Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


3d fog of war using multipass shadow mapping


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 invutil   Crossbones+   -  Reputation: 1925

Like
0Likes
Like

Posted 08 June 2013 - 12:12 AM

I want to make an RTS that will use BSP maps where units can go up/down stairs and underground. I have an idea for 3d fog of war that would show only what is within the player's units' line of sight. Each unit would be treated as a point source of light and a depth map created from its point of view.

 

How many units could I support if I did a pass for each unit? How would I do the multipass? Redraw to texture each time and pass in the texture from previous pass and choose the brighter pixels of the two?



Sponsor:

#2 MightTower2   Members   -  Reputation: 226

Like
0Likes
Like

Posted 09 June 2013 - 06:24 PM

I would guess it depends how complex your scenes are or how much time it takes to render it once...
And which technique you want to use? Because I think to render everything 6 times for one unit (like with standard cube shadow mapping) could be very slow when you have some units.

Generally I would think it could be too slow but I am not an shadow mapping expert (just implemented a naive shadow mapping algorithm which renders everything 6 times).
Would be nice to hear if and how you implemented this idea.

 



#3 invutil   Crossbones+   -  Reputation: 1925

Like
0Likes
Like

Posted 09 June 2013 - 09:43 PM

Wonder how many units this supports http://forum.unity3d.com/threads/146697-Tasharen-Fog-of-War

There will be a slider to adjust to what height the map is drawn so you can see inside buildings. And everything that's not visible to the player's units (according to the depth maps) will be drawn transparent without texture. There will be holes in the floor/ceiling where staircases will go and openings in the walls/windows for shooting.

Each unit will be a spotlight with only one depth map. On each pass I will determine the pixel coordinates in the vertex shader to where it's drawing (varying vec4 that will be interpolated in the fragment shader) so that I can determine with which texel from the passed texture from the previous pass to compare which pixels are brighter. In these passes only the depth will be drawn. The textures will have to be 1024x1024 or 2048x2048 so a ratio will need to be passed of the scale between the viewport dimensions and the texture. Or maybe it's not needed, given glViewport and a projection matrix (maybe the ratios are only needed for the final pass to the screen). So it may be stretched or blurry. But this is only the visibility map and the final pass (with textures and all effects) will be for the whole screen.

So for each unit there will be a pass to draw its depth buffer from its point of view and one pass from the player's point of view to compare which pixels are in the visibility buffer (screen).

Switching render buffers frequently may affect the frame rate so I'll combine the depth maps into one or more textures by using glViewport to draw to a specific region. A 1024x1024 map will give 16 256x256 depth maps and a 2048x2048 will give 64. There has to be enought detail for them to see through slits in the wall of bunkers or something to shoot from.

One problem though is how to programmatically determine visibility, so that I know that a unit should pursue an enemy or shoot it.

Also, might be improved by deferred lighting but I don't know how.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS