3ds Max C++ API Reference
BaseShader Class Referenceabstract

One of the base classes for the creation of the Shaders, which plug-in to the Standard material[?]. More...

#include <shaders.h>

+ Inheritance diagram for BaseShader:

Public Member Functions

RefResult NotifyRefChanged (const Interval &changeInt, RefTargetHandle hTarget, PartID &partID, RefMessage message, BOOL propagate)
 Receives and responds to messages. More...
 
SClass_ID SuperClassID ()
 Retrieves a constant representing the type of the plugin. More...
 
BOOL BypassPropertyLevel ()
 Wants to promote the shader properties to the material level. More...
 
virtual ULONG GetRequirements (int subMtlNum)=0
 Returns the requirements of the Shader for the specified sub-material. More...
 
virtual long nUserIllumOut ()
 Indicates the number of UserIllum output channels used by the shader. More...
 
virtual const MCHAR ** UserIllumNameArray ()
 Returns a static array of channel names for matching by render elements. More...
 
Dialog (Rollup) Access
virtual ShaderParamDlgCreateParamDialog (HWND hOldRollup, HWND hwMtlEdit, IMtlParams *imp, StdMat2 *theMtl, int rollupOpen, int n=0)=0
 Put up a dialog that lets the user edit the plug-ins parameters. More...
 
virtual ShaderParamDlgGetParamDlg (int n=0)=0
 Returns a pointer to the ShaderParamDlg object which manages the user interface. More...
 
virtual void SetParamDlg (ShaderParamDlg *newDlg, int n=0)=0
 Sets the ShaderParamDlg object which manages the user interface to the one passed. More...
 
Standard Parameter Access
virtual int NParamDlgs ()
 Returns the number of rollups this shader is requesting. More...
 
virtual ULONG SupportStdParams ()=0
 Std parameter support. More...
 
virtual void ConvertParamBlk (ParamBlockDescID *descOld, int oldCount, IParamBlock *oldPB)
 Required for R2.5 shaders to convert the previous Standard material parameter blocks to the current version. More...
 
Load/Save Methods
IOResult Save (ISave *isave)
 Saves and loads the plug-in's name. More...
 
IOResult Load (ILoad *iload)
 Loads the plug-in's name. More...
 
Illumination Related Methods
virtual void GetIllumParams (ShadeContext &sc, IllumParams &ip)=0
 Updates the "channels"(as well as other) data member of the "IllumParams" object passed to it with the "local" variables of the material for possible mapping prior to being given to the Shader's Illum() method. More...
 
virtual void Illum (ShadeContext &sc, IllumParams &ip)=0
 This is the illumination function for the Shader. More...
 
virtual void ShadeReflection (ShadeContext &sc, IllumParams &ip, Color &mapClr)
 Compute the reflected color from the sc, ip, and reflection map (or ray) color. More...
 
virtual void ShadeTransmission (ShadeContext &sc, IllumParams &ip, Color &mapClr, float amount)
 Compute the transmission/refraction color for the sample. More...
 
virtual void AffectReflection (ShadeContext &sc, IllumParams &ip, Color &rcol)
 This method was superseded by ShadeReflection() and is obsolete in release 4.0 and later. More...
 
Compositing Method
virtual void CombineComponents (ShadeContext &sc, IllumParams &ip)
 Finalizes the compositing of the various illumination components. More...
 
Mapping Channel Access
virtual long nTexChannelsSupported ()=0
 Returns the number of texture map map channels supported by this Shader. More...
 
virtual MSTR GetTexChannelName (long nTextureChan) MAX_SEALED
 
virtual MSTR GetTexChannelName (long nTextureChan, bool localized)=0
 Returns the name of the specified texture map channel. More...
 
virtual MSTR GetTexChannelInternalName (long nTextureChan)
 Returns the internal name of the specified texture map. More...
 
virtual long ChannelType (long nTextureChan)=0
 Returns the channel type for the specified texture map channel. More...
 
virtual long StdIDToChannel (long stdID)=0
 Returns the index of this Shader's channels which corresponds to the specified Standard materials texture map ID. More...
 
virtual void Reset ()=0
 Called when the Shader is first activated in the dropdown list of Shader choices. More...
 
- Public Member Functions inherited from SpecialFX
virtual MSTR GetName () MAX_SEALED
 
virtual MSTR GetName (bool localized) const
 
virtual BOOL Active (TimeValue t)
 
virtual void Update (TimeValue t, Interval &valid)
 
virtual SFXParamDlgCreateParamDialog (IRendParams *ip)
 
virtual BOOL SetDlgThing (SFXParamDlg *dlg)
 
virtual int NumGizmos ()
 
virtual INodeGetGizmo (int i)
 
virtual void DeleteGizmo (int i)
 
virtual void AppendGizmo (INode *node)
 
virtual BOOL OKGizmo (INode *node)
 
virtual void EditGizmo (INode *node)
 
virtual void InsertGizmo (int i, INode *node)
 
CoreExport SvGraphNodeReference SvTraverseAnimGraph (IGraphObjectManager *gom, Animatable *owner, int id, DWORD flags)
 
- Public Member Functions inherited from ReferenceTarget
virtual CoreExport void GetClassName (MSTR &s, bool localized=true) const override
 Retrieves the name of the plugin class. More...
 
virtual BOOL IsRefTarget ()
 Checks if this is a ReferenceTarget. More...
 
CoreExport RefResult TestForLoop (const Interval &refInterval, RefMakerHandle hmaker)
 Tests for a cyclical reference. More...
 
CoreExport BOOL HasDependents ()
 Checks if a ReferenceTarget has references. More...
 
CoreExport BOOL HasRealDependents ()
 Checks if this has Real (Strong) Dependents. More...
 
void BeginDependencyTest ()
 Starts Dependency Test. More...
 
BOOL EndDependencyTest ()
 Ends Dependency Test. More...
 
virtual void RefAdded (RefMakerHandle rm)
 Called after a reference is made to a target. More...
 
virtual void RefAddedUndoRedo (RefMakerHandle rm)
 Called after a reference is made to a target because of undo or redo. More...
 
virtual void RefDeleted ()
 Called after a references to this is deleted. More...
 
virtual void RefDeletedUndoRedo ()
 Called after a references to this is deleted because of undo or redo. More...
 
CoreExport RefResult DeleteAllRefsToMe ()
 Deletes all references to this ReferenceTarget. More...
 
CoreExport RefResult TransferReferences (RefTargetHandle oldTarget, BOOL delOld=FALSE)
 Transfers all the references from oldTarget to this. More...
 
CoreExport int DoEnumDependents (DependentEnumProc *dep)
 Begins an enumeration that searches back in the dependency network. More...
 
virtual CoreExport RefTargetHandle Clone (RemapDir &remap)
 This method is used by 3ds Max to clone an object. More...
 
virtual CoreExport void BaseClone (ReferenceTarget *from, ReferenceTarget *to, RemapDir &remap)
 This method copies base class data from an object to its clone. More...
 
virtual CoreExport RefResult NotifyDependents (const Interval &changeInt, PartID partID, RefMessage message, SClass_ID sclass=NOTIFY_ALL, BOOL propagate=TRUE, RefTargetHandle hTarg=NULL, NotifyDependentsOption notifyDependentsOption=REFNOTIFY_ALLOW_OPTIMIZATIONS)
 Notify all dependent RefMakers concerned with the message. More...
 
void FlagDependents (TimeValue t, PartID which=PART_PUT_IN_FG)
 This sends the REFMSG_FLAGDEPENDENTS message up the pipeline. More...
 
virtual void NotifyForeground (TimeValue t)
 This method is called to flag dependents into the FG. More...
 
virtual void NotifyTarget (int message, ReferenceMaker *hMaker)
 Sends messages to ReferenceTargets. More...
 
virtual CoreExport voidGetInterface (ULONG id)
 Inherited from Animatable. More...
 
virtual CoreExport BaseInterfaceGetInterface (Interface_ID id)
 Inherited from Animatable. More...
 
CoreExport ReferenceTarget ()
 Constructor. More...
 
virtual CoreExport RefResult AutoDelete ()
 Deletes the object when it has no more real dependents. More...
 
CoreExport RefResult MaybeAutoDelete ()
 Deletes the object when it has no more real dependents. More...
 
- Public Member Functions inherited from ReferenceMaker
CoreExport RefResult ReplaceReference (int which, RefTargetHandle newtarg, BOOL delOld=TRUE)
 Used when cloning reference makers. More...
 
CoreExport RefResult DeleteAllRefsFromMe ()
 Deletes all references from this ReferenceMaker. More...
 
CoreExport RefResult DeleteAllRefs ()
 Deletes all references both to and from this item. More...
 
CoreExport RefResult DeleteReference (int i)
 Deletes the specified reference. More...
 
virtual BOOL CanTransferReference (int i)
 Tells whether this reference can be transfered. More...
 
CoreExport ReferenceSaveManagerGetReferenceSaveManager ()
 Access the ReferenceSaveManager of this ReferenceMaker. More...
 
virtual int RemapRefOnLoad (int iref)
 Used to load old files with references. More...
 
virtual CoreExport void RescaleWorldUnits (float f)
 Rescale size of all world units in reference hierarchy. More...
 
virtual CoreExport void EnumAuxFiles (AssetEnumCallback &assetEnum, DWORD flags)
 Enumerate auxiliary files (e.g. bitmaps) More...
 
virtual CoreExport void SaveEnum (SaveEnumProc &sep, BOOL isNodeCall=0)
 The default save enumeration. More...
 
virtual CoreExport bool SpecifySaveReferences (ReferenceSaveManager &referenceSaveManager)
 Used to specify reference slot remapping during scene file save. More...
 
CoreExport int DoEnumDependents (DependentEnumProc *dep)
 Begins an enumeration that searches back in the dependency network. More...
 
CoreExport bool EnumRefHierarchy (RefEnumProc &proc, bool includeCustAttribs=true, bool includeIndirectRefs=true, bool includeNonPersistentRefs=true, bool preventDuplicatesViaFlag=true)
 This method provides a general purpose reference enumerator. More...
 
CoreExport int FindRef (RefTargetHandle rtarg)
 Get the index of the ReferenceTarget. More...
 
virtual BOOL IsRefMaker ()
 Tells whether it is a ReferenceMaker. More...
 
virtual BOOL IsRealDependency (ReferenceTarget *rtarg)
 Returns whether this is a "real" (strong) dependency or not. More...
 
virtual BOOL ShouldPersistWeakRef (RefTargetHandle rtarg)
 Specifies whether a weak reference is to be persisted on a partial load or save. More...
 
CoreExport ReferenceMaker ()
 Constructor. More...
 
CoreExport void DeleteMe ()
 Deletes an instance of this class. More...
 
virtual CoreExport int NumRefs ()
 Returns the total number of references this ReferenceMaker can hold. More...
 
virtual CoreExport RefTargetHandle GetReference (int i)
 Returns the 'i-th' reference. More...
 
- Public Member Functions inherited from Animatable
virtual void FreeCaches ()
 
virtual int NumChildren ()
 
virtual AnimatableChildAnim (int i)
 
virtual CoreExport MSTR NodeName ()
 
virtual void EditTrack ()
 
virtual CoreExport BOOL SubAnimSetKeyBufferPresent (int subNum)
 returns true if the sub-anim has a "Set Key" buffer present More...
 
virtual BOOL SetKeyBufferPresent ()
 returns true if there is a "Set Key" buffer present More...
 
virtual CoreExport void SubAnimCommitSetKeyBuffer (TimeValue t, int subNum)
 Commit any "Set Key" buffers on the given sub-anim. More...
 
virtual void CommitSetKeyBuffer (TimeValue t)
 Commit any "Set Key" buffers. More...
 
virtual CoreExport void SubAnimRevertSetKeyBuffer (int subNum)
 Revert any "Set Key" buffers on the given sub-anim. More...
 
virtual void RevertSetKeyBuffer ()
 Revert any "Set Key" buffers. More...
 
virtual LRESULT CALLBACK TrackViewWinProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
 This function is obsolete. More...
 
virtual bool IsParamBlockDesc2Used (ParamBlockDesc2 *desc)
 Returns true if the passed description is being used. More...
 
virtual bool GetMacroRecorderName (bool used_as_rhs_value, MSTR &objectSpecifiedName)
 This method is called to access the object specified name to use for the Maxscript macrorecorder. More...
 
CoreExport Animatable ()
 Constructor. More...
 
virtual CoreExport void DeleteThis ()
 Deletes an instance of this class. More...
 
virtual void GetClassName (MSTR &s) MAX_SEALED
 
MSTR ClassName (bool localized=true) const
 Returns the name of the plugin class. More...
 
virtual CoreExport Class_ID ClassID ()
 Retrieves a constant that uniquely identifies the plugin class. More...
 
virtual void BeginEditParams (IObjParam *ip, ULONG flags, Animatable *prev=NULL)
 
virtual void EndEditParams (IObjParam *ip, ULONG flags, Animatable *next=NULL)
 
virtual CoreExport void ReleaseInterface (ULONG id, void *i)
 
virtual CoreExport int SetProperty (ULONG id, void *data)
 
virtual CoreExport voidGetProperty (ULONG id)
 
CoreExport void AppendProperty (AnimProperty *prop)
 A function to directly add arbitrary properties to this object developers should ensure that the properties ID does not conflict with any Max-specific IDs. More...
 
CoreExport AnimPropertyFindProperty (DWORD id)
 Find any property. More...
 
CoreExport void AddAppDataChunk (const Class_ID &cid, SClass_ID sid, DWORD sbid, DWORD len, void *data)
 Adds application/plugin specific (custom) data to an Animatable. More...
 
CoreExport AppDataChunkGetAppDataChunk (const Class_ID &cid, SClass_ID sid, DWORD sbid)
 Retrieves the application/plugin specific (custom) data stored with an Animatable. More...
 
CoreExport BOOL RemoveAppDataChunk (const Class_ID &cid, SClass_ID sid, DWORD sbid)
 Deletes the application/plugin specific (custom) data stored with an Animatable. More...
 
CoreExport void ClearAllAppData ()
 Deletes all application/plugin specific (custom) data stored with an Animatable. More...
 
virtual int NumSubs ()
 
virtual AnimatableSubAnim (int i)
 
virtual MSTR SubAnimName (int i) MAX_SEALED
 
virtual CoreExport MSTR SubAnimName (int i, bool localized)
 
virtual BOOL CanDeleteSubAnim (int i)
 
virtual void DeleteSubAnim (int i)
 
virtual DWORD GetSubAnimCurveColor (int subNum)
 
virtual int SubNumToRefNum (int subNum)
 
virtual BOOL CanCopyAnim ()
 
CoreExport int HasSubElements (int type=0)
 
