Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS418 Computer Graphics John C. Hart

Similar presentations


Presentation on theme: "CS418 Computer Graphics John C. Hart"— Presentation transcript:

1 CS418 Computer Graphics John C. Hart
Texture Mapping CS418 Computer Graphics John C. Hart

2 Interpolation Rasterization will interpolate any vertex attribute across a polygon’s fragments Interpolating color yields Gouraud smooth shading Can also define texture coordinates (u,v) at vertices that, when interpolated, map an image onto a meshed surface 9 8 7 6 5 4 3 2 1 1 2 3 4 5 6 7 8 9

3 Texture Mapping 1 v u 1

4 Texture Mapping 1 .7 .6 v (.1,.7) (.1,.6) (.2,.6) u 1 .1 .2

5 Perspective Correction
z ytop zfront zhalf zback ybottom vfront vhalf vback In this example: y = -1, d = 1 and v = -z vback maps to ytop = -1/-zback vhalf maps to yhalf = -1/-zhalf vfront maps to ybottom = -1/-zfront So need to interpolate inverse clip verts + attrs: (x,y,z,w,u,v,1) canvas vertices and attributes: (x/w, y/w, z/w, 1/w, u/w, v/w) interpolate: (u/w, v/w, 1/w) divide per-pixel by 1/w to get interpolated (u,v) v d ycanvas = y/(-z/d) = y/w

6 Example ycanvas = y/(-z/d) = y/w u/w = 1/9 1/w = 1/9 -9 u = 1.0 -5 -3
-1 u/w = 0 1/w = 1 u = 0.0 (0,0,0) z = -1 y = -1 w = 1 u = 0 -3 -1 3 .25 -5 -1 5 .5 -7 -1 7 .75 -9 -1 9 1

7 Magnification Aliasing
“Jaggies” – lines have a staircased edge appearance Occur when a single texture sample (texels) projects to multiple screen pixels (Also occurs when rasterizing lines or polygon edges)

8 Bilinear Filtering “Jaggies” – lines have a staircased edge appearance
Occur when a single texture sample (texels) projects to multiple screen pixels (Also occurs when rasterizing lines or polygon edges) Fixed by averaging neighboring samples to find the value between samples

9 Minification Aliasing
Many texture pixels (texels) map into a single screen pixel Cannot simply add them up because some pixels would take longer than others to add

10 MIP Mapping Many texture pixels (texels) map into a single screen pixel Cannot simply add them up because some pixels would take longer than others to add Create an image pyramid from the initial texture Each level of the pyramid half the resolution of the one below it Choose the texture resolution whose projected texel size most closely matches pixel size


Download ppt "CS418 Computer Graphics John C. Hart"

Similar presentations


Ads by Google