Presentation is loading. Please wait.

Presentation is loading. Please wait.

UW EXTENSION CERTIFICATE PROGRAM IN GAME DEVELOPMENT 2 ND QUARTER: ADVANCED GRAPHICS Textures.

Similar presentations


Presentation on theme: "UW EXTENSION CERTIFICATE PROGRAM IN GAME DEVELOPMENT 2 ND QUARTER: ADVANCED GRAPHICS Textures."— Presentation transcript:

1 UW EXTENSION CERTIFICATE PROGRAM IN GAME DEVELOPMENT 2 ND QUARTER: ADVANCED GRAPHICS Textures

2 Goals 1. Understand how textures are laid out and used 2. See the finer points of texturing

3 Lookup tables  That’s what textures are, pure and simple  They are used to add fine detail to what we render  Many purposes, including:  Albedo maps – diffuse light coefficients  Gloss maps – specular light coefficients  Normal maps – normal vectors used for lighting  Transparency maps – alpha values for transparency  Height maps – detailed surface geometry (engravings)  Emissive maps – colors added after lighting  Lightmaps – precomputed light values  Normalization cubemaps – to avoid the math

4 Texture addressing modes [D3DTEXTUREADDRESS]  Coordinates in a texture go from (0,0) to (1,1)  What happens with coordinates out of range?  Depends on the addressing mode  Addressing modes (0 <= X < 1)  (Y is calculated similarly)  Clamp: X’ = max(0, min(1, X))  Wrap: X’ = frac(X)  Mirror: X’ = 1 – 2*abs(frac(X/2) – 0.5)  Border: if X is outside [0,1] then color = border

5 Texture filtering modes [D3DTEXTUREFILTERTYPE]  A texture is composed of discrete pixels  Representing samples within the image  What if coordinates not precisely on the samples?  Depends on the filtering mode  Filtering modes (0 <= X < width)  Point: Fetch(round(X))  Linear: lerp(Fetch(floor(X)), Fetch(floor(X)+1), frac(X))  Anisotropic: Complex filter (slower but higher quality) 012X floor(X)floor(X)+1 round(X)

6 Texture mipmapping  Large textures, when smaller on screen, look bad  Features appear and disappear as the image moves  This effect is called aliasing  It’s caused by interference of two samples Texture pixels (texels) and screen pixels  Must filter the texture  Using mipmaps: smaller versions of the texture  Mipmap selection is like a third texture coordinate  Addressing mode is always clamp  Filtering mode can be point or linear

7 Texture type  Regular 2D textures  2D array of colors, use two coordinates normally  Volume textures  3D array of colors, use three coordinates normally  Arranged in memory as an array of images (slices)  Cube textures  6 textures arranged as the faces of a cube  Three coordinates, vector from center of cube to texel  Other types  1D, arrays of textures

8 Texture format [D3DFORMAT]  Integer vs. floating-point values  Signed vs. unsigned values  Bits per component (4, 8, 16 and other sizes too)  Alpha vs. no-alpha (defaults to 1)  Compression (like normals and lossy codecs)  Palettes (extra lookup indirection)  UYVY (2 components at lower resolution)  Gamma (D3DSAMP_SRGBTEXTURE)

9 Texture coordinates  Either in the vertices or auto-generated  Sometimes, in the vertices are also generated  For instance, for unique mappings  Coordinate wrapping  Mapping a texture around the model  Coordinates from 0 to 1: what to do when they meet?  Coordinate transformations  Same as world positions Matrix applied Projection (division by W), too, is useful for shadow buffers


Download ppt "UW EXTENSION CERTIFICATE PROGRAM IN GAME DEVELOPMENT 2 ND QUARTER: ADVANCED GRAPHICS Textures."

Similar presentations


Ads by Google