Bug 1918529 - fix some subpixel misalignment issues with gfx.webrender.svg-filter...
[gecko.git] / dom / canvas / test / webgl-conf / checkout / conformance / glsl / misc / shader-with-for-loop.html
blobcf11a88d9f60dcc83fd46816a708fb32f39f8f75
1 <!--
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.
5 -->
7 <!DOCTYPE html>
8 <html>
9 <head>
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>
17 </head>
18 <body>
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;
26 uniform float time;
27 uniform vec2 resolution;
29 // Saw-tooth function that is synced with the demo music (128bpm)
30 float gBeat;
32 // Calculate the surface color
33 vec3 surfColor(vec2 p)
35 vec2 q=vec2(sin(.08*p.x),4.*p.y);
36 vec3 c=vec3(0);
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,
49 t=-a-sqrt(a*a-b);
50 o+=t*d;
51 return surfColor(vec2(o.x,atan(o.y,o.z)))*(1.+.01*t);
54 void main()
56 gBeat=fract(time*3.2/3.);
57 // Screen setup
58 vec2 p=(2.*gl_FragCoord.xy-resolution)/resolution.y,
59 q=2.*gl_FragCoord.xy/resolution-1.;
61 // Camera setup
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),
64 cd=normalize(ct-cp),
65 cr=normalize(cross(cd,vec3(.5*cos(.3*time),0.,1.))),
66 cu=cross(cr,cd),
67 rd=normalize(2.*cd+cr*p.x+cu*p.y);
69 // Trace! (+some funky lens/raster effects)
70 vec3 c=trace(cp,rd)*
71 min(1.,1.8-dot(q,q))*
72 (.9+.1*sin(3.*sin(gBeat)*gl_FragCoord.y));
74 gl_FragColor=vec4(c,1);
76 </script>
77 <script>
78 "use strict";
79 GLSLConformanceTester.runTest();
80 var successfullyParsed = true;
81 </script>
82 </body>
83 </html>