Stencil Buffer & Decals

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.
The Buffers and Operations
OpenGL Buffers and Tests Glenn G. Chappell U. of Alaska Fairbanks CS 481/681 Lecture Notes Friday, February 8, 2002.
Framebuffer in OpenGL MAE152 Computer Graphics for Scientists and Engineers Fall 03.
OpenGL Fragment Operations
Graphics Pipeline.
1 Buffers and Processing Fragments 2011 Autumn Animação e Visualização Tridimensional 2011/2012.
OPENGL Return of the Survival Guide. Buffers (0,0) OpenGL holds the buffers in a coordinate system such that the origin is the lower left corner.
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.
Buffers © Jeff Parker, 2011.
03/12/02 (c) 2002 University of Wisconsin, CS559 Last Time Some Visibility (Hidden Surface Removal) algorithms –Painter’s Draw in some order Things drawn.
Clever Uses of OpenGL Kurt Akeley CS248 Lecture November 2007
Computer Graphics Visible Surface Determination. Goal of Visible Surface Determination To draw only the surfaces (triangles) that are visible, given a.
黃聰賢. Light Position Mesh Polygon Shadow Polygon  Clear color buffer and stencil buffer  Render the scene with ambient only.
Introduction to OpenGL. What is OpenGL OpenGL is a low-level software interface to graphics hardware No commands for performing windowing tasks or obtaining.
Vertices and Fragments III Mohan Sridharan Based on slides created by Edward Angel 1 CS4395: Computer Graphics.
Jittering, Introduction to Stenciling Glenn G. Chappell U. of Alaska Fairbanks CS 481/681 Lecture Notes Friday, February 6, 2004.
Shadows Computer Graphics. Shadows Shadows Extended light sources produce penumbras In real-time, we only use point light sources –Extended light sources.
CS 638, Fall 2001 Today Light Mapping (Continued) Bump Mapping with Multi-Texturing Multi-Pass Rendering.
Korea University Korea University Computer Graphics Laboratory Computer Graphics Laboratory Jung Lee, Chapter 13.
Homogeneous Form, Introduction to 3-D Graphics Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Monday, October 20,
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.
Viewing With OpenGL Courtesy of Drs. Carol O’Sullivan / Yann Morvan Trinity College Dublin.
1 10/24/ :01 UML Graphics II Shadows Session 4.
Computer graphics & visualization Shadows / Transparency.
09/16/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Environment mapping Light mapping Project Goals for Stage 1.
Intro to OpenGL: Vertices and Drawing
Mobile Graphics Patrick Cozzi University of Pennsylvania CIS Spring 2012.
OpenGL Special Effects Jian-Liang Lin 2002 Blending: Alpha Channel Alpha value can be specify by glColor* When blending is enabled, the alpha value is.
11/24/ :45 Graphics II Shadow Maps Reflections Session 5.
Computer Graphics I, Fall 2010 Implementation II.
1 Perception and VR MONT 104S, Fall 2008 Lecture 20 Computer Graphics and VR.
Improving the appearance of 3D OpenGL scenes
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.
Learning Objectives Classification of Visible Surface Detection Algorithms Classification of Visible Surface Detection Algorithms Back-Face Detection Back-Face.
09/23/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Reflections Shadows Part 1 Stage 1 is in.
Some Notes on 3-D Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Friday, October 24, 2003.
The Framebuffer Hyun-Chul Cho. HyunChul Cho - KUCG -2 Buffer Goal of a graphics program Draw pictures on the screen Screen Rectangular array.
Tan-Chi Ho, CGGM Lab., CSIE of NCTU Pixel Operations and Buffers.
Buffers Ed Angel Professor Emeritus of Computer Science
Stenciling Effects Glenn G. Chappell
Discrete Techniques.
Hidden Surface Removal
CSC461: Lecture 20 Parallel Projections in OpenGL
Real-Time Rendering Shadow Volumes
Multiple-pass Reflection Depth of Field
OpenGL Buffers and Tests
CSc4820/6820 Computer Graphics Algorithms Ying Zhu Georgia State University Fog and Transparency.
Introduction to Computer Graphics with WebGL
Lecture 13 Clipping & Scan Conversion
Computer Graphics Buffers
Visibility (hidden surface removal)
Texture and Shadow Mapping
Computer Graphics Practical Lesson 7
Computer Graphics 4Practical Lesson
Computer Graphics Practical Lesson 9
Buffers Ed Angel Professor Emeritus of Computer Science
Last Time Presentation of your game and idea Environment mapping
Ref: OpenGL Programming Guide (The Red Book)
The Framebuffer 1 Lecture 37 Fri, Nov 30, 2007.
Sweep Fill Details For row = min to row=max
Frame Buffers Fall 2018 CS480/680.
Presentation transcript:

