Systems Coming Back Online

Hey Folks! We're gradually getting there, with more and more of the old game systems coming online with the new renderer. And today's screenshot isn't half bad!

Yesterday's problem with walls blocking all light turned out to be a bit more fundamental than what I thought. It wasn't a scaling issue with the blocker mesh, it was the fact that the game wasn't being told to calculate any lights at all. I had to add code to the game so that it would generate lighting/line of sight when a light was added, and recalc all of it if a new item was added/removed with light blockers. Once I got that setup, I started seeing appropriate line of sight (using a default light and view origin attached to the mouse).

I also had to change a few hierarchy settings such that the map moved around with WASD controls again. My new rendering cameras were not attached to the main camera, and didn't get the benefit of WASD moving it around.

Also, I finally hooked the item's Z-height data into the shader's render queue order, so things like high walls and conduits would render over lower things like floors and appliances.

The lights themselves took a bit of work to get online. All my light meshes were assumed to be at 0,0 in the scene, and it would just draw giant meshes far away from 0,0 if needed. Not ideal, since we could rotate lights in the scene. Also, if we the camera is hovering way off to the edge of the map, it could screw up culling. So I made changes such that each light existed at the light's root position, and the light rays radiated out from there. That turned out to have some gotchas in recalculating everything relative to the new center positions, but seems to work now.

Then, I noticed some of my more non-square objects looking bad. Since all the light blocking mesh is square, I was getting jagged/oversized shadows around some objects. To deal with this, I changed light bounding boxes to be rectangular instead of square. Which also necessitated carefully handling cases when the object was rotated/scaled. However, that now seems to behave better, too.

I fixed-up a bunch of the old UI overlay items so they now render appropriately. That was mostly changing their render layer and/or Z positions.

And we're still doing pretty well for performance. 60-70fps is what I'm typically seeing. Loading my giant "02" ship (the one with all the rooms, fusion reactor, fuel tanks, etc.) ran at 40+fps, which was initially concerning. However, turning off the per-frame line of sight calculations pushed that rate back up to 70fps. So what that tells me is that the light rendering alone is super fast, but the visibility recalcs slow things down. I might be able to optimize that some more, such as limiting the blocking meshes I check against, checking less often, or similar.

Also, this whole exercise has taught me a lot about debugging rendering. And in the process of porting this over to the main prototype, I noticed some GUI-specific things rendering each frame that aren't necessary. The system map, docking ring, and ATC are all drawing even when not visible. I suspect I can pickup a lot of performance just by disabling rendering of these while they're off-screen, and then disabling the entire ship rendering when they do appear (since they cover the whole screen).

Overall, this is looking like a week-ish well-spent. Still more to do to get things fully running. For one thing, I seem to have broken the conduit connectivity somehow, making some light testing difficult. And there's a lot of UI overlay stuff still in need of fixing. Plus, the crew still hasn't been converted to new material and shader types.

But we're getting there!