1 / 8

CS 497: Computer Graphics

CS 497: Computer Graphics. James Money. Texture Mapping. Texture Mapping is method of providing surface detail on a polygon, with relative little cost to the graphics system. It provide a way to map an image onto surface as shown:. Texture Mapping.

corbin
Télécharger la présentation

CS 497: Computer Graphics

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CS 497: Computer Graphics James Money

  2. Texture Mapping Texture Mapping is method of providing surface detail on a polygon, with relative little cost to the graphics system. It provide a way to map an image onto surface as shown:

  3. Texture Mapping Texture mapping for general surfaces is not easy. It involves mapping the (x,y) of a pixel of a object to same point on the texture map, but in a (u,v) coordinate system. For polygons, we can map the square image to the polygon’s bounding rectangle: Bounding Rectangle

  4. Texture Mapping We can also allow for repeating images on a large polygon by specifying how large the texture map is in (Umax,Vmax) and repeating from 0 after (Umax,Vmax) is reached.

  5. Texture Mapping We can add support for texture mapping in our polygon data structure by: • Add an entry for a image pointer to UmaxxVmax pixels. • The value of Umax and Vmax for this image. • Specify what the (0,0), (Umax,0), and (0,Vmax) corners of the image map to on the polygon. I.E., give me three points bounding the image named tex1,tex2, and tex3.

  6. Texture Mapping Here is how the mapping looks: Polygon (0,Vmax) (Umax,0) Tex3 Tex2 (0,0) Texture Map Tex1

  7. Texture Mapping We can add support for texture mapping in our fill routine by: • Project the 3 image points into 2D like a vertex of the polygon, except do not clip. • Set the number of pixels in Uscale to distance from tex2(in 2d) to tex1(in 2d) and divide Umax-Umin. • Set the number of pixels in Vscale to distance from tex3(in 2d) to tex1(in 2d) and divide by Vmax-Vmin.

  8. Texture Mapping • Set texture position(in floating point) to 0,0. • For each pixel draw: • If Uscale or Vscale >1 average the points contained in Rect(texture.x, texture.y, texture.x+Uscale, texture.y+Vscale) for the pixel value. Otherwise, get the pixel at (texture.x, texture.y). • Set texture position to (texture.x+Uscale*deltaX,texture.y+Vscale*deltaY); • If texture.x>Umax set texture.x=0. Same if true for Y.(Even better if you set texture.x-=Umax and wrap around for averaging pixel values above).

More Related