Shader_Minifier
Shader_Minifier copied to clipboard
fail: variables with a same name, ifdef preprocessor branching
Related: #28
Input
void main() {
#ifdef CONDITION
vec3 col = vec3( 1.0 );
#else
vec3 col = vec3( 0.0 );
#endif
gl_FragColor = vec4( col, 1.0 );
}
Actual
void main(){
#ifdef CONDITION
vec3 C=vec3(1.);
#else
vec3 r=vec3(0.);
#endif
gl_FragColor=vec4(r,1.);}
Expected
void main(){
#ifdef CONDITION
vec3 C=vec3(1.);
#else
vec3 C=vec3(0.);
#endif
gl_FragColor=vec4(C,1.);}
Here, the workaround can be to declare the variable before the macro:
void main() {
vec3 col;
#ifdef CONDITION
col = vec3( 1.0 );
#else
col = vec3( 0.0 );
#endif
gl_FragColor = vec4( col, 1.0 );
}
yes I'm using that workaround right now.