Suppose I have something like the reflection that appears in a smooth material in the standard shader. At low smoothness there is no need to read from a reflection cubemap so it can be skipped - I can do an if statement in the shader but might only slow it or I can actually just use a simpler material but that is annoying to swap material based on property values.
So what is the best option for simplicity and shader speed?
Creating a Custom Material Inspector for your shader, which can then look at the smoothness value being set for example, and can disable/enable a ReflectionCubemap keyword you’ve defined in the shader. Using “keywords” in your shader generates shader variants, and based on those shader keywords set it will run a variant that only includes the code from that specific keyword path.
1 Like