一半君的总结纸

听话只听一半君

#07 How can I turn off all of a scene’s textures for rendering (similar to the flag in PA)?

proc enableMaterials( int $enable )
// Usage:
//   enableMaterials( 0 );  -- turn off all Materials.  Everything renders
//                             gray.
//   enableMaterials( 1 );  -- turn on all Materials (normal render)
{
   string $materials[] = `ls -materials`;

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

To demonstrate what this script is doing, open the MultiLister and double-click on a Material to display it in the Attribute Editor.

Hold down the RMB over the ‘Color‘ attribute label. One of the items in this pop-up menu is “Ignore When Rendering.” This script is simply toggling this attribute — formally known as the ‘-connectionState’ attribute — off or on.

To truly disable the texture you’d want to toggle the ‘.transparency,’ ‘.ambientColor,’ etc., attributes as well. I’ll leave that as an exercise for the reader.

Note: The “Ignore When Rendering” option in the UI is only available on mapped attributes, and there’s no indication when the -connectionState is disabled for unmapped attributes. This makes sense, I suppose — a ‘connectionState’ doesn’t affect something that doesn’t have any connections.

Regardless, setting the ‘−connectionState‘ to false does take even on unmapped attributes. If you map an attribute for which the ‘−connectionState‘ is disabled, you will have to explicitly enable it to see the affects of the mapping.

Thanks to Scott Hamilton of A|W for sharing this technique.

Advertisements

发表评论

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 更改 )

Twitter picture

You are commenting using your Twitter account. Log Out / 更改 )

Facebook photo

You are commenting using your Facebook account. Log Out / 更改 )

Google+ photo

You are commenting using your Google+ account. Log Out / 更改 )

Connecting to %s

%d 博主赞过: