INFOGR Computer Graphics

Similar documents
INFOGR Computer Graphics. Jacco Bikker - April-July Lecture 3: Geometry. Welcome!

INFOGR Computer Graphics. Jacco Bikker - April-July Lecture 3: Ray Tracing (Introduction) Welcome!

INFOGR Computer Graphics

INFOGR Computer Graphics. J. Bikker - April-July Lecture 10: Shading Models. Welcome!

INFOGR Computer Graphics. J. Bikker - April-July Lecture 10: Ground Truth. Welcome!

INFOGR Computer Graphics. Jacco Bikker - April-July Lecture 14: Grand Recap. Welcome!

INFOGR Computer Graphics

INFOGR Computer Graphics

CENG 477 Introduction to Computer Graphics. Ray Tracing: Shading

Lecture 7 - Path Tracing

Virtual Reality for Human Computer Interaction

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

Practical 2: Ray Tracing

CS354 Computer Graphics Ray Tracing. Qixing Huang Januray 24th 2017

COMP 175 COMPUTER GRAPHICS. Lecture 11: Recursive Ray Tracer. COMP 175: Computer Graphics April 9, Erik Anderson 11 Recursive Ray Tracer

INFOGR Computer Graphics. J. Bikker - April-July Lecture 11: Acceleration. Welcome!

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

Topic 9: Lighting & Reflection models 9/10/2016. Spot the differences. Terminology. Two Components of Illumination. Ambient Light Source

Soft shadows. Steve Marschner Cornell University CS 569 Spring 2008, 21 February

Illumination and Shading

Topic 9: Lighting & Reflection models. Lighting & reflection The Phong reflection model diffuse component ambient component specular component

Raytracing CS148 AS3. Due :59pm PDT

Pipeline Operations. CS 4620 Lecture 10

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

Shadows. COMP 575/770 Spring 2013

INFOGR Computer Graphics. J. Bikker - April-July Lecture 11: Visibility. Welcome!

Complex Shading Algorithms

Monte Carlo Ray Tracing. Computer Graphics CMU /15-662

Lighting and Shading

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

Illumination. The slides combine material from Andy van Dam, Spike Hughes, Travis Webb and Lyn Fong

Today s class. Simple shadows Shading Lighting in OpenGL. Informationsteknologi. Wednesday, November 21, 2007 Computer Graphics - Class 10 1

Ray Tracing Part 1. CSC418/2504 Introduction to Computer Graphics. TA: Muhammed Anwar & Kevin Gibson

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

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

Supplement to Lecture 16

Illumination & Shading: Part 1

Rendering Part I (Basics & Ray tracing) Lecture 25 December 1, 2015

Computer Graphics (CS 4731) Lecture 16: Lighting, Shading and Materials (Part 1)

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

Computer Graphics (CS 543) Lecture 7b: Intro to lighting, Shading and Materials + Phong Lighting Model

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

CPSC 314 LIGHTING AND SHADING

Pipeline Operations. CS 4620 Lecture 14

Graphics (INFOGR ): Example Exam

Texture mapping. Computer Graphics CSE 167 Lecture 9

Illumination. Michael Kazhdan ( /657) HB Ch. 14.1, 14.2 FvDFH 16.1, 16.2

Computer Graphics. Lecture 14 Bump-mapping, Global Illumination (1)

Texturing. Texture Mapping. Texture Mapping. Have seen: colour can be assigned to ver7ces But: don t want to represent all this detail with geometry

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

Interactive Real-Time Raycasting

INFOMAGR Advanced Graphics. Jacco Bikker - February April Welcome!

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

Geometric optics. The University of Texas at Austin CS384G Computer Graphics Don Fussell

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

Assignment 6: Ray Tracing

Lecture 15: Shading-I. CITS3003 Graphics & Animation

Simple Lighting/Illumination Models

Homework #2. Hidden Surfaces, Projections, Shading and Texture, Ray Tracing, and Parametric Curves

