legendre fluids: a unified framework for analytic reduced...

9
Eurographics/ ACM SIGGRAPH Symposium on Computer Animation (2007) D. Metaxas and J. Popovic (Editors) Legendre Fluids: A Unified Framework for Analytic Reduced Space Modeling and Rendering of Participating Media Mohit Gupta and Srinivasa G. Narasimhan Robotics Institute, Carnegie Mellon University Abstract In this paper, we present a unified framework for reduced space modeling and rendering of dynamic and non- homogenous participating media, like snow, smoke, dust and fog. The key idea is to represent the 3D spatial variation of the density, velocity and intensity fields of the media using the same analytic basis. In many situa- tions, natural effects such as mist, outdoor smoke and dust are smooth (low frequency) phenomena, and can be compactly represented by a small number of coefficients of a Legendre polynomial basis. We derive analytic ex- pressions for the derivative and integral operators in the Legendre coefficient space, as well as the triple product integrals of Legendre polynomials. These mathematical results allow us to solve both the Navier-Stokes equations for fluid flow and light transport equations for single scattering efficiently in the reduced Legendre space. Since our technique does not depend on volume grid resolution, we can achieve computational speedups as compared to spatial domain methods while having low memory and pre-computation requirements as compared to data- driven approaches. Also, analytic definition of derivatives and integral operators in the Legendre domain avoids the approximation errors inherent in spatial domain finite difference methods. We demonstrate many interesting visual effects resulting from particles immersed in fluids as well as volumetric scattering in non-homogenous and dynamic participating media, such as fog and mist. Categories and Subject Descriptors (according to ACM CCS): I.3.7 [Computer Graphics]: Three-Dimensional Graphics and Realism 1. Introduction and Related Work Participating media such as smoke, snow, dust, mist and fog exhibit a wide range of visual effects. Such media are charac- terized by their density, velocity and intensity fields that vary across both space and time. Accurate modeling of densities and velocities as well as rendering of intensities of these me- dia is critical for achieving photo-realism in computer graph- ics. Also, many applications like games require interactive changes in lighting, view-point and the medium properties. For such applications, it is imperative to achieve these visual effects in real-time. The first step in realizing this goal of visual realism re- quires modeling the time-varying density and velocity fields of participating media. The Navier-Stokes equations for in- compressible fluid flow [CM90] provide a differential model for simulating the density and velocity fields. Explicit analytic solutions to Navier-Stokes equations are hard to obtain and hence, a number of works that employ numerical finite dif- ference methods (FDM) have been proposed [FM96, FM97, Sta99, Sta01, FF01, FSJ01, NFJ02, SRF05]. Although simple to implement, such schemes require high spatial resolution to minimize the finite differencing numerical errors, plac- ing serious demands on memory and compromising speed. Treuille et al [TMPS03] develop an approach for key-framing of fluid flows that alleviate the discretization errors. How- ever, their approach becomes computationally prohibitive for large grid sizes. More recently, an interesting data-driven ap- proach has been taken to simulate the velocity fields using a reduced dimensional PCA basis [TLP06]. This approach achieves considerable speed-ups and produces impressive re- sults, but at the cost of high memory requirements and lengthy pre-computation. Furthermore, as the authors mention, it is unclear whether the approach generalizes to new fluid flows that are not represented in the pre-computation. The second step towards the goal of creating the desired visual effects is rendering of participating media, which re- quires modeling the intensity fields resulting from volumet- ric scattering. Using the computed density field, the corre- sponding intensity field of the participating medium is then rendered by solving the light transport equation [Cha60]. Analogous to fluid modeling, many works that numerically solve the light transport equation based on FDMs have been proposed [KH84, Max94, Jen01, PM93, EP90, Sak90, LBC94, RT87]. As such, many of the issues related to numerical er- rors must be addressed here as well. While these methods Copyright c 2007 by the Association for Computing Machinery, Inc. Permission to make digital or hard copies of part or all of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, to republish, to post on servers, or to redistribute to lists, requires prior specific permission and/or a fee. Re- quest permissions from Permissions Dept, ACM Inc., fax +1 (212) 869-0481 or e-mail [email protected]. SCA 2007, San Diego, California, August 04 - 05, 2007 c 2007 ACM 978-1-59593-624-4/07/0008 $ 5.00

Upload: others

Post on 07-Mar-2020

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Legendre Fluids: A Unified Framework for Analytic Reduced …ILIM/projects/LT/LegendreFluids/Legendre... · 2012-07-05 · dia is critical for achieving photo-realism in computer

Eurographics/ ACM SIGGRAPH Symposium on Computer Animation (2007)D. Metaxas and J. Popovic (Editors)

Legendre Fluids: A Unified Framework for Analytic ReducedSpace Modeling and Rendering of Participating Media

Mohit Gupta and Srinivasa G. Narasimhan

Robotics Institute, Carnegie Mellon University

AbstractIn this paper, we present a unified framework for reduced space modeling and rendering of dynamic and non-homogenous participating media, like snow, smoke, dust and fog. The key idea is to represent the 3D spatialvariation of the density, velocity and intensity fields of the media using the sameanalytic basis. In many situa-tions, natural effects such as mist, outdoor smoke and dust are smooth (low frequency) phenomena, and can becompactly represented by a small number of coefficients of a Legendre polynomial basis. We derive analytic ex-pressions for the derivative and integral operators in the Legendre coefficient space, as well as the triple productintegrals of Legendre polynomials. These mathematical results allow us to solve both the Navier-Stokes equationsfor fluid flow and light transport equations for single scattering efficiently in the reduced Legendre space. Sinceour technique does not depend on volume grid resolution, we can achieve computational speedups as comparedto spatial domain methods while having low memory and pre-computation requirements as compared to data-driven approaches. Also, analytic definition of derivatives and integral operators in the Legendre domain avoidsthe approximation errors inherent in spatial domain finite difference methods. We demonstrate many interestingvisual effects resulting from particles immersed in fluids as well as volumetricscattering in non-homogenous anddynamic participating media, such as fog and mist.

