Top Banner
09/11/03 CS679 - Fall 2003 - Copyright Univ. of Wisconsin Last Time Graphics Pipeline Texturing Overview Cubic Environment Mapping
23

09/11/03CS679 - Fall 2003 - Copyright Univ. of Wisconsin Last Time Graphics Pipeline Texturing Overview Cubic Environment Mapping.

Dec 31, 2015

Download

Documents

Audra Simmons
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: 09/11/03CS679 - Fall 2003 - Copyright Univ. of Wisconsin Last Time Graphics Pipeline Texturing Overview Cubic Environment Mapping.

09/11/03 CS679 - Fall 2003 - Copyright Univ. of Wisconsin

Last Time

• Graphics Pipeline

• Texturing Overview

• Cubic Environment Mapping

Page 2: 09/11/03CS679 - Fall 2003 - Copyright Univ. of Wisconsin Last Time Graphics Pipeline Texturing Overview Cubic Environment Mapping.

09/11/03 CS679 - Fall 2003 - Copyright Univ. of Wisconsin

Today

• More environment mapping

• Light Maps

Page 3: 09/11/03CS679 - Fall 2003 - Copyright Univ. of Wisconsin Last Time Graphics Pipeline Texturing Overview Cubic Environment Mapping.

09/11/03 CS679 - Fall 2003 - Copyright Univ. of Wisconsin

Environment Mapping

• Environment mapping produces reflections on shiny objects

• Texture is transferred in the direction of the reflected ray from the environment map onto the object– Uses ray with same direction but

starting at the object center

• Map contains a view of the world as seen from the center of the object

Object

Viewer

Reflected ray

EnvironmentMap

Lookup ray

Page 4: 09/11/03CS679 - Fall 2003 - Copyright Univ. of Wisconsin Last Time Graphics Pipeline Texturing Overview Cubic Environment Mapping.

09/11/03 CS679 - Fall 2003 - Copyright Univ. of Wisconsin

Lat/Long Mapping

• The original algorithm (1976) placed the map on a sphere centered on the object

• Mapping functions assume that s,t texture coordinates equate to latitude and longitude on the sphere:

• What is bad about this method?– Sampling

– Map generation

– Complex texture coordinate computations

2

1 ,tan

11

2

1 1

z

x

y tsR

R

R

Page 5: 09/11/03CS679 - Fall 2003 - Copyright Univ. of Wisconsin Last Time Graphics Pipeline Texturing Overview Cubic Environment Mapping.

09/11/03 CS679 - Fall 2003 - Copyright Univ. of Wisconsin

Sphere Mapping

• Again the map lives on a sphere, but now the coordinate mapping is simplified

• To generate the map:– Take a map point (s,t), cast a ray onto a sphere in the -Z direction,

and record what is reflected

– Equivalent to photographing a reflective sphere with an orthographic camera (long lens, big distance)

• Again, makes the method suitable for film special effects

Page 6: 09/11/03CS679 - Fall 2003 - Copyright Univ. of Wisconsin Last Time Graphics Pipeline Texturing Overview Cubic Environment Mapping.

09/11/03 CS679 - Fall 2003 - Copyright Univ. of Wisconsin

A Sphere Map

Page 7: 09/11/03CS679 - Fall 2003 - Copyright Univ. of Wisconsin Last Time Graphics Pipeline Texturing Overview Cubic Environment Mapping.

09/11/03 CS679 - Fall 2003 - Copyright Univ. of Wisconsin

Indexing Sphere Maps

• Given the reflection vector:

• Implemented in hardware

• Problems:– Highly non-uniform sampling

– Highly non-linear mapping

21

222 12

2

1 ,

2

1

zyx

yx

RRRm

m

Rt

m

Rs

Page 8: 09/11/03CS679 - Fall 2003 - Copyright Univ. of Wisconsin Last Time Graphics Pipeline Texturing Overview Cubic Environment Mapping.

09/11/03 CS679 - Fall 2003 - Copyright Univ. of Wisconsin

Non-uniform Sampling

Page 9: 09/11/03CS679 - Fall 2003 - Copyright Univ. of Wisconsin Last Time Graphics Pipeline Texturing Overview Cubic Environment Mapping.

09/11/03 CS679 - Fall 2003 - Copyright Univ. of Wisconsin

Non-linear Mapping

• Linear interpolation of per-vertex texture coordinates picks up the wrong texture pixels– Use small polygons!

Correct Linear

Page 10: 09/11/03CS679 - Fall 2003 - Copyright Univ. of Wisconsin Last Time Graphics Pipeline Texturing Overview Cubic Environment Mapping.

09/11/03 CS679 - Fall 2003 - Copyright Univ. of Wisconsin

Example

Page 11: 09/11/03CS679 - Fall 2003 - Copyright Univ. of Wisconsin Last Time Graphics Pipeline Texturing Overview Cubic Environment Mapping.

09/11/03 CS679 - Fall 2003 - Copyright Univ. of Wisconsin

Parabolic Mapping

• Assume the map resides on a parabolic surface– Two surfaces, facing each other

• Improves on sphere maps:– Texture coordinate generation is a near linear process

– Sampling is more uniform

– Result is more view-independent

• However, requires multi-passes to implement, so not generally used

Page 12: 09/11/03CS679 - Fall 2003 - Copyright Univ. of Wisconsin Last Time Graphics Pipeline Texturing Overview Cubic Environment Mapping.

09/11/03 CS679 - Fall 2003 - Copyright Univ. of Wisconsin

Other Env. Map Tricks

• Partially reflective objects– First stage applied color texture

