#13: Shadows & Ray TracingOutline for todayWhere are we nowFancy Texture EffectsBump MappingBump mappingDisplacement MappingSlide 8Environment MappingSlide 10Slide 11Slide 12Reflection MappingSlide 14Slide 15Slide 16Other Texture EffectsMultipass renderingSlide 19ShadowsSlide 21Shadow MapSlide 23Slide 24Shadow MappingSlide 26Slide 27Slide 28Slide 29Slide 30Shadow Mapping NotesSlide 32Ray TracingClassic Ray TracingSlide 35What’s a Ray?First step: Ray CastingIntersection TestingRay IntersectionsRay IntersectionLightingShadow RaysSlide 43Reflection RaysReflectionsSlide 46RefractionComputing Refraction DirectionReflection and RefractionCombining Reflection and RefractionTotal Internal ReflectionRay treeSlide 53Ray-Object IntersectionRay-Sphere IntersectionSlide 56Slide 57Ray intersection notesRay-Plane IntersectionRay-Triangle IntersectionBarycentric CoordinatesSlide 62Ray-Patch IntersectionDone#13: Shadows & Ray TracingCSE167: Computer GraphicsInstructor: Ronen BarzelUCSD, Winter 20062Outline for todayFancy Texture EffectsShadow MappingRay Tracing3Where are we nowTexture mappingAssign texture coordinates to vertices•based on surface parameters•based on projection in object or world spaceInterpolate texture coordinates to pixels•look up color in texture file•to avoid magnification problems, use bilinear or bicubic filtering•to avoid minification problems, use mipmaps•precomputed hierarchy of scaled-down versions of the texture image•based on amount of minification, choose two nearest mipmaps•look up color in each, interpolate between them (trilinear interpolation)Procedural texturescompute patterns in procedural shader routineschoose details based on screen-space size of surface areaused especially for wood, marble, cloth, …4Fancy Texture EffectsWe can look up data at each pixel… What can we do with it?Given procedural shaders, can do most anything we want!Here are some common techniquesOften supported by renderer without procedural shadingSome supported directly by hardware5Bump MappingAn easy way to make a smooth surface bumpyUse a texture to represent the variation in surface heightWith Phong interpolation we have a normal for each pixelUse the texture value to perturb the normalThen use the perturbed normal for the per-pixel lightingTexture can be stored or proceduralUsed for rough surfacesUsed for “embossing”Modern hardware supports bump mappingLimitation: bumps are fake silhouette edges betray smoothness6Bump mappingQuickTime™ and aTIFF (Uncompressed) decompressorare needed to see this picture.7Displacement MappingLike bump mappingbut instead of faking by perturbing normals……actually move the surface pointGives proper silhouettes,Gives self-occlusionGives self-shadowing (once we have shadows…)Expensive and hard to do wellSupported by some software renderersSupported by some recent hardware8Displacement MappingQuickTime™ and aTIFF (Uncompressed) decompressorare needed to see this picture.QuickTime™ and aTIFF (Uncompressed) decompressorare needed to see this picture.9Environment MappingA simple but technique to fake mirror-like reflections of an environmentPrecompute, photograph, or paint an environment map:A view of the distant environment (ground, sky, horizon, etc.) from the center of the sceneCan be stored in a single spherically-projected textureCan be stored in 6 faces of a cubeImagine that the scene is enclosed in a huge sphere or cube, textured with that mapFor each vertex or point to be shaded:compute the vector e from the point to the eyecompute the reflection vector Rfind out where R intersects the environment cube/sphere, and use that texture coordinate•(because the environment is huge, we don’t need to take into acount the position of the point)add the texture color to the point’s color, with some constant ke10Environment Mappingen r For a spherical environment with polar mapping:R =2re⋅rn( )rn−res =atan2 Rz,Rx( )+π2πt =asin Ry( )+π2π11Environment MappingQuickTime™ and aTIFF (Uncompressed) decompressorare needed to see this picture.QuickTime™ and aTIFF (Uncompressed) decompressorare needed to see this picture.QuickTime™ and aTIFF (Uncompressed) decompressorare needed to see this picture.12Environment MappingQuickTime™ and aTIFF (Uncompressed) decompressorare needed to see this picture.QuickTime™ and aTIFF (Uncompressed) decompressorare needed to see this picture.QuickTime™ and aTIFF (Uncompressed) decompressorare needed to see this picture.QuickTime™ and aTIFF (Uncompressed) decompressorare needed to see this picture.QuickTime™ and aTIFF (Uncompressed) decompressorare needed to see this picture.QuickTime™ and aTIFF (Uncompressed) decompressorare needed to see this picture.(www.sparse.org)13Reflection MappingEnvironment mapping often called Reflection MappingGenerally, environment maps:only reflect distant environment, not nearby objectsare static: don’t incorporate things that animateBut you can get animated local reflections…If you’re willing to take two steps14Reflection MappingFor Woody reflected in Buzz’s helmet…QuickTime™ and aTIFF (Uncompressed) decompressorare needed to see this picture.15Reflection MappingFirst, render just Woody, using camera at Buzz’s headQuickTime™ and aTIFF (Uncompressed) decompressorare needed to see this picture.QuickTime™ and aTIFF (Uncompressed) decompressorare needed to see this picture.16Reflection MappingQuickTime™ and aTIFF (Uncompressed) decompressorare needed to see this picture.QuickTime™ and aTIFF (Uncompressed) decompressorare needed to see this picture.In main render, Buzz’s helmet procedural shader computes reflectionIf reflection hitsWoody texture mapuse its color, otherwiseuse the regular environment mapTwo renders to generate each frame!In practice, many renders to render each frame17Other Texture EffectsTextures can be used to map most any property onto a surfaceNot just colorBump or displacementDiffuse coefficient? Specular Coefficient?“combing” directions for anisotropic reflectivityParameters to procedural patternsMany texture maps can be used at onceDifferent layers of effecte.g. Base color, then smudges, scratches, dents, rust, etc.•each might affect color, bumps, displacment, lighting, reflectivity, …Hardware
View Full Document