CS 638, Fall 2001 Today Light Mapping (Continued) Bump Mapping with Multi-Texturing Multi-Pass Rendering.

Slides:



Advertisements
Similar presentations
15.1 Si23_03 SI23 Introduction to Computer Graphics Lecture 15 – Visible Surfaces and Shadows.
Advertisements

16.1 Si23_03 SI23 Introduction to Computer Graphics Lecture 16 – Some Special Rendering Effects.
8.1si31_2001 SI31 Advanced Computer Graphics AGR Lecture 8 Polygon Rendering.
Lecture 8 Transparency, Mirroring
Technische Universität München Computer Graphics SS 2014 Graphics Effects Rüdiger Westermann Lehrstuhl für Computer Graphik und Visualisierung.
CS 352: Computer Graphics Chapter 7: The Rendering Pipeline.
Ray tracing. New Concepts The recursive ray tracing algorithm Generating eye rays Non Real-time rendering.
Graphics Pipeline.
University of Sulaimani - School of Science - Computer Dept.
Computer Graphic Creator: Mohsen Asghari Session 2 Fall 2014.
Texture Mapping. Texturing  process that modifies the appearance of each point on a surface using an image or function  any aspect of appearance can.
Week 7 - Monday.  What did we talk about last time?  Specular shading  Aliasing and antialiasing.
Week 10 - Monday.  What did we talk about last time?  Global illumination  Shadows  Projection shadows  Soft shadows.
CAP4730: Computational Structures in Computer Graphics Visible Surface Determination.
Computer Graphics Visible Surface Determination. Goal of Visible Surface Determination To draw only the surfaces (triangles) that are visible, given a.
1 Dr. Scott Schaefer Shadows. 2/40 Shadows Shadows provide clues about depth Make scenes appear more realistic.
Real-Time Rendering SPEACIAL EFFECTS Lecture 03 Marina Gavrilova.
Introduction to 3D Graphics John E. Laird. Basic Issues u Given a internal model of a 3D world, with textures and light sources how do you project it.
University of Texas at Austin CS 378 – Game Technology Don Fussell CS 378: Computer Game Technology Beyond Meshes Spring 2012.
Computer Graphics Inf4/MSc Computer Graphics Lecture 11 Texture Mapping.
Computer Graphics Shadows
09/18/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Bump Mapping Multi-pass algorithms.
9/20/2001CS 638, Fall 2001 Today Finishing Up Reflections More Multi-Pass Algorithms Shadows.
Hidden Surface Removal
Shadows Computer Graphics. Shadows Shadows Extended light sources produce penumbras In real-time, we only use point light sources –Extended light sources.
Erdem Alpay Ala Nawaiseh. Why Shadows? Real world has shadows More control of the game’s feel  dramatic effects  spooky effects Without shadows the.
Computer Graphics Mirror and Shadows
Shadow Algorithms Ikrima Elhassan.
09/09/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Event management Lag Group assignment has happened, like it or not.
Graphics Graphics Korea University cgvr.korea.ac.kr 1 Chapter 6 Special Effects 강 신 진강 신 진
09/11/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Graphics Pipeline Texturing Overview Cubic Environment Mapping.
Week 2 - Friday.  What did we talk about last time?  Graphics rendering pipeline  Geometry Stage.
Game Programming (Mapping) Spring.
Advanced Computer Graphics Depth & Stencil Buffers / Rendering to Textures CO2409 Computer Graphics Week 19.
CS 638, Fall 2001 Today Project Stage 0.5 Environment mapping Light Mapping.
CS 638, Fall 2001 Multi-Pass Rendering The pipeline takes one triangle at a time, so only local information, and pre-computed maps, are available Multi-Pass.
Week 10 - Wednesday.  What did we talk about last time?  Shadow volumes and shadow mapping  Ambient occlusion.
1 10/24/ :01 UML Graphics II Shadows Session 4.
Multi-pass Rendering. © 2002 James K. Hahn, N.H. Baek2 Multi-pass Rendering Repeat: image  Rendering pass  result imageRepeat: image  Rendering pass.
Computer Graphics The Rendering Pipeline - Review CO2409 Computer Graphics Week 15.
Shadows. Shadows is important in scenes, consolidating spatial relationships “Geometric shadows”: the shape of an area in shadow Early days, just pasted.
Advanced Computer Graphics Advanced Shaders CO2409 Computer Graphics Week 16.
CS-378: Game Technology Lecture #8: More Mapping Prof. Okan Arikan University of Texas, Austin Thanks to James O’Brien, Steve Chenney, Zoran Popovic, Jessica.
CS-378: Game Technology Lecture #7: More Mapping Prof. Okan Arikan University of Texas, Austin Thanks to James O’Brien, Steve Chenney, Zoran Popovic, Jessica.
1 Perception and VR MONT 104S, Fall 2008 Lecture 21 More Graphics for VR.
Computer graphics & visualization Shadows / Transparency.
09/16/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Environment mapping Light mapping Project Goals for Stage 1.
Basic Perspective Projection Watt Section 5.2, some typos Define a focal distance, d, and shift the origin to be at that distance (note d is negative)
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
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.
1 CSCE 441: Computer Graphics Hidden Surface Removal Jinxiang Chai.
Shadows David Luebke University of Virginia. Shadows An important visual cue, traditionally hard to do in real-time rendering Outline: –Notation –Planar.
01/28/09Dinesh Manocha, COMP770 Visibility Computations Visible Surface Determination Visibility Culling.
09/23/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Reflections Shadows Part 1 Stage 1 is in.
Module 05 –Bump mapping Module 05 – Bump mapping Module 05 Advanced mapping techniques: Bump mapping.
Stenciling Effects Glenn G. Chappell
Discrete Techniques.
CS-378: Game Technology Lecture #7: More Mapping Prof. Okan Arikan
Week 7 - Monday CS361.
Week 2 - Friday CS361.
Game Programming (Mapping)
Today Visibility Overview Cell-to-Cell Cell-to-Region Eye-To-Region
The Graphics Rendering Pipeline
Jim X. Chen George Mason University
© University of Wisconsin, CS559 Fall 2004
CSCE 441: Computer Graphics Hidden Surface Removal
UMBC Graphics for Games
Last Time Presentation of your game and idea Environment mapping
Ref: OpenGL Programming Guide (The Red Book)
Presentation transcript:

