3
\$\begingroup\$

I am struggling with designing black map and fog of war in a 3d game. Black map is the area that player hasn't explored (completely unknown), while fog of war is the area that player has explored and knows geospatial topology, but no friendly units or buildings are nearby to provide player with up-to-date info about enemy movements over the area.

The problem is that my terrain is 3D, varies in height greatly and camera can be placed at any position on the map at virtually any angle.

So far I've designed very heavy fog/clouds for area under fog of war, but not so heavy that the terrain underneath would not be visible, and am not rendering non-environment objects on those locations, but black map is another story.

Simply not rendering terrain over those locations looks and feels bad, and rendering terrain in pure black is not good as, when the camera is angled to view forward, player can still see elevation - very important information in the game and should not be given away without having to explore the map.

Are there any generally accepted ways of implementing such feature?

\$\endgroup\$
1
\$\begingroup\$

Whatever your fog colour is - say black - you should be using simple linear fog to fade into that colour - consider for example how Minecraft does so here, using sky blue:

enter image description here

You can use this in conjunction with other aspects like colouring the base terrain with your fog colour. You could also have fog-coloured objects constantly drifting in front of distant terrain, like banks of thick fog, heavily obscuring what is there. So in the image above, the cloud at the top might totally obscure the top of that tree... and if there were more of them, they would obscure parts of the mountain as well. Doing this efficiently may be challenging if you want to use transparency, but will be simple if you use solid fog banks. (Easiest on desktop / consoles.)

I suppose if you don't want the player to know elevation information, you can either create flat decoy planes in far off locations, or you can randomise terrain there, or make subtle modifications to the actual terrain forms so that the player may think they know what's there... but actually don't.

Lastly you could blur the skyline using a fragment shader to further obscure distant elevations.

\$\endgroup\$
5
  • \$\begingroup\$ Doing it efficiently this way will be additionally tricky as I don't have fog of war at distance from camera, rather dozens of objects, but I could cache part by part and fade out the fog to mask slow recalculation... \$\endgroup\$
    – Mirac7
    Apr 4 '16 at 9:16
  • \$\begingroup\$ Hmm. Have you considered alpha testing to do a form of obscurance - example being the tree leaves on left of image? It's expensive on mobile / tile-based renderers, but for desktop and console it's cheap and you can place these stippled planes however you wish to get a kind of cheap alpha. They used this a lot in older games when true alpha was prohibitively expensive. \$\endgroup\$
    – Engineer
    Apr 4 '16 at 9:26
  • \$\begingroup\$ Seems to me no matter how you look at it, you have to either make fog and sky colour same - and then have ground fade to black toward the horizon (vertex colouring will do here) - or find a way to transition between them in such a way that obscures elevation information, such as heavy fragment-level blurring of the horizon. \$\endgroup\$
    – Engineer
    Apr 4 '16 at 9:28
  • \$\begingroup\$ Not really sure how would implementation with alpha testing work... The problem with making fog and sky the same colour is that I have a dynamic sky dome (primarily for stuff like water reflections) and fragment-level blurring would either look blocky or would be expensively calculated as player changes zoom level... I might be wrong on this one \$\endgroup\$
    – Mirac7
    Apr 4 '16 at 10:35
  • \$\begingroup\$ Alpha stippling is just cheap, in case you are going mobile. Mipmaps + depth have been used on e.g. iPhone 4 as a cheap blurring mechanism rather than fragment blurring. As for your skydome - well it's adapt or die, isn't it? Depends how badly you want this to work ;) Hopefully some of what I've said here will trigger other ideas for you. \$\endgroup\$
    – Engineer
    Apr 4 '16 at 11:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.