MaxScript

MaxScript Overview

In 3ds Max, assuming that your current renderer is set to V-Ray, you can refer to it from MaxScript using the renderers structure:

vr=renderers.current
VRay_Adv_1_09_03g:VRay_Adv_1_09_03g

Renderer Properties

Assuming that the variable vr holds an instance of the V-Ray renderer, you can work with the renderer settings as with any other MaxScript object:

showproperties vr
.imageSampler_type : integer
.fixedRate_subdivs : integer
.fixedRate_rand : boolean
...............
...............
...............
.options_maxDepth : integer
.options_maps : boolean
.options_filterMaps : boolean
.output_on : boolean
.output_width : integer
.output_height : integer
.output_fileOnly : boolean
.output_saveFile : boolean
.output_fileName : string
.output_saveRawFile : boolean
.output_rawFileName : string
false

Accessing the parameters is fairly easy, for example:

vr.gi_on=true

true

Renderer Methods

You can also use the following methods for saving/loading irradiance and photon maps (assuming that vr holds an instance of V-Ray):

Renderer Method
Description

vr.saveCausticsPhotonMap <filename>

saves the current caustics photon map to the given file

vr.saveGlobalPhotonMap <filename>

saves the current global photon map to the given file

vr.saveIrradianceMap <filename>

saves the current irradiance map to the given file

vr.saveLightCache <filename>

saves the current light cache to the given file

vr.loadIrradianceMap <filename>

loads the irradiance map from the given file

vr.clearIrradianceMap()

clears the irradiance map that is currently in memory

vr.clearLightCache()

clears the light cache that is currently in memory

vr.showLastVFB()

shows the V-Ray VFB window with last rendered image

Global Functions

Additionally, the following MaxScript functions are globally available:

Global Function
Description

doVRayObjectProperties()

brings up the V-Ray Object Properties dialogue

doVRayMeshExport()

brings up the V-Ray Mesh Export dialogue

vrayMeshExport [meshFile:"<mesh file>"] [autoCreateProxies:true|false] [exportMultiple:true|false] [animation:on|off] [animationRange:#scene|#explicit] [animationStart:<integer>] [animationEnd:<integer>] [animationRedrawViews:true|false] [maxPreviewFaces:<integer>]
[nodes:<object/array of objects/ objectset>]

exports a .vrmesh file without showing a dialogue.
Returns an array of newly created VRayProxy object(s), if any.

vrayMeshImport [proxy: <proxy mesh object(s)>] [explicitNormals: true|false] [weldVertices: true|false]

imports the geometry of the selected VRayProxy object(s) as an editable mesh

registerVRayMenus()

Registers V-Ray specific items in the 3ds Max standard menus

unregisterVRayMenus()

Removes V-Ray specific items from the 3ds Max standard menus

updateVRayMenus()

Refreshes all V-Ray specific items in the 3ds Max standard menus

setVRaySilentMode()

disables any V-Ray dialogues that may appear when loading a scene (i.e. notification for differences with older versions etc).

vrayEditDRSettings()

Opens the dialogue for editing the V-Ray DR settings .

V-Ray VFB Functions

The following global MaxScript functions are available for access to the V-Ray virtual frame buffer.

Global VFB Function

Description

vrayVFBGetRegionEnabled()

return whether region rendering in the V-Ray VFB is enabled (true) or disable (false)

vrayVFBGetRegion()

return an array with four integer elements, representing the pixel coordinates of the VFB render region (left, top, right, bottom). The left and top coordinates are included in the region, the right and bottom one are not.

vrayVFBSetRegionEnabled true|false

turn on or off the VFB region render option.

vrayVFBSetRegion left top right bottom

set the VFB render region to the specified coordinates.

vrayVFBGetNumChannels()

return the number of channels (render elements) in the V-Ray VFB. This will return 0 if the VFB is not initialized or does not store any data.

vrayVFBGetChannelName i

return the name of the i-th channel. Indices start from 1.

vrayVFBGetChannelType i

return the storage type of the i-th channel. Indices start from 1. The return value specifies the type of data for each pixel in the given channel: 0 - the index is not valid or the VFB does not store an image; 1 - a single floating-point number (this is used f.e. for the z-depth channels); 2 - three floating-point numbers (this is used for regular color channels); 3 - two floating-point numbers; 4 - a single integer number (used f.e. by the render ID and material ID elements); 5 - three signed floating-point numbers (this is used,for example, for normals and world position channels).

vrayVFBGetChannelAlias i

return the alias for the i-th channel. Indices start from 1. See the RegionChannelAlias enum in the file "pixelbuffer.h" from the V-Ray SDK.

vrayVFBGetChannelBitmap i

return the contents of the specified channel as a 3ds Max bitmap. Indices start from 1. This will return undefined if the channel index is not valid or the VFB does not contain any data.