Page 1 of 1

Simple Transparency Shader

PostPosted: Thu Feb 22, 2018 6:27 pm
by rxmarcus
I'm trying to wrap my head around how to do a shader that supports standard transparency in portions of a texture.

For example, I have a plain white square with transparency in the center, but I can't get it to render correctly with the center being transparent.

Image

At the moment I just have an Sampler2D texture connected to Albedo and I have the shaders Render Type set to Transparent and Render Queue to Geometry.

What else do I need to do?
Thank you

Re: Simple Transparency Shader

PostPosted: Thu Feb 22, 2018 8:56 pm
by Ricardo Teixeira
Hello,

We would be happy to help!

Is the Alpha channel connected to the opacity input?

Thanks!

Re: Simple Transparency Shader

PostPosted: Thu Feb 22, 2018 9:36 pm
by rxmarcus
Ah, thank you. I had tried connecting the Alpha channel to the Opacity input previously but it still wasn't working. After your guidance I kept that connected and discovered that I needed to have Blend RGB set to Alpha Blend. Now all is well.

Thank You!

Re: Simple Transparency Shader

PostPosted: Thu Feb 22, 2018 9:48 pm
by rxmarcus
Actually, one more question. In my Editor view, it shows transparent like it should.

But when I'm in the game view seeing what the game camera see's, my transparency is black?!

Image

Re: Simple Transparency Shader

PostPosted: Fri Feb 23, 2018 10:27 am
by Amplify_Borba
Hello, could you test using Transparent as the Blend Mode, in order to use its default settings, and report back if the issue is still present? I've attached a screenshot below as reference.

BlendMode.Jpg.jpg
BlendMode.Jpg.jpg (44.69 KiB) Viewed 10756 times


You may also check out Unity's documentation regarding Blending, it has plenty of useful information regarding this feature.

Please let me know if you have any further questions, thanks!

Re: Simple Transparency Shader

PostPosted: Fri Feb 23, 2018 8:32 pm
by rxmarcus
Changing the blend mode to Transparent does make it appear transparent rather than black, but then the Render queue is wacky because I want it to use a render queue of Geometry. If I have a 3d model that I use this shader on, then the models appendages render out of order and it looks wrong... :/

Re: Simple Transparency Shader

PostPosted: Sat Feb 24, 2018 2:48 pm
by Ricardo Teixeira
rxmarcus wrote:Changing the blend mode to Transparent does make it appear transparent rather than black, but then the Render queue is wacky because I want it to use a render queue of Geometry. If I have a 3d model that I use this shader on, then the models appendages render out of order and it looks wrong... :/


Hello,

Can you share a sample for further examination?

Thanks!