1IlluminationTom FunkhouserPrinceton UniversityCOS 426, Spring 2006Ray CastingImage RayCast(Camera camera, Scene scene, int width, int height){Image image = new Image(width, height);for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { Ray ray = ConstructRayThroughPixel(camera, i, j);Intersection hit = FindIntersection(ray, scene);image[i][j] = GetColor(scene, ray, hit);}}return image;}Image RayCast(Camera camera, Scene scene, int width, int height){Image image = new Image(width, height);for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { Ray ray = ConstructRayThroughPixel(camera, i, j);Intersection hit = FindIntersection(ray, scene);image[i][j] = GetColor(scene, ray, hit);}}return image;}WireframeRay CastingImage RayCast(Camera camera, Scene scene, int width, int height){Image image = new Image(width, height);for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { Ray ray = ConstructRayThroughPixel(camera, i, j);Intersection hit = FindIntersection(ray, scene);image[i][j] = GetColor(scene, ray, hit);}}return image;}Image RayCast(Camera camera, Scene scene, int width, int height){Image image = new Image(width, height);for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { Ray ray = ConstructRayThroughPixel(camera, i, j);Intersection hit = FindIntersection(ray, scene);image[i][j] = GetColor(scene, ray, hit);}}return image;}Without IlluminationRay CastingImage RayCast(Camera camera, Scene scene, int width, int height){Image image = new Image(width, height);for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { Ray ray = ConstructRayThroughPixel(camera, i, j);Intersection hit = FindIntersection(ray, scene);image[i][j] = GetColor(scene, ray, hit);}}return image;}Image RayCast(Camera camera, Scene scene, int width, int height){Image image = new Image(width, height);for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { Ray ray = ConstructRayThroughPixel(camera, i, j);Intersection hit = FindIntersection(ray, scene);image[i][j] = GetColor(scene, ray, hit);}}return image;}With IlluminationIllumination• How do we compute radiance for a sample ray?Angel Figure 6.2image[i][j] = GetColor(scene, ray, hit);Goal• Must derive computer models for ... Emission at light sources Scattering at surfaces Reception at the camera• Desirable features … Concise Efficient to compute “Accurate”2Overview• Direct Illumination Emission at light sources Scattering at surfaces• Global illumination Shadows Refractions Inter-object reflectionsDirect IlluminationEmission at Light Sources• IL(x,y,z,θ,φ,λ) ... describes the intensity of energy, leaving a light source, … arriving at location(x,y,z), ... from direction (θ,φ), ... with wavelength λ(x,y,z)LightEmpirical Models• Ideally measure irradiant energy for “all” situations Too much storage Difficult in practiceλOpenGL Light Source Models• Simple mathematical models: Point light Directional light Spot lightPoint Light Source• Models omni-directional point source intensity (I0), position (px, py, pz), factors (kc, kl, kq) for attenuation with distance (d)2qlc0kkkIddIL++=dLight(px, py, pz) Directional Light Source• Models point light source at infinity intensity (I0), direction (dx,dy,dz) 0IIL=(dx, dy, dz)No attenuationwith distance3Spot Light Source• Models point light source with direction intensity (I0), position (px, py, pz), direction (dx, dy, dz) attenuation2qlc0kkk)(IddLDIL++•=dLight(px, py, pz) DLγOverview• Direct Illumination Emission at light sources Scattering at surfaces• Global illumination Shadows Refractions Inter-object reflectionsDirect IlluminationScattering at Surfaces• Rs(θ,φ,γ,ψ,λ) ... describes the amount of incident energy, arriving from direction (θ,φ), ... leaving in direction (γ,ψ), … with wavelength λSurface(θ,φ)(ψ,λ)λEmpirical Models• Ideally measure radiant energy for “all” combinations of incident angles Too much storage Difficult in practiceSurface(θ,φ)(ψ,λ)λOpenGL Reflectance Model• Simple analytic model: diffuse reflection + specular reflection + emission + “ambient”SurfaceBased on modelproposed by PhongBased on modelproposed by PhongOpenGL Reflectance Model• Simple analytic model: diffuse reflection + specular reflection + emission + “ambient”SurfaceBased on Phong illumination modelBased on Phong illumination modelBased on modelproposed by PhongBased on modelproposed by Phong4Diffuse Reflection• Assume surface reflects equally in all directions Examples: chalk, claySurfaceDiffuse Reflection• How much light is reflected? Depends on angle of incident lightSurfaceθDiffuse Reflection• How much light is reflected? Depends on angle of incident lightSurfacedLΘ=cosdAdLdAθDiffuse Reflection• Lambertian model cosine law (dot product)LDDILNKI )( •=SurfaceNLθOpenGL Reflectance Model• Simple analytic model: diffuse reflection + specular reflection + emission + “ambient”SurfaceSpecular Reflection• Reflection is strongest near mirror angle Examples: mirrors, metalsNLRθθ5Specular ReflectionHow much light is seen?Depends on: angle of incident light angle to viewerNLRVViewerαθθSpecular Reflection• Phong Model cos(α)nLnSSIRVKI )( •=NLRVViewerαθθThis is a physically-motivated hack!OpenGL Reflectance Model• Simple analytic model: diffuse reflection + specular reflection + emission + “ambient”SurfaceEmissionEmission ≠ 0Emission ≠ 0• Represents light eminating directly from polygonOpenGL Reflectance Model• Simple analytic model: diffuse reflection + specular reflection + emission + “ambient”SurfaceAmbient TermThis is a total hack (avoids complexity of global illumination)!• Represents reflection of all indirect illumination6OpenGL Reflectance Model• Simple analytic model: diffuse reflection + specular reflection + emission + “ambient”SurfaceOpenGL Reflectance Model• Simple analytic model: diffuse reflection + specular reflection + emission + “ambient”SurfaceOpenGL Reflectance Model• Sum diffuse, specular, emission, and ambientLeonard McMillan, MITDirect Illumination Calculation• Single light source:LnSLDALAEIRVKILNKIKII )()( •+•++=NLRVViewerαθθDirect
View Full Document