University of Sulaimani - School of Science - Computer Dept.

Slides:



Advertisements
Similar presentations
Presented by: Stacy C. Lovell. How do we perceive color? Our eyes contain only 3 types of photosentitive cells tuned to three frequencies Red, Green,
Advertisements

Lecture 8 Transparency, Mirroring
Compositing and Blending Ed Angel Professor Emeritus of Computer Science University of New Mexico 1 E. Angel and D. Shreiner: Interactive Computer Graphics.
Technische Universität München Computer Graphics SS 2014 Graphics Effects Rüdiger Westermann Lehrstuhl für Computer Graphik und Visualisierung.
O a polygon is a plane figure specified by a set of three or more coordinate positions, called vertices, that are connected in sequence by straight-Line.
CS 352: Computer Graphics Chapter 7: The Rendering Pipeline.
The Buffers and Operations
OpenGL Buffers and Tests Glenn G. Chappell U. of Alaska Fairbanks CS 481/681 Lecture Notes Friday, February 8, 2002.
Introduction to OpenGL (Part 4)
Framebuffer in OpenGL MAE152 Computer Graphics for Scientists and Engineers Fall 03.
OpenGL Fragment Operations
Optimized Stencil Shadow Volumes
Graphics Pipeline.
Optimized Stencil Shadow Volumes
Buffers © Jeff Parker, 2013.
Game Programming 09 OGRE3D Lighting/shadow in Action
1 Buffers and Processing Fragments 2011 Autumn Animação e Visualização Tridimensional 2011/2012.
Computer Graphics(Fall 2003) COMS 4160, Lecture 7: OpenGL 3 Ravi Ramamoorthi Many slides courtesy Greg Humphreys.
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.
Computer Graphic Creator: Mohsen Asghari Session 2 Fall 2014.
CSL 859: Advanced Computer Graphics Dept of Computer Sc. & Engg. IIT Delhi.
Week 9 - Friday.  What did we talk about last time?  Area lighting  Environment mapping  Blinn and Newell's method  Sphere mapping  Cubic environmental.
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.
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.
黃聰賢. Light Position Mesh Polygon Shadow Polygon  Clear color buffer and stencil buffer  Render the scene with ambient only.
Practical and Robust Stenciled Shadow Volumes for Hardware-Accelerated Rendering Cass Everitt and Mark J. Kilgard Speaker: Alvin Date: 5/28/2003 NVIDIA.
Computer Graphics Shadows
09/18/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Bump Mapping Multi-pass algorithms.
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
Jittering, Introduction to Stenciling Glenn G. Chappell U. of Alaska Fairbanks CS 481/681 Lecture Notes Friday, February 6, 2004.
Creating Reflections and Shadows Using Stencil Buffers Mark J. Kilgard NVIDIA Corporation.
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
CS 638, Fall 2001 Today Light Mapping (Continued) Bump Mapping with Multi-Texturing Multi-Pass Rendering.
NVIDIA PROPRIETARY AND CONFIDENTIAL Occlusion (HP and NV Extensions) Ashu Rege.
Advanced Computer Graphics Depth & Stencil Buffers / Rendering to Textures CO2409 Computer Graphics Week 19.
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.
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 & visualization Shadows / Transparency.
OpenGL Architecture Display List Polynomial Evaluator Per Vertex Operations & Primitive Assembly Rasterization Per Fragment Operations Frame Buffer Texture.
OpenGL Shadow. Content Shadowing using Stencil Buffer Shadowing using Projective Texture Shadow map Shadow volume.
09/16/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Environment mapping Light mapping Project Goals for Stage 1.
Global Illumination. Local Illumination  the GPU pipeline is designed for local illumination  only the surface data at the visible point is needed to.
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.
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.
Accumulation-Based Effects Glenn G. Chappell U. of Alaska Fairbanks CS 481/681 Lecture Notes Wednesday, February 4, 2004.
Shadows David Luebke University of Virginia. Shadows An important visual cue, traditionally hard to do in real-time rendering Outline: –Notation –Planar.
1 Shadow Rendering Techniques: Hard and Soft Author: Jamiur Rahman Supervisor: Mushfiqur Rouf Department of CSE BRAC University.
Stencil Shadows Garrett Weng. What are stencil shadows? Also known as shadow volumes Relies on use of the stencil buffer Create volumes of the shadows.
09/23/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Reflections Shadows Part 1 Stage 1 is in.
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.
Computer Graphics (Fall 2003) COMS 4160, Lecture 5: OpenGL 1 Ravi Ramamoorthi Many slides courtesy Greg Humphreys.
Stenciling Effects Glenn G. Chappell
Discrete Techniques.
Draw a Simple Object.
Real-Time Rendering Shadow Volumes
OpenGL Buffers and Tests
Texture and Shadow Mapping
Computer Graphics Practical Lesson 9
Last Time Presentation of your game and idea Environment mapping
Chapter X Output Merger.
Ref: OpenGL Programming Guide (The Red Book)
OpenGL Shadow.
Stencil Buffer & Decals
Presentation transcript:

