Lighting Test Successful
Hey Folks! The line of sight and lighting test seems to still be going well. I've got it rendering multiple lights now!
There was one more bug to solve in the single line of sight/light code I've been working on, and that was to get the line of sight to behave when there weren't enough light blockers nearby. By doing that, I was able to get the light to produce nice round shapes regardless of the surroundings.
After that, I began the long process of converting my single-instance code so it could work in multiple instances. I had to move a bunch of properties around, remove some redundant data, and make sure the data lived in and was controlled by the right classes.
Then the fun started!
Today's image shows the scene with 400 blocks and 50 shadow-casting lights (many of which are off-screen). And as you'll notice in the top left, we're still up at 66fps! What's more, this is all happening under a GUI canvas where I'm rendering debug text (hidden by framerate inset), plus some hacky frame buffer effect I'm doing that doesn't get used yet. More on that in a minute.
The scene does have a few limitations. For one thing, all the lights except one are static. So they don't have to recalculate shadows per-frame. The exception is attached to the mouse, and updates per-frame. And we're still at 640x360 (360p). I haven't tested a higher res yet as this is still a target res I want to try. But it'd be interesting to see how well it handles more pixels.
Other changes are at work here, too. Some more visible than others. I fixed a lighting calculation in the shader that caused the light to be too strong below the light position, almost creating a cone of light towards the bottom of the screen. It was due to unnecessary normal map y-axis swizzling. I also adjusted the light falloff rate to be inverse cubic, instead of a weird inverse pseudo-squared function. Plus some tweaking to the default light height and attenuation.
Finally, one of the more visual changes was to make each light a random color. They're now either a xenon blue or halogen orange, borrowed from the space prototype. And it really helps show off the normal maps and shadows to see different colors interact on the same objects.
Now, back to that earlier point about the hacky frame buffer. The moving light in this scene is supposed to represent the player's line of sight. And as you can see in today's image, this is more like an omniscient view where we can see everything.
As an experiment, I want to try rendering a stencil buffer that renders everything in the player's line of sight as we see here, but anything outside of that is dimmed. Say, by 50% or 80% for starters. The result should be something like fog of war, where we see our line of sight fully (complete with people/items), and anything beyond we have a dim view (probably without creatures or items visible). Depending on how that looks, it might also be worth figuring out how to make unvisited parts of the ship completely black until we've seen it at least once.
Basically, NEO Scavenger's line of sight, except in pixels instead of hexes. We'll see if a) I can get it to work, and b) it's worth doing, tomorrow!