[Radiance-general] how to start it using participating media

Carsten Bauer cbauer- at t-online.de
Tue Jul 12 10:40:08 CEST 2005


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
0
0
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
0
0
7  1000 1000 1000 40  0 0 -1

spot ring spot_light
0
0
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
0
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
0                       
8  0 0 2.1  0 0 1  0.2  0.0

fogdemo cone fog_cone
0
0
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
0
0
5  0.5 0.5 0.5 0 0

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

grey sphere ball
0
0
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  fog_pat.cal 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 fog_pat.cal
0
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
0
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... :-)

-Carsten



More information about the Radiance-general mailing list