glsl-function-atan-xy.html (2878B)
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 atan-xy function 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> 22 "use strict"; 23 24 var piConstants = [ 25 "const float kPI = 3.14159265358979323846;", 26 "const float kHalfPI = (kPI * 0.5);", 27 "const float k2PI = (kPI * 2.0);" 28 ].join("\n"); 29 30 var kPI = Math.PI; 31 var kHalfPI = Math.PI * 0.5; 32 var k2PI = Math.PI * 2.0; 33 var atan2 = Math.atan2; // shorthand 34 35 GLSLGenerator.runReferenceImageTest({ 36 feature: "atan", 37 args: "$(type) y, $(type) x", 38 testFunc: "$(func)($(type), $(type))", 39 gridRes: 8, 40 tolerance: 5, 41 extra: piConstants, 42 tests: [ 43 { 44 source: ["$(output) = vec4(", 45 " $(func)($(input).x + 0.1, $(input).y) / k2PI + 0.5,", 46 " 0,", 47 " 0,", 48 " 1);"].join("\n"), 49 generator: function(x, y, z, w) { 50 return [ atan2(x + 0.1, y) / k2PI + 0.5, 51 0, 52 0, 53 1 ]; 54 }, 55 }, 56 { 57 source: ["$(output) = vec4(", 58 " $(func)($(input).xy + vec2(0.1, 0.1), $(input).yx) / ", 59 " k2PI + vec2(0.5, 0.5),", 60 " 0, 1);"].join("\n"), 61 generator: function(x, y, z, w) { 62 return [ atan2(x + 0.1, y) / k2PI + 0.5, 63 atan2(y + 0.1, x) / k2PI + 0.5, 64 0, 65 1 ]; 66 }, 67 }, 68 { 69 source: ["$(output) = vec4(", 70 " $(func)($(input).xyz + vec3(0.1, 0.1, 0.1), $(input).yzx) / ", 71 " k2PI + vec3(0.5, 0.5, 0.5),", 72 " 1);"].join("\n"), 73 generator: function(x, y, z, w) { 74 return [ atan2(x + 0.1, y) / k2PI + 0.5, 75 atan2(y + 0.1, z) / k2PI + 0.5, 76 atan2(z + 0.1, x) / k2PI + 0.5, 77 1 ]; 78 }, 79 }, 80 { 81 source: ["$(output) = ", 82 " $(func)($(input) + vec4(0.1, 0.1, 0.1, 0.1), $(input).wzyx) / ", 83 " k2PI + vec4(0.5, 0.5, 0.5, 0.5);", 84 ].join("\n"), 85 generator: function(x, y, z, w) { 86 return [ atan2(x + 0.1, w) / k2PI + 0.5, 87 atan2(y + 0.1, z) / k2PI + 0.5, 88 atan2(z + 0.1, y) / k2PI + 0.5, 89 atan2(w + 0.1, x) / k2PI + 0.5 ]; 90 }, 91 }, 92 ] 93 }); 94 var successfullyParsed = true; 95 </script> 96 </body> 97 </html>