Playground:
https://www.babylonjs-playground.com/#6UBVLF#3
I’ve noticed that in version 3.3.0, one can add comments after #ifdef in the shader code, and it won’t affect anything. This is consistent with what I would expect in C, though I’m not an expert on the standard by any means.
In the latest version of Babylon (4.2), though, I’ve noticed that the comment actually changes whether the #ifdef is pasted in. Is this a feature or a bug? I’m not great at shaders, and I don’t know the exact standard; if this is expected behavior, perhaps a note in the changelog would be helpful, as I’ve spent hours tracking down a bug related to this.
const trivialFragmentShader = String.raw`
void main()
{
gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);
#ifdef RED // Try removing this comment
gl_FragColor = vec4(1.0, 0.0, 1.0, 1.0);
#endif
#ifdef RED
gl_FragColor.z = 0.0;
#endif
}
`;