Real-Time Rendering COMS 6998-3, Lecture 9. Real-Time Rendering Demo Motivation: Interactive...

53
Real-Time Rendering Real-Time Rendering COMS 6998-3, Lecture 9
  • date post

    19-Dec-2015
  • Category

    Documents

  • view

    225
  • download

    0

Transcript of Real-Time Rendering COMS 6998-3, Lecture 9. Real-Time Rendering Demo Motivation: Interactive...

Page 1: Real-Time Rendering COMS 6998-3, Lecture 9. Real-Time Rendering Demo Motivation: Interactive rendering with complex natural illumination and realistic,

Real-Time RenderingReal-Time Rendering

COMS 6998-3, Lecture 9

Page 2: Real-Time Rendering COMS 6998-3, Lecture 9. Real-Time Rendering Demo Motivation: Interactive rendering with complex natural illumination and realistic,

Real-Time Rendering DemoReal-Time Rendering Demo

Motivation: Interactive rendering with complex natural illumination and realistic, measured BRDFs

Page 3: Real-Time Rendering COMS 6998-3, Lecture 9. Real-Time Rendering Demo Motivation: Interactive rendering with complex natural illumination and realistic,

Complex Light TransportComplex Light Transport

Page 4: Real-Time Rendering COMS 6998-3, Lecture 9. Real-Time Rendering Demo Motivation: Interactive rendering with complex natural illumination and realistic,

ChallengesChallenges

• Illumination complexity

• Material (BRDF)/view complexity

• Transport complexity (shadows, interreflection)

Page 5: Real-Time Rendering COMS 6998-3, Lecture 9. Real-Time Rendering Demo Motivation: Interactive rendering with complex natural illumination and realistic,

Reflection MapsReflection Maps

Blinn and Newell, 1976

Page 6: Real-Time Rendering COMS 6998-3, Lecture 9. Real-Time Rendering Demo Motivation: Interactive rendering with complex natural illumination and realistic,

Environment MapsEnvironment Maps

Miller and Hoffman, 1984

Page 7: Real-Time Rendering COMS 6998-3, Lecture 9. Real-Time Rendering Demo Motivation: Interactive rendering with complex natural illumination and realistic,

Environment MapsEnvironment Maps

Interface, Chou and Williams (ca. 1985)

Page 8: Real-Time Rendering COMS 6998-3, Lecture 9. Real-Time Rendering Demo Motivation: Interactive rendering with complex natural illumination and realistic,

Environment MapsEnvironment Maps

Cubical Environment Map180 degree fisheyePhoto by R. Packo

Cylindrical Panoramas

Page 9: Real-Time Rendering COMS 6998-3, Lecture 9. Real-Time Rendering Demo Motivation: Interactive rendering with complex natural illumination and realistic,

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 10: Real-Time Rendering COMS 6998-3, Lecture 9. Real-Time Rendering Demo Motivation: Interactive rendering with complex natural illumination and realistic,

Irradiance Environment MapsIrradiance Environment Maps

Incident Radiance(Illumination Environment Map)

Irradiance Environment Map

R N

Page 11: Real-Time Rendering COMS 6998-3, Lecture 9. Real-Time Rendering Demo Motivation: Interactive rendering with complex natural illumination and realistic,

AssumptionsAssumptions

• Diffuse surfaces

• Distant illumination

• No shadowing, interreflection

Hence, Irradiance is a function of surface normal

Page 12: Real-Time Rendering COMS 6998-3, Lecture 9. Real-Time Rendering Demo Motivation: Interactive rendering with complex natural illumination and realistic,

Diffuse ReflectionDiffuse Reflection

B ERadiosity

(image intensity)Reflectance

(albedo/texture)Irradiance

(incoming light)

×=

quake light map

Page 13: Real-Time Rendering COMS 6998-3, Lecture 9. Real-Time Rendering Demo Motivation: Interactive rendering with complex natural illumination and realistic,

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

Page 14: Real-Time Rendering COMS 6998-3, Lecture 9. Real-Time Rendering Demo Motivation: Interactive rendering with complex natural illumination and realistic,

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 15: Real-Time Rendering COMS 6998-3, Lecture 9. Real-Time Rendering Demo Motivation: Interactive rendering with complex natural illumination and realistic,

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 16: Real-Time Rendering COMS 6998-3, Lecture 9. Real-Time Rendering Demo Motivation: Interactive rendering with complex natural illumination and realistic,

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 17: Real-Time Rendering COMS 6998-3, Lecture 9. Real-Time Rendering Demo Motivation: Interactive rendering with complex natural illumination and realistic,

ComparisonComparison

Incident illumination

300x300

Irradiance mapTexture: 256x256

HemisphericalIntegration 2Hrs

Irradiance mapTexture: 256x256

Spherical HarmonicCoefficients 1sec

Time 300 300 256 256 Time 9 256 256

Page 18: Real-Time Rendering COMS 6998-3, Lecture 9. Real-Time Rendering Demo Motivation: Interactive rendering with complex natural illumination and realistic,

RenderingRendering

Irradiance approximated by quadratic polynomial

24 00 2 11 2 1 1 2 10 5 2

2 2

0

1 2 2 1 21 1 2 1 1 22

1 (3 1( ) 2 2 2

2 2 ( )2

)x y z z

x

E n c L c L c L c L c L

c L c L c Ly xz yz x yc L

( ) tE n n Mn

1

x

y

z

Surface Normal vectorcolumn 4-vector

4x4 matrix(depends linearly

on coefficients Llm)

Page 19: Real-Time Rendering COMS 6998-3, Lecture 9. Real-Time Rendering Demo Motivation: Interactive rendering with complex natural illumination and realistic,

Hardware ImplementationHardware Implementation

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

( ) tE n n Mn

surface float1 irradmat (matrix4 M, float3 v) {

float4 n = {v , 1} ;

return dot(n , M*n) ;

}

Page 20: Real-Time Rendering COMS 6998-3, Lecture 9. Real-Time Rendering Demo Motivation: Interactive rendering with complex natural illumination and realistic,

Reflectance Space ShadingReflectance Space Shading

Cabral, Olano, Nemec1999

Page 21: Real-Time Rendering COMS 6998-3, Lecture 9. Real-Time Rendering Demo Motivation: Interactive rendering with complex natural illumination and realistic,

OLF ParameterizationOLF Parameterization

N LN

V

( , )B N V

Page 22: Real-Time Rendering COMS 6998-3, Lecture 9. Real-Time Rendering Demo Motivation: Interactive rendering with complex natural illumination and realistic,

OLF ParameterizationOLF Parameterization

N

V

( , )B N V

N

V

( , )B R V

RReparameterize

by reflection vector

Page 23: Real-Time Rendering COMS 6998-3, Lecture 9. Real-Time Rendering Demo Motivation: Interactive rendering with complex natural illumination and realistic,

OLF ParameterizationOLF Parameterization

• Captures structure of BRDF (and hence OLF) better

• Reflective BRDFs become low-dimensional

N

V

( , )B N V

N

V

( , )B R V

RReparameterize

by reflection vector

Page 24: Real-Time Rendering COMS 6998-3, Lecture 9. Real-Time Rendering Demo Motivation: Interactive rendering with complex natural illumination and realistic,

OLF Structure: LafortuneOLF Structure: Lafortune

( )VB R

Vie

wy

• Single 2D reflection map no longer sufficient

• But variation with viewing direction is slow

Viewx

Page 25: Real-Time Rendering COMS 6998-3, Lecture 9. Real-Time Rendering Demo Motivation: Interactive rendering with complex natural illumination and realistic,

OLF Structure: LafortuneOLF Structure: Lafortune

( )VB R

( )RB V

View maps vary slowly

Reflectionx

Ref

lect

ion

y

Vie

wy

Viewx

Page 26: Real-Time Rendering COMS 6998-3, Lecture 9. Real-Time Rendering Demo Motivation: Interactive rendering with complex natural illumination and realistic,

A Simple FactorizationA Simple Factorization

( )VB R

( )RB V

Viewx

Vie

wy

Ref

lect

ion

yReflectionx

( , ) ( ) * ( )B R V f R g V

*

Page 27: Real-Time Rendering COMS 6998-3, Lecture 9. Real-Time Rendering Demo Motivation: Interactive rendering with complex natural illumination and realistic,

Precomputed Radiance Transfer Precomputed Radiance Transfer for Real-Time Rendering in Dynamic, for Real-Time Rendering in Dynamic,

Low-Frequency Lighting EnvironmentsLow-Frequency Lighting Environments

Peter-Pike Sloan, Microsoft Research

Jan Kautz, MPI Informatik

John Snyder, Microsoft Research

Page 28: Real-Time Rendering COMS 6998-3, Lecture 9. Real-Time Rendering Demo Motivation: Interactive rendering with complex natural illumination and realistic,

Previous Work – Where We FitPrevious Work – Where We Fit

TransportTransportComplexityComplexity

LightingLighting

simplesimple shadowsshadows

pointpointlightslights

full full env.env.mapmap

inter-inter-reflectionsreflections

singlesingleareaarealightlight

????[Moeller02][Moeller02]

