What's New in the Rendering and Lighting API

Shading

  • The MPxShaderOverride class now supports Maya shading nodes for particle sprite shading in Viewport 2.0. See the customSpriteShader/customSpriteShader.cpp example plug-in for details on creating a custom sprite shader.
  • Added the MShaderInstance::writeEffectSourceToFile() method for debugging custom shader fragment development. Use this method to see how the final shader fragments are converted to the final effect source on the current drawing API.

    You can validate the shader fragments by compiling and binding a shader instance generated from the final effect source. To enable the fragment debugging code path, set the following environment variable: MAYA_CUSTOMSPRITESHADER_DEBUG_FRAGMENTS = 1. Shader compilation errors or warnings can be displayed in the Maya Script Editor. When errors or warnings occur, modify the fragments in XML. After updating, restart Maya and reload the scene the test your fixes.

    See the customSpriteShader/customSpriteShader.cpp plug-in example for more information.

  • A new customSpriteShader/customSpriteShader.cpp example plug-in demonstrates how to connect geometry shader fragments using the C++ API or XML schema. It also includes the use of the MPxShaderOverride class to create custom shaders for particle sprites.

    The plug-in connects geometry shader fragments by creating a shader instance from a fragment graph using MShaderInstance::addInputFragment(). The fragment graph connections, properties, values, and outputs are defined by an XML schema.

    An implementation of color management on the input texture is also included in the supplied customFileTextureOutputColor.xml file. This file shows how Maya converts texture color from sRGB space or linear space. You can also use the existing MShaderInstance::createShaderInstanceWithColorManagementFragment() interface, or refer to customFileTextureOutputColor.xml for custom implementation of color management depending on your specific needs. The MPxShaderOverride::isTransparent() virtual method handles transparency notifications.

    For debugging the shader fragments, the final effect source of the shader instance is written to disk using a new MShaderInstance::writeEffectSourceToFile() interface. Shader compilation errors can be displayed in the Maya Script Editor, during binding, or queried using MShaderManager::getLastError().

    The customSpriteShader plug-in supports all Viewport 2.0 OpenGL Core Profile, OpenGL, and DirectX 11 modes.

Query for camera near and far clipping planes from shaders

You can now access and query for camera near and far planes from shaders using uniform or semantic parameters. For effects generated from a file or buffer, new parameters with semantics have been added to the MUniformParameter class DataSemantic enumerators. These uniform parameters provide access to near and far clipping planes in full effects created by the MPxShaderOverride class.

  • kSemanticNearClipPlane
  • kSemanticFarClipPlane

For shader fragments, a parameter with semantics nearClipPlane and farClipPlane are automatically updated by Viewport 2.0.

Drawing

  • Added new virtual functions to the MPxDrawOverride class, which let you continue to use MPxLocatorNode class functions to override selection behavior for custom shapes in your plug-ins. The MPxDrawOverride class functions also provide the UI drawing mechanism to supersede the MPxSurfaceShapeUI class.

    These updates do not require plug-in source code changes or recompiling.

    The new functions include:

    The rawfootPrintNode plug-in example has been updated to demonstrate the use of the new functions.

  • A new MPxImagePlaneOverride class has been added, which lets you draw custom image planes in Viewport 2.0. Create an MPxImagePlaneOverride class and register the override when you initialize your plug-in. This new class includes the following methods:

    A new customImagePlane/customImagePlane.cpp example for C++ and Python demonstrates how to use the new MPxImagePlaneOverride class and includes how to:

    Note that depth map updates still need to be done using MPxImagePlane::loadImageMap().

  • A warning message now appears when the device API that is returned does not include the current device API on which Viewport 2.0 is running. For example, if VP2 is running on OpenGL Core Profile mode, but supportedDrawAPIs() does not return MHWRender::kOpenGLCoreProfile, then a warning similar to the following appears:

    Error: line 0: Failed to create evaluator for "drawdb/geometry/apiMesh" classification because the current drawing API isn't supported.

  • The footPrintNode, footPrint_GeometryOverride, and rawFootPrintNode devkit examples have been updated to improve viewport refreshes during animation while running Maya in Parallel Evaluation Mode.

General