|
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>GLSL mat4 to mat3 test</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.js"> </script> |
|
15 <script src="../../resources/webgl-test-utils.js"> </script> |
|
16 <script src="../../resources/glsl-generator.js"> </script> |
|
17 </head> |
|
18 <body> |
|
19 <div id="description"></div> |
|
20 <div id="console"></div> |
|
21 <script id="shader_emu" type="something-not-js"> |
|
22 mat3 mat3_emu(mat4 m4) { |
|
23 return mat3( |
|
24 m4[0][0], m4[0][1], m4[0][2], |
|
25 m4[1][0], m4[1][1], m4[1][2], |
|
26 m4[2][0], m4[2][1], m4[2][2]); |
|
27 } |
|
28 </script> |
|
29 <script id="shader_test" type="something-not-js"> |
|
30 mat4 m4 = mat4($(input), $(input).yzwx, $(input).zwxy, $(input).wxyz); |
|
31 mat3 m3 = $(conversion)(m4); |
|
32 vec3 c; |
|
33 if ($(input).y < 0.33) { |
|
34 c = m3[0]; |
|
35 } else if ($(input).y > 0.66) { |
|
36 c = m3[1]; |
|
37 } else { |
|
38 c = m3[2]; |
|
39 } |
|
40 $(output) = vec4(c, 1); |
|
41 </script> |
|
42 <script> |
|
43 // See resources glsl-generator runBasicTest for how this works |
|
44 var wtu = WebGLTestUtils; |
|
45 GLSLGenerator.runBasicTest({ |
|
46 gridRes: 8, |
|
47 tests: [ |
|
48 { |
|
49 name: "mat4 to mat3", |
|
50 reference: { |
|
51 shader: wtu.getScript("shader_test"), |
|
52 subs: { |
|
53 emu: wtu.getScript("shader_emu"), |
|
54 conversion: "mat3_emu" |
|
55 } |
|
56 }, |
|
57 test: { |
|
58 shader: wtu.getScript("shader_test"), |
|
59 subs: { |
|
60 conversion: "mat3" |
|
61 }, |
|
62 } |
|
63 } |
|
64 ] |
|
65 }); |
|
66 successfullyParsed = true; |
|
67 </script> |
|
68 </body> |
|
69 </html> |
|
70 |