Surface Details

Surface Details

Surface Details ✫ Incorp orate ne details in the scene. ✫ Mo deling with p olygons is impractical. ✫ Map an image texture/pattern on the surface Catmull, 1974; Blin & Newell, 1976. ✫ Texture map Mo dels patterns, rough surfaces, 3D e ects. ✫ Solid textures 3D textures to mo del wood grain, stains, marble, etc. ✫ Bump mapping Displace normals to create shading e ects. ✫ Environment mapping Re ections of environment on shiny surfaces. ✫ Displacement mapping Perturb the p osition of some pixels. CPS124, 296: Computer Graphics Surface Details Page 1 Texture Maps ✫ Maps an image on a surface. ✫ Each element is called texel. ✫ Textures are xed patterns, pro cedurally gen- erated, or digitized images. CPS124, 296: Computer Graphics Surface Details Page 2 Texture Maps ✫ Texture map has its own co ordinate system; st-co ordinate system. ✫ Surface has its own co ordinate system; uv -co ordinates. ✫ Pixels are referenced in the window co ordinate system Cartesian co ordinates. Texture Space Object Space Image Space (s,t) (u,v) (x,y) CPS124, 296: Computer Graphics Surface Details Page 3 Texture Maps v u y xs t s x ys z y xs t s x ys z CPS124, 296: Computer Graphics Surface Details Page 4 Texture Mapping CPS124, 296: Computer Graphics Surface Details Page 5 Texture Mapping Forward mapping: Texture scanning ✫ Map texture pattern to the ob ject space. u = f s; t = a s + b t + c; u u u v = f s; t = a s + b t + c: v v v ✫ Map ob ject space to window co ordinate sys- tem. Use mo delview/pro jection transformations. Drawback: Selected texture patch usual do es not match with pixel b oundaries. ✫ Requires fractional pixel calculations. CPS124, 296: Computer Graphics Surface Details Page 6 Inverse Mapping y xs t -1 -1 M M PV T s x ys z ✫ Map screen co ordinate system to ob ject space. ✫ Map ob ject co ordinate system to texture space. ✫ Avoids fractional pixel calculations. ✫ Allows anti-aliasing. ✫ Requires calculating inverse transformations; 1 1 M ;M . PV T 1 M can be computed from pro jection and PV mo delview matrices gluUnproject 1 Computing M is not easy. T CPS124, 296: Computer Graphics Surface Details Page 7 Parametric Representation Curves: Co ordinates are represented as functions of one parameter. t = xt;yt; t 2 [a; b] Line: ` : a + b t; a + b t, t 2 R 1 1 2 2 Surfaces: Co ordinates of each p oint is represented as a function of u and v . S u; v = xu; v ;yu; v ;zu; v . ✫ Sphere: S u; v = r cos u cos v; r cos u sin v; r sin u =2 u =2; 0 v 2. ✫Cylinder: S u; v = r cos u; r sin u; v 0 u 2; 0 v h. CPS124, 296: Computer Graphics Surface Details Page 8 Inverse Mapping: An Example y t (u,v) s x z u = ; v = y 0 =2; 0 y 1 x = sin ; z = cos ; y = v: 1 1 M : u = sin x; v = y: PV Map texture origin to left b ottom corner of the surface u = s =2; v = t: 1 Pro jected pixels are mapp ed to texture with M : T 2u 1 M : s = t = v: T 2 1 s = sin x t = z: CPS124, 296: Computer Graphics Surface Details Page 9 Object to Texture Mapping 1 How do es one de ne a reasonable M ? T Bier & Sloan, 1986: Two-step pro cess: S -mapping: Mapping from a 2D texture space to a simple 3D surface, e.g., cylinder. 0 T u; v ! T x ;y ;z : i i i O-mapping: Mapping from the 3D texture pat- tern onto the ob ject surface. 0 T x ;y ;z ! Ox ;y ;z : i i i w w w CPS124, 296: Computer Graphics Surface Details Page 10 Two-Step Inverse Mapping Inverse mapping: Apply them in the reverse or- der! -1 S -1 O M-1 CPS124, 296: Computer Graphics Surface Details Page 11 S -Mapping Four p ossible surfaces: Plane, cylinder, sphere, box. Cylinder: ; z 1 r ; z z S : ; z ! 0 0 c d ✫c; d: Scaling factors. ✫ Texture origin is mapp ed to the p oint ;z 0 0 on the cylinder. Sphere: ; ', stereographic pro jection. θ (α,β) φ (θ,φ) 2 S : ; ' ! ; 2 2 1=2 1 + 1 + + 2 2 2 1=2 1 + 1 + + = tan ' cos , = tan ' sin . CPS124, 296: Computer Graphics Surface Details Page 12 S -Mapping t s t Back Left Bottom Right Top s Front CPS124, 296: Computer Graphics Surface Details Page 13 O -Mapping P' P' P P (ii) (i) P' P' P P (iii) C (iv) ✫ : Intermediate surface 0 ✫ P : Intersection of with a ray emanating from P . ✫ Direction of : i Re ection direction ii Normal of O at P iii CP ; C: centroid of O 0 iv : Normal of at P ✫ ii, iii are bad if is cylinder. CPS124, 296: Computer Graphics Surface Details Page 14 3D Textures Intro duced by Peachey and Perlin in 1985. ✫ De ne texture to be a 3D image. Carving out an ob ject from a 3D solid ma- terial. ✫ Ignoring scaling, M is identity. T ✫ Distortion is minimized. ✫ Three dimensional vector elds can be mapp ed coherently. ✫ Texture is generated by a pro cedure. ✫ Example: Wood grain can be mapp ed as a set of cylinders with resp ect to a presp eci ed axis. CPS124, 296: Computer Graphics Surface Details Page 15 3D Textures Basic texture 3D noise textured object 3D texture Textures object Object CPS124, 296: Computer Graphics Surface Details Page 16 Anti-aliasing & Texture Mapping Aliasing is particularly visible in p erio dic and co- herent textures. With Without Antialiasing Antialiasing CPS124, 296: Computer Graphics Surface Details Page 17 Anti-aliasing & Texture Mapping ✫ A pixel is mapp ed to a curvilinear quadrilat- eral. ✫ A single pixel may cover many texels. ✫ Compute a weighted sum of texel values cov- ered by the pixel. ✫ Summation is called ltering. Two-step pro cess: ✫ De ne and approximate the texture over which ltering is p erformed. ✫ Integrate by weighing and summing the texel values within the ltering area. CPS124, 296: Computer Graphics Surface Details Page 18 Anti-aliasing: Weight Functions Blinn & Newell, 1976: Pyramid weight function Preimage of Approximation Preimage of the pixel center Greene & Heckb ert, 1986: Elliptical weighted av- erage ✫ Approximate a pixel by circle. ✫ Circle always maps to an ellipse in the texture space. ✫ Find the texels that lie inside the ellipse. ✫ Use a lo ok-up table to determine the weighted value of each texel. CPS124, 296: Computer Graphics Surface Details Page 19 Anti-aliasing & Texture Mapping Mip-mapping: multum in parvo Williams, 1983 ✫ Store many texture images. ✫ i-th image is obtained by scaling down the pre- vious image by half along each axis. ✫ E ectively a 3D database. ✫ Given a pixel, search in the image with an ap- propriate resolution. CPS124, 296: Computer Graphics Surface Details Page 20 Texture Mapping in Op enGL Geometric Vertices Rasterization Display processing Pixel Pixels operations ✫ Relies on the pip eline architecture ✫ Texture mapping is done at the rasterization stage. glTexImage2D GL TEXTURE 2D, level, comp, w, h, b order, format, typ e, tarray GLubyte my texel[512][512]; glTexImage2D GL TEXTURE 2D, 0, 3, 512, 512, 0 GL RGB, GLuint, tarray; glEnableGL TEXTURE 2D; ✫ level: Multiple levels of texture maps; 0 for one level. ✫ comp: integer between 1 and 4; sp eci es how many of R, G, B, and A comp onents sp eci ed. ✫ format: Format of the texture map. CPS124, 296: Computer Graphics Surface Details Page 21 Texture Mapping in Op enGL glTexCoord2f s, t Assigns the two dimensional texture co ordinates to a vertex. (a) (b) glBeginGL QUAD; glTexCoord2f 0.0, 0.0; glVertex3f x1, y1, z1; glTexCoord2f 1.0, 0.0; glVertex3f x2, y2, z2; glTexCoord2f 1.0, 1.0; glVertex3f x3, y3, z3; glTexCoord2f 0.0, 1.0; glVertex3f x4, y4, z4; glEnd CPS124, 296: Computer Graphics Surface Details Page 22 CPS124, ✫ Texture ob jects 296: T exture glGenTexturesn, *names; glBindTexturetarget, name; Computer ✫ Rep eating the texture pattern Mapping glTexParameteriGL TEXTURE WRAP S,GL REPEAT Graphics glTexParameteri GL TEXTURE WRAP S,GL CLAMP Use GL TEXTURE WRAP T for t-co ordinates ✫ Assign a pixel color to the nearest texel in Surf glTexParameterf GL TEXTURE2D, penGL Op GL TEXTURE MAG FILTER, GL NEAREST a ce glTexParameterf GL TEXTURE2D, Det GL TEXTURE MIN FILTER, GL NEAREST ails ✫ GL LINEAR: Interp olates the color using a 2 2 average. P age 23 Bump Mapping Perturb normals in the illumination mo del calcu- lations. ✫ S u; v : Parameterized surface ✫ S = @Su; v =@ u, S = @Su; v =@ v . u v ✫ N u; v = S S ; n = N=jN j u v ✫bu; v : Bump function 0 0 0 S u; v = S u; v + bu; v n N u; v = S S v u @ 0 S = Su; v + bu; v n u @u = S + b n + bn u u u S + b n u u 0 S S + b n v v v 0 N S S + b S n + b n S + u v u u v v b b n n u v = S S + b S n + b n S u v u u v v CPS124, 296: Computer Graphics Surface Details Page 24 Bump Mapping S(u) b(u) S'(u) N'(u) CPS124, 296: Computer Graphics Surface Details Page 25 Bump Mapping ✫ De ne bump functions analytically. ✫ Use lo ok-up tables for bump functions. ✫ Approximate b ;b with nite di erences.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    27 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us