Search Unity

Shader: please help me add transparency to this shader.

Discussion in 'Shaders' started by Infinit777, Apr 9, 2017.

  1. Infinit777

    Infinit777

    Joined:
    Dec 9, 2014
    Posts:
    15
    I got this shader by following a tutorial, and I can't for the life of me figure out how to add transparency. I am new to shaders and don't understand anything.yet. (heres the tutorial)

    Code (CSharp):
    1. Shader "Custom/Stencil/Diffuse EqualOne"
    2. {
    3.  
    4. Properties
    5. {
    6.     _Color ("Main Color", Color) = (1,1,1,1)
    7.     _MainTex ("Base (RGB)", 2D) = "white" {}
    8. }
    9.  
    10. SubShader
    11. {
    12.     Tags { "RenderType"="Opaque" "Queue"="Geometry" }
    13.     LOD 200
    14.  
    15.     Stencil
    16.     {
    17.         Ref 1
    18.         Comp equal
    19.         Pass keep
    20.     }
    21.  
    22.     CGPROGRAM
    23.     #pragma surface surf Lambert
    24.  
    25.     sampler2D _MainTex;
    26.     fixed4 _Color;
    27.  
    28.     struct Input
    29.     {
    30.         float2 uv_MainTex;
    31.     };
    32.  
    33.     void surf (Input IN, inout SurfaceOutput o)
    34.     {
    35.         fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
    36.         o.Albedo = c.rgb;
    37.         o.Alpha = c.a;
    38.     }
    39.    
    40.     ENDCG
    41. }
    42.  
    43. Fallback "VertexLit"
    44. }
    45.  
     
  2. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,610
    Infinit777 likes this.
  3. Infinit777

    Infinit777

    Joined:
    Dec 9, 2014
    Posts:
    15
    Thank you very much. I will read through all this when i get home from work today.
     
  4. Infinit777

    Infinit777

    Joined:
    Dec 9, 2014
    Posts:
    15
    Got it working, Thank you very much!
     
    Peter77 likes this.