Scene Info Shelf Functions Globals Table of Contents

Volumetric Evaluation

Availability  LightWaveŽ 8.3
Component   Layout
Header  lwvolume.h

There are two globals available necessary to evaluate volumetrics in Layout: VRayFuncs and VolumetricEvaluationFuncs. The first handles volumetrics in general, and the latter handles Layout's implementation of them as plugins.

Volumetrics are processing by generating rays to be fired into the scene. The volumetric plugins react to these rays and break the ray into ray segments. Each segments is assigned a color intensity and opacity for each color channel (red, green, blue).  Once all the segments are specified, the ray is 'flattened', which is a process of converting the segments into a final opacity and intensity for each color channel for the original ray. The globals provided facilitate that process by allowing one to generate these rays and have the existing voluemtric plugins within Layout to process them.

VRayFuncs

The VRayFuncs global generate these rays and have the existing voluemtric plugins within Layout to process them. The process to follow is:

  • Create a new ray structure with LWVRayFuncs->New()
  • Initialize the ray with your desired source and direction and other required information with LWVRayFuncs->Init() and LWVRayFuncs->SetRenderFuncs()
  • Shoot the ray into the scene to be evaluated (This is where the LWVolumetricEvaluationFuncs come in)
  • Obtain the rays evaluated color intensity and opacity with LWVRayFuncs->Flatten()
  • Destroy the ray structure with LWVRayFuncs->Destroy()
  • Use the color data as you wish.
(Note: Reusing an already evaluated ray for another evaluation may have problems, so always create a new ray each time for now)

Global Call

   LWVRayFuncs *vrayfuncs;
   vrayfuncs = global( LWVRAYFUNCS_GLOBAL, GFUSE_TRANSIENT );

The global function returns a pointer to an LWVRayFuncs.

   typedef struct st_LWVRayFuncs {
      LWVolumeAccess* (*New)            (void);
      LWError         (*Destroy)        (LWVolumeAccess *ray);
      void            (*Init)           (LWVolumeAccess *ray,
                                           double o[3],
                                           double dir[3],
                                           double nearClip,
                                           double farClip,
                                           int evalFlag,
                                           int hres,
                                           double hfov,
                                           double incMultiplier,
                                           LWIlluminateFunc *illuminate);
      void            (*SetRenderFuncs) (LWVolumeAccess *ray,
                                           LWIlluminateFunc *illuminate,
                                           LWRayTraceFunc *rayTrace,
                                           LWRayCastFunc *rayCast,
                                           LWRayShadeFunc *rayShade,
                                           LWRayTraceModeFunc *rayTraceMode,
					   LWIlluminateSampleFunc *illuminateSample,
					   LWRandomFloatFunc *randomFloat );
      double          (*Flatten)        (LWVolumeAccess *ray,
                                           double color[3],
                                           double opa[3]);
    } LWVRayFuncs;

Global Call

   LWVolumetricEvaluationFuncs *volevalfuncs;
   volevalfuncs = global( LWVOLUMETRICEVALUATIONFUNCS_GLOBAL, GFUSE_TRANSIENT );

The global function returns a pointer to an LWVolumetricEvaluationFuncs.

   typedef struct st_LWVolumetricEvaluationFuncs {
      void   (*init)     (unsigned int slot, int LWINIT_context);
      void   (*newtime)  (unsigned int slot);
      double (*evaluate) (unsigned int slot, LWVolumeAccess *ray, unsigned short LWVOLF_raytype);
      void   (*cleanup)  (unsigned int slot);
   } LWVolumetricEvaluationFuncs;

Example

In order to get a volumetric plugin to evaluate outside of a render context:

  • VolumetricEvaluationFuncs->init() to prepare the volumetric handlers to be used for rendering. This will call each handler's "init" callback.
  • VolumetricEvaluationFuncs->newtime() to obtain flags from the volumetric handlers and invoke a NEWTIME notification to get them up to date with the current scrub time. This will call each handler's "newtime" callback
  • Create a ray structure using VRayFuncs->New()
  • For each ray to be evaluated for whatever purposes:
    • VRayFuncs->Init() the ray with custom parameters
    • VolumetricEvaluationFuncs->evaluate() the ray to figure each volumetric handler's contribution to the samples
    • VRayFuncs->Flatten() the ray to obtain colors and color opacities for that ray
    • VRayFuncs->Destroy() the ray when done with it.
  • VolumetricEvaluationFuncs->cleanUp() to notify a render finishing to each volumetric handler. This will call each handler's "cleanup" callback