Python API 2.0 Reference
OpenMayaRender.MShaderManager Class Reference
+ Inheritance diagram for OpenMayaRender.MShaderManager:

Public Member Functions

def __init__ ()
 
def addShaderIncludePath ()
 
def addShaderPath ()
 
def clearEffectCache ()
 
def getEffectsBufferShader ()
 
def getEffectsFileShader ()
 
def getEffectsTechniques ()
 
def getFragmentShader ()
 
def getShaderFromNode ()
 
def getStockShader ()
 
def releaseShader ()
 
def removeEffectFromCache ()
 
def shaderIncludePaths ()
 
def shaderPaths ()
 

Static Public Member Functions

def __new__ ()
 
def getLastError ()
 
def getLastErrorSource ()
 
def isSupportedShaderSemantic ()
 

Static Public Attributes

int k3dBlinnShader = 1
 
int k3dCPVDashLineShader = 13
 
int k3dCPVFatPointShader = 4
 
int k3dCPVShader = 4
 
int k3dCPVSolidShader = 18
 
int k3dCPVThickDashLineShader = 16
 
int k3dCPVThickLineShader = 11
 
int k3dColorLookupFatPointShader = 5
 
int k3dColorOpacityLookupFatPointShader = 7
 
int k3dDashLineShader = 12
 
int k3dDefaultMaterialShader = 2
 
int k3dDepthShader = 17
 
int k3dFatPointShader = 9
 
int k3dFloat2NumericShader = 21
 
int k3dFloat3NumericShader = 22
 
int k3dFloatNumericShader = 20
 
int k3dIntegerNumericShader = 19
 
int k3dIsotropicStandardSurfaceShader = 26
 
int k3dOpacityLookupFatPointShader = 6
 
int k3dPointLightShadowerShader = 24
 
int k3dPointVectorShader = 23
 
int k3dShadowerShader = 8
 
int k3dSolidShader = 0
 
int k3dSolidTextureShader = 3
 
int k3dStandardSurfaceShader = 25
 
int k3dStippleShader = 14
 
int k3dThickDashLineShader = 15
 
int k3dThickLineShader = 10
 

Detailed Description

Provides access to MShaderInstance objects for use in Viewport 2.0.

Constructor & Destructor Documentation

def OpenMayaRender.MShaderManager.__init__ ( )
Initialize self.  See help(type(self)) for accurate signature.

Member Function Documentation

def OpenMayaRender.MShaderManager.__new__ ( )
static
Create and return a new object.  See help(type) for accurate signature.
def OpenMayaRender.MShaderManager.addShaderIncludePath ( )
addShaderIncludePath(string) -> self

Add a path to the list of paths used for searching for shader include files.
def OpenMayaRender.MShaderManager.addShaderPath ( )
addShaderPath(string) -> self

Add a path to the list of shader search paths.
def OpenMayaRender.MShaderManager.clearEffectCache ( )
clearEffectCache() -> self

Clear the effect cache.

This will allow all relevant effects to be updated when the implementation of a shader fragment or fragment graph has been modified.
def OpenMayaRender.MShaderManager.getEffectsBufferShader ( )
getEffectsBufferShader(buffer, size, techniqueName, macros=None, useEffectCache=True, preCb=None, postCb=None) -> MShaderInstance

Get a new instance of a shader generated from a block of memory containing device-specific source code (as char*).

* buffer (const void*) - A pointer to the block of memory from which to load the effect.
* size (unsigned int) - The size of the effect to load in bytes.
* techniqueName (string) - The name of a technique in the effect. If an empty string is specified then the first technique in the effect will be used.
* macros (sequence of MShaderCompileMacro) - Sequence of shader macros. The default value is None, meaning that no macros are specified.
* useEffectCache (bool) - Use the internal effect cache to prevent reloading the effect every time it is requested. The default value is True.
* preCb (function) - A function, or other Python callable, to be called before render items are drawn with this shader.
* postCb (function) - A function, or other Python callable, to be called after render items are drawn with this shader.
      see MShaderManager.getEffectsFileShader() for details on the preCb and postCb functions
def OpenMayaRender.MShaderManager.getEffectsFileShader ( )
getEffectsFileShader(effecsFileName, techniqueName, macros=None, useEffectCache=True, preCb=None, postCb=None) -> MShaderInstance

Get a new instance of a shader generated from an effects file stored on disk.

