Skip to main content
GameDev.net gamedev.net
🔒 Locked

shadowing algo selection

Started by vonsatan Jul 11, 2003 at 9:17 AM 21 replies 2.5k views
Original Post
vonsatan
vonsatan
I''m trying to choose between shadow maps and stencil shadow volumes....any recommendations? ive implemented un-optimised versions of both and they both have their pro''s and con''s. The shadow usage is best compared to an FPS game and I''m after high quality and versitility (targeted at newish hardware).
Blah....
Nik02
Nik02
If you want soft shadows, use shadow maps.
On the other hand, if you want sharp, accurate shadows, use stencil volume shadows.
Niko Suni
Mihail121
Mihail121
At the first look you might think that shadowmaps are slower that the stencil ones.But as soon as you render more objects you''ll notice big decrease with the shadow volumes.Both techiniques require a dual pass rendering.The shadowmaps also require depth buffer reading which is somewhat slow but is performed only once while the stencil testing is performed for
every volume shadow caster.It depends completely on your desires what to choose.I personally prefer the shadow maps.

"You losers better learn...NOONE CONTROLS OUR GOD DAMN LIFE!!!" - MANOWAR
Nik02
Nik02
Using shadowmaps, you don''t necessarily have to read back the z-buffer. Just render the depth in alpha channel, for example, or to another texture, using vertex shader.
Niko Suni
vonsatan
vonsatan
hmmm, well I think i''m leaning towards stencil volumes. Also, ive been looking at the shadowing used in recent and upcoming games and I can''t figure out the technique being used in Half-Life 2 ...any ideas?
Blah....
Retrep
Retrep
This seems to be aiming for a happy middle ground between shadow maps and shadow volumes:

http://graphics.stanford.edu/papers/silmap/

Worth a look, perhaps..
sBibi
sBibi
vonsatan> from the screenshots I''ve seen from half-life2 and the artifacts they have, I''d say they use shadow mapping...
Maximus
Maximus
HL2 uses lightmapping for the world geometry, not sure on what it uses for entity shadowing though.

-----------------------
"When I have a problem on an Nvidia, I assume that it is my fault. With anyone else''s drivers, I assume it is their fault" - John Carmack
-----------------------"When I have a problem on an Nvidia, I assume that it is my fault. With anyone else's drivers, I assume it is their fault" - John Carmack
sBibi
sBibi
Anonymous poster> uh? why a missing shadow would mean one technique is used rather than another one?
I guess you're referring to that image:



there might be some reasons why the weapon hasn't got a shadow... maybe they didn't render weapons when rendering the shadow maps? but look at the "crab" shadows, and their stairs shape, witch is characteristic of low resolution shadow maps (well maybe not that low, but not high enough anyway...), and definitely not of shadow volumes...


[edited by - sBibi on July 12, 2003 9:24:59 AM]
Assassin
Assassin
That image has a few interesting things to note.

On the topic of shadows, the military guy has a shadow that bears the traits of a stencil shadow - sharp edges and per-pixel accuracy - while the shadow of the alien creature seems to be using a shadow map - with the tell-tale texture aliasing visible as "stairsteps". The absence of shadow from the gun is interesting; it must be treated by the engine in a different manner from the person wielding it. In any case, it seems they''re using multiple mechanisms to reach the same end - both stenciled and mapped shadows. I suspect that the aliens might have detachable limbs or something (blow em off!) which would warrant a shadow map technique instead of using stencils, since the mesh precomputation would be invalidated when a limb is separated.

The guy in the background with a big light flashing around him seems to be casting dynamic lightmaps onto the scenery - an interesting but somewhat crude departure from the style of lighting doom 3 uses, which makes use of high-resolution attenuation maps - maybe it is actually an attenuation map just at a really low resolution. In contrast, the guy in the foreground has a nice muzzle-flash graphic but seems to be casting no light onto the scene, as the shadows under himself and the alien creature aren''t from that muzzleflash, and are both very dark.

Quite a telling screenshot, I think!

Also of note is the pillar in the middle of the room - it is flat-shaded, apparently not making use of continuous vertex normals. I''m not sure if that''s a shortfalling of the content-creation pipeline or whether the artist was just too lazy to tie the faces into a smoothing group.

