1 of 37

Texturing

Instructor: Christopher Rasmussen (cer@cis.udel.edu)

March 8, 2023 Lecture 14

2 of 37

Outline

  • Bump maps
  • Texturing pipeline
  • More applications
    • Light maps
    • Environment maps

3 of 37

Bump Mapping

  • So far we’ve been thinking of textures modulating color and transparency only
    • Billboards, decals, lightmaps, etc.
  • But any other per-pixel properties are fair game...
  • Pixel normals usually smoothly varying
    • Computed at vertices for Gouraud shading; color interpolated
    • Interpolated from vertices for Phong shading
  • Textures allow setting per-pixel normal with a bump map

4 of 37

Bump map: Example

from wikipedia.org

Sphere WITH bumps

Sphere

5 of 37

Bump mapping: Why?

  • Can get a lot more surface detail without expense of more object vertices to light, transform

courtesy of Nvidia

6 of 37

Bump + color map: Example

7 of 37

Bump mapping: Example

from MIT CG lecture notes

+

=

8 of 37

Bump mapping: Example

courtesy of A. Awadallah

Height map

Bump texture applied to teapot

9 of 37

Bump mapping: How?

  • Idea: Perturb pixel normals n(u, v) derived from object geometry to get additional detail for shading
  • Compute lighting per pixel (like Phong)

from Hill

10 of 37

Bump mapping: Representations

  • 3-D vector m(u, v) added directly to normal n
  • Or: 2-D vector of coefficients (bu, bv) that scale u, v vectors tangent to surface

from Akenine-Moller & Haines

11 of 37

Bump representation: Height map f(u, v)

  • Store just scalar “altitude” at each pixel
  • Get bu, bv from partial derivatives:

    • Approximate with finite differencing

from Akenine-Moller

& Haines

12 of 37

Example: Converting height maps to normal displacements (aka normal maps)

Z coordinate set to some constant scale factor; (X, Y) normalized to [0, 1] range.

Right image is mostly blue because “straight up” vector is (0.5, 0.5, 1)

courtesy of Nvidia

13 of 37

Bump mapping: Issues

  • Bumps don’t cast shadows
  • Geometry doesn’t change, so silhouette of object is unaffected
  • Textures can be used to modify underlying geometry with displacement maps
    • Generally in direction of surface normal

courtesy of Nvidia

from https://en.wikipedia.org/wiki/Normal_mapping

14 of 37

Displacement Mapping

courtesy of spot3d.com

Bump mapping

Displacement mapping

15 of 37

Displacement Mapping the Sphere

courtesy of geeks3d.com

16 of 37

Displacement Mapping – Height Maps

courtesy of artofillusion.org -- Julian MacDonald

17 of 37

Texture mapping: Steps

  • Creation: Where does the texture image come from?
  • Geometry: Transformation from 3-D shape locations to 2-D texture image coordinates
  • Rasterization: What to draw at each pixel (since texture coords. are floats)
    • E.g., bilinear interpolation vs. nearest-neighbor

18 of 37

Texturing: Creation

  • Reproductions
    • Photographs
    • Handpainted
  • Directly-computed functions
    • E.g., lightmaps, visibility maps
  • Procedurally-built
    • Synthesize with randomness, pattern-generating rules, etc.
    • More about this after midterm

courtesy of H. Elias

courtesy of Nvidia

Procedural bump mapping

19 of 37

Texture mapping applications: Lightmaps

courtesy of K. Miller

+

=

Idea: Precompute expensive static lighting effects (such as ambient occlusion or diffuse reflectance) and “bake” them into color texture. Then scene looks more realistic as camera moves without expense of recomputing effects

20 of 37

Texture mapping application: Lightmaps

Tenebrae Quake screenshot

21 of 37

Texture mapping application: Lightmaps

Textures only

courtesy of https://jbush001.github.io/2015/06/11/quake-lightmaps.html

22 of 37

Texture mapping application: Lightmaps

Lightmap with bilinear filtering

23 of 37

Texture mapping application: Lightmaps

Textures and lightmaps combined

24 of 37

Lightmap example: Diffuse lighting only

25 of 37

Lightmap example: Light configuration

26 of 37

Lightmap example: Diffuse + lightmap

27 of 37

Texturing Pipeline (Geometry + Rasterization)

  1. Compute object space location (x, y, z) from screen space location (i, j)

list adapted from Akenine-Moller & Haines

courtesy of R. Wolfe

28 of 37

Texturing Pipeline (Geometry + Rasterization)

  • Compute object space location (x, y, z) from screen space location (i, j)
  • Use projector function to obtain object surface coordinates (u, v) (3-D -> 2-D projection)

list adapted from Akenine-Moller & Haines

courtesy of R. Wolfe

29 of 37

Texturing Pipeline (Geometry + Rasterization)

  • Compute object space location (x, y, z) from screen space location (i, j)
  • Use projector function to obtain object surface coordinates (u, v) (3-D -> 2-D projection)
  • Use corresponder function to find texel coordinates (s, t) (2-D -> 2-D transformation)
    • Scale, shift, wrap like viewport transform in geometry pipeline

list adapted from Akenine-Moller & Haines

courtesy of R. Wolfe

30 of 37

Texturing Pipeline (Geometry + Rasterization)

  • Compute object space location (x, y, z) from screen space location (i, j)
  • Use projector function to obtain object surface coordinates (u, v) (3-D -> 2-D projection)
  • Use corresponder function to find texel coordinates (s, t) (2-D -> 2-D transformation)
    • Scale, shift, wrap like viewport transform in geometry pipeline
  • Filter texel at (s, t)

list adapted from Akenine-Moller & Haines

courtesy of R. Wolfe

31 of 37

Texturing Pipeline (Geometry + Rasterization)

  • Compute object space location (x, y, z) from screen space location (i, j)
  • Use projector function to obtain object surface coordinates (u, v) (3-D -> 2-D projection)
  • Use corresponder function to find texel coordinates (s, t) (2-D -> 2-D transformation)
    • Scale, shift, wrap like viewport transform in geometry pipeline
  • Filter texel at (s, t)
  • Modify pixel (i, j)

list adapted from Akenine-Moller & Haines

courtesy of R. Wolfe

Rasterization

32 of 37

Texture coordinates at vertices

  • Polygons can be treated as parametric patches by assigning texture coordinates to vertices
    • The standard OpenGL way

courtesy of

R. Wolfe

33 of 37

Projector Functions

  • Want way to get from 3-D point to 2-D surface coordinates as an intermediate step
  • Idea: Project complex object onto simple object’s surface with parallel or perspective projection (focal point inside object)
    • Mesh: piecewise planar (default option

with texture coords)

    • Plane
    • Cylinder
    • Sphere
    • Cube

Planar projector

courtesy of R. Wolfe

34 of 37

Planar projector

Orthographic projection onto XY plane: u = x, v = y

...onto YZ plane

...onto XZ plane

courtesy of

R. Wolfe

35 of 37

Cylindrical projector

  • Convert rectangular coordinates (x, y, z) to cylindrical (r, h, θ), use only (h, θ) to index texture image

courtesy of

R. Wolfe

36 of 37

Spherical projector

  • Convert rectangular coordinates (x, y, z) to spherical (r, θ, Φ), use only (θ, Φ)

courtesy of R. Wolfe

37 of 37

Making environment textures: Cube

  • Cube map straightforward to make: Render/ photograph six rotated views of environment
    • 4 side views at compass points
    • 1 straight-up view, 1 straight-down view