Возникла проблема с исчезновением теней для худо-бедно склеенного шейдера. Хочу добиться плавного исчезновения, а не резкого обрывания. На рисунке ниже очень хорошо видно как работает отображение теней для custom shader и mobile/diffuse:
Возможно кто-то знает что необходимо добавить, чтобы получить подобный результат?
Текущий шейдер:
Синтаксис:
Используется glsl
Shader "Feelnside/Mobile Diffuse Colored"
{
SubShader
{
Pass
{
Tags {"LightMode"="ForwardBase"}
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
#include "Lighting.cginc"
// compile shader into multiple variants, with and without shadows
// (we don't care about any lightmaps yet, so skip these variants)
#pragma multi_compile_fwdbase nolightmap nodirlightmap nodynlightmap novertexlight
#pragma multi_compile_fog
// shadow helper functions and macros
#include "AutoLight.cginc"
struct v2f
{
SHADOW_COORDS(1) // put shadows data into TEXCOORD1
UNITY_FOG_COORDS(2)
fixed3 diff : COLOR0;
fixed3 color : TEXCOORD2;
fixed3 ambient : COLOR1;
fixed4 pos : SV_POSITION;
};
v2f vert (appdata_full v)
{
v2f o;
o.pos = UnityObjectToClipPos(v.vertex);
o.color = v.color;
fixed3 worldNormal = UnityObjectToWorldNormal(v.normal);
fixed nl = max(0, dot(worldNormal, _WorldSpaceLightPos0.xyz));
o.diff = nl * _LightColor0.rgb;
o.ambient = ShadeSH9(fixed4(worldNormal,1));
// compute shadows data
TRANSFER_SHADOW(o)
TRANSFER_VERTEX_TO_FRAGMENT(o);
UNITY_TRANSFER_FOG(o, o.pos);
return o;
}
fixed4 frag (v2f v) : COLOR
{
fixed4 col;
// compute shadow attenuation (1.0 = fully lit, 0.0 = fully shadowed)
fixed shadow = SHADOW_ATTENUATION(v);
// darken light's illumination with shadow, keep ambient intact
fixed3 lighting = v.diff * shadow + v.ambient;
col.rgb = lighting;
col.rgb *= v.color;
UNITY_APPLY_FOG(v.fogCoord, col);
return col;
}
ENDCG
}
// shadow casting support
UsePass "VertexLit/SHADOWCASTER"
}
//Fallback "Mobile/VertexLit"
}
{
SubShader
{
Pass
{
Tags {"LightMode"="ForwardBase"}
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
#include "Lighting.cginc"
// compile shader into multiple variants, with and without shadows
// (we don't care about any lightmaps yet, so skip these variants)
#pragma multi_compile_fwdbase nolightmap nodirlightmap nodynlightmap novertexlight
#pragma multi_compile_fog
// shadow helper functions and macros
#include "AutoLight.cginc"
struct v2f
{
SHADOW_COORDS(1) // put shadows data into TEXCOORD1
UNITY_FOG_COORDS(2)
fixed3 diff : COLOR0;
fixed3 color : TEXCOORD2;
fixed3 ambient : COLOR1;
fixed4 pos : SV_POSITION;
};
v2f vert (appdata_full v)
{
v2f o;
o.pos = UnityObjectToClipPos(v.vertex);
o.color = v.color;
fixed3 worldNormal = UnityObjectToWorldNormal(v.normal);
fixed nl = max(0, dot(worldNormal, _WorldSpaceLightPos0.xyz));
o.diff = nl * _LightColor0.rgb;
o.ambient = ShadeSH9(fixed4(worldNormal,1));
// compute shadows data
TRANSFER_SHADOW(o)
TRANSFER_VERTEX_TO_FRAGMENT(o);
UNITY_TRANSFER_FOG(o, o.pos);
return o;
}
fixed4 frag (v2f v) : COLOR
{
fixed4 col;
// compute shadow attenuation (1.0 = fully lit, 0.0 = fully shadowed)
fixed shadow = SHADOW_ATTENUATION(v);
// darken light's illumination with shadow, keep ambient intact
fixed3 lighting = v.diff * shadow + v.ambient;
col.rgb = lighting;
col.rgb *= v.color;
UNITY_APPLY_FOG(v.fogCoord, col);
return col;
}
ENDCG
}
// shadow casting support
UsePass "VertexLit/SHADOWCASTER"
}
//Fallback "Mobile/VertexLit"
}
Буду очень признателен, если кто-нибудь в силах помочь либо направить на нужное русло.