Material Attributes + If statements - How to switch material attribute based on world height?

I wish to give a snow material on everything above a property “SnowLimit”, and moss material on everything below it.

This is my current approach, a simple if statement:

  1. Is the input in the form of Material Attributes, if the world Z is above SnowLimit, it’s snow, if it’s below it’s Moss.

This if statement approach results in no errors, but the material simply becomes “unrendered” (?), as if the if statement doesn’t return anything:
This is what it looks like plugging the snow material directly into “NotCliff” at 4:

I tried using a HeightLerp, as seen on 5, but this requires a texture or vec3 as input, so it doesn’t work “off the bat”. I could reorganize a bit to make the HeightLerp work but I prefer not to since I only need the simple if logic as I’ve implemented.

Why doesn’t it work? Am I thinking too “programatically” about how materials/shaders work?

1 Like

Why not use a standard lerp?

Even if you did get this working, it would look very strange, as the snow would just start suddenly at height X.

I did eventually did this, which seems to have one material below 0 z, and another above it:

and as ClockworkOcean said, it looks quite weird:

I don’t know how to, i tried this:

with… uhm… strange results:

Could you please elaborate?

1 Like

A basic example

In the instance


So in fact, you would pipe this calculation into the material attributes node.

1 Like

Ahh, what a beauty!

I copied it and ended up with this:
HeightBlend collapse as this:

And this is the end result:

Thanks for the help!

1 Like

Looks FAB! :smiley:

1 Like

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