reflection models digital image synthesis yung-yu chuang 11/22/2007 with slides by pat hanrahan and...

59
Reflection models Digital Image Synthesis Yung-Yu Chuang 11/22/2007 with slides by Pat Hanrahan and Matt Pharr

Upload: bryan-mckenzie

Post on 20-Jan-2016

215 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Reflection models Digital Image Synthesis Yung-Yu Chuang 11/22/2007 with slides by Pat Hanrahan and Matt Pharr

Reflection models

Digital Image SynthesisYung-Yu Chuang11/22/2007

with slides by Pat Hanrahan and Matt Pharr

Page 2: Reflection models Digital Image Synthesis Yung-Yu Chuang 11/22/2007 with slides by Pat Hanrahan and Matt Pharr

Rendering equation

shading point

shading model• accuracy• expressiveness• speed

Page 3: Reflection models Digital Image Synthesis Yung-Yu Chuang 11/22/2007 with slides by Pat Hanrahan and Matt Pharr

Taxonomy 1

( , , , , , ) ( , , , , , )in outx y t x y t

General function = 12D

Scattering function = 9D

assume time doesn’t matter (no phosphorescence)

assume wavelengths are equal (no fluorescence)

Single-wavelength Scattering function = 8D

assume wavelength is discretized or integrated into RGB(This is a common assumption for computer graphics)

( , , , ) ( , , , )in outx y x y

Page 4: Reflection models Digital Image Synthesis Yung-Yu Chuang 11/22/2007 with slides by Pat Hanrahan and Matt Pharr

Taxonomy 2

Single-wavelength Scattering function = 8D( , , , ) ( , , , )in outx y x y

Bidirectional Texture Function (BTF)Spatially-varying BRDF (SVBRDF) = 6D

ignore subsurface scattering (x,y) in = (x,y) out

Bidirectional Subsurface ScatteringDistribution Function (BSSRDF) = 6D

ignore dependence on position

Light Fields, Surface LFs = 4D

ignore direction of incident light

( , , , )outx y

Texture Maps = 2D

assume Lambertian

( , )outx y

3D

assume isotropy

BRDF = 4D

ignore subsurface scattering

( , ) ( , )in out

ignore dependenceon position

Page 5: Reflection models Digital Image Synthesis Yung-Yu Chuang 11/22/2007 with slides by Pat Hanrahan and Matt Pharr

Properties of BRDFs

Page 6: Reflection models Digital Image Synthesis Yung-Yu Chuang 11/22/2007 with slides by Pat Hanrahan and Matt Pharr

Properties of BRDFs

