Overworld flythrough video

This week was busy on a few fronts, but mostly on improving rendering. The new thing I was mainly busy with, was vegetation and creatures, and shadows and occlusions. A relevant older post is this one here.

The scene in the videos contains roughly 22,000 mountains (rendered twice: normal and shadows) 150,000 trees (rendered twice: normal and shadows) and 1,000,000 sprites (rendered 3 times: normal, shaddows and occluded)

For my sanity, I'm using the shaderc tool to assist with porting shaders to GLSL, as Godot's shader integration is friendlier towards ... Godot shaders, rather than GLSL. Admittedly, porting shaders is tedious because things get a bit more complicated when communicating between GLSL and regular code, e.g. there are no "free" uniforms (everything needs to be in some sort of buffer), some buffers should ideally have a very strict layout (aligned at 32 bytes), there needs to be a distinction between uniforms and push constants, and so on.

I'm still working and iterating on the abstractions for rendering, as that's pretty big and will affect more that 75% of the remaining refactoring work, so I better get this right. Previously, throughout the code I was using Graphics.DrawMeshIstanced and I was setting an appropriate layer. This is a bit too ... rogue for my liking, so with the new setup I want something more structured, where there is no stray rendering really, so that the rendering pipeline is well-known and contained (still, I should be able to dynamically add-remove render passes, like particle systems).

I've now just completed integrating the map border, which is yet another shader/pass.

Other topics/changes:

  • As I'm moving through the abstractions, I've refactored all texture-related code to use a simple wrapper over Godot's ResourceId that includes texture metadata (width/height/format/etc).
  • Added unprojection of mouse coordinates to world-space coordinates again, for hover tile identification
  • Trying to standardize to as few pushconstant formats as possible, e.g. one that's used for all overworld passes contains camera matrix, real time and texture atlas info.
  • Found some good presets for world generation
  • Added biome map and resources map (mined material distributions) to the runtime resources structure
  • Fixed some bug with sprite depth calculation in the shaders (this allows proper occlusions now)
  • Fixed some bug where palm trees were appearing in non-deserts in the overworld
  • Fixed mushroom distribution in forests (too many previously)

That's it for now, next week is iterating more on the abstractions as I integrate more and more things from previous work. The only thing left from overworld rendering is the fog of war (for which I can temporarily fudge data), but after that I have to be able to start the game in the overworld, which means fixing lots of runtime errors and thinking hard on how to organise the game state and rendering, to improve on the previous mess, as this is the chance for a cleaner slate!

The million monster march