Hi there!
I have been searching the forums for ages, and even though there have been people with similar issues, I haven’t been able to achieve the particular effect I am looking for.
The thing that I want to create, is a point light that has no falloff and no “NdotL”. And by “no NdotL” I mean even if the light hits a surface from an angle, the surface should be equally lit. Unless the angle between the surface normal and the light direction is over 90°, in which case I want the surface to turn completely unlit. By tweaking the custom lighting model example for surface shaders in the Unity Documentation, I have actually been able to come up with pretty much the desired effect:
Shader "surfaceNoFalloff" {
Properties {
_MainTex ("Texture", 2D) = "white" {}
}
SubShader {
Tags { "RenderType" = "Opaque"}
CGPROGRAM
#pragma surface surf SimpleLambert
half4 LightingSimpleLambert_PrePass (SurfaceOutput s, half3 lightDir, half atten){
half NdotL = dot (s.Normal, lightDir);
NdotL = 100*max(0.0,NdotL);
NdotL = saturate(NdotL);
half4 c;
c.rgb = s.Albedo * _LightColor0.rgb * (NdotL* 1);
c.a = s.Alpha;
return c;
}
struct Input {
float2 uv_MainTex;
};
sampler2D _MainTex;
void surf (Input IN, inout SurfaceOutput o) {
o.Albedo = tex2D (_MainTex, IN.uv_MainTex).rgb;
}
ENDCG
}
Fallback "VertexLit"
}
The problem is though, that I can’t get realtime-shadows working with my point light, as soon as I use my custom lighting model. I think it might have something to do with my lighting model being in the forward rendering path by default, but I am not sure? Plus, I don’t know how or if it is even possible to write such a specific lighting model in the deffered lighting pass.
Do any of you know how to add real time shadows to my script, or know any other way by which I would be able to achieve the desired effect? Any help would be much appreciated