Volume and Participating Media Digital Image Synthesis Yung-Yu Chuang with slides by Pat Hanrahan...
-
Upload
clifford-fletcher -
Category
Documents
-
view
219 -
download
0
Transcript of Volume and Participating Media Digital Image Synthesis Yung-Yu Chuang with slides by Pat Hanrahan...
![Page 1: Volume and Participating Media Digital Image Synthesis Yung-Yu Chuang with slides by Pat Hanrahan and Torsten Moller.](https://reader034.fdocuments.net/reader034/viewer/2022050714/56649d365503460f94a0d9cd/html5/thumbnails/1.jpg)
Volume and Participating Media
Digital Image SynthesisYung-Yu Chuang
with slides by Pat Hanrahan and Torsten Moller
![Page 2: Volume and Participating Media Digital Image Synthesis Yung-Yu Chuang with slides by Pat Hanrahan and Torsten Moller.](https://reader034.fdocuments.net/reader034/viewer/2022050714/56649d365503460f94a0d9cd/html5/thumbnails/2.jpg)
Participating media
• We have by far assumed that the scene is in a vacuum. Hence, radiance is constant along the ray. However, some real-world situations such as fog and smoke attenuate and scatter light. They participate in rendering.
• Natural phenomena– Fog, smoke, fire– Atmosphere haze– Beam of light through clouds– Subsurface scattering
![Page 3: Volume and Participating Media Digital Image Synthesis Yung-Yu Chuang with slides by Pat Hanrahan and Torsten Moller.](https://reader034.fdocuments.net/reader034/viewer/2022050714/56649d365503460f94a0d9cd/html5/thumbnails/3.jpg)
Volume scattering processes
• Absorption (conversion from light to other forms)
• Emission (contribution from luminous particles)
• Scattering (direction change of particles)– Out-scattering– In-scattering– Single scattering v.s. multiple scattering
• Homogeneous v.s. inhomogeneous(heterogeneous)
emission in-scattering out-scattering absorption
![Page 4: Volume and Participating Media Digital Image Synthesis Yung-Yu Chuang with slides by Pat Hanrahan and Torsten Moller.](https://reader034.fdocuments.net/reader034/viewer/2022050714/56649d365503460f94a0d9cd/html5/thumbnails/4.jpg)
Single scattering and multiple scattering
single scattering multiple scattering
attenuation
![Page 5: Volume and Participating Media Digital Image Synthesis Yung-Yu Chuang with slides by Pat Hanrahan and Torsten Moller.](https://reader034.fdocuments.net/reader034/viewer/2022050714/56649d365503460f94a0d9cd/html5/thumbnails/5.jpg)
Absorption
The reduction of energy due to conversion of light to another form of energy (e.g. heat)
L dL( , )L x
ds
Absorption cross-section:
Probability of being absorbed per unit length
),( xa
dsxLxxdL a ),(),(),(
),( xa
![Page 6: Volume and Participating Media Digital Image Synthesis Yung-Yu Chuang with slides by Pat Hanrahan and Torsten Moller.](https://reader034.fdocuments.net/reader034/viewer/2022050714/56649d365503460f94a0d9cd/html5/thumbnails/6.jpg)
Transmittance
Optical distance or depth
Homogenous media: constant
( )a as s a
s
a sdssxxLsxL0
)('),'(),(ln),(ln
x
'sx
0
's
s
dsxLxxdL a ),(),(),(
dsxxL
xdLa ),(
),(
),(
s
a
sx
x
dssxxL
xdL
0
'),'(),'(
),'(
s
a dssxs0
'),'()(
![Page 7: Volume and Participating Media Digital Image Synthesis Yung-Yu Chuang with slides by Pat Hanrahan and Torsten Moller.](https://reader034.fdocuments.net/reader034/viewer/2022050714/56649d365503460f94a0d9cd/html5/thumbnails/7.jpg)
Transmittance
Opacity
Transmittance and opacity
),( xL
),( sxL
)(sT
s
a sdssxxLsxL0
)('),'(),(ln),(ln
dsxLxxdL a ),(),(),(
dsxxL
xdLa ),(
),(
),(
s
a
sx
x
dssxxL
xdL
0
'),'(),'(
),'(
),()(),(),( )( xLsTxLesxL s
)()( sesT
)(1)( sTs
![Page 8: Volume and Participating Media Digital Image Synthesis Yung-Yu Chuang with slides by Pat Hanrahan and Torsten Moller.](https://reader034.fdocuments.net/reader034/viewer/2022050714/56649d365503460f94a0d9cd/html5/thumbnails/8.jpg)
Absorption
![Page 9: Volume and Participating Media Digital Image Synthesis Yung-Yu Chuang with slides by Pat Hanrahan and Torsten Moller.](https://reader034.fdocuments.net/reader034/viewer/2022050714/56649d365503460f94a0d9cd/html5/thumbnails/9.jpg)
Emission
• Energy that is added to the environment from luminous particles due to chemical, thermal, or nuclear processes that convert energy to visible light.
• : emitted radiance added to a ray per unit distance at a point x in direction
),( xLve
dsxLxdL ve ),(),(
L dL( , )L x
ds
),( xLve
![Page 10: Volume and Participating Media Digital Image Synthesis Yung-Yu Chuang with slides by Pat Hanrahan and Torsten Moller.](https://reader034.fdocuments.net/reader034/viewer/2022050714/56649d365503460f94a0d9cd/html5/thumbnails/10.jpg)
Emission
![Page 11: Volume and Participating Media Digital Image Synthesis Yung-Yu Chuang with slides by Pat Hanrahan and Torsten Moller.](https://reader034.fdocuments.net/reader034/viewer/2022050714/56649d365503460f94a0d9cd/html5/thumbnails/11.jpg)
Scattering cross-section:
Probability of being scattered per unit length
Out-scattering
Light heading in one direction is scattered to otherdirections due to collisions with particles
L dL( , )L x
ds
s
dsxLxxdL s ),(),(),(
),( xs
![Page 12: Volume and Participating Media Digital Image Synthesis Yung-Yu Chuang with slides by Pat Hanrahan and Torsten Moller.](https://reader034.fdocuments.net/reader034/viewer/2022050714/56649d365503460f94a0d9cd/html5/thumbnails/12.jpg)
Extinction
L dL( , )L x
ds
t a s Total cross-section
Attenuation due to both absorption and scattering
s s
t a s
W
Albedo
dsxLxxdL t ),(),(),(
),( xt
s
t dssxs0
'),'()(
![Page 13: Volume and Participating Media Digital Image Synthesis Yung-Yu Chuang with slides by Pat Hanrahan and Torsten Moller.](https://reader034.fdocuments.net/reader034/viewer/2022050714/56649d365503460f94a0d9cd/html5/thumbnails/13.jpg)
Extinction
• Beam transmittance
s: distance between x and x’
• Properties of Tr:• In vaccum• Multiplicative• Beer’s law (in homogeneous medium)
x
'x
),( xL
s
t dssx
exxTr 0'),'(
)'(
1)'( xxTr
)'''()'()''( xxTrxxTrxxTr
stexxTr )'(
![Page 14: Volume and Participating Media Digital Image Synthesis Yung-Yu Chuang with slides by Pat Hanrahan and Torsten Moller.](https://reader034.fdocuments.net/reader034/viewer/2022050714/56649d365503460f94a0d9cd/html5/thumbnails/14.jpg)
In-scattering
Increased radiance due to scattering from other directions
L dL( , )L x
ds
( ) ( )p p Reciprocity
2
( ) 1S
p d Energy conserving
Phase function ( )p
),( xs
dsdxLxpxxdL s
')',()',(),(),(
'
![Page 15: Volume and Participating Media Digital Image Synthesis Yung-Yu Chuang with slides by Pat Hanrahan and Torsten Moller.](https://reader034.fdocuments.net/reader034/viewer/2022050714/56649d365503460f94a0d9cd/html5/thumbnails/15.jpg)
Source term
• S is determined by– Volume emission– Phase function which describes the angular
distribution of scattered radiation (volume analog of BSDF for surfaces)
dsxSxdL ),(),(
')',()',(),(),(),( dxLxpxxLxS sve
![Page 16: Volume and Participating Media Digital Image Synthesis Yung-Yu Chuang with slides by Pat Hanrahan and Torsten Moller.](https://reader034.fdocuments.net/reader034/viewer/2022050714/56649d365503460f94a0d9cd/html5/thumbnails/16.jpg)
Phase functions
Phase angle
Phase functions(from the phase of the moon)
1.Isotropic- simple
2.Rayleigh- Molecules (useful for very small particles whose
radii smaller than wavelength of light)3. Mie scattering
- small spheres (based on Maxwell’s equations; good model for scattering in the atmosphere due to water droplets and fog)
cos
1(cos )
4p
2
4
3 1 cos(cos )
4p
![Page 17: Volume and Participating Media Digital Image Synthesis Yung-Yu Chuang with slides by Pat Hanrahan and Torsten Moller.](https://reader034.fdocuments.net/reader034/viewer/2022050714/56649d365503460f94a0d9cd/html5/thumbnails/17.jpg)
Henyey-Greenstein phase function
2
32 2
1 1(cos )
4 1 2 cos
gp
g g
Empirical phase function
0
2 (cos )cosp d g
g: average phase angle
g = -0.3
g = 0.6
![Page 18: Volume and Participating Media Digital Image Synthesis Yung-Yu Chuang with slides by Pat Hanrahan and Torsten Moller.](https://reader034.fdocuments.net/reader034/viewer/2022050714/56649d365503460f94a0d9cd/html5/thumbnails/18.jpg)
Henyey-Greenstein approximation
• Any phase function can be written in terms of a series of Legendre polynomials (typically, n<4)
0
)(cos)12(4
1)(cos
nnnPbnp
...
)35(2
1)(
)13(2
1)(
)(
1)(
33
22
1
0
xxxP
xxP
xxP
xP
cos)(cos)(cos
)(cos),(cos1
1
dPp
Ppb
n
nn
![Page 19: Volume and Participating Media Digital Image Synthesis Yung-Yu Chuang with slides by Pat Hanrahan and Torsten Moller.](https://reader034.fdocuments.net/reader034/viewer/2022050714/56649d365503460f94a0d9cd/html5/thumbnails/19.jpg)
Schlick approximation
• Approximation to Henyey-Greenstein
• K plays a similar role like g– 0: isotropic – -1: back scattering– Could use
2
2
)cos1(
1
4
1)(cos
k
kpSchlick
255.055.1 ggk
![Page 20: Volume and Participating Media Digital Image Synthesis Yung-Yu Chuang with slides by Pat Hanrahan and Torsten Moller.](https://reader034.fdocuments.net/reader034/viewer/2022050714/56649d365503460f94a0d9cd/html5/thumbnails/20.jpg)
Importance sampling for HG
2
otherwise
21
11
|2|
1
0 if21
cos22
2
gg
gg
g
g
2
32 2
1 1(cos )
4 1 2 cos
gp
g g
![Page 21: Volume and Participating Media Digital Image Synthesis Yung-Yu Chuang with slides by Pat Hanrahan and Torsten Moller.](https://reader034.fdocuments.net/reader034/viewer/2022050714/56649d365503460f94a0d9cd/html5/thumbnails/21.jpg)
• core/volume.* volume/*class VolumeRegion {public:
bool IntersectP(Ray &ray, float *t0, float *t1); Spectrum sigma_a(Point &, Vector &);Spectrum sigma_s(Point &, Vector &);Spectrum Lve(Point &, Vector &);
// phase functions: pbrt has isotropic, Rayleigh, // Mie, HG, Schlick
virtual float p(Point &, Vector &, Vector &); // attenuation coefficient; s_a+s_s
Spectrum sigma_t(Point &, Vector &); // calculate optical thickness by Monte Carlo or // closed-form solution
Spectrum Tau(Ray &ray, float step=1., float offset=0.5);};
Pbrt implementation
t0
t1
t0 t1step
offset
![Page 22: Volume and Participating Media Digital Image Synthesis Yung-Yu Chuang with slides by Pat Hanrahan and Torsten Moller.](https://reader034.fdocuments.net/reader034/viewer/2022050714/56649d365503460f94a0d9cd/html5/thumbnails/22.jpg)
• Determined by (constant)– and– g in phase function– Emission– Spatial extent
Spectrum Tau(Ray &ray, float, float){
float t0, t1;
if (!IntersectP(ray,&t0,&t1))
return 0.;
return Distance(ray(t0),ray(t1)) * (sig_a + sig_s);
}
Homogenous volume
veL
s a
![Page 23: Volume and Participating Media Digital Image Synthesis Yung-Yu Chuang with slides by Pat Hanrahan and Torsten Moller.](https://reader034.fdocuments.net/reader034/viewer/2022050714/56649d365503460f94a0d9cd/html5/thumbnails/23.jpg)
Homogenous volume
![Page 24: Volume and Participating Media Digital Image Synthesis Yung-Yu Chuang with slides by Pat Hanrahan and Torsten Moller.](https://reader034.fdocuments.net/reader034/viewer/2022050714/56649d365503460f94a0d9cd/html5/thumbnails/24.jpg)
Varying-density volumes
• Density is varying in the medium and the volume scattering properties at a point is the product of the density at that point and some baseline value.
• DensityRegion– 3D grid, VolumeGrid– Exponential density, ExponentialDensity
![Page 25: Volume and Participating Media Digital Image Synthesis Yung-Yu Chuang with slides by Pat Hanrahan and Torsten Moller.](https://reader034.fdocuments.net/reader034/viewer/2022050714/56649d365503460f94a0d9cd/html5/thumbnails/25.jpg)
DensityRegionclass DensityRegion : public VolumeRegion {public: DensityRegion(Spectrum &sig_a, Spectrum &sig_s,
float g, Spectrum &Le, Transform &VolumeToWorld); float Density(Point &Pobj) const = 0; sigma_a(Point &p, Vector &) {
return Density(WorldToVolume(p)) * sig_a; }Spectrum sigma_s(Point &p, Vector &) { return Density(WorldToVolume(p)) * sig_s; }Spectrum sigma_t(Point &p, Vector &) { return Density(WorldToVolume(p))*(sig_a+sig_s);}Spectrum Lve(Point &p, Vector &) { return Density(WorldToVolume(p)) * le; }
...protected:
Transform WorldToVolume;Spectrum sig_a, sig_s, le;float g;
};
![Page 26: Volume and Participating Media Digital Image Synthesis Yung-Yu Chuang with slides by Pat Hanrahan and Torsten Moller.](https://reader034.fdocuments.net/reader034/viewer/2022050714/56649d365503460f94a0d9cd/html5/thumbnails/26.jpg)
VolumeGrid
• Standard form of given data• Tri-linear interpolation of data to give
continuous volume• Often used in volume rendering
![Page 27: Volume and Participating Media Digital Image Synthesis Yung-Yu Chuang with slides by Pat Hanrahan and Torsten Moller.](https://reader034.fdocuments.net/reader034/viewer/2022050714/56649d365503460f94a0d9cd/html5/thumbnails/27.jpg)
VolumeGrid
VolumeGrid(Spectrum &sa, Spectrum &ss, float gg,
Spectrum &emit, BBox &e, Transform &v2w,
int nx, int ny, int nz, const float *d);
float VolumeGrid::Density(const Point &Pobj) const {
if (!extent.Inside(Pobj)) return 0;
// Compute voxel coordinates and offsets
float voxx = (Pobj.x - extent.pMin.x) /
(extent.pMax.x - extent.pMin.x) * nx - .5f;
float voxy = (Pobj.y - extent.pMin.y) /
(extent.pMax.y - extent.pMin.y) * ny - .5f;
float voxz = (Pobj.z - extent.pMin.z) /
(extent.pMax.z - extent.pMin.z) * nz - .5f;
![Page 28: Volume and Participating Media Digital Image Synthesis Yung-Yu Chuang with slides by Pat Hanrahan and Torsten Moller.](https://reader034.fdocuments.net/reader034/viewer/2022050714/56649d365503460f94a0d9cd/html5/thumbnails/28.jpg)
VolumeGrid int vx = Floor2Int(voxx);
int vy = Floor2Int(voxy);
int vz = Floor2Int(voxz);
float dx = voxx - vx, dy = voxy - vy, dz = voxz - vz;
// Trilinearly interpolate density values
float d00 = Lerp(dx, D(vx, vy, vz), D(vx+1, vy, vz));
float d10 = Lerp(dx, D(vx, vy+1, vz), D(vx+1, vy+1, vz));
float d01 = Lerp(dx, D(vx, vy, vz+1), D(vx+1, vy, vz+1));
float d11 = Lerp(dx, D(vx, vy+1,vz+1),D(vx+1,vy+1,vz+1));
float d0 = Lerp(dy, d00, d10);
float d1 = Lerp(dy, d01, d11);
return Lerp(dz, d0, d1);
}
float D(int x, int y, int z) { x = Clamp(x, 0, nx-1); y = Clamp(y, 0, ny-1); z = Clamp(z, 0, nz-1); return density[z*nx*ny+y*nx+x];}
![Page 29: Volume and Participating Media Digital Image Synthesis Yung-Yu Chuang with slides by Pat Hanrahan and Torsten Moller.](https://reader034.fdocuments.net/reader034/viewer/2022050714/56649d365503460f94a0d9cd/html5/thumbnails/29.jpg)
Exponential density
• Given by
• Where h is the height in the direction of the up-vector
bhaehd )( ExponentialDensity
![Page 30: Volume and Participating Media Digital Image Synthesis Yung-Yu Chuang with slides by Pat Hanrahan and Torsten Moller.](https://reader034.fdocuments.net/reader034/viewer/2022050714/56649d365503460f94a0d9cd/html5/thumbnails/30.jpg)
ExponentialDensityclass ExponentialDensity : public DensityRegion {public:
ExponentialDensity(Spectrum &sa, Spectrum &ss, float g, Spectrum &emit, BBox &e, Transform &v2w, float aa, float bb, Vector &up) ...
float Density(const Point &Pobj) const {if (!extent.Inside(Pobj)) return 0;float height = Dot(Pobj - extent.pMin,
upDir);return a * expf(-b * height);
}private:
BBox extent;float a, b;Vector upDir;
}; extent.pMin
upDirPobj
h
![Page 31: Volume and Participating Media Digital Image Synthesis Yung-Yu Chuang with slides by Pat Hanrahan and Torsten Moller.](https://reader034.fdocuments.net/reader034/viewer/2022050714/56649d365503460f94a0d9cd/html5/thumbnails/31.jpg)
Light transport
• Emission + in-scattering (source term)
• Absorption + out-scattering (extinction)
• Combined
')',()',(),(),(),( dxLxpxxLxS sve
dsxLxxdL t ),(),(),(
),(),(),(),(
xSxLxds
xdLt
dsxSxdL ),(),(
![Page 32: Volume and Participating Media Digital Image Synthesis Yung-Yu Chuang with slides by Pat Hanrahan and Torsten Moller.](https://reader034.fdocuments.net/reader034/viewer/2022050714/56649d365503460f94a0d9cd/html5/thumbnails/32.jpg)
Infinite length, no surface
• Assume that there is no surface and we have an infinite length, we have the solution
dsxSxxTrxL ),'()'(),(0
x'x ),( xL
),'( xS
)'( xxTr
sxx '
s
t dssx
exxTr 0'),'(
)'(
![Page 33: Volume and Participating Media Digital Image Synthesis Yung-Yu Chuang with slides by Pat Hanrahan and Torsten Moller.](https://reader034.fdocuments.net/reader034/viewer/2022050714/56649d365503460f94a0d9cd/html5/thumbnails/33.jpg)
With surface
• The solution
dsxSxxTrxLxxTrxLd
),'()'(),()(),(0
00
x),( xL
0x
d
)( 0 xxTr ),( 0 xL
from the surface point x0
![Page 34: Volume and Participating Media Digital Image Synthesis Yung-Yu Chuang with slides by Pat Hanrahan and Torsten Moller.](https://reader034.fdocuments.net/reader034/viewer/2022050714/56649d365503460f94a0d9cd/html5/thumbnails/34.jpg)
With surface
• The solution
dsxSxxTrxLxxTrxLd
),'()'(),()(),(0
00
x),( xL
0x
d
)( 0 xxTr ),( 0 xL
from the surface point x0from the participating media
sxx '
'x
![Page 35: Volume and Participating Media Digital Image Synthesis Yung-Yu Chuang with slides by Pat Hanrahan and Torsten Moller.](https://reader034.fdocuments.net/reader034/viewer/2022050714/56649d365503460f94a0d9cd/html5/thumbnails/35.jpg)
Simple atmosphere model
Assumptions• Homogenous media• Constant source term (airlight)
• Fog• Haze
( )( )t
L sL s S
s
( ) 1 t ts sL s e S e C S C
![Page 36: Volume and Participating Media Digital Image Synthesis Yung-Yu Chuang with slides by Pat Hanrahan and Torsten Moller.](https://reader034.fdocuments.net/reader034/viewer/2022050714/56649d365503460f94a0d9cd/html5/thumbnails/36.jpg)
OpenGL fog model
fogin CffCC )1(
)()( zdensityezf
2)()( zdensityezf
startend
zendzf
)(
GL_EXP
GL_EXP2
GL_LINEAR
From http://wiki.delphigl.com/index.php/glFog
![Page 37: Volume and Participating Media Digital Image Synthesis Yung-Yu Chuang with slides by Pat Hanrahan and Torsten Moller.](https://reader034.fdocuments.net/reader034/viewer/2022050714/56649d365503460f94a0d9cd/html5/thumbnails/37.jpg)
VolumeIntegrator
class VolumeIntegrator : public Integrator {
public:
virtual Spectrum Transmittance(
const Scene *scene,
const Renderer *renderer,
const RayDifferential &ray,
const Sample *sample, …) const = 0;
};
Pick up functions Preprocess(), RequestSamples() and Li() from Integrator.
Beam transmittance for a given ray from mint to maxt
![Page 38: Volume and Participating Media Digital Image Synthesis Yung-Yu Chuang with slides by Pat Hanrahan and Torsten Moller.](https://reader034.fdocuments.net/reader034/viewer/2022050714/56649d365503460f94a0d9cd/html5/thumbnails/38.jpg)
Emission only
• Solution for the emission-only simplification
• Monte Carlo estimator
),'(),'( xLxS ev
dsxLxxTrxLxxTrxL ev
d
),'()'(),()(),(0
00
N
iievi
N
i i
ievi xLxxTrN
tt
xp
xLxxTr
N 1
01
1
),()()(
),()(1
![Page 39: Volume and Participating Media Digital Image Synthesis Yung-Yu Chuang with slides by Pat Hanrahan and Torsten Moller.](https://reader034.fdocuments.net/reader034/viewer/2022050714/56649d365503460f94a0d9cd/html5/thumbnails/39.jpg)
Emission only
• Use multiplicativity of Tr
• Break up integral and compute it incrementally by ray marching
• Tr can get small in a long ray– Early ray termination– Either use Russian Roulette or deterministically
)()()( 11 xxTrxxTrxxTr iiii
![Page 40: Volume and Participating Media Digital Image Synthesis Yung-Yu Chuang with slides by Pat Hanrahan and Torsten Moller.](https://reader034.fdocuments.net/reader034/viewer/2022050714/56649d365503460f94a0d9cd/html5/thumbnails/40.jpg)
EmissionIntegratorclass EmissionIntegrator : public VolumeIntegrator {public:
EmissionIntegrator(float ss) { stepSize = ss; } void RequestSamples(Sampler *sampler, Sample *sample, Scene *scene); Spectrum Li(Scene *scene, Renderer *renderer, RayDifferential &ray, Sample *sample, RNG &rng, Spectrum *transmittance, MemoryArena &arena); Spectrum Transmittance(Scene *scene, Renderer *, RayDifferential &ray, Sample *sample, RNG &rng, MemoryArena &arena);private:
float stepSize;int tauSampleOffset, scatterSampleOffset;
}; single 1D sample for each
![Page 41: Volume and Participating Media Digital Image Synthesis Yung-Yu Chuang with slides by Pat Hanrahan and Torsten Moller.](https://reader034.fdocuments.net/reader034/viewer/2022050714/56649d365503460f94a0d9cd/html5/thumbnails/41.jpg)
EmissionIntegrator::Transmittance
if (!scene->volumeRegion) return Spectrum(1);
float step, offset;if (sample) { step = stepSize; offset = sample->oneD[tauSampleOffset][0];} else { step = 4.f * stepSize; offset = rng.RandomFloat();}Spectrum tau = scene->volumeRegion->tau(ray, step, offset);return Exp(-tau);
use larger steps for shadow andindirect rays for efficiency
)()( sesT
s
a dssxs0
'),'()(
smaple is non-NULL only for camera rays
![Page 42: Volume and Participating Media Digital Image Synthesis Yung-Yu Chuang with slides by Pat Hanrahan and Torsten Moller.](https://reader034.fdocuments.net/reader034/viewer/2022050714/56649d365503460f94a0d9cd/html5/thumbnails/42.jpg)
EmissionIntegrator::LiVolumeRegion *vr = scene->volumeRegion;float t0, t1;if (!vr || !vr->IntersectP(ray, &t0, &t1) || (t1-t0) == 0.f) { *T = Spectrum(1.f); return 0.f;}// Do emission-only volume integration in vrSpectrum Lv(0.);// Prepare for volume integration steppingint nSamples = Ceil2Int((t1-t0) / stepSize);float step = (t1 - t0) / nSamples;Spectrum Tr(1.f);Point p = ray(t0), pPrev;Vector w = -ray.d;t0 += sample->oneD[scatterSampleOffset][0] * step;
![Page 43: Volume and Participating Media Digital Image Synthesis Yung-Yu Chuang with slides by Pat Hanrahan and Torsten Moller.](https://reader034.fdocuments.net/reader034/viewer/2022050714/56649d365503460f94a0d9cd/html5/thumbnails/43.jpg)
EmissionIntegrator::Lifor (int i = 0; i < nSamples; ++i, t0 += step) { pPrev = p; p = ray(t0); Ray tauRay(pPrev, p - pPrev, 0.f, 1.f, ray.time, ray.depth); Spectrum stepTau = vr->tau(tauRay,.5f * stepSize, rng.RandomFloat()); Tr *= Exp(-stepTau); // Possibly terminate if transmittance is small if (Tr.y() < 1e-3) { const float continueProb = .5f; if (rng.RandomFloat() > continueProb) break; Tr /= continueProb; } // Compute emission-only source term at _p_ Lv += Tr * vr->Lve(p, w, ray.time);}*T = Tr;return Lv * step;
N
iievi xLxxTr
N
tt
1
01 ),()(
)()()( 11 xxTrxxTrxxTr iiii
![Page 44: Volume and Participating Media Digital Image Synthesis Yung-Yu Chuang with slides by Pat Hanrahan and Torsten Moller.](https://reader034.fdocuments.net/reader034/viewer/2022050714/56649d365503460f94a0d9cd/html5/thumbnails/44.jpg)
Emission only
exponential density
![Page 45: Volume and Participating Media Digital Image Synthesis Yung-Yu Chuang with slides by Pat Hanrahan and Torsten Moller.](https://reader034.fdocuments.net/reader034/viewer/2022050714/56649d365503460f94a0d9cd/html5/thumbnails/45.jpg)
• Consider incidence radiance due to direct illumination
Single scattering
dsxSxxTrxLxxTrxLd
),'()'(),()(),(0
00
')',()',(),(),(),( dxLxpxxLxS dsve
x
),( 0 xL
'x
![Page 46: Volume and Participating Media Digital Image Synthesis Yung-Yu Chuang with slides by Pat Hanrahan and Torsten Moller.](https://reader034.fdocuments.net/reader034/viewer/2022050714/56649d365503460f94a0d9cd/html5/thumbnails/46.jpg)
')',()',(),(),(),( dxLxpxxLxS dsve
• Consider incidence radiance due to direct illumination
Single scattering
x
),( 0 xL
dsxSxxTrxLxxTrxLd
),'()'(),()(),(0
00
![Page 47: Volume and Participating Media Digital Image Synthesis Yung-Yu Chuang with slides by Pat Hanrahan and Torsten Moller.](https://reader034.fdocuments.net/reader034/viewer/2022050714/56649d365503460f94a0d9cd/html5/thumbnails/47.jpg)
• Ld may be attenuated by participating media
• At each point of the integral, we could use multiple importance sampling to get
But, in practice, we can just pick up light source randomly.
Single scattering
')',()',(),( dxLxpx ds
![Page 48: Volume and Participating Media Digital Image Synthesis Yung-Yu Chuang with slides by Pat Hanrahan and Torsten Moller.](https://reader034.fdocuments.net/reader034/viewer/2022050714/56649d365503460f94a0d9cd/html5/thumbnails/48.jpg)
Single scattering
![Page 49: Volume and Participating Media Digital Image Synthesis Yung-Yu Chuang with slides by Pat Hanrahan and Torsten Moller.](https://reader034.fdocuments.net/reader034/viewer/2022050714/56649d365503460f94a0d9cd/html5/thumbnails/49.jpg)
Subsurface scattering
• The bidirectional scattering-surface reflectance distribution function (BSSRDF)
),,,( iioo ppS
o
op ip
i
dAdpLppSpL i
A H
iiiiiiooooo 2
cos),(),,,(),(
![Page 50: Volume and Participating Media Digital Image Synthesis Yung-Yu Chuang with slides by Pat Hanrahan and Torsten Moller.](https://reader034.fdocuments.net/reader034/viewer/2022050714/56649d365503460f94a0d9cd/html5/thumbnails/50.jpg)
Subsurface scattering
• Translucent materials have similar mechanism for light scattering as participating media. Thus, path tracing could be used.
• However, many translucent objects have very high albedo. Taken milk as an example, after 100 scattering events, 87.5% of the incident light is still carried by a path, 51% after 500 and 26% after 1,000.
• Efficiently rendering these kinds of translucent scattering media requires a different approach.
![Page 51: Volume and Participating Media Digital Image Synthesis Yung-Yu Chuang with slides by Pat Hanrahan and Torsten Moller.](https://reader034.fdocuments.net/reader034/viewer/2022050714/56649d365503460f94a0d9cd/html5/thumbnails/51.jpg)
Highly translucent materials
![Page 52: Volume and Participating Media Digital Image Synthesis Yung-Yu Chuang with slides by Pat Hanrahan and Torsten Moller.](https://reader034.fdocuments.net/reader034/viewer/2022050714/56649d365503460f94a0d9cd/html5/thumbnails/52.jpg)
Main idea
• Assume that the material is homogeneous and the medium is semi-infinite, we can use diffusion approximation to describe the equlibrium distribution of illumination.
• There is a solution to the diffusion equation by using a dipole of two light sources to approximate the overall scattering.
![Page 53: Volume and Participating Media Digital Image Synthesis Yung-Yu Chuang with slides by Pat Hanrahan and Torsten Moller.](https://reader034.fdocuments.net/reader034/viewer/2022050714/56649d365503460f94a0d9cd/html5/thumbnails/53.jpg)
Highly scattering media
![Page 54: Volume and Participating Media Digital Image Synthesis Yung-Yu Chuang with slides by Pat Hanrahan and Torsten Moller.](https://reader034.fdocuments.net/reader034/viewer/2022050714/56649d365503460f94a0d9cd/html5/thumbnails/54.jpg)
Principle of similarity
g=0.9
n=10
n=100 n=1000
For high albedo objects, an anisotropically scattering phase function becomes isotropic after many scattering events.
![Page 55: Volume and Participating Media Digital Image Synthesis Yung-Yu Chuang with slides by Pat Hanrahan and Torsten Moller.](https://reader034.fdocuments.net/reader034/viewer/2022050714/56649d365503460f94a0d9cd/html5/thumbnails/55.jpg)
Diffusion approximation
• The reduced scattering coefficient
• The reduced extinction coefficient
ss g )1('
''sat
![Page 56: Volume and Participating Media Digital Image Synthesis Yung-Yu Chuang with slides by Pat Hanrahan and Torsten Moller.](https://reader034.fdocuments.net/reader034/viewer/2022050714/56649d365503460f94a0d9cd/html5/thumbnails/56.jpg)
Diffusion approximation
i
pp
i pp
e
Dpp
itr
4),(
p
For a point light sourceat with powerp
The fluence at from isp
ip
dpLpS i 2
),()(fluence
attr '3
)3(1 'tD
diffusioncoefficient
![Page 57: Volume and Participating Media Digital Image Synthesis Yung-Yu Chuang with slides by Pat Hanrahan and Torsten Moller.](https://reader034.fdocuments.net/reader034/viewer/2022050714/56649d365503460f94a0d9cd/html5/thumbnails/57.jpg)
Dipole diffusion approximation
d
d0z
zz
zz
ADz 2
)(1
)(1
dr
dr
F
FA
iH iirdr dnFF 2
),()(
![Page 58: Volume and Participating Media Digital Image Synthesis Yung-Yu Chuang with slides by Pat Hanrahan and Torsten Moller.](https://reader034.fdocuments.net/reader034/viewer/2022050714/56649d365503460f94a0d9cd/html5/thumbnails/58.jpg)
Dipole diffusion approximation
d
e
d
e
Dpp
dd
oi
trtr
4),(
ip op
Light enters the materialat )0,,( iii yxp
),,( zyx ii
positive lightat
),,( zyx ii
negative lightat
oii pzyxd ),,(
oii pzyxd ),,(
![Page 59: Volume and Participating Media Digital Image Synthesis Yung-Yu Chuang with slides by Pat Hanrahan and Torsten Moller.](https://reader034.fdocuments.net/reader034/viewer/2022050714/56649d365503460f94a0d9cd/html5/thumbnails/59.jpg)
Dipole diffusion approximation
• Put all together
33
)1()1(
4
1),(
d
edz
d
edzppR
dtr
dtr
oid
trtr
oi pp
),( oid ppR
![Page 60: Volume and Participating Media Digital Image Synthesis Yung-Yu Chuang with slides by Pat Hanrahan and Torsten Moller.](https://reader034.fdocuments.net/reader034/viewer/2022050714/56649d365503460f94a0d9cd/html5/thumbnails/60.jpg)
BSSRDF
• BSSRDF based on the diffusion subsurface reflectance approximation
),()(),(1
),,,( iitoidootiioo FppRFppS
i
ip op
o
![Page 61: Volume and Participating Media Digital Image Synthesis Yung-Yu Chuang with slides by Pat Hanrahan and Torsten Moller.](https://reader034.fdocuments.net/reader034/viewer/2022050714/56649d365503460f94a0d9cd/html5/thumbnails/61.jpg)
Evaluating BSSRDF
dAdpLFppRF
pL
iiiii
A H
iitoidoot
ooo
cos),(),()(),(1
),(
2
op
o
i
ip
![Page 62: Volume and Participating Media Digital Image Synthesis Yung-Yu Chuang with slides by Pat Hanrahan and Torsten Moller.](https://reader034.fdocuments.net/reader034/viewer/2022050714/56649d365503460f94a0d9cd/html5/thumbnails/62.jpg)
Evaluating BSSRDF
dAdpLFppRF
pL
A H
iiiiiiitoidoot
ooo
2
cos),(),()(),(1
),(
)()( iidt pEF
For homogeneous materials, io
dApEppRFF
pL
A
ioiddtot
ooo
)()()(),(1
),(
![Page 63: Volume and Participating Media Digital Image Synthesis Yung-Yu Chuang with slides by Pat Hanrahan and Torsten Moller.](https://reader034.fdocuments.net/reader034/viewer/2022050714/56649d365503460f94a0d9cd/html5/thumbnails/63.jpg)
Evaluating BSSRDF
dApEppRFF
pL
A
ioiddtot
ooo
)()()(),(1
),(
op
o
ip
j
jjojd
A
ioidoo AEppRdApEppRpM )()()()(
![Page 64: Volume and Participating Media Digital Image Synthesis Yung-Yu Chuang with slides by Pat Hanrahan and Torsten Moller.](https://reader034.fdocuments.net/reader034/viewer/2022050714/56649d365503460f94a0d9cd/html5/thumbnails/64.jpg)
Single scattering
![Page 65: Volume and Participating Media Digital Image Synthesis Yung-Yu Chuang with slides by Pat Hanrahan and Torsten Moller.](https://reader034.fdocuments.net/reader034/viewer/2022050714/56649d365503460f94a0d9cd/html5/thumbnails/65.jpg)
Solutions
• Path tracing• Photon mapping• Hierarchical approach (Jensen 2002)
![Page 66: Volume and Participating Media Digital Image Synthesis Yung-Yu Chuang with slides by Pat Hanrahan and Torsten Moller.](https://reader034.fdocuments.net/reader034/viewer/2022050714/56649d365503460f94a0d9cd/html5/thumbnails/66.jpg)
Three main components
• Sample a large number of random points on the surface and their incident irradiance is computed.
• Create a hierarchy of these points, progressively clustering nearby points and summing their irradiance values.
• At rendering, use a hierarchical integration algorithm to evaluate the subsurface scattering equation.
![Page 67: Volume and Participating Media Digital Image Synthesis Yung-Yu Chuang with slides by Pat Hanrahan and Torsten Moller.](https://reader034.fdocuments.net/reader034/viewer/2022050714/56649d365503460f94a0d9cd/html5/thumbnails/67.jpg)
DipoleSubsurfaceIntegrator
class DipoleSubsurfaceIntegrator : public
SurfaceIntegrator {
…
int maxSpecularDepth;
float maxError, minSampleDist;
string filename;
vector<IrradiancePoint> irradiancePoints;
BBox octreeBounds;
SubsurfaceOctreeNode *octree;
}
![Page 68: Volume and Participating Media Digital Image Synthesis Yung-Yu Chuang with slides by Pat Hanrahan and Torsten Moller.](https://reader034.fdocuments.net/reader034/viewer/2022050714/56649d365503460f94a0d9cd/html5/thumbnails/68.jpg)
Sample points
• Samples should be reasonably uniformly distributed. A Poisson disk distribution of points is a good choice.
• There are some algorithms for generating such distributions. Pbrt uses a 3D version of dart throwing by performing Poisson sphere tests. The algorithm terminates when a few thousand tests have been rejected in a row.
good
Bad, but dipole is dad for this anyway
![Page 69: Volume and Participating Media Digital Image Synthesis Yung-Yu Chuang with slides by Pat Hanrahan and Torsten Moller.](https://reader034.fdocuments.net/reader034/viewer/2022050714/56649d365503460f94a0d9cd/html5/thumbnails/69.jpg)
Sample points
![Page 70: Volume and Participating Media Digital Image Synthesis Yung-Yu Chuang with slides by Pat Hanrahan and Torsten Moller.](https://reader034.fdocuments.net/reader034/viewer/2022050714/56649d365503460f94a0d9cd/html5/thumbnails/70.jpg)
Preprocess
if (scene->lights.size() == 0) return;
<Get SurfacePoints for translucent objects>
<Compute irradiance values at sample points>
<Create octree of clustered irradiance samples>
![Page 71: Volume and Participating Media Digital Image Synthesis Yung-Yu Chuang with slides by Pat Hanrahan and Torsten Moller.](https://reader034.fdocuments.net/reader034/viewer/2022050714/56649d365503460f94a0d9cd/html5/thumbnails/71.jpg)
<Compute irradiance values at sample points>
for (uint32_t i = 0; i < pts.size(); ++i) {
SurfacePoint &sp = pts[i];
Spectrum E(0.f);
for (int j = 0; j < scene->lights.size(); ++j) {
<Add irradiance from light at point>
}
irradiancePoints.push_back(IrradiancePoint(sp, E));
}
iH iii dpLpE 2|cos|),()(
j j
jji
p
pL
NpE
)(
|cos|),(1)(
i
p
Sp
SurfacePoint
Calculate direct lighting only; it is possible to include indirect lighting but more expensive
![Page 72: Volume and Participating Media Digital Image Synthesis Yung-Yu Chuang with slides by Pat Hanrahan and Torsten Moller.](https://reader034.fdocuments.net/reader034/viewer/2022050714/56649d365503460f94a0d9cd/html5/thumbnails/72.jpg)
IrradiancePoint
struct SurfacePoint {
…
Point p;
Normal n;
float area, rayEpsilon;
};
struct IrradiancePoint {
…
Point p;
Normal n;
Spectrum E;
float area, rayEpsilon;
};
![Page 73: Volume and Participating Media Digital Image Synthesis Yung-Yu Chuang with slides by Pat Hanrahan and Torsten Moller.](https://reader034.fdocuments.net/reader034/viewer/2022050714/56649d365503460f94a0d9cd/html5/thumbnails/73.jpg)
<Create octree of clustered irradiance samples>
octree = octreeArena.Alloc<SubsurfaceOctreeNode>();
for (int i = 0; i < irradiancePoints.size(); ++i)
octreeBounds = Union(octreeBounds,
irradiancePoints[i].p);
for (int i = 0; i < irradiancePoints.size(); ++i)
octree->Insert(octreeBounds, &irradiancePoints[i],
octreeArena);
octree->InitHierarchy();
Computes representative position, irradiance and area for each node.Positions are weighted by irradiance values to emphasize the pointswith higher irradiance values.
![Page 74: Volume and Participating Media Digital Image Synthesis Yung-Yu Chuang with slides by Pat Hanrahan and Torsten Moller.](https://reader034.fdocuments.net/reader034/viewer/2022050714/56649d365503460f94a0d9cd/html5/thumbnails/74.jpg)
Li
if (bssrdf && octree) {
Spectrum sigma_a = bssrdf->sigma_a();
Spectrum sigmap_s = bssrdf->sigma_prime_s();
Spectrum sigmap_t = sigmap_s + sigma_a;
if (!sigmap_t.IsBlack()) {
DiffusionReflectance Rd(sigma_a, sigmap_s,
bssrdf->eta());
Mo = octree->Mo(octreeBounds, p, Rd, …);
FresnelDielectric fresnel(1.f, bssrdf->eta());
Ft = Spectrum(1)- fresnel.Evaluate(AbsDot(wo,n));
float Fdt = 1.f - Fdr(bssrdf->eta());
L += (INV_PI * Ft) * (Fdt * Mo);
}
}
)()(),(1
),( oodtotooo pMFFpL
![Page 75: Volume and Participating Media Digital Image Synthesis Yung-Yu Chuang with slides by Pat Hanrahan and Torsten Moller.](https://reader034.fdocuments.net/reader034/viewer/2022050714/56649d365503460f94a0d9cd/html5/thumbnails/75.jpg)
Li
L += UniformSampleAllLights(…);
if (ray.depth < maxSpecularDepth) {
L += SpecularReflect(…);
L += SpecularTransmit(…);
}
return L;
![Page 76: Volume and Participating Media Digital Image Synthesis Yung-Yu Chuang with slides by Pat Hanrahan and Torsten Moller.](https://reader034.fdocuments.net/reader034/viewer/2022050714/56649d365503460f94a0d9cd/html5/thumbnails/76.jpg)
Mo
j
jjojdoo AEppRpM )()(
op
![Page 77: Volume and Participating Media Digital Image Synthesis Yung-Yu Chuang with slides by Pat Hanrahan and Torsten Moller.](https://reader034.fdocuments.net/reader034/viewer/2022050714/56649d365503460f94a0d9cd/html5/thumbnails/77.jpg)
SubsurfaceOctreeNode::Mo
Spectrum SubsurfaceOctreeNode::Mo(BBox &nodeBound,
Point &pt, DiffusionReflectance &Rd, float maxError
{
float dw = sumArea / DistanceSquared(pt, p);
if (dw < maxError && !nodeBound.Inside(pt))
return Rd(DistanceSquared(pt, p)) * E * sumArea;
Spectrum Mo = 0.f;
If extended solid angle of the node is small enough and the point is not inside the node, use the representative values of the node to estimate.
![Page 78: Volume and Participating Media Digital Image Synthesis Yung-Yu Chuang with slides by Pat Hanrahan and Torsten Moller.](https://reader034.fdocuments.net/reader034/viewer/2022050714/56649d365503460f94a0d9cd/html5/thumbnails/78.jpg)
SubsurfaceOctreeNode::Mo
if (isLeaf)
for (int i = 0; i < 8; ++i) {
if (!ips[i]) break;
Mo += Rd(DistanceSquared(pt, ips[i]->p))
* ips[i]->E * ips[i]->area;
}
else {
Point pMid=.5f*nodeBound.pMin+.5f*nodeBound.pMax;
for (int child = 0; child < 8; ++child) {
if (!children[child]) continue;
Bbox cBound=octreeChildBound(child,nodeBound,pMid);
Mo+=children[child]->Mo(cBound, pt, Rd, maxError);
}
}
return Mo;
}
![Page 79: Volume and Participating Media Digital Image Synthesis Yung-Yu Chuang with slides by Pat Hanrahan and Torsten Moller.](https://reader034.fdocuments.net/reader034/viewer/2022050714/56649d365503460f94a0d9cd/html5/thumbnails/79.jpg)
Setting parameters
• It is remarkably unintuitive to set values of the absorption coefficient and the modified scattering coefficient.
![Page 80: Volume and Participating Media Digital Image Synthesis Yung-Yu Chuang with slides by Pat Hanrahan and Torsten Moller.](https://reader034.fdocuments.net/reader034/viewer/2022050714/56649d365503460f94a0d9cd/html5/thumbnails/80.jpg)
Marble: BRDF versus BSSRDF
![Page 81: Volume and Participating Media Digital Image Synthesis Yung-Yu Chuang with slides by Pat Hanrahan and Torsten Moller.](https://reader034.fdocuments.net/reader034/viewer/2022050714/56649d365503460f94a0d9cd/html5/thumbnails/81.jpg)
Marble: MCRT versus BSSRDF
![Page 82: Volume and Participating Media Digital Image Synthesis Yung-Yu Chuang with slides by Pat Hanrahan and Torsten Moller.](https://reader034.fdocuments.net/reader034/viewer/2022050714/56649d365503460f94a0d9cd/html5/thumbnails/82.jpg)
Milk
surface reflection translucency
![Page 83: Volume and Participating Media Digital Image Synthesis Yung-Yu Chuang with slides by Pat Hanrahan and Torsten Moller.](https://reader034.fdocuments.net/reader034/viewer/2022050714/56649d365503460f94a0d9cd/html5/thumbnails/83.jpg)
Skin
surface reflection translucency