Fog of War

I assume you will have multiplay in your strategy game? If you will, then you might want to consider this - you do not want to give your clients data about the objects that are out of the player's field of view anyway... What if the client gets hacked? They could make a game where all the objects that have not been discovered or are out of the view range are still rendered, giving them an advantage.

I've thought about this as I certainly want to have multi-player support.

Suppose unitB (from another player) is in the 'Fog of War' so that unitA cannot see it. First, the location of unitB would not even make it to A's client unless  unitA had line of sight to unitB. My Fog of War implementation is going to be based on the facing of a unit, and not a radius like so many RTS games have. This way, even if somehow a hacked client were made, the line of sight check must still be validated on the server side before that player can know where a unit is.

I'd vote for 4 which is probably why kev is asking about glFogcoords in another thread :slight_smile:

How did you you decide that a shader was the correct way of doing fog of war

By looking at tons and tons of threads about the topic. It would be tedious for me to track down every source that I found, but I found most of my sources from Here are just a few:

On this one, do a search for 'fog of war'.!3D9ECAE1F2DC56EF!238.entry

Again, there are different ways to implement 'Fog of War' as you'll see in the above URLs. Rendering to texture, volumetric fog, and shaders. For the effect that I'm after, I'm thinking shaders is the correct way to go.
Ooops, sorry, didn't mean that to come off as "justify your statements!

Hehe, no problem or offense taken. I'm happy to share my findings. Hopefully a 'Fog of War' feature can eventually make its way into the jME API, as 'Fog of War' is a key element in any RTS game.

I swear you're a runaway Blizz rep trying to release Starcraft II before Blizz can release it. Then you'll steal all their money.

Do you have any demos so I can play that game?

I tried a few approaches but ended up with a projected texture blended across the scene

Can you elaborate on your solution (i.e., some code examples)?

So do you use only one texture representing the entire map and then blend this texture across the scene? Do you manipulate this texture by setting visible areas (according to unit location) to white?

Awesome! Thank you so much for the code example. This is some good stuff.