LUA - Track render target changes events

Forums: LUA - Track render target changes events
Forum for OctaneRender Lua scripting examples, discussion and support.

LUA - Track render target changes events

Postby enricocerica » Sun Mar 31, 2019 10:25 am

enricocerica Sun Mar 31, 2019 10:25 am
Hi,
I would like to execute some LUA code whenever I start rendering from a render target and when I change for instance the camera position in this render target.
I would like to track those events in my LUA script but cannot find any way to achieve that.
Any suggestion welcome
Modeling system : I7 32GB Windows 10 & Fujitsu Celsius H720
GPU : 1x Gigabyte GTX580 3GB + 1x MSI GTX780 3GB + 1x PALIT GTX780 6GB +1x Asus Stix GTX1070 8GB
http://www.myline.be
User avatar
enricocerica
Licensed Customer
Licensed Customer
 
Posts: 994
Joined: Wed Nov 25, 2009 7:32 pm

Re: LUA - Track render target changes events

Postby jobigoud » Fri Apr 05, 2019 10:21 am

jobigoud Fri Apr 05, 2019 10:21 am
For the camera changes you'll need to use `_evaluateAllChanges` so the upstream changes on the camera position/target fields trickle down to the script.
Here is a very minimalist snippet showing it. If you expand your RT camera and plug it into the script, every time you change viewpoint the node name will be updated.

Code: Select all
local scriptgraph = {}
scriptgraph._evaluateAllChanges = true

function scriptgraph.onInit(self, graph)
    local pinInfoCamera = { label = "Camera", type = octane.pinType.PT_CAMERA }
    graph:setInputLinkers({pinInfoCamera})
end

function scriptgraph.onEvaluate(self, graph)
    graph.name = "time:" .. tostring(octane.util.getCurrentMillis())
end

return scriptgraph


For the "start rendering" I think you'll need to go through a render job.
User avatar
jobigoud
OctaneRender Team
OctaneRender Team
 
Posts: 23
Joined: Sat Aug 15, 2015 1:28 pm

Re: LUA - Track render target changes events

Postby enricocerica » Sat Apr 06, 2019 7:41 am

enricocerica Sat Apr 06, 2019 7:41 am
Thanks Jobigoud,
My script already get the camera info and it works fine but I have to run it each time I select a new render target which is not useful.
To be more clear on my wishes, each time I select a render target I would like an object to be automatically placed at the camera position without any action (I mean not running the script manually).
As I'm using a sphere around the camera in combination with a sphere surrounding the scene to created fog, the sphere around the camera should be placed at it's position when I start render.
Indeed the batch render job may help as the start render could be triggered but I usually render interactively and if I often miss the sphere placement and I should restart everything ...
It's not a big issue but would be cool to enhance my script with this feature ;)
Modeling system : I7 32GB Windows 10 & Fujitsu Celsius H720
GPU : 1x Gigabyte GTX580 3GB + 1x MSI GTX780 3GB + 1x PALIT GTX780 6GB +1x Asus Stix GTX1070 8GB
http://www.myline.be
User avatar
enricocerica
Licensed Customer
Licensed Customer
 
Posts: 994
Joined: Wed Nov 25, 2009 7:32 pm

Return to Lua Scripting


Who is online

Users browsing this forum: No registered users and 1 guest

Sat Oct 19, 2019 2:40 am [ UTC ]