Arnold + Time Node + Procedural Control

Arnold + Time Node + Procedural Control

theodoredaley
Participant Participant
996 Views
12 Replies
Message 1 of 13

Arnold + Time Node + Procedural Control

theodoredaley
Participant
Participant
I'm having a bit of an issue translating some OSL and workflows into Arnold and wondering if anyone has a good solution that does not involve keyframes.

Is there a way for Arnold to read time and then be able to manipulate that in the shader? @lee_griggs

I built a procedural animation system via OSL so instead of keyframes a user just turns on a checkbox and it will jitter the XY of the image offset and then they can input in a number to animate on every 2/3/4/5/etc frames to be like stop motion. Also to have it loop like old school animation cycles. 

This relies entirely on reading the timeline (frame number) of the scene though and then doing math to that input. In Redshift "Frame Step" does not exist as a node so I wrote an OSL that just reads the scene frame number (since each scene could be 30fps , 24 fps, etc) and it worked great.

I'm using the same OSL code in Arnold but figuring out how to input it in Arnold though is not working for me. It compiles and works but does not update the XY image at all.

It started with this basic concept but then grew from there: https://www.youtube.com/watch?v=-KN-IGsLzS4

I asked chat gpt and it said Arnold can not read time via Shader (looking specifically for Maya solution) but chat gpt is not always right! Hence asking here. I am trying my very best to not force keyframes into the shaders and would love to get it into Arnold if possible or some other fix or code. 
0 Likes
997 Views
12 Replies
Replies (12)
Message 2 of 13

wernienst
Collaborator
Collaborator

That should be possible. However I only have Arnold for 3dsMax at hand.

Here, there is an OSL: Frame Number node that reads the actual frame number. It can be used as input to other nodes.

The following example changes the bitmap via Switch RGB every 10 frames.

wernienst_0-1777993854389.png

Arnold's Image node can use custom UV values as input.

0 Likes
Message 3 of 13

theodoredaley
Participant
Participant

Thanks for the fast reply!! 

If you try the OSL shader I attached as a zip in 3DS Max does it work for you? I had someone else in Max + RS try this precise OSL and it did work (but just would like to double confirm on your end if possible does it work in 3DSMax+Arnold).

Maya + Arnold however it does not work for some reason and there is no Maya native OSL FrameNumber node unfortunately, boy that would be awesome...

Also could you copy/paste the code you see in that 3DS Max Native OSL FrameNumber node (if it can be exposed that is)? Maybe I can see what it is doing to compare and see if I need to change something to work for Maya+Arnold.

0 Likes
Message 4 of 13

wernienst
Collaborator
Collaborator

Ok, I have successfully loaded your TimeJitterXY shader. Here is a very simple setup:

wernienst_0-1778082555520.png

The FrameNumber node is feeding the Seed input and is causing the image to jump between the Jitter extremes.

To be able to move the image around, I have inserted an Arnold UV Transform node.

You can find the shader code here.

0 Likes
Message 5 of 13

theodoredaley
Participant
Participant

Oh interesting - thanks so much for testing this one out in 3DSMax!!

Ok so this was something I was wondering as well (how to add an input for the frameNumber). Since doesn't feeding into the seed make it update but the math of the animation on/off, frameStep, loop I believe would not function correctly. 

