I'm writing a custom shader for the transparent object with built-in pipeline of Unity2022.3.9f1.
For Subshader the Tags set like below
Tags { "LightMode"="ForwardBase" "Queue"="Transparent" "RenderType"="Transparent" "IgnoreProjector" = "True"}
For base pass everything is ok and the Tags look like below
Tags { "LightMode"="ForwardBase"}
Blend SrcAlpha OneMinusSrcAlpha
ZWrite Off
And for additive pass, I set them like below
Tags { "LightMode"="ForwardAdd"}
Blend SrcAlpha One // Or Blend One One
ZWrite Off
Now when a point light is on, the blending is wrong no matter Blend SrcAlpha One
or Blend One One
. The result looks like below
I'm confused what happened and how should I fix this?
PS. I'm using Blinn Phong to illuminate everything and the code is
//Lighting
UNITY_LIGHT_ATTENUATION(atten, i, i.positionWS);
float3 worldLightDir = normalize(UnityWorldSpaceLightDir(i.positionWS));
float3 ambient = UNITY_LIGHTMODEL_AMBIENT.xyz;
float3 diffuse = _LightColor0.rgb * _Diffuse.rgb * max(0, dot(normalWS, worldLightDir));
float3 halfDir = normalize(worldLightDir + viewDir);
float3 specular = _LightColor0.rgb * _Specular.rgb * pow(max(0, dot(normalWS, halfDir)), _Gloss);
float3 lighting = ambient + (diffuse + specular) * atten;