I’m having some issues with conditional compilation in a custom shader. My code looks something like this:
#if SHADER_TARGET >= 40
#pragma target 4.0
// Some code here that needs SM 4.0
#else
#pragma target 3.0
// Simplified version of code that works on SM 3.0
#endif
This compiles without errors, but it seems to always take the 4.0 compilation path unless I manually set graphics emulation to SM 3.0. Part of the SM 4.0 code is a geometry shader, and even though it’s inside conditional compilation, Unity warns that the shader includes geometry shader features and forces the target to 4.0 (this is very specifically mentioned in the console log).
The behavior of the conditional compile seems to be independent of my target build platform. I would expect that when scripts are compiled for a specific build target, the SHADER_TARGET macro would be set to the level that exists on that target. Or am I doing something wrong?
Unity version is 2017.2.0f3.
Thanks for any knowledge input here.