Real-Time High Quality Rendering COMS 6160 [Fall 2004], Lecture 4 Shadow and Environment Mapping...

34
Real-Time High Quality Real-Time High Quality Rendering Rendering COMS 6160 [Fall 2004], Lecture 4 Shadow and Environment Mapping http://www.cs.columbia.edu/~ravir/6160
  • date post

    21-Dec-2015
  • Category

    Documents

  • view

    217
  • download

    0

Transcript of Real-Time High Quality Rendering COMS 6160 [Fall 2004], Lecture 4 Shadow and Environment Mapping...

Page 1: Real-Time High Quality Rendering COMS 6160 [Fall 2004], Lecture 4 Shadow and Environment Mapping ravir/6160.

Real-Time High Quality RenderingReal-Time High Quality Rendering

COMS 6160 [Fall 2004], Lecture 4

Shadow and Environment Mapping

http://www.cs.columbia.edu/~ravir/6160

Page 2: Real-Time High Quality Rendering COMS 6160 [Fall 2004], Lecture 4 Shadow and Environment Mapping ravir/6160.

Shadow and Environment MapsShadow and Environment Maps

Basic methods to add realism to interactive rendering

Shadow maps: image-based way to add hard shadows Very old technique. Originally Williams 78 Many recent (and older) extensions Widely used even in software rendering (RenderMan) Simple alternative to raytracing for shadows

Environment maps: image-based complex lighting Again, very old technique. Blinn and Newell 76 Huge amount of recent work (much covered in course)

Together, give most of realistic effects we want But cannot be combined!! Much of course is way to get

around this limitation

Page 3: Real-Time High Quality Rendering COMS 6160 [Fall 2004], Lecture 4 Shadow and Environment Mapping ravir/6160.

Common Real-time Shadow TechniquesCommon Real-time Shadow Techniques

ShadowShadowvolumesvolumes

Light mapsLight maps

ProjectedProjectedplanarplanarshadowsshadows

HybridHybridapproachesapproaches

This slide, others courtesy Mark Kilgard

Page 4: Real-Time High Quality Rendering COMS 6160 [Fall 2004], Lecture 4 Shadow and Environment Mapping ravir/6160.

ProblemsProblems

Mostly tricks with lots of limitations

Projected planar shadowsworks well only on flat surfaces

Stenciled shadow volumesdetermining the shadow volume is hard work

Light mapstotally unsuited for dynamic shadows

In general, hard to get everything shadowing everything

Page 5: Real-Time High Quality Rendering COMS 6160 [Fall 2004], Lecture 4 Shadow and Environment Mapping ravir/6160.

Shadow MappingShadow Mapping

Lance Williams: Brute Force in image space (shadow maps in 1978, but other similar ideas like Z buffer, bump mapping using textures and so on)

Completely image-space algorithm no knowledge of scene’s geometry is required must deal with aliasing artifacts

Well known software rendering technique Basic shadowing technique for Toy Story, etc.

Page 6: Real-Time High Quality Rendering COMS 6160 [Fall 2004], Lecture 4 Shadow and Environment Mapping ravir/6160.

Phase 1: Render from LightPhase 1: Render from Light

Depth image from light source

Page 7: Real-Time High Quality Rendering COMS 6160 [Fall 2004], Lecture 4 Shadow and Environment Mapping ravir/6160.

Phase 1: Render from LightPhase 1: Render from Light

Depth image from light source

Page 8: Real-Time High Quality Rendering COMS 6160 [Fall 2004], Lecture 4 Shadow and Environment Mapping ravir/6160.

Phase 2: Render from EyePhase 2: Render from Eye

Standard image (with depth) from eye

Eye

Page 9: Real-Time High Quality Rendering COMS 6160 [Fall 2004], Lecture 4 Shadow and Environment Mapping ravir/6160.

Phase 2+: Project to light for shadowsPhase 2+: Project to light for shadows

Project visible points in eye view back to light source

Eye

(Reprojected) depths match for light and eye. VISIBLE

Page 10: Real-Time High Quality Rendering COMS 6160 [Fall 2004], Lecture 4 Shadow and Environment Mapping ravir/6160.

Phase 2+: Project to light for shadowsPhase 2+: Project to light for shadows

Project visible points in eye view back to light source

Eye

(Reprojected) depths from light, eye not the same. BLOCKED!!

Page 11: Real-Time High Quality Rendering COMS 6160 [Fall 2004], Lecture 4 Shadow and Environment Mapping ravir/6160.