University of Sulaimani - School of Science - Computer Dept. 4/11/2017 Shadows Dr. Aree Ali Mohammed Assistant Professor 2014-2015 3rd Stage aree.ali@univsul.edu.iq University of Sulaimani - School of Science - Computer Dept.

Content Shadowing using Stencil Buffer Shadowing using Projective Texture Shadow map Shadow volume

Notation Light source Occluders & receivers Shadow Point vs area Occluders & receivers Identify ahead of time? Self-shadowing? Shadow Umbra Penumbra Soft vs hard shadows

Shadows are important … It is usually better to have an inaccurate shadow than none at all

Terminology Hard Shadow Soft Shadow (area) light source occluder receiver shadow occluder umbra penumbra Occludee (receiver) Hard Shadow Soft Shadow

Soft Shadows Point light generates hard shadows only Soft shadows are generally preferable, if possible.

What is Stenciling? Per-pixel test, similar to depth buffering. Tests against value from stencil buffer; rejects fragment if stencil test fails. Distinct stencil operations performed when Stencil test fails Depth test fails Depth test passes Provides fine grain control The Stencil Buffer is another frame buffer, like the Color Buffer, Depth Buffer and Accumulation Buffer. Stencil Buffer can be used to specify a pattern so that only fragments that pass the stencil test are rendered to the color buffer. of pixel update

Stencil Buffer Example Render the fragments only where the stencil buffer bit is 0 1 1 1 Stencil Buffer Color Buffer

Per-Fragment Pipeline Pixel Ownership Test Stencil Depth Blending Dithering Logic Op Scissor Alpha Frame buffer Fragment + Associated Data

OpenGL API glEnable/glDisable(GL_STENCIL_TEST); glStencilFunc(function, reference, mask); glStencilOp(stencil_fail, depth_fail, depth_pass); glStencilMask(mask); glClear(… | GL_STENCIL_BUFFER_BIT);

Remark Shadow polygons are blended with the floor, one-by-one Repetitive blending … To prevent this from happening, use stencil buffer When a polygon is drawn, increment the stencil count (therefore, the area is not drawn again) glStencilFunc(GL_EQUAL, 1, 0xFF); glStencilOp (GL_KEEP, GL_KEEP, GL_INCR);

OpenGL Stencil Buffer Functions // glStencilFunc: set function and reference value for stencil testing // func :Specifies the test function. Options: GL_NEVER, GL_LESS, GL_LEQUAL, // GL_GREATER, GL_GEQUAL, GL_EQUAL, GL_NOTEQUAL, and GL_ALWAYS. // Default is GL_ALWAYS. // ref : Specifies the reference value for the stencil test. // ref is clamped to the range [0,2n−1], where n is the number of bits for each fragment // in the stencil buffer. The initial value is 0. // Mask: Specifies a mask that is ANDed with both the reference value and the stored // stencil value when the test is done. Default is all 1's. void glStencilFunc (GLenum func , GLint ref , GLuint mask ); // glStencilOp: set stencil test actions on the stencil buffer // fail:Specifies the action to take when the stencil test fails. Options: GL_KEEP, GL_ZERO, // GL_REPLACE, GL_INCR, GL_DECR, and GL_INVERT. Default is GL_KEEP. // zfail: Specifies the stencil action when the stencil test passes, but the depth test fails. // Options and default same as for fail. // zpass: Specifies the stencil action when both the stencil test and the depth test pass, // or when the stencil test passes and either there is no depth buffer // or depth testing is not enabled. Options and default same as for fail. void glStencilOp (GLenum fail , GLenum zfail , GLenum zpass );

How to set the Stencil Buffer First, make sure we request the stencil buffer. Next, make sure we enable stencil test Example: Make a stencil buffer have value 1 inside a diamond shape and value 0 outside. glutInitDisplayMode( GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH | GLUT_STENCIL ); glEnable(GL_STENCIL_TEST); glClearStencil(0x0); // specify stencil clear value glClear(GL_STENCIL_BUFFER_BIT); // clear stencil buffer // Set the ref value to 0x1 glStencilFunc(GL_ALWAYS, 0x1, 0x1); // Replace stencil bit with ref (0x1) whenever we process a fragment glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE); // draw a diamond (we’ll not really render the color buffer, // but just use this to set the stencil buffer) glBegin(GL_QUADS); glVertex2f(-1,0); glVertex2f(0,1); glVertex2f(1,0); glVertex2f(0,-1); glEnd();

Everything All At Once Lighting, texturing, planar shadows, and planar reflections all at one time. Stencil & polygon offset eliminate aforementioned artifacts.

Complex Shadows On Objects

Shadowing using Projective Texture

Shadow Map

Shadow Volume