Perlin, SIGGRAPH85 Einführung in Visual Computing 186.822 v Textures T u Werner Purgathofer
Surface Rendering Methods polygon rendering methods ray tracing global illumination environment mapping texture mapping bump mapping Werner Purgathofer 2
Textures in the Rendering Pipeline scene objects in object space object capture/creation ti modeling viewing projection vertex stage ( vertex shader ) transformed vertices in clip space clipping + homogenization scene in normalized device coordinates viewport transformation rasterization ti shading raster image in pixel coordinates 3 pixel stage ( fragment shader )
Environment Mapping Principle reflection mapping defined over surface of an enclosing universe (sphere, cube, cylinder) spherical environment map leighmachin.com objects in scene Werner Purgathofer 4
Environment Mapping Examples Jim Blinn Werner Purgathofer 5 Haeberli/Segal
Environment Mapping Calculation information in the environment map intensity values for light sources sky background objects environment map pixel projected onto surface reflected onto environment map Werner Purgathofer 6 pixel projection onto environment map projection reference point surface pixel
Environment Mapping Calculation information in the environment map intensity values for light sources sky background objects environment map pixel area projected onto surface reflected onto environment map Werner Purgathofer 7 pixel area projection onto environment map projection reference point surface pixel area
Environment Mapping Example Werner Purgathofer 8
Environment Mapping Filtering environment maps may be filtered for not so reflective surfaces Werner Purgathofer 9
Environment Mapping with Cube Map (1) z (1/1) y b x define textures on 6 sides of a cube, each parameterized in (u,v) v (0/0) u direction vector b starts t at (000) (0,0,0) Werner Purgathofer 10
Environment Mapping with Cube Map (2) z (1/1) find (u,v) from top view y b the direction vector b: y x if x xb b > y b and x b > z b x b vv then front face u=(y b +x)/2x b b x b y b 0 u 1 (0/0) u v=(z b +x)/2x b b analogous formulas for the other 5 faces ( x> y x> z, y> x y> z, y> x y> z, z> x z> y, z> x z> y ) Werner Purgathofer 11
Environment Mapping with Cube Map (3) z (1/1) r y n x b b=r v n v vv at a pixel: u viewing direction v (0/0) and normal vector n b + v = (2n v)n b = (2n v)n v Werner Purgathofer 12
Environment Mapping Example Werner Purgathofer 13
Adding Surface Detail most objects do not have smooth surfaces brick walls gravel roads carpets surface texture required D.Molyneaux Werner Purgathofer / Computergraphik 1 14 Stanford Artificial Studios
Adding Surface Detail modeling surface detail with polygons small polygon facets (e.g., checkerboard squares) facets overlaid on surface polygon (parent) parent surface used for visibility calculations facets used for illumination calculations impractical for complicated surface structure Werner Purgathofer 15
Texture Mapping: Principle texture patterns mapped onto surfaces texture pattern: raster image or procedure (modifies surface intensities) Jim Blinn viewing texturet space: texture-surface object space: image space: & projection (u,v) array transformation ti (u*,v*) surface transformation (x,y) pixel coordinates parameters coordinates Werner Purgathofer 16
Texture Mapping: Transformation texture mapping texture scanning (u,v) (x,y) ( ) inverse scanning (x,y) (u,v) viewing texture space: texture-surfacet object space: image space: & projection (u,v) array transformation (u*,v*) surface transformation (x,y) pixel coordinates parameters coordinates M T texture surface transformation M VP u* = u*(u,v) = a u* u + b u* v + c u* v* = v*(u,v) = a v* u + b v* v + c v* Werner Purgathofer 17
Texture Mapping: Inverse Transformation projecting pixel areas to texture space = = inverse scanning (x,y) (u,v) ( ) projected v M 1 M 1 VP pixel area T 1 0 0 1 calculation of M 1 VP u M 1 T anti aliasing with filter operations surface pixel area Werner Purgathofer 18
Texture Mapping: Cylindrical Surface M VP u*, with 0 /2 x² + y² = r² x, y 0 0 z h z v* z with 0 z h x r cos u* * y r sinu* * z v* * h r (u*,v*)* *) y M 1 M 1 VP pixel surface point (x,y,z) x θ (x,y,z) (u*,v*): u* = cos 1 (x/r), v* = z Werner Purgathofer 19
Texture Mapping: Cylindrical Surface M T u* = u π/2, v* = v h v z 1 h r (u*,v*)* *) 0 0 1 u x θ y M 1 T u = 2u*/π, v = v*/h (u* = cos 1 (x/r), v* = z) u = cos 1 (x/r)/π, v = z/h Werner Purgathofer 20
Texture Mapping: Anti aliasing anti aliasing with filter operations project pixel area into texture space and take average texture value back- projected pixel speed ups: mip mapping mapping summed area table method texturet space Werner Purgathofer 21
Perspective Correct Textures on Triangles mapping a texture on a triangle with barycentric coordinates: p(α,β,γ) = α a + β b + γ c color(x,y) = α t + β t + γ t 0 1 2 fails after perspective transform! correct: Werner Purgathofer 22
Perspective Correct Textures on Triangles solution: keep homogeneous weights h,h,h of a, b, c 0 1 2 and correct the barycentric values d=hh 1 h 2 +hβ(h 2 0 h 1 )+hγ(h 1 0 h 2 ) β w =hh 0 h 2 β/d γ w =hh 0 h 1 γ/d α w =1 β w γ w u = α w u 0 + β w u 1 + γ w u 2 v = α w v 0 + β w v 1 + γ w v 2 color(x,y) = t(u,v) instead of u=αu 0 +βu 1 +γu 2 v=αv 0 +βv 1 +γv 2 color(x,y) o = t(u,v) Werner Purgathofer 23
Solid Texturing texture defined in 3D every position in space has a color coherent textures across corners Werner Purgathofer 24
Solid Texturing Examples examples for application of 3D textures on a scull and a face Univ.Swansea Univ.Swansea Werner Purgathofer 25
Procedural Texturing procedural texture definition texture function t(x,y,z) returns intensity avoid M T 2D (surface texturing) or 3D (solid texturing) stochastic variations (noise function) examples wood grains marble foam Alias Wavefront Werner Purgathofer 26
Bump Mapping Principle bumps are visible because of shading modeling of bumps is very costly. trick: insert a detail structure b: v + = Tb Werner Purgathofer 27 u
Bump Mapping Examples Jim Blinn Dave Pape Gamestar Werner Purgathofer 28 Stanford
Reminder: Derivation of a Function f(x) derivation of a function in x one variable is the slope of the function f'(x) f'(x) = df(x)/dx = df/dx x Werner Purgathofer 29
Reminder: Partial Derivation of a Function f(x,y) y f(x,y)/ y = f/ y f(x,y)/ x ( = f/ x x partial derivations of a function in two variables are the slopes of the functions when you keep one of the variables fixed, they are slopes of tangents Werner Purgathofer 30
Bump Mapping Calculation surface roughness simulated perturbation function varies surface normal locally bump map b(u,v) n p(u,v) ( ) surface point v n * = p = * * u p v n n / n surface normal u Perlin p'(u,v) = p(u,v) + b(u,v) n b(u,v) = modified surface point + + n p (u (u,v) Werner Purgathofer 31 p(u,v)
Bump Mapping Calculation p'(u,v) (, ) = p(u,v), ) + b(u,v) n n' =(p u ' p v ' p u ' = p+bn)/ u ) = p u +b u n+bn u p u ' p u +b u n p v ' p v +b v n p u u u because b is very small Alias Wavefront n' = (p u +b u n) (p v +b v n) n' = p u p v +b v (p u n)+b u (n p v )+b u b v (n n) n n=0 n' = n * +b v (p u n)+b u (n p v ) Werner Purgathofer 32
Bump Mapping Representation bump map b(u,v) defined as raster image b u, b v : approximated with finite differences Alias Wavefront Werner Purgathofer 33
Bump Mapping Problems sources of error distortions at grazing angles wrong silhouette (geometry is not changed!) wrong shadows hd missing bump shadows light effects on back side Werner Purgathofer 34 Copyright Alias Wavefront
Bump Mapping: Grazing Angles red buttons appear too flat, although they are shaded in 3D Werner Purgathofer 35
Bump Mapping Problems sources of error distortions at grazing angles wrong silhouette (geometry is not changed!) wrong shadows hd missing bump shadows light effects on back side Werner Purgathofer 36 Copyright Alias Wavefront
Bump Mapping: Wrong Silhouette bump mapping correct geometry Lifeng Wang Lifeng Wang Werner Purgathofer 37 Copyright Alias Wavefront
Bump Mapping Problems sources of error distortions at grazing angles wrong silhouette (geometry is not changed!) wrong shadows hd missing bump shadows light effects on back side Werner Purgathofer 38 Copyright Alias Wavefront
Bump Mapping: Missing Bump Shadows bump mapping correct shadows Lifeng Wang Lifeng Wang Werner Purgathofer 39 Copyright Alias Wavefront
Bump Mapping Problems sources of error distortions at grazing angles wrong silhouette (geometry is not changed!) wrong shadows hd missing bump shadows light effects on back side Werner Purgathofer 40 Copyright Alias Wavefront
Bump Mapping: Back Side Light Effects Werner Purgathofer 41 Copyright Alias Wavefront
Bump Mapping Problems sources of error distortions at grazing angles wrong silhouette (geometry is not changed!) wrong shadows hd missing bump shadows light effects on back side there exist special algorithms to repair each error Werner Purgathofer 42 Copyright Alias Wavefront
Displacement Mapping correct version of bump mapping surface points are moved from their original position outline of object changes much harder to implement than bump mapping rare in practice latest hardware blender.org partially supports it Werner Purgathofer 43 Stefan Jeschke
Multitexturing: Combination of Mappings 2 or more textures applied to a surface examples: texture + dirt texture + light map texture + bump map photo + annotations + = Werner Purgathofer 44
Multitexturing: Combination of Mappings bump mapping & environment mapping & texture mapping Werner Purgathofer 45 Marek Mizanin
VRVis Open Lab Day for Students, 9. Juni 2015, 13:00-17:30 VRVis lädt Studentinnen und Studenten zu einem Open Lab Day ein! Lernen Sie das VRVis kennen. Informieren Sie sich über Möglichkeiten für Praktika und Diplomarbeiten. Wo: VRVis Zentrum für Virtual Reality und Visualisierung Forschungs-GmbH TechGate Vienna, 4.Stock, Donau-City-Straße 1, 1220 Wien (U1 Station ti Vienna International ti Center/Kaisermühlen) Rückfragen an: Tel. +43(1)20501 30100, Email: office@vrvis.at www.vrvis.at/openlabday