Outline

1 Texture and Anti-aliasing and MIP maps COM3404 Reflection mapping 2 Bump mapping Richard Everson References School of Engineering, Computer Science and Mathematics University of Exeter Fundamentals of 3D . Watt. Chapters 4, 5 & 6. Computer Graphics: Principles and Practice. Foley et al (1995). [email protected] Chapters 15 & 16. http://www.secamlocal.ex.ac.uk/studyres/COM304 Teaching Texture Mapping Visually. Rosalee Wolfe (1997) http://www.siggraph.org/education/materials/HyperGraph/ mapping/r wolfe/r wolfe mapping 1.htm

Richard Everson Texture and bump mapping 1 / 18 Richard Everson Texture and bump mapping 2 / 18

Texture mapping Example: Texture mapping a sphere

Equation of a sphere v Map a two-dimensional texture (image) onto the surface of x = R sin(θ) cos(φ) a three-dimensional object. w yw = R sin(θ) cos(φ)

zw = R cos(θ) u

θ is polar angle from z axis z r φ is azimuthal angle from x axis Mapping Put θ = πv and φ = 2πu θ

v = θ/π = arccos(zw /R)/π y Texture is two-dimensional. Coordinates (u, v). u = arccos(xw /Rsin(πv))/(2π) φ Mapped surface is two-dimensional. Coordinates (xw , yw , zw ) Can compute (u, v) and therefore Screen is two-dimensional. Coordinates (x , y ). for any point given world s s x coordinates.

Richard Everson Texture and bump mapping 4 / 18 Richard Everson Texture and bump mapping 5 / 18 Texture mapping a sphere Defining the texture-object mapping: Pelting

Piponi & Borshukov, Seamless texture mapping of subdivision surfaces by model pelting and texture blending, SIGGRAPH, 2000 Texture and opacity maps

Richard Everson Texture and bump mapping 6 / 18 Richard Everson Texture and bump mapping 7 / 18

Defining the texture-object mapping: Atlas Forward and inverse mapping

Sander, Snyder, Gortler, Hoppe. Texture Mapping Progressive Meshes, SIGGRAPH, 2001

Mapping (u, v) 7→ (xs , ys ) is two-dimensional to two-dimensional Richard Everson Texture and bump mapping 8 / 18 Richard Everson Texture and bump mapping 9 / 18 Forward and inverse mapping Bi-linear interpolation

Model (approximate) the mapping (u, v) 7→ (xs , ys ) as a rational linear Mapping from texture to screen is non-linear projective transform A single pixel’s pre-image may be several texels au + bv + c du + ev + f x = y = A single may lie entirely within a screen pixel. gu + hv + i gu + hv + i Inverse mapping in homogeneous coordinates: Forward Simple to comprehend  0    0  u ei − fh ch − bi bf − ce xs 0 0 Inverse mapping v  =  fg − di ai − cg cd − af  ys  Suited to scan-line algorithms q dh − eg bg − ah ae − bd w

Efficient: only required textures are computed 0 0 0 0 If pre-image of pixel covers several texels then texture should be with (xs , ys ) = (xs /w, ys /w) and (u, v) = (u /q, v /q) super-sampled. Coefficients a to i found by solving equations for the mapping of four If pre-image of pixel lies within a single texel then low-pass filtering corners of pixel in screen coordinates to quadrilateral in texture required to prevent anti-aliasing. coordinates.

Richard Everson Texture and bump mapping 10 / 18 Richard Everson Texture and bump mapping 11 / 18

Anti-aliasing and MIP maps Anti-aliasing and MIP maps

Texture Screen Compression from texture space to screen space Several texels map to a single pixel Approximate pre-image of To avoid aliasing errors, pixels in texture space by a texture image should be square of size 2n sampled many times to calculate pixels, but Permits precalculation very expensive. for anti-aliasing Magnification from texture space to screen space Single pixel lies within texel Higher resolution texture map required Richard Everson Texture and bump mapping 12 / 18 Richard Everson Texture and bump mapping 13 / 18 MIP mapping for compression Reflection mapping

Precompute subsampled copies of the texture map for sizes 2n, 2n−1,... 1

Select a texel from the appropriately sampled map 1 Render the scene surface is close to camera, use high resolution map from viewpoint of surface is distant from camera, use low resolution the reflecting surface. map 2 Texture map scene Linear interpolation between the levels improves quality onto reflecting Cost is constant per pixel surface. 3 Render scene from usual viewpoint.

Models only a single reflection, rather than reflections from multiple surfaces.

Richard Everson Texture and bump mapping 14 / 18 Richard Everson Texture and bump mapping 15 / 18

Bump mapping Bump mapping

Simulate height variations by adjusting directions of surface normals

Perception of surface height depends on lighting Phong and Gouraud lighting models depend on surface to set intensity Adjust surface normal directions according to a bump map describing bumps to be simulated Silhouette of spheres is smooth!

Richard Everson Texture and bump mapping 17 / 18 Richard Everson Texture and bump mapping 18 / 18