glsl-mat4-to-mat3.html (1725B)
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 --> 6 7 <!DOCTYPE html> 8 <html> 9 <head> 10 <meta charset="utf-8"> 11 <title>GLSL mat4 to mat3 test</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-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 "use strict"; 44 // See resources glsl-generator runBasicTest for how this works 45 var wtu = WebGLTestUtils; 46 GLSLGenerator.runBasicTest({ 47 gridRes: 8, 48 tests: [ 49 { 50 name: "mat4 to mat3", 51 reference: { 52 shader: wtu.getScript("shader_test"), 53 subs: { 54 emu: wtu.getScript("shader_emu"), 55 conversion: "mat3_emu" 56 } 57 }, 58 test: { 59 shader: wtu.getScript("shader_test"), 60 subs: { 61 conversion: "mat3" 62 }, 63 } 64 } 65 ] 66 }); 67 var successfullyParsed = true; 68 </script> 69 </body> 70 </html>