Class Atmospheric

3DS Max Plug-In SDK

Class Atmospheric

See Also: Class SpecialFX, Class SFXParamDlg, Class IRendParams, Class ShadeContext, Class Point3, Class Color, Class Interval.

class Atmospheric : public SpecialFX

Description:

This is the base class for the creation of Atmospheric plug-ins. Developers may look to the text below for information on the techniques used to create these types of effects:

Kenton Musgrave, Darwyn Peachey, Ken Perlin, Steven Worley, Texturing and Modeling A Procedural Approach (Cambridge, MA: Academic Press, Inc., 1994). ISBN: 0-12-228760-6.

Chapter 6 on Hypertexture, particularly the section on 'Raymarching', describes essentially the method 3ds max uses.

Methods:

Prototype:

virtual AtmosParamDlg *CreateParamDialog(IRendParams *ip)

Remarks:

Implemented by the Plug-In.

This method creates and returns a new instance of a class derived from AtmosParamDlg to manage the user interface. This put up a modal dialog that lets the user edit the plug-ins parameters.

Parameters:

IRendParams *ip

This is the interface given to the atmospheric effect so it may display its parameters.

Return Value:

A new instance of a class derived from AtmosParamDlg.

Note: typedef SFXParamDlg AtmosParamDlg;

Default Implementation:

{return NULL;}

Prototype:

virtual BOOL SetDlgThing(AtmosParamDlg* dlg);

Remarks:

This method is available in release 3.0 and later only.

You should implement this if you are using the ParamMap2 AUTO_UI system and the effect has secondary dialogs that have something other than the incoming effect as their 'thing'. Called once for each secondary dialog for you to install the correct thing. Return TRUE if you process the dialog, FALSE otherwise, in which case the incoming effect will be set into the dialog.

Note: Developers needing more information on this method can see the remarks for MtlBase::CreateParamDlg() which describes a similar example of this method in use (in that case it's for use by a texture map plug-in).

Parameters:

AtmosParamDlg* dlg

Points to the ParamDlg.

Default Implementation:

{ return FALSE; }

Prototype:

virtual void Shade(ShadeContext& sc,const Point3& p0,const Point3& p1,Color& color,Color& trans, BOOL isBG=FALSE)=0;

Remarks:

Implemented by the Plug-In.

This is the function that is called to apply the atmospheric effect. The line segment defined by the world space points p0 and p1 represent a segment of volume that needs to be shaded. This line segment is a line along the ray defined by the line between the viewer's eye (the camera) and the pixel being rendered in the image plane and continuing through world space. This ray is broken up into segments, with the boundaries defined by surfaces. If there are no surfaces, there will just be a single segment from the eye point going off into space (p1 will be a large number). If there is a surface that is hit, and the surface is opaque, there will still be one segment from the eye to the surface. If the surface is transparent there may be two segments, the segment before and the segment after. Therefore the ray may be broken up into many segments depending on the number of transparent surfaces hit.

The shader does not need to be directly concerned with this however. It only knows it's shading the segment between p0 and p1. It will get called repeatedly for different pixels and different segments.

The output of this method is the computed color and transparency.

An example implementation of this method is 3ds max's Simple Fog. It takes the distance of the line segment and essentially interpolates towards the fog color based on the distance. This is a very simple effect.

3ds max's Volume Fog traverses along the segment and evaluates its 3D noise function. It integrates the density across the segment, and uses the density to compute the fog color.

Parameters:

ShadeContext& sc

The ShadeContext.

const Point3& p0

The start point of the segment to shade. This point (and p1) are in an undefined 'internal' space specific to the renderer (which for the 3ds max renderer is in fact is camera space). To get to world space the plug-in would call sc.PointTo(p0,REF_WORLD).

const Point3& p1

The end point of the segment to shade.

Color& color

This method shades the volume between p0 and p1 and modifies this color.

Color& trans

This method shades the volume between p0 and p1 and modifies this transparency.

BOOL isBG=FALSE

TRUE if the background is being shaded; otherwise FALSE. If TRUE then p1 will be infinity (a large number). This is used when the option to not fog the background is on.

Prototype:

IOResult Save(ISave *isave);

Remarks:

This method is available in release 2.0 and later only.

Implemented by the system.

To facilitate naming atmospheric effects, a 'name' string has been added to the base class. This method should be called from the developers sub-classed Atmospheric plug-in to save the name.

Prototype:

IOResult Load(ILoad *iload);

Remarks:

This method is available in release 2.0 and later only.

Implemented by the system.

To facilitate naming atmospheric effects, a 'name' string has been added to the base class. This method should be called from the developers sub-classed Atmospheric plug-in to load the name.