Добавил к прозрачному шейдеру анимацию вершин и теперь когда объект с этим шейдером перекрывает чью-либо тень, то смещение вершин из шейдера не учитываются для теней, тень обрезается первоначальной геометрией.
Разумеется погуглил, нашел решение, но не могу понять как добавить смещение в коллектор и кастер теней, вроде нужно пасс добавлять в шейдер? или может есть другой способ решить проблему?
http://forum.unity3d.com/threads/custom-vertex-animations-shadows-and-unity-4-2-broken.198827/
Вот собственно мой шейдер
Синтаксис:
Используется javascript
Shader "MyShaders/DiffuseTransp_wave"
{
Properties {
_Color ("Main Color", Color) = (1,1,1,1)
_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
_Cutoff ("Alpha cutoff", Range(0,1)) = 0.5
_WindDirection ("Wind Direction", Vector) = (0,0,0,0)
_WindFrequency ("Wind Frequency", Float) = 50
}
SubShader {
Tags {"Queue"="AlphaTest" "IgnoreProjector"="True" "RenderType"="TransparentCutout"}
LOD 200
CGPROGRAM
#pragma surface surf Lambert alphatest:_Cutoff vertex:vert
//#pragma surface surf Lambert vertex:vert
sampler2D _MainTex;
fixed4 _Color;
fixed4 _WindDirection;
fixed _WindFrequency;
struct Input {
float2 uv_MainTex;
};
float4 myVertAnim (float4 pos, float3 normal, float4 vertColor) {
pos.xyz = mul( _Object2World, pos).xyz;
normal.xyz = mul( _Object2World, float4(normal.xyz, 0.0)).xyz;
float wave = 0.5 * (sin((_Time + 2 * vertColor.g) * _WindFrequency * 0.3) + sin((_Time + vertColor.g) * _WindFrequency)) * vertColor.r;
pos.x += _WindDirection.x * wave;
pos.y += _WindDirection.y * wave;
pos.z += _WindDirection.z * wave;
pos.xyz = mul( _World2Object, pos).xyz;
return pos;
}
void vert (inout appdata_full v) {
v.vertex = myVertAnim(v.vertex, v.normal, v.color);
}
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/Transparent/Cutout/VertexLit"
}
{
Properties {
_Color ("Main Color", Color) = (1,1,1,1)
_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
_Cutoff ("Alpha cutoff", Range(0,1)) = 0.5
_WindDirection ("Wind Direction", Vector) = (0,0,0,0)
_WindFrequency ("Wind Frequency", Float) = 50
}
SubShader {
Tags {"Queue"="AlphaTest" "IgnoreProjector"="True" "RenderType"="TransparentCutout"}
LOD 200
CGPROGRAM
#pragma surface surf Lambert alphatest:_Cutoff vertex:vert
//#pragma surface surf Lambert vertex:vert
sampler2D _MainTex;
fixed4 _Color;
fixed4 _WindDirection;
fixed _WindFrequency;
struct Input {
float2 uv_MainTex;
};
float4 myVertAnim (float4 pos, float3 normal, float4 vertColor) {
pos.xyz = mul( _Object2World, pos).xyz;
normal.xyz = mul( _Object2World, float4(normal.xyz, 0.0)).xyz;
float wave = 0.5 * (sin((_Time + 2 * vertColor.g) * _WindFrequency * 0.3) + sin((_Time + vertColor.g) * _WindFrequency)) * vertColor.r;
pos.x += _WindDirection.x * wave;
pos.y += _WindDirection.y * wave;
pos.z += _WindDirection.z * wave;
pos.xyz = mul( _World2Object, pos).xyz;
return pos;
}
void vert (inout appdata_full v) {
v.vertex = myVertAnim(v.vertex, v.normal, v.color);
}
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/Transparent/Cutout/VertexLit"
}