3ds Max C++ API Reference
IReshading Class Reference

#include <IReshading.h>

+ Inheritance diagram for IReshading:

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)
 

Additional Inherited Members

- Static Public Member Functions inherited from MaxHeapOperators
static UtilExport voidoperator new (size_t size)
 Standard new operator used to allocate objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e)
 Standard new operator used to allocate objects if there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new (size_t size, const char *filename, int line)
 New operator used to allocate objects that takes the filename and line number where the new was called If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, int block_type, const char *filename, int line)
 New operator used to allocate objects that takes the type of memory, filename and line number where the new was called If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e, const char *filename, int line)
 New operator used to allocate objects that takes the filename and line number where the new was called If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new (size_t size, unsigned long flags)
 New operator used to allocate objects that takes extra flags to specify special operations If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e, unsigned long flags)
 New operator used to allocate objects that takes extra flags to specify special operations If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size, const char *filename, int line)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, int block_type, const char *filename, int line)
 New operator used to allocate arrays of objects. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e, const char *filename, int line)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size, unsigned long flags)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e, unsigned long flags)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport void operator delete (void *ptr)
 Standard delete operator used to deallocate an object If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e)
 Standard delete operator used to deallocate an object If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete (void *ptr, const char *filename, int line)
 Delete operator used to deallocate an object that takes the filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, int block_type, const char *filename, int line)
 Delete operator used to deallocate an object that takes the type of memory, filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e, const char *filename, int line)
 Delete operator used to deallocate an object that takes the filename and line number where the delete was called If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete (void *ptr, unsigned long flags)
 Delete operator used to deallocate an object that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e, unsigned long flags)
 Delete operator used to deallocate an object that takes extra flags to specify special operations If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr)
 Standard delete operator used to deallocate an array of objects If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e)
 Standard delete operator used to deallocate an array of objects If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, int block_type, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the type of memory, filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the filename and line number where the delete was called If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr, unsigned long flags)
 Delete operator used to deallocate an array of objects that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e, unsigned long flags)
 Delete operator used to deallocate an array of objects that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, void *placement_ptr)
 Placement new operator. More...
 
static UtilExport void operator delete (void *ptr, void *placement_ptr)
 Placement delete operator. More...
 
static UtilExport voidaligned_malloc (size_t size, size_t alignment)
 Allocates memory on a specified alignment boundary. More...
 
static UtilExport voidaligned_realloc (void *ptr, size_t size, size_t alignment)
 Reallocates memory on a specified alignment boundary. More...
 
static UtilExport void aligned_free (void *ptr)
 Frees a block of memory that was allocated with aligned_malloc/aligned_realloc. More...
 

Detailed Description

See also
Class IReshadeFragment, Class ShadeContext, Class IllumParams

Description:
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.

Member Enumeration Documentation

◆ ReshadeRequirements

Enumerator
RR_None 
RR_NeedPreshade 
RR_NeedReshade 
@ RR_NeedPreshade
Definition: IReshading.h:55
@ RR_NeedReshade
Definition: IReshading.h:55
@ RR_None
Definition: IReshading.h:55

Constructor & Destructor Documentation

◆ ~IReshading()

virtual ~IReshading ( )
inlinevirtual
Remarks
Destructor.
57 {;}

Member Function Documentation

◆ GetReshadeRequirements()

virtual ReshadeRequirements GetReshadeRequirements ( )
inlinevirtual
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; }
80 { return RR_NeedPreshade; }

◆ PreShade()

virtual void PreShade ( ShadeContext sc,
IReshadeFragment pFrag 
)
inlinevirtual
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.

96 { }

◆ PostShade()

virtual void PostShade ( ShadeContext sc,
IReshadeFragment pFrag,
int nextTexIndex,
IllumParams ip = NULL 
)
inlinevirtual
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.

119  { }