Top Banner
Lights Digital Image Synthesis Yung-Yu Chuang with slides by Stephen Chenney
18

chap13 light.ppt [相容模式] - 國立臺灣大學 · 2009. 11. 26. · Lights • An abstract interface for lights. • Pbrt only supports physically-based lights not based lights,

Aug 16, 2020

Download

Documents

dariahiddleston
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: chap13 light.ppt [相容模式] - 國立臺灣大學 · 2009. 11. 26. · Lights • An abstract interface for lights. • Pbrt only supports physically-based lights not based lights,

Lights

Digital Image Synthesisg g yYung-Yu Chuang

with slides by Stephen Chenney

Page 2: chap13 light.ppt [相容模式] - 國立臺灣大學 · 2009. 11. 26. · Lights • An abstract interface for lights. • Pbrt only supports physically-based lights not based lights,

Lights

• An abstract interface for lights.Pbrt only supports physically based lights not • Pbrt only supports physically-based lights, not including artistic lighting.

• core/light * lights/* w• core/light.* lights/*

• Essential data members:– Transform LightToWorld WorldToLight;

pwi

– Transform LightToWorld, WorldToLight;– int nSamples;

• Essential functions:returns wi and radiance due to the light

i i ibilit 1 i iti li i• Essential functions:– Spectrum Sample_L(Point &p, Vector *wi, VisibilityTester *vis);

assuming visibility=1; initializes vis

y );– Spectrum Power(Scene *);– bool IsDeltaLight();

approximate total power

point/directional lightsp gcan’t be sampled

Page 3: chap13 light.ppt [相容模式] - 國立臺灣大學 · 2009. 11. 26. · Lights • An abstract interface for lights. • Pbrt only supports physically-based lights not based lights,

Point lights

• IsotropicL d • Located at the origin

Page 4: chap13 light.ppt [相容模式] - 國立臺灣大學 · 2009. 11. 26. · Lights • An abstract interface for lights. • Pbrt only supports physically-based lights not based lights,

Point lightsPointLight::PointLight(const Transform &light2world,

const Spectrum &intensity) : Light(light2world) {p y) g ( g ) {lightPos = LightToWorld(Point(0,0,0));Intensity = intensity;

}Spectrum PointLight::Sample_L(Point &p, Vector *wi,

VisibilityTester *visibility) {VisibilityTester *visibility) {*wi = Normalize(lightPos - p);visibility->SetSegment(p, lightPos);y g (p, g )return Intensity / DistanceSquared(lightPos, p);

}Spectrum Power(const Scene *) const {

return Intensity * 4.f * M_PI;} d

dI

24

sIId

} d s

Page 5: chap13 light.ppt [相容模式] - 國立臺灣大學 · 2009. 11. 26. · Lights • An abstract interface for lights. • Pbrt only supports physically-based lights not based lights,

Spotlights

(0,0,0)

falloffStart

totalWidth

+z

Page 6: chap13 light.ppt [相容模式] - 國立臺灣大學 · 2009. 11. 26. · Lights • An abstract interface for lights. • Pbrt only supports physically-based lights not based lights,

SpotlightsSpotLight::SpotLight(const Transform &light2world,

const Spectrum &intensity, float width, float fall): Light(light2world) {lightPos = LightToWorld(Point(0,0,0));Intensity = intensity;Intensity = intensity;cosTotalWidth = cosf(Radians(width));cosFalloffStart = cosf(Radians(fall));

}Spectrum SpotLight::Sample_L(Point &p, Vector *wi,

VisibilityTester *visibility) {VisibilityTester visibility) {*wi = Normalize(lightPos - p);visibility->SetSegment(p, lightPos);return Intensity * Falloff(-*wi)

/DistanceSquared(lightPos,p);}}

Page 7: chap13 light.ppt [相容模式] - 國立臺灣大學 · 2009. 11. 26. · Lights • An abstract interface for lights. • Pbrt only supports physically-based lights not based lights,

Spotlightsfloat SpotLight::Falloff(const Vector &w) const {

Vector wl = Normalize(WorldToLight(w));float costheta = wl.z;if (costheta < cosTotalWidth)

return 0 ;return 0.;if (costheta > cosFalloffStart)

return 1.;float delta = (costheta - cosTotalWidth) /

(cosFalloffStart - cosTotalWidth);return delta*delta*delta*delta;return delta delta delta delta;

} )'cos1(2)'cos1(sin2

0

2

0

'

0'

ddddan approximation

Spectrum Power(const Scene *) const {return Intensity * 2.f * M_PI *

(1.f - .5f * (cosFalloffStart + cosTotalWidth));( ( ));}

Page 8: chap13 light.ppt [相容模式] - 國立臺灣大學 · 2009. 11. 26. · Lights • An abstract interface for lights. • Pbrt only supports physically-based lights not based lights,

Texture projection lights

• Like a slide projectorprojector

y(0,0)

zp

p’

fov

x

Page 9: chap13 light.ppt [相容模式] - 國立臺灣大學 · 2009. 11. 26. · Lights • An abstract interface for lights. • Pbrt only supports physically-based lights not based lights,

Goniophotometric light

• Define a angular distribution from distribution from a point light

Page 10: chap13 light.ppt [相容模式] - 國立臺灣大學 · 2009. 11. 26. · Lights • An abstract interface for lights. • Pbrt only supports physically-based lights not based lights,

Goniophotometric lightGonioPhotometricLight(const Transform &light2world,

Spectrum &I, string &texname):Light(light2world) {lightPos = LightToWorld(Point(0,0,0));Intensity = I;int w, h;Spectrum *texels = ReadImage(texname, &w, &h);if (texels) {

mipmap = new MIPMap<Spectrum>(w, h, texels);p p p p ( , , );delete[] texels;

}else mipmap = NULL;else mipmap = NULL;

}Spectrum Sample_L(const Point &p, Vector *wi,

VisibilityTester *visibility) const {VisibilityTester *visibility) const {*wi = Normalize(lightPos - p);visibility->SetSegment(p, lightPos);

i * S l ( * i)return Intensity * Scale(-*wi) / DistanceSquared(lightPos, p);

}

Page 11: chap13 light.ppt [相容模式] - 國立臺灣大學 · 2009. 11. 26. · Lights • An abstract interface for lights. • Pbrt only supports physically-based lights not based lights,

Goniophotometric lightSpectrum Scale(const Vector &w) const {

Vector wp = Normalize(WorldToLight(w));swap(wp.y, wp.z);float theta = SphericalTheta(wp);float phi = SphericalPhi(wp);float s = phi * INV_TWOPI, t = theta * INV_PI;return mipmap ? mipmap->Lookup(s, t) : 1.f;

}}

Spectrum Power(const Scene *) const {return 4 f * M PI * Intensity *return 4.f M_PI Intensity

mipmap->Lookup(.5f, .5f, .5f);}

Page 12: chap13 light.ppt [相容模式] - 國立臺灣大學 · 2009. 11. 26. · Lights • An abstract interface for lights. • Pbrt only supports physically-based lights not based lights,

Point lights

• The above four lights, point light, spotlight, texture light and goniophotometric light are texture light and goniophotometric light are essentially point lights with different energy distributionsdistributions.

Page 13: chap13 light.ppt [相容模式] - 國立臺灣大學 · 2009. 11. 26. · Lights • An abstract interface for lights. • Pbrt only supports physically-based lights not based lights,

Directional lightsDistantLight::DistantLight(Transform &light2world,Spectrum &radiance, Vector &dir):Light(light2world) {p , ) g ( g ) {

lightDir = Normalize(LightToWorld(dir));L = radiance;

}Spectrum DistantLight::Sample_L(Point &p, Vector *wi,

VisibilityTester *visibility) const {VisibilityTester *visibility) const {wi = lightDir;visibility->SetRay(p, *wi);y y(p, )return L;

}Spectrum Power(const Scene *scene) {

Point wldC; float wldR;scene->WorldBound() BoundingSphere(&wldC &wldR);scene->WorldBound().BoundingSphere(&wldC, &wldR); return L * M_PI * wldR * wldR;

}

Page 14: chap13 light.ppt [相容模式] - 國立臺灣大學 · 2009. 11. 26. · Lights • An abstract interface for lights. • Pbrt only supports physically-based lights not based lights,

Area light

• Defined by a shapeshape

• Uniform over the surfacethe surface

• Single-sided• Sample L isn’t • Sample_L isn t

straightforward because a point because a point could have contributions from multiple directions (chap15).

Page 15: chap13 light.ppt [相容模式] - 國立臺灣大學 · 2009. 11. 26. · Lights • An abstract interface for lights. • Pbrt only supports physically-based lights not based lights,

Infinite area light

area light+distant light

morning skylightmorning skylight

environment light

Page 16: chap13 light.ppt [相容模式] - 國立臺灣大學 · 2009. 11. 26. · Lights • An abstract interface for lights. • Pbrt only supports physically-based lights not based lights,

Infinite area light

midday skylight

sunset skylightsunset skylight

Page 17: chap13 light.ppt [相容模式] - 國立臺灣大學 · 2009. 11. 26. · Lights • An abstract interface for lights. • Pbrt only supports physically-based lights not based lights,

Infinite area lightInfiniteAreaLight(Transform &light2world,Spectrum &L,

int ns, string &texmap) : Light(light2world, ns) {radianceMap NULL;radianceMap = NULL;if (texmap != "") {

int w, h;Spectrum *texels = ReadImage(texmap, &w, &h);if (texels) radianceMap =

new MIPMap<Spectrum>(w, h, texels);delete[] texels;

}Lbase = L;;

}Spectrum Power(const Scene *scene) const {

Point wldC; float wldR;Point wldC; float wldR;scene->WorldBound().BoundingSphere(&wldC, &wldR);return Lbase * radianceMap->Lookup(.5f, .5f, .5f)

* M PI * wldR * wldR;* M_PI * wldR * wldR;}

Page 18: chap13 light.ppt [相容模式] - 國立臺灣大學 · 2009. 11. 26. · Lights • An abstract interface for lights. • Pbrt only supports physically-based lights not based lights,

Infinite area lightSpectrum Le(const RayDifferential &r) {

Vector w = r.d; for those rays which miss the scene;Spectrum L = Lbase;if (radianceMap != NULL) {

y

Vector wh = Normalize(WorldToLight(w));float s = SphericalPhi(wh) * INV_TWOPI;float t = SphericalTheta(wh) * INV PI;float t = SphericalTheta(wh) * INV_PI;L *= radianceMap->Lookup(s, t);

}}return L;

}