Multiplying By Time Node In Shaders

Hi All,

I am trying to get an understanding of how the Time node in Shaders work.

What I want to do is change frequency of my Sine node for a varied output during runtime. It seems like I can’t control the “Period” value of the Sine node through dynamic parameters.

Therefore, my only option is to multiply the “Time” node feeding into the “Sine” node to vary the frequency. Example Below:

However, this causes a few issues. When I try to update the “PulsingRate” parameter shown in the image above (multiplier of time) inside of a blueprint, the effect visually breaks during run time. Basically the longer the game runs, the “faster” the pulsing becomes regardless of the value being set. So event if it appears to be working correctly at start of game, the pulsing will gradually become faster and faster.

To make things more confusing this multiplier only seems to make things worst if the value gets adjusted during run time. If I leave “PulsingRate” to what it started as, then the frequency will stay constant.

UnrealEditor_HnJdTtKhaI

Is there anything I am doing wrong?

1 Like

That time looks different from mine. Maybe it’s not the right one?
image

1 Like

it’s the same one, I just have mine expanded.

I did get the effect to work by creating a “FakeTime” parameter that I manually update in BP when the pulsing needs to happen. While it works, it doesn’t really solve the original issue. It’s more of a work around.

Just to be more clear, this is the work around I currently have:

If I need to update the “PulsingRate” parameter in BP, I use fake time, otherwise I use normal “Time” node.

For Fake Time node, I have a simple delta seconds increment counter that goes from 0-DesiredTimeAmount and updates the shader value every frame. It restarts from 0 whenever the pulsing needs to be enabled.

It seems like since the multiplier is creating fraction and time always moves forward, those fractions end up getting bigger and bigger. Perhaps that plays some sort of role in getting a different value from Sine?

There is something wrong with Time is the engine version. I have also noticed it.

I also couldn’t get the fake time concept to work.

It seems that the node works fine in material preview, but acts differently in game.

I seem to recall I used a parameter to subtract game time from the time node. That worked ok.

1 Like

Ah that makes sense! For me, I ended up creating a Timer component that resets every time I need pulsing to start (similar to you doing Game time subtractions).

Since I go back and forth between pulsing needing to start, speed up and stop, it works in my instance. Knowing Time will always start at 0 helped me create more control over parameters.

1 Like

I’ve accepted your suggestion as the answer since it seems to be the correct way to approach the problem! If Time needs to be altered, it needs to be accompanied by a BP.

The additional understanding I have now is that if you multiply time by an unaltered value, the scale of time is uniform so it just looks like it’s working faster.

However, as soon as you gradually alter that value, the fraction of the incrementing time become more complicated to handle. For this reason, it visually looks like it’s broken. Easiest way to combat this is to create your own time!

Thanks for your help!

1 Like

Yes, I don’t think it was like this in previous versions.

Maybe eventually, you have to remove the fix! :slight_smile:

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.