CS 638, Fall 2001 Today Light Mapping (Continued) Bump Mapping with Multi-Texturing Multi-Pass Rendering

CS 638, Fall 2001 Light Maps Aim: Speed up lighting calculations by pre- computing lighting and storing it in maps –Allows complex illumination models to be used in generating the map (eg shadows, radiosity) –Used in complex rendering algorithms to catch radiance (Radiance) Issues: –How is the mapping determined? –How are the maps generated? –How are they applied at run-time?

CS 638, Fall 2001 Choosing a Mapping Problem: In a preprocessing phase, points on polygons must be associated with points in maps One solution: –Find groups of polygons that are “near” co-planar and do not overlap when projected onto a plane Result is a mapping from polygons to planes –Combine sections of the chosen planes into larger maps –Store texture coordinates at polygon vertices Lighting tends to change quite slowly (except at hard shadows), so the map resolution can be poor

CS 638, Fall 2001 Generating the Map Problem: What value should go in each pixel of the light map? Solution: –Map texture pixels back into world space (using the inverse of the texture mapping) –Take the illumination of the polygon and put it in the pixel Advantages of this approach: –Choosing “good” planes means that texture pixels map to roughly square pieces of polygon - good sampling –Not too many maps are required, and not much memory is wasted

CS 638, Fall 2001 Example

CS 638, Fall 2001 Example

CS 638, Fall 2001 Applying Light Maps Use multi-texturing hardware –First stage: Apply color texture map –Second stage: Modulate with light map Pre-lighting textures: –Apply the light map to the texture maps as a pre-process –When is this less appealing? Multi-stage rendering: –Same effect as multi-texturing, but modulating in the frame buffer

CS 638, Fall 2001 Dynamic Light Maps Light maps are a preprocessing step, so they can only capture static lighting What is required to compute a light map at run-time? How might we make this tractable? –Spatial subdivision algorithms allow us to identify nearby objects, which helps with this process Compute a separate, dynamic light map at runtime using same mapping as static light map Add additional texture pass to apply the dynamic map

