Search Unity

Transparent, Baked Vertex Lit, Double sided shader request

Discussion in 'Shaders' started by gabaghoul, Mar 2, 2009.

  1. gabaghoul

    gabaghoul

    Joined:
    Oct 18, 2008
    Posts:
    8
    Anyone know how to go about combining these 2 shaders below to get a transparent, baked vertex lit, 2 sided object. I would really appreciate it.


    This one does Double Sided Soft Alpha Transparency:

    Shader "Vegetation" {
    Properties {
    _Color ("Main Color", Color) = (.5, .5, .5, .5)
    _MainTex ("Base (RGB) Alpha (A)", 2D) = "white" {}
    _Cutoff ("Base Alpha cutoff", Range (0,.9)) = .5
    }
    SubShader {
    // Set up basic lighting
    Material {
    Diffuse [_Color]
    Ambient [_Color]
    }
    Lighting On

    // Render both front and back facing polygons.
    Cull Off

    // first pass:
    // render any pixels that are more than [_Cutoff] opaque
    Pass {
    AlphaTest Greater [_Cutoff]
    SetTexture [_MainTex] {
    combine texture * primary, texture
    }
    }

    // Second pass:
    // render in the semitransparent details.
    Pass {
    // Dont write to the depth buffer
    ZWrite off
    // Don't write pixels we have already written.
    ZTest Less
    // Only render pixels less or equal to the value
    AlphaTest LEqual [_Cutoff]

    // Set up alpha blending
    Blend SrcAlpha OneMinusSrcAlpha

    SetTexture [_MainTex] {
    combine texture * primary, texture
    }
    }
    }
    }



    And this one does Baked Vertex Lighting:

    Shader "Baked Vertex Lighting/Vertex Lit" {
    Properties {
    _Color ("Main Color", Color) = (1,1,1,1)
    _SpecColor ("Spec Color", Color) = (1,1,1,1)
    _Emission ("Emmisive Color", Color) = (0,0,0,0)
    _Shininess ("Shininess", Range (0.01, 1)) = 0.7
    _MainTex ("Base (RGB)", 2D) = "white" { }
    }

    SubShader {
    Pass {
    Material {
    Diffuse [_Color]
    Ambient [_Color]
    Shininess [_Shininess]
    Specular [_SpecColor]
    Emission [_Emission]
    }
    Lighting Off
    Cull Off
    SeperateSpecular On
    SetTexture [_MainTex] {
    constantColor [_Color]
    Combine texture * primary DOUBLE, texture * constant
    }
    }

    Pass {
    Blend One One
    Lighting Off
    Cull Off

    BindChannels {
    Bind "Vertex", vertex
    Bind "TexCoord", texcoord
    Bind "Color", color
    }

    SetTexture [_MainTex] {
    Combine primary * texture
    }
    SetTexture [_MainTex] {
    constantColor [_Color]
    Combine previous * constant
    }
    }
    }
    }
     
  2. llavigne

    llavigne

    Joined:
    Dec 27, 2007
    Posts:
    977
    I have something that almost works, it needs double sided lighting (where only the normal orientation is taken into account)

    don't ask me how this works, no idea where this thing gets its baked vertex color from I did it by trial and error...

    Code (csharp):
    1.  
    2. Shader "Baked Vertex Lighting/Baked Vertex Cutout No Culling 2"
    3. {
    4.     Properties {
    5.         _Color ("Main Color", Color) = (1,1,1,1)
    6.         _SpecColor ("Spec Color", Color) = (1,1,1,1)
    7.         _Emission ("Emmisive Color", Color) = (0,0,0,0)
    8.         _Shininess ("Shininess", Range (0.01, 1)) = 0.7
    9.         _MainTex ("Base (RGB)", 2D) = "white" {}
    10.         _Cutoff ("Base Alpha cutoff", Range (.5,.9)) = .5
    11.  
    12.     }
    13.      
    14.     SubShader {
    15.         Pass
    16.         {
    17.             AlphaTest GEqual [_Cutoff]
    18.  
    19.             Cull off
    20.            
    21.             Material {
    22.                 Shininess [_Shininess]
    23.                 Specular [_SpecColor]
    24.                 Emission [_Emission]    
    25.             }
    26.             ColorMaterial AmbientAndDiffuse
    27.             Lighting On
    28.             SeperateSpecular On
    29.             SetTexture [_MainTex] {
    30.               Combine texture * primary, texture * primary
    31.       //          Combine texture , texture
    32.    
    33.             }
    34.             SetTexture [_MainTex] {
    35.                 constantColor [_Color]
    36.                 Combine previous * constant DOUBLE, previous * constant
    37.             }
    38.         }
    39.         // Pixel lights
    40.       //  UsePass "Bumped Specular/PPL"
    41.     }
    42. }
    43.  
     
    sathinediganesh2093 likes this.
  3. anilcan123

    anilcan123

    Joined:
    Oct 14, 2019
    Posts:
    4
    thank you so much man after 12 years
     
    jacoblaerdal likes this.
  4. Selzier

    Selzier

    Joined:
    Sep 23, 2014
    Posts:
    652
    How could you get this to render shadows?