bgfx/3rdparty/glsl-optimizer/tests/fragment/loop-forvariants-in.txt
2014-02-10 23:06:13 -08:00

22 lines
580 B
Plaintext

uniform sampler2D mainTex;
varying vec2 uv;
void main()
{
vec4 c = vec4(0.0);
// various loop forms
for (int i = 0; i < 100; ++i)
c.x += texture2D (mainTex, uv + vec2(i,i)).r;
for (int i = 0; i <= 100; i += 3)
c.x += texture2D (mainTex, uv + vec2(i,i)).r;
for (int i = 100; i >= 0; --i)
c.x += texture2D (mainTex, uv + vec2(i,i)).r;
int n = int(c.x * 10.0);
for (int i = 3; i < n; ++i)
c.x += texture2D (mainTex, uv + vec2(i,i)).r;
for (int i = 1, j = 2; i < 100 && j < 50; i += 2, j += 3)
c.x += texture2D (mainTex, uv + vec2(i,j)).r;
gl_FragColor = c;
}