Download presentation

Presentation is loading. Please wait.

Published byTalia Sharer Modified about 1 year ago

1
Projective Texture

2
Spring 20062 Projective Texture Texture projected on a scene as if by a projector Can also be used to generate spot light and shadows

3
Spring 20063 Idea Generate texture coordinates based on the projector coordinate system

4
Spring 20064 In Projector Space … xpxp ypyp Whatever is in the projector frustum has clip coord. of [-1,1]x[-1,1]xZ … (Z is irrelevant) Convert [-1,1] to [0,1] to become the texture coordinates

5
Spring 20065 Review: Pipeline

6
Fall 2009 revised6 Model Transform Viewing Transform Modelview Matrix world coordinates Pipeline Review

7
Spring 20067 Review: Texgen (Object_linear) If the texture generation function is GL_OBJECT_LINEAR, the function g = p1 * x o + p2 * y o + p3 * z o + p4 * w o is used, where g is the value computed for the coordinate; p1, p2, p3, and p4 are the four values supplied in params; and x o, y o, z o, and w o are the object coordinates of the vertex.

8
Spring 20068 Review: Texgen (Eye_linear) If the texture generation function is GL_EYE_LINEAR, the function g =p 1 ' * x e + p 2 ' * y e + p 3 ' * z e + p 4 ' * w e is used, where (p 1 ' p 2 ' p 3 ' p 4 ') = (p 1 p 2 p 3 p 4 ) * M -1 and x e, y e, z e, and w e are the eye coordinates of the vertex, p 1, p 2, p 3, and p 4 are the values supplied in params, and M is the modelview matrix when glTexGen is invoked.

9
Spring 20069 Review: Texgen Matrix Concatenate texgen planes into a 4-by-4 matrix Object-linear Eye-linear ToTo

10
Spring 200610 Coordinate Transformation From Object to Projector: From Eye to Projector: Clip coordinate of Projector Space: M: model matrix V p : view matrix to projector space V : view matrix to eye P p : projection matrix to projector space

11
Spring 200611 Scale to Texture Coordinates Scale-and-bias matrix (S) Clip Coordinate [-1,1] Texture Coordinate [0,1] Note: we only care about [s,t] (and then [x,y]). Hence, frustum clipping on z is of no importance

12
Spring 200612 Use Texgen for Coord. Transform 1 Need to keep track of model matrix M Texgen planes T o should be updated whenever M changes (model moves) Not explicitly available in OpenGL!

13
Spring 200613 Use Texgen for Coord. Transform 2 The texture coordinate generated is A’x e + B’y e + C’z e + D’ w e where (A’,B’,C’,D’) is (A,B,C,D)M −1, M is the modelview matrix when glTexGen is invoked. Thus, simply set the modelview matrix to contain only the view matrix

14
Spring 200614 Alternatively, For the rest of transformations, set the texture matrix instead We can use OpenGL matrix facility for matrix multiplication Tex coords after texgen Tex coords after texture transformation

15
Spring 200615 Summary Texgen: eye-linear When texgen is called, set modelview to contain V e only Specify the other transforms (SP p V p ) as texture matrix

16
Spring 200616 Summary need to generate the texture coordinate according to the projector coordinate system

17
Spring 200617 Demo (myprojspot - blended) Scene: textured plane and untextured teapot, subject to a textured spotlight Two rendering passes blended together (with polygon offset to resolve z-fighting)

18
Spring 200618 Demo Projective Pass Regular Pass Blended Polygon offset is critical to resolve z-fighting! GL_ONE

19
Spring 200619 Implementation Note Border pixels The projected texture needs to be padded with black boundary pixels so that the clamped texture appears Ok

20
Spring 200620 Multitexture Implementation Rather than using two blended passes, use a single (multitextured) pass Assign a separate texture unit for spot light texture Projective texture coordinate set by texgen Texture environment set to GL_ADD Base fragment/texture + spot light RGB: equivalent to one/one blending The padding is black (0,0,0); GL_ADD plays no role.

21
Spring 200621 Projective Texture Shadow Esp. good for non-planar shadow receivers

22
Spring 200622 Projective Shadow Texture Generate a shadow texture from light coordinate system Render unlit occluder only Render the shadow receiver with the projected shadow; then render the occluder Note the shadow texture is padded with white pixels. The texture environment used is GL_MODULATE (white (1,1,1) plays no role) spot or point light

23
This is normal! If you see something like this, the artifact comes from projective texture clamping: the shadow touches the texture border (not enough padding). It can be alleviated by increasing the fov or raising the light position

24
Frustum Display Shows the location/orientation of the spotlight

25
Spring 200625 Idea Projector is set by “ gluLookAt ” API Eye, center, up Vertices of the viewing frustum have clip coordinates of [-1,1] 3 Need to know their corresponding world coordinates to render

26
Spring 200626 s -f gluLookAt (eye, center, up) LTLT Change of Basis gluLookAt is equivalent to: M T

27
Spring 200627 Model Transform Viewing Transform Modelview Matrix world coordinates [-1,1] 3 MT [clip] = [Proj] [MT] [world] [world] = [MT] -1 [Proj] -1 [clip] = T -1 M -1 P -1 [clip]

28
Spring 200628 glFrustum (l,r,b,t,n,f) n,f must be positive n cannot be zero n fr rf/n z x y (1,1,1) (-1,-1,-1)

29
Spring 200629 Implementation

Similar presentations

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google