Class Shader

3DS Max Plug-In SDK

Class Shader

See Also: Class BaseShader, Class MacroRecorder.

class Shader : public BaseShader

Description:

This class is available in release 3.0 and later only.

This is the class that developers use to create Shader plug-ins. Developers must implement the methods of this class to provide data to the 3ds max interactive renderer so it can properly reflect the look of the shader in the viewports. The methods associated with the actual Shader illumination code are from the base class BaseShader.

There are various Get and Set methods defined in this class. Plug-in developers provide implementations for the 'Get' methods which are used by the interactive renderer. The implementations of the 'Set' methods are used when switching between shaders types in the Materials Editor. This is used to transfer the corresponding colors between the old Shader and the new one.

Note that some shaders may not have the exact parameters as called for in the methods. In those case an approximate value may be returned from the 'Get' methods. For example, the Strauss Shader doesn't have an Ambient channel. In that case the Diffuse color is taken and divided by 2 and returned as the Ambient color. This gives the interactive renderer something to work with that might not be exact but is somewhat representative.

Methods:

public:

Prototype:

virtual void CopyStdParams(Shader* pFrom)=0;

Remarks:

This method copies the standard shader parameters from pFrom to this object. Note that plug-ins typically disable the macro recorder during this operation as the Get and Set methods are called. See the sample code for examples.

Parameters:

Shader* pFrom

The source parameters.

Prototype:

virtual BOOL GetLockDS()=0;

Remarks:

Returns TRUE if the Diffuse / Specular lock is on; otherwise FALSE.

Prototype:

virtual BOOL GetLockAD()=0;

Remarks:

Returns TRUE if the Ambient / Diffuse lock is on; otherwise FALSE.

Prototype:

virtual BOOL GetLockADTex()=0;

Remarks:

Returns TRUE if the Ambient / Diffuse Texture lock is on; otherwise FALSE.

Prototype:

virtual Color GetAmbientClr(int mtlNum, BOOL backFace)=0;

Remarks:

Returns the Ambient Color.

Parameters:

The parameters to this method are not applicable and may safely be ignored.

Prototype:

virtual Color GetDiffuseClr(int mtlNum, BOOL backFace)=0;

Remarks:

Returns the Diffuse Color.

Parameters:

The parameters to this method are not applicable and may safely be ignored.

Prototype:

virtual Color GetSpecularClr(int mtlNum, BOOL backFace)=0;

Remarks:

Returns the Specular Color.

Parameters:

The parameters to this method are not applicable and may safely be ignored.

Prototype:

virtual Color GetSelfIllumClr(int mtlNum, BOOL backFace)=0;

Remarks:

Returns the Self Illumination Color.

Parameters:

The parameters to this method are not applicable and may safely be ignored.

Prototype:

virtual float GetSelfIllum(int mtlNum, BOOL backFace)=0;

Remarks:

Returns the Self Illumination Amount.

Parameters:

The parameters to this method are not applicable and may safely be ignored.

Prototype:

virtual float GetGlossiness(int mtlNum, BOOL backFace)=0;

Remarks:

Returns the Glossiness Level.

Parameters:

The parameters to this method are not applicable and may safely be ignored.

Prototype:

virtual float GetSpecularLevel(int mtlNum, BOOL backFace)=0;

Remarks:

Returns the Specular Level.

Parameters:

The parameters to this method are not applicable and may safely be ignored.

Prototype:

virtual float GetSoftenLevel(int mtlNum, BOOL backFace)=0;

Remarks:

Returns the Soften Level as a float.

Parameters:

The parameters to this method are not applicable and may safely be ignored.

Prototype:

virtual BOOL IsSelfIllumClrOn(int mtlNum, BOOL backFace)=0;

Remarks:

Returns TRUE if the Self Illumination Color setting is on (checked); FALSE if off.

Parameters:

The parameters to this method are not applicable and may safely be ignored.

Prototype:

virtual BOOL IsSelfIllumClrOn()=0;

Remarks:

Returns TRUE if the Self Illumination Color setting is on (checked); FALSE if off.

Prototype:

virtual Color GetAmbientClr(TimeValue t)=0;

Remarks:

Returns the Ambient Color at the specified time.

Parameters:

TimeValue t

The time at which to return the color.

Prototype:

virtual Color GetDiffuseClr(TimeValue t)=0;

Remarks:

Returns the Diffuse Color at the specified time.

Parameters:

TimeValue t

The time at which to return the color.

Prototype:

virtual Color GetSpecularClr(TimeValue t)=0;

Remarks:

Returns the Specular Color at the specified time.

Parameters:

TimeValue t

The time at which to return the color.

Prototype:

virtual float GetGlossiness(TimeValue t)=0;

Remarks:

Returns the Glossiness value at the specified time.

Parameters:

TimeValue t

The time at which to return the value.

Prototype:

virtual float GetSpecularLevel(TimeValue t)=0;

Remarks:

Returns the Specular Level at the specified time.

Parameters:

TimeValue t

The time at which to return the value.

Prototype:

virtual float GetSoftenLevel(TimeValue t)=0;

Remarks:

Returns the Soften Specular Highlights setting at the specified time.

Parameters:

TimeValue t

The time at which to return the value.

Prototype:

virtual float GetSelfIllum(TimeValue t)=0;

Remarks:

Returns the Self Illumination Amount at the specified time.

Parameters:

TimeValue t

The time at which to return the value.

Prototype:

virtual Color GetSelfIllumClr(TimeValue t)=0;

Remarks:

Returns the Self Illumination Color at the specified time.

Parameters:

TimeValue t

The time at which to return the color.

Prototype:

virtual void SetLockDS(BOOL lock)=0;

Remarks:

Sets the state of the Diffuse / Specular lock to on or off.

Parameters:

BOOL lock

TRUE for on; FALSE for off.

Prototype:

virtual void SetLockAD(BOOL lock)=0;

Remarks:

Sets the state of the Ambient / Diffuse lock to on or off.

Parameters:

BOOL lock

TRUE for on; FALSE for off.

Prototype:

virtual void SetLockADTex(BOOL lock)=0;

Remarks:

Sets the state of the Ambient / Diffuse Texture lock to on or off.

Parameters:

BOOL lock

TRUE for on; FALSE for off.

Prototype:

virtual void SetSelfIllum(float v, TimeValue t)=0;

Remarks:

Sets the Self Illumination parameter to the specified value at the time passed.

Parameters:

float v

The value to set.

TimeValue t

The time to set the value.

Prototype:

virtual void SetSelfIllumClrOn(BOOL on)=0;

Remarks:

Sets the Self Illumination Color On/Off state.

Parameters:

BOOL on

TRUE for on; FALSE for off.

Prototype:

virtual void SetSelfIllumClr(Color c, TimeValue t)=0;

Remarks:

Sets the Self Illumination Color at the specified time.

Parameters:

Color c

The color to set.

TimeValue t

The time to set the color.

Prototype:

virtual void SetAmbientClr(Color c, TimeValue t)=0;

Remarks:

Sets the Ambient Color at the specified time.

Parameters:

Color c

The color to set.

TimeValue t

The time to set the color.

Prototype:

virtual void SetDiffuseClr(Color c, TimeValue t)=0;

Remarks:

Sets the Diffuse Color at the specified time.

Parameters:

Color c

The color to set.

TimeValue t

The time to set the color.

Prototype:

virtual void SetSpecularClr(Color c, TimeValue t)=0;

Remarks:

Sets the Specular Color at the specified time.

Parameters:

Color c

The color to set.

TimeValue t

The time to set the color.

Prototype:

virtual void SetGlossiness(float v, TimeValue t)=0;

Remarks:

Sets the Glossiness parameter to the specified value at the time passed.

Parameters:

float v

The value to set.

TimeValue t

The time to set the value.

Prototype:

virtual void SetSpecularLevel(float v, TimeValue t)=0;

Remarks:

Sets the Specular Level parameter to the specified value at the time passed.

Parameters:

float v

The value to set.

TimeValue t

The time to set the value.

Prototype:

virtual void SetSoftenLevel(float v, TimeValue t)=0;

Remarks:

Sets the Soften Specular Highlights Level to the specified value at the time passed.

Parameters:

float v

The value to set.

TimeValue t

The time to set the value.

Prototype:

virtual float EvalHiliteCurve(float x);

Remarks:

This method is called to evaluate the hightlight curve that appears in the Shader user interface.

Note: This gets called from the DrawHilite() function which is available to developers in \MAXSDK\SAMPLES\MATERIALS\SHADER\SHADERUTIL.CPP. DrawHilite() get called from the window proc HiliteWndProc() in the same file. This code is available to developers to use in their Shader dialog procs.

Parameters:

float x

The input value.

Return Value:

The output value on the curve. A value of 1.0 represents the top of the curve as it appears in the UI. Values greater than 1.0 are okay and simply appear off the top of the graph.

Default Implementation:

{ return 0.0f; }

Prototype:

virtual float EvalHiliteCurve2(float x, float y, int level = 0);

Remarks:

This is the highlight curve function for the two highlight curves which intersect and appear in the UI, for instance in the Anistropic shader.

Parameters:

float x

The x input value.

float y

The y input value.

int level = 0

This is used by multi-layer shaders to indicate which layer to draw. The draw highlight curve routines use this when redrawing the graph.

Return Value:

The output value of the curve.

Default Implementation:

{ return 0.0f; }