Visualizing Shadow MappingVisualizing Shadow Mapping

A fairly complex scene with shadows

the pointthe pointlight sourcelight source

Page 12: Real-Time High Quality Rendering COMS 6160 [Fall 2004], Lecture 4 Shadow and Environment Mapping ravir/6160.

Visualizing Shadow MappingVisualizing Shadow Mapping

Compare with and without shadows

with shadowswith shadows without shadowswithout shadows

Page 13: Real-Time High Quality Rendering COMS 6160 [Fall 2004], Lecture 4 Shadow and Environment Mapping ravir/6160.

Visualizing Shadow Mapping Visualizing Shadow Mapping

The scene from the light’s point-of-view

FYI: from theFYI: from theeye’s point-of-vieweye’s point-of-viewagainagain

Page 14: Real-Time High Quality Rendering COMS 6160 [Fall 2004], Lecture 4 Shadow and Environment Mapping ravir/6160.

Visualizing Shadow Mapping Visualizing Shadow Mapping

The depth buffer from the light’s point-of-view

FYI: from theFYI: from thelight’s point-of-viewlight’s point-of-viewagainagain

Page 15: Real-Time High Quality Rendering COMS 6160 [Fall 2004], Lecture 4 Shadow and Environment Mapping ravir/6160.

Visualizing Shadow Mapping Visualizing Shadow Mapping

Projecting the depth map onto the eye’s view

FYI: depth map forFYI: depth map forlight’s point-of-viewlight’s point-of-viewagainagain

Page 16: Real-Time High Quality Rendering COMS 6160 [Fall 2004], Lecture 4 Shadow and Environment Mapping ravir/6160.

Visualizing Shadow Mapping Visualizing Shadow Mapping

Comparing light distance to light depth map

Green is Green is where the where the

light planar light planar distance and distance and

the light the light depth map depth map

are are approximatelapproximatel

y equaly equal

Non-green is Non-green is where where shadows shadows should beshould be

Page 17: Real-Time High Quality Rendering COMS 6160 [Fall 2004], Lecture 4 Shadow and Environment Mapping ravir/6160.

Visualizing Shadow Mapping Visualizing Shadow Mapping

Scene with shadows

Notice how Notice how specular specular

highlights highlights never appear never appear

in shadowsin shadows

Notice how Notice how curved curved surfaces cast surfaces cast shadows on shadows on each othereach other

Page 18: Real-Time High Quality Rendering COMS 6160 [Fall 2004], Lecture 4 Shadow and Environment Mapping ravir/6160.

Hardware Shadow Map FilteringHardware Shadow Map Filtering

“Percentage Closer” filtering Normal texture filtering just averages color components Averaging depth values does NOT work Solution [Reeves, SIGGARPH 87]

Hardware performs comparison for each sample Then, averages results of comparisons

Provides anti-aliasing at shadow map edges Not soft shadows in the umbra/penumbra sense

Page 19: Real-Time High Quality Rendering COMS 6160 [Fall 2004], Lecture 4 Shadow and Environment Mapping ravir/6160.

Hardware Shadow Map FilteringHardware Shadow Map Filtering

GL_NEAREST: blockyGL_NEAREST: blocky GL_LINEAR: antialiased edgesGL_LINEAR: antialiased edges

Low shadow map resolutionLow shadow map resolutionused to heighten filtering artifactsused to heighten filtering artifacts

Page 20: Real-Time High Quality Rendering COMS 6160 [Fall 2004], Lecture 4 Shadow and Environment Mapping ravir/6160.

Problems with shadow mapsProblems with shadow maps

Hard shadows (point lights only)

Quality depends on shadow map resolution (general problem with image-based techniques)

Involves equality comparison of floating point depth values means issues of scale, bias, tolerance

Some of these addressed in papers presented

Page 21: Real-Time High Quality Rendering COMS 6160 [Fall 2004], Lecture 4 Shadow and Environment Mapping ravir/6160.

Reflection MapsReflection Maps

Blinn and Newell, 1976

Page 22: Real-Time High Quality Rendering COMS 6160 [Fall 2004], Lecture 4 Shadow and Environment Mapping ravir/6160.

Environment MapsEnvironment Maps

Miller and Hoffman, 1984

Page 23: Real-Time High Quality Rendering COMS 6160 [Fall 2004], Lecture 4 Shadow and Environment Mapping ravir/6160.

