Search Unity

Adding cutout to a legacy shader

Discussion in 'Shaders' started by earrgames, May 25, 2016.

  1. earrgames

    earrgames

    Joined:
    Jan 27, 2014
    Posts:
    168
    Hi, I have no idea how simple is to achieve what I'm looking, I did some basic Legacy shaders (the ones with SetTexture), I don't know much about how turning them into fragment shaders so just wanted to know if I can do like the transparent cutout shaders with one of these? just adding the slider and "erasing" the ones that have transparency as I move the slider, my shader is just a dual texture one, one in each UV set, so I want to edit the second one, I mean apply the alpha cutout just to the second texture but have no clue how, this is the shader:

    Code (CSharp):
    1. Shader "Custom/Decal (2 UV sets)" {
    2. Properties {
    3.     _MainTex ("Base (RGB)", 2D) = "white" {}
    4.     _DecalTex ("Decal (RGBA)", 2D) = "white" {} //<---this is the second texture, which supports tranparency
    5. }
    6.  
    7. SubShader {
    8.     Tags { "RenderType"="Opaque" }
    9.     Material {
    10.         Diffuse [_Color]
    11.         Ambient [_Color]
    12.    
    13.     }
    14.     Pass {
    15.         BindChannels {
    16.             Bind "Vertex", vertex
    17.             Bind "normal", normal
    18.             Bind "texcoord", texcoord0 // main uses 1st uv
    19.             Bind "texcoord1", texcoord1 // decal uses 2nd uv
    20.         }
    21.         Lighting On
    22.         ColorMaterial AmbientAndDiffuse
    23.      
    24.         SetTexture [_MainTex] {combine texture}
    25.         SetTexture [_DecalTex] {combine texture lerp (texture) previous}
    26.         SetTexture [_MainTex] {combine previous * primary DOUBLE} //vertex colouring
    27.     }
    28. }
    29.  
    30. Fallback " VertexLit", 1
    31.  
    32. }
    Thanks a lot!