Presentation is loading. Please wait.

Presentation is loading. Please wait.

Graphics Graphics Korea University 1 Jang Sumi 2002.1.29 Texture Mapping Environment Mapping Stencil Buffer.

Similar presentations


Presentation on theme: "Graphics Graphics Korea University 1 Jang Sumi 2002.1.29 Texture Mapping Environment Mapping Stencil Buffer."— Presentation transcript:

1 Graphics Graphics Lab @ Korea University 1 Jang Sumi 2002.1.29 Texture Mapping Environment Mapping Stencil Buffer

2 CGVR Graphics Lab @ Korea University 2 1. Texture Mapping Mip-Mapping 2. Environment Mapping 3. Stencil Buffer 4. Demonstration Contents

3 CGVR Graphics Lab @ Korea University 3 Basic Texturing Concepts Texture Addressing Modes Wrap, Mirror, Clamp, Border Color Texture coordinates Texture Filtering 1. Texture Mapping

4 CGVR Graphics Lab @ Korea University 4 Basic Texturing Concepts Textures In real World  object's smoothness or roughness Computer Graphics  a bitmap of pixel colors that give an object the appearance of texture  creating realism in computer-generated 3-D images

5 CGVR Graphics Lab @ Korea University 5 Basic Texturing Concepts Textures 2D texture 3D texture

6 CGVR Graphics Lab @ Korea University 6 Addressing Modes (Warp) Wrap Texture Address Mode repeat the texture on every integer junction (default mode)

7 CGVR Graphics Lab @ Korea University 7 Addressing Modes (Warp) CF. Texture Wrap A texture wrapA flat wrapA cylindrical wrapA spherical wrap (cutaway view)

8 CGVR Graphics Lab @ Korea University 8 Addressing Modes (Mirror) Mirror Texture Address Mode mirror the texture at every integer boundary

9 CGVR Graphics Lab @ Korea University 9 Addressing Modes (Clamp) Clamp Texture Address Mode apply the texture once, then smear the color of edge pixels

10 CGVR Graphics Lab @ Korea University 10 Addressing Modes (Border Color) Border Color Texture Address Mode use an arbitrary color (=border color) for any texture coordinates outside the range of 0.0 through 1.0, inclusive

11 CGVR Graphics Lab @ Korea University 11 Addressing Modes (source code) IDirect3DDevice8::SetTextureStageState() Parameters  1 st : specify the desired texture stage identifier  2 nd : update the u-, v-, or w-addressing modes individually.  3 rd : determine which mode is being set. typedef enum _D3DTEXTUREADDRESS { D3DTADDRESS_WRAP= 1, D3DTADDRESS_MIRROR= 2, D3DTADDRESS_CLAM= 3, D3DTADDRESS_BORDER= 4, D3DTADDRESS_MIRRORONCE = 5, D3DTADDRESS_FORCE_DWORD= 0x7fffffff } D3DTEXTUREADDRESS;

12 CGVR Graphics Lab @ Korea University 12 Texture Filtering Purpose Magnify or minify a texture When a texture is being mapped onto a primitive image that is larger or smaller than itself

13 CGVR Graphics Lab @ Korea University 13 Texture Filtering Nearest Point Sampling A simple texture-mapping technique that places texels on a textured object. Performance  If similar sizes  fast and efficient  If not  chunky, aliased, or blurred result chunky

14 CGVR Graphics Lab @ Korea University 14 Texture Filtering Linear Texture Filtering Computes a weighted average of the texels (above, below, left, right of the nearest sample point)  +: shows better result than Nearest Point Sampling  -: edges or a chunky result Pixel center Nearest Point SamplingLinear Texture Filtering

15 CGVR Graphics Lab @ Korea University 15 Texture Filtering Anisotropic Texture Filtering

16 CGVR Graphics Lab @ Korea University 16 Texture Filtering (Mip-Map) Texture Filtering with Mip-map Use sequence of textures Performance  +: High quality  -: Memory overhead

17 CGVR Graphics Lab @ Korea University 17 Texture Filtering (Mip-Map) Mip-Map Result (1) The ugly 'bitty' look near the top is the moiré pattern in action. Same scene rendered using mip-mapping.

18 CGVR Graphics Lab @ Korea University 18 Texture Filtering (Mip-Map) Mip-Map Result (2) This demonstrates where the different mip-map levels are used by inverting the texture colour at each level.

19 CGVR Graphics Lab @ Korea University 19 Texture Filtering (Source) Mip-Map IDirect3DTexture8 * pMipMap; d3dDevice->CreateTexture(256, 256, 5, 0, D3DFMT_R8G8B8, D3DPOOL_MANAGED, &pMipMap); d3dDevice->SetTexture(0, pMipMap); d3dDevice->SetTextureStageState(0, D3DTSS_MIPFILTER, D3DTEXF_POINT);

20 CGVR Graphics Lab @ Korea University 20 2. Environment Mapping Purpose simulates highly reflective surfaces without using ray tracing T-1000 knows all about environment mapping.

21 CGVR Graphics Lab @ Korea University 21 2. Environment Mapping Cubic Environment Mapping  textures that contain image data representing the scene surrounding an object  as if the object were in the center of a cube.

