OLD | NEW |
(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>GLSL atan-xy function test</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.js"> </script> |
| 37 <script src="../../resources/webgl-test-utils.js"> </script> |
| 38 <script src="../../resources/glsl-generator.js"> </script> |
| 39 </head> |
| 40 <body> |
| 41 <div id="description"></div> |
| 42 <div id="console"></div> |
| 43 <script> |
| 44 |
| 45 var piConstants = [ |
| 46 "const float kPI = 3.14159265358979323846;", |
| 47 "const float kHalfPI = (kPI * 0.5);", |
| 48 "const float k2PI = (kPI * 2.0);" |
| 49 ].join("\n"); |
| 50 |
| 51 var kPI = Math.PI; |
| 52 var kHalfPI = Math.PI * 0.5; |
| 53 var k2PI = Math.PI * 2.0; |
| 54 var atan2 = Math.atan2; // shorthand |
| 55 |
| 56 GLSLGenerator.runReferenceImageTest({ |
| 57 feature: "atan", |
| 58 args: "$(type) y, $(type) x", |
| 59 testFunc: "$(func)($(type), $(type))", |
| 60 gridRes: 8, |
| 61 tolerance: 5, |
| 62 extra: piConstants, |
| 63 tests: [ |
| 64 { |
| 65 source: ["$(output) = vec4(", |
| 66 " $(func)($(input).x + 0.1, $(input).y) / k2PI + 0.5,", |
| 67 " 0,", |
| 68 " 0,", |
| 69 " 1);"].join("\n"), |
| 70 generator: function(x, y, z, w) { |
| 71 return [ atan2(x + 0.1, y) / k2PI + 0.5, |
| 72 0, |
| 73 0, |
| 74 1 ]; |
| 75 }, |
| 76 }, |
| 77 { |
| 78 source: ["$(output) = vec4(", |
| 79 " $(func)($(input).xy + vec2(0.1, 0.1), $(input).yx) / ", |
| 80 " k2PI + vec2(0.5, 0.5),", |
| 81 " 0, 1);"].join("\n"), |
| 82 generator: function(x, y, z, w) { |
| 83 return [ atan2(x + 0.1, y) / k2PI + 0.5, |
| 84 atan2(y + 0.1, x) / k2PI + 0.5, |
| 85 0, |
| 86 1 ]; |
| 87 }, |
| 88 }, |
| 89 { |
| 90 source: ["$(output) = vec4(", |
| 91 " $(func)($(input).xyz + vec3(0.1, 0.1, 0.1), $(input).yzx) /
", |
| 92 " k2PI + vec3(0.5, 0.5, 0.5),", |
| 93 " 1);"].join("\n"), |
| 94 generator: function(x, y, z, w) { |
| 95 return [ atan2(x + 0.1, y) / k2PI + 0.5, |
| 96 atan2(y + 0.1, z) / k2PI + 0.5, |
| 97 atan2(z + 0.1, x) / k2PI + 0.5, |
| 98 1 ]; |
| 99 }, |
| 100 }, |
| 101 { |
| 102 source: ["$(output) = ", |
| 103 " $(func)($(input) + vec4(0.1, 0.1, 0.1, 0.1), $(input).wzyx)
/ ", |
| 104 " k2PI + vec4(0.5, 0.5, 0.5, 0.5);", |
| 105 ].join("\n"), |
| 106 generator: function(x, y, z, w) { |
| 107 return [ atan2(x + 0.1, w) / k2PI + 0.5, |
| 108 atan2(y + 0.1, z) / k2PI + 0.5, |
| 109 atan2(z + 0.1, y) / k2PI + 0.5, |
| 110 atan2(w + 0.1, x) / k2PI + 0.5 ]; |
| 111 }, |
| 112 }, |
| 113 ] |
| 114 }); |
| 115 successfullyParsed = true; |
| 116 </script> |
| 117 </body> |
| 118 </html> |
| 119 |
OLD | NEW |