Cs 497 computer graphics
Download
1 / 8

CS 497: Computer Graphics - PowerPoint PPT Presentation


  • 105 Views
  • Uploaded on

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.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about ' CS 497: Computer Graphics' - corbin


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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

Texture mapping
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 mapping1
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


Texture mapping2
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.


Texture mapping3
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.


Texture mapping4
Texture Mapping

Here is how the mapping looks:

Polygon

(0,Vmax)

(Umax,0)

Tex3

Tex2

(0,0)

Texture Map

Tex1


Texture mapping5
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.


Texture mapping6
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).


ad