Class LightRayTraversal
See Also: Class ObjLightDesc.
class LightRayTraversal
Description:
This is a callback class that can be given to a ObjLightDesc to have a ray traced through the light volume. A plug-in derives a class from this one and passes it as a callback in the ObjLightDesc method TraverseVolume(). This allows a developer to integrate the illumination of a segment due to a light. t0 and t1 define the segment in terms of the given ray.
This is what the 3ds max spotlights do: First they break the segment up into three main pieces. The first piece is from the camera to where the ray intersects the lights cone volume. The callback Step() is called once over this segment (t0 and t1 will have this first piece). The illumination is constant over this entire segment from t0 to t1. It is a constant black since the light is not illuminating it at all.
The next segment is inside the cone. This segment will be broken up into small pieces. First as it's stepping along it will be between the falloff and the hotspot. The illumination over this segment goes from black to brighter and brighter as it moves towards to hotspot. Across the entire hotspot region the illumination may be constant. Then as it steps from the hotspot to the falloff the illumination will go back down to black.
Inside the hotspot region, if shadows are turned on, the light may be brighter or darker depending on if it's inside a shadow or on the edge of a shadow. The light handles all of this. It takes care of the shadows, attenuation, etc.
Now consider how the 3ds max atmospheric effects such as the volume lights use this information. For each light that they are bound to, they call the method TraverseVolume() on the light. The volume light atmospheric effect passes this callback to the TraverseVolume() method. The light then calls this Step() method of the callback for each partial segment of the ray. Given the illumination on the segment (illum) it computes the fog density over that piece. The density may be constant if noise is not turned on, or it may vary if noise is turned on. Using the fog density and the illumination it computes the light reflected off the atmosphere for the segment.
Methods:
Prototype:
virtual BOOL Step(float t0, float t1, Color illum , float distAtten)=0;
Remarks:
Implemented by the Plug-In.
This method is called for every step defined by t0 and t1. The illumination over this segment is passed in illum.
Parameters:
float t0
The start of the segment. This is a distance along the ray. The ray is made up of a point p and a unit length direction vector dir. The point defined by t0 is thus ray.p+t0*ray.dir.
float t1
The end of the segment. This is a distance along the ray. The ray is made up of a point p and a unit length direction vector dir. The point defined by t1 is thus ray.p+t1*ray.dir.
Color illum
The light intensity over the entire segment. It can be assumed that the light intensity is constant for the segment.
float distAtten
This parameter is available in release 2.0 and later only.
This parameter may be used so that volume effects can use the distance attenuation value as an input variable to their effects. For instance, the volume light uses this to change the fog color based on the distance from the light.
Return Value:
TRUE to continue; FALSE to halt the integration (stop the traversal).