Go to: Synopsis. Limitations. Return value. Related. Flags. MEL examples.

Synopsis

convertLightmap [-bakeSetDefault string] [-bakeSetOverride string] [-camera string] [-exportPathNames string] [-file string] [-help] [-miStream] [-notUndoable] [-project string] [-separator string] [-shadows] [-transferMapSpace string] [-useLensBake] [-vertexMap] string object [string object ...]

convertLightmap is undoable, NOT queryable, and NOT editable.

Calculating global illumination is an expensive and time-consuming task that denies its usage in realtime rendering. As long as the lighting conditions in scenes do not change, illumination on objects can be precomputed and stored in appropriate data structures, like texture maps or vertex colors. These can then be applied in realtime applications like hardware rendering and game engines.

The Lightmap Rendering feature allows to prerender surface color or surface lighting (including global illumination) into file textures and per-vertex colors, respectively, on a per object basis. These file textures can then be used as regular texture maps to speed up subsequent software renderings and to apply the precomputed rendering effects even to hardware rendering.

For the purposes of baking and prelighting, mental ray for Maya supports the convertLightmap command.

Any given shading group must be assigned to (some components) of the given object. Any number of shading group - object combinations can be given. The given object should uniquely identify a single instance of a single shape node. If just a transform name or a shape name is given, the command will try to determine the first child shape or instance parent. If a single object should be baked that has multiple materials assigned (per-face assignment on mesh objects, per-instance assignment on multiply instanced shape nodes) then every shading group has to be provided separately referencing the same object. On the other hand, if the same material has been applied to multiple objects (shared materials) then this shading group needs to be given multiple times for all of the objects.

Besides the command flags, per-object settings are set through bakeset of each object. If an object does not have a bakeset, and -bo flag is not specified, default settings for a bakeset will be used. See node reference of TextureBakeSet and VertexBakeSet

Limitations

The lightmap rendering is done with the render quality currently set in the mental ray render globals. Especially, photon tracing and/or final gathering should be enabled to compute global illumination that will be considered during lightmap generation. But certain limitations apply to the current implementation:

Return value

string[]The command returns an array for string values of exactly the same length as bake combinations have been given. The returned string contains the name of the baked object (either texture file name or vertex bake object) upon success, or the string "error" otherwise.

Related

Mayatomr

Flags

bakeSetDefault, bakeSetOverride, camera, exportPathNames, file, help, miStream, notUndoable, project, separator, shadows, transferMapSpace, useLensBake, vertexMap
Long name (short name) Argument types Properties
-help(-h) create
Prints a verbose help message.
-vertexMap(-vm) create
Bake illumination into vertices. If not present bake into a light map.
-useLensBake(-ulb) create
Special texture bake mode, which uses a lens shader to shape the lens to the object. Not valid with the -vertexMap flag. Best suited to baking a single large object.
-camera(-cam) string create
Which camera to use for computing the direction of the incident ray. Default: current render camera
-shadows(-sh) create
Take shadow into account. If shadow is disabled in the mental ray render globals, mental ray for maya will enable the shadow map, and shadow method segments will be turned on.
-notUndoable(-nun) create
If this parameter is given, the command can not be undone.
-project(-prj) string create
Set the project directory. If baking to a light map, light maps will be generated into "lightMap" sub directory in the project. If "lightMap" directory does not exist, the command fails to write light maps. Default: current project root directory
-separator(-sep) string create
If this parameter is given, baking will use this string to separate instance and shape name parts when generating unique file names for complex dag objects (dag instances with multiple shapes, or hierarchical dag entries). Default: no separator.
-bakeSetOverride(-bo) string create
If this parameter is given, the specified bakeset will be used instead of bakeset of each object.
-miStream(-mi) create
If this parameter is given, besides the lightmap rendering, the command generates a mental ray file that can be used with mental ray standalone. -f/-file flag must be specified.
-file(-f) string create
Specifies the absolute file name of the mental ray file to be generated. Effective only if -mi/-miStream flag is present.
-exportPathNames(-xp) string create
Export option for the file references such as : ink library, include mi file, texture file, lightmap, etc.
The string can specifies an for individual file refs, with each character in the string representing a single file ref entry, with meaning
0-nochange 1-absolute 2-relative 3-nopath, or
0-nochange a-absolute r-relative n-nopath.
The file ref entry is specified in this order :
link library, include mi file, texture file, lightmap, light profile, output image, shadow map, finalgather map, photon map, demand load object mi file. Effective only if -mi/-miStream flag is present.
Default: nochange
For example, "-xp aarrararra" will use absolute path for link libray, include file, light profile, shadow map, demapd load object mi file, and relative path for texture file, lightmap, output image, finalgather map, photon map
-transferMapSpace(-ts) string create
Use for transfer map operation only. Specify the map space. "world" or "object". Default: world
-bakeSetDefault(-bd) string create
Specifies a bake-set to include all objects not assigned to any other bake-set in the scene.

Flag can appear in Create mode of command Flag can appear in Edit mode of command
Flag can appear in Query mode of command Flag can be used more than once in a command.

MEL examples

// Bake a texture for |pSphere1|pSphereShape1 using the 'persp' camera and the initialShadingGroup.
// This uses the bakeset assigned to |pSphere1|pSphereShape1.
convertLightmap -camera persp -sh initialShadingGroup |pSphere1|pSphereShape1;

// Generates a mental ray file that can be used with mental ray standalone.
// Texture files exported with absolute path, and all other file entries
// are exported with no path.
convertLightmap -mi -file "C:/Dev/bake.mi" -xp "331333333" -camera persp -sh initialShadingGroup |pSphere1|pSphereShape1;

// Bake to verticies for |pSphere1|pSphereShape1 using the 'persp' camera and the initialShadingGroup.
// This uses the bakeset override tmpVerticesBakeSet.
convertLightmap -camera persp -sh -vm -bo tmpVerticesBakeSet initialShadingGroup |pSphere1|pSphereShape1;