virtual int GetSubFCurveExtents (int subNum, ParamDimensionBase *dim, float &min, float &max, DWORD flags)
 The values max and min should be initialized before calling this function. More...
 
virtual ParamDimensionGetParamDimension (int i)
 
virtual BOOL SelectSubAnim (int subNum)
 
virtual BOOL BypassTreeView ()
 
virtual BOOL BypassTrackBar ()
 
virtual BOOL InvisibleProperty ()
 
virtual int NumKeys ()
 
virtual TimeValue GetKeyTime (int index)
 
virtual int GetKeyIndex (TimeValue t)
 
virtual BOOL GetNextKeyTime (TimeValue t, DWORD flags, TimeValue &nt)
 
virtual void CopyKeysFromTime (TimeValue src, TimeValue dst, DWORD flags)
 
virtual void DeleteKeyAtTime (TimeValue t)
 
virtual BOOL IsKeyAtTime (TimeValue t, DWORD flags)
 
virtual int GetKeyTimes (Tab< TimeValue > &times, Interval range, DWORD flags)
 
virtual int GetKeySelState (BitArray &sel, Interval range, DWORD flags)
 
CoreExport void OpenTreeEntry (int type, DWORD tv)
 
CoreExport void CloseTreeEntry (int type, DWORD tv)
 
CoreExport int IsTreeEntryOpen (int type, DWORD tv)
 
CoreExport BOOL GetSelInTrackView (DWORD tv)
 
CoreExport void SetSelInTrackView (DWORD tv, BOOL sel)
 
CoreExport BOOL InTrackViewSelSet (int which)
 
CoreExport void SetTrackViewSelSet (int which, BOOL inOut)
 
virtual BOOL AssignController (Animatable *control, int subAnim)
 
virtual BOOL CanAssignController (int subAnim)
 Return true if we can reassign the subanim specified. More...
 
virtual BOOL CanMakeUnique ()
 
CoreExport int EnumAnimTree (AnimEnum *animEnum, Animatable *client, int subNum)
 
virtual int RenderBegin (TimeValue t, ULONG flags=0)
 
virtual int RenderEnd (TimeValue t)
 
virtual CoreExport Interval GetTimeRange (DWORD flags)
 
virtual void EditTimeRange (Interval range, DWORD flags)
 
virtual void DeleteTime (Interval iv, DWORD flags)
 
virtual void ReverseTime (Interval iv, DWORD flags)
 
virtual void ScaleTime (Interval iv, float s)
 
virtual void InsertTime (TimeValue ins, TimeValue amount)
 
virtual BOOL SupportTimeOperations ()
 
virtual CoreExport void MapKeys (TimeMap *map, DWORD flags)
 
virtual void DeleteKeys (DWORD flags)
 
virtual void DeleteKeyByIndex (int index)
 
virtual void SelectKeys (TrackHitTab &sel, DWORD flags)
 
virtual void SelectSubKeys (int subNum, TrackHitTab &sel, DWORD flags)
 
virtual void SelectSubCurve (int subNum, BOOL sel)
 
virtual void SelectKeyByIndex (int i, BOOL sel)
 
virtual BOOL IsKeySelected (int i)
 
virtual void FlagKey (TrackHitRecord hit)
 
virtual int GetFlagKeyIndex ()
 
virtual int NumSelKeys ()
 
virtual void CloneSelectedKeys (BOOL offset=FALSE)
 
virtual void AddNewKey (TimeValue t, DWORD flags)
 
virtual void MoveKeys (ParamDimensionBase *dim, float delta, DWORD flags)
 
virtual void ScaleKeyValues (ParamDimensionBase *dim, float origin, float scale, DWORD flags)
 
virtual void SelectCurve (BOOL sel)
 
virtual BOOL IsCurveSelected ()
 Returns TRUE if the function curve is selected; otherwise returns FALSE. More...
 
virtual BOOL IsSubCurveSelected (int subNum)
 Returns the selected state of the sub-curve whose index is passed. More...
 
virtual int GetSelKeyCoords (TimeValue &t, float &val, DWORD flags)
 
virtual void SetSelKeyCoords (TimeValue t, float val, DWORD flags)
 
virtual int SetSelKeyCoordsExpr (ParamDimension *dim, const MCHAR *timeExpr, const MCHAR *valExpr, DWORD flags)
 
virtual void AdjustTangents (TrackHitRecord hit, ParamDimensionBase *dim, Rect &rcGraph, float tzoom, int tscroll, float vzoom, int vscroll, int dx, int dy, DWORD flags)
 
virtual void AdjustTangents (TrackHitRecord hit, ParamDimensionBase *dim, float angle, float length, DWORD flags)
 
virtual CoreExport BOOL IsAnimated ()
 
virtual BOOL CanCopyTrack (Interval iv, DWORD flags)
 
virtual BOOL CanPasteTrack (TrackClipObject *cobj, Interval iv, DWORD flags)
 
virtual TrackClipObjectCopyTrack (Interval iv, DWORD flags)
 
virtual void PasteTrack (TrackClipObject *cobj, Interval iv, DWORD flags)
 
virtual BOOL CanCopySubTrack (int subNum, Interval iv, DWORD flags)
 
virtual BOOL CanPasteSubTrack (int subNum, TrackClipObject *cobj, Interval iv, DWORD flags)
 
virtual TrackClipObjectCopySubTrack (int subNum, Interval iv, DWORD flags)
 
virtual void PasteSubTrack (int subNum, TrackClipObject *cobj, Interval iv, DWORD flags)
 
virtual int GetTrackVSpace (int lineHeight)
 
virtual int HitTestTrack (TrackHitTab &hits, Rect &rcHit, Rect &rcTrack, float zoom, int scroll, DWORD flags)
 
virtual int PaintTrack (ParamDimensionBase *dim, HDC hdc, Rect &rcTrack, Rect &rcPaint, float zoom, int scroll, DWORD flags)
 
virtual int PaintSubTrack (int subNum, ParamDimensionBase *dim, HDC hdc, Rect &rcTrack, Rect &rcPaint, float zoom, int scroll, DWORD flags)
 
virtual int PaintFCurves (ParamDimensionBase *dim, HDC hdc, Rect &rcGraph, Rect &rcPaint, float tzoom, int tscroll, float vzoom, int vscroll, DWORD flags)
 
virtual int HitTestFCurves (ParamDimensionBase *dim, TrackHitTab &hits, Rect &rcHit, Rect &rcGraph, float tzoom, int tscroll, float vzoom, int vscroll, DWORD flags)
 
virtual int PaintSubFCurves (int subNum, ParamDimensionBase *dim, HDC hdc, Rect &rcGraph, Rect &rcPaint, float tzoom, int tscroll, float vzoom, int vscroll, DWORD flags)
 
virtual int HitTestSubFCurves (int subNum, ParamDimensionBase *dim, TrackHitTab &hits, Rect &rcHit, Rect &rcGraph, float tzoom, int tscroll, float vzoom, int vscroll, DWORD flags)
 
virtual void EditTrackParams (TimeValue t, ParamDimensionBase *dim, const MCHAR *pname, HWND hParent, IObjParam *ip, DWORD flags)
 
virtual int TrackParamsType ()
 
virtual int GetFCurveExtents (ParamDimensionBase *dim, float &min, float &max, DWORD flags)
 This method is called to calculate the largest and smallest values of the anim. More...
 
CoreExport void AddNoteTrack (NoteTrack *note)
 
CoreExport void DeleteNoteTrack (NoteTrack *note, BOOL delNote=TRUE)
 
