Texture Mappig Jia Huag This set of slides refereces the oes used at Ohio State for istructio.
Ca you do this
What Dreams May Come
Texture Mappig Of course, oe ca model the exact micro-geometry + material property to cotrol the look ad feel of a surface But, it may get extremely costly So, graphics use a more practical approach texture mappig
Texture Mappig Particles ad fractals gave us lots of detail iformatio ot easy to model mathematically ad computatioally challegig
Texture Mappig (Sophisticated) Illumiatio models gave us photo -realistic lookig surfaces ot easy to model mathematically ad computatioally challegig Phog illumiatio/shadig easy to model relatively quick to compute oly gives us dull surfaces
Texture Mappig Surfaces i the wild are very complex Caot model all the fie variatios We eed to fid ways to add surface detail How?
Texture Mappig Solutio - (its really a cheat!!) MAP surface detail from a predefied multi-dimesioal table ( texture ) to a simple polygo How?
Textures Make A Differece Good textures, whe applied correctly, make a world of differece!
A Texture ca be? F(u,v) ==> a cotiuous or discrete fuctio of: { R(u,v), G(u,v), B(u,v) } { I(u,v) } { idex(u,v) } { alpha(u,v) } (trasparecy) { ormals(u,v) } (bump map) { surface_height(u,v) } (displacemet map) Specular color (eviromet map)
The Geeralized Pipelie The geeralized pipelie of texture mappig Compute obj space locatio Use proj fuc to fid (u,v) Use corre fuc to fid texel Apply value trasform fuc Modify equatio or fragmet color Fragmet: after rasterizatio, the data are ot pixels yet, but are fragmets. Each fragmet has coordiate, color, depth, ad udergo a series of tests ad ops before showig up i the framebuffer
Texture Mappig Problem #1 Fittig a square peg i a roud hole We deal with o-liear trasformatios Which parts map where?
Iverse Mappig Need to trasform back to obj/world space to do the iterpolatio Orietatio i 3D image space (.5,1) (.8,1) (.5,.7) (.1,.6) (.6,.2) Foreshorteig
Texture Mappig Problem #2 Mappig from a pixel to a texel Aliasig is a huge problem!
Mappig to A Texel? Basically map to a image Need to iterpolate Same as. How ca I fid a appropriate value for a arbitrary (ot ecessarily iteger) idex? How would I rotate a image 45 degrees? How would I traslate it 0.5 pixels?
Iterpolatio Nearest eighbor Liear Iterpolatio
How do we get F(u,v)? We are give a discrete set of values: F[i,j] for i=0,,n, j=0,,m Nearest eighbor: F(u,v) = F[ roud(n*u), roud(m*v) ] Liear Iterpolatio: i = floor(n*u), j = floor(m*v) iterpolate from F[i,j], F[i+1,j], F[i,j+1], F[i+1,j+1] Filterig i geeral!
How do we get F(u,v)? Higher-order iterpolatio F(u,v) = å i å j F[i,j] h(u,v) h(u,v) is called the recostructio kerel Gaussia Sic fuctio splies Like liear iterpolatio, eed to fid eighbors. Usually four to sixtee
Texture ad Texel Each pixel i a texture map is called a Texel Each Texel is associated with a (u,v) 2D texture coordiate The rage of u, v is [0.0,1.0]
(u,v) tuple For ay (u,v) i the rage of (0-1, 0-1), we ca fid the correspodig value i the texture usig some iterpolatio
The Projector Fuctio 1. Model the mappig: (x,y,z) -> (u,v) 2. Do the mappig
Image space sca For each y /* sca-lie */ For each x /* pixel o sca-lie */ compute u(x,y) ad v(x,y) copy texture(u,v) to image(x,y) Samples the warped texture at the appropriate image pixels. iverse mappig
Image space sca Problems: Fidig the iverse mappig Use oe of the aalytical mappigs Bi-liear or triagle iverse mappig May miss parts of the texture map Image Texture
Texture Parameterizatio Defiitio: The process of assigig texture coordiates or a texture mappig to a object. The mappig ca be applied: Per-pixel Per-vertex
Iterpolatio Cocepts T is texture Fid textures at vertices first! t 1 y s T a T p T b P 1 1-t 1 s 1-s t 2 1-t 2 P 3 P 2
Quads? P 3 P 4 P 2 y s t a t p t b P 1 Biliear Iterpolatio of Depth Values
Texture space sca For each v For each u compute x(u,v) ad y(u,v) copy texture(u,v) to image(x,y) Places each texture sample to the mapped image pixel. Forward mappig
Texture space sca Problems: May ot fill image Forward mappig eeded Texture Image
Simple Projector Fuctios Spherical Cylidrical Plaar For some model, a sigle projector fuctio suffices. But very ofte, a artist may choose to subdivide each object ito parts that use differet projector
Plaar Mappig to a 3D Plae Simple Affie trasformatio rotate scale y v traslate z x u
Cylidrical Mappig to a Cylider Rotate, traslate ad scale i the uv-plae u -> q v -> z x = r cos(q), y = r si(q) v u
Spherical Mappig to Sphere Impossible!!!! Severe distortio at the poles u -> q v -> f x = r si(q) cos(f) y = r si(q) si(f) z = r cos(q)
Two-pass Mappig Idea by Bier ad Sloa S: map from texture space to itermediate space O: map from itermediate space to object space
Two-pass Mappig Map texture to itermediate: Plae Cylider Sphere Box Map object to same. v u u-axis
Texture Mappig O mappig: reflected ray (eviromet map) object ormal object cetroid itermediate surface ormal (ISN) that makes 16 combiatios oly 5 were foud useful
Texture Mappig Cylider/ISN (shrikwrap) Works well for solids of revolutio Plae/ISN (projector) Works well for plaar objects Box/ISN Sphere/Cetroid Box/Cetroid Works well for roughly spherical shapes
Texture Parameterizatio What is this ISN? Itermediate surface ormal. Needed to hadle cocave objects properly. Sudde flip i texture coordiates whe the object crosses the axis.
Texture Parameterizatio Flip directio of vector such that it poits i the same half-space as the outward surface ormal.
Texture Parameterizatio Plae/ISN
Texture Parameterizatio Plae/ISN Draw vector from poit (vertex or object space pixel poit) i the directio of the texture plae. The vector will itersect the plae at some poit depedig o the coordiate system
Texture Parameterizatio Plae/ISN Resembles a slide projector Distortios o surfaces perpedicular to the plae.
Texture Parameterizatio Cylider/ISN Distortios o horizotal plaes Draw vector from poit to cylider Vector coects poit to cylider axis
Texture Parameterizatio Sphere/ISN Small distortio everywhere. Draw vector from sphere ceter through poit o the surface ad itersect it with the sphere.
Iterpolatig Without Explicit Iverse Trasform Sca-coversio ad color/z/ormal iterpolatio take place i scree space, but really, what space should it be i? What about texture coordiates? Do it i clip space, or homogeous coordiates
I Clip space Two ed poits of a lie segmet (sca lie) Iterpolate for a poit Q i-betwee
I Scree Space From the two ed poits of a lie segmet (sca lie), iterpolate for a poit Q i-betwee: Where: Easy to show: i most occasios, t ad t s are differet
From t s to t Chage of variable: choose a ad b such that 1 t s = a/(a + b), t s = b/(a + b) A ad B such that (1 t)= A/(A + B), t = B/(A + B). Easy to get Easy to verify: A = aw 2 ad B = bw 1 is a solutio
Texture Coordiates All such iterpolatio happes i homogeeous space. Use A ad B to liearly iterpolate texture coordiates The homogeeous texture coordiate is: (u,v,1)
Homogeeous Texture Coordiates u l = A/(A+B) u 1l + B/(A+B)u l 2 w l = A/(A+B) w 1l + B/(A+B)w l 2 = 1 u = u l /w l = u l = (Au 1l + Bu 2l )/(A + B) u = (au 1l + Bu 2l )/(A + B) u = (au 1l /w 1l + bu 2l /w 2l )/(a 1 /w 1l + b 1 /w 2l )
Homogeeous Texture Coordiates The homogeeous texture coordiates suitable for liear iterpolatio i scree space is computed simply by Dividig the texture coordiates by scree w Liearly iterpolatig (u/w,v/w,1/w) Dividig the quatities u/w ad v/w by 1/w at each pixel to recover the texture coordiates