Scripted node stuff

Forums: Scripted node stuff
Forum for OctaneRender Lua scripting examples, discussion and support.

Scripted node stuff

Postby grimm » Sat Dec 06, 2014 9:41 am

grimm Sat Dec 06, 2014 9:41 am
Hi Thomas, Roland,

Thanks for the scripting nodes, they are very cool. :ugeek: I'm having a ton of fun playing around with them, which gave me some ideas that would be nice to have for them. Would it be possible to have the onEvaluate function be passed another parameter, like a table? The table would have in it what triggered the event (caller), like which input linker or animator if a time change. Also it would be great if the table also had in it some other ancillary information, like frame number or time stamp, etc. Having this would make it easier to do different things for different event types and be able to handle animations better. Unless there is already a method in place to do such things that I not aware of. :D
Linux Mint 19 x64 | Nvidia GTX 980 4GB (displays) RTX 2070 8GB| Intel I7 5820K 3.8 Ghz | 32Gb Memory | Nvidia Driver 440.64
User avatar
grimm
Licensed Customer
Licensed Customer
 
Posts: 1257
Joined: Wed Jan 27, 2010 8:11 pm
Location: Spokane, Washington, USA

Re: Scripted node stuff

Postby stratified » Sat Dec 06, 2014 10:00 pm

stratified Sat Dec 06, 2014 10:00 pm
Hi Jason,

Happy to hear you like it :mrgreen:

You can use inputWasChanged to check which input linker changed. Time events are only triggered by the user or a script moving the timeline. You can query the current time directly from every node or graph (e.g. node.time). Have a look at the script I posted on Friday for the details.

cheers,
Thomas
User avatar
stratified
OctaneRender Team
OctaneRender Team
 
Posts: 945
Joined: Wed Aug 15, 2012 6:32 am
Location: Auckland, New Zealand

Re: Scripted node stuff

Postby grimm » Sun Dec 07, 2014 12:11 am

grimm Sun Dec 07, 2014 12:11 am
Thanks Thomas that is perfect. Your script is giving me a lot of ideas, very cool.

I'm having a problem with the values that the .time function returns, it doesn't appear to be the same as the timeline scrubber. Look like it's off by one. If I'm on frame 0 it reports 0, which is good. If I move the scrubber to frame 1 it reports zero again. Move the scrubber to frame 2 and it reports the time for frame one, etc.

Then if I move the scrubber back to zero from frame 2 it first reports the time for frame 2 instead of 1. Then when the scrubber reaches zero it reports the time for frame 1. Looks like it's reporting the time it came from instead of the time it is currently on?

Thanks,

Jason
Linux Mint 19 x64 | Nvidia GTX 980 4GB (displays) RTX 2070 8GB| Intel I7 5820K 3.8 Ghz | 32Gb Memory | Nvidia Driver 440.64
User avatar
grimm
Licensed Customer
Licensed Customer
 
Posts: 1257
Joined: Wed Jan 27, 2010 8:11 pm
Location: Spokane, Washington, USA

Re: Scripted node stuff

Postby stratified » Sun Dec 07, 2014 12:31 am

stratified Sun Dec 07, 2014 12:31 am
grimm wrote:Thanks Thomas that is perfect. Your script is giving me a lot of ideas, very cool.

I'm having a problem with the values that the .time function returns, it doesn't appear to be the same as the timeline scrubber. Look like it's off by one. If I'm on frame 0 it reports 0, which is good. If I move the scrubber to frame 1 it reports zero again. Move the scrubber to frame 2 and it reports the time for frame one, etc.

Then if I move the scrubber back to zero from frame 2 it first reports the time for frame 2 instead of 1. Then when the scrubber reaches zero it reports the time for frame 1. Looks like it's reporting the time it came from instead of the time it is currently on?

Thanks,

Jason


Can you post a little example script so I can have a look?
User avatar
stratified
OctaneRender Team
OctaneRender Team
 
