Download presentation
Presentation is loading. Please wait.
1
1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 12 Solid Textures Bump Mapping Environment Mapping
2
2GR2-00 Marble Texture
3
3GR2-00 Solid Texture n A difficulty with 2D textures is the mapping from the object surface to the texture image – ie constructing f u (x,y,z) and f v (x,y,z) solid n This is avoided in 3D, or solid, texturing – texture now occupies a volume – can imagine object being carved out of the texture volume U V W texture space X Y Z object space Mapping functions trivial: u = x; v = y; w = z
4
4GR2-00 Defining the Texture n The texture volume itself is usually defined procedurally – ie as a function that can be evaluated, such as: texture (u, v, w) = sin (u) sin (v) sin (w) – this is because of the vast amount of storage required if it were defined by data values
5
5GR2-00 Example: Wood Texture n Wood grain texture can be modelled by a set of concentric cylinders – cylinders coloured dark, gaps between adjacent cylinders coloured light radius r = sqrt(u*u + w*w) if radius r = r 1, r 2, r 3, then texture (u,v,w) = dark else texture (u,v,w) = light looking down: cross section view U V W texture space
6
6GR2-00 Example: Wood Texture n It is a bit more interesting to apply a sinusoidal perturbation – radius:= radius + 2 * sin( 20* ), with 0< <2 n.. and a twist along the axis of the cylinder – radius:= radius + 2 * sin( 20* + v/150 ) n This gives a realistic wood texture effect
7
7GR2-00 Wood Texture
8
8GR2-00 How to do Marble? n First create noise function (in 1D): – noise [i] = random numbers on lattice of points n Next create turbulence: – turbulence (x) = noise(x) + 0.5*noise(2x) + 0.25*noise(4x) + … n Marble created by: – basic pattern: marble (x) = marble_colour (sin (x) ) – with turbulence: marble (x) = marble_colour (sin (x + turbulence (x) ) )
9
9GR2-00 Marble Texture
10
10GR2-00 Bump Mapping n This is another texturing technique n Aims to simulate a dimpled or wrinkled surface – for example, surface of an orange trick n Like Gouraud and Phong shading, it is a trick – surface stays the same – but the true normal is perturbed, or jittered, to give the illusion of surface ‘bumps’
11
11GR2-00 Bump Mapping
12
12GR2-00 How Does It Work? n Looking at it in 1D: original surface P(u) bump map b(u) add b(u) to P(u) in surface normal direction, N(u) new surface normal N’(u) for reflection model
13
13GR2-00 How It Works - The Maths! n Any 3D surface can be described in terms of 2 parameters – eg cylinder of fixed radius r is defined by parameters (s,t) x=rcos(s); y=rsin(s); z=t n Thus a point P on surface can be written P(s,t) where s,t are the parameters n The vectors: P s = dP(s,t)/ds and P t = dP(s,t)/dt are tangential to the surface at (s,t)
14
14GR2-00 How it Works - The Maths n Thus the normal at (s,t) is: N = P s x P t n Now add a bump map to surface in direction of N: P’(s,t) = P(s,t) + b(s,t) N n To get the new normal we need to calculate P’ s and P’ t P’ s = P s + b s N + b N s approx P’ s = P s + b s N - because b small n P’ t similar – P’ t = P t + b t N
15
15GR2-00 How it Works - The Maths n Thus the perturbed surface normal is: N’ = P’ s x P’ t or N’ = P s x P t + b t (P s x N) + b s (N x P t ) + b s b t (N x N) n But since – P s x P t = N and N x N = 0, this simplifies to: N’ = N + D – where D = b t (P s x N) + b s (N x P t ) = b s (N x P t ) - b t (N x P s ) = A - B
16
16GR2-00 Worked Example for a Cylinder n P has co-ordinates: n Thus: n and then x (s,t) = r cos (s) y (s,t) = r sin (s) z (s,t) = t P s : x s (s,t) = -r sin (s) y s (s,t) = r cos (s) z s (s,t) = 0 P t : x t (s,t) = 0 y t (s,t) = 0 z t (s,t) = 1 N = P s x P t :Nx = r cos (s) Ny = r sin (s) Nz = 0
17
17GR2-00 Worked Example for a Cylinder n Then: D = b t (P s x N) + b s (N x P t ) becomes: n and perturbed normal N’ = N + D is: D : b t *0 + b s *r sin (s)= b s *r sin (s) b t *0 - b s *r cos (s)= - b s *r cos (s) b t *(-r 2 ) + b s *0= - b t *(r 2 ) N’ :r cos (s) + b s *r sin (s) r sin (s) - b s *r cos (s) -b t *r 2
18
18GR2-00 Bump Mapping A Bump Map
19
19GR2-00 Bump Mapping Resulting Image
20
20GR2-00 Bump Mapping - Another Example
21
21GR2-00 Bump Mapping Another Example
22
22GR2-00 Bump Mapping Procedurally Defined Bump Map
23
23GR2-00 Environment Mapping n This is another famous piece of trickery in computer graphics n Look at a highly reflective surface – what do you see? – does the Phong reflection model predict this? n Phong reflection is a local illumination model – does not convey inter-object reflection – global illumination methods such as ray tracing and radiosity provide this n.. but can we cheat?
24
24GR2-00 Environment Mapping - Recipe n Place a large cube around the scene with a camera at the centre environment map n Project six camera views onto faces of cube - known as an environment map camera projection of scene on face of cube - environment map
25
25GR2-00 Environment Mapping - Rendering n When rendering a shiny object, calculate the reflected viewing direction (called R earlier) n This points to a colour on the surrounding cube which we can use as a texture when rendering eye point environment map
26
26GR2-00 Environment Mapping - Limitations n Obviously this gives far from perfect results - but it is much quicker than the true global illumination methods (ray tracing and radiosity) n It can be improved by multiple environment maps (why?) - one per key object reflection mapping n Also known as reflection mapping n Can use sphere rather than cube
27
27GR2-00 Environment Mapping
28
28GR2-00 Environment Mapping
29
29GR2-00 Jim Blinn n Both bump mapping and environment mapping concepts are due to Jim Blinn n Pioneer figure in computer graphics www.research.microsoft.com/~blinn www.siggraph.org/s98/conference/ keynote/slides.html
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.