I’m trying to have basic stylised shadows on one object in my scene. Every material is unlit, and my current solution is to have each object above the shadow catching area have a plane. The shadow-plane has a mask that overlays an alternative, “shadowed” texture on top of the otherwise lit one. I’m mostly happy with it, but it has forced me to keep the object flat so that the shadow planes don’t look add and align. Using decals would allow me to throw some geometry in there, and I am somewhat worried about the shadow planes causing a lot of overdraw.
I’ve read some vague forum posts talking about ”using boxes that read scene depth”, whatever that means. I’ve also tried placing a light and reading it in the material to lerp between a light and dark texture, but just like dbuffer decals, this doesn’t work on mobile. Is there a way to do this with reasonable performance, and if not, are there any workarounds?
Your Method of using planes is definitely the cheapest and most effective that you mentioned, especially if it is for a mobile game. Your Overdraw concern is perfectly valid, but you can work around it: Instead of using a square plane, somehwat model a plane to the shape of the shadow, get as close to the edges of the shadow with the geometry as possible. And of course, try to use as little Geo as you can. But geometry is often much cheaper than overdraw. A 10 sided mesh with almost no overdraw is much cheaper than a square plane with plenty of overdraw.
This also mean you don’t need any expensive materials with lots of instructions in them for “Reading Depth” as you say.
Also lights are extremely expensive or heavy on baking times, so avoiding those where possible.
Why didn’t I think of modeling the shadow plane after the mask? Thank you :- )
I’ll leave this question open because I’m interested in other ways to fake or make decals on mobile in general.
I ended up using a 2D Render Target with a render distance of a few centimeters. It’s located on set to Orthographic and it only renders specific Actors I want it to see. I use that Render Target’s Alpha as a driver for a lerp value for the ground / wall / desired material to switch between a sunny / lit and a dark / shadow colour. More or less unnoticable when it comes to performance and looks great.
Note: This is not ideal for many cases and I don’t recommend having many Render Targets, but in my case, it’s the most optimal solution.