Depth Sorting, Light Sprites, and Brightness
Hey Folks! Hope everyone had a good weekend. Feels like it was a busy one here, though I can't seem to pinpoint why. Chalk it up to parenting, I guess :)
I resumed work on the new renderer today, fixing and tweaking progressively smaller factors. The aim is to hopefully arrive at the quality level we used to see with fully 3D lighting, but with faster performance allowing us to have more of them.
Light sprites (the bright dots that represent the light itself, as opposed to its reflection on the ground) turned out to be simpler than I expected. By simply adding them to the correct level of the item's hierarchy, they maintained correct orientation and position regardless of parent transforms. And I noticed the rendering layer I assigned to them last week was incorrect. Fixing that made them render correctly in both ship editing and crew sim modes. They even show/hide correctly based on line of sight!
Then, it was off to the crew mesh and materials. I had mostly figured it out in the test scene I was using, but it turned out there were a few gotchas I missed which reared their heads when in the full game. Each object in the scene renders at a time specified by its material, and last week I assigned timing to each based on their height above the ground. This makes conduits and other overhead stuff appear above walls, which in turn appear above the floor.
Crew pieces like feet and legs need to get these timing params, too. And at first, I thought this would be straightforward. However, when walking around, even values that seemed correct would occasionally glitch out. And as it turns out, this was partially due to missing code in the shaders. I needed to change the shaders to have "ZWrite Off" so they just rendered things in the order that materials tell them to, rather than distance from camera.
I also decided to re-enable the line of sight code to see how it looked when it followed the player around. And as part of that, I attached a new light to the crew to replace the old 3D light.
As these lights started to pile-up in the scene, the brightness started getting really overblown. Everything looked overexposed and white, so I fiddled a bit with light brightness until I came to the screenshot you see today. (This is about 40% full brightness on lights.)
Overall, not too bad. And actually pretty close to where we started, except more frames per second. The head lamp has a 360 degree arc, which is one of the most visible drawbacks. But I think there are ways to fix that.
Also, I think I may have figured out why the big ship's framerate was still a bit slow: my tiles are not batching in the renderer. When the game renders the scene, it renders each little square one at a time, and the setup/break-down time for each of those little renders adds-up when you have thousands of tiles.
Ideally, the game would notice that 900 of those tiles are identical floor sprites, and just do them all in one sweep. (I.e. batching) And I think I just forgot to apply some batching code to those item types when I added it to light meshes.
Anyway, it's looking better each day, and I think we're almost to a point where I can return to gameplay stuff!