Search code examples
imageunity-game-enginepngshadertransparency

How can I have a png image with transparency, visible only from *front*?


I'm using a prefab for a box shape, which has a front and back plane.

My images are PNG and have transparent areas around the edge. I dragged the image onto my front plane, which now has a drop-down box for "Shader".

First I chose Shader: "Standard" but the transparent areas of my PNG image weren't transparent, so in order to fix that I changed it to "Sprites / Diffuse"... now the image looks fine (from the front).

However, when I rotate the shape, the image is also visible from the back. I want a way to not see the image / texture from the back.

How can I make the images only visible from the front side of a plane, whilst also preserving the transparency areas of the image / texture?


Solution

  • If you are using the standard built-in shader, you need to set the rendering mode to transparent in order for the texture's alpha channel to be transparent. The sprite shader, by default, forces the rendering of otherwise invisible back-faces, whereas the standard shader does not.

    inspector dropdown