- Home /
Help Turning Sprites into 3D Objects and Casting Shadows
Basically, I'm trying to make a game using 2D sprites that move in a 3D space. I'm trying to get a lighting effect like the one here, where characters are 2D sprites but cast shadows onto the 3D geometry. From what I've gathered, I need to turn my 2D sprites into a 3D object, since sprites won't cast shadows. I've tried a couple solutions but none have worked so far:
Placing the sprites onto planes/quads and using those instead. This just hasn't displayed my sprites properly, and I feel like doing this would make animating sprites a nightmare.
Using an external program (like Blender) to turn my sprites into planes and use those. The issue is I have no idea how to use blender or how I would animate using this, and haven't been able to find a tutorial that shows me what I want (and I don't really want to learn the entirety of blender just for this one thing).
This one was just an idea, and I have no idea if it even exists, but using really thin voxels. Basically, if there's a voxel program that allows you to adjust the depth of the voxels that would solve all of my problems.
I really want to use this kind of lighting, and I've reached the point where I can't move forward in my prototypes anymore without figuring this out, unless I want to redo all my work. Any help is appreciated.
I have, but sprite renderers don't cast shadows. That's why I want to turn my sprites into 3D models (that I can also animate), so that they can cast shadows.
Answer by HarshadK · Mar 12, 2018 at 05:58 AM
Check out this thread about the same issue you are facing: Why can't Sprites gameobjects cast shadows?. It's a bit old but should serve the solve your issue.
Main takeaway from this thread is that shader used for sprites does not support shadows so you have to use a custom shader that supports shadow.
I would add that towards the end of the thread they suggest a way without a special shader:
- in debug mode, enable cast shadows and receive shadows for the sprite renderer
- ins$$anonymous$$d of sprite renderer material, assign a standard material with cutout mode to the sprite renderer
I just tested this, and it works. I think it effectively turns your sprite renderer into a mesh renderer with a quad mesh, so there is probably a performance impact for it.