CS 638, Fall 2001 Fog Maps Dynamic modification of light-maps Put fog objects into the scene Compute where they intersect with geometry and paint the fog density into a dynamic light map –Use same mapping as static light map uses Apply the fog map as with a light map –Extra texture stage

CS 638, Fall 2001 Fog Map Example

CS 638, Fall 2001 Bump Mapping Bump mapping modifies the surface normal vector according to information in the map View dependent: the effect of the bumps depends on which direction the surface is viewed from Bump mapping can be implemented with multi- texturing or multi-pass rendering

CS 638, Fall 2001 Storing the Bump Map Several options for what to store in the map –The normal vector to use –An offset to the default normal vector –Data derived from the normal vector –Illumination changes for a fixed view Multi-texturing map: –Store four maps (or more) showing the illumination effects of the bumps from four (or more) view directions –Key point: Bump maps on diffuse surfaces just make them lighter or darker - don’t change the color

CS 638, Fall 2001 Multi-Texture Bump Maps At run time: –Compute the dot product of the view direction with the ideal view direction for each bump map Bump maps that were computed with views near the current one will have big dot products –Use the computed dot product as a blend factor when applying each bump map –Must be able to specify the blend function to the texture unit OpenGL allows this Textbook has details for more accurate bump-mapping –Note that computing a dot product between the light and the bump map value can be done with current hardware

CS 638, Fall 2001 Multi-Pass Rendering The pipeline takes one triangle at a time, so only local information, and pre-computed maps, are available Multi-Pass techniques render the scene, or parts of the scene, multiple times –Makes use of auxiliary buffers to hold information –Make use of tests and logical operations on values in the buffers –Really, a set of functionality that can be used to achieve a wide range of effects Mirrors, shadows, bump-maps, anti-aliasing, compositing, …

CS 638, Fall 2001 Buffers Color buffers: Store RGBA color information for each pixel –OpenGL actually defines four or more color buffers: front/back, left/right and auxiliary color buffers Depth buffer: Stores depth information for each pixel Stencil buffer: Stores some number of bits for each pixel Accumulation buffer: Like a color buffer, but with higher resolution and different operations Buffers are defined by: –The type of values they store –The logical operations that they influence –The way they are written and read

CS 638, Fall 2001 Fragment Tests A fragment is a pixel-sized piece of shaded polygon, with color and depth information The tests and operations performed with the fragment on its way to the color buffer are essential to understanding multi- pass techniques Most important are, in order: –Alpha test –Stencil test –Depth test –Blending As the fragment passes through, some of the buffers may also have values stored into them

CS 638, Fall 2001 Alpha Test The alpha test either allows a fragment to pass, or stops it, depending on the outcome of a test: Here,  fragment is the fragment’s alpha value, and  reference is a reference alpha value that you specify op is one of: –, >= There are also the special tests: Always and Never –Always let the fragment through or never let it through What is a sensible default? if (  fragment op  reference ) pass fragment on

CS 638, Fall 2001 Billboards Billboards are polygons with an image textured onto them, typically used for things like trees –More precisely, and image-based rendering method where complex geometry (the tree) is replaced with an image placed in the scene (the textured polygon) The texture normally has alpha values associated with it: 1 where the tree is, and 0 where it isn’t –So you can see through the polygon in places where the tree isn’t

CS 638, Fall 2001 Alpha Test and Billboards You can use texture blending to make the polygon see through, but there is a big problem –What happens if you draw the billboard and then draw something behind it? –Hint: Think about the depth buffer values –This is one reason why transparent objects must be rendered back to front The best way to draw billboards is with an alpha test: Do not let alpha < 0.5 pass through –Depth buffer is never set for fragments that are see through –Doesn’t work for transparent polygons - more later

CS 638, Fall 2001 Stencil Buffer The stencil buffer acts like a paint stencil - it lets some fragments through but not others It stores multi-bit values You specify two things: –The test that controls which fragments get through –The operations to perform on the buffer when the test passes or fails –All tests/operation look at the value in the stencil that corresponds to the pixel location of the fragment Typical usage: One rendering pass sets values in the stencil, which control how various parts of the screen are drawn in the second pass

