cse 410 computer graphics sessional
DESCRIPTION
CSE 410 Computer Graphics Sessional. Virtual Realism TEXTURE MAPPING. The Quest for Visual Realism. Why Texture Map?. So far we have done flat shading and Gouraud / Phong shading Not good to represent everything in real world What are some of our other options? - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: CSE 410 Computer Graphics Sessional](https://reader035.vdocuments.us/reader035/viewer/2022062422/56813b9d550346895da4d2c9/html5/thumbnails/1.jpg)
CSE 410 Computer Graphics Sessional
Virtual Realism
TEXTURE MAPPING
![Page 2: CSE 410 Computer Graphics Sessional](https://reader035.vdocuments.us/reader035/viewer/2022062422/56813b9d550346895da4d2c9/html5/thumbnails/2.jpg)
The Quest for Visual Realism
![Page 3: CSE 410 Computer Graphics Sessional](https://reader035.vdocuments.us/reader035/viewer/2022062422/56813b9d550346895da4d2c9/html5/thumbnails/3.jpg)
Why Texture Map?
So far we have done flat shading and Gouraud/Phong shadingNot good to represent everything in real world
What are some of our other options?Represent everything with tiny polygons
Geometry would get complicated very quickly
Apply textures across the polygonsThis allows for less geometry but the image
looks almost as good
![Page 4: CSE 410 Computer Graphics Sessional](https://reader035.vdocuments.us/reader035/viewer/2022062422/56813b9d550346895da4d2c9/html5/thumbnails/4.jpg)
Basic Concept
Textures are almost always rectangular array of pixels called texels (texture elements)
• Pasting an image onto a model• An image is mapped onto the 2D domain of a 3D model
![Page 5: CSE 410 Computer Graphics Sessional](https://reader035.vdocuments.us/reader035/viewer/2022062422/56813b9d550346895da4d2c9/html5/thumbnails/5.jpg)
Texture Coordinates
A texture is usually addressed by two numbers (s, t)s and t takes values in [0,1]
A vertex can be associated with a point on the texture by giving it one of these texture coordinatesglTexCoord*(s,t);glVertex*(x,y,z);
s
t
[0,0] [1, 0]
[0, 1]
![Page 6: CSE 410 Computer Graphics Sessional](https://reader035.vdocuments.us/reader035/viewer/2022062422/56813b9d550346895da4d2c9/html5/thumbnails/6.jpg)
Example Texture Map
![Page 7: CSE 410 Computer Graphics Sessional](https://reader035.vdocuments.us/reader035/viewer/2022062422/56813b9d550346895da4d2c9/html5/thumbnails/7.jpg)
Types of TexturesBitmap textures
Bitmapped representation of imagesRepresented by an array
Color3 texture(float s, float t){ Return txtr[(int)(s*c),(int)(t*r)]
}
Procedural texturesDefined by a mathematical function
In either case, we have a ‘texture function’texture(s,t)
![Page 8: CSE 410 Computer Graphics Sessional](https://reader035.vdocuments.us/reader035/viewer/2022062422/56813b9d550346895da4d2c9/html5/thumbnails/8.jpg)
Texture Mapping Problem
Texture space World space Screen space
(sx,sy)=Tws(Ttw (s*,t*))
![Page 9: CSE 410 Computer Graphics Sessional](https://reader035.vdocuments.us/reader035/viewer/2022062422/56813b9d550346895da4d2c9/html5/thumbnails/9.jpg)
Mapping Textures on Flat Surfaces
• Associate points on texture with points on the polygonal face– OpenGL uses the function glTexCoord*()
• sets the current texture coordinates
![Page 10: CSE 410 Computer Graphics Sessional](https://reader035.vdocuments.us/reader035/viewer/2022062422/56813b9d550346895da4d2c9/html5/thumbnails/10.jpg)
Rendering Textures on Flat Surfaces
Similar to Gouraud shadingConsider the current scan line ys
For each xs, compute the correct position P on the face
From that, obtain the correct texture coordinate (s,t)
xright
ys
ytop
ybott
xleft
(s0,t0)
(s3,t3)
(s1,t1)
(s2,t2)
xs
![Page 11: CSE 410 Computer Graphics Sessional](https://reader035.vdocuments.us/reader035/viewer/2022062422/56813b9d550346895da4d2c9/html5/thumbnails/11.jpg)
CaveatLinear interpolation does not work always!This is because…
Equal steps across a projected space do not corresponds to equal steps across the 3D space
![Page 12: CSE 410 Computer Graphics Sessional](https://reader035.vdocuments.us/reader035/viewer/2022062422/56813b9d550346895da4d2c9/html5/thumbnails/12.jpg)
Visualizing the Problem
Notice that uniform steps on the image plane do not correspond to uniform steps along the edge.
![Page 13: CSE 410 Computer Graphics Sessional](https://reader035.vdocuments.us/reader035/viewer/2022062422/56813b9d550346895da4d2c9/html5/thumbnails/13.jpg)
An Example
![Page 14: CSE 410 Computer Graphics Sessional](https://reader035.vdocuments.us/reader035/viewer/2022062422/56813b9d550346895da4d2c9/html5/thumbnails/14.jpg)
Proper Interpolation
If we move in equal steps across Ls on the screen, how should we step across texels along Lt in texture space?
Texture space Eye space Screen space
![Page 15: CSE 410 Computer Graphics Sessional](https://reader035.vdocuments.us/reader035/viewer/2022062422/56813b9d550346895da4d2c9/html5/thumbnails/15.jpg)
Proper InterpolationR(g) = lerp(A,B,g) r(f)=lerp(a,b,f), a = (a1, a2, a3, a4) or ( a1/a4, a2/a4, a3/a4)r1(f) = lerp(a1/a4, b1/b4, f)
A
B
R(g)M a
br(f)
• R(g) = lerp(A,B,g) • In homogenous coordinate [R(g),1]t
• = [lerp(A,B,g),1]t
• After perspective transformation M([lerp(A,B,g),1]t)• = lerp( M(A,1)t , M(B,1)t , g )• =[ lerp( a1, b1, g ) , lerp( a2, b2, g) , lerp(a3, b3, g) , lerp( a4, b4, g) ]• r1(f ) = lerp(a1,b1,g)/lerp(a4,b4,g)
![Page 16: CSE 410 Computer Graphics Sessional](https://reader035.vdocuments.us/reader035/viewer/2022062422/56813b9d550346895da4d2c9/html5/thumbnails/16.jpg)
Proper Interpolationr1(f) = lerp(a1/a4, b1/b4, f)r1(f ) = lerp(a1,b1,g)/lerp(a4,b4,g)
g = f / lerp((b4/a4), 1, f)
R(g) = A(1-g) + Bg= lerp(A1/a4, B1/b4, f) / lerp( 1/a4, 1/b4, f)
![Page 17: CSE 410 Computer Graphics Sessional](https://reader035.vdocuments.us/reader035/viewer/2022062422/56813b9d550346895da4d2c9/html5/thumbnails/17.jpg)
Proper Interpolation
a cooresponds to A which maps to texture (Sa, Ta)b corresponds to B which maps to texture ( Sb, Tb)
left = lerp(a,b,f)sleft(y) =lerp(SA/a4, SB/b4, f) / lerp( 1/a4, 1/b4, f)
Similar for tleft(y) and right pixelSimilar hyperbolic interpolation for intermediate pixels
a
b
a’
b’
yleft
right
![Page 18: CSE 410 Computer Graphics Sessional](https://reader035.vdocuments.us/reader035/viewer/2022062422/56813b9d550346895da4d2c9/html5/thumbnails/18.jpg)
Texture Maps and Visual Realism
Three different visual effects:1. Glowing objects
– Intensity is set equal to the texture value: I = texture(s,t)– Object appears to emit light or glow– Color can be added by considering the red, green and
blue components separately
2. Modulate reflection coefficients– Make texture appear to be painted on the surface– Change the reflection coefficients at each point by:
3. Bump mapping– Model the roughness of the surface
fsspddaa phongIlambertIItsI )(,texture
![Page 19: CSE 410 Computer Graphics Sessional](https://reader035.vdocuments.us/reader035/viewer/2022062422/56813b9d550346895da4d2c9/html5/thumbnails/19.jpg)
Bump Mapping
![Page 20: CSE 410 Computer Graphics Sessional](https://reader035.vdocuments.us/reader035/viewer/2022062422/56813b9d550346895da4d2c9/html5/thumbnails/20.jpg)
Bump Mapping Use texture map to perturb surface normal
Use texture array to set a function which perturbs surface normal Apply illumination model using perturbed normal
![Page 21: CSE 410 Computer Graphics Sessional](https://reader035.vdocuments.us/reader035/viewer/2022062422/56813b9d550346895da4d2c9/html5/thumbnails/21.jpg)
Bump Mapping
vuvuvuPvuP ,m,texture,, • The ‘perturbed’ surface becomes:
• One approximation to new normal m´(u,v) is:
vuvuvu ,d,m,m
where d is: vuuv PPvu texturemtexturem,d
![Page 22: CSE 410 Computer Graphics Sessional](https://reader035.vdocuments.us/reader035/viewer/2022062422/56813b9d550346895da4d2c9/html5/thumbnails/22.jpg)
Bump Mapping
vuvuvuPvuP ,m,texture,,
• The ‘perturbed’ surface becomes:
• To find the new normal m´(u,v)– Find two vectors tangent to the bumpy surface, then m´(u,v) is their
cross product– The two vectors follow from the partial derivatives of the P´(u,v)
equation wrt u,v
![Page 23: CSE 410 Computer Graphics Sessional](https://reader035.vdocuments.us/reader035/viewer/2022062422/56813b9d550346895da4d2c9/html5/thumbnails/23.jpg)
Wrapping Texture on Curved SurfacesWrap a label around a cylinder
• Wrap a label onto a sphere
![Page 24: CSE 410 Computer Graphics Sessional](https://reader035.vdocuments.us/reader035/viewer/2022062422/56813b9d550346895da4d2c9/html5/thumbnails/24.jpg)
References
Hill 8.5.1 – 8.5.3, 8.5.5