Download

Need Material Help - Blending between 4 textures (Seasons)

Working on my auto landscape material. I have a material parameter collection containing a scalar for the current season. 0 is spring, .25 is summer, .5 is fall, .75 is winter and 1 is back to spring.

I am having a heck of a time wrapping my head around how I might interpret this in the material editor. When the value is between 0 and .25, I need to lerp between spring and summer. When it’s between .25 and .5, I need to lerp between summer and fall. And so on.

In a normal blueprint I might make use of a select node but that doesn’t exist in the material editor … so I’m not certain how to approach this. Any thoughts?

Do they have to blend gradually from one to another?

In either case, try using an IF node.

Not the best way to do this I’m sure, but a very straightforward way is to use a lookup texture to define the seasons given your 0-1 float. Unreal has a built in way to do this using color curves, basically you create a linear color curve, then you create a color atlas and fill it with your curves and you sample from the atlas/curve from within your material.

Essentially each of the RGBA channels would represent a season and you would feed their respective channel outputs into a series of lerps.

Since it is essentially a layer stack you probably wouldn’t want to cross fade them at the same time like I’ve done above. The alpha channel also isn’t really necessary, but I didn’t think of these when I was making the curve and I’m too lazy to address it. You’ll understand when you go to implement it if it isn’t obvious already.

If you want to save a (very) small amount of memory you could generate the curves in an external program and then save them out as a single grayscale LUT with each of them stacked on each other (rather than in individual color channels). This requires a little additional setup though as you’ll have to write your own function to sample from the LUT (not that difficult, UV.x represents time and UV.y would represent the atlas)

Hmm Ok I’ll take a peek at this, thanks!

Looks handy … but what is this node called?

Success with the if node! Here’s what I got

Season is a value between 0 and 1. Spring is 0, Summer is .25.
The top If node compares the value of Season to .125, since it’s the halfway point between spring and summer. I set the equals threshold to .125 as well so it will look to .125 on either side of .125, giving a total season length of .25. So when A==B, it is transitioning between Spring and Summer (0 to .25). I multiply the Season by 4 for my lerp alpha and lerp between red and green (placeholders for my “Spring” and “Summer” textures). There should never be a scenario where A < B here, it would require “Season” to be less than 0 which shouldn’t be possible. However, if this pin is left empty, the material will not compile. If A > B, that means Season is greater than .25 so it needs to lerp between “Summer” and “Fall”.

The process is almost identical all the way down, the only difference is I had to subtract intervals of .25 from my season value before multiplying by 4 so that I always had between 0 and 1 for my lerp alpha.