Categories and Subject Descriptors(according to ACM CCS): I.3.7 [Computer Graphics]: Three-DimensionalGraphics and Realism

1. Introduction and Related Work

Participating media such as smoke, snow, dust, mist and fogexhibit a wide range of visual effects. Such media are charac-terized by their density, velocity and intensity fields that varyacross both space and time. Accurate modeling of densitiesand velocities as well as rendering of intensities of these me-dia is critical for achieving photo-realism in computer graph-ics. Also, many applications like games require interactivechanges in lighting, view-point and the medium properties.For such applications, it is imperative to achieve these visualeffects in real-time.

The first step in realizing this goal of visual realism re-quires modeling the time-varying density and velocity fieldsof participating media. The Navier-Stokes equations for in-compressible fluid flow [CM90] provide a differential modelfor simulating the density and velocity fields. Explicit analyticsolutions to Navier-Stokes equations are hard to obtain andhence, a number of works that employ numerical finite dif-ference methods (FDM) have been proposed [FM96, FM97,Sta99, Sta01, FF01, FSJ01, NFJ02, SRF05]. Although simpleto implement, such schemes require high spatial resolutionto minimize the finite differencing numerical errors, plac-

ing serious demands on memory and compromising speed.Treuille et al [TMPS03] develop an approach for key-framingof fluid flows that alleviate the discretization errors. How-ever, their approach becomes computationally prohibitive forlarge grid sizes. More recently, an interesting data-driven ap-proach has been taken to simulate the velocity fields usinga reduced dimensional PCA basis [TLP06]. This approachachieves considerable speed-ups and produces impressive re-sults, but at the cost of high memory requirements and lengthypre-computation. Furthermore, as the authors mention, it isunclear whether the approach generalizes to new fluid flowsthat are not represented in the pre-computation.

The second step towards the goal of creating the desiredvisual effects is rendering of participating media, which re-quires modeling the intensity fields resulting from volumet-ric scattering. Using the computed density field, the corre-sponding intensity field of the participating medium is thenrendered by solving the light transport equation [Cha60].Analogous to fluid modeling, many works that numericallysolve the light transport equation based on FDMs have beenproposed [KH84,Max94,Jen01,PM93,EP90,Sak90,LBC94,RT87]. As such, many of the issues related to numerical er-rors must be addressed here as well. While these methods

Copyright c© 2007 by the Association for Computing Machinery, Inc.Permission to make digital or hard copies of part or all of this work for personal orclassroom use is granted without fee provided that copies are not made or distributedfor commercial advantage and that copies bear this notice and the full citation on thefirst page. Copyrights for components of this work owned by others than ACM must behonored. Abstracting with credit is permitted. To copy otherwise, to republish, to poston servers, or to redistribute to lists, requires prior specific permission and/or a fee. Re-quest permissions from Permissions Dept, ACM Inc., fax +1 (212) 869-0481 or [email protected] 2007, San Diego, California, August 04 - 05, 2007c© 2007 ACM 978-1-59593-624-4/07/0008 $ 5.00

Page 2: Legendre Fluids: A Unified Framework for Analytic Reduced …ILIM/projects/LT/LegendreFluids/Legendre... · 2012-07-05 · dia is critical for achieving photo-realism in computer

Mohit Gupta & Srinivasa G. Narasimhan / Legendre Fluids

Clear Weather Snow Snow and Mist

Figure 1: Legendre domain 3D fluid simulation and rendering:In this example, we have3000snow flakes being carried by a wind field(Legendre domain fluid simulation). We add mist to the scene using Legendre domain rendering for participating media. Notice further objectsappearing brighter due to the air-light effect, and distantsnow-flakes becoming invisible as the mist density is increased. The clear weatherChristmas image was downloaded from www.survivinggrady.com/2005_12_01_archive.html

can produce impressive visual effects, they are too slow forinteractive applications. Recent hardware-accelerated tech-niques [DYN02, REK∗04, HL01] can significantly decreasethe running times of numerical simulations, although they arespecialized to particular phenomena.

In addition, note that the intensity fields depend on the illu-mination and viewing geometry as well as the scattering prop-erties [NGD∗06,HED05] of the participating medium. More-over, the lighting, viewpoint and the densities of the mediummay change with time. Thus, the pre-computations requiredare too prohibitive for data driven approaches to be appliedto intensity fields. For the special case of homogeneous me-dia, many previous analytic approaches [Max86, SRNN05,JMLH01, NN03] may be used to render the effects of scat-tering in real-time. However, homogeneous media are not thefocus of our work.

The goal of this paper is fast modeling and rendering of dy-namic and non-homogenous participating media, like smoke,dust and fog. The key idea is to represent the 3D spatial vari-ation of the density, velocity and intensity fields using thesame analytic basis. Jos Stam [Sta99] used Fourier basis tosolve the diffusion and projection steps of the fluid simulationpipe-line over a domain with periodic boundary conditions. Inthis work, we use Legendre Polynomials [Cha60] as our basisfunctions. In many situations, natural effects such as mist, out-door smoke and dust are smooth (low frequency) phenomena,and can be compactly represented by a small number of coef-ficients of a Legendre polynomial basis. In this work, we willfocus on optically thin media where single scattering is thedominant form of light transport [SRNN05, NGD∗06]. Un-der these conditions, the common Legendre polynomial ba-sis for different fields allows us to analytically solve both theNavier-Stokes and light transport equations in the reducedLegendre space. It turns out that this solution requires us toanalyze triple product integrals of Legendre polynomials andtheir sparsity [GN07], similar in spirit to the triple productwavelet integrals for relighting [NRH04].

Since all the fields are represented using Legendre poly-nomials, their derivatives (and integrals) can be computedanalytically, thereby avoiding the numerical errors resultingfrom spatial finite differences approximation. Additionally,the compactness of the Legendre domain representations ofnatural effects makes modeling and rendering of such partic-

