Hi all, I’ve been working on something small in my spare time outside of my main project for a while and the premise requires small rooms viewed top-down.
The main issue I have is that I don’t want to have to model each room separately as I wanted to build an in-game level editor so others can build their own eventually. As a result of this, backfaces and gaps in geometry are visible in the existing levels.
My first idea was to use raycasts to detect gaps in geometry and dynamically create these blackout zones like that, the problem is that not all levels are square, so huge numbers of RCs were required and it got VERY laggy.
All levels have a static height (2.5 units) so all I really need is a solid plane at that height with cutouts where there is geometry directly below.
Is there some kind of camera effect or something else I can use to achieve the effect in the second image?
Perhaps you could use this method to solve your problem?
You might have to generate a mesh that perfectly fit on top of your levels and this uses Shaders, but I don’t really see a regular C# code way to do something like this.
Alternatively, my first idea was to just have a black back to your walls and use a black skybox.
It’s super-easy to feed all your flat wall geometry through a function to create duplicate geometry facing the opposite way, and then assign that geometry an unlit black texture.
I even have the bulk of the “flip the triangles around” code already available for you here:
I’d just use a shader that draws the backfaces black. No point bloating your memory with a whole different model.
If you’re using URP you can use a custom render feature to do this without having to duplicate models.