S@P"@R?8?>\҉>333@ W@;?22/?UHH]3?!5P;=333@EGA@???'?\w kAG6};?~:-?ϻ=333@Y@KE@uniform float time; uniform float frequency; #define NUM_LIGHTS 2 varying vec3 normal, lightDir[NUM_LIGHTS], eyeVec; varying vec3 position; void main(void) { vec3 tangent; vec3 binormal; vec3 c1 = cross(gl_Normal, vec3(0.0, 0.0, 1.0)); vec3 c2 = cross(gl_Normal, vec3(0.0, 1.0, 0.0)); if(length(c1)>length(c2)) tangent = c1; else tangent = c2; tangent = normalize(tangent); //binormal = cross(tangent, gl_Normal); binormal = cross(gl_Normal, tangent); binormal = normalize(binormal); gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; normal = -normalize(gl_NormalMatrix * gl_Normal); position = gl_Vertex; int i = 0; for( i = 0; i < NUM_LIGHTS; ++i ) lightDir[i] = vec3(gl_LightSource[i].position.xyz - gl_Position.xyz); eyeVec = -gl_Position; } #define NUM_LIGHTS 2 #define SPIRCOEF 1.0 #define SPIRSIZE 0.15 #define SPIRINIT 1.0 #define EPSILON 0.000003 #define PI 3.14159265358979323846 varying vec3 normal, lightDir[NUM_LIGHTS], eyeVec; varying vec3 position; // controling constants float a = 0.70; float spiralScale = 15.0; float getPolarAngle( vec2 pos ) { float theta; if ( abs(pos.x) < EPSILON ) { if ( pos.y > 0.0 ) theta = (PI / 2); else theta = (3.0 * PI / 2.0); } else if ( pos.x > 0.0 ) { theta = atan( pos.y / pos.x ); if (pos.y < 0.0) theta += (2 * PI); } else theta = atan( pos.y / pos.x ) + PI; return theta; } /** * Real mathematic function used to compute the * visibility. */ float isDisplayed( vec3 position ) { float dist = sqrt( dot( position.xy, position.xy) ); float theta = getPolarAngle( position.xy ); return fract((exp(log(dist) / a) - theta) / (2 * PI)); } void main(void) { vec4 final_color = vec4(0.0, 0.0, 0.0, 0.0); vec3 N = normalize(normal); if (isDisplayed( position * 3 ) < SPIRSIZE *2 ) discard; final_color += gl_FrontLightModelProduct.sceneColor; int i = 0; for( i=0; i 0.0) { final_color += gl_LightSource[i].diffuse * gl_FrontMaterial.diffuse * lambertTerm; vec3 E = normalize(eyeVec); vec3 R = reflect(-L, N); float specular = pow( max(dot(R, E), 0.0), gl_FrontMaterial.shininess ); final_color += gl_LightSource[i].specular * gl_FrontMaterial.specular * specular; } } gl_FragColor = final_color; }