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

Slides:



Advertisements
Similar presentations
Technische Universität München Computer Graphics SS 2014 Graphics Effects Rüdiger Westermann Lehrstuhl für Computer Graphik und Visualisierung.
Advertisements

Graphics Pipeline.
Computer Graphic Creator: Mohsen Asghari Session 2 Fall 2014.
Computer Graphics Lecture 8 Arbitrary Viewing II: More Projection, Clipping and Mathematics of 3D Viewing.
Projective Texture Mapping
Week 7 - Monday.  What did we talk about last time?  Specular shading  Aliasing and antialiasing.
3D Graphics Rendering and Terrain Modeling
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2007 Tamara Munzner Viewing/Projections I.
Projection Matrices CS4395: Computer Graphics 1 Mohan Sridharan Based on slides created by Edward Angel.
Based on slides created by Edward Angel
Projection Matrices Ed Angel
Texture Mapping CPSC /24/03 Abhijeet Ghosh.
Graphics Systems I-Chen Lin’s CG slides, Doug James’s CG slides Angel, Interactive Computer Graphics, Chap 1 Introduction to Graphics Pipeline.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Models and Architectures Ed Angel Professor of Computer Science, Electrical and Computer.
1 Chapter 5 Viewing. 2 Perspective Projection 3 Parallel Projection.
Computer Graphics Mirror and Shadows
Technology and Historical Overview. Introduction to 3d Computer Graphics  3D computer graphics is the science, study, and method of projecting a mathematical.
Programmable Pipelines. Objectives Introduce programmable pipelines ­Vertex shaders ­Fragment shaders Introduce shading languages ­Needed to describe.
Computer Graphics (fall 2009)
CS 638, Fall 2001 Admin Grad student TAs may have had their accounts disabled –Please check and the lab if there is a problem If you plan on graduating.
1 Projection Matrices. 2 Objectives Derive the projection matrices used for standard OpenGL projections Introduce oblique projections Introduce projection.
Image Synthesis Rabie A. Ramadan, PhD 2. 2 Java OpenGL Using JOGL: Using JOGL: Wiki: You can download JOGL from.
1 SIC / CoC / Georgia Tech MAGIC Lab Rossignac Textures and shadows  Generation  Mipmap  Texture coordinates,
09/09/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Event management Lag Group assignment has happened, like it or not.
Graphics Systems and OpenGL. Business of Generating Images Images are made up of pixels.
CSC 461: Lecture 3 1 CSC461 Lecture 3: Models and Architectures  Objectives –Learn the basic design of a graphics system –Introduce pipeline architecture.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
OpenGL Conclusions OpenGL Programming and Reference Guides, other sources CSCI 6360/4360.
Real-time Shadow Mapping. Shadow Mapping Shadow mapping uses two-pass rendering - render depth texture from the light ’ s point-of-view - render from.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
CS 480/680 Computer Graphics OpenGL Texture Mapping Dr. Frederick C Harris, Jr. Fall 2011.
1Computer Graphics Lecture 4 - Models and Architectures John Shearer Culture Lab – space 2
CAP4730: Computational Structures in Computer Graphics 3D Transformations.
The Rendering Pipeline CS 445/645 Introduction to Computer Graphics David Luebke, Spring 2003.
Computer Graphics I, Fall 2010 Computer Viewing.
Fall 2009 Revised1 Texture Mapping (Intermediate) Jyun-Ming Chen.
Review of OpenGL Basics
OpenGL Shadow. Content Shadowing using Stencil Buffer Shadowing using Projective Texture Shadow map Shadow volume.
Advanced Computer Graphics Spring 2014 K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology.
Global Illumination. Local Illumination  the GPU pipeline is designed for local illumination  only the surface data at the visible point is needed to.
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
1 Angel: Interactive Computer Graphics5E © Addison- Wesley 2009 Image Formation Fundamental imaging notions Fundamental imaging notions Physical basis.
What are shaders? In the field of computer graphics, a shader is a computer program that runs on the graphics processing unit(GPU) and is used to do shading.
Real-Time Dynamic Shadow Algorithms Evan Closson CSE 528.
Projector-camera system Application of computer vision projector-camera v3a1.
Mobile & Casual Gaming OpenGL ES Intro. /red/chapter03.html.
09/23/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Reflections Shadows Part 1 Stage 1 is in.
Chapter 1 Graphics Systems and Models Models and Architectures.
CS5500 Computer Graphics March 20, Computer Viewing Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts.
1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 Computer Viewing Isaac Gang University of Mary Hardin-Baylor.
1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 Models and Architectures 靜宜大學 資訊工程系 蔡奇偉 副教授 2012.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2008 Tamara Munzner Viewing/Projections I.
Introduction to 3-D Viewing Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Monday, October 27, 2003.
Ying Zhu Georgia State University
CSC461: Lecture 20 Parallel Projections in OpenGL
Modeling 101 For the moment assume that all geometry consists of points, lines and faces Line: A segment between two endpoints Face: A planar area bounded.
Models and Architectures
Models and Architectures
Models and Architectures
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
Projection in 3-D Glenn G. Chappell
3D Game Programming Texture Mapping
Models and Architectures
Models and Architectures
Computer Graphics Computer Viewing
Terrain Jyun-Ming Chen Spring 2004.
3D Game Programming Texture Mapping
Presentation transcript:

Projective Texture

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

Spring Idea Generate texture coordinates based on the projector coordinate system

Spring 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

Spring Review: Pipeline

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

Spring 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.

Spring 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.

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

Spring 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

Spring 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

Spring 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!

Spring 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

Spring 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

Spring 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

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

Spring 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)

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

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

Spring 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.

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

Spring 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

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

Frustum Display Shows the location/orientation of the spotlight

Spring 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

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

Spring 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]

Spring 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)

Spring Implementation