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

Public Member Functions

def __init__ ()
 
def activatePass ()
 
def addInputFragment ()
 
def addInputFragmentForMultiParams ()
 
def addOutputFragment ()
 
def annotation ()
 
def bind ()
 
def clone ()
 
def createShaderInstanceWithColorManagementFragment ()
 
def getArraySize ()
 
def getPassCount ()
 
def isArrayParameter ()
 
def isTransparent ()
 
def isVaryingParameter ()
 
def parameterDefaultValue ()
 
def parameterList ()
 
def parameterSemantic ()
 
def parameterType ()
 
def passAnnotation ()
 
def postDrawCallback ()
 
def preDrawCallback ()
 
def renameParameter ()
 
def requiredVertexBuffers ()
 
def resourceName ()
 
def semantic ()
 
def setArrayParameter ()
 
def setAsVarying ()
 
def setIsTransparent ()
 
def setParameter ()
 
def setSemantic ()
 
def techniqueAnnotation ()
 
def techniqueNames ()
 
def uiName ()
 
def uiWidget ()
 
def unbind ()
 
def updateParameters ()
 
def writeEffectSourceToFile ()
 

Static Public Member Functions

def __new__ ()
 

Static Public Attributes

int kAnisotropyShader = 13
 
int kAnisotropyShader2 = 14
 
int kBoolean = 1
 
int kDisplacementPosShader = 15
 
int kFloat = 3
 
int kFloat2 = 4
 
int kFloat3 = 5
 
int kFloat4 = 6
 
int kFloat4x4Col = 8
 
int kFloat4x4Row = 7
 
int kGeometryShader = 4
 
int kGlossShader = 5
 
int kGlossShader2 = 6
 
int kInteger = 2
 
int kInvalid = 0
 
int kNormalShader = 1
 
int kNormalShader2 = 2
 
int kPixelShader = 0
 
int kReflectanceShader = 9
 
int kReflectanceShader2 = 10
 
int kRotationAngleShader = 7
 
int kRotationAngleShader2 = 8
 
int kRoughnessShader = 11
 
int kRoughnessShader2 = 12
 
int kSampler = 13
 
int kTexture1 = 9
 
int kTexture2 = 10
 
int kTexture3 = 11
 
int kTextureCube = 12
 
int kVertexShader = 3
 

Detailed Description

An instance of a shader that may be used with Viewport 2.0.

Constructor & Destructor Documentation

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

Member Function Documentation

def OpenMayaRender.MShaderInstance.__new__ ( )
static
Create and return a new object.  See help(type) for accurate signature.
def OpenMayaRender.MShaderInstance.activatePass ( )
activatePass(MDrawContext, int) -> self

Activates the given pass of the shader.
Must be called between calls to bind() and unbind().
def OpenMayaRender.MShaderInstance.addInputFragment ( )
addInputFragment(fragmentName, outputName, inputName, promotedInputName=None) -> self

Connect a fragment that has been registered with the fragment manager to an input on the existing MShaderInstance.
Use this method to add shader instructions to an existing MShaderInstance.
The code defined in the fragment will be compiled and executed on the GPU to compute the value for the input parameter.

* fragmentName (string) - The name of a fragment that has been registered with the MFragmentManager.
* outputName (string) - The name of the output on the registered fragment to connect to.
* inputName (string) - The name of the input parameter on the MShaderInstance to connect to.* promotedInputName (string) - The name of the input parameter on the new fragment that will be promoted to replace the input parameter being connected to.
def OpenMayaRender.MShaderInstance.addInputFragmentForMultiParams ( )
addInputFragmentForMultiParams(fragmentName, uniqueName, outputNames, inputNames, invalidParameterIndices=None, fragmentUsage=MShaderInstance.kPixelShader) -> self

Connect a named fragment that has been registered with the MFragmentManager 
to this MShaderInstance. The code defined in the fragment will be included 
in the new shader and executed on GPU to compute values for input parameters 
specified by inputNames. 

To connect with fragments, this MShaderInstance needs to be created from a 
shader fragment or fragment graph as well. Thus, a shader instance created 
from a file-based effect cannot connect with any fragments. 

After the fragment is connected, all input parameters with the same name in 
the new fragment graph are mapped to a single parameter in the shader by 
default. If uniqueness is required for input parameters on the fragment, 
uniqueName can be used to prefix names of the input parameters. 