Environment MapsEnvironment Maps

Interface, Chou and Williams (ca. 1985)

Page 24: Real-Time High Quality Rendering COMS 6160 [Fall 2004], Lecture 4 Shadow and Environment Mapping ravir/6160.

Environment MapsEnvironment Maps

Cubical Environment Map180 degree fisheyePhoto by R. Packo

Cylindrical Panoramas

Page 25: Real-Time High Quality Rendering COMS 6160 [Fall 2004], Lecture 4 Shadow and Environment Mapping ravir/6160.

Reflectance MapsReflectance Maps

Reflectance Maps (Index by N)

Horn, 1977

Irradiance (N) and Phong (R) Reflection Maps

Hoffman and Miller, 1984

Mirror Sphere Chrome SphereMatte Sphere

Page 26: Real-Time High Quality Rendering COMS 6160 [Fall 2004], Lecture 4 Shadow and Environment Mapping ravir/6160.

Irradiance Environment MapsIrradiance Environment Maps

Incident Radiance(Illumination Environment Map)

Irradiance Environment Map

R N

Page 27: Real-Time High Quality Rendering COMS 6160 [Fall 2004], Lecture 4 Shadow and Environment Mapping ravir/6160.

AssumptionsAssumptions

Diffuse surfaces

Distant illumination

No shadowing, interreflection

Hence, Irradiance is a function of surface normal

Page 28: Real-Time High Quality Rendering COMS 6160 [Fall 2004], Lecture 4 Shadow and Environment Mapping ravir/6160.

Diffuse ReflectionDiffuse Reflection

B ERadiosity

(image intensity)Reflectance

(albedo/texture)Irradiance

(incoming light)

×=

quake light map

Page 29: Real-Time High Quality Rendering COMS 6160 [Fall 2004], Lecture 4 Shadow and Environment Mapping ravir/6160.

Analytic Irradiance FormulaAnalytic Irradiance Formula

Lambertian surface acts like low-pass filter

lm l lmE A LlA

2 / 3

/ 4

0

2 1

2

2

( 1) !2

( 2)( 1) 2 !

l

l l l

lA l even

l l

l0 1 2

Ramamoorthi and Hanrahan 01Basri and Jacobs 01

Page 30: Real-Time High Quality Rendering COMS 6160 [Fall 2004], Lecture 4 Shadow and Environment Mapping ravir/6160.

9 Parameter Approximation9 Parameter Approximation

-1-2 0 1 2

0

1

2

( , )lmY

xy z

xy yz 23 1z zx 2 2x y

l

m

Exact imageOrder 01 term

RMS error = 25 %

Page 31: Real-Time High Quality Rendering COMS 6160 [Fall 2004], Lecture 4 Shadow and Environment Mapping ravir/6160.

9 Parameter Approximation9 Parameter Approximation

-1-2 0 1 2

0

1

2

( , )lmY

xy z

xy yz 23 1z zx 2 2x y

l

m

Exact imageOrder 14 terms

RMS Error = 8%

Page 32: Real-Time High Quality Rendering COMS 6160 [Fall 2004], Lecture 4 Shadow and Environment Mapping ravir/6160.

9 Parameter Approximation9 Parameter Approximation

-1-2 0 1 2

0

1

2

( , )lmY

xy z

xy yz 23 1z zx 2 2x y

l

m

Exact imageOrder 29 terms

RMS Error = 1%

For any illumination, average error < 3% [Basri Jacobs 01]

Page 33: Real-Time High Quality Rendering COMS 6160 [Fall 2004], Lecture 4 Shadow and Environment Mapping ravir/6160.

Real-Time RenderingReal-Time Rendering

Simple procedural rendering method (no textures) Requires only matrix-vector multiply and dot-product In software or NVIDIA vertex programming hardware

Widely used in Games (AMPED for Microsoft Xbox), Movies (Pixar, Framestore CFC, …)

( ) tE n n Mn

surface float1 irradmat (matrix4 M, float3 v) {

float4 n = {v , 1} ;

return dot(n , M*n) ;

}

Page 34: Real-Time High Quality Rendering COMS 6160 [Fall 2004], Lecture 4 Shadow and Environment Mapping ravir/6160.

Environment Map SummaryEnvironment Map Summary

Very popular for interactive rendering

Papers we study handle complex materials

Shadows with precomputed transfer

But cannot be directly combined with shadow maps

Limited to distant lighting assumption