Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Overlay Opaque shader

Discussion in 'Shaders' started by Frostbite23, Aug 31, 2013.

  1. Frostbite23

    Frostbite23

    Joined:
    Mar 8, 2013
    Posts:
    458
    Hello. im wanting a shader that is an opaque object and overlays all of the objects in the scene.
    what do i need to add in my shader. (i know i have to change the render type but is that it or i have to do more

    Code (csharp):
    1. Shader "Custom/Axis" {
    2.     Properties {
    3.       _MainTex ("Texture", 2D) = "white" {}
    4.       _ColorTint ("Tint", Color) = (1.0, 0.6, 0.6, 1.0)
    5.     }
    6.     SubShader {
    7.       Tags { "RenderType" = "Opaque" }
    8.       CGPROGRAM
    9.       #pragma surface surf Lambert finalcolor:mycolor
    10.       struct Input {
    11.           float2 uv_MainTex;
    12.       };
    13.       fixed4 _ColorTint;
    14.       void mycolor (Input IN, SurfaceOutput o, inout fixed4 color)
    15.       {
    16.           color *= _ColorTint;
    17.       }
    18.       sampler2D _MainTex;
    19.       void surf (Input IN, inout SurfaceOutput o) {
    20.            o.Albedo = tex2D (_MainTex, IN.uv_MainTex).rgb;
    21.       }
    22.       ENDCG
    23.     }
    24.     Fallback "Diffuse"
    25.   }
    any help would be appreciated
     
  2. Frostbite23

    Frostbite23

    Joined:
    Mar 8, 2013
    Posts:
    458
  3. gustavolsson

    gustavolsson

    Joined:
    Jan 14, 2011
    Posts:
    339
    I'm not sure if the following works with surface shaders, but you could try it.

    Render the shader last by placing in it in a later render queue:

    You might also want to disable the depth buffer so that the world does not intersect the object being rendered:

     
  4. Frostbite23

    Frostbite23

    Joined:
    Mar 8, 2013
    Posts:
    458