This method is particularly useful when plugin needs to make multiple 
connections from the input fragment to this MShaderInstance. It can be used 
to make a single connection, but addInputFragment() is more convenient in 
this case. The numbers of the output and input parameters must match. An 
output and an input parameter with the same index in the two string arrays 
will be connected. To specify fan-out connections, the same output name can 
be repeated in outputNames as need. Fan-in connections are not allowed. 

If the numbers of the output and input parameters don't match, or a 
parameter (either output or input) doesn't exist, or their types don't 
match, the relevant parameters will not be connected and the method will 
return MStatus::kInvalidParameter. In this case, the fragment may still be 
connected partially to this MShaderInstance through other connectable 
parameter pairs, and plugin can use invalidParameterIndices to query 
indices of those invalid parameters in outputNames and inputNames. 

* fragmentName (string) - Name of the input fragment.
* uniqueName (string) - A unique name to prefix names of input parameters on the input fragment.
* outputNames (list of strings) - Names of the output parameters on the input fragment to connect from.
* inputNames (list of strings) - Names of the input parameters on the MShaderInstance to connect to.
* invalidParameterIndices (list of ints) - Optional list to query indices of invalid parameters.
* fragmentUsage (int) - Not implemented.
def OpenMayaRender.MShaderInstance.addOutputFragment ( )
addOutputFragment(fragmentName, inputName) -> self

Connect a fragment that has been registered with the fragment manager to an output on the existing MShaderInstance.
The code defined in the fragment will be compiled and executed on the GPU to modify the value returned by the original shader.
For example, use this method to add additional alpha or conditionals to the output color.

* fragmentName (string) - The name of a fragment that has been registered with the MFragmentManager.
* inputName (string) - The name of the input parameter on the fragment to connect the shaders output to.
def OpenMayaRender.MShaderInstance.annotation ( )
annotation(parameterName, annotationName) -> int / float / string

Returns the value of a named parameter annotation.

 * parameterName (string) - The name of the parameter.
 * annotationName (string) - The name of the annotation.
def OpenMayaRender.MShaderInstance.bind ( )
bind(MDrawContext) -> self

Binds the shader instance to the draw context, so that it is the active shader.
def OpenMayaRender.MShaderInstance.clone ( )
clone() -> MShaderInstance

Clone the shader. This will return a new MShaderInstance object which is identical to the existing shader.
def OpenMayaRender.MShaderInstance.createShaderInstanceWithColorManagementFragment ( )
createShaderInstanceWithColorManagementFragment(inputColorSpace) -> MShaderInstance

Return a new shader instance with Color Management fragment added, which is based on the callee.
The callee shader instance is the one used for rendering a render item with image(a MPxNode with image, etc.)
The new shader is completely independent of the original shader. 
Setting parameter values on either shader after calling this function will have no effect on the other.
The function won't keep a copy of input parameter.


When the returned new shader instance is no longer needed, MShaderManager.releaseShader() 
should be called to notify the shader manager that the caller is done with the shader.

 * inputColorSpace (string) - The color space the current image is in
def OpenMayaRender.MShaderInstance.getArraySize ( )
getArraySize(string) -> int

Return the size of an array if it is an array. Returns 0 if it is not an array
def OpenMayaRender.MShaderInstance.getPassCount ( )
getPassCount(MDrawContext) -> int

Returns the number of draw passes defined by the shader.
None if the shader instance or draw context was invalid.
def OpenMayaRender.MShaderInstance.isArrayParameter ( )
isArrayParameter(string) -> bool

Determine whether the named parameter is an array.
def OpenMayaRender.MShaderInstance.isTransparent ( )
isTransparent() -> bool

Return whether the shader will render with transparency.
def OpenMayaRender.MShaderInstance.isVaryingParameter ( )
isVaryingParameter(string) -> bool

Return the true if a named parameter's values vary per vertex.
def OpenMayaRender.MShaderInstance.parameterDefaultValue ( )
parameterDefaultValue(parameterName) -> bool / int / float / tuple of float

Returns the default value of named parameter, None if no default value.
def OpenMayaRender.MShaderInstance.parameterList ( )
parameterList() -> list of string

Get the names of all parameters that are settable on this shader instance.
def OpenMayaRender.MShaderInstance.parameterSemantic ( )
parameterSemantic(parameterName) -> string

Returns the semantic associated to a named parameter.
def OpenMayaRender.MShaderInstance.parameterType ( )
parameterType(string) -> int

Get the type of the named parameter, returns kInvalid if parameter is not found.
def OpenMayaRender.MShaderInstance.passAnnotation ( )
passAnnotation(pass, annotationName) -> int / float / string