ipating media very fast. Depending on the number of coef-ficients required, we achieve computational speedups of oneto three orders of magnitude as compared to spatial domaintechniques. At the same time, only a few coefficients must bestored in memory as compared to the full 3D volumes thatmust be stored for the data-driven (eg., PCA) approaches.

The main contribution of this paper is a theoretical one:a unified framework for both fluid simulation and renderingin an analytic reduced space. We believe that this is an im-portant first step towards bridging the gap between model re-duction for fluid simulation and pre-computed radiance trans-fer for rendering. In addition, we believe that the mathemat-ical results derived in the paper are general enough to finduse in many computer graphics applications. We demonstrateseveral visual effects resulting from volumetric scattering intime-varying participating media, such as shadowgrams thatare cast by the medium on a background, mixing of differentgaseous media and airlight effects due to depth disparities inthe scene. We also show fluid simulation results illustratingsnow flakes (see Figure1) and confetti immersed in turbulentwind fields, as well as smoke density fields evolving under theinfluence of user-defined forces.

For the purpose of deriving the unified reduced space simu-lation and rendering framework, we have made several limit-ing assumptions such as smooth (low frequency) phenomena,no objects within the medium, single scattering, orthographicviewing and distant lighting. In Section8, we discuss theselimitations in detail, along with future research directions forextending the technique to more general settings.

2. Physical Models for Participating MediaDynamic and non-homogenous participating media can becharacterized by density, velocity and intensity fields, thatvary across both space and time. Whereas Navier-Stokesequations for incompressible fluid flow model the evolutionof the density and velocity fields over time, the intensity fieldsare rendered using light transport equations. The time evolu-tion of the velocity fieldu is given by [CM90]:

∂u∂ t

= −(u.∇)u−ν∇2u+∇p+b, s.t. ∇.u = 0, (1)

where,ν is the kinematic viscosity,p is the pressure field andb denotes the external forces (the notation used in the paper is

c© Association for Computing Machinery, Inc. 2007.

Page 3: Legendre Fluids: A Unified Framework for Analytic Reduced …ILIM/projects/LT/LegendreFluids/Legendre... · 2012-07-05 · dia is critical for achieving photo-realism in computer

Mohit Gupta & Srinivasa G. Narasimhan / Legendre Fluids

u velocity fieldu♦ ♦−component of velocity fieldr density fieldb external force field

b♦ ♦−component of force fieldEd direct transmission intensity fieldEs scattered intensity fieldν kinematic viscosityσ extinction coefficientβ scattering coefficientθ scattering angle

Ω(θ) scattering phase functionωd lighting directionωs viewing direction

Figure 2: Notation used in our paper.♦ stands for either x, y or z.

Distant Source

Medium

OrthographicCameraE(

,t)x

d

E( ,t)x

s

è

Figure 3: The participating medium is illuminated by a distantlight source and is viewed by an orthographic camera. Under thesingle scattering assumption, the intensity field within the mediumvolume can be split into two sets of light rays: the pre-scattering (di-rect transmission) intensity field Ed(x, t) and post-scattering intensityfield Es(x, t) (shown using red rays).

given in Figure2). Following [Sta99,CM90], Equation1 canbe written as:

∂u∂ t

= P︸︷︷︸pro jection

−(u.∇)u︸ ︷︷ ︸advection

+ ν∇2u︸ ︷︷ ︸di f f usion

+ b︸︷︷︸f orces

(2)

Here,P is a linear operator which projects a vector field toits divergence free component. Equation2 can be resolved bysplitting the right hand side into four sequential steps: (i) ad-vection, (ii) diffusion, (iii) external forces and (iv) projection[Sta99]. Similarly, the time evolution of the density fieldr isgiven by:

∂ r∂ t

= −(u.∇)r︸ ︷︷ ︸advection

− κ∇2r︸ ︷︷ ︸di f f usion

+ −αr︸︷︷︸dissipation

+ Sr︸︷︷︸source

, (3)

where,κ is the diffusion constant,α is the dissipation rateandSr is the source term for density.

Using the density fieldr, we can render the intensity fieldsfor any configuration of illumination and viewing geometry.In this work, we consider optically thin media wheresin-gle scattering is the dominant form of light transport. Fig-ure 3 shows an orthographic camera viewing a participatingmedium that is illuminated by a distant light source. Then, wecan split the intensity fields into two components: thepre-

Orthogonality∫ 1−1Li(x)L j (x)dx= δi j

Derivative L′i(x) = ∑k cikLk(x)

Integral∫

Li(x)dx= ∑k bikLk(x)

Figure 4: Properties of Legendre Polynomials [Cha60].

scattering(direct transmission) intensity fieldEd(x, t), andthe post-scatteringintensity field Es(x, t). Mathematically,these intensity fields can be written as [Cha60]:

(ωd

.∇)

Ed = −σ r ·Ed (4)

(ωs.∇)Es = −σ r ·Es+β r ·Ω(θ) ·Ed (5)

Here,σ andβ are the extinction and scattering coefficientsrespectively andΩ(θ) is the phase function. When the camerais outside the medium, the acquired2D imageof the mediumis simply the boundary of the 3D intensity fieldEs(Figure3).

3. Compact Analytic Representation ofNon-Homogenous Media

The key idea in this paper is to represent the 3D spatial varia-tion of the density, velocity and intensity fields using the sameanalytic basis. We choose to use Legendre polynomials as ba-sis functions. In many situations, natural effects such as mist,outdoor smoke and dust are smooth (low frequency) phenom-ena, and can be compactly represented by a small numberof coefficients. Legendre polynomials are orthogonal, haveglobal support (non-zero over the entire domain), and haveanalytic derivatives and integrals (Figure4). As a result, theyfind wide application in mathematical physics literature inconjunction to solving differential equations [Cha60].

A function f (x) can be represented as a linear combina-tion of Legendre polynomialsLk of different ordersf (x) =∑k FkLk(x), where the Legendre domain coefficients[Fk] canbe computed analytically as:

Fk =

1∫

−1