CoreExport BOOL HasNoteTracks ()
 
CoreExport int NumNoteTracks ()
 
CoreExport NoteTrackGetNoteTrack (int i)
 
virtual void FreeAllBitmaps ()
 
virtual void GetSystemNodes (INodeTab &nodes, SysNodeContext Context)
 
virtual BOOL IsSubClassOf (Class_ID classID)
 returns true if the animatable has sub-classed off the given class More...
 
virtual CoreExport void MouseCycleCompleted (TimeValue t)
 
virtual CoreExport void MouseCycleStarted (TimeValue t)
 
virtual int NumParamBlocks ()
 
virtual IParamBlock2GetParamBlock (int i)
 
virtual IParamBlock2GetParamBlockByID (short id)
 
CoreExport bool SvSaveData (ISave *isave, USHORT id)
 
CoreExport bool SvLoadData (ILoad *iLoad)
 
CoreExport DWORD SvGetRefIndex ()
 
CoreExport void SvSetRefIndex (DWORD i)
 
CoreExport bool SvDeleteRefIndex ()
 
CoreExport SvGraphNodeReference SvStdTraverseAnimGraph (IGraphObjectManager *gom, Animatable *owner, int id, DWORD flags)
 
virtual CoreExport bool SvCanInitiateLink (IGraphObjectManager *gom, IGraphNode *gNode)
 
virtual CoreExport bool SvCanConcludeLink (IGraphObjectManager *gom, IGraphNode *gNode, IGraphNode *gNodeChild)
 
virtual CoreExport MSTR SvGetName (IGraphObjectManager *gom, IGraphNode *gNode, bool isBeingEdited)
 
virtual CoreExport bool SvCanSetName (IGraphObjectManager *gom, IGraphNode *gNode)
 
virtual CoreExport bool SvSetName (IGraphObjectManager *gom, IGraphNode *gNode, const MSTR &name)
 
virtual CoreExport bool SvCanRemoveThis (IGraphObjectManager *gom, IGraphNode *gNode)
 
virtual CoreExport bool SvRemoveThis (IGraphObjectManager *gom, IGraphNode *gNode)
 Called when the user deletes this object in the schematic view... More...
 
virtual CoreExport bool SvIsSelected (IGraphObjectManager *gom, IGraphNode *gNode)
 Returns true if the object is selected in its schematic view. More...
 
virtual CoreExport bool SvIsHighlighted (IGraphObjectManager *gom, IGraphNode *gNode)
 
virtual CoreExport COLORREF SvHighlightColor (IGraphObjectManager *gom, IGraphNode *gNode)
 
virtual CoreExport COLORREF SvGetSwatchColor (IGraphObjectManager *gom, IGraphNode *gNode)
 
virtual CoreExport bool SvIsInactive (IGraphObjectManager *gom, IGraphNode *gNode)
 
virtual CoreExport bool SvLinkChild (IGraphObjectManager *gom, IGraphNode *gNodeThis, IGraphNode *gNodeChild)
 
virtual CoreExport bool SvHandleDoubleClick (IGraphObjectManager *gom, IGraphNode *gNode)
 
virtual CoreExport MultiSelectCallbackSvGetMultiSelectCallback (IGraphObjectManager *gom, IGraphNode *gNode)
 
virtual CoreExport bool SvCanSelect (IGraphObjectManager *gom, IGraphNode *gNode)
 
virtual CoreExport bool SvEditProperties (IGraphObjectManager *gom, IGraphNode *gNode)
 
virtual CoreExport MSTR SvGetTip (IGraphObjectManager *gom, IGraphNode *gNode)
 
virtual CoreExport MSTR SvGetRefTip (IGraphObjectManager *gom, IGraphNode *gNode, IGraphNode *gNodeMaker)
 
virtual CoreExport bool SvCanDetach (IGraphObjectManager *gom, IGraphNode *gNode)
 
virtual CoreExport bool SvDetach (IGraphObjectManager *gom, IGraphNode *gNode)
 
virtual CoreExport MSTR SvGetRelTip (IGraphObjectManager *gom, IGraphNode *gNodeTarget, int id, IGraphNode *gNodeMaker)
 Returns a string to be displayed in the tip window in the schematic view for a relationship from "gNodeMaker" to "gNodeTarget"... More...
 
virtual CoreExport bool SvCanDetachRel (IGraphObjectManager *gom, IGraphNode *gNodeTarget, int id, IGraphNode *gNodeMaker)
 Returns true if this object can respond to the SvDetachRel(...) method... More...
 
virtual CoreExport bool SvDetachRel (IGraphObjectManager *gom, IGraphNode *gNodeTarget, int id, IGraphNode *gNodeMaker)
 Detach this relationship. More...
 
virtual CoreExport bool SvHandleRelDoubleClick (IGraphObjectManager *gom, IGraphNode *gNodeTarget, int id, IGraphNode *gNodeMaker)
 Called when this relationship is double-clicked in the schematic view... More...
 
CoreExport ICustAttribContainerGetCustAttribContainer ()
 This method returns a pointer to the custom attributes container interface class. More...
 
CoreExport void AllocCustAttribContainer ()
 This method allocates space for a custom attributes container. More...
 
CoreExport void DeleteCustAttribContainer ()
 This method deletes space used by a custom attributes container. More...
 
void SetAFlag (DWORD mask)
 
void ClearAFlag (DWORD mask)
 Clears one or more bits in the Animatable flags. More...
 
bool TestAFlag (DWORD mask) const
 Tests one or more bits in the Animatable flags. More...
 
void SetAFlagEx (DWORD mask)
 Sets one or more bits in the Animatable extended flags. More...
 
void ClearAFlagEx (DWORD mask)
 Clears one or more bits in the Animatable extended flags. More...
 
bool TestAFlagEx (DWORD mask) const
 Tests one or more bits in the Animatable extended flags. More...
 
CoreExport bool TestFlagBit (int index)
 Tests the specified flag bit. More...
 
CoreExport void SetFlagBit (int index, bool newValue=true)
 Sets the specified flag bit. More...
 
CoreExport void ClearFlagBit (int index)
 Clears the specified flag bit. More...
 
- 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 Animatable
static CoreExport BOOL IsDeleted (Animatable *anim)
 Debug method to determine whether an object has been deleted. More...
 
static CoreExport AnimHandle GetHandleByAnim (Animatable *anim)
 Get the unique handle for an Animatable object. More...
 
static CoreExport AnimatableGetAnimByHandle (AnimHandle handle)
 Get an Animatable object from its unique handle. More...
 
static CoreExport AnimHandle GetNextHandle ()
 Get the unique handle for the next Animatable object to be created. More...
 
static CoreExport void EnumerateAllAnimatables (EnumAnimList &enumProcObject)
 Enumerator to enumerate across all animatables. More...
 
static CoreExport bool RegisterAppDataLoadCallback (const Class_ID &cid, SClass_ID sid, APPDATALOADPROC proc)
 Registers a callback proc that is called when an AppDataChunk is read from a scene file. More...
 
static CoreExport bool UnRegisterAppDataLoadCallback (const Class_ID &cid, SClass_ID sid, APPDATALOADPROC proc)
 Unregisters a callback proc that is called when an AppDataChunk is read from a scene file. More...
 
static CoreExport bool RegisterAppDataLoadCallback (DWORD sbid, APPDATALOADPROC proc)
 Registers a callback proc that is called when an AppDataChunk is read from a scene file. More...
 