Stencil Buffer & Decals - Stencil buffer & OpenGl commands - Using the stencil buffer to apply polygonal decals - Using the stencil buffer to apply text decals

Decals 2 step process: As surface to be stenciled is written into frame buffer, mark what pixels it modifies 2. Scan convert decal into frame buffer restricted to the pixels marked in step 1

Decals color depth stencil 000… 999… 44444444 1111111 22222244 22222299 1111111 color 11 depth stencil

Stencil Buffer Same spatial resolution as color and depth buffers Usually (and at least) 8-bits, but can vary Used to hold values related to elements being written into frame buffer

OpenGl Commands glStencilFunc() - sets function to test stencil bits with glStencilMask(), glStencilMaskSeparate() - specifies which bits in Stencil Buffer are involved glStencilOp(), glStencilOpSeparate() - specifies operation to perform as result of stencil test and depth test Separate - for front v. back faces if desired

glStencilFunc() glStencilFunc(GLenum func, Glint ref, GLuint mask) Specifies test to perform on reference value and masked bits in stencil buffer func - test function e.g., GL_LEQUAL, GL_ALWAYS ref - reference value for test mask - ANDed with ref & stencil value - selects what bits to use

glStencilMask() glStencilMask(GLuint mask) Enables and disables writing of individual bits in the stencil planes

glStencilMaskSeparate() glStencilMaskSeparate(GLenum face, GLuint mask) Face - GL_FRONT, GL_BACK, GL_FRONT_AND_BACK Enables and disables writing of individual bits in the stencil planes

glStencilOp() glStencilOp(GLenum sfail, GLenum dpfail, GLenum dppass) Specifies what action to take as a result of stencil test and depth test: GL_KEEP, GL_ZERO, GL_REPLACE, etc. sfail - fails stencil test dpfail - passes stencil test, fails depth test dppass- passes both stencil and depth test

glStencilOpSeparate() glStencilOpSeparate(GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass) Specifies what action to take as a result of stencil test and depth test: GL_KEEP, GL_ZERO, GL_REPLACE, etc. sfail - fails stencil test dpfail - passes stencil test, fails depth test dppass- passes both stencil and depth test

Applying decals Draw decal right on top of surface Draw it into buffer wherever surface was drawn (don’t draw it where surface is not visible) Don’t do depth testing

Applying polygonal decals Put ‘1’ in stencil buffer wherever surface is drawn in frame buffer glEnable(GL_STENCIL_TEST); // enable the stencil test glStencilFunc(GL_ALWAYS,1,1); // always place a 1 in the stencil buffer glStencilOp(GL_KEEP,GL_ZERO,GL_REPLACE); // if stencil fails (it won’t - why?), keep stencil value // else if depth fails, put a zero in stencil buffer // else, replace value in stencil buffer with ref draw base polygon

Applying polygonal decals Draw decal wherever stencil has a ‘1’ glStencilFunc(GL_EQUAL,1,1); // test if 1 bit is set in stencil buffer, glStencilMask(GL_FALSE); // turn off stencil writing ('0' ?) glDisable(GL_DEPTH_TEST); // don't do depth test (so it ‘passes’) draw decal polygon glEnable(GL_DEPTH_TEST); glDisable(GL_STENCIL_TEST);

Applying text decals Draw text decal wherever stencil has a ‘1’ // with depth test off and stencil writing off as in previous slide glLineWidth(6); set_material("whiteMatteMaterial"); <transforms to get it where you want it to go> glStencilFunc(GL_EQUAL,1,1); // if 1 bit is set, glutStrokeCharacter(GLUT_STROKE_MONO_ROMAN,'5'); glutStrokeCharacter(GLUT_STROKE_MONO_ROMAN,'8'); glutStrokeCharacter(GLUT_STROKE_MONO_ROMAN,'1');