how to start it using participating media

hi all,
i want to get the advice -how to simulate the
smoke/fog or underwater scene (participating media)
using radzilla to do the basic scene-any an idea how
to start it on??



Sell on Yahoo! Auctions � no fees. Bid on great items.


I never used it so far...

from Georg's radiance knowledge base at :
from this list's archive, with a link to the reference:

These links are not radzilla-specific.

Good luck, CU Lars.

hi Ida,

in coarse words, a medium in a first step sucks in light (energy..) from the field and partly absorbs that completely, partly reemits the light
again. And this is also the basic way how you specify such a medium in Radiance, you define an extinction value (three values, for the three color channels rgb) for the amount of light taken out and an 'albedo' value (also three for rgb) for the amount of light reabsorbed or 'scattered'.
The extinction comes with a unit (1/distance), whereas the albedo is a dimensionless relation of scattered/absorbed energy and thus always lies between 0 and 1.
so much for the quick and dirty version, follow the links posted by Lars to read the exact definitons..

In Radiance, medium properties are defined with the 'mist' material :

( **note- the following short demo follows freely the one in the book Rendering with Radiance by G Ward/R Shakespeare, p. 460ff **)

void mist fogdemo
6 0.07 0.07 0.07 0.5 0.5 0.5

would be a simple version with rgb extinction = 0.07 (in units 1/your world unit), eg 1/m and rgb albedo = 0.5
Note that you have to set both, see above, because without extinction there would be not light to scatter either.

The next point to consider is that the medium speciifc calculations usually take an awful lot of time, so one definitely should try to limit them
a) to certain regions in space and
b) to certain light sources, i.e consider light scattering only for the light from few selected sources.

a) is achieved by setting up a boundary for the mist volume, means creating some object made out of the mist material which encloses a volume

b) is achieved by listing the chosen sources in the mist material definition.

If you have e.g a spotlight
void spotlight spot
7 1000 1000 1000 40 0 0 -1

spot ring spot_light
8 0 0 2 0 0 -1 0.08 0.0

you may list the spot_light object in the mist definition:

void mist fogdemo
1 spot_light
6 0.07 0.07 0.07 0.5 0.5 0.5

now the enclosing volume:
the spotlight is located at 0 0 2 (x, y, z), so you can set a cone with cap for the surrounding mist volume as follows
fogdemo ring fog_cap
0 8 0 0 2.1 0 0 1 0.2 0.0

fogdemo cone fog_cone
8 0 0 2.1 0 0 0 0.2 2

##note that the surface normals point outside, i.e away from the enclosed volume
finally add some demo objects
void plastic grey
5 0.5 0.5 0.5 0 0

grey polygon ground
12 -2 -2 0
    2 -2 0
    2 2 0
   -2 2 0

grey sphere ball
4 0 0 0.5 0.2

Before you oconv and and render the scene (preferrably chose a view point outside the mist cone), one more step needs to be done, you have to tell Radiance at which distance it should sample the scattering effects, the parameter is -ms, for that 2x2x2 m scene -ms 0.1 or -ms 0.05 is a start, so append this to your render options.

So far, the treatment is the same whether you use Radiance classic or Radzilla.

In Radzilla you have now the additional possibility to modify the scattering albedo with a pattern. **Note that this is just for creating visual effects, for an exact calculation one rather would have to modify the extinction value over the volume, but this is very difficult to perform.**

Arbitrary patterns in Radiance or Radzilla can be created with help of so called 'noise functions' provided by the Radiance functional language.
As an example, create a file and write the following lines in it:
gr = abs(fnoise3(Px/A3, Py/A4, Pz/A5))+ A2 ;
red = A1*gr*gr;
grn = A1*gr*gr;
blu = A1*gr*gr;

then add a 'mistfunc' definition to your scene file:
void mistfunc fog_pat
4 red grn blu
5 1 0.0 1.0 1.0 0.3

make this appear before your mist material definition and change the mist material to have now the fog_pat as modifier:
for_pat mist fogdemo
1 spot_light
6 0.07 0.07 0.07 1 1 1

** note that now the albedo values are set to 1, to provide a neutral base, the final albedo will result out of a multiplication by this base value and the factor provided by the pattern function.**

Last but most important step:
play around with the example, the fractal noise function 'fnoise(..)' can be replaced by the normal 'noise(..)' for creating a smoother pattern,
and of course the scaling and intensity parameters A1-A5 can be adjusted as you like, also the values in the mist material. Usually, the more realistic the pattern shall look, the more complicated the mathematical function has to be :-), so experiment with all sorts of weird combinations...

This of course is just a simple demo, you soon might run into other difficulties in complicated scenes, i.e. how to set the enclosing mist volume to avoid visible artifacts (think e.g of a normal point light source instead of a spotlight like above, in this case the light output isn't restricted to certain directions so the cone approach doesn't work anymore. If all else fails, you also can set extinction and albedo globally for the whole scene with the render parameters -me and -ma ..

hope that this gets you started,
and be prepared, the mist stuff is tricky... :slight_smile:


[...] 151 lines of first class information snipped


Thank you again for taking the time write such detailed
and informative replies. That's the type of information
I hope to find when I have to tackle something new.



On Tue, Jul 12, 2005 at 01:40:08 -0700, Carsten Bauer wrote:

Hi Thomas

nice to hear that the info was useful..

btw, two short clarifications:
my last sentence was maybe a bit ambigous, of course one can set medium extinction and albedo globally, but you still need the mist volume and mist material with the source list to show scattering. Otherwise only the extinction will show up, attenuating the light according to the distance the rays have traveled in the scene
In this case, a usual way is setting global extinction, for example with -me 0.07 0.07 0.07 and then define a mist material :

void mist fogdemo
n ... sources
6 0 0 0 0.5 0.5 0.5

the zeros for the extinction in the mist materials mean to use the global value without changes, only scattering is calculated in tthe volume then.

To add further complexity and confusion :-), in limited, well defined circumstances also the extinction can be successfully modified by a pattern. A 'colorfunc' modifier to the mist material acts on the extinction values, however, they aren't changed over the mist volume, just the value at the entry point is set and then holds for that ray throughout the mist volume. In special cases, when the gradient of the extinction is vertical to the view rays, this can indeed work out well, but only then..
Think e.g of a fog layer increasing in densitiy with decrasing height above ground, and the looking through it more or less in horizontal direction...


1 Like