f (x)Lk(x)dx. (6)

In 3D, we represent a fieldf (x,y,z) that is smooth in x-,y-and z-directions as:

f (x,y,z) = ∑i jk

Fi jkLi(z)L j (y)Lk(x) . (7)

For notational ease, Equation7 is written asf (x,y,z)⇔ [Fi jk ].The Legendre representations for the various fields are givenin Figure5.

4. Analytic Operators in Legendre SpaceIn this section, we derive the legendre space formulations forvarious operators and establish that they are compact, com-putationally efficient, and completely analytic in nature. Forease of exposition, we illustrate the concepts with 1D exam-ples; analysis in 2D and 3D follows in an exactly similar man-ner.

4.1. Derivative OperatorObserve that spatial derivatives appear both in the Navier-Stokes and the light transport equations (2, 3, 4, 5) in the formof gradient and Laplacian operators. Using the property thatderivative of a legendre polynomial can be expressed in termsof lower order legendre polynomials (Figure4), we derive the

c© Association for Computing Machinery, Inc. 2007.

Page 4: Legendre Fluids: A Unified Framework for Analytic Reduced …ILIM/projects/LT/LegendreFluids/Legendre... · 2012-07-05 · dia is critical for achieving photo-realism in computer

Mohit Gupta & Srinivasa G. Narasimhan / Legendre Fluids

Field Spatial⇔ Legendre

Density Field r ⇔ [R]Velocity Field u♦ ⇔ [U♦]

Divergence free Velocity Field u♦ ⇔ [U♦(t)]External Force Field b+ ⇔ [B+(t)]Direct Transmission Intensity FieldEd ⇔ [Id]Scattered Intensity Field Es ⇔ [Is]

Figure 5: Legendre representations of various fields, where♦

stands for x,y or z. In Figures5 and 6, sub-scripts and argumentshave been dropped for brevity. For example, d and[D] should be readas d(x,y,z, t) and[Di jk(t)] respectively.

OperationOperand Result Complexity

Derivative g⇔ [G] ∂∂♦g⇔ D♦ · [G] O(K2)

Integral g⇔ [G]∫

gd♦⇔ I♦ · [G] O(K2)

Product g⇔ [G]g·h⇔ MG · [H] O(K3)h⇔ [H]

Truncation [G] [GT ] = T · [G] O(K2)

Legendre[G] g O(NK)to Spatial

Figure 6: Legendre Space Operators (♦ stands for x,y or z). Nis the size of the spatial grid. K is the size of legendre coefficientrepresentation.

derivative operator in legendre domain, which iscompletelyanalytic, and hence, devoid of the numerical errors resultingfrom the Finite Difference approximation:

f (x) = ∑i

FiLi(x) ⇒ f ′(x) = ∑i

FiL′i(x) (8)

⇒ f ′(x) = ∑k

(

∑i

Fi ∗cik

)Lk(x) . . . (Figure4)

= ∑k

F ′(k)Lk(x)

whereF ′(k) = ∑i Fi ∗cik. We can write this equation in matrixform, with [F ′

k] and[Fi ] as the coefficient vectors correspond-ing to the derivative and the original function respectively.Thederivativeoperator (x-direction) in Legendre Domain isthus given by the matrixDx(i,k) = cik:

[F ′k] = Dx ∗ [Fi ] (9)

Derivatives iny andzand the integral operator can be definedlikewise. Figure6 lists all the legendre space operators that wederive, along with the corresponding time complexity. GivenK as the size of legendre space representation[Fi ], the matrix-vector multiplication requireO(K2) computations. Buildingthe derivative and integral matrices is a one time operation,and takesO(K2) time.

4.2. Product Operator in Legendre DomainThe advection term in the Navier-Stokes equation (2, 3) aswell as the single scattering equation for rendering (4, 5) en-tail multiplication of two fields to compute a third one. Thismotivates investigating the general problem of multiplyingtwo functions,h(x) = f (x).g(x), where both the functions andthe result are represented in the Legendre Basis:

f (x) = ∑j

FjL j (x) g(x) = ∑k

GkLk(x) h(x) = ∑i

HiLi(x)

To compute theith basis coefficient for the result, we use or-thogonality of Legendre Polynomials (see Figure4)

Hi =

1∫

−1

Li(x)h(x)dx=

1∫

−1

Li(x) f (x)g(x)dx

=

1∫

−1

Li(x)

(

∑j

FjL j (x)

)(

∑k

GkLk(x)

)dx

= ∑jk

FjGkTIi jk

whereTIi jk =∫ 1−1Li(x)L j (x)Lk(x)dx is the Legendre Poly-

nomial triple product integral, and can be pre-computed apri-ori. As with the derivative and integral case, we can write theabove equation in matrix form as follows:

[Hi ] = MG∗ [Fj ] = MF ∗ [Gk] (10)

where, MG(i, j) = ∑k GkTIi jk and MF (i,k) = ∑ j FjTIi jk .Given the size of legendre representations asK, the multi-plication matrix hasO(K2) entries. For each entry,O(K)computations are required. Thus, we needO(K3) computa-tions to build the multiplication matrix andO(K2) time forthe matrix-vector multiplication. Therefore, total time com-plexity of legendre space multiplication isO(K3). However,we show that the 3D tensorTI is sparse using theLegendrePolynomials Triple Product Integrals theorem [GN07].Using the theorem, we show that approximately3

4 of the en-tries of the TI tensor are exactly zero. We exploit this sparsityto achieve computational speed-ups in the advection and therendering stages. Indeed, the time required to construct themultiplication matrix can be reduced by a factor of 4 in 1Dand by 43 = 64 in the 3D case.

Lower Order Approximation: Note that multiplying twopolynomials of degreeK each results in a polynomial of de-gree 2K. Therefore, given two functions, each with Legendrerepresentation of sizeK, the Legendre representation of theproduct will have size 2K. For computational savings, it isdesirable to keep the size of the Legendre representation con-stant. To this end, we devise a simple approximation schemeusing theChebyshev Polynomialsto truncate a given Legen-dre representation from 2K terms toK terms, while keep-ing the approximation error low under theL∞ norm [GN07].We define theTruncation Matrix Operator T in legendrespace, such that