CS 638, Fall 2001 Stencil Tests You give an operation, a reference value, and a mask Operations: –Always let the fragment through –Never let the fragment through –Logical operations between the reference value and the value in the buffer:, >= The mask is used to select particular bit-planes for the operation –(reference & mask ) op ( buffer & mask )

CS 638, Fall 2001 Stencil Operations Specify three different operations –If the stencil test fails –If the stencil passes but the depth test fails –If the stencil passes and the depth test passes Operations are: –Keep the current stencil value –Zero the stencil –Replace the stencil with the reference value –Increment the stencil –Decrement the stencil –Invert the stencil (bitwise)

CS 638, Fall 2001 Depth Test and Operation Depth test compares the depth of the fragment and the depth in the buffer –Depth increase with greater distance from viewer Tests are: Always, Never,, >= Depth operation is to write the fragments depth to the buffer, or to leave the buffer unchanged –Why do the test but leave the buffer unchanged? Each buffer stores different information about the pixel, so a test on one buffer may be useful in managing another

CS 638, Fall 2001 Multi-Pass Algorithms Designing a multi-pass algorithm is a non-trivial task –At least one person I know of has received a PhD for developing such algorithms References for multi-pass algorithms: –The OpenGL Programming guide discusses many multi-pass techniques in a reasonably understandable manner –Game Programming Gems has some –Watt and Policarpo has others –Several have been published as academic papers –As always, the web is your friend

CS 638, Fall 2001 Planar Reflections (Flat Mirrors) Use the stencil buffer, color buffer and depth buffer Basic idea: –We need to draw all the stuff around the mirror –We need to draw the stuff in the mirror, reflected, without drawing over the things around the mirror Key point: You can reflect the viewpoint about the mirror to see what is seen in the mirror, or you can reflect the world about the mirror

CS 638, Fall 2001 Reflecting Objects If the mirror passes through the origin, and is aligned with a coordinate axis, then just negate appropriate coordinate Otherwise, transform into mirror space, reflect, transform back MirrorWall

CS 638, Fall 2001 Small Problem Reflecting changes the apparent vertex order as seen by the viewer –Impacts back-face culling, so turn it off or change interpretation of vertex ordering Reflecting the view has the same effect, but this time it also shift the left-right sense in the frame buffer –Works, just harder to understand what’s happening

CS 638, Fall 2001 Rendering Reflected First First pass: –Render the reflected scene without mirror, depth test on Second pass: –Disable the color buffer, Enable the stencil buffer to always pass but set the buffer, Render the mirror polygon –Now, set the stencil test to only pass points outside the mirror –Clear the color buffer - does not clear points inside mirror area Third Pass: –Enable the color buffer again, Disable the stencil buffer –Render the original scene, without the mirror –Depth buffer stops from writing over things in mirror

CS 638, Fall 2001 Reflection Example The stencil buffer after the second pass The color buffer after the second pass – the reflected scene cleared outside the stencil

CS 638, Fall 2001 Reflection Example The color buffer after the final pass

CS 638, Fall 2001 Reflected Scene First (issues) If the mirror is infinite, there is no need for the second pass –But might want to apply a texture to roughen the reflection If the mirror plane is covered in something (a wall) then no need to use the stencil or clear the color buffer in pass 2 Objects behind the mirror cause problems: –Will appear in reflected view in front of mirror –Solution is to use clipping plane to cut away things on wrong side of mirror Curved mirrors by reflecting vertices differently Doesn’t do: –Reflections of mirrors in mirrors (recursive reflections) –Multiple mirrors in one scene (that aren’t seen in each other)

CS 638, Fall 2001 Rendering Normal First First pass: –Render the scene without the mirror Second pass: –Clear the stencil, Render the mirror, setting the stencil if the depth test passes Third pass: –Clear the depth buffer with the stencil active, passing things inside the mirror only –Reflect the world and draw using the stencil test. Only things seen in the mirror will be drawn

CS 638, Fall 2001 Normal First Addendum Same problem with objects behind mirror –Same solution Can manage multiple mirrors –Render normal view, then do other passes for each mirror –Only works for non-overlapping mirrors (in view) –But, could be extended with more tests and passes A recursive formulation exists for mirrors that see other mirrors