Acg04 Texture

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 41

Advanced Computer Graphics

Texture Mapping
Texture Mapping
} Surfaces in real world are very complex
} Objects have properties that vary across surface
} Cannot model all the fine variations
} We need to find ways to add surface detail
} How?
Texture Mapping
} Of course, one can model the exact micro-geometry +
material property to control the look and feel of a
surface
} But, it may get extremely costly
} So, graphics use a more practical approach – texture
mapping

Asian Dragon - 7M triangles, 133 MB Lucy - 28M triangles, 508 MB


The Quest for Visual Realism
Texture Mapping
} Texture Mapping
} Want a function that assigns a color to each point
} The the surface is a 2D domain, so that is essentially an
image
} can represent using any image representation
} raster texture images are very popular
Textures
} Describe color variation in interior of 3D polygon
} When scan converting a polygon, vary pixel colors
according to values fetched from a texture
Surface Textures
} Add visual detail to surfaces of 3D objects
Texture and Texel
} Each pixel in a texture map is called a Texel
} Each Texel is associated with a (u,v) 2D texture
coordinate
} The range of u, v is [0.0,1.0] due to normalization
(u,v) tuple
} For any (u,v) in the range of (0-1, 0-1) multiplied by
texture image width and height, we can find the
corresponding value in the texture map
How do we get F(u,v)?
} We are given a discrete set of values:
} F[i,j] for i=0,…,N, j=0,…,M
} Nearest neighbor:
} F(u,v) = F[ round(N*u), round(M*v) ]
} Linear Interpolation:
} i = floor(N*u), j = floor(M*v)
} interpolate from F[i,j], F[i+1,j], F[i,j+1], F[i+1,j]
} Filtering in general !
Interpolation

Nearest neighbor Linear Interpolation


Specifying texture coordinates
} Texture coordinates needed at every vertex
} For each pixel, interpolated down/across scan lines

} Hard to specify by hand


} Difficult to wrap a 2D texture around a 3D object
Planar mapping
} Compute texture coordinates at each vertex by
projecting the map coordinates onto the model
Cylindrical Mapping
Spherical Mapping
Cube Mapping
Option: unfold the surface
Option: make an atlas
Texture Filtering
} Resampling using mip mapping
} Magnification: Interpolation
} Minification: Averaging
Texture Image
Texture => Image

We would like a constant cost per pixel


Texture Filtering
} Aliasing is a problem

Point Sampling Area Filtering


Mip Mapping
} MIP = Multim In Parvo = Many things in a small place
} Constructs an image pyramid. Each level is a
prefilteredversion of the level below resampled at half
the frequency.
} Whilerasterizing use the level with the sampling rate
closest to the desired sampling rate.
Mip Mapping
• Used with bilinear/trilinear interpolation

R
R
G B

G B

Trilinear interpolation
Mip Mapping - Example
• used to save some of the filtering work needed during texture minification

Courtesy of John hart


Texture Filtering Methods
} Nearest Neighbor interpolation

} Bilinear Interpolation

} Trilinear Interpolation

} Anisotropic filtering <anisotropic filtering)


} Precomputed rectangular(trapezoidal) maps
example
} No mip mapping vs with mip mapping
example
} Bilinear mip mapping vs trilinear mip mapping
Bump Mapping
} Use texture to perturb normals
} Textures are treated as height field
} creates a bump-like effect

+ =

original surface bump map modified surface

O(u , v) B (u , v) O' (u, v)

Does not change silhouette edges


Bump Mapping
} Texture values perturb surface normals
} Textures are treated as height field

+ =
geometry Bump map Bump mapped geometry
Stores heights: can derive normals
Bump Mapping
Bump Mapping
Normal Mapping (bump mapping)
} Replace normals (RGB values are stored in XYZ)
Displacement Mapping
Use texture to displace the surface geometry

+ =

Bump mapping only affects the normals,


Displacement mapping changes the actual positions
(including the silhouette)
Displacement Mapping (Result)
} Displacement Offset
Environment Maps
Use texture to represent reflected color
} Texture indexed by reflection vector
} Approximation works when objects are far away from
the reflective object
Environment Maps
Using a spherical environment map

Spatially variant resolution


Environment Maps
Using a cubical environment map
Environment Mapping
} Environment mapping produces reflections on shiny
objects
} Texture is transferred in the direction of the reflected ray
from the environment map onto the object
} Reflected ray: R=2(N·V)N-V Environment Map

Viewer
Reflected ray

Object
Approximations Made
} The map should contain a view of the world with the
point of interest on the object as the eye
} We can’t store a separate map for each point, so one map is
used with the eye at the center of the object
} Introduces distortions in the reflection, but the eye doesn’t
notice
} Distortions are minimized for a small object in a large room
} The mapping can be computed at each pixel, or only at
the vertices
Example
Environmental Mapping
} Generate images using Tools, Special Cameras (fisheye,
omnidirectional)
3D Textures
} Texture values indexed by 3D location (x, y, z)
} Object is carved out of the
solid texture
} Expensive storage, or
} Compute on the fly
ex) Perlin Noise
} Marble or wood

You might also like