Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8" >
- <title>Rotating Square</title>
- <script id="vertex-shader" type="x-shader/x-vertex">
- attribute vec4 vPosition;
- uniform float theta;
- void
- main()
- {
- float s = 0.3*sin( theta );
- float c = 0.4 * cos( theta );
- gl_Position.x = -s * vPosition.y + c * vPosition.x + 0.4*sin(theta);
- gl_Position.y = s * vPosition.x + c * vPosition.y + 0.4*cos(theta);
- gl_Position.z = 0.0;
- gl_Position.w = 1.0;
- }
- </script>
- <script id="fragment-shader" type="x-shader/x-fragment">
- precision mediump float;
- void
- main()
- {
- float rateX = 3.0;
- float rateY = 5.0;
- float sinScaleX = 10.0;
- float sinScaleY = 300.0;
- float lerpValue = gl_FragCoord.y / 500.0;
- lerpValue = cos(lerpValue*sinScaleY);
- if (lerpValue>0.3) lerpValue = 0.5*lerpValue;
- float lerpValue2 = gl_FragCoord.x / 500.0;
- lerpValue2 = sin(lerpValue2*sinScaleX);
- if (lerpValue2>.7) lerpValue2 = 0.5*lerpValue2;
- gl_FragColor = rateY * mix(vec4(12/255, 53/255, 169/255, 1.0), vec4(0.3, 0.3, 0.0, 1.0), lerpValue)
- + rateX * mix(vec4(1.5, 0.2, 0.3, 1.0), vec4(0.4, 0.4, 0.2, 1.0), lerpValue2);
- }
- </script>
- <script type="text/javascript" src="../Common/webgl-utils.js"></script>
- <script type="text/javascript" src="../Common/initShaders.js"></script>
- <script type="text/javascript" src="../Common/MV.js"></script>
- <script type="text/javascript" src="rotatingSquare1.js"></script>
- </head>
- <body>
- <canvas id="gl-canvas" width="1024" height="1024">
- Oops ... your browser doesn't support the HTML5 canvas element
- </canvas>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement