110 likes | 200 Views
Textures – Basic Principles. Lecture 29 Fri, Nov 14, 2003. Geometry vs. Detail. There is a practical limit to how much detail we can show with geometry. For example, imagine trying to create the appearance of a brick wall through geometry. Construct brick and cement rectangles.
E N D
Textures – Basic Principles Lecture 29 Fri, Nov 14, 2003
Geometry vs. Detail • There is a practical limit to how much detail we can show with geometry. • For example, imagine trying to create the appearance of a brick wall through geometry. • Construct brick and cement rectangles. • Color them dark red and light gray. • Would they look realistic?
Textures • A much more efficient method is to • Photograph an actual brick wall. • Create a single large polygon. • Paste the photograph onto the polygon. • Not only is this more efficient, but the results are superior. • These pictures are called textures, since they give “texture” to a surface.
Textures • A texture may be created externally as a bitmap file (.bmp). • It consists of a rectangular array of RGB triples (integers from 0 to 255). • Each RGB triple is called a texel.
Examples • WoodGrain.bmp. • Bricks.bmp. • TextureDemo.cpp. • RgbImage.cpp.
Textures • It is also possible to create textures internally as arrays of RGB triples. • This is especially convenient when the picture is geometrically simple. • The object would be a 3-dimensional array image[i][j][k]. • i = row number. • j = column number. • k = color (0 = red, 1 = green, 2 = blue).
Textures • It is possible to have 1-dimensional, 2-dimensional, and 3-dimensional textures, although we will work only with 2-dimensional textures. • A texture has its own (s, t) coordinate system. • s is the horizontal coordinate, 0 s 1. • t is the vertical coordinate, 0 t 1.
1 t 0 s 0 1 Texture Parameters • Each texel has (r, s) coordinates. (.5, .5) (.75, .25)
Textures • To paste a texture onto a polygon, we assign to each vertex of the polygon a pair of (s, t) coordinates. • That is, we map a portion of the texture to the polygon. • Interpolation is used to assign a texel to each pixel throughout the interior of the polygon.
Mapping Textures to Faces • When a polygon is drawn, each vertex has a point in the texture mapped to it.
Nate Robin’s Texture Tutorial • Tutors