So for Maya I still need to solve the frameNumber issue. I tried updating the OSL to have an input for the frameNumber directly (just don't know how to get that data from Maya). 

If you swap this newer OSL (Even though says  Maya -should work in Max) in I believe it will should allow you to use that 3DSMax frameNumber directly vs seed. 

But again, this all seems to work in MaxArnold but not MayaArnold. 

0 Likes
Message 6 of 13

theodoredaley
Participant
Participant

Taking the OSL from the 3DS Max github, I just tried to use that in C4DArnold just to quickly test. It doesn't get the framedata from the timeline - at least in there. I always do this to quickly RnD if time is being read and updating (HueShift over time) but it only worked once I would manually input a frame number. So guessing Maya will have that same issue with the OSL. 

0 Likes
Message 7 of 13

Stephen.Blair
Community Manager
Community Manager

Frame data from the timeline won't be available at render time.
Some plugins, like MtoA, put the frame number as user data on the options node. 
Export an ASS file and check that, you'll see what info is available at render time. 

I suppose a shader could read the frame number from the options node. Or maybe the OSL shader can put the frame/timeline data as user data on some other object in the scene.



// Stephen Blair
// Arnold Renderer Support
0 Likes
Message 8 of 13

theodoredaley
Participant
Participant

Hi Stephen, thanks for the input.

So would that mean the OSL I just posted with the frameNumber as an input, could we add the frame data into that? I don't really use Maya so anything complex sounds already over my head in many ways - I'm just trying to convert shaders I built in C4D+RS, was able to get help to build Maya+RS (including the frame info), so hoping there is an equivalent for Maya + Arnold. 

"Export an ASS file and check that, you'll see what info is available at render time." How would you check that?
"I suppose a shader could read the frame number from the options node." I don't know what that means unfortunately. Is there a video or image or documentation to explain this a bit more?

I was reading online and saw that there is some way to use Maya Mel script to add frame data to ports? Could that be a possibility? Ie. in the shader have Mel Script attached to a node that does read the frameNumber, or the OSL input itself? If so, how would you do that (ie. what steps/ code are needed)? Or if not then is there some comparable setup like the 3DS Max method that @wernienst showed? 

0 Likes
Message 9 of 13

babarbrohi820
Contributor
Contributor

Interesting setup  Arnold can be pretty restrictive compared to Redshift when it comes to timeline-aware shader behavior. From what I know, Arnold shaders generally don’t have direct access to scene time/frame data in the same way, so people usually pass frame values through user data, expressions, or driver nodes instead of reading time directly inside OSL. Your procedural stop-motion workflow sounds really cool though.



 
 
 
0 Likes
Message 10 of 13

theodoredaley
Participant
Participant

Thanks for this insight! I would like to know what are the ways to do this through you mentioned: 
1. user data 
2. expressions 
3. driver nodes 

Treat me like a baby who has just heard the words "Maya" "Mel" "Arnold"  and how would I be able to get the frame number into the shader (be it a screenshot/documentation/video clip/file to look at). In my (childlike) mind, somehow you:
1/Mel Script that gives you the frame number --> connect to my OSL "FrameInput" --> done.
or somehow you
2/right click on the OSL "FrameInput" -->do some Maya stuff that gives you the frame number expression --> done
or
3/you have a node that drives time in the shader --> connect to OSL --> done

Of course I am oversimplifying this but I truly don't know Arnold and Maya, Redshift also does not give you access to frame/time. So in C4D I found out you can create frameNumber via OSL. And in Maya+RS the same thing held up but it does not in Arnold so this I understand. 

But if the user data is a method, how do you do this? If it is expressions - what expression and where does it go? Driver nodes - what does this mean? I really do not know/understand Maya unfortunately to this degree. So asking (as I have been searching online and failing) what the actual steps are. 

My latest OSL (attached again here) does not read frame number, it will take in that data though and do functions to it. Hence added the  "FrameInput" so can connect some form of frame information (wherever/however that can be accessed) as opposed to trying to read frame via the OSL. 

If this is not possible then ok, but it sounds from the replies as if there are methods to do this? I'm just asking for more specifics. Or if not good to know I tried my very best and then I can cut the feature (that is what I had to do for Octane, since truly no way to do it after talking with their devs). 

0 Likes
Message 11 of 13

Stephen.Blair
Community Manager
Community Manager

To get the frame number during a render, it has to be an Arnold plugin, like an Arnold shader. For example, in OSL, something like this:

shader read_frame(
    output float out_frame = 0
)
{
    getattribute("options", "frame", out_frame);
}

 

options.frame is actually not custom user data. frame is a builtin parameter of the options node.
MtoA sets the frame value.

If you needed some other kind of timeline data, then maybe you would use "Arnold user data".
See this tutorial: Help | Ai User Data Float Tutorial | Autodesk

 

MEL or Maya expressions, stuff that is evaluated in Maya, could be used to get the values you want to store as Arnold user data.



// Stephen Blair
// Arnold Renderer Support
0 Likes
Message 12 of 13

mouradking2026
Community Visitor
Community Visitor

@theodoredaley wrote:
I'm having a bit of an issue translating some OSL and workflows into Arnold and wondering if anyone has a good solution that does not involve keyframes.

Is there a way for Arnold to read time and then be able to manipulate that in the shader? @lee_griggs king365tv

I built a procedural animation system via OSL so instead of keyframes a user just turns on a checkbox and it will jitter the XY of the image offset and then they can input in a number to animate on every 2/3/4/5/etc frames to be like stop motion. Also to have it loop like old school animation cycles. 

This relies entirely on reading the timeline (frame number) of the scene though and then doing math to that input. In Redshift "Frame Step" does not exist as a node so I wrote an OSL that just reads the scene frame number (since each scene could be 30fps , 24 fps, etc) and it worked great.

I'm using the same OSL code in Arnold but figuring out how to input it in Arnold though is not working for me. It compiles and works but does not update the XY image at all.

It started with this basic concept but then grew from there: https://www.youtube.com/watch?v=-KN-IGsLzS4

I asked chat gpt and it said Arnold can not read time via Shader (looking specifically for Maya solution) but chat gpt is not always right! Hence asking here. I am trying my very best to not force keyframes into the shaders and would love to get it into Arnold if possible or some other fix or code. 

Interesting question. Procedural control can be very powerful when working with animated effects and complex scenes. Using the time node to drive parameters dynamically often provides much more flexibility than relying on manually keyed values, especially when experimenting with different timing setups.

0 Likes
Message 13 of 13

mohamedbentaleb395
Community Visitor
Community Visitor

@theodoredaley wrote:
I'm having a bit of an issue translating some OSL and workflows into Arnold and wondering if anyone has a good solution that does not involve keyframes.

Is there a way for Arnold to read time and then be able to manipulate that in the shader? @lee_griggs

I built a procedural animation system via OSL so instead of keyframes a user just turns on a checkbox and it will jitter the XY of the image offset and then they can input in a number to animate on every 2/3/4/5/etc frames to be like stop motion. Also to have it loop like old school animation cycles. 

This relies entirely on reading the timeline (frame number) of the scene though and then doing math to that input. In Redshift "Frame Step" does not exist as a node so I wrote an OSL that just reads the scene frame number (since each scene could be 30fps , 24 fps, etc) and it worked great.

I'm using the same OSL code in Arnold but figuring out how to input it in Arnold though is not working for me. It compiles and works but does not update the XY image at all.

It started with this basic concept but then grew from there: https://www.youtube.com/watch?v=-KN-IGsLzS4iptv

I asked chat gpt and it said Arnold can not read time via Shader (looking specifically for Maya solution) but chat gpt is not always right! Hence asking here. I am trying my very best to not force keyframes into the shaders and would love to get it into Arnold if possible or some other fix or code. 

This is exactly the kind of information I was looking for. Reading the frame from the options node seems much cleaner than relying on keyframes for procedural animation. I'll experiment with getattribute("options", "frame", out_frame) and see how well it fits into my OSL workflow.

0 Likes