• 沒有找到結果。

Participating media

N/A
N/A
Protected

Academic year: 2022

Share "Participating media"

Copied!
12
0
0

加載中.... (立即查看全文)

全文

(1)

Volume and Participating Media

Digital Image Synthesis g g y Yung-Yu Chuang

with slides by Pat Hanrahan and Torsten Moller

Participating media

• We have by far assumed that the scene is in a vacuum Hence radiance is constant along the vacuum. Hence, radiance is constant along the ray. However, some real-world situations such as fog and smoke attenuate and scatter light as fog and smoke attenuate and scatter light.

They participate in rendering.

N t l h

• Natural phenomena

– Fog, smoke, fire – Atmosphere haze – Beam of light through

clouds

– Subsurface scattering

Volume scattering processes

• Absorption (conversion from light to other forms)

E i i

• 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) Homogeneous v.s. inhomogeneous(heterogeneous)

emission in-scattering out-scattering absorption

Single scattering and multiple scattering

attenuation attenuation

single scattering multiple scattering

(2)

Absorption

The reduction of energy due to conversion of light to another form of energy (e g heat)

to another form of energy (e.g. heat)

LdL

( )

L x ( , )  LdL

L x

ds ) , ( 

a

x

ds

ds x L x x

dL ( x  )    ( x  ) L ( x  ) ds dL ( ,  )   

a

( ,  ) ( ,  )

Absorption cross-section:

a

( x ,  )

Probability of being absorbed per unit length

Transmittance

ds x L x x

dL ( ,  )   

a

( ,  ) ( ,  )

dL (  )

xs

dL ( ' )

s

s

ds x x

L x dL

a

( , )

) , (

) ,

(  

s

a s

x

x

ds s

x x L

x dL

0

' ) , ' ) (

, ' (

) , '

(   

s L x

a

x s ds s

x L

0

) ( ' ) , ' ( )

, ( ln ) , (

ln       

x Optical distance or depth

x

p p 0

 ' s

xs '

s a

x s ds s

0

' ) , ' ( )

(   

Homogenous media: constant ( ) s s

    

a

s

0

a

( ) s

a

s

    

Transmittance and opacity

ds x L x x

dL ( ,  )   

a

( ,  ) ( ,  )

dL (  )

xs

dL ( ' )

s

s

ds x x

L x dL

a

( , ) )

, (

) ,

(  

s

a s

x

x

ds s

x x L

x dL

0

' ) , ' ) (

, ' (

) , '

(   

) ( L

s L x

a

x s ds s

x L

0

) ( ' ) , ' ( )

, ( ln ) , (

ln       

) ( ) ( ) ( )

(

( )

L T L

L ( x s  ,  ) e

(s)

L ( x ,  ) T

( s ) L ( x ,  ) L ( x ,  )

L  

s

Transmittance T (s )

)

)

(

( s e

s

T

Opacity

 ) , ( x s   L  )

( s e T

) ( 1 )

( T L ( xs  ,  )

) ( 1 )

( s T

s

 

Absorption

(3)

Emission

• Energy that is added to the environment from luminous particles due to chemical thermal or luminous particles due to chemical, thermal, or nuclear processes that convert energy to visible light

light.

• : emitted radiance added to a ray per it di t t i t i di ti

) , ( xL

ve

unit distance at a point x in direction

ds x L x

dL ( x  )  L ( x  ) ds dL ( ,  )

ve

( ,  )

LdL ( , )

L x ( , )  LdL

L x

ds ) , ( xL

ve

ds

Emission

Out-scattering

Light heading in one direction is scattered to other directions due to collisions with particles

directions due to collisions with particles

LdL ( , )

L x

) , ( 

s

x ds

d L dL (  )  (  ) (  ) Scattering cross-section:

ds x L x x

dL ( ,  )   

s

( ,  ) ( ,  ) Scattering cross-section:

Probability of being scattered per unit length

s

y g p g

Extinction

LdL ( , )

L x ( , ) x   LdL

ds ) , ( 

t

x ds

ds x L x x

dL ( ,  )   

t

( ,  ) ( ,  )

t a s

     Total cross-section

 

Alb d

s s

t a s

W  

  

 

Albedo

Attenuation due to both absorption and scattering

s

t

x s ds

s ) ( ' , ) '

(   

s

t

x s ds

0

) , (

)

(   

(4)

Extinction

• Beam transmittance x '

s

x ) , ( x

L

s

t x s ds

e x x

Tr

0

' ) , ' (

) ' (

s: distance between x and x’ x

• Properties of Tr:

• In vaccum Tr ( x  x ' )  1

• In vaccum

• Multiplicative

B ’ l (i h di )

1 ) ( x  xTr

) '' ' ( ) ' (

) ''

( x x Tr x x Tr x x

Tr     

• Beer’s law (in homogeneous medium)

ts

e x x

Tr ( x  )' xe

Tr (  )

In-scattering

Increased radiance due to scattering from other directions

directions

LdL

( )

L x

 '

LdL ( , )

L x

ds ) , ( 

s

xds

ds d x L x

p x x

dL

s

 

 

( , )( , ' ) ( , ' ) '

) ,

(       

Phase function p (     )

s

p

 

 

) , ( ) ,

( ) , ( ) , (

( ) ( )

p      p     Reciprocity

( ) 1

p      d

Energy conserving Phase function p (    )

( ) ( )

p     p   

2

( ) 1

S

p     d

Source term

' ) ' , ( ) ' , ( ) , ( ) , ( ) ,

( xL x   xp x   L xd

S

ve s

ds x S x

dL ( ,  )  ( ,  )

• S is determined by

Volume emission – Volume emission

– Phase function which describes the angular

distribution of scattered radiation (volume analog of distribution of scattered radiation (volume analog of BSDF for surfaces)

Phase functions

Phase angle cos         Phase functions

(from the phase of the moon)

 

( p )

1. Isotropic 1

(cos ) p  4

  - simple

2. Rayleigh

2 4

3 1 cos (cos )

p  4 

 

- Molecules (useful for very small particles whose radii smaller than wavelength of light)

3 Mi tt i 3. Mie scattering

- small spheres (based on Maxwell’s equations; good

model for scattering in the atmosphere due to water

model for scattering in the atmosphere due to water

droplets and fog)

(5)

Henyey-Greenstein phase function

Empirical phase function

1 1

2

p p

g = -0.3

 

2

2 32

1 1

(cos )

4 1 2 cos

p g

g g

  

 

 

g = 0.6

0

2 p (cos ) cos d g

    

0

g : average phase angle

Henyey-Greenstein approximation

• Any phase function can be written in terms of a series of Legendre polynomials (typically n<4) series of Legendre polynomials (typically, n<4)

 1 ( 2 1 ) (cos ) )

(cos n b P

p   

0

) (cos )

1 2 4 (

) (cos

n

n n

P b n

p

 

1 ) (

P

 ) ( )

( P

b

) (

1 ) (

1 0

x x P

x P

cos ) (cos ) (cos

) (cos ), (cos

1

d P

p

P p

b

n n



) 1 3 2 ( ) 1

(

2

2

x x

P  

 ) (cos ) cos (cos

1

d P

p

n

) 3 5 2 ( ) 1

(

3

3

x x x

P  

...

Schlick approximation

• Approximation to Henyey-Greenstein

2 2

) cos 1 (

1 4 ) 1

(cos   

k

p

Schlick

  k

• K plays a similar role like g

) cos 1 (

4   k

• K plays a similar role like g

– 0: isotropic

-1: back scattering – -1: back scattering

– Could use k  1 . 55 g  0 . 55 g

2

Importance sampling for HG

1 1

2

(cos ) g

p  

2

32

(cos )

4 1 2 cos

p

g g

    



  2

 

 2 if 0

1

2

g

 

 

 

 

 

 

 

 

otherwise 2

1 1 1

| 2

|

cos 1

2 2 2

g g g g

g

 

 

  1   2 

| 2

| g g g

(6)

Pbrt implementation

• core/volume.* volume/*

class VolumeRegion { t0 t1

public:

bool IntersectP(Ray &ray, float *t0, float *t1);

Spectrum sigma a(Point &, Vector &);p g _ ( , ) Spectrum sigma_s(Point &, Vector &);

Spectrum Lve(Point &, Vector &);

// phase functions: pbrt has isotropic, Rayleigh, // phase functions: pbrt has isotropic, Rayleigh, // Mie, HG, Schlick

virtual float p(Point &, Vector &, Vector &);

// attenuation coefficient; s a+s s // attenuation coefficient; s_a+s_s Spectrum sigma_t(Point &, Vector &);

// calculate optical thickness by Monte Carlo or

// l d f l ti

// closed-form solution

Spectrum Tau(Ray &ray, float step=1., float offset=0.5);

t0 step t1

}; t0 step t1

offset

Homogenous volume

• Determined by (constant)

d

– and

– g in phase function

E i i L

s

a

– Emission – Spatial extent

L

ve

Spectrum Tau(Ray &ray, float, float){

float t0 t1;

float t0, t1;

if (!IntersectP(ray,&t0,&t1)) return 0.;

return Distance(ray(t0),ray(t1)) * (sig_a + sig_s);

}

Homogenous volume Varying-density volumes

• Density is varying in the medium and the volume scattering properties at a point is the product of scattering properties at a point is the product of the density at that point and some baseline value

value.

• DensityRegion

– 3D grid, VolumeGrid

– Exponential density, ExponentialDensity

(7)

DensityRegion

class 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 &) {p g _ ( p, ) {

return Density(WorldToVolume(p)) * sig_s; } Spectrum sigma_t(Point &p, Vector &) {

return Density(WorldToVolume(p))*(sig a+sig s);}

return Density(WorldToVolume(p)) (sig_a+sig_s);}

Spectrum Lve(Point &p, Vector &) {

return Density(WorldToVolume(p)) * le; } ...

protected:

Transform WorldToVolume;

S i i l

Spectrum sig_a, sig_s, le;

float g;

};

VolumeGrid

• Standard form of given data

T i li i l i f d i

• Tri-linear interpolation of data to give continuous volume

• Often used in volume rendering

VolumeGrid

VolumeGrid(Spectrum &sa, Spectrum &ss, float gg, Spectrum &emit, BBox &e, Transform &v2w,p , , , 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 // Compute voxel coordinates and offsets float voxx = (Pobj.x - extent.pMin.x) /

(extent.pMax.x - extent.pMin.x) * nx - .5f;

( p p )

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;

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 // 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);p( y, , );

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);

d i [ * * * ]

return density[z*nx*ny+y*nx+x];

}

(8)

Exponential density

• Given by

h

bh

d ( )

• Where h is the height

ae

bh

h

d ( ) 

ExponentialDensity in the direction of

the up-vector

ExponentialDensity

class 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 {y( j) { if (!extent.Inside(Pobj)) return 0;

float height = Dot(Pobj - extent.pMin, upDir);

return a * expf(-b * height);

return a expf( b height);

} private:

BBox extent; P bj

h BBox extent;

float a, b;

Vector upDir;

}

upDir Pobj

};

extent.pMin

Light transport

• Emission + in-scattering (source term)

' ) ' , ( ) ' , ( ) , ( ) , ( ) ,

( xL x   xp x   L xd

S

ve s

• Absorption + out-scattering (extinction)

ds x S x

dL ( ,  )  ( ,  )

• Absorption + out scattering (extinction)

ds x L x x

dL ( ,  )   

t

( ,  ) ( ,  )

• Combined

) , ( ) , ( ) , ) (

,

(     

x S x L ds x

x dL

t

Infinite length, no surface

• Assume that there is no surface and we have an infinite length we have the solution

infinite length, we have the solution

ds x S x x Tr x

L ( ( , ,  ) )

 ( ( ' ) ) ( ( ' , ,  ) )

0

s t x s ds

T

0

' ) , ' (

) ' (

) ' ( S

x e

x

Tr ( ' )

0

x '

x L ( x ,  )

)  , ' ( xS

) ' ( x x

TrL ( x ,  )

' x s

x '  

(9)

With surface

• The solution

ds x

S x x Tr x

L x x Tr x

L

d

) , ' ( ) ' ( ) , ( ) (

) , (

0 0

0

 

       

from the surface point x

0

) , ( x

0

L

x

) , ( xL

0

x

d ) ( x

0

x

Tr

) , ( xL

With surface

• The solution

ds x

S x x Tr x

L x x Tr x

L

d

) , ' ( ) ' ( ) , ( ) (

) , (

0 0

0

 

       

from the surface point x

0

from the participating media )

, ( x

0

L

x

) , ( xL

0

x

d ) ( x

0

x

Tr

'

x L ( x ,  )

' x sx '  

Simple atmosphere model

Assumptions

H di

• Homogenous media

• Constant source term (airlight)

( ) ( )

L s L S

 ( )

t

( )

s L s S

s

   

 

( ) 1

s s

L ( )1

ts

S

ts

C S C

L s   e

Se

C S C

• Fog

• Haze

• Haze

OpenGL fog model

fog

in

f C

fC

C   ( 1  )

) (d

GL_EXP

)

)

(

( z e

densityz

f

GL EXP2

)2

)

(

( z e

densityz

f

_

z

f end

) (

GL_LINEAR

start z end

f ( )  

From http://wiki.delphigl.com/index.php/glFog

(10)

VolumeIntegrator

class VolumeIntegrator : public Integrator { public: Beam transmittance for a given public:

virtual Spectrum Transmittance(

const Scene *scene

g ray from mint to maxt const Scene *scene,

const Ray &ray, const Sample *sample const Sample *sample, float *alpha) const = 0;

} };

Pick up functions Preprocess(), RequestSamples()

d f

and Li() from Integrator.

Emission only

• Solution for the emission-only simplification

) , ' ( ) , '

( x    L x  

S

ev

d

ds x

L x x Tr x

L x x Tr x

L

ev

d

) , ' ( ) ' ( ) , ( ) (

) , (

0 0

0

 

       

• Monte Carlo estimator

N

i

i ev i

N

i

i ev

i

Tr x x L x

N t t x

p x L x x Tr

N

1

0 1 1

) , ( ) ) (

(

) , ( ) (

1  

i

i

p x

i

N

N

1

( )

1

Emission only

• Use multiplicativity of Tr

) (

) (

)

( x x Tr x x

1

Tr x

1

x Tr

i

 

i

i

i

• Break up integral and compute it incrementally by ray marching y y g

• Tr can get small in a long ray

– Early ray termination – Early ray termination

– Either use Russian Roulette or deterministically

EmissionIntegrator

class EmissionIntegrator : public VolumeIntegrator { public:

EmissionIntegrator(float ss) { stepSize = ss; } void RequestSamples(Sample *sample, const Scene

*scene);scene);

Spectrum Transmittance(const Scene *, const Ray

&ray, const Sample *sample, float *alpha) const;

Spectrum Li(const Scene * const RayDifferential Spectrum Li(const Scene *, const RayDifferential

&ray, const Sample *sample, float *alpha) const;

private:

float stepSize;

int tauSampleOffset, scatterSampleOffset;

};

single 1D sample for each

};

g p

(11)

EmissionIntegrator::Transmittance

if (!scene->volumeRegion) return Spectrum(1);

float step = float step

sample ? stepSize : 4.f * stepSize;

float offset =

use larger steps for shadow and indirect rays for efficiency

sample ? sample->oneD[tauSampleOffset][0] : RandomFloat();

indirect rays for efficiency

Spectrum tau =

scene->volumeRegion->Tau(ray,step,offset);

return Exp(-tau);

)

)

(

( s e

s

T

s

a

x s ds

s

0

' ) , ' ( )

(   

EmissionIntegrator::Li

VolumeRegion *vr = scene->volumeRegion;

float t0, t1;

if (!vr || !vr->IntersectP(ray, &t0, &t1)) return 0;

// Do emission-only volume integration in vr Spectrum Lv(0 );

Spectrum Lv(0.);

// Prepare for volume integration stepping int N = Ceil2Int((t1-t0) / stepSize);

float step = (t1 - t0) / N;

Spectrum Tr(1.f);

Point p = ray(t0), pPrev;

Point p ray(t0), pPrev;

Vector w = -ray.d;

if (sample)

t0 += sample->oneD[scatterSampleOffset][0]*step;

else

t0 += RandomFloat() * step;() p;

EmissionIntegrator::Li

for (int i = 0; i < N; ++i, t0 += step) { // Advance to sample at t0 and update T pPrev = p;

p = ray(t0);

Spectrum stepTau = vr->Tau(Ray(pPrev,p-pPrev,0,1),

) (

) (

)

( x x Tr x x

1

Tr x

1

x Tr

i

 

i

i

i

.5f * stepSize, RandomFloat());

Tr *= Exp(-stepTau);

// Possibly terminate if transmittance is small

// y

if (Tr.y() < 1e-3) {

const float continueProb = .5f;

if (RandomFloat() > continueProb) break;

if (RandomFloat() > continueProb) break;

Tr /= continueProb;

}

// Compute emission only source term at p // Compute emission-only source term at _p_

Lv += Tr * vr->Lve(p, w);

}

*

t

1

t

0

N

T ( ) L ( )

return Lv * step;

i

i ev

i

x L x

x N

1

Tr

0

1

( ) ( ,  )

Emission only

exponential density

(12)

Single scattering

• Consider incidence radiance due to direct illumination

illumination

ds x S x x Tr x

L x x Tr x

L

d

) , ' ( ) ' ( ) , ( ) (

) ,

( 

0

0

0

' ) ' , ( ) ' , ( ) , ( ) , ( ) ,

( xL x   xp x   L xd

S

ve s

d

) ( L

x )

, ( x

0

L

' x x

Single scattering

• Consider incidence radiance due to direct illumination

illumination

ds x S x x Tr x

L x x Tr x

L

d

) , ' ( ) ' ( ) , ( ) (

) ,

( 

0

0

' ) ' , ( ) ' , ( ) , ( ) , ( ) ,

( xL x   xp x   L xd

S

ve s

d

0

) ( L

x )

, ( x

0

L

x

Single scattering

• L

d

may be attenuated by participating media A h i f h i l ld

• At each point of the integral, we could use multiple importance sampling to get

' ) ' , ( ) ' , ( ) ,

(     

s

xp x L

d

x d

But, in practice, we can just pick up light source randomly

source randomly.

Single scattering

參考文獻

相關文件

In this paper, we propose a practical numerical method based on the LSM and the truncated SVD to reconstruct the support of the inhomogeneity in the acoustic equation with

 Encourage students to ‘retell’ the water cycle afterwards – speaking and writing (individual and/or group work)... In nature, water keeps changing between liquid water and

In the hydrologic cycle, water from oceans, lakes, swamps, rivers, plants, and even you, can turn into water vapor. Water vapor condenses into millions of tiny droplets that

Now, nearly all of the current flows through wire S since it has a much lower resistance than the light bulb. The light bulb does not glow because the current flowing through it

In planning for school-based MOI arrangements for the third cycle, schools may, having due regard to curriculum planning considerations and students’ gradual improvement in

Based on a model for the errors that is presented in the following section, probabilities for these values will be

O.K., let’s study chiral phase transition. Quark

Assuming also that the radius of the orbit does not change and that the change in the speed of the electron due to field is small, find an expression for the change in the