I need to render a display layer to a texture, but I need objects from other layers to still cast shadows. Setting the camera’s culling mask completely disables the other objects, so I lose shadows on the objects I’m rendering.
The only way I’ve found to do this is to iterate through every object in the scene that isn’t in my layer, set shadowCastingMode to ShadowsOnly before I call Render, then set it back, but that’s slow even in simple scenes. It can take longer than the actual render.
Shader replacement with a shader that only casts shadows almost does it, but that would require modifying every other shader in the game to add a subshader, which would be way too invasive. (Shader replacement is very limited…)
This is for an effect asset, so expecting people to add a replacement subshader to every shader in their game for one isolated effect won’t really work. If there was a way to say “replace all shaders with tag X, and use shader Y if it doesn’t have the tag” it would work, but replacement shaders only let you say “replace all shaders with tag X, and don’t render at all if it doesn’t have the tag”.
Unless there’s something in replacement shaders I don’t know about, or some way to add global “fallback replacement shaders” automatically…
Object > Mesh Renderer > Lighthing > Cast Shadows > Choose Shadow Only
Been searching for 2 hours and i have found solution cliclking every mesh renderer setting randomly lul