Twitter  Facebook  YouTube  E-Mail  RSS
The One Man MMO Project
The story of a lone developer's quest to build an online world :: MMO programming, design, and industry commentary
Shroud Rendering
By Robert Basler on 2016-05-03 01:52:55
Homepage: email:one at onemanmmo dot com

The first time I played Miranda with the shroud rendering enabled I was surprised by how much scarier the game had become all of a sudden. Now I was wondering what was in the dark just beyond the line of sight of my tanks.

[The Shroud and Minimap]

I understand why none of the modern RTS games I looked at have an old Command & Conquer style shroud. If you look at those games, the shroud was a black 2D overlay over the terrain with nice soft edges, and the camera was at a fixed angle and distance above the terrain and shroud. As units go under the shroud they fade from view, and if units are shooting out from under the shroud, you can see their weapons. With Miranda's mobile camera, and 100m tall buildings and huge cliffs, I spent a lot of time trying to figure out how to reproduce all those effects.

The natural place to start is rendering the 3D shroud to a texture, blurring it to give soft edges, and then compositing it with the rendered scene. This idea fell apart as soon as I realized that with Miranda's mobile camera it was entirely possible for units on a hill to be in front of a shrouded area where the blurring would incorrectly cover them. In the end I had to give up on the idea of soft edges on the shroud, but I was able to retain everything else including the ability to have units disappear beneath the shroud, and fire from within the shroud. The shroud is rendered sort of like putting a black shoebox upside down over the terrain. It is a black box just tall enough to hide all the units and terrain props on the shrouded terrain. I also made the shape of the shroud follow the terrain, so the horizon line retains its original unshrouded shape.

Spending a lot of effort to render the terrain and units only to cover them with solid black seems on the face of it to be a little wasteful. I had read that graphics cards will optimize rendering by not processing pixels if there are already pixels rendered closer to the camera based on the depth buffer. Since I need to render the entire scene beneath the shroud to properly handle the edges, I decided to test the benefits of this optimization by rendering the shroud first on the premise that most everything else should be able to be skipped. Unfortunately, I could see no appreciable performance difference drawing the shroud first.

Later I may revisit the 3D shroud rendering to smooth out the jagged edges. I also discovered that line-of-sight dimming which is quite common in modern RTS's is really easy to implement, you just draw a sphere around the unit with the same radius as the visibility radius and render that as white to a bitmap initialized to black. Then you composite that bitmap with the scene, converting to greyscale anywhere the mask bitmap is white. Classic C&C doesn't have line-of-sight dimming, so I won't be adding that for now.

The last part of implementing the shroud was blacking out the 2D world map and minimap. Most of the effort there was figuring out how to access the massive amount of data that makes up the shroud in a timely manner every frame. Luckily the shroud changes quite slowly so the whole shroud is read and converted to a high resolution greyscale bitmap at startup, then I use a simple delta system to update only the part of the bitmap where the map shroud has changed. To generate the final map I just pick out whatever subsection of the whole map I need.

[There's a whole lot of map left to discover!]

Next I'm moving on to server load simulation, performance optimization and scaling.

New Comment

Cookie Warning

We were unable to retrieve our cookie from your web browser. If pressing F5 once to reload this page does not get rid of this message, please read this to learn more.

You will not be able to post until you resolve this problem.

Comment (You can use HTML, but please double-check web link URLs and HTML tags!)
Your Name
Homepage (optional, don't include http://)
Email (optional, but automatically spam protected so please do)
Multiply: 2 and 6 = (What's this?)

  Admin Log In

[The Imperial Realm :: Miranda] [Blog] [Gallery] [About]
Terms Of Use & Privacy Policy