| OLD | NEW | 
|---|
| (Empty) |  | 
|  | 1 | 
|  | 2 /* | 
|  | 3 ** Copyright (c) 2012 The Khronos Group Inc. | 
|  | 4 ** | 
|  | 5 ** Permission is hereby granted, free of charge, to any person obtaining a | 
|  | 6 ** copy of this software and/or associated documentation files (the | 
|  | 7 ** "Materials"), to deal in the Materials without restriction, including | 
|  | 8 ** without limitation the rights to use, copy, modify, merge, publish, | 
|  | 9 ** distribute, sublicense, and/or sell copies of the Materials, and to | 
|  | 10 ** permit persons to whom the Materials are furnished to do so, subject to | 
|  | 11 ** the following conditions: | 
|  | 12 ** | 
|  | 13 ** The above copyright notice and this permission notice shall be included | 
|  | 14 ** in all copies or substantial portions of the Materials. | 
|  | 15 ** | 
|  | 16 ** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | 
|  | 17 ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | 
|  | 18 ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | 
|  | 19 ** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY | 
|  | 20 ** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | 
|  | 21 ** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | 
|  | 22 ** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. | 
|  | 23 */ | 
|  | 24 | 
|  | 25 | 
|  | 26 /* The following files are direct copies of each other: | 
|  | 27  * | 
|  | 28  *   GL/acos/acos_vec2_frag_xvary_ref.frag | 
|  | 29  *   GL/asin/asin_vec2_frag_xvary_ref.frag | 
|  | 30  * | 
|  | 31  * Care should be taken to apply any changes to both.  Only the last | 
|  | 32  * line where gl_FragColor is assigned should be different. | 
|  | 33  */ | 
|  | 34 | 
|  | 35 #ifdef GL_ES | 
|  | 36 precision mediump float; | 
|  | 37 #endif | 
|  | 38 varying vec4 color; | 
|  | 39 | 
|  | 40 float lerp(float a, float b, float s) | 
|  | 41 { | 
|  | 42         return a + (b - a) * s; | 
|  | 43 } | 
|  | 44 | 
|  | 45 void main (void) | 
|  | 46 { | 
|  | 47         float asinValues[17]; | 
|  | 48         asinValues[0] = -1.5708; | 
|  | 49         asinValues[1] = -1.06544; | 
|  | 50         asinValues[2] = -0.848062; | 
|  | 51         asinValues[3] = -0.675132; | 
|  | 52         asinValues[4] = -0.523599; | 
|  | 53         asinValues[5] = -0.384397; | 
|  | 54         asinValues[6] = -0.25268; | 
|  | 55         asinValues[7] = -0.125328; | 
|  | 56         asinValues[8] = 0.0; | 
|  | 57         asinValues[9] = 0.125328; | 
|  | 58         asinValues[10] = 0.25268; | 
|  | 59         asinValues[11] = 0.384397; | 
|  | 60         asinValues[12] = 0.523599; | 
|  | 61         asinValues[13] = 0.675132; | 
|  | 62         asinValues[14] = 0.848062; | 
|  | 63         asinValues[15] = 1.06544; | 
|  | 64         asinValues[16] = 1.5708; | 
|  | 65 | 
|  | 66         const float M_PI = 3.14159265358979323846; | 
|  | 67         vec2 c = 2.0 * (color.rg - 0.5); | 
|  | 68 | 
|  | 69         vec2 arrVal = (c + vec2(1.0, 1.0)) * 8.0; | 
|  | 70         int arr0x = int(floor(arrVal.x)); | 
|  | 71         int arr0y = int(floor(arrVal.y)); | 
|  | 72         vec2 weight = arrVal - floor(arrVal); | 
|  | 73         vec2 asin_c = vec2(0.0); | 
|  | 74 | 
|  | 75         if (arr0x == 0) | 
|  | 76                 asin_c.x = lerp(asinValues[0], asinValues[1], weight.x); | 
|  | 77         else if (arr0x == 1) | 
|  | 78                 asin_c.x = lerp(asinValues[1], asinValues[2], weight.x); | 
|  | 79         else if (arr0x == 2) | 
|  | 80                 asin_c.x = lerp(asinValues[2], asinValues[3], weight.x); | 
|  | 81         else if (arr0x == 3) | 
|  | 82                 asin_c.x = lerp(asinValues[3], asinValues[4], weight.x); | 
|  | 83         else if (arr0x == 4) | 
|  | 84                 asin_c.x = lerp(asinValues[4], asinValues[5], weight.x); | 
|  | 85         else if (arr0x == 5) | 
|  | 86                 asin_c.x = lerp(asinValues[5], asinValues[6], weight.x); | 
|  | 87         else if (arr0x == 6) | 
|  | 88                 asin_c.x = lerp(asinValues[6], asinValues[7], weight.x); | 
|  | 89         else if (arr0x == 7) | 
|  | 90                 asin_c.x = lerp(asinValues[7], asinValues[8], weight.x); | 
|  | 91         else if (arr0x == 8) | 
|  | 92                 asin_c.x = lerp(asinValues[8], asinValues[9], weight.x); | 
|  | 93         else if (arr0x == 9) | 
|  | 94                 asin_c.x = lerp(asinValues[9], asinValues[10], weight.x); | 
|  | 95         else if (arr0x == 10) | 
|  | 96                 asin_c.x = lerp(asinValues[10], asinValues[11], weight.x); | 
|  | 97         else if (arr0x == 11) | 
|  | 98                 asin_c.x = lerp(asinValues[11], asinValues[12], weight.x); | 
|  | 99         else if (arr0x == 12) | 
|  | 100                 asin_c.x = lerp(asinValues[12], asinValues[13], weight.x); | 
|  | 101         else if (arr0x == 13) | 
|  | 102                 asin_c.x = lerp(asinValues[13], asinValues[14], weight.x); | 
|  | 103         else if (arr0x == 14) | 
|  | 104                 asin_c.x = lerp(asinValues[14], asinValues[15], weight.x); | 
|  | 105         else if (arr0x == 15) | 
|  | 106                 asin_c.x = lerp(asinValues[15], asinValues[16], weight.x); | 
|  | 107         else if (arr0x == 16) | 
|  | 108                 asin_c.x = asinValues[16]; | 
|  | 109 | 
|  | 110         if (arr0y == 0) | 
|  | 111                 asin_c.y = lerp(asinValues[0], asinValues[1], weight.y); | 
|  | 112         else if (arr0y == 1) | 
|  | 113                 asin_c.y = lerp(asinValues[1], asinValues[2], weight.y); | 
|  | 114         else if (arr0y == 2) | 
|  | 115                 asin_c.y = lerp(asinValues[2], asinValues[3], weight.y); | 
|  | 116         else if (arr0y == 3) | 
|  | 117                 asin_c.y = lerp(asinValues[3], asinValues[4], weight.y); | 
|  | 118         else if (arr0y == 4) | 
|  | 119                 asin_c.y = lerp(asinValues[4], asinValues[5], weight.y); | 
|  | 120         else if (arr0y == 5) | 
|  | 121                 asin_c.y = lerp(asinValues[5], asinValues[6], weight.y); | 
|  | 122         else if (arr0y == 6) | 
|  | 123                 asin_c.y = lerp(asinValues[6], asinValues[7], weight.y); | 
|  | 124         else if (arr0y == 7) | 
|  | 125                 asin_c.y = lerp(asinValues[7], asinValues[8], weight.y); | 
|  | 126         else if (arr0y == 8) | 
|  | 127                 asin_c.y = lerp(asinValues[8], asinValues[9], weight.y); | 
|  | 128         else if (arr0y == 9) | 
|  | 129                 asin_c.y = lerp(asinValues[9], asinValues[10], weight.y); | 
|  | 130         else if (arr0y == 10) | 
|  | 131                 asin_c.y = lerp(asinValues[10], asinValues[11], weight.y); | 
|  | 132         else if (arr0y == 11) | 
|  | 133                 asin_c.y = lerp(asinValues[11], asinValues[12], weight.y); | 
|  | 134         else if (arr0y == 12) | 
|  | 135                 asin_c.y = lerp(asinValues[12], asinValues[13], weight.y); | 
|  | 136         else if (arr0y == 13) | 
|  | 137                 asin_c.y = lerp(asinValues[13], asinValues[14], weight.y); | 
|  | 138         else if (arr0y == 14) | 
|  | 139                 asin_c.y = lerp(asinValues[14], asinValues[15], weight.y); | 
|  | 140         else if (arr0y == 15) | 
|  | 141                 asin_c.y = lerp(asinValues[15], asinValues[16], weight.y); | 
|  | 142         else if (arr0y == 16) | 
|  | 143                 asin_c.y = asinValues[16]; | 
|  | 144 | 
|  | 145         // acos(x) = PI/2 - asin(x) | 
|  | 146         gl_FragColor = vec4(0.5 - asin_c / M_PI, 0.0, 1.0); | 
|  | 147 } | 
| OLD | NEW | 
|---|