Blinn/Newell Method(1976)
Total Page:16
File Type:pdf, Size:1020Kb
Texturing Methods Alpha Mapping Light Mapping Gloss Mapping Environment Mapping ◦ Blinn/Newell ◦ Cube, Sphere, Paraboloid Mapping Bump Mapping ◦ Emboss Method ◦ EM bump mapping ITCS 3050:Game Engine Design 1 Texturing Methods Alpha Mapping Decaling: Eg., flower in a teapot, parts outside of the flower have α = 0; clamp to border mode with a transparent border. Cutouts: Similar idea, but make all background pixels to be trans- parent. ”Tree” example: Combine the tree texture with a rotated copy to form a cheap 3D tree. ITCS 3050:Game Engine Design 2 Texturing Methods Light Mapping For static environments, diffuse lighting is view independent, specu- lar lighting is not. Can capture diffuse illumination in a texture, as a light map Useful to perform light mapping in a separate stage - can use smaller textures, use texture animation (moving spotlights) Volume light textures provide more comprehensive light maps. ITCS 3050:Game Engine Design 3 Texturing Methods Gloss Mapping Gloss mapping helps selective use of glossiness (shininess) on 3D objects Example: Brick wall with shiny bricks, dull mortar - use a gloss map with high values for brick positions and low values elsewhere. o = tdiff ⊗ idiff + tglossispec Thus, we simply enhance the brightness of the highlights using the gloss map. ITCS 3050:Game Engine Design 4 Texturing Methods Environment Mapping (EM) Introduced by Blinn and Newell. Also called reflection mapping, powerful means to obtain reflections in curved surfaces. Uses the direction of the reflection vector as an index into an image containing the environment. Assumptions: lights are far, no self reflection. ITCS 3050:Game Engine Design 5 Texturing Methods Environment Mapping Procedure Generate 2D image of environment Pixels containing reflective objects - compute reflection vector from normal and view vector Compute index into environment map, using the reflection vector Retrieve texel from the EM to color pixel. ITCS 3050:Game Engine Design 6 Texturing Methods Blinn/Newell Method(1976) Compute reflection vector and transform to spherical coords (ρ, φ) φ ∈ (0, 2π) is the longitude, ρ ∈ (0, π) is the latitude r = (rx, ry, rz) = e − 2(n · e)n φ = arccos(−rz), φ = atan2(ry, rx) ITCS 3050:Game Engine Design 7 Texturing Methods Blinn/Newell Method:Issues Border at φ = 0, and map converges at poles, can cause distortions. Index computed on per pixel basis, makes it challenging for real-time applications. Problems with vertices in triangles that cross poles. Very rarely used technique in current applications. ITCS 3050:Game Engine Design 8 Texturing Methods Cubic Environment Maps (Green 1987) The most popular EM technique implemented on modern graphics hardware. Why? High speed and flexibility. Method: ◦ Place camera in the center of the environment ◦ Project environment onto the sides of a cube centered around the camera ITCS 3050:Game Engine Design 9 Texturing Methods Cubic Environment Maps:Advantages Environment maps are generated easily in realtime. Samples are more uniform (compared to spherical projection) Direction of reflection vector determines cube face to use Normalize by largest absolute value of refl. vector (range from -1 to 1), remap to (0, 1). Must deal with edges whose vertices map to different cube faces. Modern GPUs compute refl. vector interpolation and face computa- tion, yielding per-pixel EM lookup. ITCS 3050:Game Engine Design 10 Texturing Methods Other Methods Sphere, Paraboloid Mappings Refer text, for details ITCS 3050:Game Engine Design 11 Texturing Methods Lighting Using Environment Mapping Environment maps can be used to simulate specular reflections and refractions. Incorporate lighting (highlights that can be missed by Gouraud shad- ing) into the texture. Resulting in highlighting on a per pixel basis, at a fixed cost. Lights of any size or shape. ITCS 3050:Game Engine Design 12 Texturing Methods Recursive Reflections Using EM Repeated use of environment maps to simulate reflections Example: a red and blue sphere ◦ Generate EM for red sphere ◦ Generate EM for blue sphere, using red sphere’s EM ◦ Iterate (better, to amortize with one EM per frame) ITCS 3050:Game Engine Design 13 Texturing Methods Environment Mapping: Issues Does not work well with flat surfaces - reflection rays span only a small part of the environment Small part of the environment projected onto a large planar surface - excessive magnification. ITCS 3050:Game Engine Design 14 Texturing Methods Environment Mapping: Example Diffuse, Gloss, Reflection Mapping A 2 stage multitexturingexample, using the following lighting model o = tdiff ⊗ idiff + tglossrspec ITCS 3050:Game Engine Design 15 Texturing Methods Environment Mapping: Example ITCS 3050:Game Engine Design 16 Texturing Methods Bump Mapping Introduced by Blinn (1978) Inexpensive way of simulating wrinkles and bumps on geometry Too expensive to model these geometrically Instead let a texture modify the normal at each pixel, and then use this normal to compute lighting Not a physically realistic model. ITCS 3050:Game Engine Design 17 Texturing Methods Bump Mapping: Example ITCS 3050:Game Engine Design 18 Texturing Methods Bump Mapping Methods b u u b v v n n' bump texture b , b u v Height Field Texels Offset Map: Store 2 signed values, bu, bv, amounts to vary the nor- mal along u, v axes. 0 n = buu + bvv Heightfield Map: Use the local gradient (differences between neighboring values) along columns and rows of height field. ITCS 3050:Game Engine Design 19 Texturing Methods Bump Mapping: Issues Overall, per-pixel bump mapping is very convincing, Two problems, breaks down along silhouettes, no self shadowing. Per-pixel bump mapping is impractical for real-time applications, so most methods solve simpler versions of the lighting equation. In general, assumption of reasonable aspect ratio between the tex- ture and object, else can result in rendering artifacts (stretching, compression) ITCS 3050:Game Engine Design 20 Texturing Methods Emboss Bump Mapping Technique borrowed from image processing Embossing, gives a chiselled look to images Original height field image is copied, shifted and subtracted from the original ITCS 3050:Game Engine Design 21 Texturing Methods Emboss Bump Mapping Procedure Render surface with heightfield as diffuse monochrome texture Shift all (u,v) coords in the direction of the light Render again with diffuse texture, subtracting from first pass result. Render again with no heightfield, diffusely illuminated and Gouraud shaded and add to the result ITCS 3050:Game Engine Design 22 Texturing Methods Emboss Bump Mapping: Details Must transform light source direction into the tangent space of the vertex (u,v) Form an orthogonal coordinate system, involving t, b, n tx ty tz 0 bx by bz 0 nx ny nz 0 0 0 0 1 ITCS 3050:Game Engine Design 23 Texturing Methods Emboss Bump Mapping: Details t is tangential to surface (u or v) and orthogonal to n, b = n × t Matrix transforms the light direction l and the vertex is shifted along 0 0 (lx, ly) Limitations: Only diffuse surfaces, bumps disappear if light is di- rectly overhead, does not work well with mip-mapping ITCS 3050:Game Engine Design 24 Texturing Methods Dot Product (Dot3) Bump Mapping Primary method of bump mapping on modern graphics hardware. This method uses a normal map, storing the actual normals in the texture. 8 bit values [0,255], mapped to the range [-1,1] Light source direction is mapped to tangential space of vertex (simi- lar to embossing), coords of light vector interpolated across surface. Interpolate unnormalized vectors, then use a special cubic environ- ment map to retrieve normalized vectors. Combine the retrieved normals by a dot product with the bump tex- ture normals (similar to diffuse illumination calculation). ITCS 3050:Game Engine Design 25 Texturing Methods Dot Product (Dot3) Bump Mapping Diffuse Contribution: dot product between interpolated light vector bump texture normal. Specular Contribution: Use Blinn’s halfway angle vector and pixel shaders to compute highlights in real-time. Some type of bump map filtering is necessary. ITCS 3050:Game Engine Design 26 Texturing Methods Environment Map Bump Mapping Approach:Perturb the (u,v) coords of the environment map by (u,v) differentials retrieved from the bump map. Effectively, wobbles the reflection vector, distorting the look of the reflected surface. A 2 × 2 matrix allows transformation of bump map coords, prior to application to environment map. ITCS 3050:Game Engine Design 27 Texturing Methods Environment Bump Mapping Advantages: Only 2 texture accesses, regardless of number of lights Limitation: Only a single planar environment map is permitted Application: Used to render reflections of bodies of water, flat sur- faces ITCS 3050:Game Engine Design 28 Texturing Methods Bump Mapping: Other Methods 3D textures: Feasible on modern hardware as well Multitexturing: More than one set of texture coords per vertex, out- put from the first texture stage is input to the next Opens up for many possibilities Displacement Mapping Actually change geometry Non-photorealistic rendering, volume rendering, LIC ITCS 3050:Game Engine Design 29 Texturing Methods ITCS 3050:Game Engine Design 30 Texturing Methods.