
when i export vertex position/normals/tangent to vat(vertex animation texture), position and tangent work well but normals work fail look like this,
i m using “exr” to export them.
Are you sure this is a normal issue? It looks more like shadow acne. Does it go away if you disable shadows on the light?
ops,yep this is a problem with shadow acne,the normal may be correct,But i still cannot figure out why the shadow show acne when using VAT.
,thanks bgolus.
What does your shadowcaster pass look like? Is it calling the usual macros? The macros in the vertex shader are there to apply the shadow bias. If the macros are there, what are the bias settings on your light?
#ifndef UNIVERSAL_SHADOW_CASTER_PASS_INCLUDED
#define UNIVERSAL_SHADOW_CASTER_PASS_INCLUDED
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Shadows.hlsl"
float3 _LightDirection;
#if VAT_ON
//anima========================================
uniform sampler2D _PositionAnimaTex;
uniform float _AnimaScale;
//anima========================================
#endif
struct Attributes
{
float4 positionOS : POSITION;
float3 normalOS : NORMAL;
float2 texcoord : TEXCOORD0;
#if VAT_ON
float2 animaUV:TEXCOORD1;
#endif
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct Varyings
{
float2 uv : TEXCOORD0;
float4 positionCS : SV_POSITION;
};
float4 GetShadowPositionHClip(Attributes input)
{
float3 positionWS = TransformObjectToWorld(input.positionOS.xyz);
float3 normalWS = TransformObjectToWorldNormal(input.normalOS);
float4 positionCS = TransformWorldToHClip(ApplyShadowBias(positionWS, normalWS, _LightDirection));
#if UNITY_REVERSED_Z
positionCS.z = min(positionCS.z, positionCS.w * UNITY_NEAR_CLIP_VALUE);
#else
positionCS.z = max(positionCS.z, positionCS.w * UNITY_NEAR_CLIP_VALUE);
#endif
return positionCS;
}
Varyings ShadowPassVertex(Attributes v)
{
#if VAT_ON
//anima=====================================
float4 uv=float4(v.animaUV.x,_Time.x*_AnimaScale,0,0);
float3 pos=tex2Dlod(_PositionAnimaTex,uv).xyz;
v.positionOS=float4(pos.x,pos.y,pos.z,0);
//anima======================================
#endif
Varyings output;
UNITY_SETUP_INSTANCE_ID(v);
output.uv = TRANSFORM_TEX(v.texcoord, _BaseMap);
output.positionCS = GetShadowPositionHClip(v);
return output;
}
half4 ShadowPassFragment(Varyings input) : SV_TARGET
{
Alpha(SampleAlbedoAlpha(input.uv, TEXTURE2D_ARGS(_BaseMap, sampler_BaseMap)).a, _BaseColor, _Cutoff);
return 0;
}
#endif
Hi bgolus,this is my shadow caster code,I just do little change on the original URP “ShadowCasterPass”.
the VAT_ON is a shaderfeature that control if using vertex animation texture or not.
thanks for your teaching.have a good time~