[FTi ]︸︷︷︸K×1

= T︸︷︷︸K×2K

∗ [Fi ]︸︷︷︸2K×1

where[Fi ] is the legendre representation of size 2K, and[FTi ]

is the corresponding truncated representation of sizeK. Aswith derivatives and integrals, truncation requires a matrixmultiplication with a time complexity ofO(K2). Building thetruncation matrixT is a one time operation requiringO(K2)operations.

c© Association for Computing Machinery, Inc. 2007.

Page 5: Legendre Fluids: A Unified Framework for Analytic Reduced …ILIM/projects/LT/LegendreFluids/Legendre... · 2012-07-05 · dia is critical for achieving photo-realism in computer

Mohit Gupta & Srinivasa G. Narasimhan / Legendre Fluids

5. Modeling in Legendre DomainUsing the Legendre representations for fields and the op-erators (derivative, multiplication, truncation), we solve theNavier-Stokes equations (2, 3) in the Legendre domain. Forvelocity simulation, we decompose Equation2 into the 4 se-quential steps of advection, diffusion, external forces and pro-jection [Sta99]. Now we show how each of these steps can besimulated in the Legendre domain:

5.1. AdvectionIn the spatial domain, the conservation form of the advectionequation is given by:

∂∂ t

u♦ =−∇ · (uu♦) (11)

= −

(∂∂x

uxu♦ +∂∂y

uyu♦ +∂∂z

uzu♦

)(12)

Subscript♦ denotes eitherx,y or z direction. This form im-plicitly assumes a divergence free velocity field, i.e.∇ ·u = 0.

Legendre space advection equationis then derived by sub-stituting the legendre representations of the fields (Figure5),along with the legendre space derivative and multiplicationoperators (Figure6) in Equation12:

∂∂ t [U♦(t)] = −A· [U♦(t)] (13)

whereA = T︸︷︷︸truncation

·

∑♦

D♦︸︷︷︸derivative

· MU♦s︸ ︷︷ ︸

multiplication

∑♦

(·)♦ is short-hand for(·)x +(·)y +(·)z. For example,∑♦

D♦ ·

MU♦ is expanded asDx ·MUx +Dy ·MUy +Dz·MUz. We updatethe legendre representations of the velocity field by comput-ing the eigen decomposition ofA = AE ·

∧· A−1

E [TLP06]:

[U♦(t +t)] =(

AE ·et·∧·A−1

E

)· [U♦(t)] (14)

A similar approach can be used to update the density field aswell. Since it uses the multiplication operator, the time com-plexity of Legendre advection isO(K3) (Section4), whereK is the number of coefficients. In addition to the computa-tional speed-up, using the completely analytic Legendre do-main derivative operator reduces the numerical dissipation in-herent in the FDM based approximations of the derivative op-erator (Figure7).

(a) Original Field (b) Legendre Advection (c) Spatial Advection

Figure 7: Comparison between Legendre and Spatial domain ad-vection (high intensities signify higher values of the field). Notice, thatthe field after advection in the spatial domain (c) has lower energythan the field resulting from analytic legendre domain advection (b).Spatial advection results in dissipation of energy due to discretizationof the gradient operators. The grid size used for spatial advection was5002, while144coefficients were used for legendre advection.

5.2. DiffusionFor the diffusion step, we solve the implicit form of diffusionequation:(

IN×N −νt ∇2)

u♦ (x, t +t) = u♦ (x, t) (15)

whereN is the total number of simulation grid voxels. Theimplicit form of diffusion equation is more stable than theexplicit form. However, one drawback of the implicit formis that it requires solving a large system of linear equations.Fortunately, in our case, this issue is addressed by solving thediffusion equation in the reduced legendre space. Once again,we use the legendre representation of the fields and the opera-tors (Figures5 and 6) to obtain thelegendre space diffusionequation:

(IK×K −νt D2

)[U♦ (t +t)] = [U♦ (t)] (16)

where,D2 = (Dx)2 +

(Dy)2

+ (Dz)2 is the legendre space

Laplacian operator. Since we solve aK×K linear system, thetime complexity of legendre space diffusion isO(K3). This isa considerable speed-up over solving the(N×N) system inspatial domain.

5.3. External ForcesExternal forces are handled by adding their legendre repre-sentation (Figure5) to that of the velocity field:

[U♦(t +t)] = [U♦(t)]+ [B♦] ·t (17)

5.4. ProjectionThis step ensures that the velocity field is divergence free,which is required to satisfy mass-conservation. For the pro-jection step, we use the implicit definition of the projectionoperatorP:

∇2q = ∇ ·u u = Pu = u−∇q (18)

This step requires solving the following Poisson system ofequation for the scalar fieldq: ∇2q = ∇ ·u. u, the divergencefree component ofu (∇ · u = 0), is then computed by sub-tracting the gradient ofq from u. The Poisson equation canbe formulated as a linear system of equations by discretizingthe ∇2 operator in the spatial domain. Analogously, we candefinePL, the projection operator in the legendre space im-plicitly as follows:

D2 · [Q] = ∑♦

D♦ · [U♦(t)] (19)

[U♦(t)] = PL · [U♦(t)] = [U♦(t)]−D♦ · [Q] (20)

Hence, in legendre space projection step, we need to solve thelinear system of equations in the unknown vector[Q] (Equa-tion 19), requiringO(K3) time. As with diffusion, this is aconsiderable speed-up over solving the(N×N) linear systemin spatial domain.As an additional advantage, using the an-alytic definitions of the derivative operators in all the simula-tion steps alleviates the numerical errors resulting from spatialfinite difference approximations.

c© Association for Computing Machinery, Inc. 2007.

Page 6: Legendre Fluids: A Unified Framework for Analytic Reduced …ILIM/projects/LT/LegendreFluids/Legendre... · 2012-07-05 · dia is critical for achieving photo-realism in computer

