cubereflectshinymap.shader

00001 varying vec3 vEye;
00002 varying vec3 vNormal;
00003 
00004 void main() 
00005 {
00006     // Get the normal and normalize
00007     vNormal = gl_NormalMatrix * gl_Normal;
00008     
00009     // Get the world space position
00010     vec4 vPos = gl_ModelViewMatrix * gl_Vertex;
00011 
00012     // Get the eye vector
00013     vEye = -vPos.xyz;
00014     
00015     //Use the first set of texture coordinates in the fragment shader 
00016     gl_TexCoord[0] = gl_MultiTexCoord0;
00017 
00018     // Transform the position to screen space
00019     gl_Position = ftransform(); 
00020 }
00021 
00022 ~~~~~
00023 
00024 varying vec3 vEye;
00025 varying vec3 vNormal;
00026 
00027 uniform float reflectivity;
00028 
00029 uniform sampler2D Texture0; // Diffuse map
00030 // uniform sampler2D Texture1; // Normal map
00031 uniform samplerCube Texture2; // Cube map
00032 // uniform sampler2D Texture3; // Shininess map
00033 // uniform sampler2D Texture4; // Emissive map
00034 
00035 void main() 
00036 {
00037     // Get the bump vector
00038     vec3 vN = normalize( vNormal );
00039 
00040     // Get the eye vector
00041     vec3 vE = normalize( vEye );
00042     
00043     // Get the reflection vector
00044     vec3 vR = reflect( vE, vN );
00045     
00046     // Put it through the matrix
00047     vR = mat3( gl_TextureMatrix[0] ) * vR;
00048     vR.x = -vR.x;
00049 
00050     // Get the value from the cubemap
00051     // gl_FragColor = 1.0;
00052     // gl_FragColor = vec4( vN.xyz * 0.5 + 0.5, 1.0 ); 
00053     gl_FragColor = textureCube( Texture2, vR.xyz );
00054     
00055     // Sample the diffuse texture
00056     vec4 tex = texture2D( Texture0, gl_TexCoord[0].xy );
00057     
00058     // Set the alpha
00059     gl_FragColor.a = reflectivity * tex.a;
00060 }

Generated on Fri Mar 23 12:55:03 2007 for glsldemo by  doxygen 1.5.1-p1