i’m working on this little tool and could really use some guidance. I worked out the RPM related kinks with Grant at RPM but this is still not fully functioning.
It will create a Property CapSet for all lights in the scene. Then it creates a single pass for each light and attempts to turn all but that light off…
It works to turn VRaySun off, but does not turn it back on again…
Also, it is not working with daylight systems. i.e. $[2].enabled = true
It still needs a lot of work beyond these issues. I have yet to take into account the number of existing CapSets.
if not rmpasses.open do RPMdata.RMopenFloater()
global allLights = #()
for a in lights where classof a != Targetobject do --and classof a != objectset
(
append allLights a
)
capSet = RPMCaptureProps.createCaptureObjectSet() -- create a new capture set. Would like to add the Name at this point
lightCapture = RPMCaptureProps.getMyPropDefinitions lightinputarray:#("On") --Define the properties
RPMCaptureProps.assignCaptureProperties #(1) lightCapture --Assign the properties to the capture set. Would like to use the appropriate index here if there were existing CaptureSets
RPMCaptureProps.addObjectsToSet 1 allLights suppressProgress:false -- Add all the lights to the CapSet
--Build a pass for each light
for i = 1 to allLights.count do
(
lightname = allLights[i].name
RPMdata.AddPassSetup setname:lightname noEdit:true
--turn off all lights
for k = 1 to allLights.count do
(
if (hasproperty allLights[k] "enabled") then allLights[k].enabled = false
else if (hasproperty allLights[k][2] "enabled") then allLights[k][2].enabled = false
else allLights[k].on = false
)
--turn on the corrisponding Light
if (hasproperty allLights[i] "enabled") then allLights[i].enabled = true
else if (hasproperty allLights[i][2] "enabled") then allLights[i][2].enabled = true
else allLights[i].on = true
RPMCaptureProps.OPcapture_object allLights
)
rmpasses.close()
RPMdata.RMopenFloater()
For anyone interested, Grant from RPM worked it out for me. If you have RPM, this will create one pass per light, including any light with the “enabled” property instead of “on”
enjoy!
p.s. if you don’t have RenderPassManager, have a look here. It is a major lifesaver and the support is amazing.
if not rmpasses.open do RPMdata.RMopenFloater()
global allLights = #()
for a in lights where classof a != Targetobject do
(
append allLights a
)
global existPasses = RPMdata.GetPassCount() --store the existing number of passes
print ("PassCount:" + existPasses as string)
haveCreatedLightSet = false;
--Build a pass for each light
for i = 1 to allLights.count do
(
lightname = allLights[i].name
RPMdata.AddPassSetup setname:lightname noEdit:true force:true -- the force stops it asking about creating a camera
if haveCreatedLightSet == false do -- if we call these before a pass is created it errors.
(
-- assume there is only one
capSet = RPMCaptureProps.createCaptureObjectSet() -- create a new capture set. Would like to add the Name at this point
RPMCaptureProps.setCapSetName (RPMCaptureProps.getnumcapsets()) "Lights"
lightCapture = RPMCaptureProps.getMyPropDefinitions lightinputarray:#("On") custominputarray:#("enabled")--Define the properties
-- work around the problem that the last call didn't actually do what it should have and add the supplied custom property:
lightCapture[7] = #("enabled")
RPMCaptureProps.assignCaptureProperties #(RPMCaptureProps.getnumcapsets()) lightCapture --Assign the properties to the capture set. Would like to use the appropriate index here if there were existing CaptureSets
RPMCaptureProps.addObjectsToSet (RPMCaptureProps.getnumcapsets()) allLights suppressProgress:false -- Add all the lights to the CapSet
haveCreatedLightSet = true;
)
for k = 1 to allLights.count do --turn off all lights
(
if isproperty allLights[k] #on then (
allLights[k].on = false --turn on the corrisponding Light
)
else if isproperty allLights[k] #enabled do(
allLights[k].enabled = false --turn on the corrisponding Light
)
)
if isproperty allLights[i] #on then (
allLights[i].on = true --turn on the corrisponding Light
)
else if isproperty allLights[i] #enabled do(
allLights[i].enabled = true --turn on the corrisponding Light
)
RPMCaptureProps.OPcapture_object allLights
)
rmpasses.close()
RPMdata.RMopenFloater()
Awesome -that will be very handy. Thanks for the share!
b
No problem.
The one thing it needs is to turn off the environment map in the common params. when i have time, I’ll look into it. If anyone solves it in the mean time, I’d love to have an update.