Search Unity

How to recreate Unity Transparent Render Type to see text through opaque objects

Discussion in 'Shaders' started by Rekavik, Mar 10, 2017.

  1. Rekavik

    Rekavik

    Joined:
    Oct 8, 2016
    Posts:
    1
    Up until yesterday I have been using the Unity Standard Shader to make some spheres transparent so that 3D text inside the sphere can be read. Using the render type "Transparent" in the Unity Shader the spheres still appear to be opaque and I am still seeing the right faces of the object, and the text is still able to be seen through the sphere.

    I have created a new shader in Shader Forge so that I can use the Opacity Clip/Alpha Clip feature to make a cutout animation. But I cannot reproduce this transparency behavior in my new Shader. I dont want the text to draw through everything in the world (which would be the case if I used "ZTest Always"), I just want it to be seen through the sphere that it is in.

    I have attached a picture for reference. Any advice would be SUPER helpful as I have been trying to find a solution for this problem for quite some time. If Shader Forge is not a viable solution I can also give/accept the shader code. Thank you so much!

    upload_2017-3-10_16-10-50.png
    Red sphere using ShaderForge shader, blue sphere using Unity Standard Shader. Text draws through the sphere but not the other objects in the scene.
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,348
    Alpha clip writes to depth, usually transparent shaders (alpha blend, additive, etc.) do not. If your font shader isn't using ZTest Always and is appearing "inside" transparent objects this is either because its render queue is after that object, or you're just getting lucky that Unity's sorting is causing it to draw afterward.

    I would suggest you use the frame debugger to step through rendering to see how things are working now.

    I would also suggest not using transparent shaders for the spheres, and instead look at using a camera "push" shader for rendering the font. Basically a shader that'll move the polygons of the text closer to the camera so it won't get occluded by the solid spheres.