Thu, 15 Jan 2015 21:03:48 +0100
Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)
1 <!--
2 Copyright (c) 2011 The Chromium Authors. All rights reserved.
3 Use of this source code is governed by a BSD-style license that can be
4 found in the LICENSE file.
5 -->
6 <!DOCTYPE html>
7 <html>
8 <head>
9 <meta charset="utf-8">
10 <title>WebGL GLSL Conformance Tests</title>
11 <link rel="stylesheet" href="../../../resources/js-test-style.css"/>
12 <link rel="stylesheet" href="../../resources/glsl-feature-tests.css"/>
13 <script src="../../../resources/js-test-pre.js"></script>
14 <script src="../../resources/webgl-test-utils.js"></script>
15 <script src="../../resources/glsl-conformance-test.js"></script>
16 </head>
17 <body>
18 <div id="description"></div>
19 <div id="console"></div>
20 <script id="sharedVertexShader" type="text/something-not-javascript">
21 // shared vertex shader should succeed.
22 uniform mat4 viewProjection;
23 uniform vec3 worldPosition;
24 uniform vec3 nextPosition;
25 uniform float fishLength;
26 uniform float fishWaveLength;
27 uniform float fishBendAmount;
28 attribute vec4 position;
29 attribute vec2 texCoord;
30 varying vec4 v_position;
31 varying vec2 v_texCoord;
32 varying vec3 v_surfaceToLight;
33 void main() {
34 vec3 vz = normalize(worldPosition - nextPosition);
35 vec3 vx = normalize(cross(vec3(0,1,0), vz));
36 vec3 vy = cross(vz, vx);
37 mat4 orientMat = mat4(
38 vec4(vx, 0),
39 vec4(vy, 0),
40 vec4(vz, 0),
41 vec4(worldPosition, 1));
42 mat4 world = orientMat;
43 mat4 worldViewProjection = viewProjection * world;
44 mat4 worldInverseTranspose = world;
46 v_texCoord = texCoord;
47 // NOTE:If you change this you need to change the laser code to match!
48 float mult = position.z > 0.0 ?
49 (position.z / fishLength) :
50 (-position.z / fishLength * 2.0);
51 float s = sin(mult * fishWaveLength);
52 float a = sign(s);
53 float offset = pow(mult, 2.0) * s * fishBendAmount;
54 v_position = (
55 worldViewProjection *
56 (position +
57 vec4(offset, 0, 0, 0)));
58 v_surfaceToLight = (world * position).xyz;
59 gl_Position = v_position;
60 }
61 </script>
62 <script id="fragmentShaderA" type="text/something-not-javascript">
63 // shared fragment shader should succeed.
64 precision mediump float;
65 uniform vec4 lightColor;
66 varying vec4 v_position;
67 varying vec2 v_texCoord;
68 varying vec3 v_surfaceToLight;
70 uniform vec4 ambient;
71 uniform sampler2D diffuse;
72 uniform vec4 specular;
73 uniform float shininess;
74 uniform float specularFactor;
75 // #fogUniforms
77 vec4 lit(float l ,float h, float m) {
78 return vec4(1.0,
79 max(l, 0.0),
80 (l > 0.0) ? pow(max(0.0, h), m) : 0.0,
81 1.0);
82 }
83 void main() {
84 vec4 diffuseColor = texture2D(diffuse, v_texCoord);
85 vec4 normalSpec = vec4(0,0,0,0); // #noNormalMap
86 vec3 surfaceToLight = normalize(v_surfaceToLight);
87 vec3 halfVector = normalize(surfaceToLight);
88 vec4 litR = lit(1.0, 1.0, shininess);
89 vec4 outColor = vec4(
90 (lightColor * (diffuseColor * litR.y + diffuseColor * ambient +
91 specular * litR.z * specularFactor * normalSpec.a)).rgb,
92 diffuseColor.a);
93 // #fogCode
94 gl_FragColor = outColor;
95 }
96 </script>
97 <script id="fragmentShaderB" type="text/something-not-javascript">
98 // shared fragment shader should succeed.
99 precision mediump float;
100 varying vec4 v_position;
101 varying vec2 v_texCoord;
102 varying vec3 v_surfaceToLight;
104 // #fogUniforms
106 vec4 lit(float l ,float h, float m) {
107 return vec4(1.0,
108 max(l, 0.0),
109 (l > 0.0) ? pow(max(0.0, h), m) : 0.0,
110 1.0);
111 }
112 void main() {
113 vec4 normalSpec = vec4(0,0,0,0); // #noNormalMap
114 vec4 reflection = vec4(0,0,0,0); // #noReflection
115 vec3 surfaceToLight = normalize(v_surfaceToLight);
116 vec4 skyColor = vec4(0.5,0.5,1,1); // #noReflection
118 vec3 halfVector = normalize(surfaceToLight);
119 vec4 litR = lit(1.0, 1.0, 10.0);
120 vec4 outColor = vec4(mix(
121 skyColor,
122 vec4(1,2,3,4) * (litR.y + litR.z * normalSpec.a),
123 1.0 - reflection.r).rgb,
124 1.0);
125 // #fogCode
126 gl_FragColor = outColor;
127 }
128 </script>
129 <script>
130 GLSLConformanceTester.runTests([
131 { vShaderSource: document.getElementById("sharedVertexShader").text,
132 vShaderSuccess: true,
133 fShaderSource: document.getElementById("fragmentShaderA").text,
134 fShaderSuccess: true,
135 linkSuccess: true,
136 passMsg: 'shared fragment shader should succeed',
137 },
138 { vShaderSource: document.getElementById("sharedVertexShader").text,
139 vShaderSuccess: true,
140 fShaderSource: document.getElementById("fragmentShaderB").text,
141 fShaderSuccess: true,
142 linkSuccess: true,
143 passMsg: 'shared fragment shader should succeed',
144 }
145 ]);
146 successfullyParsed = true;
147 </script>
148 </body>
149 </html>