At runtime, (bi)linearly interpolate between these coordinates during rasterization. Object space. Texture space. Image
Why Texturing? Idea: enhance visual appearance of plain surfaces by applying fine structured details
Texturing Eduard Gröller (today: Stefan Jeschke) Institute of Computer Graphics and Algorithms Vienna University of Technology 1
Eduard Gröller, Stefan Jeschke
Why Texturing?
Texturing: General Approach
Also possible: model very complex objects just by using simple textured geometry
Texels
Texture space (u,v)
Object space (xO,yO,zO)
Rendering (Projection etc.)
Parametrization
Eduard Gröller, Stefan Jeschke
2
Eduard Gröller, Stefan Jeschke
Image Space (xI,yI)
3
Texture Definition
Solid Texturing: Parametrization
A texture is a function:
1D texture: parameter can have arbitrary domain (along one axis, incident angle, etc.)
Algebraic: fast to evaluate but limited variety Sampled: most common method Raster images that are taken with a digital camera, scanned or synthesized
Textures can be defined: In 3D object space: "solid texturing" On the 2D object surface: "texture mapping" Eduard Gröller, Stefan Jeschke
4
Eduard Gröller, Stefan Jeschke
5
Solid Texturing: Parametrization
Solid Texturing: Parametrization
2D texture
Other 2D texture: cylindrical parametrization
Projection of 2D data
Depending on cylindrical coordinates of each point
Many possibilities for definition
Eduard Gröller, Stefan Jeschke
6
Eduard Gröller, Stefan Jeschke
7
Solid Texturing: Parametrization
Solid Texturing: Parametrization
Other 2D texture: spherical parametrization
3D texture: T(u,v,w)
Depending on spherical coordinates of each point
0 ≤ x2+y2 < 1 ¨ light brown 1 ≤ x2+y2 < 2 ¨ dark brown 2 ≤ x2+y2 < 3 ¨ yellow etc.
rings
added noise Eduard Gröller, Stefan Jeschke
8
Solid Texturing Examples (1)
Eduard Gröller, Stefan Jeschke
10
Eduard Gröller, Stefan Jeschke
9
Solid Texturing Examples (2)
Eduard Gröller, Stefan Jeschke
11
Solid Texturing Examples (3)
Texture Mapping
"Bombing": special solid texture function
Parametrization per vertex
Random sized spheres define areas of different material (like cheese holes) Precalculation of position and radius of all spheres
Apply (u,v) texture coordinates to every vertex
At runtime, (bi)linearly interpolate between these coordinates during rasterization
Fast rendering
¨ Object space 12
Eduard Gröller, Stefan Jeschke
Eduard Gröller, Stefan Jeschke
Texture space
Image space
13
Texture Mapping: Parametrization
Texture Mapping: Parametrization
Difficulty: how to minimize texture distortions?
Texture gradient Defines the amount of texture pattern distortion due to the spatial position in 3D-space
¨
Size / Shape / Density
¨
¨ ¨
Angular and area distortions can not be minimized at the same time! (except for some special cases) Eduard Gröller, Stefan Jeschke
14
Eduard Gröller, Stefan Jeschke
15
Texture Mapping: Parametrization
Texture Mapping vs. Solid Texturing
Example: box parametrization
Texture mapping
Solid texturing Eduard Gröller, Stefan Jeschke
16
Eduard Gröller, Stefan Jeschke
17
Texturing: Rendering
Aliasing
Problem: aliasing
Caused by undersampling: texture information is lost
One pixel in image space covers many texels
Texture space
Image space Eduard Gröller, Stefan Jeschke
18
Eduard Gröller, Stefan Jeschke
19
Anti-Aliasing
Anti-Aliasing
A good pixel value is the weighted mean of the pixel area projected into texture space
Calculation of the weighted mean at runtime (called "direct convolution")
Calculation at runtime or in a preprocess
Often used approximations
v Pixel
X X
Texture space
Eduard Gröller, Stefan Jeschke
u
Image space
20
Anti-Aliasing
Anti-Aliasing: Summed Area Table
Calculation of the weighted mean in a preprocess (called "prefiltering") Summed area table Mip Mapping (+ optional anisotropic filtering)
u
0 Eduard Gröller, Stefan Jeschke
22
+
=
+ S(u–,v–)
sum = ? (u0,v0)
=
S(u+,v+) – S(u–,v+) u
v
u ≤ u0 v ≤ v0
–
(u+,v+) (u–,v–)
precalculation of rectangle sums for each pixel
v
v T
Summed area table S
S(u0,v0) = Σ T(u,v)
21
Eduard Gröller, Stefan Jeschke
Effort/pixel is constant!
–
=
– S(u+,v–) = sum
u Eduard Gröller, Stefan Jeschke
23
Anti-Aliasing: Example (Summed Area T.)
Anti-Aliasing: MIP Mapping MIP Mapping (“Multum In Parvo”)
Di s
ta
nc e
Texture size is reduced by factors of 2 (downsampling = "much info on a small area") Simple (4 pixel average) and memory efficient Last image is only ONE texel
Eduard Gröller, Stefan Jeschke
24
Anti-Aliasing: Example (Mip Mapping)
Eduard Gröller, Stefan Jeschke
25
Anti-Aliasing: MIP Mapping MIP Mapping Algorithm "Mip Map level" D := ld(max(d1,d2)) T0 := value from texture D0= trunc (D)
d2 d1
Use bilinear interpolation
Eduard Gröller, Stefan Jeschke
26
Bilinear interpolation
Eduard Gröller, Stefan Jeschke
27
Trilinear interpolation
X
Anti-Aliasing: MIP Mapping
Anti-Aliasing: Mip Mapping (Example)
Trilinear interpolation:
Other example for bilinear vs. trilinear filtering
T1 := value from texture D1 = D0+1 (bilin.interpolation) Pixel value := (D1–D)·T0 + (D–D0)·T1 Linear interpolation between successive MIP Maps
Avoids "Mip banding" (but doubles texture lookups)
28
Eduard Gröller, Stefan Jeschke
Eduard Gröller, Stefan Jeschke
Anti-Aliasing
29
Anti-Aliasing (Bilinear Filtering Example)
Bilinear reconstruction for texture magnification (D