lecture 18 - ray tracing - environment mapping - refraction

Similar documents
COMP environment mapping Mar. 12, r = 2n(n v) v

lecture 19 Shadows - ray tracing - shadow mapping - ambient occlusion Interreflections

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

Level of Details in Computer Rendering

CHAPTER 1 Graphics Systems and Models 3

CS 381 Computer Graphics, Fall 2008 Midterm Exam Solutions. The Midterm Exam was given in class on Thursday, October 23, 2008.

Pipeline Operations. CS 4620 Lecture 10

CS 4620 Program 3: Pipeline

CS451Real-time Rendering Pipeline

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

Computer Graphics. Lecture 9 Environment mapping, Mirroring

Photorealism: Ray Tracing

Lighting. To do. Course Outline. This Lecture. Continue to work on ray programming assignment Start thinking about final project

Complex Shading Algorithms

Topics and things to know about them:

Pipeline Operations. CS 4620 Lecture 14

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

CS 354R: Computer Game Technology

Problem Set 4 Part 1 CMSC 427 Distributed: Thursday, November 1, 2007 Due: Tuesday, November 20, 2007

CS 4620 Midterm, March 21, 2017

6.837 Introduction to Computer Graphics Final Exam Tuesday, December 20, :05-12pm Two hand-written sheet of notes (4 pages) allowed 1 SSD [ /17]

Deferred Rendering Due: Wednesday November 15 at 10pm

Supplement to Lecture 16

Effects needed for Realism. Computer Graphics (Fall 2008) Ray Tracing. Ray Tracing: History. Outline

Consider a partially transparent object that is illuminated with two lights, one visible from each side of the object. Start with a ray from the eye

Introduction to Visualization and Computer Graphics

Texture mapping. Computer Graphics CSE 167 Lecture 9

Einführung in Visual Computing

Computer Graphics. Lecture 02 Graphics Pipeline. Edirlei Soares de Lima.

Computer Graphics. Lecture 13. Global Illumination 1: Ray Tracing and Radiosity. Taku Komura

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

The Rasterization Pipeline

CPSC / Texture Mapping

COMP 4801 Final Year Project. Ray Tracing for Computer Graphics. Final Project Report FYP Runjing Liu. Advised by. Dr. L.Y.

03 RENDERING PART TWO

Recall: Indexing into Cube Map

Shadows in the graphics pipeline

TSBK 07! Computer Graphics! Ingemar Ragnemalm, ISY

Topic 12: Texture Mapping. Motivation Sources of texture Texture coordinates Bump mapping, mip-mapping & env mapping

CSE528 Computer Graphics: Theory, Algorithms, and Applications

Rasterization Overview

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

Lecture 2. Shaders, GLSL and GPGPU

COMP371 COMPUTER GRAPHICS

Topic 11: Texture Mapping 11/13/2017. Texture sources: Solid textures. Texture sources: Synthesized

CS 4620 Program 4: Ray II

Homework 3: Programmable Shaders

CS 465 Program 5: Ray II

Intro to Ray-Tracing & Ray-Surface Acceleration

Graphics for VEs. Ruth Aylett

Midterm Exam Fundamentals of Computer Graphics (COMP 557) Thurs. Feb. 19, 2015 Professor Michael Langer

CS 431/636 Advanced Rendering Techniques

Scanline Rendering 2 1/42

Overview: Ray Tracing & The Perspective Projection Pipeline

Topic 11: Texture Mapping 10/21/2015. Photographs. Solid textures. Procedural

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

Movie: Geri s Game. Announcements. Ray Casting 2. Programming 2 Recap. Programming 3 Info Test data for part 1 (Lines) is available

Textures and normals in ray tracing

Computer Graphics. Lecture 10. Global Illumination 1: Ray Tracing and Radiosity. Taku Komura 12/03/15

Ray Tracing. Kjetil Babington

Ulf Assarsson Department of Computer Engineering Chalmers University of Technology

CS 488. More Shading and Illumination. Luc RENAMBOT

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

CS Simple Raytracer for students new to Rendering

Textures. Texture coordinates. Introduce one more component to geometry

Blue colour text questions Black colour text sample answers Red colour text further explanation or references for the sample answers

ECS 175 COMPUTER GRAPHICS. Ken Joy.! Winter 2014


Computer Graphics (CS 543) Lecture 10: Soft Shadows (Maps and Volumes), Normal and Bump Mapping

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

