Over the past couple of days we've made many improvements & fixes :
- New smooth lighting code for non-shadow receiving entities.
- Proper lighting for weapon models in character hands.
- One fewer rendering pass during directional light rendering.
- Fixed shadow frusta to be shorter - only to light range.
- Fixed shadow frusta to reflect actual visual bbox.
- Fixed the debris to use debris atlas texure so that debris matches the color of the texture it is derived from.
- Changed facets to always be reloaded from the csv file on entity creation. This changes the entities from a prototype-based system to a class system.
- Fixed the entity turning code to be more consistent as well as simpler and more readable.
- Stopped calling animation code when entity has been dead for over two seconds.
The smooth lighting code worked very well for being so simple. It's too slow to make all entities ( doors, enemies, etc. ) receive actual world shadows and shadows from other entities, so I needed an alternate approach. For a long time, I've had code to do several jittered ray casts through the scene towards a light in order to compute an occlusion percentage, but it's not super fast when doing like 9 ray casts per frame, per entity, and it doesn't always look that good, when an entity suddenly shifts lighting very quickly.
I managed to fix both issues at once, by adding a light amount facet to each entity, and doing a single raycast per light per visible entity per frame, and then smoothly averaging the new value into the old values. So, I effectively replaced spatial smoothing ( by doing 9 samples ) with temporal smoothing, with 1 sample averaged in over many frames. I gotta say, it looks very good, even on the main character, altough I think we will keep him receiving real shadows by default.
The weapons were rendering as .x files, rather than as true entities, which meant that they weren't being lit per-pixel, and couldn't have their own visible state or animations, so I fixed that. This brought up the issue of how to do shadowing for entities attached to other entities, like weapons. One option would be to have them use their own shadowing term, and the other was to have them use the entity's shadow term.
I ended up using the attachee's entity shadow term to ensure the gun wasn't brighter or darker than the entity carrying it.
Gameplay-wise, the AI received more tweaks, including the AI now tracking down the player rather than hiding so much. We also added in the two-handed gun aiming stance. When you right click, you can't move, and your character shifts to the more accurate two-handed gun stance, and the laser sight appears and can be used to aim at the enemies.
This makes a for nice little rhythm where you right click, aim at the enemy, shoot of a burst of 5 shots, then let go of the right button and dodge to the side, then take aim again.