Graphics Reference
In-Depth Information
v += vel*uT + 0.5*vec3(0., uGravity, 0.)*uT*uT;
gl_Position = uProjectionMatrix * vec4( v, 1. );
EmitVertex( );
}
void
main( )
{
V01 = ( gl_PositionIn[1] - gl_PositionIn[0] ).xyz;
V02 = ( gl_PositionIn[2] - gl_PositionIn[0] ).xyz;
Normal = normalize( cross( V01, V02 ) );
V0 = gl_PositionIn[0].xyz;
CG = ( gl_PositionIn[0].xyz + gl_PositionIn[1].xyz
+ gl_PositionIn[2].xyz ) / 3.;
int numLayers = 1 << uLevel;
float dt = 1. / float( numLayers );
float t = 1.;
for( int it = 0; it <= numLayers; it++ )
{
float smax = 1. - t;
int nums = it + 1;
float ds = smax / float( nums - 1 );
float s = 0.;
for( int is = 0; is < nums; is++ )
{
ProduceVertex( s, t );
s += ds;
}
t -= dt;
}
}
Exercises
1. Adapt the CD/DVD shader example to look more realistic by applying
cube-mapping as well as diffraction to add a reflection of a scene in the
colored disk. Do the same to add the reflection of sky clouds in the oil
slick.
Search WWH ::




Custom Search