Gap on the mesh
I came around some problems with previous optimizations:
You can see some black dot on the upper-left of the room. Those appear randomly when camera moves. When switching to the new terrain mesh it appears there are some very small gaps between the faces, and they get accentuated when rendering shadows.
I can’t find why those gaps exist, they aren’t there when using the full/complex mesh. I checked the mesh but all points are correctly connected, and there’s no precision problems (I even cast everything to int, and those ints are too small to come across float precision problems).
And furthermore they don’t appear on vertex but on faces edge, on this screenshot you can see the black dot is in a middle of a segment between two faces:
I think it’s some sort of precision problem when the GPU tries to connect the faces after applying camera transformations. With the complex mesh this problem does not appear as faces are a lot smaller.
So I checked if this new mesh was really useful, and it appears it just improves performance by something like less than 5%… It’s crazy as it reduce vertex count by a very huge factor (around 100x-200x)…
Another crazy stuff is that when removing duplicated vertex in the complex mesh it reduces vertex count by a small factor (2x-3x) but improves performance by around 25%… There’s really something I don’t quite get happening here.
And correcting this gap “manually” (basically by removing filtering on the shadow map + checking in the final render if value is too different + applying PCF on final render) might just kill the small performance gain.
So I don’t know what to think, maybe I’ll drop this new mesh for the moment…
Currently I don’t think Alien Blitz needs shadow mapping, I’m mainly trying that for a next engine, and if it could fit on Alien Blitz then why not. But it’s too much work in my opinion, and not really needed.
But another thing that shadow mapping could be good for is to limit field of view. From the beginning this game was supposed to have a limited view, so that only what the mecha can see should be visible, here’s a very old screenshot of this concept:
But in isometric if was way too costly. And in 2d/3d I just added a fog above terrain.
But now with shadow mapping I can just put a camera on the mecha to know what it can see.
First I tried with a directional light:
Problem is the mecha moves way too much (avoiding bullets, or just walking through the level) so it makes it horrible.
So I tried with a point light:
We loose some realism as the mecha can now see behind himself, but it’s way better.
You can still see sprites as shadow is not applied on them yet, but it seems quite good, it needs more testing but it seems ok performance wise and from a game design point of view it should be good too.
What is sure is that if it is included in Alien Blitz it will be a PC only feature.