This reference page is linked to from the following overview topics: Parent class descriptions, Overview of hardware shading node plug-ins, Implementing a hardware shading node plug-in.
Base class for user defined hardware shaders.
MPxHwShaderNode allows the creation of user-defined hardware shaders. A hardware shader allows the plug-in writer to control the on-screen display of an object in Maya.
You must derive a hardware shader node from MPxHwShaderNode for it to have any affect on the on-screen display at all. In addition to their affect on the on-screen display of objects, hardware shaders function as surface shader nodes. This allows you to connect any shading network up to the hardware shader's outColor attribute to handle the shading during a software render.
To create a working hardware shader, derive from this class and override the bind(), unbind(), and geometry() methods. If your hardware shader uses texture coordinates from Maya, you also need to override either texCoordsPerVertex or getTexCoordSetNames(). The other methods of the parent class MPxNode may also be overridden to perform dependency node capabilities.
NOTE: Plug-in hardware shaders are fully supported for polygonal mesh shapes. NURBS surfaces are only supported in the High Quality Interactive viewport and Hardware Renderer if the glBind/glGeometry/glUnbind methods of this class are implemented.
blindDataShader.h, cgfxShaderNode.h, GLSLShaderNode.h, hwAnisotropicShader_NV20.h, hwColorPerVertexShader.cpp, hwDecalBumpShader_NV20.h, hwManagedTextureShader.cpp, hwPhongShader.h, hwReflectBumpShader_NV20.h, hwRefractReflectShader_NV20.h, hwToonShader_NV20.h, hwUnlitShader.h, and pnTrianglesNode.h.
#include <MPxHwShaderNode.h>
Public Types |
|
enum | Writeable
{ kWriteNone = 0x0000, kWriteVertexArray = 0x0001, kWriteNormalArray = 0x0002, kWriteColorArrays = 0x0004, kWriteTexCoordArrays = 0x0008, kWriteAll = 0x000f } |
Bit masks used in conjuction with the 'writeable' parameter passed to the geometry() method to determine which arrays the shader is allowed to write to. More... |
|
enum | DirtyMask
{ kDirtyNone = 0x0000, kDirtyVertexArray = 0x0001, kDirtyNormalArray = 0x0002, kDirtyColorArrays = 0x0004, kDirtyTexCoordArrays = 0x0008, kDirtyAll = 0x000f } |
Bit masks used in combination with the return value of the dirtyMask() method to determine which portions of the geometry are dirty. More... |
|
enum | TransparencyOptions { kIsTransparent = 0x0001, kNoTransparencyFrontBackCull = 0x0002, kNoTransparencyPolygonSort = 0x0004 } |
Bit masks to be returned by the shader's transparencyOptions() method. More... |
|
Public Member Functions |
|
MPxHwShaderNode () | |
Class constructor. |
|
virtual | ~MPxHwShaderNode () |
Class destructor. |
|
virtual MPxNode::Type | type () const |
This method returns the type of the node.
|
|
virtual MStatus | bind (const MDrawRequest &request, M3dView &view) |
This method is invoked for hardware
rendering to Maya's 3D view. |
|
virtual MStatus | unbind (const MDrawRequest &request, M3dView &view) |
This method is invoked for hardware
rendering to Maya's 3D view. |
|
virtual MStatus | geometry (const MDrawRequest &request, M3dView &view, int prim, unsigned int writable, int indexCount, const unsigned int *indexArray, int vertexCount, const int *vertexIDs, const float *vertexArray, int normalCount, floatArrayPtr normalArrays, int colorCount, floatArrayPtr colorArrays, int texCoordCount, floatArrayPtr texCoordArrays) |
This method is invoked for hardware
rendering to Maya's 3D view. |
|
virtual MStatus | glBind (const MDagPath &shapePath) |
This method should only be overridden for
hardware rendering. |
|
virtual MStatus | glUnbind (const MDagPath &shapePath) |
This method should only be overridden for
hardware rendering. |
|
virtual MStatus | glGeometry (const MDagPath &shapePath, int glPrim, unsigned int writeMask, int indexCount, const unsigned int *indexArray, int vertexCount, const int *vertexIDs, const float *vertexArray, int normalCount, floatArrayPtr normalArrays, int colorCount, floatArrayPtr colorArrays, int texCoordCount, floatArrayPtr texCoordArrays) |
This method should only be overridden for
hardware rendering. |
|
virtual bool | supportsBatching () const |
Specifies whether or not this shader
supports batched rendering of shapes. |
|
virtual bool | invertTexCoords () const |
Specifies whether this shader requires
inverted texture coordinates. |
|
const MDagPath & | currentPath () const |
This method returns a reference to the
current path that the shader is invoked for. |
|
unsigned int | dirtyMask () const |
This method returns a "dirty" mask that
indicates which geometry items have changed from the last
invocation of the plugin to draw. |
|
virtual int | normalsPerVertex () |
Specifies how many normals per vertex the HW
shader would like Maya to provide. |
|
virtual int | colorsPerVertex () |
This method returns the number of color
values per vertex that the hw shader node would like to receive
from Maya. |
|
virtual int | getColorSetNames (MStringArray &names) |
NO SCRIPT SUPPORT. |
|
virtual int | texCoordsPerVertex () |
This method returns the number of texture
coordinate values per vertex that the hw shader node would like to
receive from Maya. |
|
virtual int | getTexCoordSetNames (MStringArray &names) |
NO SCRIPT SUPPORT. |
|
virtual bool | hasTransparency () |
This method returns a boolean value that
indicates whether the object will be drawn transparently or not.
|
|
virtual bool | provideVertexIDs () |
This method returns a boolean value that
indicates whether a map of the vertex IDs will be provided to the
geometry method. |
|
virtual unsigned int | transparencyOptions () |
This method returns transparency options for
usage as hints for Maya's internal draw during a given rendering
pass. |
|
virtual MStatus | getAvailableImages (const MString &uvSetName, MStringArray &imageNames) |
NO SCRIPT SUPPORT. |
|
virtual MStatus | renderImage (const MString &imageName, floatRegion region, int &imageWidth, int &imageHeight) |
NO SCRIPT SUPPORT. |
|
virtual MStatus | renderSwatchImage (MImage &image) |
If the shader specifies to override swatch
rendering, then this method must be overridden in order to draw
anything into a swatch. |
|
MObject | currentShadingEngine () const |
This method returns an MObject to
the shading engine that is currently being rendered. |
|
Static Public Member Functions |
|
static MPxHwShaderNode * | getHwShaderNodePtr (MObject &object) |
This is a static convenience method to be
able to get an MPxHwShaderNode
from an MObject
provided by a swatch generator class (Class derived from MSwatchRenderRegister). |
|
static const char * | className () |
Returns the name of this class. |
|
Static Public Attributes |
|
static MObject | outColor |
output color value |
|
static MObject | outColorR |
output color red |
|
static MObject | outColorG |
output color green |
|
static MObject | outColorB |
output color blue |
|
static MObject | outTransparency |
output transparency value |
|
static MObject | outTransparencyR |
output transparency red |
|
static MObject | outTransparencyG |
output transparency green |
|
static MObject | outTransparencyB |
output transparency blue |
|
static MObject | outMatteOpacity |
output matte opacity value |
|
static MObject | outMatteOpacityR |
output matte opacity red |
|
static MObject | outMatteOpacityG |
output matte opacity green |
|
static MObject | outMatteOpacityB |
output matte opacity blue |
|
static MObject | outGlowColor |
output glow color value |
|
static MObject | outGlowColorR |
output glow color red |
|
static MObject | outGlowColorG |
output glow color green |
|
static MObject | outGlowColorB |
output glow color blue |
enum Writeable |
Bit masks used in conjuction with the 'writeable' parameter passed to the geometry() method to determine which arrays the shader is allowed to write to.
enum DirtyMask |
Bit masks used in combination with the return value of the dirtyMask() method to determine which portions of the geometry are dirty.
enum TransparencyOptions |
Bit masks to be returned by the shader's transparencyOptions() method.
MPxNode::Type type | ( | ) | const [virtual] |
This method returns the type of the node.
This method should not be overridden by the user. It will return MPxNode::kHwShaderNode.
Reimplemented from MPxNode.
MStatus bind | ( | const MDrawRequest & | request, |
M3dView & | view | ||
) | [virtual] |
This method is invoked for hardware rendering to Maya's 3D view.
This is the preferred method of interactive feedback and performance. the "gl" version should be used for batch hardware rendering.
This method is called to set up the OpenGL state. It would typically ensure that textures were bound and that any specific OpenGL extensions are enabled. A status code of MS::kSuccess should be returned unless there was a problem during the display, such as insufficient memory or required input data is missing or invalid.
[in] | request | the draw request. |
[in] | view | the view in which to draw. |
MStatus unbind | ( | const MDrawRequest & | request, |
M3dView & | view | ||
) | [virtual] |
This method is invoked for hardware rendering to Maya's 3D view.
This is the preferred method of interactive feedback and performance. the "gl" version should be used for batch hardware rendering.
This method is called to restore the OpenGL state. Specifically, it must disable any OpenGL extensions that the matching bind() method may have enabled. This is necessary to ensure that the rest of Maya's drawing code continues to work correctly. A status code of MS::kSuccess should be returned unless there was a problem such as insufficient memory or required input data is missing or invalid.
The arguments passed to this method are the same ones that were passed to the bind() method.
[in] | request | the draw request. |
[in] | view | the view in which to draw. |
MStatus geometry | ( | const MDrawRequest & | request, |
M3dView & | view, | ||
int | prim, | ||
unsigned int | writable, | ||
int | indexCount, | ||
const unsigned int * | indexArray, | ||
int | vertexCount, | ||
const int * | vertexIDs, | ||
const float * | vertexArray, | ||
int | normalCount, | ||
floatArrayPtr | normalArrays, | ||
int | colorCount, | ||
floatArrayPtr | colorArrays, | ||
int | texCoordCount, | ||
floatArrayPtr | texCoordArrays | ||
) | [virtual] |
This method is invoked for hardware rendering to Maya's 3D view.
This is the preferred method of interactive feedback and performance. the "gl" version should be used for batch hardware rendering.
This method does all the actual OpenGL drawing. The arguments contain all the data to successfully call glDrawElements or glDrawRangeElements. It is possible that there will be multiple calls to this method surrounded by a single call to bind() and unbind().
Note 1. The array of vertex IDs returned corresponds to each triangle's vertex. This allows access to associated blind data per vertex. The vertexIDs array allows querying of information such as color per vertex etc.
Note 2. The array of array parameters passed to this method can contain sparse information. Check array positions against NULL to ensure that the array information item is valid.
It is necessary to use the indexArray to access information contained in the data arrays.
[in] | request | the draw request. |
[in] | view | the view in which to draw. |
[in] | prim | the type of primitive to draw. This is one of the values accepted by glBegin(). Typically it will be GL_TRIANGLES but it could be any of the others. |
[in] | writable | this is a mask which indicates which of the various array
arguments can be modified in place. If a bit in writable is set
then you can modify corresponding data array (after casting it to a
non-const type). If the bit is not set in writable then you must
not modify the data since it points to internal Maya
storage. You can test the bits in writeable against the values
defined by the enum MPxHwShaderNode::Writable . |
[in] | indexCount | specifies both the number of indices to draw and the size of the indexArray argument. |
[in] | indexArray | the array of index values. This array is in a format suitable
for passing as the indices argument to
glDrawElements() or
glDrawRangeElements() . See the OpenGL documentation
for details on calling these routines. |
[in] | vertexCount | the number of elements in the vertexArray, the normalArray, each of the colorArrays, and each of the texCoordArrays. |
[in] | vertexIDs | the component IDs of the vertices in vertexArray. This array is only provided if it was requested by overriding the provideVertexIDs() method to return true. |
[in] | vertexArray | the array of vertex data. Currently, this is always 3 element
floating point values. This data is in a format suitable for
passing to glVertexPointer() . See the OpenGL
documentation for details. |
[in] | normalCount | the number of individual "normal" arrays that are being provided in normalArrays. See the description of normalsPerVertex method below for details. |
[in] | normalArrays | the normal (and tangent) data suitable. There may be 0, 1, 2, or 3 "normal" arrays. See the description of the normalsPerVertex method below for details. |
[in] | colorCount | the number of individual color arrays. |
[in] | colorArrays | the arrays of color data. The first set of color data is
pointed to by colorArrays[0]. Each color array contains vertexCount
color values, each of which is 4 floating point values long and
represents the red, green, blue, and alph values on a 0 to 1 scale.
Each individual array is suitable for passing to
glColorPointer() . |
[in] | texCoordCount | the number of texture coordinate arrays. Each array contains one set of UV texture coordinates. |
[in] | texCoordArrays | the arrays of texture coordinate data. The first set of texture
coordinate data is pointed to by texCoordArrays[0]. Each array
contains vertexCount coordinate values, each of which is 2 floating
point values long. Each individual array is suitable for passing to
glTexCoordPointer() . |
This method should only be overridden for hardware rendering.
The implementation can assume the graphics context and model view projection matrix have already been set.
This method will be invoked once per frame and should be overridden to allocate any resources needed for the draw. For example, binding vertex programs, fragment programs, or allocating textures. A status code of MS::kSuccess should be returned unless there was a problem such as insufficient memory or required input data is missing or invalid.
[in] | shapePath | Path to the surface being drawn. |
This method should only be overridden for hardware rendering.
The implementation can assume the graphics context and model view projection matrix have already been set.
This method will be invoked once per frame and should be overridden to deallocate any resources used to draw. It's important that all resources be released when a batch hardware render has occured because the graphics context will be deleted. It may be desireable to override the other version of bind/unbind to keep track of whether the draw is for the 3D view or the batch hardware renderer. This information could then be used to better track the reuse of resources and optimize performance.
A status code of MS::kSuccess should be returned unless there was a problem.
[in] | shapePath | Path to the surface being drawn. |
MStatus glGeometry | ( | const MDagPath & | shapePath, |
int | prim, | ||
unsigned int | writable, | ||
int | indexCount, | ||
const unsigned int * | indexArray, | ||
int | vertexCount, | ||
const int * | vertexIDs, | ||
const float * | vertexArray, | ||
int | normalCount, | ||
floatArrayPtr | normalArrays, | ||
int | colorCount, | ||
floatArrayPtr | colorArrays, | ||
int | texCoordCount, | ||
floatArrayPtr | texCoordArrays | ||
) | [virtual] |
This method should only be overridden for hardware rendering.
The implementation can assume graphics context and model view projection matrix have already been set.
This method does all the actual OpenGL drawing. The arguments contain all the data to successfully call glDrawElements or glDrawRangeElements. It is possible that there will be multiple calls to this method surrounded by a single call to bind() and unbind().
Note 1. The array of vertex IDs returned corresponds to each triangle's vertex. This allows access to associated blind data per vertex. The vertexIDs array allows querying of information such as color per vertex etc.
Note 2. The array of array parameters passed to this method can contain sparse information. Check array positions against NULL to ensure that the array information item is valid.
It is necessary to use the indexArray to access information contained in the data arrays.
[in] | shapePath | Path to the surface being drawn. |
[in] | prim | the type of GL primitive is supplied as it would be used for glBegin() or glDrawElements(). Typically it will be GL_TRIANGLES or GL_TRIANGLE_STRIP for drawing polygonal or nurb surfaces respectively. |
[in] | writable | this is a mask which indicates which of the various array
arguments can be modified in place. If a bit in writable is set
then you can modify corresponding data array (after casting it to a
non-const type). If the bit is not set in writable then you must
not modify the data since it points to internal Maya
storage. You can test the bits in writeable against the values
defined by the enum MPxHwShaderNode::Writable . |
[in] | indexCount | specifies both the number of indices to draw and the size of the indexArray argument. |
[in] | indexArray | the array of index values. This array is in a format suitable
for passing as the indices argument to
glDrawElements() or
glDrawRangeElements() . See the OpenGL documentation
for details on calling these routines. |
[in] | vertexCount | the number of elements in the vertexArray, the normalArray, each of the colorArrays, and each of the texCoordArrays. |
[in] | vertexIDs | the component IDs of the vertices in vertexArray. This array is only provided if it was requested by overriding the provideVertexIDs() method to return true. |
[in] | vertexArray | the array of vertex data. Currently, this is always 3 element
floating point values. This data is in a format suitable for
passing to glVertexPointer() . See the OpenGL
documentation for details. |
[in] | normalCount | the number of individual "normal" arrays that are being provided in normalArrays. See the description of normalsPerVertex method below for details. |
[in] | normalArrays | the normal (and tangent) data suitable. There may be 0, 1, 2, or 3 "normal" arrays. See the description of the normalsPerVertex method below for details. |
[in] | colorCount | the number of individual color arrays. |
[in] | colorArrays | the arrays of color data. The first set of color data is pointed to by colorArrays[0]. Each color array contains vertexCount color values, each of which is 4 floating point values long and represents the red, green, blue, and alpha values on a 0 to 1 scale. The 3D view and hardware renderer handle missing color data differently. The 3D view will create an array and pass black colors for each vertex, whereas the hardware renderer will supply a NULL pointer to indicate that color per-vertex data is unavailable. |
[in] | texCoordCount | the number of texture coordinate arrays. Each array contains one set of UV texture coordinates. |
[in] | texCoordArrays | the arrays of texture coordinate data. The first set of texture
coordinate data is pointed to by texCoordArrays[0]. Each array
contains vertexCount coordinate values, each of which is 2 floating
point values long. Each individual array is suitable for passing to
glTexCoordPointer() . The 3D view and hardware renderer
handle missing texture coordinates differently. The 3D view will
create an array of [0,0] texture coordinates for each vertex,
whereas the hardware renderer will supply a NULL pointer to
indicate that uv-set data is unavailable. |
bool supportsBatching | ( | ) | const [virtual] |
Specifies whether or not this shader supports batched rendering of shapes.
In normal rendering, a shader is invoked using bind/geometry/unbind (or glBind/glGeometry/glUnbind) once for each shape being rendered. When a shader is used in batched rendering mode however, bind is called once, a series of geometry calls are made for each shape being rendered, followed by a single call to unbind (and similarly for glBind, glGeometry and glUnbind). As shader binding/unbinding can be expensive, batched rendering can significantly improve rendering performance. The more (particularly expensive) operations that can be moved out of the geometry/glGeometry methods the greater the performance improvement is. Ideally, only shape specific operations (such as binding geometry arrays and shape matrices) should be left in the geometry methods.
It is important to note that your shader can only use batched rendering mode if there is no shape (i.e. dag path) specific code in bind, glBind, unbind, or glUnbind. If any of these methods perform shape specific processing, this code must either be moved into geometry/glGeometry, or you must return false in this method to indicate batching should be disabled for this shader.
By default, this method will return false to ensure compatibility with existing shader code.
bool invertTexCoords | ( | ) | const [virtual] |
Specifies whether this shader requires inverted texture coordinates.
(i.e. where the top-left hand corner of UV space is (0,0) instead of the bottom-left corner).
By default, this method will return false to ensure compatibility with existing shader code.
const MDagPath & currentPath | ( | ) | const |
This method returns a reference to the current path that the shader is invoked for.
The path is only valid before a call to any of the attribute specifying routines:
The path is not guaranteed to be valid at any other time.
This method allows the plugin to return attribute queries which are relative to a specific path or object.
For example, the plugin can retrieve the MObject from the path, then use the MFnMesh class on the MObject, assuming the object is a polygonal surface. Through MFnMesh the code can query the actual number of texture coordinate sets on the surface and return appropriate values for the getTexCoordSetNames() routine.
The [gl]bind(), [gl]unbind() and [gl]geometry() routines already have access to a dag path which is the same path as the one which can be retrieved via this method.
For performance reasons, it is recommended that for those methods the MDagPath passed in as an argument should be used.
unsigned int dirtyMask | ( | ) | const |
This method returns a "dirty" mask that indicates which geometry items have changed from the last invocation of the plugin to draw.
The mask is valid at the time that geometry() or glGeometry() is called and at no other time.
Note that this mask is relative to the geometry for the current object (path) being drawn by the shader. The current path is the MDagPath argument passed in via the geometry routines.
In general the mask will mark the geometry as not being dirty.
Scenarios where the geometry will be marked dirty include:
int normalsPerVertex | ( | ) | [virtual] |
Specifies how many normals per vertex the HW shader would like Maya to provide.
This can range from 0 to 3. The first normal is the surface normal. The second "normal" is the primary tangent (generally the "u" direction). The third "normal" is the secondary tangent or the binormal (generally the "v" direction). Together, the normal, tangent and binormal form an orthogonal basis frequently named "tangent space basis".
The tangent and binormal vectors are guaranteed to be normalized and orthogonal to the surface normal. Please note that extracting the tangent and/or binormal requires expensive calculations, that will slow down refresh time substantially. In a future version, Maya may cache the resulting tangent space basis; in the meantime, only ask for more than one normal per vertex if they are absolutely required.
Also note that the tangent and binormal calculation requires a uv map. Currently, they are always computed from the first available uv map; if there is no uv mapping on the surface, Maya will only provide surface normals in the geometry call, regardless of the value returned by normalsPerVertex().
If you do not override this method, Maya will provide 1 normal per vertex.
Maya will automatically and silently clamp the result of this function to the [0,3] range.
COMPATIBILITY NOTE: Automatic tangent space basis calculation is only supported starting with Maya 4.0.1. Maya 4.0 supported a different scheme that was much more complicated and no longer supported.
int colorsPerVertex | ( | ) | [virtual] |
This method returns the number of color values per vertex that the hw shader node would like to receive from Maya.
Maya will attempt to provide all the color data that the shader would like but it will never provide more data that is actually available in the shape. The color sets returned by getColorSetNames() will override the number of color sets specified by colorsPerVertex(). If you do not override this method or getColorSetNames(), Maya will provide no colors per vertex.
int getColorSetNames | ( | MStringArray & | names | ) | [virtual] |
NO SCRIPT SUPPORT.
This method returns an array of color per vertex set names.
Maya will attempt to provide color per vertex data from these maps in the corresponding array element in the colorArrays argument to the geometry method. For example, if the names[2] is "cpv56" then colorArrays[2] will be the array of values from cpv56, or NULL if the shape being rendered does not have a color set of that name. If this method is not overridden an empty list of names will be returned, and Maya will use colorsPerVertex() to determine how many color sets to provide.
[in] | names | a string array holding the names of the color per vertex sets from which color data should be extracted. |
int texCoordsPerVertex | ( | ) | [virtual] |
This method returns the number of texture coordinate values per vertex that the hw shader node would like to receive from Maya.
Maya will attempt to provide all the texture coordinate data that the shader would like but it will never provide more data than is actually available in the shape. The uv sets returned by getTexCoordSetNames() will override the number of uv sets specified by texCoordsPerVertex(). If you do not override this method or getTexCoordSetNames(), Maya will provide no texture coordinates per vertex.
int getTexCoordSetNames | ( | MStringArray & | names | ) | [virtual] |
NO SCRIPT SUPPORT.
This method returns an array of texture coordinate set names.
Maya will attempt to provide texture coordinates from these maps in the corresponding array element in the texCoordArrays argument to the geometry method. For example, if the names[2] is "uvSet3" then texCoordArrays[2] will be the array of values from uvSet3. If this method is not overridden an empty list of names will be returned, and Maya will use texCoordsPerVertex() to determine how many uv sets to provide.
[in] | names | a string array holding the names of the uvSets from which texture coordinate data should be extracted. |
bool hasTransparency | ( | ) | [virtual] |
This method returns a boolean value that indicates whether the object will be drawn transparently or not.
Transparent objects must be drawn after all the opaque objects in the scene or they will not display correctly. Maya uses the return value to determine when it can draw this shape.
Note : The functionality in this method has been subsumed by the transparencyOptions() method. It is recommended that shader node writers use this newer method as it provides greater control over how transparency is interpreted by Maya's refresh mechanism.
For backward compatibility, if this method is specified and returns a "true" value, it will override the transparencyOptions() method.
bool provideVertexIDs | ( | ) | [virtual] |
This method returns a boolean value that indicates whether a map of the vertex IDs will be provided to the geometry method.
unsigned int transparencyOptions | ( | ) | [virtual] |
This method returns transparency options for usage as hints for Maya's internal draw during a given rendering pass.
Parameters are returned via an integer containing masked out bits. By default the mask is set to 0, meaning that the drawing should be treated as regular opaque object drawing. This will generally mean one call per draw pass.
Options to control transparency are specified by returning one or more masks specified by the TransparencyOptions enumeration :
Note : Setting the "hasTransparency()" method to true will override this method. This is for backward compatibility with behaviour on existing hardware shader nodes. It is recommended that shaders use the "transparencyOptions()" override, and not longer use the older "hasTransparency()" override from their shader classes.
MStatus getAvailableImages | ( | const MString & | uvSetName, |
MStringArray & | imageNames | ||
) | [virtual] |
NO SCRIPT SUPPORT.
Maya will call this method to get your shader's list of images which are available for use in the UV texture editor for the UV set specified.
Typically, this list will include one entry for each texture using the specified UV set, however, your shader is free to return as many images as you wish (for example, blending between two textures, texture alpha masks, artificially shaded views of bump/normal maps, etc). Your shader's renderImage() method will be used to render the images themselves.
[in] | uvSetName | Name of a UV set the channel list should be filtered against. |
[out] | imageNames | Array in which to return the names of the images this shader defines which are valid for the uvSetName specified. |
MStatus renderImage | ( | const MString & | imageName, |
floatRegion | region, | ||
int & | imageWidth, | ||
int & | imageHeight | ||
) | [virtual] |
NO SCRIPT SUPPORT.
This method allows you to to render the background image used for this shader in the UV texture editor.
The image requested will be one of the image names returned by your shader's getAvailableImages() method.
The implementation must return the dimensions of the image in the 'imageWidth' and 'imageHeight' parameters so that Maya can perform pixel snapping and other resolution-dependent operations.
The implementation can assume OpenGL context, model view projection matrix, and texture transformations have already been set. A default color of white will be set, however you are free to change this. The magnification filter will be set to either point or bilinear based on user configuration and should not be modified. The values of GL_TEXTURE_WRAP_S and GL_TEXTURE_WRAP_T are undefined on entry, and your implementation is responsible for setting them to appropriate values (e.g. GL_REPEAT).
The arguments contain the name of the image to render, and the vertex and texture coordinate values to use at each corner of the rectangular image being rendered. Your implementation is responsible for restoring the original the value of any OpenGL state that is modified.
For example:
glPushAttrib( <GL bits your shader modifies> ); glPushClientAttrib( GL_CLIENT_VERTEX_ARRAY_BIT); ... setup material here ... glBegin( GL_QUADS); glTexCoord2f(region[0][0], region[0][1]); glVertex2f(region[0][0], region[0][1]); glTexCoord2f(region[0][0], region[1][1]); glVertex2f(region[0][0], region[1][1]); glTexCoord2f(region[1][0], region[1][1]); glVertex2f(region[1][0], region[1][1]); glTexCoord2f(region[1][0], region[0][1]); glVertex2f(region[1][0], region[0][1]); glEnd(); glPopAttrib(); glPopClientAttrib();
[in] | imageName | Name of the image to render. This corresponds to one of the image names returned by your shader's getAvailableImages() method. |
[in] | region | Rectangular region to be rendered. The values of this parameter should be used to populate the vertex and texture coordinates of the rectangle being rendered. |
[out] | imageWidth | Native width (e.g. texture pixel width) of the image. This should be for the entire image, not just the portion within 'region'. |
[out] | imageHeight | Native height (e.g. texture pixel height) of the image. This should be for the entire image, not just the portion within 'region'. |
If the shader specifies to override swatch rendering, then this method must be overridden in order to draw anything into a swatch.
The default implementation is to draw nothing. The basic logic to draw a swatch is as follows:
[in,out] | image | Image object to which this method must write the rendered swatch. On input the image's dimensions are already set and pixel storage already allocated. |
MPxHwShaderNode * getHwShaderNodePtr | ( | MObject & | object | ) | [static] |
This is a static convenience method to be able to get an MPxHwShaderNode from an MObject provided by a swatch generator class (Class derived from MSwatchRenderRegister).
[in] | object | The object to examine. |
MObject currentShadingEngine | ( | ) | const |
This method returns an MObject to the shading engine that is currently being rendered.
This method will only return a valid MObject during the following calls:
const char * className | ( | ) | [static] |