MPxSurfaceShadingNodeOverride Class Reference

#include <MPxSurfaceShadingNodeOverride.h>

Class Description

Base class for user defined surface shading node overrides.

MPxSurfaceShadingNodeOverride is an extension of MPxShadingNodeOverride which is specialized for surface shaders. Plugin surface shader nodes that may be connected directly to a Maya shading engine should define an override which derives from this class instead of MPxShadingNodeOverride when providing support for Viewport 2.0.

In addition to providing all the functionality of MPxShadingNodeOverride, MPxSurfaceShadingNodeOverride also lets the override flag certain parameters and attributes for special processing.

Maya also treats MPxSurfaceShadingNodeOverride objects differently than plain MPxShadingNodeOverride objects. In particular, Maya will attempt to connect the shade fragments for lights to the fragment provided by an implementation of MPxSurfaceShadingNodeOverride. The following named input parameters on the fragment will be recognized and have the specified Maya lighting parameters automatically connected to them.

Parameter name Parameter type Automatically connected value from lights
Lw 3-float World space light direction vector for diffuse lighting
HLw and SLw 3-float World space light direction vector for specular lighting
diffuseI 3-float Diffuse irradiance for light
specularI 3-float Specular irradiance for light
ambientIn 3-float Total contribution from all ambient lights

When there are multiple lights in the scene, the contribution from the fragments that make up the final shading effect is computed once for each light and then the results are accumulated. So the parameters above are all for the whichever light is currently being computed.

Please examine the fragments and fragment graphs for the Maya phong shader (mayaPhongSurface) for examples of how light information can be used.

Implementations of MPxSurfaceShadingNodeOverride must be registered with Maya through MDrawRegistry.

+ Examples:
+ Inheritance diagram for MPxSurfaceShadingNodeOverride:

Public Member Functions

 MPxSurfaceShadingNodeOverride (const MObject &obj)
 Construct an MPxSurfaceShadingNodeOverride. More...
 
virtual ~MPxSurfaceShadingNodeOverride ()
 Destructor.
 
virtual MString primaryColorParameter () const
 This method is called just after getCustomMappings() to allow the plugin to provide extra surface shader-specific information. More...
 
virtual MString transparencyParameter () const
 This method is called just after getCustomMappings() to allow the plugin to provide extra surface shader-specific information. More...
 
virtual MString bumpAttribute () const
 This method is called after getCustomMappings() to allow the plugin to provide surface-shader specific information. More...
 
- Public Member Functions inherited from MPxShadingNodeOverride
 MPxShadingNodeOverride (const MObject &obj)
 Construct an MPxShadingNodeOverride. More...
 
virtual ~MPxShadingNodeOverride ()
 Destructor.
 
virtual MHWRender::DrawAPI supportedDrawAPIs () const
 Returns the draw API supported by this override. More...
 
virtual bool allowConnections () const
 An override may prevent Maya from connecting fragments to specific parameters of the fragment for this override by providing custom attribute parameter mappings. More...
 
virtual MString fragmentName () const =0
 Override this method to return the name of the fragment or fragment graph to use for rendering the shading node associated with this override. More...
 
virtual void getCustomMappings (MAttributeParameterMappingList &mappings)
 Maya will automatically match parameters on the shade fragment specified by this override with attributes on the associated Maya node as long as the names and types match. More...
 
virtual MString outputForConnection (const MPlug &sourcePlug, const MPlug &destinationPlug)
 When Maya attempts to connect the fragment for this override to the fragment for another node in the shading network, it will call this method to get the name of the output on the fragment to use for the connection. More...
 
virtual bool valueChangeRequiresFragmentRebuild (const MPlug *plug) const
 This method will be called by Maya when it detects changes in the attribute values of nodes in the shading network. More...
 
virtual void updateDG ()
 This method is called every time Maya needs to update the parameter values on the final shading effect of which the fragment produced by this override is a part. More...
 
virtual void updateShader (MShaderInstance &shader, const MAttributeParameterMappingList &mappings)
 This method is called every time Maya needs to update the parameter values on the final shading effect of which the fragment produced by this override is a part. More...
 

Static Public Member Functions

static const char * className ()
 Returns the name of this class. More...
 
- Static Public Member Functions inherited from MPxShadingNodeOverride
static const char * className ()
 Returns the name of this class. More...
 

Constructor & Destructor Documentation

Construct an MPxSurfaceShadingNodeOverride.

Parameters
[in]objThe Maya surface shading node this override will be used for

Member Function Documentation

MString primaryColorParameter ( ) const
virtual

This method is called just after getCustomMappings() to allow the plugin to provide extra surface shader-specific information.

If required, the override may return the name of a 3-float parameter on the fragment that should be marked as the primary color. If the viewport is set to hide textures (shaded mode) then the specified parameter will be set using the "default color" value from the texture which is connected to the associated attribute on the Maya node.

The default implementation returns the empty string (no primary color).

The name must correspond to a parameter on the fragment that is mapped to an attribute on the node either automatically or through custom attribute parameter mappings.

Returns
The name of the fragment parameter to use as the primary color
+ Examples:
MString transparencyParameter ( ) const
virtual

This method is called just after getCustomMappings() to allow the plugin to provide extra surface shader-specific information.

If required, the override may return the name of a single float or 3-float parameter on the fragment that should be marked as the parameter that drives the transparency of the surface shader. The values of this parameter will be watched so that scene objects using this shader will be correctly marked and sorted for transparent drawing.

The default implementation returns the empty string (no transparency).

The name must correspond to a parameter on the fragment that is mapped to an attribute on the node either automatically or through custom attribute parameter mappings.

Returns
The name of the fragment parameter that should drive transparency
+ Examples:
MString bumpAttribute ( ) const
virtual

This method is called after getCustomMappings() to allow the plugin to provide surface-shader specific information.

If required, the override may return the name of the attribute on the node that accepts connections from bump nodes for doing bump or normal mapping (often this is "normalCamera"). A special mapping will be created linking this attribute to the parameter named "Nw" (world space normal) on the fragment. The special mapping will ensure that the extra fragments needed for bump mapping are set up correctly. If there is no "Nw" parameter on the fragment the mapping will not be created and bump mapping will not work for the associated shader.

The default implementation returns the empty string (no bump).

Returns
The name of the attribute that accepts bump connections from bump nodes
+ Examples:
const char * className ( )
static

Returns the name of this class.

Returns
Name of this class.

The documentation for this class was generated from the following files:
  • MPxSurfaceShadingNodeOverride.h
  • MPxSurfaceShadingNodeOverride.cpp