Public Types | Public Member Functions | Protected Attributes | Friends

MaxRenderElement Class Reference

This reference page is linked to from the following overview topics: Render Elements.


Search for all occurrences

Detailed Description

See also:
Class IRenderElement, Class ShadeContext, Class IllumParams , Render Elements

Description:
This class is available in release 4.0 and later only.

This is the RenderElement base class for 3ds Max' default scanline renderer. RenderElement plugins that utilize ShadeContext and IllumParams should sub-class from here. . All render elements that support the max renderer should derive from this class. The class implements a handler for the ShadeOutputIndex of the elements value in the ShadeOutput array. Access to the elements value is accomplished within PostIllum or PostAtmosphere by:

AColor myColor;

// ... do some computation

sc.out.elementVals[ mShadeOutputIndex ] = myColor;

// ... or

sc.out.elementVals[ ShadeOutputIndex() ] = myColor;

A sample plugin of a Render Element can be found in the SDK samples; /MAXSDK/SAMPLES/RENDER/RENDERELEMENTS.
Data Members:
protected:

int mShadeOutputIndex;

The index into element value array in shadeOutput class.

#include <renderelements.h>

Inheritance diagram for MaxRenderElement:
Inheritance graph
[legend]

List of all members.

Public Types

enum   { IID = 0xeffeeffe }

Public Member Functions

void  SetShadeOutputIndex (int shadeOutputIndex)
int  ShadeOutputIndex () const
virtual void  Update (TimeValue timeValue)
virtual void  PostIllum (ShadeContext &sc, IllumParams &ip)=0
virtual void  PostAtmosphere (ShadeContext &sc, float z, float prevZ)=0
virtual void *  GetInterface (ULONG id)
virtual void  ReleaseInterface (ULONG id, void *i)

Protected Attributes

int  mShadeOutputIndex

Friends

class  FilterComp

Member Enumeration Documentation

anonymous enum
Enumerator:
IID 
{ IID = 0xeffeeffe };

Member Function Documentation

void SetShadeOutputIndex ( int  shadeOutputIndex ) [inline]
Remarks:
This method sets the index into the element array in the ShadeOutput class. This method is implemented by this base class & need not be re-implemented by derivative classes. Derivative classes access the index either through the interface or directly as mShadeOutputIndex. Set is used by the system to assign an index to each element. This index persists throughout a single rendering.
Parameters:
int shadeOutputIndex

The shadeOutput index.
{ mShadeOutputIndex = shadeOutputIndex; }
int ShadeOutputIndex ( ) const [inline]
Remarks:
This method gets the index into the element array in the ShadeOutput class. This method is implemented by this base class & need not be re-implemented by derivative classes. Derivative classes access the index either through the interface or directly as mShadeOutputIndex. Set is used by the system to assign an index to each element. This index persists throughout a single rendering.
{ return mShadeOutputIndex; }
virtual void Update ( TimeValue  timeValue ) [inline, virtual]
Remarks:
This method will update the element to time timeValue. Note that most elements don't care.

Update is called to communicate the time to the element. It will be called on each element before the call to PostIllum() is executed. No current render element uses this, but it could prove useful someday. This class provides a default stub implementation, so this need not be implemented unless needed.
Parameters:
TimeValue timeValue

The timevalue at which the update gets called.
{ }
virtual void PostIllum ( ShadeContext sc,
IllumParams ip 
) [pure virtual]
Remarks:
This method is used to compute the element and store the result in the ShadeContext's ShadeOutput.

This is the first of the actual computation methods for the render element. PostIllum() is called by the material just after an illumination is computed for a fragment. Some materials, like the multi-materials don't compute illumination themselves but mix illuminations from other leaf materials. Such materials do not call PostIllum(), but need to consider the elements when blending the shadeoutputs from the leaf materials. The ShadeContext is the same shadecontext passed into the material's shade method, & contains the member variable 'out', which is the current output from the full pixel shading and the storage place for renderElement values.

The other param, IllumParams, contains detailed information about the shading process. Specifically, the component-wise output from the shading process is available in the IllumParams. Also the illumParams passed in are dependent on whether the element has requested shadows or not. The standard material keeps two sets of these and supplies the one requested. This method must be implemented, tho some elements merely stub it out or clear the output element value. It should put it's output is in sc.out.elementVals[ShadeOutputIndex() ]. Even if you do not need this function, it is a good idea to clear the element val.
Parameters:
ShadeContext& sc

A reference to the ShadeContext.

IllumParams& ip

A reference to the IllumParams.
virtual void PostAtmosphere ( ShadeContext sc,
float  z,
float  prevZ 
) [pure virtual]
Remarks:
This is the second computation method and is only called if the elements has atmospheres applied. If it is applied, then the element value is retrieved from the shadeContext, the atmosphere is applied to it & and the output from the atmosphere is left in sc.out.c and sc.out.t. Last, PostAtmosphere is called with the shadeContext, and the 2 z values used by the atmosphere to compute it. If the point is directly visible to the camera, then prevZ will be 0.0f, otherwise it is the z of the next closest obscuring transparent fragment in front of the fragment being shaded. It is up to the render element to process the output in sc.out.c and save the result in sc.out.elementVals[ShadeOutputIndex() ]. Note that when PostAtmosphere is called the original value set by PostIllum is saved in the element val. This can be overwritten or used in some computation. For example, to separate atmosphere from the composite color, sc.out.c and sc.out. elementVals[ShadeOutputIndex() ] can be differenced.
Parameters:
ShadeContext& sc

A reference to the ShadeContext.

float z

The first depth value.

float prevZ

The previous depth value.
virtual void* GetInterface ( ULONG  id ) [inline, virtual]
Remarks:
The renderer will call this method to see if IRenderElement is compatible with it This is used for future expansion in interface classes. When the 3ds Max development team needs to add additional functionality to an interface class this method provides a way to do that without breaking the API. If the 3ds Max developers would add methods to an existing class it would invalidate the plug-ins that used the class. Using thismethod allows additional functionality to be added to the interface class without breaking the API.
Parameters:
ULONG id

Currently this is not used and is reserved for future use.

Implements IRenderElement.

Reimplemented in MaxBakeElement, MaxBakeElement8, and MaxBakeElement10.

{ return (id == IID) ? this : SpecialFX::GetInterface(id);}
virtual void ReleaseInterface ( ULONG  id,
void *  i 
) [inline, virtual]
Remarks:
This method is not currently used. It is reserved for future use. Its purpose is for releasing an interface created with GetInterface().

Implements IRenderElement.

Reimplemented in MaxBakeElement.

{ }

Friends And Related Function Documentation

friend class FilterComp [friend]

Member Data Documentation

int mShadeOutputIndex [protected]

MaxRenderElement MaxRenderElement MaxRenderElement MaxRenderElement MaxRenderElement MaxRenderElement MaxRenderElement MaxRenderElement MaxRenderElement MaxRenderElement
MaxRenderElement MaxRenderElement MaxRenderElement MaxRenderElement MaxRenderElement MaxRenderElement MaxRenderElement MaxRenderElement MaxRenderElement MaxRenderElement