Quantcast
Channel: Questions in topic: "build"
Viewing all articles
Browse latest Browse all 4084

Variant Stripping: Shader keywords are invalid outside of the Editor

$
0
0
I'm trying to strip Unity Post Process's shaders. To do so, I have a list of **unwanted** keyword and I strip incoming variants using this list in a **IPreprocessShaders**. ---------- It works perfectly when I build from the editor, I go from about 5000 variants for *Uber Shader* to about 90 variants. ---------- But when I build from the command line **nothing is stripped at all because** the list of unwanted keywords is somehow empty (it's keywords inside the list that are empty). In fact, when I check their validity before stripping the variants, they are **all invalid** if the build is being run from the command line. This is also true if I add shaders using those keywords inside the *Preloaded Shaders* list of *Graphic Settings*. ---------- The problem is that if a keyword is invalid, passing it to **ShaderKeywordSet::IsEnabled** will always return false. ---------- Here is the code that checks keywords validity. class ShaderVariantPostFXStripper : IPreprocessShaders { // Every keywords we don't want to be compiled. private ShaderKeyword[] m_ForbidenKeywords; public ShaderVariantPostFXStripper() { // Create keywords. m_ForbidenKeywords = new ShaderKeyword[] { new ShaderKeyword("GRAIN"), new ShaderKeyword("DITHERING"), new ShaderKeyword("VIGNETTE_MASKED"), new ShaderKeyword("BLOOM_LENS_DIRT"), new ShaderKeyword("USER_LUT"), new ShaderKeyword("DEPTH_OF_FIELD"), new ShaderKeyword("DEPTH_OF_FIELD_COC_VIEW") }; for (int j = 0, l = m_ForbidenKeywords.Length; j < l; ++j) { if (!m_ForbidenKeywords[j].IsValid()) Debug.LogError("[POSTFX Shader Stripper] Invalid shader keyword at index " + j); } } ... ---------- Do you have an idea of where I should take a look to fix this problem ? Or do you think this is a bug ? Thanks in advance.

Viewing all articles
Browse latest Browse all 4084

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>