#12: Texture MappingOutline for todayLighting ReviewAdvanced Lighting & RenderingAdvanced LightingShadingFlat shadingGouraud ShadingPhong ShadingGouraud vs. Phong shadingNote: Perspective DistortionCartoon ShadingIllustrationProcedural ShadingProgrammable GPUsSlide 16TextureTexture dataTexture examplesSlide 20Texture MapTexture MappingTexture Coordinate AssignmentParametric MappingSlide 25Orthographic MappingPerspective MappingSpherical MappingCylindrical MappingSkin MappingsSolid TexturesDecalsTexture PackingSlide 34Texture InterpolationPerspective CorrectionTilingSlide 38ClampingMirroringMagnificationSlide 42Magnification: point samplingMagnification: Bilinear interpolationMinificationSlide 46Minification: point samplingSlide 48MipmappingMipmapsSlide 51Nearest mipmap, point-sampledNearest mipmap, bilinear interpolationTrilinear mipmappingSlide 55Mipmapping LimitationAnisotropic MipmappingEliptical Weighted AveragingSlide 59Procedural texturesProcedural Texturesnoise functionsPerlin NoiseWorley Cellular NoiseProcedural TextureSlide 66Fancy Texture EffectsEnvironment MappingSlide 69Slide 70Slide 71Bump MappingBump mappingDisplacement MappingSlide 75Other Texture EffectsDone#12: Texture MappingCSE167: Computer GraphicsInstructor: Ronen BarzelUCSD, Winter 20062Outline for todayLighting & Shading wrapupTexture MappingProcedural TexturesFancy Texture Effects3Lighting ReviewLocal Illumination Lighting ModelsAmbient •Normals don’t matterDiffuse (Lambert)•Angle between surface normal and lightPhong, Blinn•Surface normal, light, and viewpointWhat they capture:Direct illumination from light sourcesDiffuse and Specular reflections(Very) Approximate effects of global lightingCompute lighting on any point on a surfaceVertices in particular4Advanced Lighting & RenderingShadowsReflectionTranslucency, refractionCaustics (light focusing)Global Illumination (light “spilling” from one surface to another)Area light sources/emittersAtmospheric effects (fog, clouds)Motion blurDepth of fieldExposure & dynamic range…5Advanced LightingQuickTime™ 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.6ShadingChoosing the color for each pixelFor photorealism, typically shading==lightingBut can take shortcuts, or do other thingsVarious techniques:FlatGouraudPhongCartoonIllustrationProcedural7Flat shadingCompute shading at a representative point and apply to whole polygonOpenGL uses one of the verticesAdvantages: Fast - one shading computation per polygon, fill entire polygon with same colorDisadvantages:InaccurateFaceted8Gouraud ShadingLight each vertex with its own location and normalResult is a color at each vertexInterpolate the colors across each triangleDefault mode for most hardware Advantages:Fast: incremental calculations when rasterizingMuch smoother - use one normal per shared vertex to get continuity between facesDisadvantages:Don’t get smooth specular highlightsC1-discontinuities in colorcause Mach bands: perceptualillusions of edges9Phong ShadingWant to recompute lighting at every pixelNeed normal vector at each pixelInterpolate vertex normalsInterpolate the normals while scan-convertingTypically, bilinearly interpolate x,y,z; then renormalizeAlso interpolate or transform to get position in world/camera spaceKnown as Phong Shading or Phong InterpolationNot to be confused with Phong Lighting Model(though both are often used at the same time)Advantages:More accurateBetter imagesDisadvantages:SlowStill not completely accurateModern GPUs can perform Phong shading via pixel shaders10Gouraud vs. Phong shadingGouraud misses specular hilightssolution:tessellate more finely: use smaller trianglesthat would help with the polygonal artifacts on the silhouettes tooGouraud Phong11Linear interpolation in screen space doesn’t align with linear interpolation in world spaceSolutions:Do hyperbolic interpolation (see Buss)Break up into smaller triangles Z – into the sceneImageplaneNote: Perspective Distortion12Cartoon ShadingGeneral approach:Compute simple lighting•diffuse (with shadows)Remap continuous intensityto two (or a few) levelsSome trickery to draw dark edgesQuickTime™ and aTIFF (Uncompressed) decompressorare needed to see this picture.13IllustrationUse lighting & shadow to define “tone”Not scan-conversion -- separate algorithms for drawing strokes(Winkenbach & Salesin, University of Washington)14Procedural ShadingSoftware or hardware renderer calls an arbitrary routine at every pixel (or sub-pixel)Routine is known as a shaderCan typically implement Phong or any other lighting modelUsed for patterns or other special effectsUsed for cartoon shadingShader typically written in a special-purpose shading languageRenderMan Shading Language (Pixar)Cg (Nvidia)HLSL (DirectX)C/C++ plugins, for software renderersShader: can get surface normal, position, material properties, light locations, …computes a color value (also a transparency value)can sometimes change the surface position! displacement shader15Programmable GPUsTwo kinds of shaders:vertex shaders: run once for each vertexpixel shaders: run for each pixelLimits onsize of programamount of memory availabletypes of memory and texture access (will talk about texture later)etc.Technology still improving, capabilities keep expanding16Outline for todayLighting & Shading wrapupTexture MappingProcedural TexturesFancy Texture Effects17TextureWe know how to model and render uniform smooth surfacesWant more interesting texture:variations in colorsmall-scale patterns, bumps, roughnessIn principle we could model everythingreally tiny trianglesper-vertex colorper-vertex material propertiesModeling everything unwieldy, impracticalToo much of the wrong kind of dataDon’t need that much fine-scale geometric data (triangle vertices)Just want surface data, separate from geometric data18Texture dataTexture data can come fromFiles: •Typically, 2D color
View Full Document