Shader source code examples
 
 
 
Example shader Classification Description

anisotropicShader

shader/surface

example shader that modifies specular highlights

backfillShader

shader/surface

modified Phong surface shader that fills non-diffuse illuminated areas with color

brickShader

texture/2d

brick texture node

cellShader

texture/3d

Solid texture of cells

checkerShader

texture/2d

node that uses texture UV coordinates to make a checker pattern

compositingShader

texture/2d

node for compositing anti-aliased mask and rgb textures

contrastShader

utility/color

node that manipulates color with contrast + bias

depthShader

shader/surface

example surface shader that colors objects based on distance from the camera

displacementShader

shader/displacement

example displacement shader

flameShader

texture/3d

Solid texture of flames

gammaShader

utility/color

node that manipulates color with gamma correction

geomShader

utility/general

node that outputs geometry xyz position

hwAnisotropicShader_NV20

shader/surface/utility

NV20-specific (Geforce3) sample shader to produce an anisotropic shading effect

hwPhongShader

shader/surface/utility

example of using a cube-environment map to perform per pixel phong shading

hwToonShader_NV20

shader/surface/utility

NV20-specific (Geforce3) sample shader for cartoon-like effects

interpShader

utility/general

node that interpolates two colors based on the surface normal

lambertShader

shader/surface

example Lambert surface shader

lavaShader

texture/3d

Solid texture of lava

lightShader

light

example light shader

mixtureShader

utility/color

node that takes two color inputs and two mask inputs and mixes them into a resulting color

noiseShader

texture/3d

node that applies a noise function to the output color

phongShader

shader/surface

example Phong surface shader

shadowMatteShader

shader/surface

example shader that outputs mask/alpha in shadowed areas only

slopeShader

utility/color

colors faces of a mesh based on their slope or angle relative to a user defined threshold

solidCheckerShader

texture/3d

example solid texture

vertexColorShader (cvColorShader)

utility/color

node that allows vertex color (CPV) to be software rendered

volumeShader

shader/volume

example volume shader

ASHLI shader (Linux and Windows)

shader/surface/utility

Demonstrates how to support the high level shading languages HLSL and GLSL using the hardware shader interface.

hwRenderPostEffect

NA

Demonstrates how to add a post rendering effect to a hardware shader.

anisotropicShader

Produces dependency graph node AnisotropicShader

This node modifies the specular highlight of a surface shader.

The output attributes of the AnisotropicShader node are called “outColor” and “outTransparency”. To use this shader, create a AnisotropicShader node with Shading Group or connect it’s output to a Shading Group’s “SurfaceShader” attribute.

backfillShader

Produces dependency graph node BackFillShader

This node is an example of a surface shader that fills non-diffuse illuminated areas with color.

The inputs for this node are can be found in the Maya UI on the Attribute Editor for the node.

The output attribute of the node is called “outColor”. It is a 3 float value that represents the resulting color produced by the shader. To use this shader, create a BackFillShader with Shading Group or connect its output to a Shading Group’s “SurfaceShader” attribute.

brickShader

Produces dependency graph node brickTexture

This node is an example of brick 2d texture.

The output attribute of the BrickTexture node is called “outColor”. To use this shader, create a BrickTexture and connect it’s output to an input of a surface/shader node such as Color.

cellShader

Produces dependency graph node Cells

This node is an example of a solid texture that divides 3D space into cells.

The output attributes of this node are called “outColor” and “outAlpha.”

To use this shader, create a Cell node and connect the output to an input of a surface/shader node such as Color.

checkerShader

Produces dependency graph node CheckerNode

This node is an example of evaluating texture UV coordinates and produces a checkerboard pattern. It also can take advantage of the 2d texture placement node for transforming UV coordinates with a manipulator.

The inputs for this node are two colors and two bias values, where each bias value is used to determine the pattern.

The output attribute of the CheckerNode node is called “outColor”. It is a 3 float value that represents the resulting color derived from the object’s UV texture coordinates. To use this shader, create a CheckerNode and connect its output to an input of a surface/shader node such as Color.

compositingShader

Produces dependency graph node CompositeNode

This node is an example of a compositing shading node.

The inputs for this node are foreground, background, back color, and a mask value.

The output attributes of the CompositeNode node are called “outColor” and “outAlpha”. To use this shader, create a CompositeNode and connect it’s output to an input of a surface/shader node such as Color.

contrastShader

Produces dependency graph node ContrastNode

This node is an example of manipulating color.

The inputs for this node are input color, contrast and bias. The contrast and bias inputs are 3 float values so that it can be applied to each rgb channel of an input color separately.

The output attribute of the ContrastNode node is called “outColor”. It is a 3 float value that represents the resulting color derived from the effective contrast and bias settings. To use this shader, create a ContrastNode and connect its output to an input of a surface/shader node such as Color.

depthShader

Produces dependency graph node DepthShader

This node is an example of a surface shader that colors objects based on distance from the camera.

The inputs for this node are can be found in the Maya UI on the Attribute Editor for the node.

The output attribute of the node is called “outColor”. It is a 3 float value that represents the resulting color produced by the node. To use this shader, create a DepthShader with Shading Group or connect its output to a Shading Group’s “SurfaceShader” attribute.

displacementShader

Produces dependency graph node DispNodeExample

This node is an example of displacement shader.

The inputs for this node are input color and an input multiplier.

The output attribute of the DispNodeExample node is called “displacement”. To use this shader, create a DispNodeExample node and connect it’s output to the “displacementShader” input of a Shading Group.

flameShader

Produces dependency graph node Flame

This node is an example of a solid texture that uses turbulence and an axis to animate the texture’s movement.

The output attributes of this node are called “outColor” and “outAlpha.”

To use this shader, create a Flame node and connect the output to an input of a surface/shader node such as Color.

gammaShader

Produces dependency graph node GammaNode

This node is an example of manipulating color with gamma correction.

The inputs for this node are input color and gamma values. The gamma input has 3 float values so that it can be applied to each rgb channel of an input color separately.

The output attribute of the GammaNode node is called “outColor”. To use this shader, create a GammaNode and connect its output to an input of a surface/shader node such as Color.

geomShader

Produces dependency graph node GeomNode

This node is an example of a evaluating the geometric xyz position on an object.

The inputs for this node are scale and offsets depicted as sliders in the Attribute Editor for the node.

The output attribute of the GeomNode node is called “outColor”. It is a 3 float value that represents the xyz position on the object. To use this shader, create a GeomNode and connect its output to an input of a surface/shader node such as Color.

hwAnisotropicShader_NV20

NV20-specific (Geforce3) sample shader.

This shader produces an anisotropic shading effect. It allows the user to change the parameters of an anisotropic lookup table.

This shader builds on the foundation demonstrated in the hwUnlitShader.

hwPhongShader

This is an example of a using a cube-environment map to perform per pixel Phong shading.

The light direction is currently fixed at the eye position. This could be changed to track an actual light but has not been coded for this example.

If multiple lights are to be supported, than the environment map would need to be looked up for each light either using multi-texturing or multipass.

hwToonShader_NV20

NV20-specific (Geforce3) sample shader.

This shader allows for cartoon-like effects.

It allows the user to specify a base decal texture, and a lighting look-up texture.

This shader builds on the foundation demonstrated in the hwUnlitShader.

hwRenderPostEffect

This plug-in demonstrates how to add processing to the hardware renderer. Simple operations such as inverting the image and adding color triangles to the view are performed by this plug-in.

To use this shader, load the plug-in and turn on the High Quality Interactive view.

interpShader

Produces dependency graph node InterpNode

This node is an example of evaluating the surface normal on an object.

The inputs for this node are two colors and an input value that will modify the interpolation of color.

The output attribute of the InterpNode node is called “outColor”. It is a 3 float value that represents the interpolated color as a result of the surface normal. To use this shader, create a IntepNode and connect its output to an input of a surface/shader node such as Color or Transparency.

lambertShader

Produces dependency graph node LambertShader

This node is an example of a Lambert shader and how to build a dependency node as a surface shader in Maya.

The inputs for this node are many, and can be found in the Maya UI on the Attribute Editor for the node.

The output attributes for the node are “outColor” and “outTransparency”. To use this shader, create a lambertShader with Shading Group or connect the outputs to a Shading Group’s “SurfaceShader” attribute.

lavaShader

Produces dependency graph node Lava

This node is an example of a solid texture that uses turbulence.

The output attributes of this node are called “outColor” and “outAlpha”.

To use this shader, create a Lava node and connect the output to an input of a surface/shader node such as Color.

lightShader

Produces dependency graph node lightNode

This node is an example of a directional light.

The inputs for this node are direction, color, and some boolean flags to indicate if the light is contributing to ambient, diffuse, and specular components. There is also a position input that can receive a connection from a 3d manipulator for placement within the scene.

The output attribute of the LightNode node is compound attribute called “lightData”. To use this shader, create a LightNode and modify it’s inputs to see the different illumination results.

meshReorderCmd

Command to re-index a polygon mesh based on a used defined starting face, a new mesh is created that has this new ordering.

To use this command, create a poly plane and run the following;

