Added Fog of War, Fixed clipping, and adjust lights.
I keep going to start work on the UI for this game, so that I can start stepping into the other buildings and their units + behaviors, but then I notice something that seems off. Today I was messing around in Dungeon Keeper 1 - attempting to determine map sizes to keep things in a similar vein, when I noticed the lighting in that old masterpiece is still superior to what I was seeing in mine. Then it clicked, of course - RTS games have Fog of War!
Immediately I started thinking of a way that I could implement a similar style of FoW as DK1. The fog seems to darken completely - but it sort of only happens half way though the immediate edge of the dungeon/dirt wall (fading into the darkness). After a few hours of investigating other's solutions, I decided on a combination of a few different methods and my own spin. Grabbing my current chunk mesh generator, I pulled out the surface tool building part of it, and re-purposed it for the fog of war.
The fog of war is determined by a simple mapsize_x by mapsize_y sized dynamic image (generated and updated through code on the fly), this dynamic image is then UV mapped onto a mesh of the same proportions (a plane subdivided by mapsize_x and mapsize_y). The dynamic image and fog can be seen in action in the attached video above. The way this works is similar to the pathfinding algorithm (another grab + repurpose of code :D!). Though, this time, the sector walker (used to determine walkable tiles linked into sectors) uses an 8 directions neighbour check instead of the original 4 direction (north, south, east, west). It is also looking for all "void" tiles (not walls), since buildings aren't walkable, don't want fog being placed on top of those XD. This new sector is then run through, and each tile within it is set to a white pixel, this is what determines where the fog is showing, and where it isn't.
A happy little accident here, due to the stretching/scaling of the fog mesh, the filtering/mipmaps on the texture actually create a similar blur effect at the edges of the fog - showing the top of the walls in the same way from DK1! It was then just as simple as applying the wobble shader to ensure vertices are moving the same as on the base mesh, and elevate the fog 0.1 units higher through the shader. It worked awesome!
That, however, was when I noticed something I had been ignoring: the Excavate overlay clips into the mesh below it, even though the vertices all match positions. I did some digging and found that the mesh I was using (from blender) for the plane, had inverted winding compared to my Godot SurfaceTool mesh... after a few tests and adjustments, I managed to remove that minor nuisance completely :D!
| Godot - you can see now, everything is balanced, as it should be :). |
Outside of these changes, I also changed the light generation to work like DK1 too - in that, lights can generate as soon as tiles are claimed, on dirt or reinforced walls. The lights will also jump to other walls should the one they are on be destroyed, or remove themselves if there is no valid wall to attach to. In light of this, all light generation logic was moved to the claim task, and additions were made during excavation to ensure similarity :).
I definitely need to tackle the UI next, no more putting it off for other things that jump out at me :).
Until next time!
Get Crypt Underlord
Crypt Underlord
Submission for the RTS JAM 1998.
More posts
- Development is on hold for now...Jul 18, 2022
- Experiments with Cursors, Draft ImplementationJul 10, 2022
- Draft UI, Minimap, and Contextual MenuJul 09, 2022
- New states for A.I. tasks, Item drops too.Jul 04, 2022
- Family Time Obligation: Complete, back to work :)Jul 03, 2022
- Optimizations and A.I. AdditionsJun 30, 2022
- Missed a day, heres some progress!Jun 29, 2022
- Not much time to work today, but did so anyway!Jun 27, 2022
- Basic: Inventory & Tasks, + Shaders and Lighting.Jun 26, 2022
Leave a comment
Log in with itch.io to leave a comment.