Sign in to follow this  
evanofsky

Half-Life 2 Shadows

Recommended Posts

I'm curious- how does half-life 2 handle dynamic shadows? I can tell it uses shadow mapping, and that only shadows from the sun are computed. But my question is, does hl2 render a shadow map for each object from the direction of the sun, or is it one huge shadow map? Or is it some other method I haven't heard of yet?

Share this post


Link to post
Share on other sites
Whats there not to understand? it renders a shadow map for each object and then projects it onto the respective polys. so there is a shadow map for each object, (or maybe not every instance but just every type, ie Terrorist, and it reuses that multiple times, i dont know)

disclaimer: i dont know any of this for SURE, but im pretty sure

hope that helps
-Dan

Share this post


Link to post
Share on other sites
well, you can turn on a cvar to show shadow ids, (they appear as numbers over the shadows), so i assume theyre being rendered seperately.

Share this post


Link to post
Share on other sites
Its not shadow maps per se. Each seems to be rendered separately for characters without any self shadowing and only part of the world seems to be receiving the projection of the shadow. In one location a combine was on the stairs but the shadow was projected through the steps and onto the world below (stairs weren't shadowed).

I think they render a separate one for each character because some of their levels can have multiple lights in close proximity, which is handled by lightmaps for the world and then the shadow is rendered for the closest light or averaged between two (guessing here, didn't watch for the effect).

It looks like shadow mapping but I dont think thats what they would use because the world doesn't cast shadows (all precomputed lightmaps). I think they are rendering the character to a texture (untextured and gray) from a light source or some average of and then projecting that texture on the world. This would help explain how self shadowing isn't possible in the engine.

HTH


Share this post


Link to post
Share on other sites
Quote:
Original post by nts
Its not shadow maps per se. Each seems to be rendered separately for characters without any self shadowing and only part of the world seems to be receiving the projection of the shadow. In one location a combine was on the stairs but the shadow was projected through the steps and onto the world below (stairs weren't shadowed).


Yes, if you play CS:S there is alot of shadows appearing on the wrong side of solid objects, its one of my pet hates with the engine. It looks great and all but the shadows can ruin it at times [rolleyes]

Share this post


Link to post
Share on other sites
I think it uses something called texture shadows that is used in alot of games for character shadows. Basically all objects have a texture that has a shadow rendered onto it and that then is projected onto the world. This technique is used in Ogre for example. It has some limitations like no self-shadowing and (at least in Ogre) shadowscasting objects can't recieve shadows.

Not 100% sure about this though so please correct me if I am wrong.

Share this post


Link to post
Share on other sites
I'd be interested to hear how they look on older ATI cards (ones that have neither depth textures nor floating-point textures).

Share this post


Link to post
Share on other sites
They don't use shadow mapping if you by "shadow mapping" mean what is commonly understood i.e a projected texture that contains depth values. They just render each dynamic object in all black as seen from the view of the sun into a texture and project that. Just bog standard cookie-cutter projected shadow textures. As seen in countless PS2 games for example.

Share this post


Link to post
Share on other sites
speakin of game shadows.
does anyone know how blizzard makes the shadows in world of warcraft?
i mean the big ones, casted by trees and buildings, not the character shadows which are weak.

shadow maps as well?
thanks

Share this post


Link to post
Share on other sites
Quote:
Original post by HardguyThis technique is used in Ogre for example. It has some limitations like no self-shadowing and (at least in Ogre) shadowscasting objects can't recieve shadows.


Why doesn't Ogre allow self shadowing anyway? The "basic" shadow mapping algorithm allows for self shadowing..

Share this post


Link to post
Share on other sites
Quote:
Original post by ehmdjii
...does anyone know how blizzard makes the shadows in world of warcraft?
i mean the big ones, casted by trees and buildings...


They look to me like prerendered lightmaps. The sun changes and I think the shadows change, but thats just too much geometry to be dynamically drawing shadows all the time. Plus its static.

Share this post


Link to post
Share on other sites
If the objects in question aren't animated, couldn't they use prerendered shadowmaps? i.e. a projected texture that is an 'accurate' shadow for a given range of light directions. If they set up three or four per building they could just fade between them as the time of day changes.

Share this post


Link to post
Share on other sites
A problem with projected shadows (at least the way hl2 does it) is this:

2 objects close together wil re-shadow the area they were projected onto. Is there a way to remedy this?

Share this post


Link to post
Share on other sites
>> Is there a way to remedy this?

In the source engine or your own program?

If you want to fix it in game.... well, cross your fingers and hope that valve releases a patch for it, which is unlikely. Shadowing is a major component of any engine that includes it, and patching/correcting after the fact would be dodgy.

If your curious about correcting this effect in your own programs, of course you can! Easiest method: Don't use this type of shadow. Both Shadow Volumes and Shadow Maps give good results, and follow logic that helps correctly shadow ANY surface as long as the render pipline is set up correctly.

Share this post


Link to post
Share on other sites
This is easy to fix if you light properly. I use rendering black objects onto white backgrounds without this double-darkening effect.

The key is to do additive lighting instead of subtractive or multiplicative shadows.

Start with ambient, then calculate shadows for the 1st light, either to dest alpha or stencil, then calculate light for 1st light, only adding it where shadow is not marked.

Share this post


Link to post
Share on other sites
So HL2 is not using true shadow mapping ever? Or is it only on the cheaper paths where they use projected texture shadows?

Share this post


Link to post
Share on other sites
Quote:
Original post by Promit
So HL2 is not using true shadow mapping ever? Or is it only on the cheaper paths where they use projected texture shadows?

I wonder about that, too. To me it occured as if the shadows were pretty much correct (e.g. including self-shadowing). In my settings all options including shadows and shader detail are maxed out (got a semi-decent fully DX9 compatible Radeon).
I *guess* the artifacts stem from the sub-optimal rendering path, but maybe I just didn't look too closely at the shadows [wink].

Share this post


Link to post
Share on other sites
Quote:
Original post by Hardguy
I think it uses something called texture shadows that is used in alot of games for character shadows. Basically all objects have a texture that has a shadow rendered onto it and that then is projected onto the world. This technique is used in Ogre for example. It has some limitations like no self-shadowing and (at least in Ogre) shadowscasting objects can't recieve shadows.

Not 100% sure about this though so please correct me if I am wrong.


I'm not certain... The shadows here, in Ogre's shadow demo, are stencil shadows, not shadowmaps.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Ogre supports additive stencil (like Doom3, self-shadowing and multi-light accurate), modulative stencil (Neverwinter Nights, self-shadowing but not multi-light accurate) and fixed-function projective texture shadows (no self-shadowing, not multilight accurate). Each has it's own benefits and trade offs.

The reason for not using shadow maps out of the box is that they require shaders to be applicable to all hardware / APIs. For example, on GL there is a shadowmap extension, but on DirectX there is no non-shader standard; merely the 'magic' nVidia depth texture support and nothing on ATI without shaders. Due to time constraints we supported the biggest user base by supporting fixed function with the option for the user to supply custom shadow caster / receiver shaders if more advanced effects were required (with the inherent minimum card requirements).

Share this post


Link to post
Share on other sites
I'm using a Radeon 9700, and my settings are on high for everything. It actually occured to me that the metal sheets I used to check might not cast very sophisticated shadows so I tried using the airboat placed on top of the car, but the artifact was still there. I suppose in-game this is less noticable, because 2 shadow casting objects rarely get into a position where their shadows are cast onto the same surface. Still, it seams like a bit of a cheap effect, which makes me wonder whether it is due to my graphics card. If anyone is running HL2 on something more substantial than a 9700 they could clarify...

Share this post


Link to post
Share on other sites
It happens on my Geforce 6800 (In half life 2), and it happened in their demonstration before they released the game, it's a limitation of the engine I think.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this