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 attribute vec4 gtf_Color; |
| 27 attribute vec4 gtf_Vertex; |
| 28 uniform mat4 gtf_ModelViewProjectionMatrix; |
| 29 varying vec4 color; |
| 30 |
| 31 float lerp(float a, float b, float s) |
| 32 { |
| 33 return a + (b - a) * s; |
| 34 } |
| 35 |
| 36 void main (void) |
| 37 { |
| 38 float sinValues[17]; |
| 39 sinValues[0] = 0.0; |
| 40 sinValues[1] = 0.382683; |
| 41 sinValues[2] = 0.707107; |
| 42 sinValues[3] = 0.92388; |
| 43 sinValues[4] = 1.0; |
| 44 sinValues[5] = 0.92388; |
| 45 sinValues[6] = 0.707107; |
| 46 sinValues[7] = 0.382683; |
| 47 sinValues[8] = 0.0; |
| 48 sinValues[9] = -0.382683; |
| 49 sinValues[10] = -0.707107; |
| 50 sinValues[11] = -0.92388; |
| 51 sinValues[12] = -1.0; |
| 52 sinValues[13] = -0.923879; |
| 53 sinValues[14] = -0.707107; |
| 54 sinValues[15] = -0.382683; |
| 55 sinValues[16] = 0.0; |
| 56 |
| 57 const float M_PI = 3.14159265358979323846; |
| 58 vec3 c = 2.0 * M_PI * gtf_Color.rgb; |
| 59 float sign = 1.0; |
| 60 |
| 61 vec3 sin_c = vec3(0.0); |
| 62 float fact; |
| 63 float fact_of; |
| 64 |
| 65 // Taylors series expansion for sin |
| 66 for(int i = 0; i < 12; i++) |
| 67 { |
| 68 fact = 1.0; |
| 69 for(int j = 2; j <= 23; j++) |
| 70 if (j <= 2 * i + 1) |
| 71 fact *= float(j); |
| 72 |
| 73 sin_c += sign * pow(c, vec3(2.0 * float(i) + 1.0)) / fact; |
| 74 sign *= -1.0; |
| 75 } |
| 76 |
| 77 color = vec4(0.5 * sin_c + 0.5, 1.0); |
| 78 gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex; |
| 79 } |
OLD | NEW |