Public Types | Public Member Functions

IReshading Class Reference

Search for all occurrences

Detailed Description

See also:
Class IReshadeFragment, Class ShadeContext, Class IllumParams

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

This interface class is the interface that must be supported by materials and shaders to support interactive rendering in 3ds Max. If this interface is not returned when requested through GetInterface() on the mtl or shader, then it is determined they do not support reshading. Any material that does not support reshading is evaluated only at preshading time.

In 3ds Max, interactive rendering is implemented as fragment based caching scheme. It's very much like a giant multi-layer g-buffer with enough information stored with each fragment to re-run the material shading process without re-rendering, all stored in a compressed form.

The rendering process in divided into 2 parts: preshading and reshading. Preshading builds the scene and renders fragments to the compressed g-buffer, called the rsBuffer. To do this, it saves a minimal amount of information with each fragment, then gives each material and texture the opportunity to pre-shade itself.

Basically, the reshader populates a minimal ShadeContext, with the fragment center position in camera space (where shading is done), the shading normal, the sub-pixel mask, the coverage, pointers to the original material and INode, light lists, screen bounding box of object, the renderID, and screen integer x and y.

Any other values from the shade context that a material, shader, texture(future), atmosphere(future) or light(future) needs to save, it does so at pre-shade time, and retrieves the data at reshading time. So, for example, the multi-materials save which material is visible, anisotropic shaders save the Anisotropic reference vector.

#include <imtl.h>

Inheritance diagram for IReshading:
Inheritance graph
[legend]

List of all members.

Public Types

enum   ReshadeRequirements { RR_None = 0, RR_NeedPreshade, RR_NeedReshade }

Public Member Functions

virtual  ~IReshading ()
virtual ReshadeRequirements  GetReshadeRequirements ()
virtual void  PreShade (ShadeContext &sc, IReshadeFragment *pFrag)
virtual void  PostShade (ShadeContext &sc, IReshadeFragment *pFrag, int &nextTexIndex, IllumParams *ip=NULL)

Member Enumeration Documentation


Constructor & Destructor Documentation

virtual ~IReshading ( ) [inline, virtual]
Remarks:
Destructor.
{;}

Member Function Documentation

virtual ReshadeRequirements GetReshadeRequirements ( ) [inline, virtual]
Remarks:
This method is called by the interactive reshader after being notified that the material has changed. The return value indicates if the material is still valid, or needs to be preshaded or reshaded. The value should pertain only to the latest change to the material. If a material doesn't support reshading, it doesn't need to override this function -- any change will cause the nodes to which it's attached to be re- preShaded.
Returns:
One of the following values;

RR_None

No actions needs to be taken.

RR_NeedPreshade

A pre-shade is needed.

RR_NeedReshade

A re-shade is needed.
Default Implementation:
{ return RR_NeedPreshade; }
{ return RR_NeedPreshade; } // mjm - 06.02.00
virtual void PreShade ( ShadeContext sc,
IReshadeFragment pFrag 
) [inline, virtual]
Remarks:
This method will pre-shade the object and cache any needed values in the fragment.

This method is called on the materials/shaders/textures as the reshading buffer is being built at the same point in the rendering process where the materials shade function would normally be called. Note that at this time the shade context is completely valid, as in a normal rendering. Any values the material wishes to cache can be attached to the reshading fragment passed in, and retrieved later at postShade time.
Parameters:
ShadeContext& sc

A reference to the shade context.

IReshadeFragment* pFrag

A pointer to the fragment.
Default Implementation:
{ }

Reimplemented in Shader.

{ }
virtual void PostShade ( ShadeContext sc,
IReshadeFragment pFrag,
int &  nextTexIndex,
IllumParams ip = NULL 
) [inline, virtual]
Remarks:
This method will retrieve cached values and compute shade & transparency for the fragment.

This method is called for the material of each fragment as the reshading buffer is being traversed. Materials retrieve whatever they may have stored to complete the minimal shade context and compute a shade for the fragment. PostShade() calls to shaders contain an additional parameter, the IllumParams, filled with the textured/blended but unshaded values for each texture. The shade context passed into PostShade() is the minimal shade context outlined above.
Parameters:
ShadeContext& sc

A reference to the shade context.

IReshadeFragment* pFrag

A pointer to the fragment.

int& nextTexIndex

A reference to the next texture index.

IllumParams* ip = NULL

A pointer to the IllumParams containing textured/blended but unshaded values for each texture.
Default Implementation:
{ }

Reimplemented in Shader.

                                                                                { }

IReshading IReshading IReshading IReshading IReshading IReshading IReshading IReshading IReshading IReshading
IReshading IReshading IReshading IReshading IReshading IReshading IReshading IReshading IReshading IReshading