CS 563 Advanced Topics in Computer Graphics
Texture Sampling & antialiasing - Basic Texturing (Ch. 8)
Physically Based Rendering
Travis Grant
grant_travis@emc.com
Outline
Texture Space Sampling Rate
Aliasing associated with Texture
Refracted and Reflected Rays
Texture Coordinate Generation
Texture Interface and basic textures
grant_travis@emc.com :: Slide 2
p. 496 Fig. 11.5 (a) ./images/11F05A.png
Grid texture on sphere w/ 1 sample per pixel
grant_travis@emc.com :: Slide 3
Two Core Challenges for
removing Texture Aliasing
Sampling Rate
Must be computed in Texture space as opposed
to screen space
Must determine rate which the texture function is
being sampled
Sampling Theory
Given the sampling rate we need to remove
excess frequencies beyond the Nyquist limit from
the texture function
grant_travis@emc.com :: Slide 4
Texture Sampling Rate
(s(t) )
,s,t
(u0,v0)
(x0,y0) (u,v) texture space
(x,y)
object space
(u1,v 1)
image space
( x1 , y 1 )
PBRT Texture coordinates are (S,T):
- Commonly used industry Apps often use (u,v)
- PBRT uses (u,v) as a shapes “parametric description” coordinates
p=f(u,v) = p(x,y)
- Where p(x,y) is the Worldspace intersection point p. 488 Fig. 11.2 :: Slide 5
Simple Example:
Finding Texture Sampling Rate
Image Space, Object Space &
Texture Space perfectly aligned
s=Px t=Py
x y
s t
xr yr
thus given a sample spacing of 1 pixel in
the image plane the sample spacing in
(s,t) texture space is (1/xr, 1/yr)
grant_travis@emc.com :: Slide 6
Simple Example:
Finding Texture Sampling
Rate
f f
Image Space, Object Space & f ( x' , y ' ) f ( x, y ) ( x' x) ( y ' y )
Texture Space perfectly aligned x y
s 1 t
0
x xr x
s t 1
0
y y yr
grant_travis@emc.com :: Slide 7
Daylon Leveller Tutorial Texture Aliasing
- The previous example was purposely kept overly simple:
- The following realities all lend to more complex but common
scenarios:
Object Visibility
Object Shape
Perspective
Shadowing
Texture Frequency Variance
Daylon Leveller Tutorial :: Slide 8
Texture Sampling Rate
(s,t)
(u,v) p
x
from image space to world space -> p(x,y) p
(x,y)
y
u u
x y
to parametric coordinates -> u(x,y),v(x,y)
v v
x y
p. 488 Fig. 11.2 :: Slide 9
Estimating Partial
Derivatives
ry rx
n
p px
py
p. 491 Fig. 11.3 :: Slide 10
ryrx
n Estimating Partial
Derivatives
p px
py
ax by cz d 0 equation 1
a nx a ny a nz d (n p)
(( a, b, c) 0) d
t
(a, b, c) d
equation 2
p p
dpdx = px p dpdy = py p
x y
p. 491 Fig. 11.3 :: Slide 11
(u,v) parameterization
dv p’
∂p
∂v
∂p
∂u
p
du
p. 492 Fig. 11.4 :: Slide 12
(u,v) parameterization
p x p x
p' p x u v
p p p y p y u
p' p u v p' p y
u v v
or
p' p u v
z p z p z
u
v
grant_travis@emc.com :: Slide 13
Filtering Texture Functions
first evaluate T ( f ( x, y))
band-limit: by convolving with the sinc filter
Tb ' ( x, y) sinc( x' )sinc( y' )T ' ( f ( x x' , y y' ))dx' dy'
convolved with the pixel filter g(x,y) centered at the point (x,y)
xWidth / 2 yWidth / 2
T f ' ( x, y ) g(x', y')T ' ( x x' , y y' )dx' dy'
xWidth / 2 yWidth / 2
b
grant_travis@emc.com :: Slide 14
What did we get for our efforts?
Texture Aliasing
p. 486 Fig. 11.1 (a) ./images/11F01A.png p. 486 Fig. 11.1 (b) ./images/11F01B.png
Severe aliasing artifacts Zoom-In of sphere from left
Notice High-Frequency detail is present
grant_travis@emc.com :: Slide 16
Texture Aliasing
p. 486 Fig. 11.1 (a) ./images/11F01A.png p. 486 Fig. 11.1 (c) ./images/11F01C.png
Severe aliasing artifacts Texture function applied
grant_travis@emc.com :: Slide 17
p. 496 Fig. 11.5 (c) ./images/11F05C.png
antialiased image, even with a single sample per pixel
grant_travis@emc.com :: Slide 18
Reflected & Refracted Rays
p. 496 Fig. 11.5 (a) ./images/11F05A.png
Tracking ray differentials
Left is glass (reflection & refraction)
Right is Mirror (reflection)
grant_travis@emc.com :: Slide 19
Tracking Ray
Differentials
p. 496 Fig. 11.5 (b) ./images/11F05B.png p. 496 Fig. 11.5 (c) ./images/11F05C.png
aliasing artifacts antialiasing w/ ray differentials
grant_travis@emc.com :: Slide 20
Specular Reflection
r r’
θ
θ
θ’
θ’
p. 497 Fig. 11.6 :: Slide 21
Specular Reflection
where: wi is the reflected direction with respect to a shift of a pixel in the x and y directions
wi
w wi
x
wi wo 2( wo n)n
wi wo n wo n
wo 2( wo n)n 2 wo n n
x x x x x
wo n wo n
n wo
x x x
p. 497 Fig. 11.6 :: Slide 22
(s,t) Texture Coordinate
Generation
p. 499 Fig. 11.7 ./images/11F05A.png
(u,v) Spherical Cylindrical Planer
Different texture coordinate generation techniques
Checkerboard texture applied to a hyperboloid
grant_travis@emc.com :: Slide 23
Texture
Interfaces and Basic Texture
Constant
Scale
Mix
Bilinear
References
“Physically Based Rendering” by Gregg Humphreys & Matt Pharr
All Images Obtained from “Physically Based Rendering” CD-ROM
Figures recreated by tgrant from figures cited in “Physically Based Rendering”
textbook
Daylon Graphics – Leveller Documentation
Raytracer Texturing
www.cambridgeincolour.com (Sean T. Mchugh)
Digital Image Interpolation
“Computer Graphics: Principles & Practice” by Foley, van Dam, Feiner, Hughes
“What We Need Around Here is More Aliasing” by Blinn, J.F.
“Return of the Jaggy” by Blinn, J.F.
“The Aliasing Problem in Computer-Generated Shaded Images” by Crow, F.
“A Comparison of Antialiasing Techniques” by Crow, F.
Harvey Mudd College
HMC Tutorial on Partial Differentiation
grant_travis@emc.com :: Slide 25
Questions?
Backup Slides
grant_travis@emc.com :: Slide 27
Geometric Meaning
of Partial Derivatives
Suppose the graph of z = f(x,y)
is the surface shown.
Consider the partial
derivative of f with respect
to x at a point (x0,y0).
Holding y constant and varying
x, we trace out a curve that
is the intersection of the
surface with the vertical
plane y = y0.
The partial derivative fx(x0,y0)
measures the change in z
per unit increase in x along
this curve. That is, fx(x0,y0)
is just the slope of the curve
at (x0,y0). The geometrical
interpretation of fy(x0,y0) is
analogous.
Harvey Mudd College (see References) :: Slide 28
Blinn “What we need around here is more Aliasing” :: Slide 29
Blinn “What we need around here is more Aliasing” :: Slide 30
Blinn “What we need around here is more Aliasing” :: Slide 31
Blinn “What we need around here is more Aliasing” :: Slide 32
Aliasing Review
jaggies = staircasing = aliasing
resampled
Ideal Line on Low Resolution Grid Aliased
reproduced from cambridgeincolour.com :: Slide 33
Aliasing Review
IF (Line_Is_Inside_Pixel) = black
resampled
Ideal Line on Low Resolution Grid Aliased
reproduced from cambridgeincolour.com :: Slide 34
Aliasing Review
High Frequency Variation
resampled
Ideal Line on Low Resolution Grid Aliased
reproduced from cambridgeincolour.com :: Slide 35
Aliasing Review
resampled
Ideal Line on Low Resolution Grid Anti-Aliased
reproduced from cambridgeincolour.com :: Slide 36
Unweighted Area Sampling
Three Properties of Unweighted area sampling:
1) Intensity of the pixel intersected by a line edge decreases as the distance
between the pixel center and the edge increases
2) Non-intersected pixels are not influenced
3) Only the total amount of overlapped area matters (not weighted based on
orientation towards the center of the pixel)
resampled
Ideal Line on Low Resolution Grid Anti-Aliased
reproduced from cambridgeincolour.com :: Slide 37
Unweighted Area Sampling
Accounting for contributions of original
-> result is % of BLACK (light Gray)
resampled
Ideal Line on Low Resolution Grid Anti-Aliased
reproduced from cambridgeincolour.com :: Slide 38