Hey,
I am working on a custom cut-out shader. (i am using custom toon shaders for all elements in my game that receive “noisy” shadows) I got the part working that the albedo gets cut off based on the alpha of a texture. The shader doesn’t cast and receive shadows in the right way yet though.
It seems like it casts and receives the shadow using the full geometry and not with the cut out texture.
i don’t really have an idea how to go about this, i tried looking at the standard and other cut out shaders but they are black boxes for me. any help would be appreciated!
You need to make a ShadowCaster pass that just outputs depth using this same shader math you have here.
You can see an example in the “Implementing Shadow Casting” section near the bottom of this documentation:
I just wanted to point out this line. addshadow and fullforwardshadows are optional parameters for the #pragma surface used by Surface Shaders. They have no affect on vertex fragment shaders. Surface Shaders are vertex fragment shader generators, and can generate multiple passes including the "LightMode"="ForwardBase" pass you have above, as well as several others. If you use the addshadow it generates a "LightMode"="ShaderCaster" pass.
If you’re writing the vertex fragment shader manually, you’ll need to also write the shadow caster pass manually, like @Invertex mentioned above.
I understand by following this documentation to implement a “standard” shadow casting pass but I don’t see how to change it in any way? It looks exactly the same. The doc mentions : "… object has custom vertex shader based deformations, or has alpha cutout / semitransparent parts… " which is actually both true of my shader but I just don’t see what to do about it. Maybe I just don’t understand the basics of making a shadow casting pass, are there some basic tutorials on this? All I see are just black-boxes like “SHADOW_CASTER_FRAGMENT(i)” and I have no idea how I can affect the shadow that is being cast.
Also, can you tell me what you mean when you say the ShadowCaster pass outputs depth? I don’t see the fragment shader outputting color or anything like I would be used to in the example in the documentation.
Sorry for all the questions! I thought I grasped shaders a little bit better by now but I keep getting confused by all these unity functions and included stuff that is predefined.
i guess i can see how it will be easy to do the same transformations to the vertex in the vert of the shadow caster pass but how do i use the texture of cutout?
The short version is any code you’re doing in your forward base pass that would affect the shape / shadow of the object need to also be done in the shadow caster pass too.
On a side note, your example shader code above is: