#ifdef RCSIDS static char rcsid[] = "$Id: noisysmoke.sl,v 1.1.1.1 2002/02/10 02:35:49 tal Exp $"; #endif /************************************************************************** * noisysmoke.sl * * Description: * This is a volume shader for smoke. Trapezoidal integration is * used to integrate the GADD to find scattering and extinction. * * Parameters: * density - overall smoke density control * integstart, integend - bounds along the viewing ray direction of the * integration of atmospheric effects. * stepsize - step size for integration * use_lighting - if nonzero, light visibility along the ray will be taken * into account. * use_noise - makes the smoke noisy (nonuniform) when nonzero * freq, octaves, smokevary - control the fBm of the noisy smoke * lightscale - multiplier for light scattered toward viewer in volume * debug - if nonzero, copious output will be sent to stderr. * * Author: Larry Gritz * * History: * * $Revision: 1.1.1.1 $ $Date: 2002/02/10 02:35:49 $ * * $Log: noisysmoke.sl,v $ * Revision 1.1.1.1 2002/02/10 02:35:49 tal * RenderMan Repository * * Revision 1.4.2.1 1998-02-06 14:02:30-08 lg * Converted to "modern" SL with appropriate use of vector & normal types * * Revision 1.4 1997-09-10 12:43:54-07 lg * Changed direction of I to maintain PRMan compatibility * * Revision 1.3 1996-03-01 17:07:40-08 lg * Eliminated duplicate local variable declarations * * Revision 1.2 1996-02-29 18:04:26-08 lg * Compute only one octave of noise when not lit (big speedup) * * Revision 1.1 1996-02-05 11:03:45-08 lg * Initial RCS revision * **************************************************************************/ #define snoise(p) (2*noise(p)-1) /* Here is where we define the GADD. */ #define GADD(PP,PW,li,g) \ if (use_lighting > 0) { \ li = 0; \ illuminance (PW) { li += Cl; } \ } else { li = 1; } \ if (use_noise != 0) { \ Psmoke = PP*freq; \ smoke = snoise (Psmoke); \ /* Optimize: one octave only if not lit */ \ if (comp(li,0)+comp(li,1)+comp(li,2) > 0.01) { \ f=1; \ for (i=1; i 0) { printf ("nsteps = %f, t1 = %f, end = %f\n", nsteps, integstart, end); printf (" Cv = %c, Ov = %c\n", Cv, Ov); } }