22 CGVR Graphics Lab @ Korea University 22 Cubic Env. Mapping Cubic Environment Mapping (1) textures that contain image data representing the scene surrounding an object as if the object were in the center of a cube.

23 CGVR Graphics Lab @ Korea University 23 Cubic Env. Mapping Cubic Environment Mapping (2)

24 CGVR Graphics Lab @ Korea University 24 Cubic Env. Mapping Mipmapped Cubic Environment Maps  IDirect3DCubeTexture8::GetCubeMapSurface

25 CGVR Graphics Lab @ Korea University 25 Cubic Env. Mapping Texture Coordinates for Cubic Environment Maps Fomula: if D3DRS_LOCALVIEWER is TRUE else R is the reflection vector being computed E is the normalized Position -to-eye vector N is the camera-space vertex normal N Z is the world space reflection vector from either formula

26 CGVR Graphics Lab @ Korea University 26 Cubic Env. Mapping DWORD dwFVF= D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVFTEX1 | D3DFVF_TEXCOORDSIZE3(0); m_d3dDevice->SetTextureStageState ( 2, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR | 1);

27 CGVR Graphics Lab @ Korea University 27 Cubic Env. Mapping Creating Cubic Environment Map Surfaces IDirect3DDevice8::CreateCubeTexture LPDIRECT3DCUBETEXTURE8 m_pCubeMap; m_d3dDevice->CreateCubeTexture( 256, 1, D3DUSAGE_RENDERTARGET, D3DFMT_R8G8B8, D3DPOOL_DEFAULT, &m_pCubeMap );

28 CGVR Graphics Lab @ Korea University 28 Cubic Env. Mapping Accessing Cubic Environment Map Faces IDirect3DCubeTexture8::GetCubeMapSurface LPDIRECT3DSURFACE8 pFace2; m_pCubeMap->GetCubeMapSurface( D3DCUBEMAP_FACE_POSITIVE_Y, 0, &pFace2);

29 CGVR Graphics Lab @ Korea University 29 Spherical Environment Mapping 2-D representation of the full 360-degree view of the scene surrounding of an object as if taken through a fish-eye lens

30 CGVR Graphics Lab @ Korea University 30 Spherical Environment Mapping Texture Coordinates for Spherical Environment Maps Formula u and v are the texture coordinates being computed Nx and Ny are the x and y components of the camera-space vertex normal.

31 CGVR Graphics Lab @ Korea University 31 Spherical Environment Mapping Applying Spherical Environment Maps  IDirect3DDevice8::SetTexture  IDirect3DTexture8

32 CGVR Graphics Lab @ Korea University 32 3. Stencil Buffer Purpose mask pixels in an image The mask controls whether the pixel is drawn. This helps to reduce the workload and increases performance.

33 CGVR Graphics Lab @ Korea University 33 Dissolve one image is gradually replaced by another Fade (in/out) Dissolve from/to a black or white image to a scene A special case of dissolving Swipe series of stencil masks 3. Stencil Buffer

34 CGVR Graphics Lab @ Korea University 34 3. Stencil Buffer Decaling control which pixels from a particular primitive image are drawn to the rendering target surface Compositing occlude an area of the rendering target surface Write some other texture to the occluded area Outline mask same shape but slightly smaller Silhouette stencil mask is the same size and shape as the primitive

35 CGVR Graphics Lab @ Korea University 35 3. Stencil Buffer How the Stencil Buffer Works 1. Stencil ReferenceAND Stencil Mask 2. Stencil Buffer ValueAND Stencil Mask 3. Compare the result of step 1 to the result of step 2, using the comparison function.  (StencilRef & StencilMask) CompFunc (StencilBufferValue & StencilMask)

36 CGVR Graphics Lab @ Korea University 36 3. Stencil Buffer Source Code Comparison function  typedef enum _D3DRENDERSTATETYPE { ……. D3DRS_STENCILFUNC …… }

37 CGVR Graphics Lab @ Korea University 37 3. Stencil Buffer  typedef enum _D3DCMPFUNC { D3DCMP_NEVER = 1, D3DCMP_LESS = 2, D3DCMP_EQUAL = 3, D3DCMP_LESSEQUAL = 4, D3DCMP_GREATER = 5, D3DCMP_NOTEQUAL = 6, D3DCMP_GREATEREQUAL = 7, D3DCMP_ALWAYS = 8, D3DCMP_FORCE_DWORD = 0x7fffffff } D3DCMPFUNC;

38 CGVR Graphics Lab @ Korea University 38 4. Demonstration Cube Map

39 CGVR Graphics Lab @ Korea University 39 4. Demonstration Fish Eye

40 CGVR Graphics Lab @ Korea University 40 4. Demonstration Shadow Volume (Stencil buffer)Stencil Mirror

41 CGVR Graphics Lab @ Korea University 41 4. Demonstration Stencil Depth


Download ppt "Graphics Graphics Korea University 1 Jang Sumi 2002.1.29 Texture Mapping Environment Mapping Stencil Buffer."

Similar presentations


Ads by Google