Presentation is loading. Please wait.

Presentation is loading. Please wait.

Fall 2009 Revised1 Texture Mapping (Intermediate) Jyun-Ming Chen.

Similar presentations


Presentation on theme: "Fall 2009 Revised1 Texture Mapping (Intermediate) Jyun-Ming Chen."— Presentation transcript:

1 Fall 2009 Revised1 Texture Mapping (Intermediate) Jyun-Ming Chen

2 Fall 2009 Revised2 Texture Suite highlight bubble

3 Fall 2009 Revised3 Texture Suite warp underwater

4 Fall 2009 Revised4 Outline Dynamic sub texture image 1D and 3D textures Render to texture Environment mapping Cubemap Spheremap Bump map Light map Projective texture Q coord

5 Fall 2009 Revised5 Dynamic Texture CopyTexSubImage2D Replace a rectangular portion of 2D texture with pixels from the current READ_BUFFER This involves a read- back from GPU to CPU. Can you think of a way to move the dynamic texture around?! A better way of doing it: Render-to-texture (RTT) with framebuffer object (FBO)

6 Fall 2009 Revised6 glTexSubImage2D Replace part of the original image as new subimage Width and size of image need not be 2 n E.g., dynamic texture glTexSubImage2D (target, level, xoffset, yoffset, width, height, format, type, pixels)

7 Fall 2009 Revised7 Other Related Functions void glCopyTexImage2D(target, level, internalformat, x, y, width, height, border); defines a two-dimensional texture image with pixels from the current GL_READ_BUFFER. void glCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height); docdoc replaces a rectangular portion of a two- dimensional texture image with pixels from the current GL_READ_BUFFER (rather than from main memory, as is the case for glTexSubImage2D). Similar to glCopyPixel s

8 Fall 2009 Revised8 3D Textures

9 Fall 2009 Revised9 Render-to-Texture (RTT) Generate a snapshot every  degrees Total 360/  shots The shots are stored as a single texture Width and height must be 2 n E.g., 128x128x8,  =45

10 Fall 2009 Revised10 RTT Implementation First determine a viewing range such that all views are rendered well. The snapshots are taken from slightly elevated positions. At each position, pre-render to some 2^n resolution, copy the image to buffer When the panorama is done, set all pixels with background color to zero alpha values. Bind it to a texture object.

11 Fall 2009 Revised11 RTT The image version of the model will be set on a (cylindrical) billboard The texture can be chosen as follows:  If you tank is symmetric, you can use even fewer images

12 Fall 2009 Revised12 RTT (symmetric tank) 180°  8 images: (180/7  26)° apart port side starboard side Reverse the port-side image  0 7 1 2 3 4 5 6 

13 Fall 2009 Revised13 Perlin Noise 3D Texture Noise as texture

14 Fall 2009 Revised14 Light Map By Michael Gold (ref)ref NVIDIA

15 Fall 2009 Revised15 Light Maps Quake ( 雷神之錘, id software) was the first computer game to use light map

16 Fall 2009 Revised16

17 Fall 2009 Revised17 Lightmaps Cached Lighting Results Reuse lighting calculations  Multiple local lights (same type)  Static portion of scene ’ s light field  Sample region with texture instead of tessellating

18 Fall 2009 Revised18 Lightmaps Getting the most from the Lightmap Maximize lightmap re-use, minimize lightmap size Texture size versus sampling level  Full surface texture with built-in lighting  Small surface texture, small low-resolution lightmap Adjust texture matrix to re-use lightmap  Dynamic lighting: track moving lights

19 Fall 2009 Revised19 Lightmaps Segmenting Scene Lighting Static vs. dynamic light fields Global vs. local lighting Similar light shape

20 Fall 2009 Revised20 Lightmaps Segmenting the lightfields Dominant Lighting Local lighting

21 Fall 2009 Revised21 Lightmaps Moving Local Lights Recreate the texture; simple but slow Manipulate the lightmap  Translate to move relative to the surface  Scale to change spot size  Change base polygon color to adjust intensity Projective textures ideal for spotlights

22 Fall 2009 Revised22 Lightmaps Moving Local Lights Translate Texture Scale Texture Change Base Polygon Intensity

23 Fall 2009 Revised23 Lightmaps Creating a lightmap Light white, tesselated surface with local light Render, capture image as texture Texture contains ambient and diffuse lighting Texture can also be computed analytically

24 Fall 2009 Revised24 Lightmaps Creating a lightmap Render surface lit by local light Create a Texture Map from Image

25 Fall 2009 Revised25 Lightmaps Lightmap building tips Minimize texture resolution to match required sampling Edges of texture should have uniform intensity Light intensity change should be negligible at edges Don ’ t forget borders if you clamp the lightmap  Fill in border to match edge and corner  Or use border color

26 Fall 2009 Revised26 Lightmaps Lightmap building tips Boundary should have constant value Intensity changes from light should be minimal near edge of lightmap

27 Fall 2009 Revised27 Lightmaps Lighting with a Lightmap Local light is affected by surface color and texture Two step process adds local light contribution:  Modulate textured, unlit surfaces with lightmap  Add locally lit image to scene Can mix OpenGL, lightmap lighting in same scene

28 Fall 2009 Revised28 Lightmaps Creating local contribution Unlit Scene Lightmap Intensity Local Light Contribution Lightmap

29 Fall 2009 Revised29 Lightmaps Using Lightmaps Move lightmaps using texture matrix Distance from surface simulated by scaling texture and changing intensity Texgen maps lightmap to surfaces, overrides local texture coordinates  Can avoid changing model ’ s texture coordinates

30 Fall 2009 Revised30 Projective Texture Mapping Light source as slide projector Also generate shadows

31 Fall 2009 Revised31 Projective Texture Mapping

32 Fall 2009 Revised32 Implementation Tricks The projected texture need to be padded with black boundary pixels so that the clamped texture appears Ok Some natural faults (more than one layer of surface got textured): no way to resolve this!?

33 Fall 2009 Revised33 Q coord See Sampcode/qcoord

34 Fall 2009 Revised34 Code Samples Cutout texture Render-to-texture (RTT) Whirlpool cubemap lightmap billboarding


Download ppt "Fall 2009 Revised1 Texture Mapping (Intermediate) Jyun-Ming Chen."

Similar presentations


Ads by Google