Normal extrusion with front culling

Hi, I'm trying to combine the normal extrusion shader from the surface shader examples with a front face culling shader that only displays one solide color (no lambert, no UV texture) Basically combining normal extrusion:

alt text

with the backface shader:

Shader "BackFace" { 
Properties {       
    _Color ("Backface Color", Color) = (.1,.2,.5,0.5)   
}

Category {
    ZWrite Off
    Lighting Off
    Tags {Queue=Transparent}
    Blend SrcAlpha One
    Color [_Color]
    SubShader {
        Pass {
            Cull Front
        }
    }
} }

Here is what I have so far but I can't seem to combine both without removing the lambert part that generates shading. Any help is appreciated:

Shader "Example/Normal Extrusion" {
Properties {

// color is part of the backface shader

    _Color ("Backface Color", Color) = (.1,.2,.5,0.5)  
    _MainTex ("Texture", 2D) = "white" {}
    _Amount ("Extrusion Amount", Range(0,0.1)) = 0.05

}
SubShader {
  Tags { "RenderType" = "Opaque" }

// backface shader part

ZWrite Off
Lighting Off
Tags {Queue=Transparent}
Blend SrcAlpha One
Color [_Color]
Pass {
    Cull Front
}

// normal extrusion part

  CGPROGRAM
  #pragma surface surf Lambert vertex:vert

  struct Input {
      float2 uv_MainTex;
  };

  float _Amount;
  void vert (inout appdata_full v) {
      v.vertex.xyz += v.normal * _Amount;
  }

    sampler2D _MainTex;
    void surf (Input IN, inout SurfaceOutput o) {
      o.Albedo = tex2D (_MainTex, IN.uv_MainTex).rgb;
  }

  ENDCG

} 
Fallback "Diffuse"} 

1 Answer

1

Nevermind I did. Just ran the input color in the emissive value. Also fixed the Input structure accordingly in the CG code. here is what my code looks like if anybody cares!

Shader "Example/Normal Extrusion" {
Properties {

// color is part of the backface shader

    _Color ("Backface Color", Color) = (.1,.2,.5,0.5)  
    _Amount ("Extrusion Amount", Range(0,0.1)) = 0.05

}
SubShader {
  Tags { "RenderType" = "Opaque" }

// backface shader part

ZWrite Off
Lighting Off
Tags {Queue=Transparent}
Blend Off

// this pass renders the inside faces

Pass {
    Cull Front
}

// normal extrusion part

    CGPROGRAM
    #pragma surface surf Lambert vertex:vert

    float4 _Color;
    float _Amount;

    struct Input {
      float4 color : COLOR;
    };

    void vert (inout appdata_full v) {
      v.vertex.xyz += v.normal * _Amount;
    }

    void surf (Input IN, inout SurfaceOutput o) {
        o.Emission = _Color;
    }

  ENDCG

} 
Fallback "Diffuse"}