How does Game Time differ from Time in material functions?

Hi

im making a material function to drive a material

and then recreating the function in a blueprint to similarly drive a physcics object displacement

I am using ‘Game Time in Seconds’ in the blueprint

How does this correspond with Time in the Material Function?

thanks

Hope this gets answered because there does not seem to be a lot of information on this. As far as I can tell game time and material time aren’t connected in any way – in fact material time can ‘loop’ at a given period. I’m currently having trouble retrieving this current material time for blueprint calculations.

From what I understand the purpose of the ‘Time’ node in the material editor is timing of operations, as in timing like what a metronome provides. Keeping a beat or a steady pace.

‘Game Time in Seconds’ on the other hand keeps track of time passed, like a stopwatch, returning the same value everywhere.

I think that the two will not reliably return the same value due to the material Time node not being initiated the same way Game Time in Seconds is initiated. A material on a spawned object would likely start ticking from that point on.

If you want an identical value to be shared between blueprint and material I think you would have to pass a parameter from blueprint to a material.

I’m guessing there is no way of passing a parameter from a material to a blueprint due to where and when they are executed in the system. Blueprint CPU(first), Material GPU(last)

1 Like

thanks for your comment.

I have in fact also been looking for a way to pass a parameter from material function to a blueprint, and have not found one.

Your explanation makes sense. Is there a clear and reliable guide somewhere which extends this style of description, i.e. to explain how Unreal actually conceptualises and represents the game in code?..

because as a newby I would have found this very very useful, but I didnt find it anywhere.

There is quite a substantial amount of documentation on the structure of games in unreal.
https://docs.unrealengine.com/latest/INT/Programming/UnrealArchitecture/index.html

Looking at it, it does seem to be divided into the two domains of gameplay coding/scripting, and rendering. I don’t know of any article that describes the jump between the two.
The way I think of it is, that the gameplay code runs to completion taking all changes into account and places meshes and effects according to the results of input and algorithms. The scene containing meshes and references to materials, things to be seen, are then passed to the GPU for it to do its thing, filling the gbuffer with scene textures to be used by material code to render an image to be passed through post processing and then put on screen. Everything repeating once per frame.

Even if the editors for blueprints and materials look the same, the compiled output from them is different. Blueprints are turned to something C++ like, while materials end in HLSL I believe. Two different languages for two different purposes. I guess the ability to pass variables from materials to blueprint does not exist because it would be impractical to implement and the results from doing so could likely be achieved by passing variables the other way instead.

Here is a tutorial explaining how to drive material parameters using a blueprint, it might be what you are looking for.

I stumbled across a way to get parameters from material instances and remembered this question.

If you have a reference to a dynamic material instance you can use get scalar, or vector, parameter nodes to get their values.

I am not sure how it was back in those days, but in 4.19 Time equals World->GetTimeSeconds().

This is not correct on 4.25.5.

Easy to prove by throwing Time node into a DebugScalarValues node. In editor it shows as being the time since the editor was started. I haven’t tested a build but I imagine it’s the time since the game was launched, which would differ from World time if you change worlds.

I worked around this by having a MaterialCollectionParameter called “WorldTimeSeconds” that I set every Tick in my GameMode to GetWorld()->GetTimeSeconds() so that they were aligned and any material could use it globally.

Now I can just tell my one-shot flipbooks what the current time is and it can play once and stop all in the material :slight_smile:

1 Like

As of 5.3, 19/12/2023.

Material::Time == FApp::GetCurrentTime() - GStartTime =/= GetWorld()->GetTimeSeconds()

1 Like

It’s true for UE 4.27 too