[Blinn76][Blinn76]

[Heidrich00][Heidrich00]

[Crow77][Crow77]

[Ashikhmin02][Ashikhmin02]

our our techniquetechnique

Non-InteractiveNon-Interactive

[Matusik02][Matusik02]

Page 29: Real-Time Rendering COMS 6998-3, Lecture 9. Real-Time Rendering Demo Motivation: Interactive rendering with complex natural illumination and realistic,

MotivationMotivation• Better light integration and

transport • dynamic, area lights • self-shadowing • interreflections

• For diffuse and glossy surfaces

• At real-time rates

point lightpoint light area lightarea light

area lighting,area lighting,no shadowsno shadows

area lighting,area lighting,shadowsshadows

Page 30: Real-Time Rendering COMS 6998-3, Lecture 9. Real-Time Rendering Demo Motivation: Interactive rendering with complex natural illumination and realistic,

lightlight

2D example, piecewise constant basis, shadows only

2p2p

1p1p3p3p

Diffuse Self-TransferDiffuse Self-Transfer

PreprocessPreprocess

1p1p

2p2p

3p3p

Project LightProject Light

lightlight

RenderingRendering

•• ==1p1p

1p1p

2p2p

2p2p ==••

3p3p

3p3p ==••

Page 31: Real-Time Rendering COMS 6998-3, Lecture 9. Real-Time Rendering Demo Motivation: Interactive rendering with complex natural illumination and realistic,

PrecomputationPrecomputation

Basis 16Basis 16

Basis 17Basis 17

Basis 18Basis 18

illuminateilluminate resultresult

......

......

Page 32: Real-Time Rendering COMS 6998-3, Lecture 9. Real-Time Rendering Demo Motivation: Interactive rendering with complex natural illumination and realistic,

Diffuse Transfer ResultsDiffuse Transfer Results

No Shadows/Inter Shadows Shadows+InterNo Shadows/Inter Shadows Shadows+Inter

Page 33: Real-Time Rendering COMS 6998-3, Lecture 9. Real-Time Rendering Demo Motivation: Interactive rendering with complex natural illumination and realistic,

Arbitrary BRDF ResultsArbitrary BRDF Results

Other BRDFsOther BRDFs Spatially VaryingSpatially VaryingAnisotropic BRDFsAnisotropic BRDFs

Page 34: Real-Time Rendering COMS 6998-3, Lecture 9. Real-Time Rendering Demo Motivation: Interactive rendering with complex natural illumination and realistic,

Shadow Mappingwith Today’s OpenGL Hardware

CEDEC 2001Tokyo, Japan

Shadow Mappingwith Today’s OpenGL Hardware

CEDEC 2001Tokyo, Japan

Mark J. KilgardGraphics Software EngineerNVIDIA Corporation

Page 35: Real-Time Rendering COMS 6998-3, Lecture 9. Real-Time Rendering Demo Motivation: Interactive rendering with complex natural illumination and realistic,

Motivation Motivation

• Shadows increase scene realism• Real world has shadows• More control of the game’s feel

• dramatic effects• spooky effects

• Other art forms recognize the value of shadows• But yet most games lack realistic shadows

Page 36: Real-Time Rendering COMS 6998-3, Lecture 9. Real-Time Rendering Demo Motivation: Interactive rendering with complex natural illumination and realistic,

Common Real-time Shadow TechniquesCommon Real-time Shadow Techniques

ShadowShadowvolumesvolumes

Light mapsLight maps

ProjectedProjectedplanarplanarshadowsshadows

HybridHybridapproachesapproaches

Page 37: Real-Time Rendering COMS 6998-3, Lecture 9. Real-Time Rendering Demo Motivation: Interactive rendering with complex natural illumination and realistic,

ProblemsProblems

• Mostly tricks with lots of limitations• Projected planar shadows

• well works only on flat surfaces• Stenciled shadow volumes

• determining the shadow volume is hard work• Light maps

• totally unsuited for dynamic shadows• In general, hard to get everything shadowing

everything

Page 38: Real-Time Rendering COMS 6998-3, Lecture 9. Real-Time Rendering Demo Motivation: Interactive rendering with complex natural illumination and realistic,

Shadow MappingShadow Mapping

• Image-space shadow determination• Lance Williams published the basic idea in 1978

• By coincidence, same year Jim Blinn invented bump mapping (a great vintage year for graphics)

• Completely image-space algorithm• means no knowledge of scene’s geometry is required

• must deal with aliasing artifacts

• Well known software rendering technique• Pixar’s RenderMan uses the algorithm

• Basic shadowing technique for Toy Story, etc.