Mohit Gupta & Srinivasa G. Narasimhan / Legendre Fluids

5.5. Density DissipationFor density simulation, Equation3 is solved in the legendrespace. The advection, diffusion and source terms are handledin a way similar to velocity simulation. The dissipation termis then solved in the legendre space as follows:

(1+tα) · [R(t +t)] = [R(t)] (21)

Size of the Legendre representation:Figure8 illustrates thetime-evolution of 2D density and velocity fields for differ-ent sizes of Legendre representations. We start with the samelow frequency density and velocity fields and apply the sameforces throughout the 3 different Legendre domain simula-tions. We can observe that more coefficients allow for higherfrequencies and vorticities as the density and velocity fieldsevolve. In Figures9, 10 and 11, we also provide theoreticaland empirical computational complexity of our framework asa function of the size of the Legendre representation (K). Auser can use these as a guide for choosing the Legendre rep-resentation size that best addresses the demands (speed/ highfrequency detail) of a particular application.

6. Rendering in Legendre SpaceRendering requires solving the light transport equations (4,5)in the Legendre domain using techniques similar to those usedfor the Navier-Stokes equations.

6.1. Direct Transmission intensity fieldAs earlier, substituting Legendre representations of variousfields and Legendre operators (Figures5 and 6) into Equa-tion 4, we get:

(

∑♦

ωd♦D♦

)· [Id] = −σT ·MR · [Id]

⇒ Lωd · [Id(t)] = 0 (22)

whereLωd =

(

∑♦

ωd♦

D♦ +σT ·MR

).

6.2. Scattered intensity fieldSimilarly, we can project Equation5 into the Legendre do-main:(

∑♦

ωs♦D♦

)· [Is]=−σT ·MR · [Is] + βΩ(θ) ·T ·MR · [Id]

⇒ Lωs · [Is] = βΩ(θ) ·T ·MR · [Id] (23)

whereLωs =

(

∑♦

ωs♦

D♦ +σT ·MR

).

In the legendre space, both the light scattering equations arethus formulated as linear systems of equations in the un-knowns [Id] (22) and [Is] (23). Along with the boundaryconditions, which can be formulated as additional linear con-straints, these systems can be solved inO(K3) time.

Imagine a camera observing the medium from the outside

Initial Density Field Initial Velocity Field

Evolved Density Fields

16co

effic

ient

s36

coef

ficie

nts

64co

effic

ient

s

Evolved Velocity Fields

16co

effic

ient

s36

coef

ficie

nts

64co

effic

ient

s

8th second 16th second 32nd secondFigure 8: 2D Legendre domain Simulation results:Evolution ofdensity and velocity for different number of Legendre coefficients.More coefficients allow higher frequencies andvorticities in the den-sity and velocity fields.

(Figure 3). Then, theimage recorded is given by the scat-tering intensity fieldEs at the domain boundary:

Es(x,y,z, t) = ∑i jk

Isi jkLi(x)L j (y)Lk(z) (24)

If the image resolution isS, then time-complexity of imagecomputation isO(SK). Note that the image computation stepis output-sensitive, and can easily be parallelized. Our Legen-dre domain modeling and rendering framework is summa-rized in Figure9.

c© Association for Computing Machinery, Inc. 2007.

Page 7: Legendre Fluids: A Unified Framework for Analytic Reduced …ILIM/projects/LT/LegendreFluids/Legendre... · 2012-07-05 · dia is critical for achieving photo-realism in computer

Mohit Gupta & Srinivasa G. Narasimhan / Legendre Fluids

For every time step:

• Update Velocity and Density FieldsAdvection (13) and Diffusion (16) O(K3)Forces/Source (17) O(K2)Projection(19, 20) O(K3)

• Update Intensity FieldsDirect Transmission(22), Scattered (23) O(K3)

• Compute Image (24) O(SK)

Figure 9: Legendre domain Rendering algorithm:K is the size ofLegendre space representations and S is the image resolution.

Number of Legendre Coefficients16 36 64 144

Spa

tialG

ridS

ize

2002 500X 250X 75X 10X3002 1250X 625X 187X 25X4002 2500X 1250X 375X 50X5002 5000X 2500X 750X 100X

Figure 10: Typical computational speed-ups for 2D simulation andrendering in Legendre domain as compared to the spatial domain.

7. ResultsOur results show that Legendre polynomials can express a va-riety of interesting density and force distributions compactly,thereby letting the user manipulate the densities, velocitiesand forces globally to produce the desired effects.

Particles immersed in dynamic fluid media:Figure12 andFigure1 show simulations of 500 pieces of confetti and 3000snow-flakes respectively being carried by a wind field sim-ulated using 216 Legendre coefficients each. We can noticevorticities being created in the confetti example due to theturbulent behavior of the wind field. On the other hand, thesnow flakes are carried by a more gentle,breeze-likewind.We encourage the reader to view the animation results in thesupplementary video.

Simulation of smoke and advection of scattering albedos:Figure14 shows a vertically upwards axial impulse appliedto a vase shapedsmoke density field. Since the impulse isapplied for a short duration, the density field dissolves to-wards the end of the simulation. For the first time, we alsoshow advection of the optical properties of the medium (scat-tering albedos), in addition to the physical properties (densi-ties and velocities), resulting in completely new colors andappearances as the medium evolves under external forces.

Single Scattering based rendering of participating me-dia: We demonstrate the visual effects of both relightingthe medium under the single scattering model, and varyingthe viewpoint and scattering albedos, as the medium evolvesunder user defined forces (supplementary video). We alsoshow interesting effects of shadowgrams that are cast by themedium on a background plane (Figures13and 14).

3D Visual effects resulting from volumetric scattering innon-homogenous and dynamic participating media:In theexamples of Figure15and Figure1, we add non-homogenousmist to scenes with large depth variation. Notice how dis-tant objects appear brighter due to the airlight [Kos24] effect.Reproducing such effects accurately, particularly for non-

