Understanding Textures: Generation, Application, and Perlin Noise in Computer Graphics - P, Study notes of Computer Graphics

The concept of textures in computer graphics, discussing methods to obtain and apply them, focusing on procedural textures and perlin noise. It covers topics like texture mapping, interpolation, and the advantages of perlin noise.

Typology: Study notes

Pre 2010

Uploaded on 02/13/2009

koofers-user-hto
koofers-user-hto 🇺🇸

9 documents

1 / 32

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
1
Texture
Pattern of Intensity and color.
Can be generalized to 3D texture.
How do we get them?
Take pictures.
Write a program (procedural textures).
Synthesize from examples
How do we apply them? (Texture mapping)
Specify a mapping from texture to object.
Interpolate as needed.
This can be a challenging problem, but we’ll consider
simpler version.
No Textures
Image courtesy, Foley, van Dam, Feiner, Hughes
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20

Partial preview of the text

Download Understanding Textures: Generation, Application, and Perlin Noise in Computer Graphics - P and more Study notes Computer Graphics in PDF only on Docsity!

Texture

  • Pattern of Intensity and color.
    • Can be generalized to 3D texture.
  • How do we get them?
    • Take pictures.
    • Write a program (procedural textures).
    • Synthesize from examples
  • How do we apply them? (Texture mapping)
    • Specify a mapping from texture to object.
    • Interpolate as needed.
    • This can be a challenging problem, but we’ll consider simpler version.

No Textures

Image courtesy, Foley, van Dam, Feiner, Hughes

With Textures

Image courtesy, Foley, van Dam, Feiner, Hughes

Texture Image

v

u 1

Courtesy, http://titan.spaceports.com/~seymor

v^ Procedural Texture

(^7) u

Assuming 3 bits: Vwave = v % 2

v^ Procedural Texture

(^7) u

Uwave = u % 2 Vwave = v % 2 Pix(u, v) = Uwave Vwave

Example Procedural Models

Images from Texturing and Modeling: A Procedural Approach By Ebert, Musgrave, Peachey, Perlin, and Worley

Example Procedural Models

Images from Texturing and Modeling: A Procedural Approach By Ebert, Musgrave, Peachey, Perlin, and Worley

Example Procedural Textures

Images from Texturing and Modeling: A Procedural Approach By Ebert, Musgrave, Peachey, Perlin, and Worley

What is Texture?

  • Something that repeats (or continues, or has

structure) with variation.

  • Must separate what repeats and what stays

the same.

  • Model as repeated trials of a random process
    • The probability distribution stays the same.
    • But each trial is different.
    • This may be true (eg., pile of objects)
  • Can be added structure (general shape of

mountain, plus rocky variation).

Perlin Noise

  • Natural phenomenon derives its richness from

variations

  • But we don’t want white noise!
  • Almost all movies use some form of Perlin noise:
    • James Cameron Movies (Abyss,Titanic,...)
    • Animated Movies (Lion King, Moses,...)
    • Arnold Movies (T2, True Lies, ...)
    • Star Wars Episode I, Star Trek Movies
    • Batman Movies
    • Refer noisemachine.com for details

Perlin Noise

• Reproducibility

• No repeatability

• Band limited (smoothly

changing)

• User control

2D Perlin Noise

Images courtesy of Paul Bourke

Smooth Noise

1. Populate an integer grid with random

values.

2. Interpolate in between to get values at non-

integer points

  • This creates a kind of smoothing

Advantages:

1. Randomness at grid points

2. Band limited

Linear Interpolation

f(x) = floor(x)(x-floor(x)) + ceiling(x)(ceiling(x)-x)

  • Average of neighboring points weighted by distance to them.

Cubic Interpolation

Instead of weighting by distance, d, weight by:

1 – 3d^2 + 2|d|^3

•Smooth •Symmetric

(www.noisemachine.com – Perlin)

Multiple Octaves

How about if we introduce more

frequencies?

double fractalsum(double x, double y, double z) { double value = 0; double f;

*for(f = MINFREQ; f < MAXFREQ; f = 2) value += gnoise(x * f, y * f) / f; return(value); } Demo of assignment executable

(www.noisemachine.com – Perlin)

Fractsum 10 x 10

Turbulence 10 x 10

Spatial regularities

• Multiply intensities by sine of x

coordinates.

• Demo

Map Intensities to Color

Demo

(www.noisemachine.com – Perlin)

Nonlinear changes in intensity

Blue channel always 255, others taken from noise.

OpenGL Texturing

  • Create and specify a texture object
    • Create a texture object
    • Specify the texture image
    • Specify how texture has to be applied for each pixel
  • Enable texture mapping
  • Draw the textured polygons
    • Identify the active texture
    • Specify texture coordinates with vertices

Specify a 2D Texture Object

  • glTexImage2D(GLenum target, GLint level, GLint

*internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLVoid *texels);*

  • Eg: glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 128, 128, 0, GL_RGBA, GL_UNSIGNED_BYTE, image);
  • format and type used to specify the way the texels are stored
  • internalFormat specifies how OpenGL should store the data internally
  • width and height have to be powers of 2; you can use gluScaleImage( ) to scale

Specify how Texture is applied

  • glTexParameter{if}(GLenum target, GLenum pname, TYPE param)
  • target can be: GL_TEXTURE_1D, GL_TEXTURE_2D, …

pname param

GL_TEXTURE_WRAP_S GL_CLAMP, GL_REPEAT

GL_TEXTURE_WRAP_T GL_CLAMP, GL_REPEAT

GL_TEXTURE_MAG_FILTER GL_NEAREST, GL_LINEAR

GL_TEXTURE_MIN_FILTER GL_NEAREST, GL_LINEAR

Enable the Texture and Draw

  • glEnable (GL_TEXTURE_2D)
    • Enable 2D texturing
  • glTexCoord2f (GL_FLOAT u, GL_FLOAT v)
    • Specify texture coordinates per vertex (just

as normals, color, etc).

  • demo