

































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


































The actual texture mapping computations take place atthe scan conversion and pixel rendering stages of thegraphics pipeline ^
During scan conversion, as we are looping through thepixels of a triangle, we must interpolate the
tx
t y
texture
coordinates in a similar way to how we interpolate the rgb
color and
z
depth values
^
As with all other interpolated values, we mustprecompute the slopes of each coordinate as they varyacross the image pixels in
x
and
y
^
Once we have the interpolated texture coordinate, welook up that pixel in the texture map and use it to colorthe pixel
The scan conversion process usually uses linear interpolation to interpolatevalues across the triangle (colors, z, etc.) ^
If we use linear interpolation to interpolate the texture coordinates, we mayrun into inaccuracies ^
This is because a straight line of
regularly
spaced points in 3D space maps
to a straight line of
irregularly
spaced points in device space (if we are using
a perspective transformation) ^
The result is that the texture maps exactly onto the triangle at the vertices,but may warp and stretch within the triangle as the viewing angle changes ^
This is known as
texture swimming
and can be quite distracting on large
triangles ^
To fix the problem, we must perform a perspective correct interpolation, or hyperbolic
interpolation
^
This requires interpolating the w coordinate across the triangle andperforming a perspective division for each pixel ^
See page 121 & 128 in the book for more info
Let’s consider the scan conversion process once again and look at how thepixel rendering process fits in ^
Remember that in scan conversion of a triangle, we loop from the top rowdown to the bottom row in y, and then loop from left to right in x for eachrow ^
As we are looping over these pixels, we are incrementing variousinterpolated values (such as
z
,^ r
,^ g
,^ b
,^ t
, and x
ty
^
Each of these increments requires only 1 addition per pixel, but perspectivecorrection requires 1 an additional divide per pixel and 1 additional multiplyper pixel for each perspective corrected value ^
Before actually writing the pixel, we compare the interpolated
z
value with
the value written into the zbuffer, stored per pixel. If it is further than theexisting z value, we don’t render the pixel and proceed to the next one. If itis closer, we finish rendering the pixel by writing the final color into theframebuffer and the new z value into the zbuffer ^
If we are doing expensive per-pixel operations (such as Phong interpolation& per-pixel lighting), we can postpone them until after we are sure that thepixel passes the zbuffer comparison. If we are doing a lot of expensive per-pixel rendering, it is therefore faster if we can render closer objects first
Let’s take a closer look at texture space ^
It’s not quite like the normalized image space or devicespaces we’ve seen so far ^
The image itself ranges from 0.0 to 1.0, independent ofthe actual pixel resolution ^
It allows tiling of values <0 and > ^
The individual pixels of the texture are called
texels
^
Each texel maps to a uniform sized box in texture space.For example, a 4x4 texture would have pixel centers at1/8, 3/8, 5/8, and 7/
^
Point sampling ^
Bilinear sampling ^
Bicubic sampling
Minification
is the opposite of magnification and refers to how we handle the
texture when we view it from far away ^
Ideally, we would see textures from such a distance as to cause each texelto map to roughly one pixel ^
If this were the case, we would never have to worry about magnification andminification ^
However, this is not a realistic case, as we usually have cameras movingthroughout an environment constantly getting nearer and farther fromdifferent objects ^
When we view a texture from too close, a single texel maps to many pixels.There are several popular magnification rules to address this ^
When we are far away, a many texels may map to a single pixel.Minification addresses this issue ^
Also, when we view flat surfaces from a more edge on point of view, we getsituations where texels map to pixels in a very stretched way. This case isoften handled in a similar way to minification, but there are otheralternatives
^
^
^
^
^
^