Interactive Computer Graphics A TOP-DOWN APPROACH WITH SHADER-BASED OPENGL

Mach band effect. The Mach band effect increases the visual unpleasant representation of curved surface using flat shading.

Computer Graphics (CS 543) Lecture 13b Ray Tracing (Part 1) Prof Emmanuel Agu. Computer Science Dept. Worcester Polytechnic Institute (WPI)

OpenGl Pipeline. triangles, lines, points, images. Per-vertex ops. Primitive assembly. Texturing. Rasterization. Per-fragment ops.

Lecture 12: Advanced Rendering

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

The University of Calgary

Lecture 11: Ray tracing (cont.)

Homework #2. Shading, Projections, Texture Mapping, Ray Tracing, and Bezier Curves

Assignment 2 Ray Tracing

COMP 175: Computer Graphics April 11, 2018

Shading, Advanced Rendering. Week 7, Wed Feb 28

Ray Tracing. CSCI 420 Computer Graphics Lecture 15. Ray Casting Shadow Rays Reflection and Transmission [Ch ]

GLOBAL EDITION. Interactive Computer Graphics. A Top-Down Approach with WebGL SEVENTH EDITION. Edward Angel Dave Shreiner

CS 130 Exam I. Fall 2015

frame buffer depth buffer stencil buffer

CS 464 Review. Review of Computer Graphics for Final Exam

Effects needed for Realism. Ray Tracing. Ray Tracing: History. Outline. Foundations of Computer Graphics (Spring 2012)

Sung-Eui Yoon ( 윤성의 )

Photorealistic 3D Rendering for VW in Mobile Devices

Computer Graphics Lecture 11

Graphics and Interaction Rendering pipeline & object modelling

Lighting and Shading

Ray Tracing. Outline. Ray Tracing: History

3D Programming. 3D Programming Concepts. Outline. 3D Concepts. 3D Concepts -- Coordinate Systems. 3D Concepts Displaying 3D Models

Ray Tracing COMP575/COMP770

Motivation. Sampling and Reconstruction of Visual Appearance. Effects needed for Realism. Ray Tracing. Outline

Culling. Computer Graphics CSE 167 Lecture 12

Programmable GPUS. Last Time? Reading for Today. Homework 4. Planar Shadows Projective Texture Shadows Shadow Maps Shadow Volumes

MITOCW MIT6_172_F10_lec18_300k-mp4

Transcription:

lecture 18 - ray tracing - environment mapping - refraction

Recall Ray Casting (lectures 7, 8) for each pixel (x,y) { cast a ray through that pixel into the scene, and find the closest surface along the ray through that pixel } compute the RGB value, based on that surface

Ray tracing is like ray casting, but now mirror reflections are allowed. Shadow to be discussed next week.

for each pixel (x,y) { Ray Tracing (sketch) cast a ray through that pixel into the scene if the nearest surface is a mirror, repeat re-cast the ray in the reflection direction until you hit a non-mirror surface } else compute the RGB value of the visible non-mirror surface and assign that value to the pixel (x,y) // All the techniques we discussed in lecture 8 can be applied here. e.g. BSP trees, octrees, hierarchical bounding volumes

eye "cast ray" mirror "reflected ray " checkerboard ground

Recall lecture 12: Mirror Reflection light reflection direction mirror

A similar model is used in ray tracing. viewer reflection direction mirror

In Assignment 3, you will implement a simple ray tracer. Part of the material for A3 involves shadows, which we discuss next lecture.

Ray tracing does not naturally fit into graphics pipeline. clip coordinates fragments vertices pixels vertex processor "primitive assembly" & clipping rasterization fragment processor Why not? Because...vertex and fragment shaders only have access to a small amount of information (in particular, local scene geometry)

Environment Mapping If you want real time graphics with mirror surfaces, use "environment mapping" instead. An "environment map" is a "360 deg" RGB image of a scene, defined on the unit sphere centered at some scene point. We denote it E(rx, ry, rz) where r is direction of rays to the environment as seen from the scene point. physical situation E(rx, ry, rz)

