llumination Courtesy of Adam Finkelstein, Princeton University
Ray Casting mage RayCast(Camera camera, Scene scene, int width, int height) { mage image = new mage(width, height); for (int i = 0; i < width; i) { for (int j = 0; j < height; j) { Ray ray = ConstructRayThroughPixel(camera, i, j); ntersection hit = Findntersection(ray, scene); image[i][j] = GetColor(scene, ray, hit); } } return image; } Wireframe
Ray Casting mage RayCast(Camera camera, Scene scene, int width, int height) { mage image = new mage(width, height); for (int i = 0; i < width; i) { for (int j = 0; j < height; j) { Ray ray = ConstructRayThroughPixel(camera, i, j); ntersection hit = Findntersection(ray, scene); image[i][j] = GetColor(scene, ray, hit); } } return image; } Without llumination
Ray Casting mage RayCast(Camera camera, Scene scene, int width, int height) { mage image = new mage(width, height); for (int i = 0; i < width; i) { for (int j = 0; j < height; j) { Ray ray = ConstructRayThroughPixel(camera, i, j); ntersection hit = Findntersection(ray, scene); image[i][j] = GetColor(scene, ray, hit); } } return image; } With llumination
llumination How do we compute radiance for a sample ray? image[i][j] = GetColor(scene, ray, hit); Angel Figure 6.2
Goal Must derive computer models for... o Emission at light sources o Scattering at surfaces o Reception at the camera Desirable features o Concise o Efficient to compute o Accurate
Overview Direct llumination o Emission at light sources o Scattering at surfaces Global illumination o Shadows o Refractions o nter-object reflections Direct llumination
Modeling ight Sources (x,y,z,θ,φ,λ)... o describes the intensity of energy, o leaving a light source, o arriving at location(x,y,z),... o from direction (θ,φ),... o with wavelength λ (x,y,z) ight
Empirical Models deally measure irradiant energy for all situations o Too much storage o Difficult in practice λ
OpenG ight Source Models Simple mathematical models: o Point light o Directional light o Spot light
Point ight Source Models omni-directional point source o intensity ( 0 ), o position (px, py, pz), o factors (k c, k l, k q ) for attenuation with distance (d) d ight (px, py, pz) 0 = k c k ld k q d 2
Directional ight Source Models point light source at infinity o intensity ( 0 ), o direction (dx,dy,dz) (dx, dy, dz) No attenuation with distance = 0
Spot ight Source Models point light source with direction o intensity ( 0 ), o position (px, py, pz), o direction (dx, dy, dz) o attenuation d (px, py, pz) ight D γ = ( D 0 k c k ld ) k d q 2
Overview Direct llumination o Emission at light sources o Scattering at surfaces Global illumination o Shadows o Refractions o nter-object reflections Direct llumination
Modeling Surface Reflectance R s (θ,φ,γ,ψ,λ)... o describes the amount of incident energy, o arriving from direction (θ,φ),... o leaving in direction (γ,ψ), o with wavelength λ λ (θ,φ) (ψ,λ) Surface
Empirical Models deally measure radiant energy for all combinations of incident angles o Too much storage o Difficult in practice λ (θ,φ) (ψ,λ) Surface
OpenG Reflectance Model Simple analytic model: o diffuse reflection o specular reflection o emission o ambient Based on model proposed by Phong Surface
OpenG Reflectance Model Simple analytic model: o diffuse reflection o specular reflection o emission o ambient Based on Phong model proposed illumination by model Phong Surface
Diffuse Reflection Assume surface reflects equally in all directions o Examples: chalk, clay Surface
Diffuse Reflection How much light is reflected? o Depends on angle of incident light θ Surface
Diffuse Reflection How much light is reflected? o Depends on angle of incident light d = dacos Θ θ d da Surface
Diffuse Reflection ambertian model o cosine law (dot product) N θ Surface = ( N ) D D
OpenG Reflectance Model Simple analytic model: o diffuse reflection o specular reflection o emission o ambient Surface
Specular Reflection Reflection is strongest near mirror angle o Examples: mirrors, metals R θ N θ
Specular Reflection How much light is seen? Depends on: o angle of incident light o angle to viewer Viewer V R α θ N θ
Specular Reflection Phong Model o cos(α) n This is a physically-motivated hack! Viewer V R α θ N θ = ( V R) S S n
OpenG Reflectance Model Simple analytic model: o diffuse reflection o specular reflection o emission o ambient Surface
Emission Represents light eminating directly from polygon Emission 0
OpenG Reflectance Model Simple analytic model: o diffuse reflection o specular reflection o emission o ambient Surface
Ambient Term Represents reflection of all indirect illumination This is a total hack (avoids complexity of global illumination)!
OpenG Reflectance Model Simple analytic model: o diffuse reflection o specular reflection o emission o ambient Surface
OpenG Reflectance Model Simple analytic model: o diffuse reflection o specular reflection o emission o ambient Surface
OpenG Reflectance Model Sum diffuse, specular, emission, and ambient eonard McMillan, MT
Surface llumination Calculation Single light source: Viewer V R α θ N θ = E A A D ( N ) ( V S R) n
Surface llumination Calculation Multiple light sources: ) ) ( ) ( ( = i i n i S i i D A A E R V N N 2 V Viewer 1
Overview Direct llumination o Emission at light sources o Scattering at surfaces Global illumination o Shadows o Transmissions o nter-object reflections Global llumination
Global llumination Greg arson
Shadows Shadow term tells if light sources are blocked o Cast ray towards each light source i o S i = 0 if ray is blocked, S i = 1 otherwise = n S D A A E S R V N ) ) ( ) ( ( Shadow Term
Ray Casting Trace primary rays from camera o Direct illumination from unblocked lights only = E A A ( D ( N ) S ( V n R) ) S
T T R S n S D A A E S R V N = ) ) ( ) ( ( Recursive Ray Tracing Also trace secondary rays from hit surfaces o Global illumination from mirror reflection and transparency
Mirror reflections Trace secondary ray in mirror direction o Evaluate radiance along secondary ray and include it into illumination model Radiance for mirror reflection ray n = E A A ( D ( N ) S ( V R) ) S S R T T
Transparency Trace secondary ray in direction of refraction o Evaluate radiance along secondary ray and include it into illumination model T T R S n S D A A E S R V N = ) ) ( ) ( ( Radiance for refraction ray T
T T R S n S D A A E S R V N = ) ) ( ) ( ( Transparency Transparency coefficient is fraction transmitted o T = 1 for translucent object, T = 0 for opaque o 0 < T < 1 for object that is semi-translucent Transparency Coefficient T
Refractive Transparency For thin surfaces, can ignore change in direction o Assume light travels straight through surface N η i η r T Θr Θ i T Θ i T
Refractive Tranparency For solid objects, apply Snell s law: η sin r Θ r = η sin i Θ i N η i η r Θ i T Θr T ηi = ( cos Θi cos Θr ) N η r ηi η r
Recursive Ray Tracing Ray tree represents illumination computation Ray traced through scene Ray tree T T R S n S D A A E S R V N = ) ) ( ) ( (
Recursive Ray Tracing Ray tree represents illumination computation Ray traced through scene Ray tree T T R S n S D A A E S R V N = ) ) ( ) ( (
Recursive Ray Tracing GetColor calls RayTrace recursively mage RayTrace(Camera camera, Scene scene, int width, int height) { mage image = new mage(width, height); for (int i = 0; i < width; i) { for (int j = 0; j < height; j) { Ray ray = ConstructRayThroughPixel(camera, i, j); ntersection hit = Findntersection(ray, scene); image[i][j] = GetColor(scene, ray, hit); } } return image; }
Summary Ray casting (direct llumination) o Usually use simple analytic approximations for light source emission and surface reflectance Recursive ray tracing (global illumination) o ncorporate shadows, mirror reflections, and pure refractions All of this is an approximation so that it is practical to compute More on global illumination later!
llumination Terminology Radiant power [flux] (Φ) o Rate at which light energy is transmitted (in Watts). Radiant ntensity () o Power radiated onto a unit solid angle in direction (in Watts/sr)» e.g.: energy distribution of a light source (inverse square law) Radiance () o Radiant intensity per unit projected surface area (in Watts/m 2 sr)» e.g.: light carried by a single ray (no inverse square law) rradiance (E) o ncident flux density on a locally planar area (in Watts/m 2 )» e.g.: light hitting a surface along a Radiosity (B) o Exitant flux density from a locally planar area (in Watts/ m 2 )