Number of Legendre Coefficients

Spa

tialG

ridS

ize

64 125 216203 100X 25X 8X303 1300X 325X 105X403 7500X 1875X 600X

Figure 11: Typical computational speed-ups for 3D simulation andrendering in Legendre domain as compared to the spatial domain.

homogenous media, is critical for achieving photo-realismwhile rendering 3D scenes. Finally, in Figure16, we add non-homogenous and dynamic fog to a clear day fly-through ofSwiss Alps.

Computational Speed-ups:Due to the compact representa-tions of fields in the Legendre domain, we can achieve com-putational speed-ups of one to three orders of magnitude, de-pending on the number of Legendre coefficients (Figures10and 11). The comparison is made with our implementationof the Stable Fluids [Sta99] algorithm in the spatial domain.However, our technique places a restriction on the size of thesimulation time-step; adding higher frequencies will requirea progressively smaller time-step owing to stability consid-erations given by the CFL condition [FM97]. On the otherhand, the Stable Fluids technique can support arbitrarily largetime-steps. All our implementation was done in MATLAB ona 3.2GHzP-4 PC with 2 GB of RAM.

Figure 12: Legendre domain Simulation result:500pieces of con-fetti being carried by a turbulent wind field simulated using216Legendre coefficients.

8. Discussion of Limitations and Future Work

Our goal in this paper is fast rendering of non-homogenousand dynamic participating media. We achieve this by repre-senting the spatio-temporally varying intensity (rendering), aswell as density and velocity (simulation) fields in a reducedanalytic Legendre space. This results in a single scatteringbased rendering technique for smooth non-homogenous anddynamic media, a significant improvement over similar tech-niques which make the severely limiting assumption of ho-mogenous medium densities [SRNN05]. We believe this isthe first work that provides a unified framework for both mod-eling and rendering in an analytic reduced space, and hopethis can help bridge the gap between model reduction in flu-ids and pre-computed radiance transfer in rendering. How-ever, the speed and analytic nature of the technique come at

c© Association for Computing Machinery, Inc. 2007.

Page 8: Legendre Fluids: A Unified Framework for Analytic Reduced …ILIM/projects/LT/LegendreFluids/Legendre... · 2012-07-05 · dia is critical for achieving photo-realism in computer

Mohit Gupta & Srinivasa G. Narasimhan / Legendre Fluids

the cost of its limited ability to handle high frequency fluidphenomena. Indeed, using only a global Legendre Polynomi-als basis offers limited local control and allows only for thebox-boundary conditions, making it difficult to account forcomplex effects like local vorticities, turbulence and objectsinside the medium. Also, being aglobal sub-space method,it offers low flexibility on the domain boundaries.

These limitations can be addressed by augmenting theglobal Legendre polynomials basis, which capture the major-ity of the energy of the fluid flow, with a local-support ba-sis such as Haar-Wavelets or spatial voxels, thus accountingfor the spatially sparse ’residual energy’. This is similar inspirit to adding local high frequency turbulence, or vortici-ties [FSJ01] to counter the dampening caused by the StableFluids semi-Lagrangian technique. Also, high frequency de-tails in a particular dimension can be captured by keeping thefull spatial representation and using Legendre expansion inthe remainnig directions. Using suchhybrid basescan providethe desired local control in addition to computational speed-ups, and in our opinion, forms a very promising direction forfuture research. Since we also make assumptions of singlescattering, orthographic viewing and distant lighting, extend-ing our system to perspective viewer and more general, near-field lighting is another research direction worth exploring.

Acknowledgements

We would like to thank Adam Bargteil for helpful technicaldiscussions and the anonymous reviewers for their commentsand suggestions. This work was supported in parts by an NSFCAREER award #IIS-0643628, an NSF grant #CCF-0541307and an ONR award #N00014-05-1-0188.

References

[Cha60] CHANDRASEKHAR S.: Radiative Transfer. Oxford Univ.Press, 1960.1, 2, 3

[CM90] CHORIN A., MARSDEN J.: A Mathematical Introductionto Fluid Mechanics. Springer-Verlag. Texts in Applied Mathemat-ics 4. Second Edition., New York, 1990.1, 2, 3

[DYN02] DOBASHI Y., YAMAMOTO T., NISHITA T.: Interactiverendering of atmospheric scattering effects using graphicshard-ware. InGraphics Hardware Workshop(2002), pp. 99–109.2

[EP90] EBERT D. S., PARENT R. E.: Rendering and animationof gaseous phenomena by combining fast volume and scanline a-buffer techniques. InProceedings of SIGGRAPH(1990).1

[FF01] FOSTERN., FEDKIW R.: Practical animation of liquids. InProceedings of SIGGRAPH(2001), pp. 23–30.1

[FM96] FOSTERN., METAXAS D.: Realistic animation of liquids.Graph. Models Image Process. 58, 5 (1996), 471–483.1

[FM97] FOSTERN., METAXAS D.: Modeling the motion of a hot,turbulent gas. InProceedings of SIGGRAPH(1997).1, 7

[FSJ01] FEDKIW R., STAM J., JENSEN H. W.: Visual simulationof smoke. InProceedings of SIGGRAPH(2001), pp. 15–22.1, 8

[GN07] GUPTA M., NARASIMHAN S.: Legendre polynomialsTriple Product Integral and lower-degree approximation ofpoly-nomials using Chebyshev polynomials. Tech. Rep. CMU-RI-TR-07-22, Carnegie Mellon University, May 2007.2, 4

[HED05] HAWKINS T., EINARSSONP., DEBEVECP.: Acquisitionof time-varying participating media.ACM Trans. Graph. 24, 3(2005), 812–815.2

[HL01] HARRIS M., LASTRA A.: Real-time cloud rendering. InEurographics(2001), pp. 76–84.2

[Jen01] JENSEN H. W.: Realistic image synthesis using photonmapping. A. K. Peters, Ltd., Natick, MA, USA, 2001.1

