Shader_Minifier
Shader_Minifier copied to clipboard
Incorrect parsing behavior in multi-if scrope
input shader
varying vec2 v_texcoordOut;
uniform sampler2D s_texture;
uniform float u_degree;
uniform float u_degree2;
void main(void)
{
vec2 texcoord = v_texcoordOut;
if(u_degree > 0.001)
{
if(u_degree2 > 0.8)
{
texcoord.x += 0.1;
}
else if(u_degree2 >0.5)
{
texcoord.y += 0.1;
}
}
gl_FragColor = texture2D(s_texture, texcoord);
}
after command
mono "$script_dir/shader_minifier.exe" -v --preserve-externals --field-names stpq -o res.h input.frag
// Generated with Shader Minifier 1.3.6 (https://github.com/laurentlb/Shader_Minifier/)
#ifndef RES_H_
# define RES_H_
const char *Basic_frag =
"precision highp float;varying vec2 v_texcoordOut;"
"uniform sampler2D s_texture;"
"uniform float u_degree,u_degree2;"
"void main()"
"{"
"vec2 f=v_texcoordOut;"
"if(u_degree>.001)"
"if(u_degree2>.8)"
"f.s+=.1;"
"else if(u_degree2>.5)"
"f.t+=.1;"
"gl_FragColor=texture2D(s_texture,f);"
"}";
#endif // RES_H_
missing scrope in ""if(u_degree>.001)""
I think the output is correct, the curly braces are not needed here.
Some machines produce compilation errors because of this approach
Can you give more information on your setup? What tool is compiling the code? Have you considered filing a bug against that tool?
As far as I can tell, the syntax is not ambiguous, it's properly defined in the spec (at least for GLSL).