I am making a top down 2.5D RPG, with 2D Sprite Renderer to render the characters, and 3D for the background with Mesh Renderer in URP.
How do I make my 2D Sprites cast shadows on 3D models?
I am making a top down 2.5D RPG, with 2D Sprite Renderer to render the characters, and 3D for the background with Mesh Renderer in URP.
How do I make my 2D Sprites cast shadows on 3D models?
Is this just not possible?
These sorts of things should be solved through art and design choices rather than arcane graphics tricks.
Not a Unity guru here, but… Here are some options in ascending order of complexity a̶n̶d̶ ̶i̶n̶s̶a̶n̶i̶t̶y̶.
I’m sure you know that the most brazen approach is to just slap a black blob on the ground. A flat mesh ever so slightly above the surface. Worked alright for some games where there’s no elevation. But I can’t tell if this approach fits your game.
If your characters have fancy sprite-animations and you need the animations to be reflected in the shadow, and you can get away with your shadow being disconnected from the character, you could duplicate your sprite, make it black and put it below.
You could also consider transitioning your characters into some form of 3d to have them interact with light.
I’m not sure, but I think I’ve seen a game where some form of biplanar mapping was used to slap sprite shadows on uneven terrain. Can’t say I understand all the particulars, but I think it’s possible to render a shadow plane, and then map that plane onto the background geometry.
Here’s an idea for a madman who married the 2.5d aesthetic, but absolutely needs realistic shadows in there for some reason - make a 3d model of your character, place it alongside your sprite, have it be on a rendering layer that isn’t rendered by your main camera, but is rendered by the shadowmapper. That way there would be an invisible 3d model casting a visible shadow. I might be fetching too far with this one.
Shame there’s no built-in solution.
Thank you @BakeMyCake , I will just work with blob shadow, since other solutions seems to increase the workload to produce an asset immensely (Even harder to edit as well).
I am asking the forums because I remember a few years ago before SRP, it used to be possible. But sadly I can’t find the old solution that I’ve seen back then. I originally thought there is a built-in solution that I am not aware of, turns out there might not be any.
Once again, thanks!
Could it be the projector-related? https://docs.unity3d.com/Manual/class-Projector.html
You haven’t specified what the game looks like, but if you just want a black stencil of your sprite, try using a textured quad instead of the regular sprite renderer. Assign a cutout material to it. As far as I remember cutout respects texture alpha for shadows. It may not be the best for performance, but if you’re developing for desktop and not going to have hundreds of characters on the screen you’ll be fine.
The game is a lot like this.
https://www.youtube.com/watch?v=tdfoj6aVWao
Or this
https://stackoverflow.com/questions/52299446/sprite-shadow-in-3d-world
A lot inspired by the beautiful Ragnarok Online/Tree of Savior
https://www.youtube.com/watch?v=ofLTA9-D14o
But giving up on having real-time shadow that works with sprite sheet animation and using blob shadow seems to make the most sense to me. (It also have the added bonus of readability to where the current player’s location is)
And yes, textured quad & cutout shader would work, but it has the downside of not being able to use sprite sheet with the animation editor without a lot of work.
Using a lit & shadow casting cutout shader on a sprite should work just as well as it does on a quad.
Yeah, but that means it won’t support Unity sprite sheet animations out of the box.
Why not?