Graphics Reference
In-Depth Information
in the projective spotlight PVRShaman workspace in Chapter_14/PVR_
ProjectiveSpotlight , the results of which are pictured in Figure 14-8.
Figure 14-8
Projective Spotlight Example
Projective Texturing Basics
The example uses the 2D texture image pictured in Figure 14-9 and applies
it to the surface of a teapot using projective texturing. Projective spotlights
were a very common technique used to emulate per-pixel spotlight falloff
before shaders were introduced to GPUs. Projective spotlights can still
provide an attractive solution because of their high level of efficiency.
Applying the projective texture takes just a single texture fetch instruction
in the fragment shader and some setup in the vertex shader. In addition,
the 2D texture image that is projected can contain really any picture, so
many different effects can be achieved.
What, exactly, do we mean by projective texturing? At its most basic,
projective texturing is the use of a 3D texture coordinate to look up into a 2D
texture image. The ( s , t ) coordinates are divided by the ( r ) coordinate such that
a texel is fetched using ( s/r , t/r ) . The OpenGL ES Shading Language provides a
special built-in function to do projective texturing called textureProj .
vec4 textureProj (sampler2D sampler , vec3 coord
[, float bias ])
a sampler bound to a texture unit specifying the texture to
fetch from.
sampler
a 3D texture coordinate used to fetch from the texture map.
The ( x , y ) arguments are divided by ( z ) such that the fetch
occurs at ( x/z , y/z ).
coord
an optional LOD bias to apply.
bias
 
 
 
Search WWH ::




Custom Search