Open slagatoras opened 2 years ago
I think URP doesn't support Surface Shader anymore, you should either use Shader Graph or write a Lit Shader you own which clip the pixels manually. Check the code below, the important parts are the 2 Clip() functions. But I'm not sure is this the best way to achieve tho.
SubShader
{
Tags { "RenderPipeline" = "UniversalPipeline" "IgnoreProjector" = "True" "Queue" = "Geometry" }
HLSLINCLUDE
// Includes & Structs
ENDHLSL
Pass
{
Tags { "LightMode" = "UniversalForward" }
HLSLPROGRAM
#pragma vertex vert
#pragma fragment frag
v2f vert(a2v v)
{
// Vertex calculations
return o;
}
half4 frag(v2f i) : SV_TARGET
{
float3 adjustedCenter = sliceCenter + sliceNormal * sliceOffsetDst;
float3 offsetToSliceCentre = adjustedCenter - i.worldPos;
clip(dot(offsetToSliceCentre, sliceNormal));
// Fragment calculations
return color;
}
ENDHLSL
}
// Important! Have to use a custom shadercaster to clip out the shadow
Pass
{
Tags { "LightMode" = "ShadowCaster" }
ZWrite On
ZTest LEqual
Cull Off // Set cull off to keep shadow casting from the inner clipped part
HLSLPROGRAM
#pragma vertex vert
#pragma fragment frag
v2f vert(a2v v)
{
// Same as forward pass
return o;
}
half4 frag(v2f i) : SV_TARGET
{
float3 adjustedCenter = sliceCenter + sliceNormal * sliceOffsetDst;
float3 offsetToSliceCentre = adjustedCenter - i.worldPos;
clip(dot(offsetToSliceCentre, sliceNormal));
return 0;
}
ENDHLSL
}
}
Any luck with that? has anyone managed to convert it to URP please?