1cos),(

iiior df

Page 7: Reflection models Digital Image Synthesis Yung-Yu Chuang 11/22/2007 with slides by Pat Hanrahan and Matt Pharr

Isotropic and anisotropic

Page 8: Reflection models Digital Image Synthesis Yung-Yu Chuang 11/22/2007 with slides by Pat Hanrahan and Matt Pharr

Reflection models

• BRDF/BTDF/BSDF• Scattering from realistic surfaces is best descri

bed as a mixture of multiple BRDFs and BSDFs.• core/reflection.*• Material = BSDF that combines multiple BRDFs

and BSDFs. (chap. 10)• Textures = reflection and transmission propert

ies that vary over the surface. (chap. 11)

Page 9: Reflection models Digital Image Synthesis Yung-Yu Chuang 11/22/2007 with slides by Pat Hanrahan and Matt Pharr

Surface reflection models

• Measured data: usually described in tabular form or coefficients of a set of basis functions

• Phenomenological models: qualitative approach; models with intuitive parameters

• Simulation: simulates light scattering from microgeometry and known reflectance properties

• Physical optics: solve Maxwell’s equation• Geometric optics: microfacet models

Page 10: Reflection models Digital Image Synthesis Yung-Yu Chuang 11/22/2007 with slides by Pat Hanrahan and Matt Pharr

Reflection categories

diffuse

perfect specular retro-reflective

glossy specular

Page 11: Reflection models Digital Image Synthesis Yung-Yu Chuang 11/22/2007 with slides by Pat Hanrahan and Matt Pharr

Geometric setting

n

t

s

sinsin ,

sincos

1sin ,cos 2

yx

zz

incident and outgoing directions are normalized and outward facing after being transformed into the local frame

local frame

Page 12: Reflection models Digital Image Synthesis Yung-Yu Chuang 11/22/2007 with slides by Pat Hanrahan and Matt Pharr

BxDF

• BxDFType– BSDF_REFLECTION, BSDF_TRANSMISSION– BSDF_DIFFUSE, BSDF_GLOSSY (retro-reflective), BSDF_SPECULAR

• Spectrum f(Vector &wo, Vector &wi)=0;• Spectrum Sample_f(Vector &wo, Vector *wi, float u1, float u2, float *pdf);

• Spectrum rho(Vector &wo, int nSamples=16, float *samples=NULL);

• Spectrum rho(int nSamples, float *samples);

used to find an incident direction for an outgoing direction;especially useful for reflection with a delta distribution

iiiorohd dpf |cos|),,()(hemispherical-directional reflectance; computed analytically or by sampling

hemispherical-hemisphericalreflectance

oioiiorhh ddpf

|coscos|),,(1

Page 13: Reflection models Digital Image Synthesis Yung-Yu Chuang 11/22/2007 with slides by Pat Hanrahan and Matt Pharr

Specular reflection and transmission• Reflection: • Transmission: (Snell’s law)

oi

ttii sinsin

n

i o

n

i

t

index of refraction dispersion

Page 14: Reflection models Digital Image Synthesis Yung-Yu Chuang 11/22/2007 with slides by Pat Hanrahan and Matt Pharr

Fresnel reflectance

• Reflectivity and transmissiveness: fraction of incoming light that is reflected or transmitted; they are usually view dependent. Hence, the reflectivity should be corrected by Fresnel equation

• Fresnel reflectance for dielectrics

Page 15: Reflection models Digital Image Synthesis Yung-Yu Chuang 11/22/2007 with slides by Pat Hanrahan and Matt Pharr

Indices of refraction

medium Index of refraction

Vaccum 1.0

Air at sea level 1.00029

Ice 1.31

Water (20°C) 1.333

Fused quartz 1.46

Glass 1.5~1.6

Sapphire 1.77

Diamond 2.42

Page 16: Reflection models Digital Image Synthesis Yung-Yu Chuang 11/22/2007 with slides by Pat Hanrahan and Matt Pharr

Fresnel reflectance• Fresnel reflectance for conductors (no

transmission) index of refraction

absorption coefficient

Page 17: Reflection models Digital Image Synthesis Yung-Yu Chuang 11/22/2007 with slides by Pat Hanrahan and Matt Pharr

ηand k for a few conductors

• However, for most conductors, these coefficients are unknown. Approximations are used to find plausible values for these quantities if reflectance at the normal incidence is known.

Object η k

Gold 0.370 2.820

Silver 0.177 3.638

Copper 0.617 2.630

Steel 2.485 3.433

Page 18: Reflection models Digital Image Synthesis Yung-Yu Chuang 11/22/2007 with slides by Pat Hanrahan and Matt Pharr

Approximation

• Measure Fr for θi=0

Page 19: Reflection models Digital Image Synthesis Yung-Yu Chuang 11/22/2007 with slides by Pat Hanrahan and Matt Pharr

Fresnel classclass Fresnel {public: virtual Spectrum Evaluate(float cosi) const = 0;};class FresnelConductor : public Fresnel {public: FresnelConductor(Spectrum &e, Spectrum &kk)

: eta(e), k(kk) {}private: Spectrum eta, k;};class FresnelDielectric : public Fresnel {public: FresnelDielectric(float ei, float et) {

eta_i = ei; eta_t = et; }private:

float eta_i, eta_t;};

Evaluate directly implements Fresnel formula for conductor

Evaluate directly implements Fresnel formula for dielectric

Page 20: Reflection models Digital Image Synthesis Yung-Yu Chuang 11/22/2007 with slides by Pat Hanrahan and Matt Pharr

Specular reflectionclass SpecularReflection : public BxDF {public: SpecularReflection(const Spectrum &r, Fresnel *f) : BxDF(BxDFType(BSDF_REFLECTION | BSDF_SPECULAR)), R(r), fresnel(f) { } Spectrum f(const Vector &, const Vector &) const { return Spectrum(0.); } Spectrum Sample_f(const Vector &wo, Vector *wi,

float u1, float u2, float *pdf) const; float Pdf(const Vector &wo, const Vector &wi) const{ return 0.;

}private:

Spectrum R;Fresnel *fresnel;

};

Page 21: Reflection models Digital Image Synthesis Yung-Yu Chuang 11/22/2007 with slides by Pat Hanrahan and Matt Pharr

Specular reflectionSpectrum SpecularReflection::Sample_f(Vector &wo,

Vector *wi, float u1, float u2, float *pdf) const{

// Compute perfect specular reflection direction

*wi = Vector(-wo.x, -wo.y, wo.z);

*pdf = 1.f;

return fresnel->Evaluate(CosTheta(wo)) * R /

fabsf(CosTheta(*wi));

}

Page 22: Reflection models Digital Image Synthesis Yung-Yu Chuang 11/22/2007 with slides by Pat Hanrahan and Matt Pharr

Perfect specular reflection

Page 23: Reflection models Digital Image Synthesis Yung-Yu Chuang 11/22/2007 with slides by Pat Hanrahan and Matt Pharr

Perfect specular transmission

Page 24: Reflection models Digital Image Synthesis Yung-Yu Chuang 11/22/2007 with slides by Pat Hanrahan and Matt Pharr

Fresnel modulation

Page 25: Reflection models Digital Image Synthesis Yung-Yu Chuang 11/22/2007 with slides by Pat Hanrahan and Matt Pharr

Lambertian reflection• It is not physically feasible, but provides a goo

d approximation to many real-world surfaces.

class COREDLL Lambertian : public BxDF {

public:

Lambertian(Spectrum &reflectance)

: BxDF(BxDFType(BSDF_REFLECTION | BSDF_DIFFUSE)),

R(reflectance), RoverPI(reflectance * INV_PI) {}

Spectrum f(Vector &wo, Vector &wi) {return RoverPI}

Spectrum rho(Vector &, int, float *) { return R; }

Spectrum rho(int, float *) { return R; }

private:

Spectrum R, RoverPI;

};

Page 26: Reflection models Digital Image Synthesis Yung-Yu Chuang 11/22/2007 with slides by Pat Hanrahan and Matt Pharr

Derivations

oioiiorhh ddpf

|coscos|),,(1

cddc

R ooii

coscos

oioi ddcR

|coscos|1

2

2

2

2

0

021

21

0

2

0

2

0 0

)2cos(2

)2()2sin(2

sincos

sincoscos

i

ii

iiii

iiiiii

d

dd

ddd

R

c

Page 27: Reflection models Digital Image Synthesis Yung-Yu Chuang 11/22/2007 with slides by Pat Hanrahan and Matt Pharr

Derivations

iiiorohd dpf |cos|),,()(

R

d

d

R

iiR

iiR

cos

cos

Page 28: Reflection models Digital Image Synthesis Yung-Yu Chuang 11/22/2007 with slides by Pat Hanrahan and Matt Pharr

Microfacet models• Rough surfaces can be modeled as a collection

of small microfacets. Their aggregate behavior determines the scattering.

• Two components: distribution of microfacets and how light scatters from individual microfacet → closed-form BRDF expression

n

Page 29: Reflection models Digital Image Synthesis Yung-Yu Chuang 11/22/2007 with slides by Pat Hanrahan and Matt Pharr

Important geometric effects to consider

masking shadowing interreflection

Most microfacet models assume that all microfacets makeup symmetric V-shaped grooves so that only neighboringmicrofacet needs to be considered. Particular models consider these effects with varying degrees of accuracy.

Page 30: Reflection models Digital Image Synthesis Yung-Yu Chuang 11/22/2007 with slides by Pat Hanrahan and Matt Pharr

Oren-Nayar model• Many real-world materials such as concrete, sa

nd and cloth are not real Lambertian. Specifically, rough surfaces generally appear brighter as the illumination direction approaches the viewing direction.

• A collection of symmetric V-shaped perfect Lambertian grooves whose orientation angles follow a Gaussian distribution.

• Don’t have a closed-form solution, instead they used an approximation

Page 31: Reflection models Digital Image Synthesis Yung-Yu Chuang 11/22/2007 with slides by Pat Hanrahan and Matt Pharr

Oren-Nayar model

Page 32: Reflection models Digital Image Synthesis Yung-Yu Chuang 11/22/2007 with slides by Pat Hanrahan and Matt Pharr

Oren-Nayar model

)tansin))cos(,0max((),(

),min( ,),max(

09.0

45.0 ,

)33.0(21

2

2

2

2

oioir

oioi

BAf

BA

standard deviation for Gaussian

Page 33: Reflection models Digital Image Synthesis Yung-Yu Chuang 11/22/2007 with slides by Pat Hanrahan and Matt Pharr

Oren-Nayar model

Page 34: Reflection models Digital Image Synthesis Yung-Yu Chuang 11/22/2007 with slides by Pat Hanrahan and Matt Pharr

Oren-Nayar model

Page 35: Reflection models Digital Image Synthesis Yung-Yu Chuang 11/22/2007 with slides by Pat Hanrahan and Matt Pharr

Oren-Nayar model

Page 36: Reflection models Digital Image Synthesis Yung-Yu Chuang 11/22/2007 with slides by Pat Hanrahan and Matt Pharr

Oren-Nayar modelclass OrenNayar : public BxDF {public: Spectrum f(const Vector &wo, const Vector &wi)const; OrenNayar(const Spectrum &reflectance, float sig) : BxDF(BxDFType(BSDF_REFLECTION | BSDF_DIFFUSE)), R(reflectance) { float sigma = Radians(sig); float sigma2 = sigma*sigma; A = 1.f - (sigma2 / (2.f * (sigma2 + 0.33f))); B = 0.45f * sigma2 / (sigma2 + 0.09f);

}private:

Spectrum R;float A, B;

};

Page 37: Reflection models Digital Image Synthesis Yung-Yu Chuang 11/22/2007 with slides by Pat Hanrahan and Matt Pharr

Oren-Nayar modelSpectrum OrenNayar::f(Vector &wo, Vector &wi)vconst{ float sinthetai = SinTheta(wi); float sinthetao = SinTheta(wo); float sinphii = SinPhi(wi), cosphii = CosPhi(wi); float sinphio = SinPhi(wo), cosphio = CosPhi(wo); float dcos = cosphii * cosphio + sinphii * sinphio; float maxcos = max(0.f, dcos); float sinalpha, tanbeta; if (fabsf(CosTheta(wi)) > fabsf(CosTheta(wo))) { sinalpha = sinthetao; tanbeta = sinthetai / fabsf(CosTheta(wi)); } else { sinalpha = sinthetai; tanbeta = sinthetao / fabsf(CosTheta(wo)); } return R * INV_PI * (A + B * maxcos * sinalpha * tanbeta);}

Page 38: Reflection models Digital Image Synthesis Yung-Yu Chuang 11/22/2007 with slides by Pat Hanrahan and Matt Pharr

Lambertian

Page 39: Reflection models Digital Image Synthesis Yung-Yu Chuang 11/22/2007 with slides by Pat Hanrahan and Matt Pharr

Oren-Nayer model

Page 40: Reflection models Digital Image Synthesis Yung-Yu Chuang 11/22/2007 with slides by Pat Hanrahan and Matt Pharr

Torrance-Sparrow model

• One of the first microfacet models, designed to model metallic surfaces

• A collection of perfectly smooth mirrored microfacets with distribution

io

)( hD

h

Page 41: Reflection models Digital Image Synthesis Yung-Yu Chuang 11/22/2007 with slides by Pat Hanrahan and Matt Pharr

Torrance-Sparrow model

Page 42: Reflection models Digital Image Synthesis Yung-Yu Chuang 11/22/2007 with slides by Pat Hanrahan and Matt Pharr

Configuration

l

w

Page 43: Reflection models Digital Image Synthesis Yung-Yu Chuang 11/22/2007 with slides by Pat Hanrahan and Matt Pharr

a

Geometry attenuation factor

h L

wms

areafacet total

dilluminate and leboth visib is that areafacet G

w

m

w

m

w

mwmw vsvs 1,1minl

,minl

i

h h

hshi

hshi

mwa

mwa

sinsincos

coscossin

i

i

sin

cos

)cos(

)cos(

ih

ihs

w

m

)cos(

coscos21

ih

ihs

w

m

shadowing

Page 44: Reflection models Digital Image Synthesis Yung-Yu Chuang 11/22/2007 with slides by Pat Hanrahan and Matt Pharr

Geometry attenuation factor

h E

wmv

a

i

h h

)cos(

coscos21

oh

ohv

w

m

masking

)cos(

coscos2,

)cos(

coscos2min1,1min

oh

oh

ih

ihvs

w

m

w

mG

ho

oh

hi

ihio

nnnnG

))((2

,))((2

min,1min),(

Page 45: Reflection models Digital Image Synthesis Yung-Yu Chuang 11/22/2007 with slides by Pat Hanrahan and Matt Pharr

Torrance-Sparrow model

Page 46: Reflection models Digital Image Synthesis Yung-Yu Chuang 11/22/2007 with slides by Pat Hanrahan and Matt Pharr

Microfacet modelclass COREDLL MicrofacetDistribution {

public:

virtual ~MicrofacetDistribution() { }

virtual float D(const Vector &wh) const=0;

virtual void Sample_f(const Vector &wo,

Vector *wi, float u1, float u2,

float *pdf) const = 0;

virtual float Pdf(const Vector &wo,

const Vector &wi) const = 0;

};

Page 47: Reflection models Digital Image Synthesis Yung-Yu Chuang 11/22/2007 with slides by Pat Hanrahan and Matt Pharr

Microfacet modelclass Microfacet : public BxDF {public: Microfacet(const Spectrum &reflectance, Fresnel *f,

MicrofacetDistribution *d); Spectrum f(const Vector &wo,const Vector &wi) const; float G(Vector &wo, Vector &wi, Vector &wh) const { float NdotWh = fabsf(CosTheta(wh)); float NdotWo = fabsf(CosTheta(wo)); float NdotWi = fabsf(CosTheta(wi)); float WOdotWh = AbsDot(wo, wh); return min(1.f, min((2.f*NdotWh*NdotWo/WOdotWh),

(2.f*NdotWh*NdotWi/WOdotWh)));}

...private: Spectrum R; Fresnel *fresnel; MicrofacetDistribution *distribution;};

Page 48: Reflection models Digital Image Synthesis Yung-Yu Chuang 11/22/2007 with slides by Pat Hanrahan and Matt Pharr

Microfacet modelSpectrum Microfacet::f(const Vector &wo,

const Vector &wi)

{

float cosThetaO = fabsf(CosTheta(wo));

float cosThetaI = fabsf(CosTheta(wi));

Vector wh = Normalize(wi + wo);

float cosThetaH = Dot(wi, wh);

Spectrum F = fresnel->Evaluate(cosThetaH);

return R * distribution->D(wh)

* G(wo, wi, wh) * F

/ (4.f * cosThetaI * cosThetaO);

}

Page 49: Reflection models Digital Image Synthesis Yung-Yu Chuang 11/22/2007 with slides by Pat Hanrahan and Matt Pharr

Microfacet models• Blinn• Anisotropic

Page 50: Reflection models Digital Image Synthesis Yung-Yu Chuang 11/22/2007 with slides by Pat Hanrahan and Matt Pharr

Blinn microfacet distribution• Distribution of microfacet normals is modeled

by an exponential falloff

• For smooth surfaces, this falloff happens very quickly; for rough surfaces, it is more gradual.

• Microfacet distribution must be normalized to ensure that they are physically plausible. The projected area of all microfacet faces over some area dA, the sum should be dA.

eh

ehh nD )(cos)()(

1cos)(

hhh dD

Page 51: Reflection models Digital Image Synthesis Yung-Yu Chuang 11/22/2007 with slides by Pat Hanrahan and Matt Pharr

Blinn microfacet distribution

hn

h

dAhd

hhd cos

1cos)(

hhh dD 1cos)(

hhe

h dc n

1sin)(cos2

0 0

12

hhh

eh ddc

1)cos()(cos22

0

1 h

eh dc

12

)(cos2

0cos

1cos

2

h

he

ce

h

2

2e

c ehh n

eD )(

2

2)(

Page 52: Reflection models Digital Image Synthesis Yung-Yu Chuang 11/22/2007 with slides by Pat Hanrahan and Matt Pharr

Blinn microfacet distribution

class Blinn : public MicrofacetDistribution{ ... float Blinn::D(const Vector &wh) const { float costhetah = fabsf(CosTheta(wh)); return (exponent+2) * INV_TWOPI * powf(max(0.f, costhetah), exponent); }}

e=4 e=20

Page 53: Reflection models Digital Image Synthesis Yung-Yu Chuang 11/22/2007 with slides by Pat Hanrahan and Matt Pharr

Torrance-Sparrow with Blinn distribution

Page 54: Reflection models Digital Image Synthesis Yung-Yu Chuang 11/22/2007 with slides by Pat Hanrahan and Matt Pharr

• Blinn microfacet model is radially symmetric (only depending on θh); hence, it is isotropic.

• Ashikmin and Shirley have developed a microfacet model for anisotropic surfaces

Anisotropic microfacet model

xe

ye

hyhx eehh nD

22 sincos)()(

Page 55: Reflection models Digital Image Synthesis Yung-Yu Chuang 11/22/2007 with slides by Pat Hanrahan and Matt Pharr

Ashikmin-Shirley model

1cos)(22 sincos

hh

eeh dc hyhx n

1sin)(cos2

0 0

1sincos2

22

hhhee

h ddc hyhx

1cos)(cos2

0 0

1sincos2

22

hhee

h ddc hyhx

12sincos

)(cos2

0

0

1

22

2sincos 22

h

hyhx

eeh d

eec

hyhx

12sincos

12

022

hhyhx

dee

c

Page 56: Reflection models Digital Image Synthesis Yung-Yu Chuang 11/22/2007 with slides by Pat Hanrahan and Matt Pharr

Ashikmin-Shirley model

12sincos

12

022

hhyhx

dee

c

122

2

yx eec

hyhx eeh

yx

h nee

D

22 sincos)(

2

)2)(2()(

Page 57: Reflection models Digital Image Synthesis Yung-Yu Chuang 11/22/2007 with slides by Pat Hanrahan and Matt Pharr

Anisotropic microfacet model

Page 58: Reflection models Digital Image Synthesis Yung-Yu Chuang 11/22/2007 with slides by Pat Hanrahan and Matt Pharr

Lafortune modelAn efficient model to fit measured data to a parameterized model with a relatively small number of parameters

n

i

eziizyiiyxiixo

d

ior

iooo

pf

1,,, )),,((

),,(

eiziyixo

eioior Rpf

),,(

),(),,(

nmodified Phong model

Lafortune model

),,( ,,, ziyixi oooorientation vector)1,1,1( specular

)5.0,1,1( off-specular)1,1,1( retro-reflective

Page 59: Reflection models Digital Image Synthesis Yung-Yu Chuang 11/22/2007 with slides by Pat Hanrahan and Matt Pharr

Lafortune model (for a measured clay)