Unity Shader Graph - Trying to create a shader to add a drop shadow to a sprite

The approach i’m trying is having a game object (sprite) with another game object behind it (no sprite, shader using that texture, but just for the alpha).

For the game object using this shader, the one i’m trying to make into a drop shadow, im using the “multiply” blend mode. The part that i’m stuck on is if it’s possible to control the transparency of the alpha mask? And if so how do i do it?

The attached images are the baseline setup and the use case

Unless I’m missing something about your question, you should be able to control the transparency of the shadow by multiplying this value you’re setting in the Fragment’s Alpha input by a scalar between 0 and 1.

image

I tried that, but sadly it only works when you have the blend mode set to “alpha”. If the blend mode is set to “multiply” it doesn’t. I’m assuming it’s because of this and or the alpha clip?

like this (Edit smarter more friendly version)

here’s the compensation / artist friendly version… theres no use for alpha on the master node as you can see

image

Multiply blend doesn’t process alpha in the blend operation(s)
DstColor Zero
or
Zero SrcColor

it won’t use alpha to do anything with those above operations
Your sprite needs to turn white = makes it go away

hence the OneMinus inversions to compensate for it to be logical to the color input

fademult3

2 Likes

thanks for the breakdown, i appreciate it. Is this approach to blending without alpha less expensive as well?

Not cheaper, as the blend mode is still standard architecture on the GPU

Source*(something) + Destination*(something)

Nothing about this changed/changes. A ‘Multiply’ blend mode preset just doesn’t use alpha, but that will not affect performance; It’s still a blend mode operation as above.

— It’s setup to use the Multiply preset that is standard in Shadergraph… (you’d have to write the .Shader file yourself to make blend modes different from those four default options)

for this to work intuitively for artists it needed the x2 Invert nodes, a computation increase; Though TBF , those two extra nodes are a negligible cost for an easy to use Multiply sprite.

1 Like

Thanks for the examples Torbach, I don’t usually work with multiply blending so I didn’t even know the alpha channel is ignored. I just checked and in UE4 the Opacity input is actually greyed out when selecting the “Modulate” blend mode.