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.

Slides:



Advertisements
Similar presentations
Computer Graphics - Rasterization -
Advertisements

15.1 Si23_03 SI23 Introduction to Computer Graphics Lecture 15 – Visible Surfaces and Shadows.
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.
CS 4363/6353 BASIC RENDERING. THE GRAPHICS PIPELINE OVERVIEW Vertex Processing Coordinate transformations Compute color for each vertex Clipping and Primitive.
University of Sulaimani - School of Science - Computer Dept.
Computer Graphic Creator: Mohsen Asghari Session 2 Fall 2014.
CSL 859: Advanced Computer Graphics Dept of Computer Sc. & Engg. IIT Delhi.
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.
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.
Chapter 6: Vertices to Fragments Part 2 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley Mohan Sridharan Based on Slides.
Vertices and Fragments III Mohan Sridharan Based on slides created by Edward Angel 1 CS4395: Computer Graphics.
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.
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.
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
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
University of Illinois at Chicago Electronic Visualization Laboratory (EVL) CS 426 Intro to 3D Computer Graphics © 2003, 2004, 2005 Jason Leigh Electronic.
CS 638, Fall 2001 Today Light Mapping (Continued) Bump Mapping with Multi-Texturing Multi-Pass Rendering.
02/26/02 (c) 2002 University of Wisconsin, CS 559 Last Time Canonical view pipeline Orthographic projection –There was an error in the matrix for taking.
Buffers Textures and more Rendering Paul Taylor & Barry La Trobe University 2009.
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.
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.
Shadows. Shadows is important in scenes, consolidating spatial relationships “Geometric shadows”: the shape of an area in shadow Early days, just pasted.
Shadow Mapping Chun-Fa Chang National Taiwan Normal University.
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.
Implementation II.
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.
11/24/ :45 Graphics II Shadow Maps Reflections Session 5.
Computer Graphics I, Fall 2010 Implementation II.
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.
Shadows David Luebke University of Virginia. Shadows An important visual cue, traditionally hard to do in real-time rendering Outline: –Notation –Planar.
Computer Graphics Through OpenGL: From Theory to Experiments, Second Edition Chapter 13.
1 Shadow Rendering Techniques: Hard and Soft Author: Jamiur Rahman Supervisor: Mushfiqur Rouf Department of CSE BRAC University.
09/23/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Reflections Shadows Part 1 Stage 1 is in.
Computer Graphics Implementation II
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.
The Graphics Rendering Pipeline
Jim X. Chen George Mason University
UMBC Graphics for Games
Last Time Presentation of your game and idea Environment mapping
Ref: OpenGL Programming Guide (The Red Book)
Frame Buffers Fall 2018 CS480/680.
Presentation transcript:

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