- Home /
How do I modify the self illum diffuse shader to not cull backfaces?
I'm really new to this an I'm trying to modify the self illumin shader so that it doesn't cull the backfaces of my geometry. Here is the code I tried modifying:
Shader "Self-Illumin/DiffuseBackface" {
Properties {
_Color ("Main Color", Color) = (1,1,1,1)
_MainTex ("Base (RGB) Gloss (A)", 2D) = "white" {}
_Illum ("Illumin (A)", 2D) = "white" {}
_EmissionLM ("Emission (Lightmapper)", Float) = 0
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 200
CGPROGRAM
#pragma surface surf Lambert
sampler2D _MainTex;
sampler2D _Illum;
fixed4 _Color;
struct Input {
float2 uv_MainTex;
float2 uv_Illum;
};
void surf (Input IN, inout SurfaceOutput o) {
fixed4 tex = tex2D(_MainTex, IN.uv_MainTex);
fixed4 c = tex * _Color;
o.Albedo = c.rgb;
o.Emission = c.rgb * tex2D(_Illum, IN.uv_Illum).a;
o.Alpha = c.a;
}
ENDCG
Pass {
Cull Off
}
}
FallBack "Self-Illumin/VertexLit"
}
Notice I added the Pass{Cull Off} I don't think that's right..
Comment
Best Answer
Answer by Piflik · May 15, 2012 at 04:20 PM
Cull off is essentially right, but at the wrong position. Try this:
Shader "Self-Illumin/DiffuseBackface" {
Properties {
_Color ("Main Color", Color) = (1,1,1,1)
_MainTex ("Base (RGB) Gloss (A)", 2D) = "white" {}
_Illum ("Illumin (A)", 2D) = "white" {}
_EmissionLM ("Emission (Lightmapper)", Float) = 0
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 200
Cull Off
CGPROGRAM
#pragma surface surf Lambert
sampler2D _MainTex;
sampler2D _Illum;
fixed4 _Color;
struct Input {
float2 uv_MainTex;
float2 uv_Illum;
};
void surf (Input IN, inout SurfaceOutput o) {
fixed4 tex = tex2D(_MainTex, IN.uv_MainTex);
fixed4 c = tex * _Color;
o.Albedo = c.rgb;
o.Emission = c.rgb * tex2D(_Illum, IN.uv_Illum).a;
o.Alpha = c.a;
}
ENDCG
}
FallBack "Self-Illumin/VertexLit"
}
Oh.. Thanks! That works great! Sorry for the noob question..
Your answer
Follow this Question
Related Questions
Illuminate specific parts of a texture? 1 Answer
How to render projector in front of walls but behind player? 1 Answer
Transparent Shader Render Order Issue 0 Answers
Problem with flipping ! 0 Answers
Transparent Diffuse issues 1 Answer