meshReorder pPlane1.vtx[5] pPlane1.vtx[23] pPlane1.vtx[9];

mixtureShader

Produces dependency graph node MixtureNode

This node is an example of evaluating multiple inputs and produces a resulting color.

The inputs for this node are two colors and two masks, where each color has a corresponding mask associated with it and the result color is the mixture of both colors with masks.

The output attribute of the MixtureNode node is called “outColor”. It is a 3 float value that represents the resulting color mixture based on the mask values. To use this shader, create a MixtureNode and connect it’s output to an input of a surface/shader node such as Color.

noiseShader

Produces dependency graph node SolidNoise

This node is an example of a 3d texture.

The output attribute of the SolidNoise node is called “outColor”.

rockingTransform

This plug-in implements an example custom transform that can be used to perform a rocking motion around the X axis. Geometry of any rotation can be made a child of this transform to demonstrate the effect. The plug-in contains two pieces:

1. The custom transform node -- rockingTransformNode

2. The custom transformation matrix -- rockingTransformMatrix

These classes are used together in order to implement the rocking motion. Note that the rock attribute is stored outside of the regular transform attributes.

MEL usage:

// Create a rocking transform and make a rotated plane
// its child.
loadPlugin rockingTransform;
file -f -new;
polyPlane -w 1 -h 1 -sx 10 -sy 10 -ax 0 1 0 -tx 1 -ch 1;
select -r pPlane1 ;
rotate -r -ws -15 -15 -15 ;
createNode rockingTransform;
parent pPlane1 rockingTransform1;
setAttr rockingTransform1.rockx 55;

rockingTransformCheck

This plug-in implements an example custom transform that can be used to perform a rocking motion around the X axis. The checkAndSetRotation() method is implemented in order to apply locks and rotation limits to user input.

Geometry of any rotation can be made a child of this transform to demonstrate the effect. The plug-in contains two pieces:

1. The custom transform node -- rockingTransformCheckNode

2. The custom transformation matrix -- rockingTransformCheckMatrix

These classes are used together in order to implement the rocking motion. Note that the rock attribute is stored outside of the regular transform attributes.

MEL usage:

// Create a rocking transform and make a rotated plane
// its child.
loadPlugin rockingTransformCheck;
file -f -new;
polyPlane -w 1 -h 1 -sx 10 -sy 10 -ax 0 1 0 -tx 1 -ch 1;
select -r pPlane1 ;
rotate -r -ws -15 -15 -15 ;
createNode rockingTransformCheck;
parent pPlane1 rockingTransformCheck1;
setAttr rockingTransformCheck1.rockx 10;

NOTE: classes used in this example derive from classes defined in the rockingTransform example.

shadowMatteShader

Produces dependency graph node ShadowMatte

This node will create a matte/mask only in areas that are in a lights shadow through the transparency output.

You can optionally use a boolean input to see where the shadow areas are in the color channels instead of the mask.

The output attributes of the ShadowMatte node are called “outColor” and “outTransparency”. To use this shader, create a ShadowMatte node with Shading Group or connect it’s output to a Shading Group’s “SurfaceShader” attribute.

slopeShader

Produces dependency graph node slopeShader

The slopeShape is comprised of three components: slopeShader, slopeShader Behavior and slopeShaderNode.

The slopeShader colors faces of a mesh based on their slope or angle relative to a user defined threshold.

solidCheckerShader

Produces dependency graph node SolidChecker

This node is an example of a 3d checker texture.

The output attributes of the SolidChecker node are called “outColor” and “outAlpha”. To use this shader, create a SolidChecker node and connect its output to an input of a surface/shader node such as Color.

phongShader

Produces dependency graph node PhongNode

This node is an example of a Phong shader and how to build a dependency node as a surface shader in Maya.

The inputs for this node are can be found in the Maya UI on the Attribute Editor for the node.

The output attribute of the node is called “outColor”. It is a 3 float value that represents the resulting color produced by the node. To use this shader, create a phongNode with Shading Group or connect its output to a Shading Group’s “SurfaceShader” attribute.

vertexColorShader (cvColorShader)

This plug-in creates a node that allows vertex color (CPV) to be software rendered.

volumeShader

Produces dependency graph node VolumeNode

This node is an example of a volume shader. Volume shaders are used to apply color to specialized shapes associated with light sources called “light shapes”. One such set of shapes is created by the Light Fog effect. The Light Fog effect can be assigned to any point or spot light through the attribute editors for the point and spot lights.

The output attribute of the VolumeNode node is called “outColor”. To use this shader, create a VolumeNode node and connect its output to the “volumeShader” input of a Shading Group. The shading group must be connected to a light shape.