I’m setting the following in Maya 2018.1 on Windows 10:
import maya.cmds as cmds
import maya.mel as mel
vrlmapFilepath = '//server/prod/proj2/maya/images/scene83/pre-render/vrlmap_per_frame_renderlayer1_camera1.%04d.vrlmap'
cmds.setAttr('vraySettings.primaryEngine', 3) # Set Light cache (primary engine)
cmds.setAttr('vraySettings.secondaryEngine', 0) # Disable secondary engine alltogether
cmds.setAttr('vraySettings.mode', 0) # Set light cache mode to Single frame
cmds.setAttr('vraySettings.autoSaveFile', vrlmapFilepath, type='string') # Set path to vrlmap file
cmds.setAttr('vraySettings.autoSave', 1) # Enable autosave of vrlmap file
cmds.setAttr('vraySettings.globopt_gi_dontRenderImage', 1) # Disable final image rendering
cmds.setAttr('vraySettings.sys_distributed_rendering_on', 0) # Disable DR
1. EXR is written although “Don’t render final image” is enabled
Although I just want to render out the vrlmap, the multichannel EXR is also written out (V-Ray 3.60.02). Do you see this on your end too?
It would be great if the EXR was not written.
2. Did the autosave attribute name change?
With the code snippet above, vrlmaps are generated as expected. But I notice that when setting vraySettings.autoSaveFile like above, the filepath is not visibly entered into the render globals UI. If I edit this attribute in the render globals UI by hand (not by code) I see the following being outputted to the script editor:
- and so it seems this attribute name has changed from “vraySettings.autoSaveFile” to “vraySettings.lc_autoSaveFile”. Is this correct? Should I be using vraySettings.lc_autoSaveFile instead of vraySettings.autoSaveFile?
- Do you know for which V-Ray for Maya version this was changed?
Looking into it now. I think we changed it back in september 2014 (around when 3.0 came out) and that’s why there’s two attributes. The newer one is the one we currently use and we added it to allow support for <tags> in the filepaths and filenames. Our code should do a sync between the two if needed (I think), but it would be best if you used the newer one just to stay on the safe side. So the “lc_” prefixed attribute is the one you want. Looking into the other issues now.
Hmm, The other thing seems to be a bug, it also affects .vrimg. I’ll add a ticket to our bug-tracker.
In my tests, a possible workaround is to also enable “don’t save image” (setAttr vraySettings.dontSaveImage 1) along with “don’t render final image”
When also setting vraySettings.dontSaveImage, the EXR is still written, so that workaround did not work for me.
I just tried using only the “lc_” prefixed attribute for the filepath. What’s funny is when I use that path with V-Ray 3.60.02 is, no vrlmap is written at all!
When I execute the command in the Maya UI I can see that the attribute field is not populated with anything and remains empty.
But if I use the older attribute, the vrlmap is rendered. Do you see this on your end too?
You should be able to repro this by opening up Maya 2018.1 + V-Ray 3.60.02 official and executing the following:
"""Light cache map WRITE pre-render script"""
import maya.cmds as cmds
import maya.mel as mel
vrlmapFilepath = '//server/prod/proj2/maya/images/scene83/pre-render/vrlmap_precalc_per_frame_greenlayer_camera1.%04d.vrlmap'
cmds.setAttr('vraySettings.primaryEngine', 3) # Set Light cache (primary engine)
cmds.setAttr('vraySettings.secondaryEngine', 0) # Disable secondary engine alltogether
cmds.setAttr('vraySettings.mode', 0) # Set light cache mode to Single frame
# This actually does work (if uncommented)
# cmds.setAttr('vraySettings.autoSaveFile', vrlmapFilepath, type='string') # Set path to vrlmap file (legacy)
# Oddly enough, the below autosave cmd does not seem to set the value in Render Globals and doesn't work in batch render mode
cmds.setAttr('vraySettings.lc_autoSaveFile', vrlmapFilepath, type='string') # Set path to vrlmap file
cmds.setAttr('vraySettings.autoSave', 1) # Enable autosave of vrlmap file
cmds.setAttr('vraySettings.globopt_gi_dontRenderImage', 1) # Disable final image rendering
cmds.setAttr('vraySettings.sys_distributed_rendering_on', 0) # Disable DR
- Is the “lc_ …” attribute field empty in your Maya UI as well after having executed the above code?
That’s odd - the “don’t save image” part works fine here.
As for the light cache’s auto save path, paying more attention to it now - and it seems that there’s something broken, I can confirm that. But I also get the same bug with the legacy attribute (the one that’s not lc_ prefixed).
You could try a post-translate python script to make sure the correct parameter is set (since this actually edits the vray plugins’ parameters after the scene is exported to memory).
from vray.utils import *
vrlmapFilepath='C:/Users/yolov/Desktop/giwriteout/test.<frame04>.vrlmap'
slc=findByType('SettingsLightCache')[0]
slc.set('mode', 0) # Set light cache mode to Single frame
slc.set('auto_save', 1) # Enable autosave
slc.set('auto_save_file', vrlmapFilepath) # Set path to vrlmap file
#"hack" to disable image write-out
#basically forces an empty string for image name, which disables the vray image writer
so=findByType('SettingsOutput')[0]
so.set('img_file', '')
Note that in the post-translate I’ve used the <frame0n> formatting, instead of %0nd. Setting %0nd in the UI will automatically update it to the newer format.
Hope that this works as a workaround. I’ll see what’s broken in the UI, I already suspect what it is and I think it’s not going to be hard to fix.
Aaaand one more thing. Can you try reworking your initial script to use the <frame0n> format instead of %0nd? I think this is where things get funky and it “should” work fine with <frame0n>. The auto-update for the formatting gets weird when script-accessing the attribute. There’s a slightly separate code that does the update if the value is passed from the “browse”. It might explain everything we’ve seen so far.
Replacing the frame tag formatting in your script does the trick on my end, which means that there will be no need to use post-translate python.
Ok, cool, I can now use the “lc_” attribute when changing the padding in my filepath from %04d to <frame04>. Did this padding change happen back in 2014 as well?
That’s odd - the “don’t save image” part works fine here.
What exactly are you doing in order to get the EXR not to be written?
I’m rendering on the commandline (not in Maya UI or with VFB), and is providing a -preRender argument with a MEL script which launches the Python commands.
Filename prefix is: <Scene>_<Layer>_<Camera>.
Animation is enabled, rendering frame 1-1.
Scene attached: scene83.zip
"""Light cache map WRITE pre-render script"""
import maya.cmds as cmds
import maya.mel as mel
vrlmapFilepath = '//server/prod/proj2/maya/images/scene83/pre-render/vrlmap_precalc_per_frame_greenlayer_camera1.<frame04>.vrlmap'
cmds.setAttr('vraySettings.primaryEngine', 3) # Set Light cache (primary engine)
cmds.setAttr('vraySettings.secondaryEngine', 0) # Disable secondary engine alltogether
cmds.setAttr('vraySettings.mode', 0) # Set light cache mode to Single frame
cmds.setAttr('vraySettings.lc_autoSaveFile', vrlmapFilepath, type='string') # Set path to vrlmap file
cmds.setAttr('vraySettings.globopt_gi_dontRenderImage', 1) # Disable final image rendering
cmds.setAttr('vraySettings.dontSaveImage', 1) # Don't save image
cmds.setAttr('vraySettings.sys_distributed_rendering_on', 0) # Disable DR
… what happens if you do a getAttr ?
>>> vrlmapFilepath_legacy = '//server/prod/proj2/maya/images/scene83/pre-render/vrlmap_precalc_per_frame_greenlayer_camera1.%04d.vrlmap'
>>> cmds.setAttr('vraySettings.autoSaveFile', vrlmapFilepath_legacy, type='string') # Set path to vrlmap file (legacy)
>>> x = cmds.getAttr('vraySettings.autoSaveFile')
>>> print(x)
//server/prod/proj2/maya/images/scene83/pre-render/vrlmap_precalc_per_frame_greenlayer_camera1.<frame04>.vrlmap
So it seems that does work even if the UI is showing nothing in the attribute field. scene83.zip (12.9 KB)
The “don’t save image” option is ignored in command-line renders, that’s why it doesn’t work, but then again it’s still a bug that an exr is written out when “don’t render final image” is enabled.
You could still go around this by passing an empty string to SettingsOutput::img_file with post-translate python.
The frame tag was changed back in 2014, yes. It would be best to use the new tags anywhere that keywords/tags can be used, which basically means all the string fields in the render settings (vray.settings).