Real Time Reflections Han-Wei Shen

Similar documents
Ray Tracing: Special Topics CSCI 4239/5239 Advanced Computer Graphics Spring 2018

Computer Graphics. Lecture 9 Environment mapping, Mirroring

For Intuition about Scene Lighting. Today. Limitations of Planar Shadows. Cast Shadows on Planar Surfaces. Shadow/View Duality.

Last Time. Why are Shadows Important? Today. Graphics Pipeline. Clipping. Rasterization. Why are Shadows Important?

Real-Time Shadows. Last Time? Today. Why are Shadows Important? Shadows as a Depth Cue. For Intuition about Scene Lighting

Rendering If we have a precise computer representation of the 3D world, how realistic are the 2D images we can generate? What are the best way to mode

Computergrafik. Matthias Zwicker. Herbst 2010

Graphics pipeline and transformations. Composition of transformations

Last Time. Reading for Today: Graphics Pipeline. Clipping. Rasterization

Robust Stencil Shadow Volumes. CEDEC 2001 Tokyo, Japan

Lecture 17: Recursive Ray Tracing. Where is the way where light dwelleth? Job 38:19

Rasterization Overview

Real-Time Shadows. Last Time? Textures can Alias. Schedule. Questions? Quiz 1: Tuesday October 26 th, in class (1 week from today!

Recursive Ray Tracing. Ron Goldman Department of Computer Science Rice University

TSBK03 Screen-Space Ambient Occlusion

Shadow Algorithms. CSE 781 Winter Han-Wei Shen

Recollection. Models Pixels. Model transformation Viewport transformation Clipping Rasterization Texturing + Lights & shadows

03 RENDERING PART TWO

Computer Graphics. Shadows

CMSC427 Advanced shading getting global illumination by local methods. Credit: slides Prof. Zwicker

Project 1, 467. (Note: This is not a graphics class. It is ok if your rendering has some flaws, like those gaps in the teapot image above ;-)

CS 112 The Rendering Pipeline. Slide 1

Chapter 5. Projections and Rendering

Rendering. Converting a 3D scene to a 2D image. Camera. Light. Rendering. View Plane

Real-Time Shadows. MIT EECS 6.837, Durand and Cutler

Homework #2. Shading, Ray Tracing, and Texture Mapping

Orthogonal Projection Matrices. Angel and Shreiner: Interactive Computer Graphics 7E Addison-Wesley 2015

Introduction to Visualization and Computer Graphics

Clipping. CSC 7443: Scientific Information Visualization

Real-Time Shadows. Last Time? Schedule. Questions? Today. Why are Shadows Important?

Computer Graphics 10 - Shadows

Today. Rendering pipeline. Rendering pipeline. Object vs. Image order. Rendering engine Rendering engine (jtrt) Computergrafik. Rendering pipeline

COMP3421. Introduction to 3D Graphics

REFLECTION & REFRACTION

Approximating Refraction Kenneth Hurley Please send me comments/questions/suggestions

Last week. Machiraju/Zhang/Möller

So far, we have considered only local models of illumination; they only account for incident light coming directly from the light sources.

Pipeline Operations. CS 4620 Lecture 10

Computer Graphics Shadow Algorithms

Game Architecture. 2/19/16: Rasterization

CS451Real-time Rendering Pipeline

3D Viewing. CMPT 361 Introduction to Computer Graphics Torsten Möller. Machiraju/Zhang/Möller

Shadows in the graphics pipeline

Textures. Texture coordinates. Introduce one more component to geometry

Light: Geometric Optics

Real-Time Shadows. Computer Graphics. MIT EECS Durand 1

Pipeline Operations. CS 4620 Lecture Steve Marschner. Cornell CS4620 Spring 2018 Lecture 11

Light & Optical Systems Reflection & Refraction. Notes

CSE 690: GPGPU. Lecture 2: Understanding the Fabric - Intro to Graphics. Klaus Mueller Stony Brook University Computer Science Department

Chapter 2 A top-down approach - How to make shaded images?

Ray tracing. Computer Graphics COMP 770 (236) Spring Instructor: Brandon Lloyd 3/19/07 1

CPSC GLOBAL ILLUMINATION

3D Polygon Rendering. Many applications use rendering of 3D polygons with direct illumination

Acknowledgement: Images and many slides from presentations by Mark J. Kilgard and other Nvidia folks, from slides on developer.nvidia.

Pipeline Operations. CS 4620 Lecture 14

Global Rendering. Ingela Nyström 1. Effects needed for realism. The Rendering Equation. Local vs global rendering. Light-material interaction

Models and Architectures. Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico

The Ray model of Light. Reflection. Class 18

Shading, Advanced Rendering. Week 7, Wed Feb 28

Local Illumination. CMPT 361 Introduction to Computer Graphics Torsten Möller. Machiraju/Zhang/Möller

Surface Graphics. 200 polys 1,000 polys 15,000 polys. an empty foot. - a mesh of spline patches:

Computer Graphics I Lecture 11

CS230 : Computer Graphics Lecture 4. Tamar Shinar Computer Science & Engineering UC Riverside

Light: Geometric Optics (Chapter 23)

CSE 167: Introduction to Computer Graphics Lecture #5: Projection. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2017

What for? Shadows tell us about the relative locations. Vienna University of Technology 2

Reading. 18. Projections and Z-buffers. Required: Watt, Section , 6.3, 6.6 (esp. intro and subsections 1, 4, and 8 10), Further reading:

Volume Shadows Tutorial Nuclear / the Lab

Lecture 19: All Together with Refraction

At the interface between two materials, where light can be reflected or refracted. Within a material, where the light can be scattered or absorbed.

RASTERISED RENDERING

3D Viewing. Introduction to Computer Graphics Torsten Möller. Machiraju/Zhang/Möller

Introduction to Computer Graphics with WebGL

CIS 581 Interactive Computer Graphics

CS 130 Final. Fall 2015

Projection and viewing. Computer Graphics CSE 167 Lecture 4

Level of Details in Computer Rendering

Pixels and Buffers. CS 537 Interactive Computer Graphics Prof. David E. Breen Department of Computer Science

Notes on Assignment. Notes on Assignment. Notes on Assignment. Notes on Assignment

CSE 167: Introduction to Computer Graphics Lecture #9: Visibility. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2018

Software Engineering. ò Look up Design Patterns. ò Code Refactoring. ò Code Documentation? ò One of the lessons to learn for good design:

CIS 581 Interactive Computer Graphics (slides based on Dr. Han-Wei Shen s slides) Requirements. Reference Books. Textbook

Introduction Ray tracing basics Advanced topics (shading) Advanced topics (geometry) Graphics 2010/2011, 4th quarter. Lecture 11: Ray tracing

E.Order of Operations

CS559 Computer Graphics Fall 2015

COMP3421. Introduction to 3D Graphics

CHETTINAD COLLEGE OF ENGINEERING & TECHNOLOGY CS2401 COMPUTER GRAPHICS QUESTION BANK

Optics INTRODUCTION DISCUSSION OF PRINCIPLES. Reflection by a Plane Mirror

CSE 167: Introduction to Computer Graphics Lecture #5: Rasterization. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2015

Rendering. Mike Bailey. Rendering.pptx. The Rendering Equation

Virtual Reality for Human Computer Interaction

CS 4204 Computer Graphics

CS184 : Foundations of Computer Graphics Professor David Forsyth Final Examination

Shadow Rendering EDA101 Advanced Shading and Rendering

Topics and things to know about them:

CS 498 VR. Lecture 18-4/4/18. go.illinois.edu/vrlect18

Reflection and Refraction of Light

CHAPTER 1 Graphics Systems and Models 3

Lecture 4. Viewing, Projection and Viewport Transformations

Physics Experiment 13

Transcription:

Real Time Reflections Han-Wei Shen

Reflections One of the most noticeable effect of inter-object lighting Direct calculation of the physics (ray tracing) is too expensive Our focus is to capture the most significant ifi reflection while minimizing the overhead via rendering the virtual object virtual object Clipped to reflector reflector object

Image vs. Object Space Methods Image space methods: create a texture from a view of the reflected objects and apply it to the reflector Advantage: does not depend d on the object geometry Disadvantage: sampling issue and also only an approximation (environment mapping as an example) Object space methods: create the actual geometry of the object s reflection and render it to the reflector Disadvantage: accuracy of the geometry Advantage: more accurate reflection (for nearby objects) Both methods need to create the virtual objects

Planar Reflections The most common reflection flat mirror, floor, wall, etc Creating virtual objects for the reflected objects is much easier A view independent operation only consider the relative position of the object and the reflector The virtual object is created by transforming the object across the reflector plan

Reflection Transformation Can be broken into three stages: 1. Transform the objects into the reflector s local coordinate system Translate the reflector to the world origin and rotate so the reflector plane will coincident with the world s XY plane 2. Scale by -1 in Z 3. Transform the reflected object s local coordinates of the reflector back to the world coordinates Rotate the world s XY plane to the reflector s plane and then translate the origin to the reflector s local origin Overall - A translation of the mirror plane to the origin, a Overall A translation of the mirror plane to the origin, a rotation embedding the mirror to x-y plane, a scale of -1 in Z, inverse rotation, and a translation back to the mirror location

Reflection Matrix Given a point P on the reflector plane, vector V perpendicular to the plane 1-2Vx^2-2VxVy -2VxVz 2(P.V)Vx R = -2VxVy 1-2Vy^2-2VyVz 2(P.V)Vy -2VxVz -2VyVz 1-2Vz^2 2(P.V)Vz 0 0 0 1 Multiply R to the object vertices produce an reflected object on the opposite side of the reflector plane The entire scene is duplicated, simulating a reflector of infinite extent

Render the Reflected Geometry An important task: clip the reflected geometry so that it is only visible on the reflector surface Beyond the reflector boundaries and in front of reflector side front

Clipping using the stencil You only want the reflected geometry to appear on the reflector surface Use stencil buffer: Clear the stencil buffer Render the reflector and set the stencil Render the reflected geometry only at where the stencil pixels have been set The above algorithm is to use the stencil buffer to control where to draw the reflection

Clipping using the stencil Another method: render the reflected object first, and then render the reflector to set the stencil buffer, then clear the color buffer everywhere except where the stencil being set This method is to use the stencil buffer to control where to erased the incorrect reflection Advantage: when it is faster to use stencil to control clearing the scene than drawing the entire scene with stenfil tests

The stencil erase algorithm Draw the reflected objects Clear the stencil and depth buffers Configure the stencil so that t 1 will be set where polygons are rendered Disable draw to color buffer Draw the reflector Reconfigure the stencil Clear the color and depth buffer to the background color (except where the stencil being set) Disable stencil test Draw the rest of scene (except reflected objects and reflector)

The stencil erase algorithm

Clipping using texture mapping Render the reflected geometry Store the image into a texture (using FBO or glcopyteximage2d) Clear the color and depth buffer Redraw the entire scene, with the reflector textured with the previous texture (the process of texturing reflector will automatically clip the reflected geometry outside the boundary) Note that reflected geometry in front of the reflector still needs to be clipped before the texture map is created (using the reflector as the clipping plane supported by OpenGL s application clipping plane)

Clipping using texture mapping The key is to assign correct texture coordinates to the reflector Basic idea s and t coordinates correlate to x and y window coordinates of the reflector Project the reflector vertex to the clip space Bias and scale the texture coordinates from [-1,1] to [0,1] Perform perspective division and use the first two components to access the texture

Clipping using texture mapping

Interreflection Goal: let the reflections to bounce between reflectors The number of bounces needs to be limited to preserve interactivity The reflection transformations need to be concatenated Render the deepest interreflection first

Interreflection Clear the stencil buffer Set the stencil operation to increment the stencil values where pixels are rendered Render each reflector involved in interreflection into stencil buffer Set the stencil test to pass where the stencil value equal the number of interreflection Apply planar transformation Draw the reflected scene Draw the reflector, blending if desired

Refraction Snell s law refraction angel is based on the medium s refraction index n1 sin 1 = n2 sin 2 U (eye) N n1 n1 R (refraction vector) n2 n2

Refraction Vector n = n1/n2 R = nu N( n(n.u) + 1-n^2(1-(N.U)^2) (N ) or R = U (1-n)N(N.U) (a simplified form) U (eye) N n1 R n2

Planar Refraction Move the eye point to match the refraction vector 1/n * d d away from the interface rotate the eye (when not (when eye ray is perpendicualr) Perpendicular) When the refraction ray bent toward the normal direction (a common case)

Environment Map Refraction Take 6 shots from the refractor to its environment Based on the eye rays, calculate the refracted rays using snell s s law at each refractor s vertex Using the refracted rays as texture coordinate (s,t,r) to look up the environment cube map

Environment Map Refraction Create Environment Cube Map Calculate the refractor ray and Use it as the texture coordinates to the environment cube map result