- Home /
Gradient transparency results in full opacity for half of the gradient
So, when I set a perfect opacity gradient from 255 to 0, Unity renders the gradient as half complete opacity, then picks up proper opacity at 128 down to zero. Looks extremely smooth from that point in fact. Here's what it looks like, and my settings for the texture are on the right:
I'm using the "Transparent/Cut Out/ Soft Edge Unlit" as my shader on the plane. I need unlit because my scene doesn't have lights. I can avoid the complete opacity by starting my gradient at 128 and going down to 0, but then I don't get any full opacity range. It starts out as half transparent and goes to full transparency. Here's the PNG I'm using (I tried PSD and TGA as well):
Can anyone help me out? Am I doing something dumb? Is there any way to get a full range of transparency from completely opaque to invisible? Thanks!
Answer by Eric5h5 · Jun 08, 2013 at 12:32 AM
Transparent/cutout means either transparent or not. If you want a range of transparency, don't use cutout shaders. That particular shader has some extra stuff for soft edges in addition to cutout, hence the behavior you see, but the important thing is not to use any sort of cutout shader for this. By the way, you only need 2 pixels for that texture--100% solid green for one pixel and 100% transparent for the other--since bilinear filtering will take care of the gradient.
That did the trick! Thank you. I chose cutout because someone told me I had to when I was seeing that the green had a gradient to white as well as transparent with the other shaders, but I fixed that issue by taking off the transparency mask on the green layer in photoshop.