static CoreExport bool UnRegisterAppDataLoadCallback (DWORD sbid, APPDATALOADPROC proc)
 Unregisters a callback proc that is called when an AppDataChunk is read from a scene file. More...
 
static CoreExport int RequestFlagBit ()
 Requests an unique flag bit index. More...
 
static CoreExport void ReleaseFlagBit (int index)
 Releases the flag bit index. More...
 
static CoreExport void ClearFlagBitInAllAnimatables (int index)
 Clears the specified flag bit in all Animatables. More...
 
- 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...
 
- Public Attributes inherited from SpecialFX
MSTR name
 
- Static Public Attributes inherited from Animatable
static const AnimHandle kInvalidAnimHandle = 0
 
- Protected Member Functions inherited from ReferenceTarget
virtual CoreExport int DoEnumDependentsImpl (DependentEnumProc *dep)
 Method to perform an enumeration on a ReferenceTarget. More...
 
virtual CoreExport ~ReferenceTarget ()=0
 Destructor. More...
 
- Protected Member Functions inherited from ReferenceMaker
virtual CoreExport ~ReferenceMaker ()=0
 Destructor. More...
 
virtual CoreExport void SetReference (int i, RefTargetHandle rtarg)
 Stores a ReferenceTarget as its 'i-th' reference`. More...
 
void BlockEval ()
 Validates a given reference link between this reference maker and its reference target. More...
 
void UnblockEval ()
 Validates a given reference link between this reference maker and its reference target. More...
 
int Evaluating ()
 Validates a given reference link between this reference maker and its reference target. More...
 
CoreExport RefResult StdNotifyRefChanged (const Interval &changeInt, RefTargetHandle hTarget, PartID partID, RefMessage message, BOOL propagate, NotifyDependentsOption notifyDependentsOption)
 Validates a given reference link between this reference maker and its reference target. More...
 
- Protected Member Functions inherited from Animatable
virtual CoreExport ~Animatable ()=0
 Destructor. More...
 
- Protected Member Functions inherited from Noncopyable
 Noncopyable ()
 
 ~Noncopyable ()
 
- Protected Attributes inherited from Animatable
DWORD aflag
 
AnimPropertyList aprops
 

Detailed Description

One of the base classes for the creation of the Shaders, which plug-in to the Standard material[?].

Note that developers should derive their plug-in Shader from Class Shader and not from this class directly. If not, the interactive renderer will not know how to render the Shader in the viewports. Developers of this plug-in type also need to have an understanding of how the Standard material and the Shader work together. Every material has a Shader. The Shader is the piece of code which controls how light is reflected off the surface. The Standard material is the mapping mechanism which handles all the texturing for the material. Managing the user interface is also done by the standard material. This way the Shader plug-in needs only to worry about the interaction of light on the surface.

Prior to release 3, developers could write Material plug-ins that performed their own shading. However, this was usually a major programming task. Release 3 provides the simpler Shader plug-in that would benefit from sharing all the common capabilities. The Standard material, with its 'blind' texturing mechanism, makes this possible. It doesn't know what it is texturing - it simply textures 'stuff'. The shader names the channels (map), fills in the initial values, and specifies if they are a single channel (mono) or a triple channel (color). The Standard material handles the rest including managing the user interface. The main part of the code in a Shader is responsible for supplying this information to a Standard material. The values are passed and received back in class IllumParams. There is a specific method named Illum() in a shader, which actually does the shading.

Plug-In Information:
Class defined in: SHADER.H
Super class ID: SHADER_CLASS_ID
Standard file name extension: DLB
Extra include file needed: SHADERS.H
See also
SpecialFX, ShaderParamDlg, ShadeContext, IllumParams, IMtlParams, StdMat2 Mtl, Color, ILoad, ISave

Member Function Documentation

◆ NotifyRefChanged()

RefResult NotifyRefChanged ( const Interval changeInt,
RefTargetHandle  hTarget,
PartID partID,
RefMessage  message,
BOOL  propagate 
)
inlinevirtual

Receives and responds to messages.

A plugin which makes references must implement a method to receive and respond to messages broadcast by its dependents. This is done by implementing NotifyRefChanged(). The plugin developer usually implements this method as a switch statement where each case is one of the messages the plugin needs to respond to. The Method StdNotifyRefChanged calls this, which can change the partID to new value. If it doesn't depend on the particular message& partID, it should return REF_DONTCARE.

  • For developer that need to update a dialog box with data about an object you reference note the following related to this method: This method may be called many times. For instance, say you have a dialog box that displays data about an object you reference. This method will get called many time during the drag operations on that object. If you updated the display every time you'd wind up with a lot of 'flicker' in the dialog box. Rather than updating the dialog box each time, you should just invalidate the window in response to the NotifyRefChanged() call. Then, as the user drags the mouse your window will still receive paint messages. If the scene is complex the user may have to pause (but not let up on the mouse) to allow the paint message to go through since they have a low priority. This is the way many windows in 3ds Max work.
Parameters
changeInt- This is the interval of time over which the message is active. Currently, all plug-ins will receive FOREVER for this interval, with the exception of REFMSG_FLAGDEPENDENTS notifications. In that case, changeInt.Start() is the timepoint to perform the dependency test.
hTarget- This is the handle of the reference target the message was sent by. The reference maker uses this handle to know specifically which reference target sent the message.
partID- This contains information specific to the message passed in. Some messages don't use the partID at all. See the section List of Reference Messages for more information about the meaning of the partID for some common messages.
message- The message parameters passed into this method is the specific message which needs to be handled.
propagate- If called through ReferenceMaker::NotifyDependents(), the value of 'propagate' passed to it. Used if calling NotifyDependents() from within NotifyRefChanged().
Returns
The return value from this method is of type RefResult. This is usually REF_SUCCEED indicating the message was processed. Sometimes, the return value may be REF_STOP. This return value is used to stop the message from being propagated to the dependents of the item.

Implements ReferenceMaker.

269  {return REF_SUCCEED;}
@ REF_SUCCEED
The operation succeeded.
Definition: ref.h:765

◆ SuperClassID()

SClass_ID SuperClassID ( )
inlinevirtual

Retrieves a constant representing the type of the plugin.

Returns
A super class id that uniquely identifies the type (category) of the plugin. Note that several plugin classes can be of the same type, thus return the same super class id. Plugins are uniquely identified by their class ids.
See also
SClass_ID

Reimplemented from ReferenceTarget.

271 {return SHADER_CLASS_ID;}
#define SHADER_CLASS_ID
Standard material shader super-class ID.
Definition: plugapi.h:452

◆ BypassPropertyLevel()

BOOL BypassPropertyLevel ( )
inlinevirtual

Wants to promote the shader properties to the material level.

Reimplemented from Animatable.

274 { return TRUE; }

◆ GetRequirements()

virtual ULONG GetRequirements ( int  subMtlNum)
pure virtual

Returns the requirements of the Shader for the specified sub-material.

Many objects in the rendering pipeline use the requirements to tell the renderer what data needs to be available. The shader's requirements are OR'd with the combined map requirements and returned to the renderer via the Stdmtl2's GetRequirements() function.

Parameters
subMtlNumThis parameter is not used.
Returns
One or more flag from Material Requirements Flags
See also
Material Requirements Flags (defined in imtl.h)

◆ CreateParamDialog()

virtual ShaderParamDlg* CreateParamDialog ( HWND  hOldRollup,
HWND  hwMtlEdit,
IMtlParams imp,
StdMat2 theMtl,
int  rollupOpen,
int  n = 0 
)
pure virtual

Put up a dialog that lets the user edit the plug-ins parameters.

This method creates and returns a pointer to a ShaderParamDlg object and puts up the dialog which lets the user edit the Shader's parameters.

Parameters
hOldRollupThe window handle of the old rollup. If non-NULL, the IMtlParams::ReplaceRollupPage() method is usually used instead of IMtlParams::AddRollupPage() to present the rollup.
hwMtlEditThe window handle of the material editor.
impThe interface pointer for calling methods in 3ds Max.
theMtlPointer to the Standard material being edited.
rollupOpenTrue to have the UI rollup open; false to have it closed.
nThis parameter is available in release 4.0 and later only. Specifies the number of the rollup to create. Reserved for future use with multiple rollups.

◆ NParamDlgs()

virtual int NParamDlgs ( )
inlinevirtual

Returns the number of rollups this shader is requesting.

314 { return 1; }

◆ GetParamDlg()

virtual ShaderParamDlg* GetParamDlg ( int  n = 0)
pure virtual

Returns a pointer to the ShaderParamDlg object which manages the user interface.

Parameters
nSpecifies the rollup to get ShaderParamDlg for. Reserved for future use with multiple rollups.

◆ SetParamDlg()

virtual void SetParamDlg ( ShaderParamDlg newDlg,
int  n = 0 
)
pure virtual

Sets the ShaderParamDlg object which manages the user interface to the one passed.

Parameters
newDlgPoints to the new ShaderParamDlg object.
nSpecifies the rollup to set ShaderParamDlg for. Reserved for future use with multiple rollups.

◆ Save()

IOResult Save ( ISave isave)
inlinevirtual

Saves and loads the plug-in's name.

These should be called at the start of a plug-in's Save() method.

Parameters
*isaveAn interface for saving data.

Reimplemented from SpecialFX.

341 { return SpecialFX::Save(isave); }
CoreExport IOResult Save(ISave *isave)

◆ Load()

IOResult Load ( ILoad iload)
inlinevirtual

Loads the plug-in's name.

This should be called at the start of a plug-in's Load() method.

Parameters
*iloadAn interface for loading data.

Reimplemented from SpecialFX.

346 { return SpecialFX::Load(iload); }
CoreExport IOResult Load(ILoad *iload)

◆ SupportStdParams()

virtual ULONG SupportStdParams ( )
pure virtual

Std parameter support.

Returns a value which indicates which of the standard parameters are supported.

Returns
A Shader Standard Parameter Flags.
See also
Standard Parameter flags

◆ ConvertParamBlk()

virtual void ConvertParamBlk ( ParamBlockDescID descOld,
int  oldCount,
IParamBlock oldPB 
)
inlinevirtual

Required for R2.5 shaders to convert the previous Standard material parameter blocks to the current version.

Parameters
descOldPointer to the old parameter block descriptor.
oldCountThe number in the array of parameters above.
oldPBPointer to the old parameter block.
365 {};

◆ GetIllumParams()

virtual void GetIllumParams ( ShadeContext sc,
IllumParams ip 
)
pure virtual

Updates the "channels"(as well as other) data member of the "IllumParams" object passed to it with the "local" variables of the material for possible mapping prior to being given to the Shader's Illum() method.

The shader plug-in copies the state of all its parameters (at their current animation state) into the data members of the "IllumParams" passed.

Parameters
scThe ShadeContext which provides information on the pixel being shaded.
ipPointer to the IllumParams to update.

◆ Illum()

virtual void Illum ( ShadeContext sc,
IllumParams ip 
)
pure virtual

This is the illumination function for the Shader.

Developers will find it very helpful to review the Mtl::Shade() method of the Standard material. This is the main method of the material which computes the color of the point being rendered. This code is available in /MAXSDK/SAMPLES/MATERIALS/STDMTL2.CPP. This code shows how the Standard calls Shader::GetIllumParams(), sets up mapping channels, calls this Illum() method, and calls the Shader::CombineComponents() method when all done.

Parameters
scThe ShadeContext which provides information on the pixel being shaded.
ipThe object whose data members provide communication between 3ds Max and the shader. Input values are read from here and output values are also stored here. Note that the "XOut" (ambIllumout, etc) data members of this class are initialized to 0 before the first call to this method. The input to this method has the textured illumination parameters, the bump perturbed normal, the view vector, the raw (unattenuated) colors in the reflection and refraction directions, etc.
Sample Code:
Below is a brief analysis of the standard Blinn shader Illum() method. This is the standard 'computer graphics look' type shader supplied with 3ds Max. The entire method follows:

void Blinn2::Illum(ShadeContext &sc, IllumParams &ip)
{
Color lightCol;
// Blinn style phong
BOOL is_shiny= (ip.channels[ID_SS].r > 0.0f) ? 1:0;
double phExp = pow(2.0, ip.channels[ID_SH].r * 10.0) * 4.0;
for (int i=0; i<sc.nLights; i++) {
l = sc.Light(i);
float NL, diffCoef;
Point3 L;
if (l->Illuminate(sc,ip.N,lightCol,L,NL,diffCoef)) {
if (l->ambientOnly) {
ip.ambIllumOut += lightCol;
continue;
}
if (NL<=0.0f)
continue;
// diffuse
if (l->affectDiffuse)
ip.diffIllumOut += diffCoef * lightCol;
// specular (Phong2)
if (is_shiny&&l->affectSpecular) {
Point3 H = Normalize(L-ip.V);
float c = DotProd(ip.N,H);
if (c>0.0f) {
if (softThresh!=0.0 && diffCoef<softThresh) {
c *= Soften(diffCoef/softThresh);
}
c = (float)pow((double)c, phExp);
ip.specIllumOut += c * ip.channels[ID_SS].r * lightCol;
}
}
}
}
// Apply mono self illumination
if ( ! selfIllumClrOn ) {
float si = ip.channels[ID_SI].r;
ip.diffIllumOut = (si>=1.0f) ? Color(1.0f,1.0f,1.0f):ip.diffIllumOut * (1.0f-si) + si;
}
else {
// colored self illum,
}
// now we can multiply by the clrs,
// the following is applicable only in R4
int chan = ip.stdIDToChannel[ ID_RL ];
ShadeTransmission(sc, ip, ip.channels[chan], ip.refractAmt);
chan = ip.stdIDToChannel[ ID_RR ];
ShadeReflection( sc, ip, ip.channels[chan] );
CombineComponents( sc, ip );
}
virtual void ShadeReflection(ShadeContext &sc, IllumParams &ip, Color &mapClr)
Compute the reflected color from the sc, ip, and reflection map (or ray) color.
Definition: shaders.h:636
virtual void CombineComponents(ShadeContext &sc, IllumParams &ip)
Finalizes the compositing of the various illumination components.
Definition: shaders.h:697
virtual void ShadeTransmission(ShadeContext &sc, IllumParams &ip, Color &mapClr, float amount)
Compute the transmission/refraction color for the sample.
Definition: shaders.h:648
Definition: color.h:73
float r
These values are in the range 0.0 to 1.0.
Definition: color.h:78
Definition: IllumParams.h:112
Color ambIllumOut
Definition: IllumParams.h:129
Color diffIllumOut
Definition: IllumParams.h:129
Color selfIllumOut
Definition: IllumParams.h:129
float refractAmt
Definition: IllumParams.h:123
int * stdIDToChannel
Definition: IllumParams.h:126
Color channels[STD2_NMAX_TEXMAPS]
Definition: IllumParams.h:119
Color specIllumOut
Definition: IllumParams.h:130
Definition: imtl.h:123
BOOL affectDiffuse
Definition: imtl.h:125
BOOL ambientOnly
Definition: imtl.h:127
virtual BOOL Illuminate(ShadeContext &sc, Point3 &normal, Color &color, Point3 &dir, float &dot_nl, float &diffuseCoef)
Definition: imtl.h:178
BOOL affectSpecular
Definition: imtl.h:126
Definition: point3.h:54
Definition: ShadeContext.h:369
int nLights
Definition: ShadeContext.h:380
virtual LightDesc * Light(int n)=0
constexpr double DotProd(const DPoint2 &a, const DPoint2 &b)
Returns the dot product of two DPoint2s.
Definition: dpoint2.h:308
DPoint2 Normalize(const DPoint2 &p)
Returns a unit vector.
Definition: dpoint2.h:302
#define ID_RR
Refraction.
Definition: TextureMapIndexConstants.h:25
#define ID_SS
Specular Level (Shininess strength in 3ds Max release 2.0 and earlier)
Definition: TextureMapIndexConstants.h:19
#define ID_RL
Reflection.
Definition: TextureMapIndexConstants.h:24
#define ID_DI
Diffuse.
Definition: TextureMapIndexConstants.h:16
#define ID_SP
Specular.
Definition: TextureMapIndexConstants.h:17
#define ID_SI
Self-illumination.
Definition: TextureMapIndexConstants.h:20
#define ID_AM
Ambient.
Definition: TextureMapIndexConstants.h:15
#define ID_SH
Glossiness (Shininess in 3ds Max release 2.0 and earlier)
Definition: TextureMapIndexConstants.h:18

Some of the key parts of this method are discussed below:

The is_shiny line sets a boolean based on if the Shader has a shininess setting > 0. Note that the Blinn shader uses the same channel ordering as the original Standard material so it can index its channels using the standard ID ID_SS.

BOOL is_shiny= (ip.channels[ID_SS].r > 0.0f) ? 1:0;

Next the 'Phong Exponent' is computed. This is just a function that is used to give a certain look. It uses 2^(Shinniness *10) * 4. This calculation simply 'feels right' and gives a good look.

double phExp = pow(2.0, ip.channels[ID_SH].r * 10.0) * 4.0;

The following loop sums up the effect of each light on this point on surface.

for (int i=0; i<sc.nLights; i++) {

Inside the loop, the light descriptor is grabbed from the ShadeContext:

l = sc.Light(i);

The LightDesc::Illuminate() method is then called to compute some data:

if (l->Illuminate(sc,ip.N,lightCol,L,NL,diffCoef)) {

To Illuminate() is passed the ShadeContext (sc), and the normal to the surface (ip.N) (pointing away from the surface point).

The method returns the light color (lightCol), light vector (L) (which points from the surface point to the light), the dot product of N and L (NL) and the diffuse coefficient (diffCoef). The diffuse coefficient is similar to NL but has the atmosphere between the light and surface point taken into account as well.

The next piece of code checks if the light figures into the computations:

if (NL<=0.0f)

continue;

If NL<0 then the cosine of the vectors is greater than 90 degrees. This means the light is looking at the back of the surface and is therefore not to be considered.

The next statement checks if the light affect the diffuse channel (lights may toggle on or off their ability to affect the diffuse and specular channels.)

if (l->affectDiffuse)

ip.diffIllumOut += diffCoef * lightCol;

If the light affects the diffuse channel then the diffuse illumination output component of the IllumParams is added to. This is done by multiplying the diffuse coefficient (returned by LightDesc::Illuminate()) times the light color (also returned by LightDesc::Illuminate()). Notice that the diffIllumOut is being accumulated with each pass of the light loop.

The next section of code involves the specular component. If the light is shiny, and it affects the specular channel a vector H is computed.

if (is_shiny&&l->affectSpecular) {

Note the following about this H vector computation. Most vectors are considered pointing from the point on the surface. The view vector (IllumParams::V) does not follow this convention. It points from the 'eye' towards the surface. Thus it's reversed from the usual convention.

H is computed to be the average of L and V. This is (L+V)/2. Since we normalize this we don't have to divide by the 2. So, if V followed the standard convention this would be simply L+V. Since it doesn't it is L+(-ip.V) or L-ip.V.

Point3 H = Normalize(L-ip.V);

Next the dot product of N and H is computed and stored in c. When you take the dot product of two normalized vectors what is returned is the cosine of the angle between the vectors.

float c = DotProd(ip.N,H);

If c>0 and the diffuse coefficient is less than the soften threshold then c is modified by a 'softening' curve.

if (c>0.0f)
{
if (softThresh!=0.0 &&
diffCoef<softThresh) {
c *=
Soften(diffCoef/softThresh);
}
}

Note that the Soften() function is defined in /MAXSDK/SAMPLES/MATERIALS/SHADERUTIL.CPP and developers can copy this code.

c = (float)pow((double)c,phExp);

Next, c is raised to the power of the Phong exponent. This is effectively taking a cosine (a smooth S curve) and raising it to a power. As it is raised to a power it becomes a sharper and sharper S curve. This is where the shape of the highlight curve in the Materials Editor UI comes from.

That completes the pre computations for the specular function. Then c is multiplied by the specular strength (ip.channels[ID_SS].r) times the light color (lightCol). The result is summed in specular illumination out (ip.specIllumOut).

ip.specIllumOut += c * ip.channels[ID_SS].r * lightCol;

That completes the light loop. It happens over and over for each light.

Next the self illumunation is computed. If the Self Illumination Color is not on, then the original code for doing mono self illumination is used.

// Apply mono self illumination
if ( ! selfIllumClrOn )
{
float si = ip.channels[ID_SI].r;
ip.diffIllumOut = (si>=1.0f) ? Color(1.0f,1.0f,1.0f)
:
ip.diffIllumOut * (1.0f-si) + si;
}
else
{
// Otherwise the self illumination color is summed in to the Self Illumination
Out (ip.selfIllumOut).
// colored self illum,
}

Then, we multiply by the colors for ambient, diffuse and specular.

The results are ambIllumOut, diffIllumOut, and specIllumOut. Note that these components are not summed. In R3 and earlier these results would be returned to the Standard material. However, R4 introduces a couple extra steps.

Finally, we call ShadeTransmission() and ShadeReflection() to apply the transmission/refraction and reflection models. The core implementation of 3ds Max provides the standard models, but the shader can override these methods to compute its own models.

int chan = ip.stdIDToChannel[ ID_RL ];
ShadeTransmission(sc, ip, ip.channels[chan],ip.refractAmt);
chan = ip.stdIDToChannel[ ID_RR ];
ShadeReflection( sc, ip, ip.channels[chan] );

In R4, It is a shader's responsibility to combine the components of the shading process prior to exiting Illum() (in R3, this was the responsibility of the Standard material). In order to combine these values together to produce the final color for that point on the surface (IllumParams.finalC), the shader should call CombineComponents() method. The Shader base class provides a default implementation which simply sums everything together and multiplies by the opacity.

virtual void CombineComponents( IllumParams& ip )
{
}
float finalOpac
Definition: IllumParams.h:121
Color finalC
Definition: IllumParams.h:141
Color reflIllumOut
Definition: IllumParams.h:130
Color transIllumOut
Definition: IllumParams.h:129

◆ ShadeReflection()

virtual void ShadeReflection ( ShadeContext sc,
IllumParams ip,
Color mapClr 
)
inlinevirtual

Compute the reflected color from the sc, ip, and reflection map (or ray) color.

The core implementation of this provides the standard 3ds Max reflection model. To support the standard reflection model, a shader may call this default implementation.

Parameters
scThe context which provides information on the pixel being shaded.
ipThe object whose data members provide communication between 3ds Max and the shader.
mapClrThe input reflection (or ray) color is passed in here and the resulting 'affected' color is stored here.

Reimplemented in Shader.

636 {}

◆ ShadeTransmission()

virtual void ShadeTransmission ( ShadeContext sc,
IllumParams ip,
Color mapClr,
float  amount 
)
inlinevirtual

Compute the transmission/refraction color for the sample.

The core implementation of this provides the standard 3ds Max reflection model. To support the standard transmission/refraction model, a shader may call this default implementation.

Parameters
scThe context which provides information on the pixel being shaded.
ipThe object whose data members provide communication between 3ds Max and the shader.
mapClrThe input refraction (or ray) color is passed in here and the resulting 'affected' color is stored here.
amountThe level of the amount spinner for the refraction channel.

Reimplemented in Shader.

648 {}

◆ AffectReflection()

virtual void AffectReflection ( ShadeContext sc,
IllumParams ip,
Color rcol 
)
inlinevirtual

This method was superseded by ShadeReflection() and is obsolete in release 4.0 and later.

This method provides the shader with an opportunity to affect the reflection code.

Parameters
scThe ShadeContext which provides information on the pixel being shaded.
ipThe object whose data members provide communication between 3ds Max and the shader.
rcolThe input reflection color is passed in here, and the resulting 'affected' color is stored here too.
Sample Code:
A simple example like Phong does the following:
{
rcol *= ip.channels[ID_SP];
};
virtual void AffectReflection(ShadeContext &sc, IllumParams &ip, Color &rcol)
This method was superseded by ShadeReflection() and is obsolete in release 4.0 and later.
Definition: shaders.h:680
If a color can affect the reflection of light off a surface than it can usually affect the reflection of other things off a surface. Thus some shaders influence the reflection color using the specular color and specular level. For instance the Multi Layer Shader does the following:
#define DEFAULT_GLOSS2 0.03f
void MultiLayerShader::AffectReflection(ShadeContext &sc, IllumParams &ip, Color &rcol)
{
float axy = DEFAULT_GLOSS2;
float norm = 1.0f / (4.0f * PI * axy );
rcol *= ip.channels[_SPECLEV1].r * ip.channels[_SPECCLR1] * norm;
}
#define PI
The constant Pi defined as float.
Definition: trig.h:13
680 {}

◆ CombineComponents()

virtual void CombineComponents ( ShadeContext sc,
IllumParams ip 
)
inlinevirtual

Finalizes the compositing of the various illumination components.

A default implementation is provided which simply adds the components together. Developers who want to do other more specialized composition can override this method. For example, a certain Shader might want to composited highlights over the underlying diffuse component since the light is reflected and the diffuse color wouldn't fully show through. Such a Shader would provide its own version of this method.

Parameters
scThe ShadeContext which provides information on the pixel being shaded.
ipThe illumination parameters to composite and store.
697 {};

◆ nTexChannelsSupported()

virtual long nTexChannelsSupported ( )
pure virtual

Returns the number of texture map map channels supported by this Shader.

◆ GetTexChannelName() [1/2]

virtual MSTR GetTexChannelName ( long  nTextureChan)
inlinevirtual
Note
This method has been deprecated in terms of implementation as of 3ds Max 2022. Plugin developers should implement GetTexChannelName(long nTextureChan, bool localized) instead. This method can no longer be overriden and calls to it are now forwarded to the function that replaced it with a "bool localized" value of true. This is done so that plugin developers who do not localize their plugins don't have to update all the places where they call this method. Plugin developers who do localize their plugins should analyze the places where they call this method to decide what value to pass it for the "bool localized" parameter.
See also
BaseShader::GetTexChannelName(long nTextureChan, bool localized)
715  {
716  return GetTexChannelName(nTextureChan, true);
717  };
virtual MSTR GetTexChannelName(long nTextureChan) MAX_SEALED
Definition: shaders.h:714

◆ GetTexChannelName() [2/2]

virtual MSTR GetTexChannelName ( long  nTextureChan,
bool  localized 
)
pure virtual

Returns the name of the specified texture map channel.

Parameters
nTextureChanThe zero based index of the texture map channel whose name is returned.
localizedIf true, then the channel name returned should be localized in the language 3ds Max is currently using. Otherwise it should be the channel name in English. If a plugin does not provide localized string resources, it can disregard this parameter and always return the channel name in English.

◆ GetTexChannelInternalName()

virtual MSTR GetTexChannelInternalName ( long  nTextureChan)
inlinevirtual

Returns the internal name of the specified texture map.

The Standard material uses this to get the fixed, parsable internal name for each texture channel it defines.

Parameters
nTextureChanThe zero based index of the texture map whose name is returned.
732 { return GetTexChannelName(nTextureChan, true); }

◆ ChannelType()

virtual long ChannelType ( long  nTextureChan)
pure virtual

Returns the channel type for the specified texture map channel.

There are four channels which are part of the Material which are not specific to the Shader. All other channels are defined by the Shader (what they are and what they are called.) The four which are not the province of the Shader are Bump, Reflection, Refraction and Displacement. For example, Displacement mapping is really a geometry operation and not a shading one. The channel type returned from this method indicates if the specified channel is one of these, or if it is a monochrome channel, a color channel, or is not a supported channel.

Parameters
nTextureChanThe zero based index of the texture map whose name is returned.
Returns
Texture channel type flags.
See also
Texture channel type flags

◆ StdIDToChannel()

virtual long StdIDToChannel ( long  stdID)
pure virtual

Returns the index of this Shader's channels which corresponds to the specified Standard materials texture map ID.

This allows the Shader to arrange its channels in any order it wants in the IllumParams::channels array but enables the Standard material to access specific ones it needs (for instance the Bump channel or Reflection channel).

Parameters
stdIDThe ID whose corresponding channel to return.
See also
Texture Map Indices "List of Material Texture Map Indices".
Returns
The zero based index of the channel. -1 if there is not a corresponding channel.
Sample Code:
This can be handled similar to below where an array is initialized with the values of this plug-in shader's channels that correspond to each of the standard channels. Then this method just returns the correspond index from the array.
static int stdIDToChannel[N_ID_CHANNELS] =
{
0, 1, 2, 5, 4, -1, 7, 8, 9, 10, 11, 12
};
long StdIDToChannel(long stdID){ return stdIDToChannel[stdID]; }
virtual long StdIDToChannel(long stdID)=0
Returns the index of this Shader's channels which corresponds to the specified Standard materials tex...
#define N_ID_CHANNELS
Number of IDs in stdMat.
Definition: shaders.h:16

◆ nUserIllumOut()

virtual long nUserIllumOut ( )
inlinevirtual

Indicates the number of UserIllum output channels used by the shader.

775 { return 0; }

◆ UserIllumNameArray()

virtual const MCHAR** UserIllumNameArray ( )
inlinevirtual

Returns a static array of channel names for matching by render elements.

778 { return NULL; }
#define NULL
Definition: autoptr.h:18

◆ Reset()

virtual void Reset ( )
pure virtual

Called when the Shader is first activated in the dropdown list of Shader choices.

The Shader should reset itself to its default values.