Half Lambert / Wrap Diffuse Shader
Hello! I am a complete noob when it comes to shaders. The problem is, you NEED to have shaders in order to make your game look good. I did a ton of research about the kind of shaders I would want in my game, and then shader that I think would fit the best for me is a 'wrapped diffuse' or 'half lambert' shader. I wanted to go for the Super Smash Bros 4 look and feel. I can't seem to find very much documentation at all about these shaders, and considering I don't know anything about writing in ShaderLab, this is almost an impossible task for me. I have spent HOURS trying to figure it out, so I thought I would just direct myself to Unity Answers to solve my problem. The trouble I am having is that all the code online has serious problems. Even the Unity documentation about surface shaders includes code for a 'wrap shader', but it's really messed up. The code snippet from that documentation looks really good, but only if you delete the 'Fallback' at the end, as it causes weird pixelation around the line that divides what is dark and what is lit. If I remove the 'fallback' line, it works, but for some reason the shadows from other objects with other shaders can be seen on top of the the object with the wrap shader applied. It's like it's transparent but only to shadows. The other problem is I have no idea how to program shadows into the shader. All I need to do is fix these three problems, and I should have a working shader. Can anyone write me a CORRECT 'wrap diffuse' shader that actually WORKS?? I would GREATLY appreciate it. I know I've written a book, but if anyone has an answer to this problem I wouldn't be able to thank you enough. Thanks. Here is the code I've been using that has these problems:
Shader "Shader Test" {
Properties {
_Color ("Main Color", Color) = (1,1,1,1)
_MainTex ("Base (RGB)", 2D) = "white" {}
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 200
CGPROGRAM
#pragma surface surf WrapLambert
half4 LightingWrapLambert (SurfaceOutput s, half3 lightDir, half atten) {
half NdotL = dot (s.Normal, lightDir);
half diff = NdotL * 0.5 + 0.5;
half4 c;
c.rgb = s.Albedo * _LightColor0.rgb * (diff * atten);
c.a = s.Alpha;
return c;
}
sampler2D _MainTex;
fixed4 _Color;
struct Input {
float2 uv_MainTex;
};
void surf (Input IN, inout SurfaceOutput o) {
fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
o.Albedo = c.rgb;
o.Alpha = c.a;
}
ENDCG
}
//Fallback "Legacy Shaders/VertexLit"
}
As you can see on the last line, I had to cancel out the 'Fallback' section as it really messed with the shader.