Page 39: Real-Time Rendering COMS 6998-3, Lecture 9. Real-Time Rendering Demo Motivation: Interactive rendering with complex natural illumination and realistic,

ReferencesReferences

• Important SIGGRAPH papers• Lance Williams, “Casting Curved Shadows on Curved

Surfaces,” SIGGRAPH 78• William Reeves, David Salesin, and Robert Cook

(Pixar), “Rendering antialiased shadows with depth maps,” SIGGRAPH 87

• Mark Segal, et. al. (SGI), “Fast Shadows and Lighting Effects Using Texture Mapping,” SIGGRAPH 92

Page 40: Real-Time Rendering COMS 6998-3, Lecture 9. Real-Time Rendering Demo Motivation: Interactive rendering with complex natural illumination and realistic,

Shadow Mapping Concept (1)Shadow Mapping Concept (1)

• Depth testing from the light’s point-of-view• Two pass algorithm• First, render depth buffer from the light’s point-of-view

• the result is a “depth map” or “shadow map”• essentially a 2D function indicating the depth of the

closest pixels to the light• This depth map is used in the second pass

Page 41: Real-Time Rendering COMS 6998-3, Lecture 9. Real-Time Rendering Demo Motivation: Interactive rendering with complex natural illumination and realistic,

Shadow Mapping Concept (2)Shadow Mapping Concept (2)

• Shadow determination with the depth map• Second, render scene from the eye’s point-of-view• For each rasterized fragment

• determine fragment’s XYZ position relative to the light• this light position should be setup to match the frustum

used to create the depth map• compare the depth value at light position XY in the depth

map to fragment’s light position Z

Page 42: Real-Time Rendering COMS 6998-3, Lecture 9. Real-Time Rendering Demo Motivation: Interactive rendering with complex natural illumination and realistic,

Shadow Mapping Concept (3)Shadow Mapping Concept (3)

• The Shadow Map Comparison• Two values

• A = Z value from depth map at fragment’s light XY position• B = Z value of fragment’s XYZ light position

• If B is greater than A, then there must be something closer to the light than the fragment

• then the fragment is shadowed• If A and B are approximately equal, the fragment is lit

Page 43: Real-Time Rendering COMS 6998-3, Lecture 9. Real-Time Rendering Demo Motivation: Interactive rendering with complex natural illumination and realistic,

Visualizing Shadow MappingVisualizing Shadow Mapping

• A fairly complex scene with shadows

the pointthe pointlight sourcelight source

Page 44: Real-Time Rendering COMS 6998-3, Lecture 9. Real-Time Rendering Demo Motivation: Interactive rendering with complex natural illumination and realistic,

Visualizing Shadow MappingVisualizing Shadow Mapping

• Compare with and without shadows

with shadowswith shadows without shadowswithout shadows

Page 45: Real-Time Rendering COMS 6998-3, Lecture 9. Real-Time Rendering Demo Motivation: Interactive rendering with complex natural illumination and realistic,

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 46: Real-Time Rendering COMS 6998-3, Lecture 9. Real-Time Rendering Demo Motivation: Interactive rendering with complex natural illumination and realistic,

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 47: Real-Time Rendering COMS 6998-3, Lecture 9. Real-Time Rendering Demo Motivation: Interactive rendering with complex natural illumination and realistic,

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 48: Real-Time Rendering COMS 6998-3, Lecture 9. Real-Time Rendering Demo Motivation: Interactive rendering with complex natural illumination and realistic,

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 49: Real-Time Rendering COMS 6998-3, Lecture 9. Real-Time Rendering Demo Motivation: Interactive rendering with complex natural illumination and realistic,

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 50: Real-Time Rendering COMS 6998-3, Lecture 9. Real-Time Rendering Demo Motivation: Interactive rendering with complex natural illumination and realistic,

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 51: Real-Time Rendering COMS 6998-3, Lecture 9. Real-Time Rendering Demo Motivation: Interactive rendering with complex natural illumination and realistic,

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 heightens filtering artifactsused to heightens filtering artifacts

Page 52: Real-Time Rendering COMS 6998-3, Lecture 9. Real-Time Rendering Demo Motivation: Interactive rendering with complex natural illumination and realistic,

Soft Shadows?Soft Shadows?

Page 53: Real-Time Rendering COMS 6998-3, Lecture 9. Real-Time Rendering Demo Motivation: Interactive rendering with complex natural illumination and realistic,

ConclusionConclusion

• Variety of techniques• Shadows• Complex illumination• Complex materials

• Limited manipulability in most cases• Cannot change lighting, geometry, viewpoint etc.

• Is it possible to have everything simultaneously?