MPxSurfaceShadingNodeOverride Class Reference

This reference page is linked to from the following overview topics: Autodesk Maya 2014, Scene Overrides, Framework Classes, Transition Guide, Devkit Samples, 3.5 Shading Node Overrides.



Detailed 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:

depthShader.cpp.

#include <MPxSurfaceShadingNodeOverride.h>

Inheritance diagram for MPxSurfaceShadingNodeOverride:

List of all members.

Public Member Functions

 MPxSurfaceShadingNodeOverride (const MObject &obj)
 Construct an MPxSurfaceShadingNodeOverride.
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.
virtual MString transparencyParameter () const
 This method is called just after getCustomMappings() to allow the plugin to provide extra surface shader-specific information.
virtual MString bumpAttribute () const
 This method is called after getCustomMappings() to allow the plugin to provide surface-shader specific information.

Static Public Member Functions

static const char * className ()
 Returns the name of this class.

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
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
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
const char * className ( ) [static]

Returns the name of this class.

Returns:
Name of this class.

Reimplemented from MPxShadingNodeOverride.


MPxSurfaceShadingNodeOverride MPxSurfaceShadingNodeOverride MPxSurfaceShadingNodeOverride MPxSurfaceShadingNodeOverride MPxSurfaceShadingNodeOverride MPxSurfaceShadingNodeOverride MPxSurfaceShadingNodeOverride MPxSurfaceShadingNodeOverride MPxSurfaceShadingNodeOverride MPxSurfaceShadingNodeOverride
MPxSurfaceShadingNodeOverride MPxSurfaceShadingNodeOverride MPxSurfaceShadingNodeOverride MPxSurfaceShadingNodeOverride MPxSurfaceShadingNodeOverride MPxSurfaceShadingNodeOverride MPxSurfaceShadingNodeOverride MPxSurfaceShadingNodeOverride MPxSurfaceShadingNodeOverride MPxSurfaceShadingNodeOverride