Accessing Bump Maps [MEL]



All material nodes within Maya contain a "normalCamera" attribute. This is infact the attribute to which a bump node will be connected. The bump node can either be of type MFn::kBump or MFn::kBump3d. Where games are concerned, a 2d bump map is probably the only thing you'll need to worry about.

The file that is used as the bump map image itself is used as an input to the bump map node. This is a simple greyscale image that defines the bump. The bump node essentially converts this to a tangent space vector that can be used by the surface shader.

Any image you retrieve as the bump map, should be run through a conversion process to encode the normals into the texture.






// create an iterator to go through all meshes
void OutputBumpMap(MObject& obj)

MFnDependencyNode fn(obj);

// get a plug to the normalCamera attribute on the material

MPlug bump_plug = fn.findPlug("normalCamera");
MPlugArray connections;

// get connections to the attribute


// loop through each one to find a bump2d node

for(unsigned int i=0;i<connections.length();++i)

if (connections[i].node().apiType() == MFn::kBump)

// attach a function set to the 2d bump node

float bump_depth;

// get the bump depth value from the node
bumpDepth = fnBump.findPlug("bumpDepth");

// we now have the fun and joy of actually finding
// the file node that is connected to the bump map
// node itself. This is going to involve checking
// the attribute connections to the bumpValue attribute.

MPlug bump_value = fnBump.findPlug("bumpValue");
MPlugArray bv_connections;

for(unsigned int j=0;j<bv_connections.length();++j)


if(bv_connections[i].node().apiType() == MFn::kFileTexture)


// we have a texture. determine
// which texture it is.

MFnDependencyNode fnTex(bv_connections[i].node());

cout << "\tbumpmap 1\n"
<< "\t\tbumpdepth "
<< bump_depth
<< "\n\t\ttexture_node "
<< "\n";






cout << "\tbumpmap 0\n";





What Next?

Transform Data

Animation Data

Animation Curves


Rob Bateman [2004]