Posts: 945
Joined: Wed Aug 15, 2012 6:32 am
Location: Auckland, New Zealand

Re: Scripted node stuff

Postby grimm » Sun Dec 07, 2014 1:22 am

grimm Sun Dec 07, 2014 1:22 am
No problem, here you go:

scrubber_test.lua
(783 Bytes) Downloaded 174 times


Thanks Thomas, hope this helps.

Jason
Linux Mint 19 x64 | Nvidia GTX 980 4GB (displays) RTX 2070 8GB| Intel I7 5820K 3.8 Ghz | 32Gb Memory | Nvidia Driver 440.64
User avatar
grimm
Licensed Customer
Licensed Customer
 
Posts: 1257
Joined: Wed Jan 27, 2010 8:11 pm
Location: Spokane, Washington, USA

Re: Scripted node stuff

Postby grimm » Sun Dec 07, 2014 2:14 am

grimm Sun Dec 07, 2014 2:14 am
Hey Thomas,

Sorry looks like more issues, maybe? When I render my animation through the turntable script the script node is getting ignored. Also when I stop the render and exit the script it put Octane in a very strange state. If I try and load another ocs file it locks up Octane so tight I have to kill it with the -9 option.
Linux Mint 19 x64 | Nvidia GTX 980 4GB (displays) RTX 2070 8GB| Intel I7 5820K 3.8 Ghz | 32Gb Memory | Nvidia Driver 440.64
User avatar
grimm
Licensed Customer
Licensed Customer
 
Posts: 1257
Joined: Wed Jan 27, 2010 8:11 pm
Location: Spokane, Washington, USA

Re: Scripted node stuff

Postby grimm » Sun Dec 07, 2014 2:31 am