Previously... contour or image rendering in 2D

Visualisatie BMT. Rendering. Arjan Kok

CPSC / Texture Mapping

TSBK 07! Computer Graphics! Ingemar Ragnemalm, ISY

Reading. Ray Tracing. Eye vs. light ray tracing. Geometric optics. Required:

Texture Mapping II. Light maps Environment Maps Projective Textures Bump Maps Displacement Maps Solid Textures Mipmaps Shadows 1. 7.

Rendering Algorithms: Real-time indirect illumination. Spring 2010 Matthias Zwicker

Reading. Ray Tracing. Eye vs. light ray tracing. Geometric optics. Required: Watt, sections , (handout) Further reading:

Shading. Shading = find color values at pixels of screen (when rendering a virtual 3D scene).

Screen Space Ambient Occlusion. Daniel Kvarfordt & Benjamin Lillandt

Local vs. Global Illumination & Radiosity

Practical Techniques for Ray Tracing in Games. Gareth Morgan (Imagination Technologies) Aras Pranckevičius (Unity Technologies) March, 2014

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

Computer Graphics Ray Casting. Matthias Teschner

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

Introduction Rasterization Z-buffering Shading. Graphics 2012/2013, 4th quarter. Lecture 09: graphics pipeline (rasterization and shading)

Ray Tracing. Brian Curless CSEP 557 Fall 2016

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

Lighting and Materials

2/1/10. Outline. The Radiance Equation. Light: Flux Equilibrium. Light: Radiant Power. Light: Equation. Radiance. Jan Kautz

Shading 1: basics Christian Miller CS Fall 2011

Advanced Shading I: Shadow Rasterization Techniques

Volume Rendering. Lecture 21

Computergrafik. Matthias Zwicker Universität Bern Herbst 2016

Advanced Graphics. Path Tracing and Photon Mapping Part 2. Path Tracing and Photon Mapping

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

INFOMAGR Advanced Graphics. Jacco Bikker - February April Welcome!

Computer Graphics I. Assignment 3

Computer Graphics Lecture 11

Introduction to Radiosity

CS452/552; EE465/505. Clipping & Scan Conversion

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

CS 428: Fall Introduction to. Raytracing. Andrew Nealen, Rutgers, /18/2009 1

Ambien Occlusion. Lighting: Ambient Light Sources. Lighting: Ambient Light Sources. Summary

Computer Graphics. Illumination and Shading

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

The Rendering Equation and Path Tracing

782 Schedule & Notes

Today. Global illumination. Shading. Interactive applications. Rendering pipeline. Computergrafik. Shading Introduction Local shading models

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

Volume Illumination and Segmentation

Transcription:

INFOGR Computer Graphics Jacco Bikker & Debabrata Panja - April-July 2018 Lecture 5: Ray Tracing Welcome!

Today s Agenda: Ray Tracing Recap Shading Textures

INFOGR Lecture 5 Ray Tracing 4 Ray Tracing Ray Tracing: World space Geometry Eye Screen plane Screen pixels Primary rays Intersections Point light Shadow rays Light transport Extension rays Light transport

INFOGR Lecture 5 Ray Tracing 5 Recap D Ray definition Ray setup Point on the screen: p u, v = p 0 + u p 1 p 0 + v(p 2 p 0 ), u, v [0,1) Ray direction (before normalization): D = p u, v E A ray is an infinite line with a start point: p 0 p(t) = O + td, where t > 0. p 1 Ԧc t struct Ray { float3 O; float3 D; float t; }; // ray origin // ray direction // distance E O p 2 p 0 Ԧq O The ray direction is generally normalized. p 2 p 2 P? t = (O N + d)/(d N) D N = D x N x + D y N y + D z N z O N = O x N x + O y N y + O z N z

Today s Agenda: Ray Tracing Recap Shading Textures

INFOGR Lecture 5 Ray Tracing 7 Shading

