Texture Mapping Intermediate - PowerPoint PPT Presentation

1 / 43
About This Presentation
Title:

Texture Mapping Intermediate

Description:

Used when the tex coords are too cumbersome to specify, or will be changed with time. ... There are a few glaring limitations to spherical mapping. ... – PowerPoint PPT presentation

Number of Views:99
Avg rating:3.0/5.0
Slides: 44
Provided by: melod6
Category:

less

Transcript and Presenter's Notes

Title: Texture Mapping Intermediate


1
Texture Mapping (Intermediate)
  • Jyun-Ming Chen

2
Texture Suite
3
Texture Suite
4
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
Dynamic Texture
A better way of doing it Render-to-texture (RTT)
with framebuffer object (FBO)
  • 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?!
6
glTexSubImage2D
  • Replace part of the original image as new
    subimage
  • Width and size of image need not be 2n
  • E.g., dynamic texture

glTexSubImage2D (target, level, xoffset,
yoffset, width, height, format, type, pixels)
7
Other Related Functions
Similar to glCopyPixels
  • 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) doc
  • 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).

8
3D Textures
9
Render-to-Texture (RTT)
  • Generate a snapshot every q degrees
  • Total 360/q shots
  • The shots are stored as a single texture
  • Width and height must be 2n
  • E.g., 128x128x8, q45

10
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 2n
    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
RTT
  • The image version of the model will be set on a
    (cylindrical) billboard
  • The texture can be chosen as follows

f
If you tank is symmetric, you can use even fewer
images
12
RTT (symmetric tank)
1
2
0
  • 180?8 images (180/7?26) apart
  • port side
  • starboard side
  • Reverse the port-side image

3
f
4
f
5
6
7
13
Perlin Noise
3D Texture Noise as texture
14
Light Map
  • By Michael Gold (ref)
  • NVIDIA

15
Light Maps
Quake (????, id software) was the first computer
game to use light map
16
(No Transcript)
17
Lightmaps
  • Cached Lighting Results
  • Reuse lighting calculations
  • Multiple local lights (same type)
  • Static portion of scenes light field
  • Sample region with texture instead of tessellating

18
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
Lightmaps
  • Segmenting Scene Lighting
  • Static vs. dynamic light fields
  • Global vs. local lighting
  • Similar light shape

20
Lightmaps
  • Segmenting the lightfields

Dominant Lighting
Local lighting
21
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
Lightmaps
  • Moving Local Lights

Translate Texture
Scale Texture
Change Base Polygon Intensity
23
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
Lightmaps
  • Creating a lightmap

Render surface lit by local light
Create a Texture Map from Image
25
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
  • Dont forget borders if you clamp the lightmap
  • Fill in border to match edge and corner
  • Or use border color

26
Lightmaps
  • Lightmap building tips

Boundary should have constant value
Intensity changes from light should be
minimal near edge of lightmap
27
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
Lightmaps
Lightmap
  • Creating local contribution

Unlit Scene
Local Light Contribution
Lightmap Intensity
29
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 models texture coordinates

30
Projective Texture Mapping
Also generate shadows
Light source as slide projector
31
Projective Texture Mapping
32
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
Q coord
  • See Sampcode/qcoord

34
Sphere Map
35
Sphere Map (cont)
36
Generating Sphere Map (ref)
37
Adding Silhouettes with Sphere Map
38
Reflection Mapping (wikipedia)
  • the most common ones are the Standard Environment
    Mapping in which a single texture contains the
    image of the surrounding as reflected on a mirror
    ball, or the Cubic Environment Mapping in which
    the envirornment is unfolded onto the six faces
    of a cube and stored therefore as six square
    textures.
  • A typical drawback of this technique is the
    absence of self reflections you cannot see any
    part of the reflected object inside the
    reflection itself.

39
Spheremap
  • involves the use of a textured sphere infinitely
    far away from the object that reflects it. By
    creating a spherical texture using a fisheye lens
    or via prerendering or with a light probe, this
    texture is mapped to a hollow sphere, and the
    texel colors are determined by calculating the
    light vectors from the points on the object to
    the texels in the environment map. This technique
    may produce results which are superficially
    similar to those produced by raytracing, but
    incurs less of a performance hit because all of
    the colors of the points to be referenced are
    known beforehand, so all it has to do is to
    calculate the angles of incidence and reflection.
  • There are a few glaring limitations to spherical
    mapping. For one thing, due to the nature of the
    texture used for the map, there is an abrupt
    point of singularity on the backside of objects
    using spherical mapping. Cube mapping (see below)
    was developed to address this issue. Since cube
    maps (if made and filtered correctly) have no
    visible seams, they are an obvious successor to
    the archaic sphere maps, and nowadays spherical
    environment maps are almost nonexistent in
    certain contemporary graphical applications, such
    as video game graphics.

40
Cube Mapping
  • Cube mapped reflection is a technique that uses
    cube mapping to make objects look like they
    reflect the environment around them. Generally,
    this is done with the same skybox that is used in
    outdoor renderings. Though this is not a true
    reflection since objects around the reflective
    one will not be seen in the reflection, the
    desired effect is usually achieved.
  • Cube mapped reflection is done by determining the
    vector that the object is being viewed at. This
    camera ray is reflected about the surface normal
    of where the camera vector intersects the object.
    This results in the reflected ray which is then
    passed to the cube map to get the texel which the
    camera then sees as if it is on the surface of
    the object. This creates the effect that the
    object is reflective.

41
Dynamic Cube Map
42
Reference
  • here

43
Code Samples
lightmap
  • Cutout texture
  • Render-to-texture (RTT)
  • Whirlpool

billboarding
cubemap
Write a Comment
User Comments (0)
About PowerShow.com