grimm Sun Dec 07, 2014 2:31 am
Well now it looks like the ocs file I saved of the scene crashes Octane. :( One of my CPUs gets pegged at 100% and I have to kill -9 it.

bad_ocs.zip
(11.74 KiB) Downloaded 152 times


Thanks Thomas, I'm a pest today aren't I. :twisted:
Linux Mint 19 x64 | Nvidia GTX 980 4GB (displays) RTX 2070 8GB| Intel I7 5820K 3.8 Ghz | 32Gb Memory | Nvidia Driver 440.64
User avatar
grimm
Licensed Customer
Licensed Customer
 
Posts: 1257
Joined: Wed Jan 27, 2010 8:11 pm
Location: Spokane, Washington, USA

Re: Scripted node stuff

Postby stratified » Sun Dec 07, 2014 9:39 pm

stratified Sun Dec 07, 2014 9:39 pm
Hi Jason,

Don't worry, we're happy that you're willing to help fleshing out the bugs.

grimm wrote:Thanks Thomas that is perfect. Your script is giving me a lot of ideas, very cool.

I'm having a problem with the values that the .time function returns, it doesn't appear to be the same as the timeline scrubber. Look like it's off by one. If I'm on frame 0 it reports 0, which is good. If I move the scrubber to frame 1 it reports zero again. Move the scrubber to frame 2 and it reports the time for frame one, etc.

Then if I move the scrubber back to zero from frame 2 it first reports the time for frame 2 instead of 1. Then when the scrubber reaches zero it reports the time for frame 1. Looks like it's reporting the time it came from instead of the time it is currently on?

Thanks,

Jason


You should use graph.time instead of rootGraph.time, The time in the document is updated bottom-up. This means that the scripted graph is updated first and then the root graph. The callbacks are done as soon as the scripted graph is updated but at that point the root graph isn't updated yet and hence has still the old time stamp.

grimm wrote:Hey Thomas,

Sorry looks like more issues, maybe? When I render my animation through the turntable script the script node is getting ignored. Also when I stop the render and exit the script it put Octane in a very strange state. If I try and load another ocs file it locks up Octane so tight I have to kill it with the -9 option.


I haven't tested this but the turntable animation takes a copy of the full scene but your graph script still grabs the original root graph on initialization. So I think you're always querying the time of the original unmodified project.

The crash is a bug in Octane you uncovered. It happens when you tried to access the root graph of the project while the project is still loading. You can work around this by refraining from doing anything with the root node graph in the onInit function.

cheers,
Thomas
User avatar
stratified
OctaneRender Team
OctaneRender Team
 
Posts: 945
Joined: Wed Aug 15, 2012 6:32 am
Location: Auckland, New Zealand

Re: Scripted node stuff

Postby grimm » Sun Dec 07, 2014 10:16 pm

grimm Sun Dec 07, 2014 10:16 pm
stratified wrote:You should use graph.time instead of rootGraph.time, The time in the document is updated bottom-up. This means that the scripted graph is updated first and then the root graph. The callbacks are done as soon as the scripted graph is updated but at that point the root graph isn't updated yet and hence has still the old time stamp.


Thanks Thomas, that makes sense, unfortunately I'm still getting the lag after I changed the code to use graph instead of the root graph. Here is an updated test script:

scrubber_test.lua
(715 Bytes) Downloaded 161 times


stratified wrote:I haven't tested this but the turntable animation takes a copy of the full scene but your graph script still grabs the original root graph on initialization. So I think you're always querying the time of the original unmodified project.


Ah, that makes sense too. :mrgreen: So when you copy the root graph the script node doesn't get copied as well? I just tested it with the new script that uses graph but it doesn't get updated as well. I'm still missing an understanding of what goes on underneath. I guess I was assuming that when the graph was copied it would operate like a completely separate graph in it's own space per se?

stratified wrote:The crash is a bug in Octane you uncovered. It happens when you tried to access the root graph of the project while the project is still loading. You can work around this by refraining from doing anything with the root node graph in the onInit function.


I removed all of the references to the root graph in onInit but it's still locking Octane up. :( Here are the new files I'm using:

anim_texture.lua
(1.91 KiB) Downloaded 174 times


script_node_test2.ocs
(34.57 KiB) Downloaded 222 times


Edit: Or is the get project settings also affecting it?
Linux Mint 19 x64 | Nvidia GTX 980 4GB (displays) RTX 2070 8GB| Intel I7 5820K 3.8 Ghz | 32Gb Memory | Nvidia Driver 440.64
User avatar
grimm
Licensed Customer
Licensed Customer
 
Posts: 1257
Joined: Wed Jan 27, 2010 8:11 pm
Location: Spokane, Washington, USA

Re: Scripted node stuff

Postby stratified » Sun Dec 07, 2014 11:15 pm

stratified Sun Dec 07, 2014 11:15 pm
Hi Jason,

I think you're getting confused by the rounding errors:

Code: Select all
****Event Started****
Scrubber Time - 0.03999999910593
I think this is frame # 0


The time in Octane is represented in floating point. For example if you have 25 fps, the frame duration is 0.04 seconds. In floating point this is represented as 0.03999... . If you then use math.floor(currentTime / frameTime), you will always underestimate the frame number. What you should do is have an epsilon and if you're close enough to the integer, clamp it to the integer. I know it's subtle but there's not much we can do here.

It is operating in it's own graph. The turntable animation script takes a copy of the root graph of the project but not of the project itself. But octane.project.getSceneGraph() will always return the root graph of the original project. You can get around this by getting the parent graph of the scripted graph which is always the correct one.

Accessing the project settings is the culprit here. I guess the best thing is to always fetch them during evaluation.

cheers,
Thomas
User avatar
stratified
OctaneRender Team
OctaneRender Team
 
Posts: 945
Joined: Wed Aug 15, 2012 6:32 am
Location: Auckland, New Zealand
Next

Return to Lua Scripting


Who is online

Users browsing this forum: No registered users and 7 guests

Thu Jul 02, 2020 9:50 am [ UTC ]