Advanced Texturing Methods - PowerPoint PPT Presentation

About This Presentation
Title:

Advanced Texturing Methods

Description:

Chrome Mapping. Chrome mapping is a type of environment mapping in ... Note: Some people would not call chrome mapping a type of environment mapping. I would. ... – PowerPoint PPT presentation

Number of Views:48
Avg rating:3.0/5.0
Slides: 17
Provided by: glenngc
Learn more at: https://www.cs.uaf.edu
Category:

less

Transcript and Presenter's Notes

Title: Advanced Texturing Methods


1
Advanced Texturing Methods
  • Glenn G. ChappellCHAPPELLG_at_member.ams.org
  • U. of Alaska Fairbanks
  • CS 381 Lecture Notes
  • Monday, December 8, 2003

2
ReviewQuick Dirty Texture Generation
  • An easy way to generate a small texture is to
    begin with a string array, then turn map
    characters into colors somehow.
  • For an example, see qdtexture.cpp, on the web
    page.

3
ReviewProcedural Texture 1/6
  • Often, the trickiest part of texture mapping is
    generating the texture image.
  • Possible sources
  • External images.
  • From photographs, various graphics programs.
  • Reading the frame buffer.
  • Use glReadPixels.
  • Program-generated texture.
  • This is what we look at now.
  • Texture generated from scratch by a program is
    called procedural texture.
  • We look at a technique for procedural-texture
    generation pioneered by Ken Perlin of New York
    University.

4
ReviewProcedural Texture 2/6
  • Perlins idea is to begin with a special noise
    function. Properties
  • Easy to generate.
  • Random-ish looking.
  • All variation is at about the same scale.
  • All variation has about the same amplitude.
  • Highest, lowest, and average values are about the
    same for all parts of the image.

5
ReviewProcedural Texture 3/6
  • One type of noise we would like to be able to use
    is 1/f-noise.
  • All frequencies present, with amplitudes
    proportional to the inverse of the frequency.
  • So the height of a hill is proportional to its
    width.
  • 1/f-noise is the way the real world looks.
  • But its a pain to generate.
  • Perlin suggests simulating 1/f-noise
  • Sum many copies of his noise function, each at
    twice the frequency and half the amplitude of the
    previous.

6
ReviewProcedural Texture 4/6
  • Another idea of Perlin noise with cusps.
  • Sum as before, but take the absolute value of
    each noise function before summing them all.
  • Good for cloudy-looking things.

7
ReviewProcedural Texture 5/6
  • Perlins technique is aimed at 3-D textures.
  • Here we can make objects appear to be cut out of
    a 3-D block of material.
  • Essentially, let the texture coordinates be the
    same as the vertex coordinates.
  • Unfortunately, OpenGL 1.1 (which most of us seem
    to have) does not support 3-D texturing in a
    system-independent manner.
  • However, we can use Perlins techniques to
    generate 2-D texture simply by taking a slice of
    a 3-D noise function.

8
ReviewProcedural Texture 6/6
  • I have created a package (Pnoise) to create a
    minor variation on Perlins noise function.
  • Major differences
  • His is entirely deterministic. I use an
    externally seeded pseudo-random number generator.
  • I produce noise functions that wrap.
  • The images on the previous slides were generated
    by my code, not Perlins.
  • Specifically pnoise3d(), fnoise3d(),
    filterfnoise3d(, pnoise_abs).
  • See proctexture.cpp for sample code.

9
More on Procedural TextureProducing Colors 1/2
  • One piece remains in order to produce interesting
    procedural textures
  • Convert a noise function into an image.
  • We need to be able to map noise values (in
    1,1) to colors (RGB).

10
More on Procedural TextureProducing Colors 2/2
  • One versatile method
  • Choose colors for specified values in 1,1.
  • Then determine the color associated with a value
    by lirping between the two nearest specified
    values.
  • EXAMPLE TIME.

1.0
0.7
0.2
1.0
1.0
0.7
0.2
1.0
0.7
11
More on Procedural TextureOther Methods
  • Other methods for generating procedural texture
    are possible (and are not really that difficult
    to come up with). For example
  • A particle doing a random walk and leaving behind
    trails of color.
  • This technique was used to generate some of the
    3-D textures used in BLUIsculpt.
  • Think of something else

12
Bump Mapping Demo
  • Bump Mapping
  • Like texturing, except look up normals instead of
    colors.
  • Use the bump-map normal to perturb the usual
    surface normal.
  • Result bumpy-looking surface.
  • With a smooth silhouette.
  • Bump mapping requires per-fragment lighting.
  • And therefore it is not well suited to the OpenGL
    pipeline.
  • But bump mapping is not hard to add to a ray
    tracer.
  • What do you suppose is a good way to generate a
    bump map?

13
Environment MappingIntroduction
  • In environment mapping, we simulate mirror-like
    reflection using texturing.
  • Generate texture coordinates based on the
    direction that light, originating from the
    viewer, would reflect off the surface.
  • Need
  • Viewing location (always (0,0,0) in OpenGL).
  • Vertex coordinates.
  • Surface normal.

14
Environment MappingSphere Map
  • A simple environment-mapping technique is to use
    a sphere map.
  • Take the reflected light direction, add 1 to z,
    normalize.
  • Use the resulting x, y as texture coordinates.
  • The texture is a fish-eye-lens picture of the
    environment.
  • E.g., see plate 21 in the red book.

15
Environment MappingChrome Mapping
  • Chrome mapping is a type of environment mapping
    in which we do not attempt to produce a realistic
    picture of the environment.
  • Just make mirror-like reflections of something.
  • Then objects look metallic, regardless of the
    incorrect reflections.
  • Note Some people would not call chrome mapping a
    type of environment mapping.
  • I would.
  • In particular, it is legal on assignment 11.

16
Environment MappingOpenGL
  • OpenGL includes automatic texture-coordinate
    generation.
  • One of the options does a sphere map.
  • In initialization (or whereever)
  • glTexGeni(GL_S, GL_TEXTURE_GEN_MODE,
    GL_SPHERE_MAP)
  • glTexGeni(GL_T, GL_TEXTURE_GEN_MODE,
    GL_SPHERE_MAP)
  • To enable
  • glEnable(GL_TEXTURE_GEN_S)
  • glEnable(GL_TEXTURE_GEN_T)
  • Disabling is as usual.
  • Normals must be specified. glTexCoord is not
    necessary.
  • How to generate the texture, though ?
Write a Comment
User Comments (0)
About PowerShow.com