00001 varying vec3 vEye;
00002 varying vec3 vNormal;
00003
00004 void main()
00005 {
00006
00007 vNormal = gl_NormalMatrix * gl_Normal;
00008
00009
00010 vec4 vPos = gl_ModelViewMatrix * gl_Vertex;
00011
00012
00013 vEye = -vPos.xyz;
00014
00015
00016 gl_TexCoord[0] = gl_MultiTexCoord0;
00017
00018
00019 gl_Position = ftransform();
00020 }
00021
00022 ~~~~~
00023
00024 varying vec3 vEye;
00025 varying vec3 vNormal;
00026
00027 uniform float reflectivity;
00028 uniform float refractiveindex;
00029
00030 uniform sampler2D Texture0;
00031
00032 uniform samplerCube Texture2;
00033
00034
00035
00036 void main()
00037 {
00038
00039 vec3 vN = normalize( vNormal );
00040
00041
00042 vec3 vE = normalize( vEye );
00043
00044
00045 vec3 vR = reflect( vE, vN );
00046
00047
00048 vec3 vReflect = reflect( vE, vN );
00049
00050
00051 vec3 vRefract = refract( vE, -vN, 1.0 / refractiveindex );
00052
00053
00054 vReflect = mat3( gl_TextureMatrix[0] ) * vReflect;
00055 vReflect.x = -vReflect.x;
00056
00057
00058 vRefract = mat3( gl_TextureMatrix[0] ) * vRefract;
00059 vRefract.x = -vRefract.x;
00060
00061
00062 vec4 vReflectColour = textureCube( Texture2, vReflect.xyz );
00063
00064
00065 vec4 vRefractColour = textureCube( Texture2, vRefract.xyz );
00066
00067
00068 float interpolant = dot( vE, vN );
00069 if ( interpolant < 0.0 ) interpolant = -interpolant;
00070
00071
00072 interpolant = pow( 1.0 - interpolant, 2.0 );
00073
00074
00075 gl_FragColor.rgb = vReflectColour.rgb * interpolant + vRefractColour.rgb * ( 1.0 - interpolant );
00076
00077
00078 gl_FragColor.a = reflectivity;
00079 }