Hi, I’m writing a custom shader that makes large changes to the shape of the geometry. It’s in forward rendering mode.
I started with unity’s Standard shader because I want all of its features as well, and have been modifying it to do what I need.
I have this mostly working except for a bug where from certain angles shadows appear that give away the real shape of the models rather than the one created by the shaders.
The problem I’m having is that I don’t seem to be able to alter the shadow caster pass.
This is the part I need to change:
You can see in the properties it says the shader is CustomStandard pass #1.
The code in that pass looks like this:
Pass {
Name "ShadowCaster"
Tags { "LightMode" = "ShadowCaster" }
ZWrite On ZTest LEqual
CGPROGRAM
#pragma target 3.0
// -------------------------------------
#pragma shader_feature _ _ALPHATEST_ON _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON
#pragma multi_compile_shadowcaster
#pragma vertex vertShadowCaster
#pragma fragment fragShadowCaster
#include "UnityStandardShadow.cginc"
ENDCG
}
And the code in the vert and frag shader is just this:
void vertShadowCaster (VertexInput v, out float4 opos : SV_POSITION)
{
UNITY_SETUP_INSTANCE_ID(v);
opos = UnityObjectToClipPos(v.vertex);
}
half4 fragShadowCaster () : SV_Target
{
return 0;
}
As you can see, there’s basically nothing in there.
I don’t know a lot about shaders so I’m confused how this is actually rendering anything at all for this pass and yet it definitely is, if I commend out the opos line in the vert shader then it stops rendering, if I put a clip(-1) in the frag shader then it stops rendering.
The return value for the frag shader doesn’t seem to do anything, I tried returning different results and the rendered image is the same.
What I want to be able to do is alter the pixels being rendered in the frag shader just like you can in any other pass.
So can someone explain how this ShadowCaster pass works?