Advanced Computer Graphics Depth & Stencil Buffers / Rendering to Textures CO2409 Computer Graphics Week 19.

Slides:



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

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.
Ray tracing. New Concepts The recursive ray tracing algorithm Generating eye rays Non Real-time rendering.
Graphics Pipeline.
Computer Graphic Creator: Mohsen Asghari Session 2 Fall 2014.
Week 7 - Monday.  What did we talk about last time?  Specular shading  Aliasing and antialiasing.
Week 11 - Wednesday.  Image based effects  Skyboxes  Lightfields  Sprites  Billboards  Particle systems.
Week 10 - Monday.  What did we talk about last time?  Global illumination  Shadows  Projection shadows  Soft shadows.
David Luebke5/11/2015 CS 551 / 645: Introductory Computer Graphics David Luebke
CHAPTER 12 Height Maps, Hidden Surface Removal, Clipping and Level of Detail Algorithms © 2008 Cengage Learning EMEA.
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.
CS 4731: Computer Graphics Lecture 18: Hidden Surface Removal Emmanuel Agu.
CGDD 4003 THE MASSIVE FIELD OF COMPUTER GRAPHICS.
Computer Graphics 14: Surface Detection Methods
Final Gathering on GPU Toshiya Hachisuka University of Tokyo Introduction Producing global illumination image without any noise.
1 Lecture 11 Scene Modeling. 2 Multiple Orthographic Views The easiest way is to project the scene with parallel orthographic projections. Fast rendering.
Vertices and Fragments III Mohan Sridharan Based on slides created by Edward Angel 1 CS4395: Computer Graphics.
CSE 872 Dr. Charles B. Owen Advanced Computer Graphics1 Other Rendering Techniques Types of rendering – Wireframe techniques – Scan-line conversion – Reyes.
Computer Graphics 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.
Computer Graphics Mirror and Shadows
1 Perception, Illusion and VR HNRS 299, Spring 2008 Lecture 19 Other Graphics Considerations Review.
Technology and Historical Overview. Introduction to 3d Computer Graphics  3D computer graphics is the science, study, and method of projecting a mathematical.
Chapter 2 Getting Started: Drawing Figures. The Framebuffer Lecture 2 Fri, Aug 29, 2003.
Computer Graphics Texture Mapping
Computer Graphics World, View and Projection Matrices CO2409 Computer Graphics Week 8.
CS 450: COMPUTER GRAPHICS REVIEW: INTRODUCTION TO COMPUTER GRAPHICS – PART 2 SPRING 2015 DR. MICHAEL J. REALE.
Week 2 - Friday.  What did we talk about last time?  Graphics rendering pipeline  Geometry Stage.
10/26/04© University of Wisconsin, CS559 Fall 2004 Last Time Drawing lines Polygon fill rules Midterm Oct 28.
Visible-Surface Detection Jehee Lee Seoul National University.
Emerging Technologies for Games Alpha Sorting and “Soft” Particles CO3303 Week 15.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Computer Graphics Module Review CO2409 Computer Graphics.
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.
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.
Advanced Computer Graphics Advanced Shaders CO2409 Computer Graphics Week 16.
2 COEN Computer Graphics I Evening’s Goals n Discuss application bottleneck determination n Discuss various optimizations for making programs execute.
Games Development 1 Camera Projection / Picking CO3301 Week 8.
1Computer Graphics Implementation II Lecture 16 John Shearer Culture Lab – space 2
1 Perception and VR MONT 104S, Fall 2008 Lecture 21 More Graphics for VR.
Advanced Computer Graphics Shadow Techniques CO2409 Computer Graphics Week 20.
09/16/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Environment mapping Light mapping Project Goals for Stage 1.
Advanced Computer Graphics Spring 2014 K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology.
Emerging Technologies for Games Deferred Rendering CO3303 Week 22.
Computer Graphics Blending CO2409 Computer Graphics Week 14.
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © Visible Surface Determination (VSD) To render or not to render, that is the question… 1 of.
Computer Graphics I, Fall 2010 Implementation II.
Honours Graphics 2008 Session 5. Today’s focus Rasterization Visibility determination Coarse / fine visibility determination.
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.
The Graphics Pipeline Revisited Real Time Rendering Instructor: David Luebke.
Computer Graphics Inf4/MSc 1 Computer Graphics Lecture 5 Hidden Surface Removal and Rasterization Taku Komura.
Visible surface determination. Problem outline Given a set of 3D objects and a viewing specification, we wish to determine which lines or surfaces are.
Graphics, Modeling, and Textures Computer Game Design and Development.
1 Computer Graphics Week11 : Hidden Surface Removal.
09/23/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Reflections Shadows Part 1 Stage 1 is in.
Visible-Surface Detection Methods. To identify those parts of a scene that are visible from a chosen viewing position. Surfaces which are obscured by.
Visible Surface Detection
Discrete Techniques.
Week 7 - Monday CS361.
CSCE 441: Computer Graphics Hidden Surface Removal
Visibility (hidden surface removal)
The Framebuffer 1 Lecture 37 Fri, Nov 30, 2007.
Computer Graphics Material Colours and Lighting
Presentation transcript:

Advanced Computer Graphics Depth & Stencil Buffers / Rendering to Textures CO2409 Computer Graphics Week 19

Lecture Contents 1.Sorting Polygons 2.Depth Buffers 3.Z-Buffers 4.Stencil Buffers 5.Using Stencil Buffers 6.Rendering to Textures

Sorting Polygons When rendering, we have paid no attention to the order in which we draw models. Why not? –If painting, we would probably draw distant objects first, then the near ones over the top –This is Painters Algorithm To do this in a program, would need to sort the list of scene polygons by distance (camera Z) –Expensive –[Although needed for alpha blending] But what about this case:

Depth Buffers Graphics cards contain a depth buffer –Along with the back-buffer Used to sort rendered primitives in depth order A depth buffer is a rectangular array of depth values corresponding to pixels in the back-buffer –Each pixel in the back-buffer has an associated value in the depth-buffer Depth data is stored in different formats: –Usually 24/32 bit floating-point –Other types are possible 0.0 (Black) = Near 1.0 (White) = Far

Z-Buffers A Z-buffer stores the viewport space Z coordinate of each pixel in the back buffer –Calculated per vertex during the 3D->2D camera projection, the range is 0.0 (near) to 1.0 (far) –The range covers the near to far clip distance of the camera –Interpolated per-pixel for final primitives When rendering a pixel to the back buffer: –Only render pixel if its z value is less than existing value in the z buffer –The new z value is written into the appropriate z-buffer location

Z-Buffers The Z-buffer must be cleared at the beginning of each render –To the furthest Z-value –So new pixels are not hidden behind last frame’s depths –Clear Z-buffer at same time as clearing back-buffer (viewport) When using a Z-buffer, the order that opaque primitives are rendered is not important –Intersecting opaque primitives will be rendered correctly However, transparent primitives may need to be drawn in sorted order (painters algorithm) –Depending on the blending method

Disadvantages of Z-Buffers Pixels at different distances may end up with the same z value in the z-buffer Makes inaccurate sorting and visual artefacts –Especially for parallel or distant primitives Can fix by adjusting camera near and far clip distance –Adjusts spread of z-values Z-values are not distributed evenly Typically, over 90% of the (far) visible z range is stored in less than 10% of the actual z values – I.e. Fewer possible distant Z-values

Stencil Buffers –1 or 8 reserved bits The stencil buffer is a mask controlling when pixels are drawn to the back-buffer –Not associated with a specific technique –Can be used for many tasks Shadows using stencil buffer: The stencil-buffer is a buffer of additional per-pixel values associated with the depth buffer These values are almost always embedded within the depth values themselves

Stencil Buffer Operation The graphics app can test current stencil values with a customisable function before writing each pixel Result of the test can be used to decide: –Whether to write the pixel or not –Whether to write a new stencil buffer value or not A new stencil value can also be generated using a different customisable function A very general system Gives great flexibility in the use of the stencil buffer: –Overlays, portals/mirrors, fades/dissolves, shadows…

Example of Stencil Buffer Use Steps to draw mirror / portal using a stencil: 1.Clear the mirror polygon, setting all the stencil values to 1 2.Render reflected scene but only draw where the stencil is equal to 1 (only on the mirror) 3.Draw surface effects over the mirror polygon Avoids drawing mirror content in wrong area

Rendering to Textures In the last slide we saw a scene rendered into the surface of a polygon with the help of the stencil buffer Can also do this by rendering to a texture used for the polygon (instead of to the back buffer) We can set up a special Render Target texture and render the scene to it as an initial step When the main scene is rendered, the scene in the rendered texture is visible –Quality limited by texture size A simple method, used widely

Render to Texture vs Stencil Stencil buffer techniques are of higher quality They do not use GPU memory Can help for many unusual techniques Can be tricky to set up and get working More rarely used Render to Texture is very flexible –E.g. applying a texture to a complex object is easy, but difficult using stencils Much easier to program Widely used as a standard technique for mirrors, portals, shadows, post-processing etc,