Is it possible to add cutout to this shader? I would need only a few specific parts of the mesh to receive shadows based on alpha/mask while keeping it transparent.
Add this line to your properties: _Cutoff ("Alpha cutoff", Range(0,1)) = 0.5
And replace your Fallback line with:
Fallback “Transparent/Cutout/VertexLit”
That’ll get it setup to use an alpha tested shadow. After that you’ll need to add back in a _MainTex property, the alpha of which you can use to modify the areas that receive shadows.
Note that this also controls which areas cast shadows, and transparent objects that receive shadows will prevent areas behind it from receiving shadows.
I want shadows on transparent meshes. Based on my research it is very hard to achieve so I plan on adding a second mesh in front of it which receives the shadow. It kind of worked except the shadow is visible on the whole shadow receiver mesh instead of just a few spots. The cutout of booth the transparent mesh and the shadow receiver have to be the same otherwise there will be floating shadows
So, if I understand what you’re trying to do, you’ve got an existing transparent material using either alpha blending or alpha test to only show in certain areas. Then you also this additional material that you’re using just to show shadows, presumably using a copy of the transparent mesh?
I’m assuming the transparent material is still rendering during the transparent queue, and this material is set to run during the alpha test queue to ensure it receives shadows. Yes? The result would be your transparent object is going to render “on top” of the shadows rather than the shadows being part of the transparency, so maybe you move the transparent material to be on a queue less than the shadow collector?
If that’s the case, I’m not sure why you wouldn’t just change your transparent material to use shadows? The only issue is materials with a transparent queue can’t receive the data about shadows, but a transparent material with an alpha test queue (really < 2500) will still get information about shadows, as long as it still has a shadow caster pass.