So… I have a shader that reacts to light in a non-additive way, and since passes in forward rendering are additively blended with each other, I have to find a way to only render the shader once (in forward mode). I can make it compile a black version of the shader for any passes but base, which works, but that seems like a waste of resources.
On top of that, afaik I should expect 1 directional light, and up to 4 lights rendered as vertex lights in that pass, right?
But it also seems that a point light works. THere is no attenuation though. What options do I have here?
It took 3 shaders and alot of reading before I realised these limitations to the rendering pipeline, so I would just like to know my options, and what I’m forgetting or missing here.
I either get only directional light support, no point, or I get the problem with I have no way of including more lights (even vertex ones, oh, and my frag shader just got commented out )
Right now it works fine with 1 light, point or directional, and that’s it, no shadows either it seems.
Shader "Custom/LineTest3" {
Properties {
_MainTex ("Texture", 2D) = "white" { }
_Color ("Main Color", Color) = (0,0,0,0)
_LineTex ("Line (RGB)", 2D) = "white" { }
_EdgeSoftness ("Softness of shaded edge", Range (0.1, 0.5)) = 0.1
_WrapAround ("Warp Lighting around Object", Range(0.5, 1.0)) = 1.0
}
SubShader {
Tags {"RenderType"="Opaque"}
LOD 200
CGPROGRAM
#pragma surface surf Sharpline
#include "UnityCG.cginc"
sampler2D _MainTex;
sampler2D _LineTex;
half _EdgeSoftness;
float _WrapAround;
float _Color;
float LineValue;
struct Input {
float2 uv_MainTex;
float2 uv_LineTex;
};
half4 LightingSharpline (SurfaceOutput s, half3 lightDir, half atten) {
half4 c;
c.rgba = 0;
#ifndef UNITY_PASS_FORWARDADD
float NdotL = dot(s.Normal, lightDir);
NdotL = NdotL * _WrapAround + (1 - _WrapAround);
c.rgb = (1 - saturate((LineValue - (NdotL * atten)) / _EdgeSoftness)) * s.Albedo;
c.a = 1;
#endif
return c;
}
void surf (Input IN, inout SurfaceOutput o) {
o.Albedo = tex2D(_MainTex, IN.uv_MainTex);
LineValue = tex2D(_LineTex, IN.uv_LineTex);
}
ENDCG
}
}