Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(759)

Side by Side Diff: third_party/webgl/sdk/tests/conformance/glsl/misc/shared.html

Issue 10399113: Roll webgl conformance tests to r17874: part 2, adding r17874 (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 <!--
2
3 /*
4 ** Copyright (c) 2012 The Khronos Group Inc.
5 **
6 ** Permission is hereby granted, free of charge, to any person obtaining a
7 ** copy of this software and/or associated documentation files (the
8 ** "Materials"), to deal in the Materials without restriction, including
9 ** without limitation the rights to use, copy, modify, merge, publish,
10 ** distribute, sublicense, and/or sell copies of the Materials, and to
11 ** permit persons to whom the Materials are furnished to do so, subject to
12 ** the following conditions:
13 **
14 ** The above copyright notice and this permission notice shall be included
15 ** in all copies or substantial portions of the Materials.
16 **
17 ** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 ** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 ** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 ** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 ** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
24 */
25
26 -->
27
28 <!DOCTYPE html>
29 <html>
30 <head>
31 <meta charset="utf-8">
32 <title>WebGL GLSL Conformance Tests</title>
33 <link rel="stylesheet" href="../../../resources/js-test-style.css"/>
34 <link rel="stylesheet" href="../../resources/glsl-feature-tests.css"/>
35 <script src="../../../resources/js-test-pre.js"></script>
36 <script src="../../resources/webgl-test-utils.js"></script>
37 <script src="../../resources/glsl-conformance-test.js"></script>
38 </head>
39 <body>
40 <div id="description"></div>
41 <div id="console"></div>
42 <script id="sharedVertexShader" type="text/something-not-javascript">
43 // shared vertex shader should succeed.
44 uniform mat4 viewProjection;
45 uniform vec3 worldPosition;
46 uniform vec3 nextPosition;
47 uniform float fishLength;
48 uniform float fishWaveLength;
49 uniform float fishBendAmount;
50 attribute vec4 position;
51 attribute vec2 texCoord;
52 varying vec4 v_position;
53 varying vec2 v_texCoord;
54 varying vec3 v_surfaceToLight;
55 void main() {
56 vec3 vz = normalize(worldPosition - nextPosition);
57 vec3 vx = normalize(cross(vec3(0,1,0), vz));
58 vec3 vy = cross(vz, vx);
59 mat4 orientMat = mat4(
60 vec4(vx, 0),
61 vec4(vy, 0),
62 vec4(vz, 0),
63 vec4(worldPosition, 1));
64 mat4 world = orientMat;
65 mat4 worldViewProjection = viewProjection * world;
66 mat4 worldInverseTranspose = world;
67
68 v_texCoord = texCoord;
69 // NOTE:If you change this you need to change the laser code to match!
70 float mult = position.z > 0.0 ?
71 (position.z / fishLength) :
72 (-position.z / fishLength * 2.0);
73 float s = sin(mult * fishWaveLength);
74 float a = sign(s);
75 float offset = pow(mult, 2.0) * s * fishBendAmount;
76 v_position = (
77 worldViewProjection *
78 (position +
79 vec4(offset, 0, 0, 0)));
80 v_surfaceToLight = (world * position).xyz;
81 gl_Position = v_position;
82 }
83 </script>
84 <script id="fragmentShaderA" type="text/something-not-javascript">
85 // shared fragment shader should succeed.
86 precision mediump float;
87 uniform vec4 lightColor;
88 varying vec4 v_position;
89 varying vec2 v_texCoord;
90 varying vec3 v_surfaceToLight;
91
92 uniform vec4 ambient;
93 uniform sampler2D diffuse;
94 uniform vec4 specular;
95 uniform float shininess;
96 uniform float specularFactor;
97 // #fogUniforms
98
99 vec4 lit(float l ,float h, float m) {
100 return vec4(1.0,
101 max(l, 0.0),
102 (l > 0.0) ? pow(max(0.0, h), m) : 0.0,
103 1.0);
104 }
105 void main() {
106 vec4 diffuseColor = texture2D(diffuse, v_texCoord);
107 vec4 normalSpec = vec4(0,0,0,0); // #noNormalMap
108 vec3 surfaceToLight = normalize(v_surfaceToLight);
109 vec3 halfVector = normalize(surfaceToLight);
110 vec4 litR = lit(1.0, 1.0, shininess);
111 vec4 outColor = vec4(
112 (lightColor * (diffuseColor * litR.y + diffuseColor * ambient +
113 specular * litR.z * specularFactor * normalSpec.a)).rgb,
114 diffuseColor.a);
115 // #fogCode
116 gl_FragColor = outColor;
117 }
118 </script>
119 <script id="fragmentShaderB" type="text/something-not-javascript">
120 // shared fragment shader should succeed.
121 precision mediump float;
122 varying vec4 v_position;
123 varying vec2 v_texCoord;
124 varying vec3 v_surfaceToLight;
125
126 // #fogUniforms
127
128 vec4 lit(float l ,float h, float m) {
129 return vec4(1.0,
130 max(l, 0.0),
131 (l > 0.0) ? pow(max(0.0, h), m) : 0.0,
132 1.0);
133 }
134 void main() {
135 vec4 normalSpec = vec4(0,0,0,0); // #noNormalMap
136 vec4 reflection = vec4(0,0,0,0); // #noReflection
137 vec3 surfaceToLight = normalize(v_surfaceToLight);
138 vec4 skyColor = vec4(0.5,0.5,1,1); // #noReflection
139
140 vec3 halfVector = normalize(surfaceToLight);
141 vec4 litR = lit(1.0, 1.0, 10.0);
142 vec4 outColor = vec4(mix(
143 skyColor,
144 vec4(1,2,3,4) * (litR.y + litR.z * normalSpec.a),
145 1.0 - reflection.r).rgb,
146 1.0);
147 // #fogCode
148 gl_FragColor = outColor;
149 }
150 </script>
151 <script>
152 GLSLConformanceTester.runTests([
153 { vShaderSource: document.getElementById("sharedVertexShader").text,
154 vShaderSuccess: true,
155 fShaderSource: document.getElementById("fragmentShaderA").text,
156 fShaderSuccess: true,
157 linkSuccess: true,
158 passMsg: 'shared fragment shader should succeed',
159 },
160 { vShaderSource: document.getElementById("sharedVertexShader").text,
161 vShaderSuccess: true,
162 fShaderSource: document.getElementById("fragmentShaderB").text,
163 fShaderSuccess: true,
164 linkSuccess: true,
165 passMsg: 'shared fragment shader should succeed',
166 }
167 ]);
168 successfullyParsed = true;
169 </script>
170 </body>
171 </html>
172
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698