– Second stage does environment mapping using alpha blend with existing color

• Just put the lights in the environment map– What does this simulate?

• Recursive reflections

• Bad cases for environment maps?

Page 13: 09/11/03CS679 - Fall 2003 - Copyright Univ. of Wisconsin Last Time Graphics Pipeline Texturing Overview Cubic Environment Mapping.

09/11/03 CS679 - Fall 2003 - Copyright Univ. of Wisconsin

Light Maps

• Speed up lighting calculations by pre-computing lighting and storing it in maps– Allows complex illumination models to be used in generating the

map (eg shadows, radiosity)– Used in complex rendering algorithms (Radiance), not just games

• Issues:– How is the mapping determined?– How are the maps generated?– How are they applied at run-time?

Page 14: 09/11/03CS679 - Fall 2003 - Copyright Univ. of Wisconsin Last Time Graphics Pipeline Texturing Overview Cubic Environment Mapping.

09/11/03 CS679 - Fall 2003 - Copyright Univ. of Wisconsin

Example

Page 15: 09/11/03CS679 - Fall 2003 - Copyright Univ. of Wisconsin Last Time Graphics Pipeline Texturing Overview Cubic Environment Mapping.

09/11/03 CS679 - Fall 2003 - Copyright Univ. of Wisconsin

Choosing a Mapping

• Problem: In a preprocessing phase, points on polygons must be associated with points in maps

• One solution:– Find groups of polygons that are “near” co-planar and do not

overlap when projected onto a plane• Result is a mapping from polygons to planes

– Combine sections of the chosen planes into larger maps– Store texture coordinates at polygon vertices

• Lighting tends to change quite slowly (except when?), so the map resolution can be poor

Page 16: 09/11/03CS679 - Fall 2003 - Copyright Univ. of Wisconsin Last Time Graphics Pipeline Texturing Overview Cubic Environment Mapping.

09/11/03 CS679 - Fall 2003 - Copyright Univ. of Wisconsin

Generating the Map

• Problem: What value should go in each pixel of the light map?

• Solution:– Map texture pixels back into world space (using the inverse of the

texture mapping)

– Take the illumination of the polygon and put it in the pixel

• Advantages of this approach:– Choosing “good” planes means that texture pixels map to roughly

square pieces of polygon - good sampling

– Not too many maps are required, and not much memory is wasted

Page 17: 09/11/03CS679 - Fall 2003 - Copyright Univ. of Wisconsin Last Time Graphics Pipeline Texturing Overview Cubic Environment Mapping.

09/11/03 CS679 - Fall 2003 - Copyright Univ. of Wisconsin

Example

Nearest interpolation Linear interpolation

What type of lighting (diffuse, specular, reflections) can the map store?

Page 18: 09/11/03CS679 - Fall 2003 - Copyright Univ. of Wisconsin Last Time Graphics Pipeline Texturing Overview Cubic Environment Mapping.

09/11/03 CS679 - Fall 2003 - Copyright Univ. of Wisconsin

Example

No light maps With light maps

Page 19: 09/11/03CS679 - Fall 2003 - Copyright Univ. of Wisconsin Last Time Graphics Pipeline Texturing Overview Cubic Environment Mapping.

09/11/03 CS679 - Fall 2003 - Copyright Univ. of Wisconsin

Applying Light Maps

• Use multi-texturing hardware– First stage: Apply color texture map

– Second stage: Modulate with light map• Actually, make points darker with light map

• DirectX allows you to make points brighter with texture

• Pre-lighting textures:– Apply the light map to the texture maps as a pre-process

– Why is this less appealing?

• Multi-stage rendering:– Same effect as multi-texturing, but modulating in the frame buffer

Page 20: 09/11/03CS679 - Fall 2003 - Copyright Univ. of Wisconsin Last Time Graphics Pipeline Texturing Overview Cubic Environment Mapping.

09/11/03 CS679 - Fall 2003 - Copyright Univ. of Wisconsin

Dynamic Light Maps

• Light maps are a preprocessing step, so they can only capture static lighting

• Texture transformations allow some effects

• What is required to recompute a light map at run-time?

• How might we make this tractable?– Spatial subdivision algorithms allow us to identify nearby objects,

which helps with this process

• Compute a separate, dynamic light map at runtime using same mapping as static light map

• Add additional texture pass to apply the dynamic map

Page 21: 09/11/03CS679 - Fall 2003 - Copyright Univ. of Wisconsin Last Time Graphics Pipeline Texturing Overview Cubic Environment Mapping.

09/11/03 CS679 - Fall 2003 - Copyright Univ. of Wisconsin

Fog Maps

• Dynamic modification of light-maps

• Put fog objects into the scene

• Compute where they intersect with geometry and paint the fog density into a dynamic light map– Use same mapping as static light map uses

• Apply the fog map as with a light map– Extra texture stage

Page 22: 09/11/03CS679 - Fall 2003 - Copyright Univ. of Wisconsin Last Time Graphics Pipeline Texturing Overview Cubic Environment Mapping.

09/11/03 CS679 - Fall 2003 - Copyright Univ. of Wisconsin

Fog Map Example

Page 23: 09/11/03CS679 - Fall 2003 - Copyright Univ. of Wisconsin Last Time Graphics Pipeline Texturing Overview Cubic Environment Mapping.

09/11/03 CS679 - Fall 2003 - Copyright Univ. of Wisconsin

Todo

• Confirm group names and meeting times– Email [email protected]

• By Monday, Sept 15: Goals for stage 1

• By Monday, Sept 22: Lock in Stage 1