Returns the value of the current technique's pass annotation.

 * pass (int) - The index of the pass.
 * annotationName (string) - The name of the pass annotation.
def OpenMayaRender.MShaderInstance.postDrawCallback ( )
postDrawCallback() -> function/None

Returns the post-draw callback function set for the this shader instance.
Returns None if the callback function is not set or is not a python function.
def OpenMayaRender.MShaderInstance.preDrawCallback ( )
preDrawCallback() -> function/None

Returns the pre-draw callback function set for the this shader instance.
Returns None if the callback function is not set or is not a python function.
def OpenMayaRender.MShaderInstance.renameParameter ( )
renameParameter(parameterName, string) -> self

Rename a named parameter.
def OpenMayaRender.MShaderInstance.requiredVertexBuffers ( )
requiredVertexBuffers(MVertexBufferDescriptorList) -> self

Get the vertex buffer descriptors that describe the buffers required
by a given shader instance.
def OpenMayaRender.MShaderInstance.resourceName ( )
resourceName(parameterName) -> string

Returns the resource name of a named texture parameter.
The resource name of a texture parameter can be specified in the effect file using the 'ResourceName' annotation.
It allows users to define a default texture using an external file.
If no resource was defined for a texture, this function returns an empty string.
def OpenMayaRender.MShaderInstance.semantic ( )
semantic(string) -> string

Return the semantic for a named parameter.
def OpenMayaRender.MShaderInstance.setArrayParameter ( )
setArrayParameter(parameterName, sequence of bool, int) -> self
setArrayParameter(parameterName, sequence of int, int) -> self
setArrayParameter(parameterName, sequence of float, int) -> self
setArrayParameter(parameterName, sequence of MMatrix, int) -> self

Set the value of a named array parameter.
def OpenMayaRender.MShaderInstance.setAsVarying ( )
setAsVarying(parameterName, bool) -> self

Set whether the named parameter's values will vary per vertex.
def OpenMayaRender.MShaderInstance.setIsTransparent ( )
setIsTransparent(bool) -> self

Set whether the shader will render with transparency.
def OpenMayaRender.MShaderInstance.setParameter ( )
setParameter(parameterName, bool) -> self
setParameter(parameterName, int) -> self
setParameter(parameterName, float) -> self
setParameter(parameterName, list of float) -> self
setParameter(parameterName, MFloatVector) -> self
setParameter(parameterName, MMatrix) -> self
setParameter(parameterName, MFloatMatrix) -> self
setParameter(parameterName, MTexture) -> self
setParameter(parameterName, MRenderTarget) -> self
setParameter(parameterName, MSamplerState) -> self

Set the value of the named parameter.
def OpenMayaRender.MShaderInstance.setSemantic ( )
setSemantic(parameterName, string) -> self

Set the semantic of a named parameter.
def OpenMayaRender.MShaderInstance.techniqueAnnotation ( )
techniqueAnnotation(annotationName) -> int / float / string

Returns the value of the current technique annotation.

 * annotationName (string) - The name of the technique annotation.
def OpenMayaRender.MShaderInstance.techniqueNames ( )
techniqueNames() -> list of strings

Returns a list of the technique names for the effect.
def OpenMayaRender.MShaderInstance.uiName ( )
uiName(parameterName) -> string

Returns the UI name associated with a named parameter.
The UI name can be specified in shader using the 'UIName' annotation.
The UI name can be used to specify the name that will be displayed in the Attribute Editor.
def OpenMayaRender.MShaderInstance.uiWidget ( )
uiWidget(parameterName) -> string

Returns the UI widget type associated with a named parameter.
The UI widget type can be specified in shader using the 'UIWidget' annotation.The UI widget can be used to specify which widget should be used to control the parameter in the Attribute Editor.
def OpenMayaRender.MShaderInstance.unbind ( )
unbind(MDrawContext) -> self

Unbinds the shader instance from the draw context.
def OpenMayaRender.MShaderInstance.updateParameters ( )
updateParameters(MDrawContext) -> self

Updates the bound shader instance with the current parameter data.
def OpenMayaRender.MShaderInstance.writeEffectSourceToFile ( )
writeEffectSourceToFile(filePath) -> self

Write the source of the final OGSFX/HLSL/CgFX effect to a specified file. Use
this for debugging to see how fragments are turned into the final effect for
the current drawing API.

Note that the effect will not be written if the effect is not generated from
shader fragments or any of the shader fragments is marked as hidden.