- Home /
Is it possible to replace texture read with a constant color if texture value is "default-white"?
Is it possible to recognize in shader that texture is set as default-white and use shader preprocessor to optimize texture read with a constant color in that case?
I would like to replace texture read with a constant value if a control texture (roughness, metal & ao) of a PBR shader is default white?
Or do I need to use shader variants?
br, Pauli/kuuasema
Answer by pmerilainen · May 30, 2018 at 12:57 PM
Ok I figured out this on my own.
It seems the #pragma multi_compile ___ YOUR_CUSTOM_DIRECTIVE did the trick.
I just set the material's keyword in the custom material inspector (or in the scripts if materials are streamed/assembled dynamically).
If material's control texture is set (not null), I just set the keyword/preprocessor directive with Material.EnableKeyword() and use constant value (of white) in the #else block in the shader.