Jump to content
  • Advertisement
Sign in to follow this  
BlueTomato

OpenGL Shadows like in The Battle for Middle-earth?

This topic is 4865 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am working on an action game with lots of small units on screen at any time, in a topographical landscape that can be scrolled in all directions, much like the typical 3D RTS game. I really like the Sage engine that powers Command and Conquer: Generals and The Battle for Middle-earth. It is quite similar to what I need graphics and speed wise in my own engine. I am trying to figure out what kind of shadow algorithm is powering these games. The self shadowing works great, and the shadows are in high resolution. Yet, it is really very fast. The high resolution shadow edges suggests no shadow mapping is used. But for a game with that many units on-screen at a time, stencil shadows should be too slow? Hmmm? Anyone know what technique they might have used, and how it works? Or of any other technique that can be used for accurate (self) shadowing of a large number of units in a scrolling landscape? My camera will always be pointing in the same angle, and the light source too, if that helps. I am using OpenGL.

Share this post


Link to post
Share on other sites
Advertisement
Actually, I can almost garantee that they are using shadow mapping. Stencil shadows would be WAY too expensive to perform on that many units.

As for how they got those clean shadows, I would imagine they use PSM, TSM, or something very similar.

Share this post


Link to post
Share on other sites
Well this is not my area of expertise at all, but if the camera doesn't move and the lights don't move, can you pre render the shadows then just project them onto the groud (if the ground is not flat) if the ground is flat, then you could use some decal. Just ideas, I haven't done anything with shadows but if you could pre render the shadow to a texture then just apply texture via projection or just on the flat land.

-THACO

Share this post


Link to post
Share on other sites
Looking at some screenshots, it looks like a mix of techniques is used. Stencil shadows are used for large creatures and some structures, while smaller units simply have one or two darker patches blended under their feet.

Share this post


Link to post
Share on other sites
Quote:
Original post by MumbleFuzz
Looking at some screenshots, it looks like a mix of techniques is used. Stencil shadows are used for large creatures and some structures, while smaller units simply have one or two darker patches blended under their feet.


Yes, I agree with MumbleFuzz.
And I think it's a pretty good way to render shadows in a RTS

Share this post


Link to post
Share on other sites
Quote:
Original post by MePHyst0
Quote:
Original post by MumbleFuzz
Looking at some screenshots, it looks like a mix of techniques is used. Stencil shadows are used for large creatures and some structures, while smaller units simply have one or two darker patches blended under their feet.


Yes, I agree with MumbleFuzz.
And I think it's a pretty good way to render shadows in a RTS


Sorry, then the game is a bad example of what I want to achieve. I really want a method that is fast enough for proper shadows for all units.

A better example is Age of Empire 3, like this screenshot suggests:

http://www.gamespot.com/pc/strategy/ageofempiresiii/screens.html?page=19

Any idea how they manage to get these kinds of fast and accurate shadows for both scenery (trees etc), and even the tiniest units?

From what I have read about their engine, it scales really well even on slow computers...

Share this post


Link to post
Share on other sites
I'm going to venture to say the shadows in AOE III are perspective shadow maps (or a similar technique). Reasons:

- a lot of geometry + tree leaves casting shadows = not stencil shadows
- shadows look pretty sharp and have a near pixel perfect precision everywhere = not standard shadow maps
- shadows are not blurry, and are applied to dynamic entities = not lightmaps
- shadows that overlap are not darker = not projected textures
- generally a single, directional light source = best case for perspective/light-space shadow maps

Y.

Share this post


Link to post
Share on other sites
Quote:
Original post by Ysaneya
I'm going to venture to say the shadows in AOE III are perspective shadow maps (or a similar technique). Reasons:

- a lot of geometry + tree leaves casting shadows = not stencil shadows
- shadows look pretty sharp and have a near pixel perfect precision everywhere = not standard shadow maps
- shadows are not blurry, and are applied to dynamic entities = not lightmaps
- shadows that overlap are not darker = not projected textures
- generally a single, directional light source = best case for perspective/light-space shadow maps

Y.


I am not so familiar with the details of this technique, but would it not require support for very large texture maps to get a aliasing free appearance in such a high resolution image?

Any OpenGL tutorials on how to implement this around?

Thanks

Share this post


Link to post
Share on other sites
Quote:
Original post by BlueTomato
I am not so familiar with the details of this technique, but would it not require support for very large texture maps to get a aliasing free appearance in such a high resolution image?

Any OpenGL tutorials on how to implement this around?

Thanks


No, because unlike standard shadow maps, perspective shadow maps take into account the camera space. You're getting (under good conditions) close to pixel perfect shadows with a single 1024x1024 texture.

There are a few cons to perspective shadow maps though (at least what i've heard, as i haven't implemented them myself). Handling omni lights is tough (which doesn't matter in a RTS since the only light casting shadows is a directional one: the sun light). Because the perspective shadow map projection takes into account the camera frustum, you must update the shadow map every frame. Finally, it's not a technique easy to implement, and the quality of the shadows depend on the camera and light direction. I think an RTS with generally a top-like view, is one of the rare "good" situations for perspective shadow maps.

I'm not aware of any OpenGL tutorial implementing it, but i know there are a few papers floating around, and NVidia has on its developer site a demo with source code for Direct3D.

Y.

Share this post


Link to post
Share on other sites
There are a couple of examples of standard shadow maps around, but i've never seen one for any of the other types... I've a feeling that one of the GPG books might have something on it however...

edit:
and I was right;
Game Programming Gems 4 : Section 5.3 - Perspective Shadow Maps

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!