Particles and decals are all over the place, with funny-looking pink & blue things apparently being spewed by the alien getting shot, and bullet marks on the pillar and the creature itself.
Assassin, aka RedBeard. andyc.org
Nik02
Nik02
That pic _really_ from HL2 ?
Oh dear...
Niko Suni
c t o a n
c t o a n
Seriously! Look at the pillar''s texture mapping... It looks as though the textures don''t match especially down near the bottom... Tsk tsk tsk, if they''re trying to promote their engine/game, they might want to release screenshots that have SOME degree of polish... Anyway, I''m looking at the collision detection between the ''dead'' guy next to the active player, and it appears as though their feet are intersecting! I have to say though, just looking at their player/creature models, they seem somewhat anti-aliased or something? Looks pretty nice!

Chris Pergrossi
< ctoan >
My Realm
Chris PergrossiMy Realm | "Good Morning, Dave"
vember
vember
It could be a possibility that they''re using a seperate shadow-map for each dynamic object in that screenshot (for each light). That could explain that you see the staircase effect on the alien but not the human, since the aliens shadow cover a much larger area, if the maps were sampled at the same resolution.
sBibi
sBibi
vember> yes, that''s also what I thought of, and if you look carefully at the dead player''s shadows, you''ll see some staircase effect that doesn''t seem to be dued to simple pixel aliasing... so I doubt a bit about shadow volumes...

assasin> I''m OK with almost everything you said, apart 2 things, first the stencil shadows (I''m not too sure about thatone), and then the pillar...
why a pillar like that would necessarilybe absolutely round and smooth??
There are many places near where I live that have pillars like that, with flat edges, like decagons or whatever... and the artists probably didn''t want it to look smooth... it looks nice to me
and for the textures.. mmh maybe it''s exactly the same thing... but it''s right they seem to lack too much connectivity between each other, it might look a bit strange... but I find it far less shocking than the heavily aliased lightmap casted by the far away guy, the missing gun shadows, and now that ctoan pointed it out, that collision problem...
mohamed adel
mohamed adel
the presence of aliasing is not a sign of the use of shadow maps.I have made a demo that uses the Shadow volume to find the the shadow of a mesh and when disabeling antialiasing the shadows look aliased and rough.on the other hand when using 4x antialiasing the shadows looks completely soft .(I use anti aliasing or disable them from the vga driver).

there are two bottle necks in the performance of shadow volume techniqe:
1-The calculation of the silhoute and the shadow volume. This dependce on the following:
I-The number of vertices in the mesh , the no. of meshes you are rendering and the no of lights in the scene.
II-The speed of your processor because the calculation of the silhoute is performed by the processor.
to optimize the the shadow volume calculation you can use one of the following techniques:
a)Calculate the shadow volume once every two or four frames(I have tried this techniqe and It caused the shadow to flicker when the body moves).This technique was mentioned in the article of ("the theory of stencil shadow volumes") on this site.I think it can be used for only slow moving objects.

b)Decrease the no. of Lights that appear in each scene during your level design or choose some lights to calculate their shadows.In doom 3 Shadows are calculated for each light source but the maximum no of lights that appear in one scene is 4 or 5 lights.

c)Decrease the no of vertices or decrease the no of objects and specially characters(due to the calculations required for the change of the shadow volume as the character moves and the tweening required for the shadow volume).In E3 2003 carmack said that he used monsters and demons in doom3 so that you fight a demon or two in each room for some time instead of intering a room and hunt 10 characters because there''s no hardware that can render a big no. of characters with all their shadows and detail.
Also carmak uses a model format MD5 that have a good trick.it contains 1 million normals and only 5000 vertices .this enables him to use the big no of normals to render the characters with very high detail and use the smaller no of vertices to calculate the shadow volume and collision detection and so on.
this is why there''s no screenshots for terrains in doom3.it is impossible to render the shadow of the terrain using the shadow volume with such a big no of vertices used in terrains in modern game engines (unreal 2 for example renders 200000 triangles per frame reduces to 10000 using geomipmapping ).


The second bottle neck in the stencil shadow method is the process of copying the generated shadow volume vertices in the memory.Due to the change of the shadow vomule dynamically the shadow volume vertices are copied in the vertex buffer once per frame.You can optimize the copying of the shadow vertices by placing the veretex buffer in the system memory or the vide card''s memory according to the speed and band width of them. In computers that contain an old vga and a newer system memory the speed and band width of the system memory may be higher than that of the video card''s memory, so the vertex buffer used for the shadow volume should be stored in the system memory in such computers.on Computers with new video cards the video cards memory is always faster and have a higher band width than system memory,so vertex buffer used for the shadow volume should be in the video card''s memory in such computers.

