I'm trying to create a shader that will blend two materials together with the top material being blended based on a simple world rotation mask so that if I rotate my mesh the blended material will always appear on top no matter the orientation. I've created the mask but have no idea how to use it as an opacity / alpha mask for the texture maps that I want to use. In function this is a moss generator, so I want to be able to give the moss an albedo, normal, and packed map. I just don't understand how to translate this simple 0-1 mask into an alpha channel for my textures. It seems really simple but for the life of me I can't figure it out. I'm still new to this whole thing, I guess.
The mask I created using the rock's normal details.
The function I made for generating the mask.
Any help would be greatly appreciated.
Replies
Just plug the output of your function into the alpha input on a blend node. You could use a Linear Interpolate or one of the material blend nodes like MatLayerBlendSimple if you want to blend a whole material at once.
I've tried this but it doesn't work.
Your mask function looks different to the first picture. I think the problem is that the masking setup you have is outputting 3 outputs (RGB) instead of a single value.
Some suggestions.
use the r output from your mask texture sample. Not the RGB output.
You could add a component mask between the multiply and the matlayerblend with only the r channel turned on.
I think the error at the "Pixel Normal WS" node is due to the input being the vector/normal of the pixel, which is then used to blend with a normal map which changes the input of the node. So probably this node can't be used with blends involving normal maps?
Could blend by vertex normal (modified + height mask?) instead. Or transform the tangent space normal map of your base layer to world space and mask the desired channel - I would check the cost if it's worth it.
hey @coolguyslims
Do you know that there is already a node in Unreal that does a world aligned blend for you? It's called "worldAlignedBlend"
It looks like this:
And the neat thing is that this node is just a connection of other nodes. So if you want to see how it works you can double click on it and see inside it.
For example if you have a look inside there's this section that shows you how to do a blend that's compatible with normalMaps
@sprunghunt
Yep, I got it working a couple days ago and that's how I did it!
I was making it more complicated than it needed to be.
The auto-masking is really cool. I'm going to try out your old suggestions regardless about using just one channel instead of RGB or use a component mask. Just for future reference.
Thanks for the help! 😊