64
Environment Mapping CSE 781 – Roger Crawfis

Environment Mapping CSE 781 – Roger Crawfis

  • Upload
    barth

  • View
    26

  • Download
    0

Embed Size (px)

DESCRIPTION

Environment Mapping CSE 781 – Roger Crawfis. Natural illumination. People perceive materials more easily under natural illumination than simplified illumination. Images courtesy Ron Dror and Ted Adelson. Natural illumination. - PowerPoint PPT Presentation

Citation preview

Page 1: Environment Mapping CSE 781 – Roger Crawfis

Environment MappingCSE 781 – Roger Crawfis

Page 2: Environment Mapping CSE 781 – Roger Crawfis

Natural illuminationPeople perceive materials more easily under natural illumination than simplified illumination.

Images courtesy Ron Dror and Ted Adelson

Page 3: Environment Mapping CSE 781 – Roger Crawfis

Natural illuminationNatural illumination is very expensive compared to using simplified illumination (take CSE 782).

directional source natural illumination

Page 4: Environment Mapping CSE 781 – Roger Crawfis

Environment Mapping

• Determine reflected ray.• Look-up direction

from a sphere-map.

• Reflection only dependson the direction, not the position.

Page 5: Environment Mapping CSE 781 – Roger Crawfis

Environment Mapping

• We can also encodethe reflected directions using several other formats.

• Greene, et al suggested a cube. This has the advantage that it can be constructed by six normal renderings.

Page 6: Environment Mapping CSE 781 – Roger Crawfis

Environment Mapping

• Create six views from the shiny object’s centroid.

• When scan-converting the object, index into the appropriate view and pixel.

• Use reflection vector to index.• Largest component of reflection vector will

determine the face.

Page 7: Environment Mapping CSE 781 – Roger Crawfis

Environment Mapping

• Problems:– Reflection is about object’s centroid.– Okay for small objects and

and distant reflections. N

N

Page 8: Environment Mapping CSE 781 – Roger Crawfis

Environment Mapping

• Latitude/Longitude– Too much distortion at poles

Page 9: Environment Mapping CSE 781 – Roger Crawfis

Environment Mapping

• Cube Maps– Can be created with GPU– Low distortion

Page 10: Environment Mapping CSE 781 – Roger Crawfis

Environment Mapping

• Cube Mapping

Page 11: Environment Mapping CSE 781 – Roger Crawfis

Sphere Mapping

Page 12: Environment Mapping CSE 781 – Roger Crawfis

Indexing Sphere Maps• Given the reflection vector R

• (s,t) on the spherical map• Problems:

– Highly non-uniform sampling– Highly non-linear mapping

21222 12

21 ,

21

zyx

yx

RRRm

mR

tmRs

Page 13: Environment Mapping CSE 781 – Roger Crawfis

Non-linear Mapping

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

Correct Linear

Page 14: Environment Mapping CSE 781 – Roger Crawfis

Sphere Mapping• Can be easily created by photographing a

mirrored sphere.

Page 15: Environment Mapping CSE 781 – Roger Crawfis

Sphere Mapping

Miller and Hoffman, 1984

Page 16: Environment Mapping CSE 781 – Roger Crawfis

Sphere Mapping

• Example

Page 17: Environment Mapping CSE 781 – Roger Crawfis

Parabolic Mapping

• Dual ParaboloidError

Support Region

Page 18: Environment Mapping CSE 781 – Roger Crawfis

Parabolic Mapping

Page 19: Environment Mapping CSE 781 – Roger Crawfis

Environment Mapping

• Applications– Specular highlights– Multiple light sources– Reflections for shiny surfaces– Irradiance for diffuse surfaces

Page 20: Environment Mapping CSE 781 – Roger Crawfis

Specular Highlights

• Sphere map on top• Result in the middle• Standard OpenGL lighting on the

bottom.• Not needed with fragment shaders,

… unless …

• Still a nice technique for many lights.• View dependent.

Page 21: Environment Mapping CSE 781 – Roger Crawfis

Chrome Mapping

• Cheap environment mapping• Material is very glossy, hence perfect

reflections are not seen.• Index into a pre-computed view independent

texture.• Reflection vectors are still view dependent.

Page 22: Environment Mapping CSE 781 – Roger Crawfis

Chrome Mapping

• Usually, we set it to a very blurred landscape image.– Brown or green on the bottom– White and blue on the top.– Normals facing up have a white/blue color– Normals facing down on average have a brownish

