Graphics Reference
In-Depth Information
Sang = sin(uAng);
vec2 stp; // st' = st rotated by -Ang
stp.s = st.s*Cang + st.t*Sang;
stp.t = -st.s*Sang + st.t*Cang;
float theta = atan( stp.t, stp.s );
// this is the normal of the parts of the object
// that are not in a pyramid:
vec3 normal = ToXyz( vec3( 0., 0., 1. ) );
// figure out what part of the pyramid we are in and
// get the normal there; then transform it to eye cords
if( abs(stp.s) > Swidth/4. || abs(stp.t) > Theight/4. )
{
normal = ToXyz( vec3( 0., 0., 1. ) );
}
else
{
if( PI/4. <= theta && theta <= 3.*PI/4. )
{
normal = ToXyz( vec3( 0., uHeight, Theight/4. ) );
}
else if( -PI/4. <= theta && theta <= PI/4. )
{
normal = ToXyz( vec3( uHeight, 0., Swidth/4. ) );
}
else if( -3.*PI/4. <= theta && theta <= -PI/4. )
{
normal = ToXyz( vec3( 0., -uHeight, Theight/4. ) );
}
else if( theta >= 3.*PI/4. || theta <= -3.*PI/4. )
{
normal = ToXyz( vec3( -uHeight, 0., Swidth/4. ) );
}
}
float intensity = uAmbient + (1.-uAmbient)*
dot(normal, vLightDir);
vec3 litColor = uSurfaceColor.rgb * intensity;
fFragColor = vec4( litColor, uSurfaceColor.a );
}
Cube Maps
Cube maps are textures that simulate the effect of an environment that sur-
rounds the 3D scene, and are usually used to create reflection or refraction
Search WWH ::




Custom Search