2 Copyright (c) 2019 The Khronos Group Inc.
3 Use of this source code is governed by an MIT-style license that can be
4 found in the LICENSE.txt file.
10 <meta charset=
"utf-8">
11 <title>WebGL GLSL Conformance Tests
</title>
12 <link rel=
"stylesheet" href=
"../../../resources/js-test-style.css"/>
13 <link rel=
"stylesheet" href=
"../../../resources/glsl-feature-tests.css"/>
14 <script src=
"../../../js/js-test-pre.js"></script>
15 <script src=
"../../../js/webgl-test-utils.js"></script>
16 <script src=
"../../../js/glsl-conformance-test.js"></script>
19 <div id=
"description"></div>
20 <div id=
"console"></div>
21 <script id=
"fragmentShader" type=
"text/something-not-javascript">
22 // fragment shader with for loop should succeed
24 // TODO(gman): trim to min size to test bug.
25 precision mediump float;
27 uniform vec2 resolution;
29 // Saw-tooth function that is synced with the demo music (
128bpm)
32 // Calculate the surface color
33 vec3 surfColor(vec2 p)
35 vec2 q=vec2(sin(
.08*p.x),
4.*p.y);
37 for(float i=
0.;i
<15.;i++)
38 c+=(
1.+sin(i*sin(time)+vec3(
0.,
1.3,
2.2)))*
.2/length(q-vec2(sin(i),
12.*sin(
.3*time+i)));
39 return c+vec3(mix(mod(floor(p.x*
.2)+floor(p.y*
2.2),
2.),
.2,gBeat));
42 // Ray trace (cylinder)
43 vec3 trace(vec3 o,vec3 d)
45 d.y*=
.65+
.1*sin(
.5*time);
46 float D=
1./(d.y*d.y+d.z*d.z),
47 a=(o.y*d.y+o.z*d.z)*D,
48 b=(o.y*o.y+o.z*o.z-
36.)*D,
51 return surfColor(vec2(o.x,atan(o.y,o.z)))*(
1.+
.01*t);
56 gBeat=fract(time*
3.2/
3.);
58 vec2 p=(
2.*gl_FragCoord.xy-resolution)/resolution.y,
59 q=
2.*gl_FragCoord.xy/resolution-
1.;
62 vec3 cp=vec3(-time*
20.+
1.,
1.6*sin(time*
1.2),
2.+
2.*cos(time*
.3)),
63 ct=cp+vec3(
1.,
.3*cos(time),-
.2),
65 cr=normalize(cross(cd,vec3(
.5*cos(
.3*time),
0.,
1.))),
67 rd=normalize(
2.*cd+cr*p.x+cu*p.y);
69 // Trace! (+some funky lens/raster effects)
72 (
.9+
.1*sin(
3.*sin(gBeat)*gl_FragCoord.y));
74 gl_FragColor=vec4(c,
1);
79 GLSLConformanceTester
.runTest();
80 var successfullyParsed
= true;