Garages and Fog Nerdery

Dang, I guess it’s been a few weeks and mostly I’ve been working on more of the inventory system.  I managed to get the Garage working fully and now they appear on the map as places you can load out your gear, repair and refuel.  

Working on infrastructure for this long gets a bit taxing, so I wanted to switch over to something more visual for a palette cleanser…  so I chose to noodle around with Fog of War (not the most fun thing, but better than weeks of UI noodling).

Nerd Alert inbound!

Image result for hazard tape

My Fog of War (that is, how I represent areas of the map you haven’t explored and/or can’t see) is currently implemented tile-by-tile.  I implemented it by creating a custom shader that fades out the individual tile models based on a fade value I feed each one.  This has a few drawbacks:

  • The edges are hard and look a bit amateur as a result.
  • The fade currently goes to black, which is fine for dungeons but not appropriate for all my above-ground venues.
    • (Large areas of black also look a bit “cheap” on 3D games, although that’s my own personal bias.  2D Roguelikes somehow look just fine with the very same thing, however!)
  • I can only fade per-mesh, so in order to support height-mapped terrain meshes, I’d have to write some wacky shader to handle it.
  • I have to put a custom material on every model, and write a shader for any weirdo material tricks that a specific mesh wants to use.

I did some experiments with non-black fade colors, which didn’t add a ton of complexity to the shader but still emphasized hard edges.  Also, I had to turn off screen space ambient occlusion (SSAO) to make it fade to the pure color, which is something I use for my terrain features to “pop” a bit more.  Not a huge loss, but it only reminds me about how my technique is impacting my rendering and asset management.

In the end, I’d like a fairly “soft” (and in my opinion, more pro-tier) representation of Fog of War.  For most 2D Roguelikes, the common technique is to place a huge planar texture between the camera and the world and draw areas of black and transparency over it to obscure undiscovered areas.  I had steered clear of this technique because my terrain is 3D and my camera is a perspective projection with a viewing angle of about 35 degrees…  this causes the Fog plane to parallax (obscure different areas based on the viewing angle)…

However, this can be solved with math…  I can scale and offset the fog of war plane to match a fairly flat map, so I’m going to try it out. Granted, using a plane will fail if the player ever drives up a hill (which is something I support, but only use in a few locations), but I think this technique should do well for all my current combat areas (not the adventure ones) for the short term.  Will see if I can get it rigged up tomorrow morning before work. Wish me luck!

 

Leave a Reply

Your email address will not be published. Required fields are marked *