* effectsFileName (string) - The effects file.
* techniqueName (string) - The name of a technique in the effects file. If an empty string is specified then the first technique in the effects file will be used.
* macros (sequence of MShaderCompileMacro) - Sequence of shader macros. The default value is None, meaning that no macros are specified.
* useEffectCache (bool) - Use the internal effect cache to prevent reloading the effect file every time it is requested. The default value is True.
* preCb (function) - A function, or other Python callable, to be called before render items are drawn with this shader.
          def preCb(MDrawContext, MRenderItemList, MShaderInstance)
* postCb (function) - A function, or other Python callable, to be called after render items are drawn with this shader.
          def postCb(MDrawContext, MRenderItemList, MShaderInstance)
def OpenMayaRender.MShaderManager.getEffectsTechniques ( )
getEffectsTechniques(effecsFileName, macros=None, useEffectCache=True) -> tuple of strings

Analyzes a given effect file to extract the names of the techniques that are defined.

* effectsFileName (string) - The effects file.
* macros (sequence of MShaderCompileMacro) - Sequence of shader macros. The default value is None, meaning that no macros are specified.
* useEffectCache (bool) - Use the internal effect cache to prevent reloading the effect every time it is requested. The default value is True.
def OpenMayaRender.MShaderManager.getFragmentShader ( )
getFragmentShader(fragmentName, structOutputName, decorateFragment, preCb=None, postCb=None) -> MShaderInstance

Get a new instance of a shader generated from a named shader fragment or fragment graph.

* fragmentName (string) - The name of the fragment to generate a shader from.
* structOutputName (string) - If the output of the fragment is a struct, use this parameter to specify which member of the struct to use.
                                                     This parameter is ignored if the output of the fragment is not a struct.
* decorateFragment (bool) - If True, Maya state fragments will be added.
* preCb (function) - A function, or other Python callable, to be called before render items are drawn with this shader.
* postCb (function) - A function, or other Python callable, to be called after render items are drawn with this shader.
      see MShaderManager.getEffectsFileShader() for details on the preCb and postCb functions
def OpenMayaRender.MShaderManager.getLastError ( )
static
getLastError() -> string

Get the description of the last error encountered by the shader manager regarding an effect.
This includes fragment and effect loading, technique query, and shader binding.
def OpenMayaRender.MShaderManager.getLastErrorSource ( )
static
getLastErrorSource(displayLineNumber=False, filterSource=False, numSurroundingLines=2) -> string

Get the source of the shader that generated the last error. See getLastError().
 * displayLineNumber (bool) - If True, add the number line at the beginning of each line. The default is False.
 * filterSource (bool) - If True, only display the lines surrounding the error(s). The default is False.
 * numSurroundingLines (int) - The number of leading and trailing lines to display around filtered source. The default is 2.
def OpenMayaRender.MShaderManager.getShaderFromNode ( )
getShaderFromNode(shaderNode, shapePath, linkLostCb=None, linkLostUserData=None, preCb=None, postCb=None, nonTextured=False) -> MShaderInstance

Get the shader instance by evaluating the shading network of a surface shader node (either standard or custom) in the scene.

If the surface shader node is NULL or supported by neither Maya nor the plug-in, this method will return NULL.

The shape path is used as the object context for shading network evaluation to ensure that the shader instance fits its requirements. If the shape path is invalid (e.g. an empty path), a shader instance to fit basic requirements is created but will not include any geometry-dependent requirements.

The linkLostCb will be invoked whenever the link to the surface shader node is lost. The link can be lost in a number of ways, e.g. shader nodes are deleted or shading network connections are modified. However, the linkLostCb will not be invoked for changes to a shading group; if needed, it is the plug-in's responsibility to monitor any changes to the shading group (via MNodeMessage and/or MPxNode::connectionMade/connectionBroken).

After the shader instance is created, its parameter values can be automatically updated by Viewport 2.0 whenever the related shading attributes are changed, thus no attempt should be made to override parameter values of the shader instance manually.

* shaderNode (MObject) - The surface shader node.
* shapePath (MDagPath) - The DAG path of a shape to be used as the object context for shading network evaluation.
* linkLostCb (function) - A function, or other Python callable, to be called when this shader instance is no longer connected to the node it was translated for.
          def linkLostCb(MShaderInstance, MUserData)
* linkLostUserData (MUserData) - User supplied data to be passed into the link lost callback.
       This data will not be deleted internally and the lifetime must be managed by the caller.
       The link lost callback will only be called once so it is safe to delete this data anytime after the callback has been triggered.
