Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Section
Column
width62%

The V-Ray scene access python API allows you to modify the V-Ray scene after it is translated by the V-Ray for Maya translator, and before it is rendered and/or exported to a .vrscene file. Note that the V-Ray scene may be quite different from its representation in Maya. As such, some knowledge about the way V-Ray translates various Maya constructs may be required. It would be best to study .vrscene files exported by V-Ray for Maya.

The scene access API allows you to expand the V-Ray for Maya translator by providing custom translation for constructs that are not recognized by V-Ray, or for modifying the scene before rendering without changing the original Maya scene.

You can specify the post-translate python script to be executed in the VRayCommon tab of the Render Settings dialog, in the MEL/Python callbacks rollout. The script is executed right after the scene is translated, and before it is rendered and/or exported to a .vrscene file. At present, when rendering an animation, the script is executed just once, before any frame is rendered.

For more information on various types of script access , see the Scripting page.


 


UI Path: ||Render Settings window|| > Common tab > MEL/Python callbacks rollout


 

Column
width5%

 

Column
width33%

Image Removed Image Added

Available Python Functions and Classes

...

Code Block
languagepy
from vray.utils import *

# Assuming an object pPlaneShape1@node has a VRayMtl assigned
# Get the material's diffuse texture and pass it through a TexAColorOp
# Create a TexAColorOp plugin
# Multiply the texture by a color inside TexAColorOp
# Get the 'product' output from TexAColorOp and use it as the diffuse input in the VRayMtl

node = findByName('pPlaneShape1@node')[0] # Find the node by name
node_mtl = node.get('material') # Get the node's material
node_brdf = node_mtl.get('brdf') # Get the material's brdf to reach the BRDFVRayMtl plugin
diffuseTex = node_brdf.get('diffuse') # Get the diffuse texture of BRDFVRayMtl

colorOp = create('TexAColorOp', 'TexAColorOp1') # Create a TexAColorOp texture
colorOp.set('color_a', diffuseTex) # Set the VRayMtl's diffuse texture as color_a
colorOp.set('color_b', Color(1.0, 0.1, 0.1)) # Set a Color() as color_b

node_brdf.set('diffuse', colorOp.output('product')) # Set the 'product' output of TexAColorOp as the diffuse input of BRDFVRayMtl

# Similarly, we can get the 'sum' or any other output
# node_brdf.set('diffuse', colorOp.output('sum'))

 

 

...