x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

How to get System Time inside a Material Blueprint?

I need to be able to read the local system's time of day in seconds in real time to be used for various functions inside the material. The only time-related node that is available within the material blueprint, Time, is useless, as it does not have anything to do with real time, but instead being useful for things like UV panning or sines. After trying to find a solution online, I have found vague mentions of being able to have another blueprint feed the material various things, including system time. How do I do this?

Product Version: UE 4.21
Tags:
more ▼

asked Dec 16 '18 at 05:07 PM in Rendering

avatar image

Mihhhhhhhh
1 1 2

(comments are locked)
10|2000 characters needed characters left

2 answers: sort voted first
  • If you can get real time in simple Actor blueprint, you can create DynamicMaterialInstance in it and pass that time into material as some scalar parameter.

  • If you understand how materials system works - you can create your own material node and pass system time with it.

  • If you read Time function documentation - you will see that this function returns game time in seconds, which is really similar to what you searching for.

more ▼

answered Dec 16 '18 at 05:50 PM

avatar image

redbox
4.2k 79 16 102

avatar image Mihhhhhhhh Dec 16 '18 at 06:10 PM
  • I don't completely understand how this works.

  • This might be the best solution for my case. Do I make a Material Function, or something else?

  • Can I use game time in seconds to figure out the time of day in the real world?

avatar image redbox Dec 16 '18 at 08:03 PM
  • If you want to make some sort of time of the day system, ou must understand how it works...

  • This requires c++ knowledge to make modifications in engine. Check documentation for programmers.

  • No, game time created when game started, and destroyed when game closed.

avatar image Mihhhhhhhh Dec 16 '18 at 08:26 PM
  • ...I understand how the system I’m making works, it is simply lacking one parameter to tie it all together. What I don’t understand is how DynamicMaterialInstances work or how they can get any variables from an Actor Blueprint, but I’ll do some research.

  • More reading to be done for this one as well. It might be a good option.

  • That makes it irrelevant in my case, like in the OP, as similarity isn’t of any use here.

(comments are locked)
10|2000 characters needed characters left

Hi,

I think the first option that @redbox tried to say is this;

Create a Blueprint Actor; On EventBeginPlay (or any other event that suit for you) you create a dynamic material instance, then push from the Return Value a Set Scalar Parameter (or any other parameter that you want to set), then you get the Get Real Time Seconds and plug into the value of the parameter node. Remember to write correctly which parameter you want to set (image below):

alt text

capturar.png (64.1 kB)
more ▼

answered Dec 18 '18 at 06:11 PM

avatar image

Alan199211
6 1 2 3

avatar image Mihhhhhhhh Dec 18 '18 at 06:39 PM

Thank you! How does this work? All of the tutorials and the official documentation states that for this to work, you need to base this all around a mesh that has the material. I also can't seem to be able to replicate your screenshot. You have a Target, I have a Collection-input which has an empty dropdown-menu. I also can't simply type a parameter name, but instead have an empty dropdown menu. alt text

problem.png (65.6 kB)
avatar image Alan199211 Dec 18 '18 at 07:05 PM

That's because you probably are using the wrong set scalar parameter value node.

Try to pull the value from the Return Value.

alt text

capturar.png (59.8 kB)
avatar image Mihhhhhhhh Dec 18 '18 at 07:27 PM

My bad, there are two nodes with the same name which I didn't notice - fixed it. What do I do with this Actor Blueprint now? Can I simply use the material wherever now?

avatar image Alan199211 Dec 18 '18 at 07:32 PM

You can add a Static Mesh Component which is the Mesh that you're using the material, then you can use normally on your levels without difference

avatar image Mihhhhhhhh Dec 18 '18 at 08:44 PM

One more question. Get Real Time Seconds' tooltip is Returns time in seconds since world was brought up for play. That doesn't sound right. Shouldn't I instead be using Now which says Returns the local date and time on this computer?

avatar image Alan199211 Dec 18 '18 at 11:04 PM

Oh!! I haven't noticed but Get Real Time Seconds really is the same thing as @redbox said earlier, it starts to count after begin play and stops after end play. Sorry :(

The correct node should be Now, then you get the time in seconds, minutes, hours, etc.

alt text

capturar.png (26.5 kB)
avatar image Mihhhhhhhh Dec 19 '18 at 12:35 AM

Thank you, you were really helpful and everything functions as it should :- )

(comments are locked)
10|2000 characters needed characters left
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question