color.

Page 23: Environment Mapping CSE 781 – Roger Crawfis

Chrome Mapping

• Also useful for things like fire.• The major point, is that it is not important

what actually is shown in the reflection, only that it is view dependent.

Page 24: Environment Mapping CSE 781 – Roger Crawfis

Diffuse Reflection

radiosity(image intensity)

reflectance(albedo/texture)

irradiance(incoming light)

×=

quake light map

EB

Page 25: Environment Mapping CSE 781 – Roger Crawfis

Lambertian SurfaceDiffuse

Scattering

specular reflection

diffuse reflection

Light everywhere

Page 26: Environment Mapping CSE 781 – Roger Crawfis

2-Color Hemi-sphere Model

Sky Color

Ground Color

q

The 2-color hemi-sphere model from Lab1 was a very simple environment map for diffuse reflection.

Page 27: Environment Mapping CSE 781 – Roger Crawfis

Model Elements

Sky Color

Final Color

Ground Color

Hemisphere Model

Page 28: Environment Mapping CSE 781 – Roger Crawfis

Distributed Light Model

Hemisphere of possible incident light directions

Surface NormalMicrofacet Normal - defines axis of hemisphere

q

Page 29: Environment Mapping CSE 781 – Roger Crawfis

Irradiance environment maps

Illumination Environment Map Irradiance Environment Map

L n

