bgfx/3rdparty/glsl-optimizer/tests/fragment/loop-forarounddiscard-inES.txt
2012-10-07 20:41:18 -07:00

25 lines
650 B
Text

struct v2f {
highp vec2 uv;
highp vec3 nl;
};
uniform sampler2D _MainTex;
uniform highp vec4 _TerrainTreeLightColors[4];
lowp vec4 xlat_main (in v2f i) {
highp int j = 0; // loop init before discard
lowp vec4 col = texture2D( _MainTex, i.uv);
if (col.w < 0.5)
discard;
mediump vec3 light = vec3(0.0);
for ( ; (j < 3); (j++)) { // loop body after discard
light += col.xyz * i.nl[j] * _TerrainTreeLightColors[j].xyz;
}
return vec4(light, 1.0);
}
varying highp vec2 xlv_uv;
varying highp vec3 xlv_nl;
void main() {
v2f i;
i.uv = xlv_uv;
i.nl = xlv_nl;
gl_FragData[0] = xlat_main(i);
}