INFOGR Lecture 5 Ray Tracing 8 Shading The End We used primary rays to find the primary intersection point. Determining light transport: Sum illumination from all light sources If they are visible. We used a primary ray to find the object visible through a pixel: Now we will use a shadow ray to determine visibility of a light source.

INFOGR Lecture 5 Ray Tracing 9 Shading Shadow Ray P light Constructing the shadow ray: p(t) = O + td Ray origin: the primary intersection point I. Ray direction: P light I (normalized) I Restrictions on t: 0 < t < P light I

INFOGR Lecture 5 Ray Tracing 10 Shading Shadow Ray P light Direction of the shadow ray: P light I P light I Equally valid: I P light P light I or I P light I P light Note that we get different intersection points depending on the direction of the shadow ray. It doesn t matter: the shadow ray is used to determine if there is an occluder, not where. I This has two consequences: 1. We need a dedicated shadow ray query; 2. Shadow ray queries are (on average) twice as fast. (why?)

INFOGR Lecture 5 Ray Tracing 11 Shading Shadow Ray In theory, theory and practice are the same. In practice, they are not. Problem 1: Our shadow ray queries report intersections at t = ~0. Why? Cause: the shadow ray sometimes finds the surface it originated from as an occluder, resulting in shadow acne. Fix: offset the origin by epsilon times the shadow ray direction. Note: don t forget to reduce t max by epsilon.

INFOGR Lecture 5 Ray Tracing 12 Shading Shadow Ray In theory, theory and practice are the same. In practice, they are not. Problem 2: Our shadow ray queries report intersections at t = t max. Why? Cause: when firing shadow rays from the light source, they may find the surface that we are trying to shade. Fix: reduce t max by 2 epsilon.

INFOGR Lecture 5 Ray Tracing 13 Shading Shadow Ray The most expensive shadow rays are those that do not find an intersection. Why? (because those rays tested every primitive before concluding that there was no occlusion)

INFOGR Lecture 5 Ray Tracing 14 Shading Transport The amount of energy travelling from the light via the surface point to the eye depends on: The brightness of the light source The distance of the light source to the surface point Absorption at the surface point The angle of incidence of the light energy

INFOGR Lecture 5 Ray Tracing 15 Shading Transport Brightness of the light source: Expressed in watt (W), or joule per second ( J/s or Js 1 ). Energy is transported by photons. Photon energy depends on wavelength; energy for a yellow photon is ~3.31 10 19 J. A 100W light bulb thus emits ~3.0 10 21 photons per second.

INFOGR Lecture 5 Ray Tracing 16 Shading Transport Energy at distance r: For a point light, a brief pulse of light energy spreads out as a growing sphere. The energy is distributed over the surface of this sphere. Energy per unit area is therefore proportional to the inverse area of the sphere at distance r, i.e.: E/m 2 = E light 1 4πr 2 Light energy thus dissipates at a rate of 1 r 2. This is referred to as distance attenuation.

INFOGR Lecture 5 Ray Tracing 17 Shading Transport Absorption: Most materials absorb light energy. The wavelengths that are not fully absorbed define the color of a material. The reflected light is thus: E reflected = E incoming C material Note that C material cannot exceed 1; the reflected light is never more than the incoming light. C material is typically a vector: we store r, g, b for all light transport. A x B x A B = A y C y A z C z ( entrywise product )

INFOGR Lecture 5 Ray Tracing 18 Shading Transport Energy arriving at an angle: A small bundle of light arriving at a surface affects a larger area than the cross-sectional area of the bundle. Per m 2, the surface thus receives less energy. The remaining energy is proportional to: cos α or: N L.

INFOGR Lecture 5 Ray Tracing 19 Shading Transport All factors: E light L Emitted light : defined as RGB color, floating point Distance attenuation: 1 r 2 Absorption, modulate by material color N dot L N α cos α color

INFOGR Lecture 5 Ray Tracing 20 Shading

Today s Agenda: Ray Tracing Recap Shading Textures

