Technische Universität München Computer Graphics SS 2014 Graphics Effects Rüdiger Westermann Lehrstuhl für Computer Graphik und Visualisierung.

Slides:



Advertisements
Similar presentations
Visible-Surface Detection(identification)
Advertisements

Chapter 1 The Study of Body Function Image PowerPoint
GR2 Advanced Computer Graphics AGR
GR2 Advanced Computer Graphics AGR
15.1 Si23_03 SI23 Introduction to Computer Graphics Lecture 15 – Visible Surfaces and Shadows.
GR2 Advanced Computer Graphics AGR
GR2 Advanced Computer Graphics AGR
16.1 Si23_03 SI23 Introduction to Computer Graphics Lecture 16 – Some Special Rendering Effects.
9.1si31_2001 SI31 Advanced Computer Graphics AGR Lecture 9 Adding Realism Through Texture.
8.1si31_2001 SI31 Advanced Computer Graphics AGR Lecture 8 Polygon Rendering.
13.1 si31_2001 SI31 Advanced Computer Graphics AGR Lecture 13 An Introduction to Ray Tracing.
VOORBLAD.
Computer Graphics An Introduction. What’s this course all about? 05/10/2014 Lecture 1 2 We will cover… Graphics programming and algorithms Graphics data.
1 05/10/2014 Computer Graphics Lecture 10 Global Illumination 1: Ray Tracing and Radiosity Taku Komura.
Computer Graphics Inf4/MSc 1 Computer Graphics Lecture 4 View Projection Taku Komura.
Lecture 8 Transparency, Mirroring
25 seconds left…...
Technische Universität München Fakultät für Informatik Computer Graphics SS 2014 Sampling Rüdiger Westermann Lehrstuhl für Computer Graphik und Visualisierung.
Technische Universität München Fakultät für Informatik Computer Graphics SS 2014 Lighting Rüdiger Westermann Lehrstuhl für Computer Graphik und Visualisierung.
Technische Universität München Fakultät für Informatik Computer Graphics SS 2014 Transformations Rüdiger Westermann Lehrstuhl für Computer Graphik und.
Optimized Stencil Shadow Volumes
Graphics Pipeline.
Optimized Stencil Shadow Volumes
Game Programming 09 OGRE3D Lighting/shadow in Action
Computer Graphic Creator: Mohsen Asghari Session 2 Fall 2014.
CSL 859: Advanced Computer Graphics Dept of Computer Sc. & Engg. IIT Delhi.
Computer Graphics methods
Week 10 - Monday.  What did we talk about last time?  Global illumination  Shadows  Projection shadows  Soft shadows.
3D Graphics Rendering and Terrain Modeling
9/25/2001CS 638, Fall 2001 Today Shadow Volume Algorithms Vertex and Pixel Shaders.
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.
Practical and Robust Stenciled Shadow Volumes for Hardware-Accelerated Rendering Cass Everitt and Mark J. Kilgard Speaker: Alvin Date: 5/28/2003 NVIDIA.
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.
Computer Graphics Shadows
09/18/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Bump Mapping Multi-pass algorithms.
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.
CS 638, Fall 2001 Today Light Mapping (Continued) Bump Mapping with Multi-Texturing Multi-Pass Rendering.
Technology and Historical Overview. Introduction to 3d Computer Graphics  3D computer graphics is the science, study, and method of projecting a mathematical.
Week 2 - Wednesday CS361.
09/09/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Event management Lag Group assignment has happened, like it or not.
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.
CHAPTER 11 Shadows © 2008 Cengage Learning EMEA. LEARNING OBJECTIVES In this chapter you will learn about: – –Shadow rendering algorithms – –Blinn’s shadow.
Advanced Computer Graphics Depth & Stencil Buffers / Rendering to Textures CO2409 Computer Graphics Week 19.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
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.
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.
Computer graphics & visualization Shadows / Transparency.
Global Illumination. Local Illumination  the GPU pipeline is designed for local illumination  only the surface data at the visible point is needed to.
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
Rendering Pipeline Fall, D Polygon Rendering Many applications use rendering of 3D polygons with direct illumination.
11/24/ :45 Graphics II Shadow Maps Reflections Session 5.
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.
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.
Spring 2006 G5BAGR – Advanced Computer Graphics
Rendering Pipeline Fall, 2015.
3D Graphics Rendering PPT By Ricardo Veguilla.
Jim X. Chen George Mason University
Texture and Shadow Mapping
Frame Buffer Applications
Presentation transcript:

Technische Universität München Computer Graphics SS 2014 Graphics Effects Rüdiger Westermann Lehrstuhl für Computer Graphik und Visualisierung

Technische Universität München Computer Graphics Advanced graphics effects Effects which are not provided natively by the rasterization based graphics pipeline Scene reflections Shadows 2

Technische Universität München Computer Graphics Advanced graphics effects Reflections Note the difference between local illumination and scene reflection –Local illumination considers the reflection of direct light –Scene reflection considers the reflection of the scene Problem: which scene point reflects in an object point 3

Technische Universität München Computer Graphics Advanced graphics effects Scene reflections using rasterization based pipeline –Rasterization based pipeline projects scene onto the image plane –Camera position is projection center for all scene parts, ie. single view projection –To simulate scene reflections, the scene has to be rendered from multiple views, ie. from each object point that reflects towards the viewer –Requires many rendering passes, and is too costly in general 4

Technische Universität München Computer Graphics Advanced graphics effects Planar reflections –Reflect the scene about a planar mirror Basic algorithm: flip scene through the mirror and re- render 5

Technische Universität München Computer Graphics Advanced graphics effects Reflect of scene at the mirror plane requires finding the reflection matrix Re-render reflected scene but restrict drawing to the pixels through which the mirror is seen Mirror Reflected scene Wall 6

Technische Universität München Computer Graphics Advanced graphics effects The reflection matrix –p[3]: point on plane –n[3]: plane normal –d: n·p –Multiply reflection matrix with modeling matrix 7

Technische Universität München Computer Graphics Advanced graphics effects Restrict drawing of the flipped scene to the pixels through which the mirror is seen 8

Technische Universität München Computer Graphics Advanced graphics effects Restricted drawing via the stencil test –Stencil buffer: stores for each pixel a bit-mask –A stencil test can be performed after the depth test for each fragment Color buffer Depth buffer Stencil buffer 9

Technische Universität München Computer Graphics Advanced graphics effects Typical use of the stencil buffer/test stencil = 1 Initialize Stencil buffer Render pass 1Render pass 2 Test: ref = 0; stencil == ref Test: ref = 1; stencil == ref 10

Technische Universität München Computer Graphics Advanced graphics effects Mirror rendering algorithm A) Initialize modelview matrix, enable depth/stencil testing B) Render mirror to mask all covered pixels in stencil buffer mask = 1 11

Technische Universität München Computer Graphics Advanced graphics effects Mirror rendering algorithm C) Multiply modeling matrix with reflection matrix to flip the scene D) Render scene where pixels have been mask* *clip everything in front of the mirror plane using a clip-plane 12

Technische Universität München Computer Graphics Advanced graphics effects Mirror rendering algorithm E) Reset modeling matrix to initial state F) Render scene where pixels have not been mask + = 13

Technische Universität München Computer Graphics Advanced graphics effects Non planar reflections 14

Technische Universität München Computer Graphics Advanced graphics effects Environment mapping: –Simulate an infinitely small reflecting sphere in the center of the scene to be reflected –Compute (or measure) and store in a texture the incoming light at the sphere for all directions –At run-time, for a given reflection vector look-up the stored light from the texture and use as fragment color 15

Technische Universität München Computer Graphics Advanced graphics effects Cube maps –An alternative to environment maps which can be generated very efficiently using rendering functionality –Captures the incoming light through 6 faces of a cube centered at the environment center –Generated by rendering the scene 6 times from the cube center, with the respective cube face being the viewport 16

Technische Universität München Computer Graphics Advanced graphics effects See also

Technische Universität München Computer Graphics Advanced graphics effects Cube map is stored in 6 2D textures Cube map access: –For each fragment compute the reflection vector R –The largest component of R selects the cube face –By dividing the other components through the largest, the 2D texture coordinate in the selected face is given 18

Technische Universität München Computer Graphics Advanced graphics effects 19

Technische Universität München Computer Graphics Advanced graphics effects Cube map examples 20

Technische Universität München Computer Graphics Advanced graphics effects Effects which are not provided natively by the rasterization based graphics pipeline Scene reflections Shadows 21

Technische Universität München Computer Graphics Advanced graphics effects Why shadows? 22

Technische Universität München Computer Graphics Advanced graphics effects Shadows and visibility: Remember, the depth-test resolves visibility on a per- fragment basis –z-buffer stores minimum z-value of all fragments projecting into the same pixel –Testing during fragment processing Frustum (perspective) transformation preserves z-ordering Incremental z-value update (if fragment is closer to near plane than current one) –Visibility is with respect to the viewer 23

