DOC PREVIEW
UCSD CSE 167 - Texture Mapping

This preview shows page 1-2-3-19-20-39-40-41 out of 41 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 41 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 41 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 41 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 41 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 41 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 41 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 41 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 41 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 41 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Texture MappingSlide 2Texture MapTexture CoordinatesSlide 5Vertex ClassTexture InterpolationPerspective CorrectionPixel RenderingSlide 10TilingSlide 12ClampingMirroringCombinationsTexture SpaceMagnificationSlide 18MinificationSlide 20Slide 21MipmappingSlide 23Mipmapping LimitationsAnisotropic MipmappingEliptical Weighted AveragingAntialiasingBasic Texture MappingTexture Coordinate AssignmentOrthographic MappingPerspective MappingSpherical MappingCylindrical MappingSkin MappingsEnvironment MappingSlide 36Cube MappingSolid TexturesTexture CombiningBump MappingDisplacement MappingTexture MappingCSE167: Computer GraphicsInstructor: Steve RotenbergUCSD, Fall 2005Texture MappingTexture mapping is the process of mapping an image onto a triangle in order to increase the detail of the renderingThis allows us to get fine scale details without resorting to rendering tons of tiny trianglesThe image that gets mapped onto the triangle is called a texture map or texture and is usually a regular color imageTexture MapWe define our texture map as existing in texture space, which is a normal 2D spaceThe lower left corner of the image is the coordinate (0,0) and the upper right of the image is the coordinate (1,1)The actual texture map might be 512 x 256 pixels for example, with a 24 bit color stored per pixelTexture CoordinatesTo render a textured triangle, we must start by assigning a texture coordinate to each vertexA texture coordinate is a 2D point [tx ty] in texture space that is the coordinate of the image that will get mapped to a particular vertexTexture Mappingv0v1v2t2t0t1(1,1)(0,0)xyTexture Space Triangle (in any space)Vertex ClassWe can extend our concept of a Model to include texture coordinatesWe can do this by simply extending the Vertex class:class Vertex {Vector3 Position;Vector3 Color;Vector3 Normal;Vector2 TexCoord;public:void Draw() {glColor3f(Color.x, Color.y, Color.z);glNormal3f(Normal.x, Normal.y, Normal.z);glTexCoord2f(TexCoord.x, TexCoord.y);glVertex3f(Position.x, Position.y, Position.z); // This has to be last}};Texture InterpolationThe actual texture mapping computations take place at the scan conversion and pixel rendering stages of the graphics pipelineDuring scan conversion, as we are looping through the pixels of a triangle, we must interpolate the txty texture coordinates in a similar way to how we interpolate the rgb color and z depth valuesAs with all other interpolated values, we must precompute the slopes of each coordinate as they vary across the image pixels in x and yOnce we have the interpolated texture coordinate, we look up that pixel in the texture map and use it to color the pixelPerspective CorrectionThe scan conversion process usually uses linear interpolation to interpolate values across the triangle (colors, z, etc.)If we use linear interpolation to interpolate the texture coordinates, we may run 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 and performing a perspective division for each pixelSee page 121 & 128 in the book for more infoPixel RenderingUsually, we want to combine texture mapping with lightingLet’s assume that we are doing vertex lighting and using Gouraud shading to interpolate the lit colors across the triangleAs we render each pixel, we compute the interpolated light color and multiply it by the texture color to get our final pixel colorOften, when we are using texture maps, we don’t need to use vertex colors, and so they are implicitly set to (1,1,1)The texture map itself usually defines the material color of the object, and it is allowed to vary per pixel instead of only per vertexPixel RenderingLet’s consider the scan conversion process once again and look at how the pixel rendering process fits inRemember that in scan conversion of a triangle, we loop from the top row down to the bottom row in y, and then loop from left to right in x for each rowAs we are looping over these pixels, we are incrementing various interpolated values (such as z, r, g, b, tx, and ty)Each of these increments requires only 1 addition per pixel, but perspective correction requires 1 an additional divide per pixel and 1 additional multiply per 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 the existing z value, we don’t render the pixel and proceed to the next one. If it is closer, we finish rendering the pixel by writing the final color into the framebuffer 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 the pixel 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 firstTilingThe image exists from (0,0) to (1,1) in texture space, but that doesn’t mean that texture coordinates have to be limited to that rangeWe can define various tiling or wrapping rules to determine what happens when we go outside of the 0…1 rangeTilingxyTexture Space(0,0)(1,1)ClampingxyTexture Space(0,0)(1,1)MirroringxyTexture Space(0,0)(1,1)CombinationsOne can usually set the tiling modes independently in x and ySome systems support independent tiling modes in x+, x-, y+, and y-Texture SpaceLet’s take a closer look at texture spaceIt’s not quite like the normalized image space or device spaces we’ve seen so farThe image itself ranges from 0.0 to 1.0, independent of the actual pixel resolutionIt allows tiling of values <0 and >1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 at 1/8, 3/8, 5/8, and


View Full Document

UCSD CSE 167 - Texture Mapping

Documents in this Course
Lighting

Lighting

38 pages

Review

Review

59 pages

Surfaces

Surfaces

22 pages

Review

Review

110 pages

Midterm

Midterm

4 pages

Lighting

Lighting

38 pages

Lighting

Lighting

71 pages

Review

Review

110 pages

Lighting

Lighting

71 pages

Load more
Download Texture Mapping
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Texture Mapping and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Texture Mapping 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?