Presentation is loading. Please wait.

Presentation is loading. Please wait.

Projective Texture Mapping. Projective Textures Use to simulate effects: Slide projectors Spotlight illuminations Shadows Reprojection of images.

Similar presentations


Presentation on theme: "Projective Texture Mapping. Projective Textures Use to simulate effects: Slide projectors Spotlight illuminations Shadows Reprojection of images."— Presentation transcript:

1 Projective Texture Mapping

2 Projective Textures Use to simulate effects: Slide projectors Spotlight illuminations Shadows Reprojection of images

3 Texture Projection Very similar to projecting the objects to the screen But now we will project the scene to the light source (or the slide projector, for example) The key is to calculate the texture coordinates of the projection receiver camera Slide projector image plane Projection geometry

4 Calculate the Texture Coordinates Main idea – Project the objects to the “image plane” of the projector and use the projector’s NDC to calculate the texture coordinates projector objects Projection projector objects Projection

5 Calculate the Texture Coordinates Use OpenGL’s texgen function and set it to GL_OBJECT_LINEAR Construct the texture matrix as a concatenation of (M_t = T * P * M) M: Modelview (set the projector’s view using gluLookAt) P: Projection (set the projector’s “camera” parameters) T: Bias and Scale: transform from projector’s NDC [-1,1] to [0,1] to look up texture

6 Things to pay attention: Need to make sure that only the objects meant to receive the projected texture will render with the texture (not every object in the scene) Need to use 4D texture coordinates to ensure correct perspective projection

7 Example Code Note that in this example we are using GL_EYE_LINEAR, but it is okay As long as you remember to transform the eye space back to object space first (next page to continue)

8 Example Code … //draw the scene …

9 Spotlight illumination The OpenGL’s spot light feature requires us to tessellate the polygons The main idea – project the texture to the scene from the light as a illumination mask Regular point light source is used

10 Algorithm Drawing the scene with depth buffering enabled and color buffer write disabled Load and enable the spotlight texture and use GL_MODULATE to map the texture Enable texture coordinate geneartion and load the texture matrix Enable blending and use GL_ONE, GL_ONE for the blending function Disable depth buffer write, set the depth function to GL_EQUAL Draw the scene with the vertex color set to the spot light color Disable the spot light texture, texgen, and texture transformation Set the blend function to GL_DST_COLOR Draw the scene with normal diffuse and specular light

11 Using textures for contouring Remember the texture coodinates are generated as: s = Ax + By + Cz+ Dw (same for t, r, q if needed), where A, B, C, D are user specified parameters, and x,y,z,w can be either object space or eye space position This can be used to measure the distance to the plane Ax+By+Cz+D when w = 1 If we simply apply a 1D texture from the generated texture coordinate S (below), then you are making the object based on its distance to a particular plane

12 Examples


Download ppt "Projective Texture Mapping. Projective Textures Use to simulate effects: Slide projectors Spotlight illuminations Shadows Reprojection of images."

Similar presentations


Ads by Google