INFOGR Lecture 5 Ray Tracing 22 Textures Texturing a Plane Given a plane: y = 0 (i.e., with a normal vector (0,1,0) ). Two vectors on the plane define a basis: u = (1,0,0) and Ԧv = (0,0,1). Using these vectors, any point on the plane can be reached: P = λ 1 u + λ 2 Ԧv. We can now use λ 1, λ 2 to define a color at P: F(λ 1, λ 2 ) =. u Ԧv P

INFOGR Lecture 5 Ray Tracing 23 Textures Example: F(λ 1, λ 2 ) = sin(λ 1 ) Another example: F(λ 1, λ 2 ) = ( int (2 λ 1 ) + (int)λ 2 ) & 1

INFOGR Lecture 5 Ray Tracing 24 Textures Other examples (not explained here): Perlin noise Details: http://www.noisemachine.com/talk1 Voronoi / Worley noise Details: A cellular texture basis function, S. Worley, 1996.

INFOGR Lecture 3 Geometry Textures

INFOGR Lecture 5 Ray Tracing 26 Textures Obviously, not all textures can be generated procedurally. Finding P using basis vectors u, Ԧv and parameters λ 1, λ 2 : 0 255 0 P x P y = λ 1 u + λ 2 Ԧv = λ 1u x + λ 2 Ԧv x λ 1 u y + λ 2 Ԧv y 255...But what about the opposite, i.e. can we find λ 1, λ 2 given P? Ԧv P u

INFOGR Lecture 5 Ray Tracing 27 Textures Obviously, not all textures can be generated procedurally. For the generic case, we lookup the color value in a pixel buffer. x y = P u P Ԧv T width T height Note that we find the pixel to read based on P; we don t find a P for every pixel of the texture. Ԧv P u

INFOGR Lecture 5 Ray Tracing 28 Textures Retrieving a pixel from a texture: 0 255 0 x y = P u P Ԧv T width T height We don t want to read outside the texture. To prevent this, we have two options: 1. Clamping x y = clamp(p u, 0, 1) clamp(p Ԧv, 0,1) T width T height 255 2. Tiling x y = frac(p u) frac(p Ԧv) T width T height Tiling is efficiently achieved using a bitmask. This requires texture dimensions that are a power of 2.

INFOGR Lecture 5 Ray Tracing 29 Textures Texture mapping: oversampling

INFOGR Lecture 5 Ray Tracing 30 Textures Texture mapping: undersampling

INFOGR Lecture 5 Ray Tracing 31 Textures Fixing oversampling Oversampling: reading the same pixel from a texture multiple times. Symptoms: blocky textures. Remedy: bilinear interpolation: Instead of clamping the pixel location to the nearest pixel, we read from four pixels. w p1 : (1 frac(x)) (1 frac(y)) w p2 : frac x (1 frac y ) w p3 : 1 frac x frac(y) w p4 : 1 (wp 1 + wp 2 + wp 3)

INFOGR Lecture 5 Ray Tracing 32 Textures Fixing oversampling

INFOGR Lecture 5 Ray Tracing 33 Textures Fixing undersampling Undersampling: skipping pixels while reading from a texture. Symptoms: Moiré, flickering, noise. Remedy: MIP-mapping. The texture is reduced to 25% by averaging 2x2 pixels. This is repeated until a 1x1 image remains. When undersampling occurs, we switch to the next MIP level.

INFOGR Lecture 3 Geometry Textures

INFOGR Lecture 3 Geometry Textures

INFOGR Lecture 5 Ray Tracing 36 Textures Trilinear interpolation: blending between MIP levels.

Today s Agenda: Ray Tracing Recap Shading Textures

Need help? Tuesday May 15, 13:15 HULPMIDDAG GRAPHICS BBG 2.01

INFOGR Computer Graphics Jacco Bikker & Debabrata Panja - April-July 2018 END OF lecture 5: Ray Tracing Next lecture: Ray Tracing (2)