on the other hand the main weak point in the shadow map technique is that it can''t be used for point lights, due to the need for light frustum.also it needs a pixel shader withch is not availble on the old cards (if you want to use it for a game).
but the shadow map performance doesn''t depend on the no of vertices rendered so it can be used for rendering the shadow of the terrain.you can use it to render the shadows for outdoor scenes for directional lights (as when walking in a terrain nder the sun) and use the stencil shadows for indoor scenes that contain point lights.

also shadow maps can be used in rendering soft shadows and changing the shadow darkness according to the distance from the occluder,whith is unavailable in the shadow volume technique.

I am trying a method that I have thought of for the changing the shadow darkness in the shadow volume method.It dependes on rendering the shadow volume with dark color for the verives near the occluder and light color for vertices away from the occluder so the color is interpolated between far and near vertices with darkness decreasing with distance of the occluder.The shadow volumes are rendered to texture each frame and the texture is used for texturing the gray square that is used in stenciling the shadow volume.(note that I have never read about this technique so it may be wrong or not workng,I am still trying to implement it in me shadow demo).
This is all that I know about this subject and the choice is yours according to your engine or your minimum requirements required.
I hope that helps.

sBibi
sBibi
"the presence of aliasing is not a sign of the use of shadow maps.I have made a demo that uses the Shadow volume to find the the shadow of a mesh and when disabeling antialiasing the shadows look aliased and rough"

we weren''t talking about that kind of aliasing...
the shadows aliasing on that screenshot are much more than one pixel per step...
c t o a n
c t o a n
Since you are looking for a way to improve the quality of the shadows in Shadow Volumes, let me point you in the right direction. The way most professional engines perform the ''shadow'' rendering in stencil shadows is NOT to render an alpha-quad over the entire scene, but instead, just DON''T render the pixels where the stencil is > 0 (or however you choose to implement it: pass or fail). Since most scenes will not allow a single section to remain COMPLETELY in the dark, there''s no need to clear the screen to black before rendering, as the geometry in question WILL be within the ''non-shadow'' portion of another light, and will therefore be rendered using the standard attenuation maps and the like. However, if your game (like Doom III) promotes dark and erry places, I would recommend clearing the background to black BEFORE you start rendering (i.e. at the beginning of the rendering cycle). This is FAR cheaper then rendering an alpha quad for each light over the entire scene. I refer to the two methods as additive (which is described here) and subtractive (the ''render an alpha quad over the scene'' method).

Chris Pergrossi
< ctoan >
My Realm
Chris PergrossiMy Realm | "Good Morning, Dave"
Basiror
Basiror
quote:
Original post by Assassin
That image has a few interesting things to note.

On the topic of shadows, the military guy has a shadow that bears the traits of a stencil shadow - sharp edges and per-pixel accuracy - while the shadow of the alien creature seems to be using a shadow map - with the tell-tale texture aliasing visible as "stairsteps". The absence of shadow from the gun is interesting; it must be treated by the engine in a different manner from the person wielding it. In any case, it seems they''re using multiple mechanisms to reach the same end - both stenciled and mapped shadows. I suspect that the aliens might have detachable limbs or something (blow em off!) which would warrant a shadow map technique instead of using stencils, since the mesh precomputation would be invalidated when a limb is separated.

The guy in the background with a big light flashing around him seems to be casting dynamic lightmaps onto the scenery - an interesting but somewhat crude departure from the style of lighting doom 3 uses, which makes use of high-resolution attenuation maps - maybe it is actually an attenuation map just at a really low resolution. In contrast, the guy in the foreground has a nice muzzle-flash graphic but seems to be casting no light onto the scene, as the shadows under himself and the alien creature aren''t from that muzzleflash, and are both very dark.

Quite a telling screenshot, I think!

Also of note is the pillar in the middle of the room - it is flat-shaded, apparently not making use of continuous vertex normals. I''m not sure if that''s a shortfalling of the content-creation pipeline or whether the artist was just too lazy to tie the faces into a smoothing group.

Particles and decals are all over the place, with funny-looking pink & blue things apparently being spewed by the alien getting shot, and bullet marks on the pillar and the creature itself.



just that you know HL uses worldcraft as level editor and worldcraft doesn t support something like smoothing groups

maybe they support bezier patches now but i don t know that
http://www.8ung.at/basiror/theironcross.html

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.