Changing material with sun rotation

Is there any way to take out sun rotation value and put it inside material that will allow me to change material alpha?
I have landscape material that from some height show snow on north side of the mountain - its material blend of HeightLerp and one other normal and I want to change mask from combined during the day to only HeightLerp during the night. Is that possible, and if it is how can I do this or where to look to find some answers?

Hello! One common method is to create Material with parameter, after that instance from it dynamic Material Instance (For BP - Create Dynamic Material Instance | Unreal Engine Documentation, for C++ - UMaterialInstanceDynamic | Unreal Engine Documentation). In both case in created instance you can change param with SetParameter funcs…

Another possible one could be to maybe use Material Parameter Collection?

  1. Create the collection.
  2. Add float or vector parameter to store sun rotation.
  3. Create level blueprint.
  4. Assign sun value to collection parameter.
  5. Add Collection Param in you material graph to grab sun angle data.

I made as you said, but I can’t find anywhere any info how to set new rotation information into this parameter collection that I could read it in material - could you elaborate more?

Depending on what kind of rotation value you wanna use, it can be a float. or a vector.
for example, you can use vector to grab all rotation axes (X,Y,Z).
then in the level blueprint, grab those values from your sun asset and assign it to the material collection parameter you created.
Does that answer you question? :slight_smile:
If not, maybe try to follow the tutorial on the page, the concept of the workflow came from there :slight_smile:
Let me know afterwards if it is still not clear, i’ll try if i can still help you out.

In logic way I know what you are saying, but I can’t repeat it with my poor skills :slight_smile:
I created parameter as a vector (it doesn’t matter for me which type) to separate XYZ to RGB.
Then I opened level blueprint, there I made for my directional light rotation on tick only on Y axis multiplied by time and I updated my light rotation and sky. Now I don’t know how to get that angle im using to set the parameter - I dont know how to take it and set it and then I dont know how to put it into material(probably because I didnt made set part right) - I only know that for angle on Y from 0-180 is perm 0, and from 180-250-360 is gradient 0-1-0

I dont know how to take it and set it
In the tutorial, it shows a “Set Scaler Parameter Value” node for your level blueprint.
Pick your Material Parameter Collection there, and pick the parameter you created to override.
Then pipe in you angle values to it.

and then I dont know how to put it into material.
You can drag and drop your Material Parameter Collection file to the Material Editor :slight_smile:
It should contain the parameter you created.

Yeah that with drag drop I figured out below is what I managed. Sorry, Im total newbie in unreal so I maybe know 0.1% of stuff :smiley: I was looking even for something that I could see if parameter in the material editor is changing - you know, even numerically but I couldn’t find how to do it.

Sorry, Im total newbie in unreal so I maybe know 0.1% of stuff :smiley:
haha no worries, same here. still trying to learn a lot of stuff. i only just jumped backed again to using unreal >_<

I was looking even for something that I could see if parameter in the material editor is changing
yeah, for this i tend to visualize the values through colors. You could try plugging it directly to the diffuse or emission, and see if it’s gonna change.

I’ve found something that could be solution but atm I have no idea how to connect it.
From rotator extract Y angle and somehow connect it with curve where I will determine value from 0-1, and from rotator math that if its less or equal 180 degree turn 0, from 180-270 and 270-360 turn out curve value that is from 0 to 1 and again to 0

Ok I figured it out, I used wrong clock - I cant use Event tick - this type need proper clock and then pick value from that is easy.

To describe problem for others looking answer: Create Material Parameter Collection, Create scalar, Create curve, Make clock from below, Make curve variable, Connect it to Get Float Value, Connect time from before subtraction and you have pretty good working 0-1 mask in material.

Thanks Galagast for help!
Link to guy who made proper clock that solve all problems: Multiplayer Day Night Cycle Tutorial in Unreal Engine 4 - YouTube

nice! glad you were able to find a resolution :slight_smile: