Texture Mapping - PowerPoint PPT Presentation

1 / 31
About This Presentation
Title:

Texture Mapping

Description:

Modeling the fine detail in real objects with triangles is just too hard sometimes. ... light model contains a simple hack for indirect reflection ambient reflection ... – PowerPoint PPT presentation

Number of Views:16
Avg rating:3.0/5.0
Slides: 32
Provided by: chrisw6
Category:
Tags: hack | mapping | texture

less

Transcript and Presenter's Notes

Title: Texture Mapping


1
Texture Mapping
2
Motivation
  • Modeling the fine detail in real objects with
    triangles is just too hard sometimes.
  • Phong lighting looks like plastic or rubber,
    maybe sometimes sort-of-like metal.

3
Motivation
  • Added surface detail can help computer graphics
    images look more real.
  • We cant explicitly model all of the detail, its
    just too expensive.
  • Texture mapping lets us use real images in our
    CG scenes to add realistic fine detail without
    the high geometric costs.

4
Texture mapping uses
  • Replacing fine detail geometry with images
  • What might we use the texture to modulate?
  • Color ambient, diffuse, specular
  • Alpha transparency
  • Normals lighting effects
  • More?
  • Well come back to this next time
  • How do we do it?

5
Fundamentals
  • Textures are most often 2D images
  • A single element of texture is called a texel
  • The value of the texel is used to modify surface
    appearance in some way
  • The mapping between texture and surface
    determines how pixels and texels correspond

6
Spherical mapping
7
Cylindrical mapping

8
How do we find the right texel?
  • Find the visible pixel (z-buffer, or whatever)
  • Find the point on the surface the corresponds to
    the visible pixel
  • Find the point in the texture (texel) that maps
    to the point on the surface
  • Use the texel values as appropriate to shade the
    pixel

9
Picking texture coordinates
  • Texture mapping is not automatic its often an
    art.
  • For objects where we have a parametric form of
    the surface, it can be easy to find the 2D
    texture mapping.
  • x fx(u, v) y fy(u, v) z fz(u, v)
  • Otherwise, the coordinates have to be specified
    manually.

10
Texture coordinates
11
Texture rendering
  • Parameterize the texture function of u and v
  • Normalized coordinates 0, 1
  • Associate each triangle with a texture
  • Give each triangle vertex a (u, v) texture
    coordinate
  • Interpolate texture coordinates across the
    triangle during rasterization
  • Like interpolating color, except

12
Texture Mapping Applications
13
What can we use texture for?
  • From an architecture independent (theoretical)
    standpoint
  • Color
  • Transparency
  • Lighting
  • Geometry
  • Volumetric effects
  • Special effects (lens flare, explosions, etc)
  • OpenGL treats texturing separate from lighting
    part of the shading phase only.
  • Modern (vendor) extensions to OpenGL are allowing
    textures to be part of the lighting process.

14
Using alpha to trim geometry
  • You can use an alpha channel in a texture to
    control what parts of the geometry are rendered
    into the scene.
  • Alpha blending alpha used to combine existing
    pixels in frame buffer with texel (as specified
    by some operator)
  • Alpha testing only those texels with specified
    alpha values are drawn into the frame buffer
    (like depth testing)

15
Lightmaps
  • Lightmaps or illumination maps are only valid for
    the specific geometry for which they were created
    by an artist or an algorithm.
  • Texture only
  • Texture
  • Lightmap

16
Environment mapping
17
Environment mapping
  • Our light model contains a simple hack for
    indirect reflection ambient reflection which
    is constant everywhere.
  • Using textures, we can approximate first bounce
    indirect lighting on shiny objects.
  • Pretend the object is inside a sphere, and we
    have a mapping from the sphere to an image of the
    objects surroundings.
  • Then we need only determinewhere in the
    environment the reflection
  • vector points.

18
Spherical mapping
  • We can map the entire environment into a sphere
    theres only one singular point in the map (0, 0,
    -1).
  • How do we map R into 2D coordinates?
  • But that singularity can be a problem.
  • Okay if you never see the back side.

19
Cube mapping
  • Layout in a cube (typically actually 6 separate
    textures).
  • The largest component of R tells us which of the
    6 textures to use (the one associated with the
    face of the cube R point to)
  • We can scale the remaining components to get
    texture coordinates within the appropriate face
    texture.

20
Environment maps for transparent objects
21
Cel-shading
22
Anisotropic lighting
23
Bump mapping
  • The theory of bump mapping is that we use a
    texture to determine how to displace the surface
    normal.
  • Displacements are calculated from the directional
    derivatives of the texture.
  • We make some assumptions
  • Displacements are small (dont have to
    renormalize)
  • Displacements are in the tangent plane to the
    surface
  • Texture coordinates span the tangent plane

24
Bump mapping
  • In a standard graphics pipeline say, OpenGL
    can we implement bump mapping as described? Why
    not?
  • We can, however, approximate it by multiple
    passes the most common technique is emboss bump
    mapping.
  • Pass 1 Render with diffuse lighting
  • Pass 2 Subtract a shifted version of the bump
    map
  • Pass 3 Add the bump map
  • How is it shifted?
  • In the direction of the projection of the light
    vector on the tangent plane.
  • Works okay for planar objects and small
    perturbations.

25
Bump mapping
26
Bump mapping
  • How do you recognize bump-mapped objects?

27
Displacement mapping
  • Displacement mapping actually changes the
    geometry according to the texture.
  • Not done in typical graphics hardware.

28
Projective textures
  • Slide projectors, additional spotlights, masked
    lights, and shadows can all be added by
    projective textures.
  • What if we started with an image, and wanted to
    project the image onto the geometry in the scene.
    But then we want to view that geometry, and the
    results of the projection, from elsewhere.

29
Shadow textures
  • Projective textures will end up projecting to all
    surface elements which can map back to valid
    texture coordinates.
  • This includes back facing (from the point of view
    of the projection source) and otherwise occluded
    surfaces.
  • But, if we really did render from that point of
    view, we could collect a depth map to correspond
    to the projective texture.

30
Shadow textures
  • We can transform depth similarly to geometry, and
    look up in the depth texture whether a piece of
    surface was visible to the other point of view.
  • If not visible, we dont apply the
  • projective texture.
  • We could also override previous
  • lighting calculations and leave
  • the surface in shadow.

31
3D textures
  • Useful for a better approximation of objects
    carved/sculpted from a solid piece of some
    material more realistic looking than warping an
    image around the surface.
  • Effectively computes
  • the intersection of
  • the object with the
  • texture.
  • Wood, granite, and
  • marble objects are
  • often textured this
  • way.
Write a Comment
User Comments (0)
About PowerShow.com