Search Unity

Vertex Color with fade effect

Discussion in 'Shaders' started by DJ_JW, Apr 26, 2015.

  1. DJ_JW

    DJ_JW

    Joined:
    Apr 26, 2015
    Posts:
    24
    Hi Guys

    I am not sure if this is even possible, but is there a way to use a pure Vertex Color shader but have the ability to "Fade" the object (or change its transparency). I can't find a way to have the alpha set to say 0.5 to have the object semi transparent.

    Please note I have no shader development skill and have tried merging lots of different solutions on the forum with this but cannot get it to work. Either the object completely disappears or it just doesn't change.

    Thanks in advance for any help :)

    The shader I am using for my vertex colour shader is the one from codeanimo website (This seems to work great for what I want but just no alpha capability)

    Code (CSharp):
    1.     Properties{
    2.         _MainTex("Base (Lightmapping Only)", 2D) = "white" {}// If this doesn't exist, Beast Lightmapper will complain
    3.     }
    4.  
    5.     SubShader{
    6.         LOD 100
    7.         Pass {
    8.             Tags { "LightMode" = "Vertex" }
    9.            
    10.             ColorMaterial AmbientAndDiffuse
    11.             Lighting On
    12.             SeparateSpecular On
    13.            
    14.             SetTexture [_MainTex] {
    15.                 combine primary + primary DOUBLE
    16.             }
    17.         }
    18.        
    19.         // Lightmapped, encoded as dLDR
    20.         Pass {
    21.             Tags { "LightMode" = "VertexLM" }
    22.            
    23.             BindChannels {
    24.                 Bind "Vertex", vertex
    25.                 Bind "normal", normal
    26.                 Bind "texcoord1", texcoord0 // lightmap uses 2nd uv
    27.                 Bind "texcoord", texcoord1 // main uses 1st uv
    28.             }
    29.            
    30.             SetTexture [unity_Lightmap] {
    31.                 matrix [unity_LightmapMatrix]
    32.                 combine texture
    33.             }
    34.             SetTexture [_MainTex] {
    35.                 combine primary + previous DOUBLE, primary
    36.             }
    37.         }
    38.        
    39.         // Lightmapped, encoded as RGBM
    40.         Pass {
    41.             Tags { "LightMode" = "VertexLMRGBM" }
    42.            
    43.             BindChannels {
    44.                 Bind "Vertex", vertex
    45.                 Bind "normal", normal
    46.                 Bind "texcoord1", texcoord0 // lightmap uses 2nd uv
    47.                 Bind "texcoord1", texcoord1 // unused
    48.                 Bind "texcoord", texcoord2 // main uses 1st uv
    49.             }
    50.            
    51.             SetTexture [unity_Lightmap] {
    52.                 matrix [unity_LightmapMatrix]
    53.                 combine texture * texture alpha DOUBLE
    54.             }
    55.             SetTexture [_MainTex] {
    56.                 combine previous QUAD, primary
    57.             }
    58.         }
    59.        
    60.     }
     
  2. Zicandar

    Zicandar

    Joined:
    Feb 10, 2014
    Posts:
    388