Scripted Common Bake Map plug-ins extend the BakeToTextureMap
and are owned by it. These plug-ins provide a unified view of a bake element that from a users's point of view looks the same for all renderers. The renderer-specific logic for each supported renderer is held in a companion CommonBakeMapOperator
, which sets up the bake environment and specifies the actual bake element used.
The default Common Bake Maps shipped with 3ds Max are located in $startupScripts/BTT
, and they are a good place to look for examples of how to implement this type of plug-in.
A scripted Common Bake Map plug-in is declared by specifying the <superclass>
as CommonBakeMap
.
Common Bake Map plug-ins implement a special extended user interface, indicated by extendedUi: true
in the rollout description. This UI uses Qt instead of legacy Win32 as the underlying UI framework, and provides access to extended Qt widget properties and layouts. See Bake To Texture Rollout Controls for more information.
The Extended UI is intended for use only with Common Bake Map plug-ins, and is not supported for any other type of rollout.
For an example see Scripted Bake To Texture plug-in Example
The following optional keywords can be used in a CommonBakeMap
declaration:
tooltTip : string
Defines a tooltip string to display when the mouse hovers over the bake map in the Bake To Texture treeview.
useGamma : bool
Indicates whether the common bake map should present gamma settings in its UI.
backgroundColor : point3
Specifies the default background color of the baked image.
The CommonBakeMapOperator
plug-in class is a renderer-specific handler that initializes and de-initializes the bake environment for a map.
The following are mandatory keywords in the CommonBakeMapOperator
declaration:
commonMapClassID : 2 element array
The class ID of the CommonBakeMap to which this bake map operator belongs to.
rendererClassID : 2 element array
The renderer class ID for which this bake map operator does bake operations.
The following is an optional keyword:
bakeElementClassID : 2 element array
The class ID of the bake element used in the baking process. The bake element can be either be defined statically via keyword on the plugin description level, or if the bake element is depended on by some operator internal logic it can also be provided dynamically via the bakeElementClassID()
callback. This gets called before the baking process if no bakeElementClassID
has been defined as a plugin class keyword.
The following properties are available on the CommonBakeMapOperator
class:
bttMap : BakeToTextureMap : Read only
The bake to texture map to which this bake operator refers to. It gives you access to the general bake map interface, including its parameters.
commonMap : MAXWrapperObject : Read only
The common bake map to which this bake operator belongs to. The object reference gives you access to the parameters defined by the common bake map.
preBake( bakeElem : BakeElementProperties) : void
This callback is called right before the baking process begins.
This can be used to do renderer- and map- specific setup of the baking environment.
The parameter bakeElement
is an instance of the bake element used for baking.
postBake() : void
This callback is called when the baking process is finished.
This can be used to reset the changes made in the preBake
callback.
requireSceneChange() : bool
Called from BTT before the baking to group the maps following their require scene change property. If the map returns true it will still be grouped with maps of same type with same parameters.
bakeElementClassID() : 2 element array
The class ID of the bake element which is used for the baking process.
If no bake element has been defined via keyword on the plugin description level, then you must implement the dynamic callback bakeElementClassID
. This gets called before the baking process so that Bake To Texture knows which bake element it should create.