
288 7. Real-time 3D: OpenGL
const float d=0.01;
// Assumes gray color, get value
float y1 = (texture2D(Rsf, TexCoord+vec2( 0.0, d)).r);
// above and below sample point.
float y2 = (texture2D(Rsf, TexCoord+vec2( 0.0,-d)).r);
// and to left
float x1 = (texture2D(Rsf, TexCoord+vec2( d, 0.0)).r);
// and right
float x2 = (texture2D(Rsf, TexCoord+vec2(-d, 0.0)).r);
vec3 normDelta=normalize(vec3((y2-y1)*Gradient,
(x1-x2)*Gradient,1.0));
Procedural textu res It is in the area of pro ced u r al textures that the real p ower of
the programmable GPU becomes evident. M or e or less any texture that can be
described algorithmically can be programmed into the GPU and