I have material, that takes camera under my map and make it appear on material, so is there a way to make for example black and replace it with any other color? I need to make minimap, but i need to make all other color exept red to be invisible.
Use a LERP:
when the alpha-input is 0 it will be just the A input, when the alpha-input is 1, it will be the B input, weighted in between. eg: alpha of 0.5 will be 50/50. You can use values outside of 0 → 1 if you want and the appropriate input will be scaled (multiplied) appropriately. eg: if I scale the checker-pattern by 3:
0 (black) is still 0 and 1 becomes 3 which mucks up the texture.
This is one of the cheapest ops, use this vs IF if you can help it.
Yeah, i see, but how can i replace only black color to be invisible? Is there a way do do such a thing? Or can i just somehow make that on my level “void” below my level would be just invisible insted of black?
Ah! So what you seemingly want more is maths to make a hard-edge?
The IF node can certainly work there, and it’s not ‘bad’ to use it, just that b/c both paths are evaluated, people tend to use it thinking ‘oh, that pixel will be black so the other path never fires’; no. You still have to account for the cost of either path b/c pixel-to-pixel you won’t really know if it will always be black.
LERP, you tend to use as a weighted-blend, so it’s implicit that both paths need be evaluated anyways. 6 of one, half-a-dozen of the other, but with a subtle nuance.
What you really want is to know how to make a hard-mask.
IF is actually useful here, as well as Step:
The multiply-by-1 is just to show the gradient; 0 on the left progressing to 1 as we move right.
The IF cuts the alpha at 0.5 and blends only one or the other based on that pivot-value.
The way you read step is ‘if X is greater-than-or-equal-to Y, return 1, else return 0’. In this case it cuts the gradient at 0.25. I find Step tends to pack better overall, that in more complex materials, you tend to save instructions vs other methods.
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.