* preCb (function) - A function, or other Python callable, to be called before render items are drawn with this shader.
* postCb (function) - A function, or other Python callable, to be called after render items are drawn with this shader.
      see MShaderManager.getEffectsFileShader() for details on the preCb and postCb functions.
* nonTextured (bool) - Whether or not a non-textured effect instance is needed. The default value is false.
def OpenMayaRender.MShaderManager.getStockShader ( )
getStockShader(shaderId, preCb=None, postCb=None) -> MShaderInstance

Get a new instance of a stock shader.

* shaderId (int) - The Id of stock shader.
* preCb (function) - A function, or other Python callable, to be called before render items are drawn with this shader.
* postCb (function) - A function, or other Python callable, to be called after render items are drawn with this shader.
      see MShaderManager.getEffectsFileShader() for details on the preCb and postCb functions

List of available stock shader:
  k3dSolidShader                  An instance of a solid color shader for 3d rendering
  k3dBlinnShader                  An instance of a Blinn shader for 3d rendering
  k3dDefaultMaterialShader        An instance of a stock "default material" shader for 3d rendering
  k3dSolidTextureShader           An instance of a stock solid texture shader for 3d rendering
  k3dCPVFatPointShader            An instance of a stock color per vertex fat point shader for 3d rendering
  k3dColorLookupFatPointShader    An instance of a stock fat point shader using a 1D color texture lookup.
  k3dShadowerShader               An instance of a stock shader which can be used when rendering shadow maps
  k3dFatPointShader               An instance of a stock fat point shader for 3d rendering
  k3dThickLineShader              An instance of a stock thick line shader for 3d rendering
  k3dCPVThickLineShader           An instance of a color per vertex stock thick line shader for 3d rendering
  k3dDashLineShader               An instance of a stock dash line shader for 3d rendering
  k3dCPVDashLineShader            An instance of a color per vertex stock dash line shader for 3d rendering
  k3dStippleShader                An instance of a stipple shader for drawing 3d filled triangles
  k3dThickDashLineShader          An instance of a stock thick dash line shader for 3d rendering.
  k3dCPVThickDashLineShader       An instance of a color per vertex stock thick dash line shader for 3d rendering.
  k3dDepthShader                  An instance of a stock shader that can be used for 3d rendering of depth
  k3dCPVSolidShader               An instance of a stock solid color per vertex shader for 3d rendering
  k3dIntegerNumericShader         An instance of a stock shader for drawing single integer values per vertex for 3d rendering.
  k3dFloatNumericShader           An instance of a stock shader for drawing single float values values per vertex for 3d rendering.
  k3dFloat2NumericShader          An instance of a stock shader for drawing 2 float values per vertex for 3d rendering.
  k3dFloat3NumericShader          An instance of a stock shader for drawing 3 float values per vertex for 3d rendering.
  k3dPointVectorShader            An instance of a stock shader that can be used for 3d rendering of lines based on a point and a vector stream
def OpenMayaRender.MShaderManager.isSupportedShaderSemantic ( )
static
isSupportedShaderSemantic(string) -> bool

Return if a given string is a supported shader semantic.
def OpenMayaRender.MShaderManager.releaseShader ( )
releaseShader(MShaderInstance) -> None

Deletes the MShaderInstance and releases its reference to the underlying shader which is held by the MShaderInstance object.
def OpenMayaRender.MShaderManager.removeEffectFromCache ( )
removeEffectFromCache(effecsFileName, techniqueName, macros=None) -> self

Remove an effect from the cache.

This is particulary useful when calling the getEffectsTechniques() and/or getEffectsFileShader() with the flag useEffectCache set to True for maximum performance, and will allow reloading the effect from the disk when the shader file has been modified.

* effectsFileName (string) - The effects file.
* techniqueName (string) - The name of a technique in the effects file. If an empty string is specified then the first technique in the effects file will be used.
* macros (sequence of MShaderCompileMacro) - Sequence of shader macros. The default value is None, meaning that no macros are specified.
def OpenMayaRender.MShaderManager.shaderIncludePaths ( )
shaderIncludePaths() -> list of strings

Query the list of search paths user for searching for shader include files.
def OpenMayaRender.MShaderManager.shaderPaths ( )
shaderPaths() -> list of strings

Query the list of shader search paths.