dnLnE )(

Page 30: Environment Mapping CSE 781 – Roger Crawfis

Example Hemi-sphere Map

Environment map(longitude/latitude)

Irradiance map

Page 31: Environment Mapping CSE 781 – Roger Crawfis

Cube Map And Its Integral

Page 32: Environment Mapping CSE 781 – Roger Crawfis

Spherical Harmonics

Roger CrawfisCSE 781

Page 33: Environment Mapping CSE 781 – Roger Crawfis

• Basis Functions are pieces of signal that can be used to produce approximations to a function

1c

2c

3c

Basis functions

Page 34: Environment Mapping CSE 781 – Roger Crawfis

• We can then use these coefficients to reconstruct an approximation to the original signal

1c

2c

3c

Basis functions

Page 35: Environment Mapping CSE 781 – Roger Crawfis

• We can then use these coefficients to reconstruct an approximation to the original signal

xBcN

iii

1

Basis functions

Page 36: Environment Mapping CSE 781 – Roger Crawfis

Orthogonal Basis Functions

• Orthogonal Basis Functions– These are families of functions with special

properties

jiji

dxxBxB ji 01

Page 37: Environment Mapping CSE 781 – Roger Crawfis

Orthogonal Basis Functions

• Space to represent data• Different spaces often allow for compression

of coefficients• Lets look at one simple example of the

following piece of data

Data

Page 38: Environment Mapping CSE 781 – Roger Crawfis

Orthogonal Basis Functions• Standard Basis

Coefficient for each discrete position

Page 39: Environment Mapping CSE 781 – Roger Crawfis

DCT• Discrete Cosine Transform• Use Cosine waves as basis functions

1

cos x

cos 2

x cos 3x

Page 40: Environment Mapping CSE 781 – Roger Crawfis

Function Reconstruction with DCT

0.15 + 0.25 =

- 0.3 =

k cos x

cos 3x

Page 41: Environment Mapping CSE 781 – Roger Crawfis

Function Reconstruction with DCT

• Only needed 3 coefficients instead of 20!– Remaining coefficients are all 0

• Most of the time data not perfect• Obtain good reconstruction from few

coefficients• Arbitrary function conversion requires

projection

Page 42: Environment Mapping CSE 781 – Roger Crawfis

Real spherical harmonics

Page 43: Environment Mapping CSE 781 – Roger Crawfis

Reading SH diagrams

–+

Not thisdirection

Thisdirection

Page 44: Environment Mapping CSE 781 – Roger Crawfis

Reading SH diagrams

–+

Not thisdirection

Thisdirection

Page 45: Environment Mapping CSE 781 – Roger Crawfis

The SH functions0

0y

11y

11y

12y

22y

02y

12y2

2y

Page 46: Environment Mapping CSE 781 – Roger Crawfis

The SH functions

Page 47: Environment Mapping CSE 781 – Roger Crawfis

Spherical harmonics

-1-2 0 1 2

0

1

2

( , )lmY q

xy z

xy yz 23 1z zx 2 2x y

1

m

l

Page 48: Environment Mapping CSE 781 – Roger Crawfis

Examples of reconstruction

Displacement mapping on the sphere

Page 49: Environment Mapping CSE 781 – Roger Crawfis

An example• Take a function comprised of two area light sources

– SH project them into 4 bands = 16 coefficients

2380042508370317000106420

27800417009400908093006790

3291

.,,.,.,.,.,.,.,,.,,.

,.,.,.,.

Page 50: Environment Mapping CSE 781 – Roger Crawfis

Low frequency light source• We reconstruct the signal

– Using only these coefficients to find a low frequency approximation to the original light source

Page 51: Environment Mapping CSE 781 – Roger Crawfis

SH lighting for diffuse objects• An Efficient Representation for Irradiance Environment Maps,

Ravi Ramamoorthi and Pat Hanrahan, SIGGRAPH 2001• Assumptions

– Diffuse surfaces– Distant illumination – No shadowing, interreflection

irradiance is a function of surface normal

)( op,ωB iiiio ωθcos)ωp,()ω,ωp,(2

dLf ds)n()( Epn)B(p,

Page 52: Environment Mapping CSE 781 – Roger Crawfis

Spherical harmonic expansionExpand lighting (L), irradiance (E) in basis functions

0

( , ) ( , )l

lm lml m l

L L Yq q

0

( , ) ( , )l

lm lml m l

E E Yq q

= .67 + .36 + …

Page 53: Environment Mapping CSE 781 – Roger Crawfis

Analytic irradiance formula Lambertian surface

acts like low-pass filter

lm l lmE A LlA

2 / 3

/ 4

0

2 1

22

( 1) !2( 2)( 1) 2 !

l

l l l

lA l evenl l

l0 1 2cosine term

Page 54: Environment Mapping CSE 781 – Roger Crawfis

9 parameter approximation

Exact image Order 01 term

RMS error = 25 %

-1-2 0 1 2

0

1

2

( , )lmY q

xy z

xy yz 23 1z zx 2 2x y

l

m

Page 55: Environment Mapping CSE 781 – Roger Crawfis

9 Parameter Approximation

Exact image Order 14 terms

RMS Error = 8%

-1-2 0 1 2

0

1

2

( , )lmY q

xy z

xy yz 23 1z zx 2 2x y

l

m

Page 56: Environment Mapping CSE 781 – Roger Crawfis

9 Parameter Approximation

Exact image Order 29 terms

RMS Error = 1%

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

-1-2 0 1 2

0

1

2

( , )lmY q

xy z

xy yz 23 1z zx 2 2x y

l

m

Page 57: Environment Mapping CSE 781 – Roger Crawfis

Comparison

Incident illumination

300x300

Irradiance mapTexture: 256x256

HemisphericalIntegration 2Hrs

Irradiance mapTexture: 256x256

Spherical HarmonicCoefficients 1sec

Time 300 300 256 256 Time 9 256 256

Page 58: Environment Mapping CSE 781 – Roger Crawfis

RenderingIrradiance approximated by quadratic

polynomial2

4 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

xyz

Surface Normal vectorcolumn 4-vector

4x4 matrix(depends linearly

on coefficients Llm)

Page 59: Environment Mapping CSE 781 – Roger Crawfis

matrix form

c1L22 c1L2-2 c1L21 c2L11

c1L2-2 -c1L22 c1L2-1 c2L1-1

c1L21 c1L2-1 c3L20 c2L10

c2L11 c2L1-1 c2L10 c4L00 –c5L20

M =

MnnnE T

Page 60: Environment Mapping CSE 781 – Roger Crawfis

Complex geometryAssume no shadowing: Simply use surface normal

y

Page 61: Environment Mapping CSE 781 – Roger Crawfis

Cool!

Page 62: Environment Mapping CSE 781 – Roger Crawfis
Page 63: Environment Mapping CSE 781 – Roger Crawfis

IN4151 Introduction 3D graphics 63

Diffuse environment shading

received radiance is function of accessability

specular reflection

diffuse reflection

• Need integration over environment map

• For diffuse reflection scaled by cosinus

• Index in filtered versions of map

ambient occlusion

Page 64: Environment Mapping CSE 781 – Roger Crawfis

A Skin Texture Shader

• Skin appears softer than Lambertian reflectance because of subsurface scattering

• Seeliger lighting modelI = (N L) / (N L + N V )

• Implement as a texture shaders = N Lt = N V

C = s/(s+t )