[JMLH01] JENSENH. W., MARSCHNERS. R., LEVOY M., HAN-RAHAN P.: A practical model for subsurface light transport. InProceedings of SIGGRAPH(2001), pp. 511–518.2

[KH84] K AJIYA J. T., HERZEN B. P. V.: Ray tracing volume den-sities.SIGGRAPH Comput. Graph. 18, 3 (1984), 165–174.1

[Kos24] KOSCHMIEDERH.: Theorie der horizontalen sichtweite.beitr. InPhys. Freien Atm.(1924), pp. 171–181.7

[LBC94] LANGUENOU E., BOUATOUCH K., CHELLE M.: Globalillumination in presence of participation media with generalprop-erties. InFifth Eurographics Workshop on Rendering(1994).1

[Max86] MAX N. L.: Atmospheric illumination and shadows. InProceedings of SIGGRAPH(1986), pp. 117–124.2

[Max94] MAX N. L.: Efficient light propagation for multipleanisotropic volume scattering. InFifth Eurographics Workshopon Rendering(1994), pp. 87–104.1

[NFJ02] NGUYEN D. Q., FEDKIW R., JENSENH. W.: Physicallybased modeling and animation of fire. InProceedings of SIG-GRAPH(2002), pp. 721–728.1

[NGD∗06] NARASIMHAN S. G., GUPTA M., DONNER C., RA-MAMOORTHI R., NAYAR S. K., JENSEN H. W.: Acquiring scat-tering properties of participating media by dilution.ACM Trans.Graph. 25, 3 (2006), 1003–1012.2

[NN03] NARASIMHAN S. G., NAYAR S. K.: Shedding light on theweather. InProceedings of the IEEE Computer Society Conferenceon Computer Vision and Pattern Recognition(June 2003), vol. 1,pp. 665 – 672.2

[NRH04] NG R., RAMAMOORTHI R., HANRAHAN P.: Tripleproduct wavelet integrals for all-frequency relighting.ACM Trans.Graph. 23, 3 (2004), 477–487.2

[PM93] PATTANAIK S., MUDUR S.: Computation of global illumi-nation in a participating medium by monte carlo simulation.Jour-nal of Vis. and Computer Animation 4, 3 (1993), 133–152.1

[REK∗04] RILEY K., EBERT D., KRAUS M., TESSENDORFJ.,HANSEN C.: Efficient rendering of atmospheric phenomena. InEuroGraphics Symposium on Rendering(2004).2

[RT87] RUSHMEIER H. E., TORRANCE K. E.: The zonal methodfor calculating light intensities in the presence of a participatingmedium. InProceedings of SIGGRAPH(1987), pp. 293–302.1

[Sak90] SAKAS G.: Fast rendering of arbitrary distributed volumedensities. InEurographics(1990), pp. 519–530.1

[SRF05] SELLE A., RASMUSSENN., FEDKIW R.: A vortex parti-cle method for smoke, water and explosions.ACM Trans. Graph.24, 3 (2005), 910–914.1

[SRNN05] SUN B., RAMAMOORTHI R., NARASIMHAN S. G.,NAYAR S. K.: A practical analytic single scattering model forreal time rendering.ACM Trans. Graph. 24, 3 (2005).2, 7

[Sta99] STAM J.: Stable fluids. InProceedings of SIGGRAPH(1999), pp. 121–128.1, 2, 3, 5, 7

[Sta01] STAM J.: A simple fluid solver based on the fft.J. Graph.Tools 6, 2 (2001), 43–52.1

[TLP06] TREUILLE A., LEWIS A., POPOVIC Z.: Model reductionfor real-time fluids.ACM Trans. Graph. 25, 3 (2006).1, 5

[TMPS03] TREUILLE A., MCNAMARA A., POPOVIC Z., STAM

J.: Keyframe control of smoke simulations.ACM Trans. Graph.22, 3 (2003), 716–723.1

c© Association for Computing Machinery, Inc. 2007.

Page 9: Legendre Fluids: A Unified Framework for Analytic Reduced …ILIM/projects/LT/LegendreFluids/Legendre... · 2012-07-05 · dia is critical for achieving photo-realism in computer

Mohit Gupta & Srinivasa G. Narasimhan / Legendre Fluids

Light Source and View Point Variation Variation in Scattering PropertiesFigure 13: 3D Legendre domain Rendering:Here we consider asmoke-cubeilluminated by distant light source(s). The image is formedat an orthographic viewer observing the scene. Since the whole of our pipe-line is in the reduced Legendre domain, the user can control theview-point, lighting and scattering albedo interactively. Notice the varying shadow-gram patterns on the wall as the smoke evolves. The smokeand the shadow become darker as we decrease the albedo. Colored smoke and shadows can be created by varying the scatteringpropertiesdifferently across the color channels. This example required64coefficients for density and velocity, and216coefficients for intensity fields.

Figure 14: 3D Legendre domain simulation and advection of optical properties:3D Simulation results for a vertically upwards axial impulseapplied to avase shapedsmoke density field.. Also, we advect the optical propertiesof the media (scattering albedos) along with the densitiesand velocities to create the effect of mixing of different media. This example required216Legendre coefficients for density and velocity fields(simulation) and512coefficients for intensity fields (rendering).

Clear Weather Homogenous mist Non-homogenous mist AttenuationFigure 15: Rendering of Non-homogenous participating media:Our technique can be used to render non-homogenous media as well underthe single scattering model efficiently. Here we add mist to aclear weather scene (Images courtesy Google Earth). Non-homogenous densitydistributions, for example the high mist density over the lake provides for more realism as compared to homogenous mist.Also, notice howdistant objects appear brighter due to the air-light effect, whereas distant objects appear darker in the attenuation-only image.

Figure 16: Snapshots from a fly-through of Swiss Alps with Non-homogenous and dynamic fog added (Images courtesy Google Earth). Imageshave been tone-mapped to high-lite the non-homogeneity of the medium. Complete video is included with the supplementalmaterial.

c© Association for Computing Machinery, Inc. 2007.