Presentation is loading. Please wait.

Presentation is loading. Please wait.

3D Computer Graphics: Textures. Textures: texels Texture is a way of assigning a diffuse color to a pixel – can be with 1, 2 or 3D- can use maps, interpolation.

Similar presentations


Presentation on theme: "3D Computer Graphics: Textures. Textures: texels Texture is a way of assigning a diffuse color to a pixel – can be with 1, 2 or 3D- can use maps, interpolation."— Presentation transcript:

1 3D Computer Graphics: Textures

2 Textures: texels Texture is a way of assigning a diffuse color to a pixel – can be with 1, 2 or 3D- can use maps, interpolation or images- we’ll consider mostly 2D- when using images it is generally safer to have the dimensions (including any border) powers of 2 Texel is a texture element: individual colors in a position (u,v) Pixels need to be mapped to texels: not always 1-1: magnification or minification – can have some interpolation- also problems with specular component Can think of a 3D texture as being carved in wood or marble

3 Texture: mapping Textures get mapped via vertices (can think of the texture as sewn onto polygons) What happens when the polygon and the texture are different sizes or even different shapes?

4 Exercise in mapping Take an 8x8 texture that is 4 squares (a checkerboard) Consider mapping the texture onto the 4 corners of the square; a triangle; a rectangle What happens if the square you are mapping is 16X16, 9X9

5 Texture tiling Instead of stretching or shrinking a texture onto a polygon, it can be repeated with tiling. In that case a pixel is mapped directly to a texel (can also be more complicated). If you run out, only part of the texture is shown, if you have more pixels than texels, then it repeats (in either or both directions) When you do tiling you probably want the texture to make sense when it repeats; also beware of tiling random-like textures such as bark because they can produce unwanted patterns Try tiling the checkerboard onto a 16x16; and onto a 20x20; onto a 5x16

6 Bump Mapping What to do about the specular highlights? What to do about the look of wallpaper painted on a plane? The highlights are those of the plane polygon and don’t reflect the content in the texture One could put in many more polygons but a (clever) solution is to alter the normals. Then the lighting and highlights will make it seem as if the polygon has “bumps” or “wrinkles” in it. This must be done with an explicit map on the texture that produces a new (bumped) normal and hence a new (bumped) reflective vector; this can also be done by introducing turbulence or noise into the normals (see next section)

7 Environment Mapping It is sometimes desirable to see the surrounding environment reflected off an object; for example, a room might be reflected off the surface of a glass; we can think of the glass an encased in a bubble that is the room or encased by another object; the encasing object is centered at the same place as the reflecting object The mapping will take a viewing direction, which will then give a reflecting direction and then return the color of the proper pixel from the background

8 Environment Mapping (con’t) Sometimes this is accomplished by mapping a sphere onto the surface (a bubble surrounding the object); there can be distortion at the north and south poles Often a cube, with 6 sides is used: the cube is set up perhaps by taking pictures at 90 degree angles (front, right, back, left) and up and down and then these are put onto the 6 faces of a cube; each face is a square texture; those faces are the projection planes; the viewing direction gives a reflecting direction and its largest absolute value and its sign determines which of the 6 planes is being used

9 Functional Texture Mappings Texture may also be produced through functions For example, draw the following functional texture which will be 16x16: for y in range(16): for x in range(16): if sin  x)/4>0: tex[x][y]=(0,0,255) else: tex[x][y]=(0,255,0)

10 Functional Texture Mappings (con’t) There are any other kinds of functions Famous function by Perlin to produce noise Others build on that to produce turbulence, marbling effect, bark, clouds, etc. Look at some of the functions: use some randomness, but want the function to be re- producible; combinations of the cosine function

11 Problem of Aliasing Go back to our 8x8 texture. We talked about the problem of too many pixels and thus having to map to parts of texels; now consider the problem of a very small polygon that doesn’t have as many pixels as there are texels: what happens now? Notice that this can happen as objects get far away and perspective is used. Consider mapping a 4x4 polygon to the 8x8 texture; or a 3x3 polygon to the 8x8 texture. We are not going to get squares: some of them will be larger; or what happens with a 2x2 polygon or even a 1x1 Consider the general problem of aliasing

12 Antialiasing One solution is to do some sort of weighted averaging: could be 4 nearest pixels (2x2 array) or 9 nearest (3x3) (called supersampling): the weights are stronger in the middle- all powers of 2; inverse mapping can also use a sort of averaging (or integration) to look at the surrounding area In more general settings often see an averaging to blur jagged lines


Download ppt "3D Computer Graphics: Textures. Textures: texels Texture is a way of assigning a diffuse color to a pixel – can be with 1, 2 or 3D- can use maps, interpolation."

Similar presentations


Ads by Google