Technische Universität München Computer Graphics Advanced graphics effects z-buffer algorithm: colorbuffer  BackgroundColor z-buffer  1 foreach polygon foreach fragment x,y // generated by the rasterizer z = fragment x,y.depth if z < z-buffer[x,y] then// depth test z-buffer[x,y] = z colorbuffer[x,y] = fragment x,y.color 24

Technische Universität München Computer Graphics Advanced graphics effects Visibility: which objects can be seen from the view point? Shadows: which objects can be seen from the light source? © Bertrand Clerc Design 25

Technische Universität München Computer Graphics Advanced graphics effects Shadow mapping –Simulates shadows in two rendering passes (1)Renders the scene from the light source position to determine all fragments which are not in shade, ie. which are seen by the light (2)Renders the scene from the camera position and tests each generated fragment whether it was seen or not in the first pass  If it was seen in the first pass it receives light, otherwise it is in shade and its color is darkened  The test simply checks whether in the first pass there was a fragment closer to the light than the current fragment 26

Technische Universität München Computer Graphics Advanced graphics effects Shadow mapping – the 1st pass –Since we need the fragments from the first pass to perform the test in the second pass, these fragments have to be stored –What we store is the distances of these fragments to the light source, which is simply the content of the deph buffer after the first pass 27

Technische Universität München Computer Graphics Advanced graphics effects Shadow mapping – the 1st pass: the depth buffer after the first rendering pass is stored in a texture map – the shadow map –In DX this can be realized by a pixel shader that computes the fragments depth values and writes these values into a texture resource instead of the color buffer –First, set up the description of the texture, then create that texture, and finally use the texture to setup a render target view –The so-generated texture can then be made accessible to a pixel shader in the second rendering pass 28

Technische Universität München Computer Graphics Advanced graphics effects Shadow mapping – the 2nd pass renders from the camera –A pixel shader computes the fragments distances to the light source –The shader also projects the fragments towards the light source into the shadow map – the fragments coordinate after projection is used as texture coordinate into the shadow map Light Depth of fragment to light source 29

Technische Universität München Computer Graphics Advanced graphics effects Shadow mapping – the 2nd pass –Finally, the shader compares the fragments depth with the depth stored in the shadow map and decides whether it is in shade or not Light Depth in shadow map Depth of fragment to light source 30

Technische Universität München Computer Graphics Advanced graphics effects Shadow mapping –Requires one additional rendering pass per light source –Can only be used in combination with point light sources –Artefacts can occur due to the resolution of the shadow map 4096x x

Technische Universität München Computer Graphics Shadow volumes –Relies on a geometric representation of the spatial region that is shadowed by an object –Shadow polyhedra is generated by projecting the objects´ shilouette edges (as seen from the light source) onto the shadowed surface and connecting the respective points –Shadow algorithm now tests whether object points, ie. fragments, are inside or outside a shadow volume

Technische Universität München Computer Graphics Shadow volumes

Technische Universität München Computer Graphics Shadow volumes Shadow volume geometry Without shadows Shadow volume Final scene

Technische Universität München Computer Graphics Shadow volumes When is a point in shadow? Shadow volume algorithm [Crow 1977] –Intersect the rays from the eye with shadow volume boundaries –For each ray Start with counter = 0, and increment/decrement the counter at every shadow volume front/back face If ray hits an object and counter == 0, then the object point is not in shadow

Technische Universität München Computer Graphics Shadow volumes Algorithm [Heidmann 91] 1.Render the unlit scene and clear the stencil buffer 2.Loop over all light sources Clear stencil buffer, disable depth write and color write but leave depth test enabled Render front-facing polygons of the shadow volume and increment the stencil where they pass the depth test Render back-facing polygons of the shadow volume and decrement the stencil where they pass the depth test Render the lit scene where stencil value = 0 (with additive blending) Note: –Stencil value classifies fragments as shadowed or unshadowed Shadowed pixels end up with non-zero stencil

Technische Universität München Computer Graphics Shadowing object Light source Eye position zero Unshadowed object Shadow Volume Count = = 0 Illuminated (Behind Shadow Volumes)

Technische Universität München Computer Graphics Shadowing object Light source Eye position zero Shadowed object Shadow Volume Count = = 2 Shadowed (inside Shadow Volumes)

Technische Universität München Computer Graphics Shadowing object Light source Eye position zero Uns hadowed object Shadow Volume Count = 0 Illuminated (before Shadow Volumes)