MEL How-To #26

Back · Previous · Next Maya

How can I Prelight a polymesh without having its material/texture influence the resulting vertex colouring?

During the H2O presentation on the Alias|wavefront stage at GDC 2000 I demonstrated H2O's "Polygon Apply Color" panel that includes what I call a "Neutral Prelight" option. Here's the deal:

Normally when you prelight geometry to which materials and textures have been applied, the Prelight operation uses the "emission" value at the vertex -- this includes the color of the material/texture.

It was Scott Hamilton from A|w that demonstrated to us how to achieve the "neutral" prelight.

Common Material Attributes

Open the Attribute Editor for a Material and look in the Common Material Attributes section. Right-click on the label for the "Color" swatch. The bottom menu item will read ‘Ignore when Rendering’. Check this ON.

You will see the material preview swatch render a neutral gray (or whatever you have set for the Default Color from the file node). Now a Prelight applied for any faces using this texture will use only the influence from the lights and not from the applied texture.

Our demonstration at GDC explained how we used MEL to simplify this process by applying the Ignore when Rendering flag en masse across all of the scene's Materials, performing a Prelight, then resetting all Ignore when Rendering flags.

The Ignore when Rendering flag is set/cleared via the ‘shadingConnection’ MEL command; e.g.:

// Disable the shading connection, i.e. check ON Ignore when Rendering
shadingConnection -e -connectionState false lambert1.color;

H2O's ‘polygonApplyColor’ script performs the set/clear across all Materials using a simple procedure:

proc enableRendering( int $enable )
{
  string $materials[] = `ls -materials`;

  for ( $mat in $materials )
    shadingConnection -e -cs $enable ( $mat + ".color" );
}

I cannot distribute the source for the polygonApplyColor script, but here's the panel to give you an idea how it works:

polygonApplyColor

Related Articles

Alias|wavefront's Assistant Online: How to Prelight a Scene