3ds Max C++ API Reference
IShaderManager Class Referenceabstract

Represents the programmable shader associated with a material or texture map plug-in. More...

#include <IShaderManager.h>

+ Inheritance diagram for IShaderManager:

Public Types

enum  ShaderType { ShaderTypeMetaSL = 0 , ShaderTypeAMG }
 Supported shader types. More...
 
- Public Types inherited from BaseInterface
enum  LifetimeType { noRelease , immediateRelease , wantsRelease , serverControlled }
 

Public Member Functions

virtual Interface_ID GetID ()
 Retrieves the interface ID of IShaderManager. More...
 
virtual ShaderType GetShaderType () const =0
 Retrieves the shader's type. More...
 
virtual const MCHARGetShaderClassName () const =0
 Retrieves the shader's class name. More...
 
virtual const MCHARGetShaderFile () const =0
 Retrieves the fully qualified path of the shader file. More...
 
- Public Member Functions inherited from BaseInterface
virtual UtilExport ~BaseInterface ()
 Destructor. More...
 
UtilExport BaseInterfaceGetInterface (Interface_ID id)
 
virtual LifetimeType LifetimeControl ()
 
virtual bool RegisterNotifyCallback (InterfaceNotifyCallback *incb)
 
virtual void UnRegisterNotifyCallback (InterfaceNotifyCallback *incb)
 
virtual BaseInterfaceAcquireInterface ()
 
virtual void ReleaseInterface ()
 
virtual void DeleteInterface ()
 
virtual BaseInterfaceCloneInterface (void *remapDir=NULL)
 
- Public Member Functions inherited from InterfaceServer
virtual UtilExport ~InterfaceServer ()
 Destructor. More...
 
template<class InterfaceType >
InterfaceType * GetTypedInterface ()
 

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

Represents the programmable shader associated with a material or texture map plug-in.

Materials and texture maps can use programmable shaders to describe their appearance when displayed in the Nitrous viewport and rendered with Quicksilver. Programmable shaders allow for a more realistic and complex visual appearance than ISimpleMaterial does. Note that 3ds Max 2012 only supports MetaSL shaders.

Plug-ins do not need to derive from IShaderManager. They rather need to create instances of it using IShaderManagerCreator::CreateShaderManager(), one for each shader they support. 3ds Max will query the plug-in for its IShaderManager via a request for the interface identified by ISHADER_MANAGER_INTERFACE_ID. Typically a plug-in would create an instance of IShaderManager in response to this request in its override of Animatable::GetInterface(Interface_ID) and delete it in its destructor by calling IShaderManagerCreator::DeleteShaderManager(). The following code snippet illustrates how a plug-in manages its IShaderManager instance:

// A material plug-in that has a shader
class MyMtlPlugin : public MtlBase {
private:
IShaderManager* mShaderManager;
public:
MyMtlPlugin() : mShaderManager(NULL) {
// It's not recommended to create the IShaderManager in the plug-in's constructor
// since the shader manager needs a pointer to the plug-in, which hasn't been
// fully constructed yet. Therefore calls the shader manager may make to
// virtual methods of the plug-in may lead to a crash.
}
~MyMtlPlugin() {
// Do not call the delete operator in mShaderManager, ask IShaderManagerCreator
// to destroy it properly.
mpManager = NULL;
}
// In case the plug-in may have several shaders with one IShaderManager
// instance for each, it will need to make sure that the IShaderManager
// interface pointer that is returned corresponds to the currently active
// shader.
return GetShaderManager();
else
return MtlBase::GetInterface(iid);
}
IShaderManager* GetShaderManager() {
if (mpManager == NULL) {
_M("MetaSL shader class name"), // same class name as found in the shader file
_M("Fully qualified shader file path") // Full path to a xmsl shader file
this);
}
return mpManager;
}
};
#define ISHADER_MANAGER_INTERFACE_ID
Interface ID of class IShaderManager.
Definition: IShaderManager.h:20
#define NULL
Definition: autoptr.h:18
Definition: baseinterface.h:78
UtilExport BaseInterface * GetInterface(Interface_ID id)
Definition: maxtypes.h:215
static IShaderManagerCreator * GetInstance()
Retrieves the sole instance of IShaderManagerCreator.
Definition: IShaderManager.h:159
virtual void DeleteShaderManager(IShaderManager *pShaderGraphManager)=0
Deletes an IShaderManager instance.
virtual IShaderManager * CreateShaderManager(IShaderManager::ShaderType type, const MCHAR *className, const MCHAR *shaderFileName, ReferenceTarget *pRefTarget)=0
Creates an IShaderManager object based on a programmable shader.
@ ShaderTypeMetaSL
MetaSL shader.
Definition: IShaderManager.h:98
Definition: MtlBase.h:159
virtual CoreExport void * GetInterface(ULONG id)
Inherited from Animatable.
#define _M(x)
Used to wrap string literals.
Definition: strbasic.h:67

The parameters of the shader need to be fed with values from the parameters of the material or texture map plug-in. This process is facilitated by class IParameterTranslator that plug-ins need to implement.

See also
IParameterTranslator

Member Enumeration Documentation

◆ ShaderType

enum ShaderType

Supported shader types.

Enumerator
ShaderTypeMetaSL 

MetaSL shader.

ShaderTypeAMG 

AMG shader.

97  {
98  ShaderTypeMetaSL = 0,
100  };
@ ShaderTypeAMG
AMG shader.
Definition: IShaderManager.h:99

Member Function Documentation

◆ GetID()

virtual Interface_ID GetID ( )
inlinevirtual

Retrieves the interface ID of IShaderManager.

Reimplemented from BaseInterface.

◆ GetShaderType()

virtual ShaderType GetShaderType ( ) const
pure virtual

Retrieves the shader's type.

◆ GetShaderClassName()

virtual const MCHAR* GetShaderClassName ( ) const
pure virtual

Retrieves the shader's class name.

◆ GetShaderFile()

virtual const MCHAR* GetShaderFile ( ) const
pure virtual

Retrieves the fully qualified path of the shader file.