Environment Mapping Algorithm for each pixel (xp,yp) { cast a ray through (xp, yp) to the nearest scene point (x,y,z) if (x,y,z) has mirror reflectance { compute mirror reflection direction (rx, ry, rz) } // copy environment map value I(xp, yp) = E(rx, ry, rz) } else compute RGB using Blinn-Phong (or other model) How does this differ from ray tracing?

Example (Blinn and Newell 1976) hand drawn (cylindrical) environment by Jim Blinn Notice reflections of windows in the teapot. This teapot has diffuse shading + mirror components. Today we will talk only about the mirror component.

A more complex environment...

Cube map (Green 1986) a data structure for environment maps Construct 6 images, each with 90 deg field of view angle.

Examples google "cube map images" These (cube mapped) environment maps are pre-computed. They are OpenGL textures.

How to index into a cube map? (derivation over next few slides) Given reflection vector r = (rx, ry, rz), lookup E(rx, ry, rz) How?

A: Project r onto cube face. ( rx, ry, rz ) = ( rx, ry, rz ) / max { rx, ry, rz }. One of the components will have value +- 1, and this tells us which face of the cube to use. The other two components are used for indexing into that face. Need to remap the indices from [-1, 1] to [0, N) where each face of the cube map has NxN pixels.

Sphere Map a second data structure for environment maps The reflection of the scene in a small mirror sphere.

Q: How much of scene is visible in the reflection off a mirror sphere? A: - 180 degrees? (half of the scene) - between 180 and 360 degrees? - 360 degrees? (the entire scene)

Claim: if you are given the reflection of a scene in a small spherical mirror, then you can compute what any mirror object looks like (if know the object's shape). Why? All you need to know is the reflection direction at each pixel and then use it to index index into the environment map defined by the given image of the sphere.

How to index into a sphere map? Given reflection vector r = (rx, ry, rz), lookup E(rx, ry, rz) Q: How? A: Map r = (rx, ry, rz) to (s, t) which is defined below.

Let's now derive the mapping. First observe: For a point on a unit sphere,

Texture coordinates for a sphere map Identify (s,t) coordinates with (nx, ny).

To map r = (rx, ry, rz) to (s,t), assume orthographic projection, namely assume v = (0, 0, 1) for all surface points.

Substituting for v and n and manipulating gives: (details in lecture notes)

Capturing Environment Maps with Photography early 1980s http://www.pauldebevec.com/reflectionmapping/

Hollywood: Terminator 2 (1991) How was this achieved?

Q: What implicit assumptions are we making when using environment maps? A: We assume the environment is the same for all scene points (x,y,z). This essentially assumes that the environment is at infinity. Why is that wrong? Why does it not matter?

Q: For the scene below, which of the objects (1, 2, 3, 4) would be visible or partly visible either directly or in the mirror, if we used: - ray tracing - environment mapping

Q: For the scene below, which of the objects (1, 2, 3, 4) would be visible or partly visible directly, if we used: - ray tracing - environment mapping A: 3, 4 (but not 1, 2)

Q: For the scene below, which of the objects (1, 2, 3, 4) would be visible or partly visible in the mirror, if we used: - ray tracing - environment mapping A: 2, 3, 4 (but not 1)

Q: For the scene below, which of the objects (1, 2, 3, 4) would be visible or partly visible in the mirror, if we used: - ray tracing - environment mapping A: 1, 3, 4 (but not 2)

Notice the poor resolution at the rim of the circle.

Where do various steps of environment mapping occur in the graphics pipeline? clip coordinates fragments vertices pixels vertex processor "primitive assembly" & clipping rasterization fragment processor

Vertex processor...? Rasterizer...? Fragment processor...?

Solution 1 (bad, not used): Vertex processor computes the reflection vector r for each vertex, and looks up RGB values from environment map. Rasterizer interpolates RGB values and assigns them to the fragments. Fragment processor does basically nothing. Why is this bad? (Hint: think of what would happen for a square mirror. It would smoothly interpolate between the values at the four corners. That's not what real mirrors do.)

Solution 2 (good): Vertex processor computes the reflection vector r for each vertex. Rasterizer interpolates reflection vectors and assigns them to the fragments. Fragment processor uses reflection vectors to look up RGB values in the environment map.

Any image of a sphere can be used as an environment map.

lecture 18 - ray tracing - environment mapping - refraction

Refraction

You can use environment mapping or ray tracing to get the RGB value. Environment mapping can be done in OpenGL 2.x and beyond using shaders.

See nice video here. http://3dgep.com/environment-mapping-with-cg-and-opengl/ #The_Refraction_Shader

Geri's Game (1997, Pixar, won Oscar for animation) https://www.youtube.com/watch?v=9iyrc7g2icg Check out refraction in glasses around 2 minutes in. This was done using environment mapping.