I am working on a Grid shader and it’s going pretty well (my first shader, thanks shader graph!). However I want the end result of the grid to be slightly transparent on top of a texture. I’m having problems achieving this…
In the attached screenshot the result of the grid is in the bottom. Rectangle > One Minus > Multiply. But no matter what other transparent Color I put into Multiply, I seem to be unable to get a transparent result. Here the Color parameter is a near invisible pink, but it comes out as fully opaque.
Just to be clear, is the magenta color coming from your selected color or is that the error color?
The alpha channel doesn’t generally come into play for most of the Shader Graph previews the way you’d expect. It’s performing RR, GG, BB, and AA separately, rather than (RGBA) * (RGBA) as you’re hoping. Think of the channels as being entirely separate. You could technically split the Color into RGBA floats, recombine the color into RGB without the alpha, and multiply against the color’s alpha value.
It’s usually better to treat transparency as a separate mask which you explicitly combine after your various layers are in place. To me, the main reason to use a separate alpha is that it’s often unused and I’ve gotten used to ignoring it as a result. Most color swatches that I come across are tints with separate floats to control visibility. An added bonus is that you can multiply above 1 to get more extreme values whereas a color picker only goes to 1.0 alpha.
In this case, I’d recommend using a Lerp node instead of Add to get the best options for your colors. Additive will only let you choose colors that are brighter than that green texture you’ve started with. Instead of using the alpha from your color input, make a separate float called Transparency, set it to a 0-1 slider, and multiply it against the grid before the Lerp. The Lerp will blend between the base color (your texture) and your secondary color using the black/white values output by your grid. The extra multiplier will make everything approach black so that when the float is zero, the grid is invisible.