Major shadow rendering techniques

Discussion in 'General 3D Technology' started by Reverend, Apr 23, 2003.

  1. Reverend

    Banned

    Joined:
    Jan 31, 2002
    Messages:
    3,266
    Likes Received:
    24
    After some discussion with Ubisoft re Splinter Cell, we (i.e. me and my Ubi contact/programmer) agree on the following :

    Given the current generation of hardware, and the way "forward" as suggested by these hardware and the hype generated by (1) above, I was wondering what folks here has to say about the pros and cons of each and every technique listed above.

    Note that this discusson can be related to lighting algorithms, which Kristof suggested to me in a separate internal matter, like quad-lighting.

    PS. Don't ask me what shadow technique (as well as other 3D tech) Splinter Cell 2 would be using... coz, well, I can't tell :)
     
  2. pcchen

    pcchen Moderator
    Moderator Veteran Subscriber

    Joined:
    Feb 6, 2002
    Messages:
    2,705
    Likes Received:
    73
    Location:
    Taiwan
    Just some major points:


    Stencil shadow volumes

    Pros: robust (with Carmack's reverse and infinite planes), simple to implement, widely supported by display hardwares (requires only stencil buffer)

    Cons: eats lot of fillrate (except for tilers), hardware accelerated shadow volume generation is complex or slow, hard edges, handles geometry only (no alpha textures)


    Shadow buffers

    Pros: simple to implement, hardware accelerated (few or no CPU intervention), can mimic soft shadows

    Cons: not so robust, requires special hardware support, need different kind of textures for different kind of lights (directional vs point)


    (non-prioritized) projected shadows

    Pros: hardware accelerated (few or no CPU intervention), can mimic soft shadows

    Cons: not robust, need different kind of textures for different kind of lights (directional vs point)
     
  3. Ostsol

    Veteran

    Joined:
    Nov 19, 2002
    Messages:
    1,765
    Likes Received:
    0
    Location:
    Edmonton, Alberta, Canada
    Does "shadow buffers" refer to projected shadowmaps that that use the z-buffer?
     
  4. Chalnoth

    Legend

    Joined:
    May 28, 2002
    Messages:
    12,723
    Likes Received:
    101
    Location:
    New York, NY
    I just have to say...unless shadow buffers can be used easily to shadow the entire scene, they pale in comparison to stencil shadows. I still think that once DOOM3 comes out, it will quickly become very important to apply shadows to everything (a few games already do it, such as NWN, and it looks fabulous, but DOOM3 will have the circulation required to really get people to see how good global shadowing can look).

    Oh, and Ostol, here's nVidia's white paper on how shadow maps are done on the GeForce3 (and beyond, presumably):
    http://developer.nvidia.com/view.asp?IO=hwshadowmap_paper

    It appears that the technique uses a texture as sort of a second z-buffer for the shadow mapping.
     
  5. Ostsol

    Veteran

    Joined:
    Nov 19, 2002
    Messages:
    1,765
    Likes Received:
    0
    Location:
    Edmonton, Alberta, Canada
    Ah. . . that's what I thought. . . Strange that Splinter Cell only uses this for NVidia cards since the Radeon 9500 and up support it, too. . . *shrugs*
     
  6. Rodéric

    Rodéric a.k.a. Ingenu
    Moderator Veteran

    Joined:
    Feb 6, 2002
    Messages:
    3,942
    Likes Received:
    791
    Location:
    Planet Earth.
    AFAIK you can use shadow maps to shadow everything just like you use the inefficient shadow volumes.

    Anyway as long as it works almost ok.

    I don't see the point of having say... PIKMIN with a global shadowing scheme.
    :lol:
     
  7. ERP

    ERP Moderator
    Moderator Veteran

    Joined:
    Feb 11, 2002
    Messages:
    3,669
    Likes Received:
    47
    Location:
    Redmond, WA


    There was a Siggraph paper last year "Perspective shadowmapping" that addressed the whole scene issue. Shadow maps have a lot to recommend them from a hardware implemention and performance standpoint.

    Stencils IMO offer a better overall solution but at a significant cost, they provide a pixel accurate determination of lit/non-lit in screen space rather than lightspace which prevents some of the potentially horrid aliasing that can occur.

    Moving forwards I think you'll continue to see variations on both approaches, there are ways to extend both to provide approximate soft shadows, which makes more sense is going to be dependant on the application for a while to come yet.
     
  8. nAo

    nAo Nutella Nutellae
    Veteran

    Joined:
    Feb 6, 2002
    Messages:
    4,324
    Likes Received:
    89
    Location:
    San Francisco
    Unfortunately PSM introduces new problems with lights behind the camera..
     
  9. Colourless

    Colourless Monochrome wench
    Veteran

    Joined:
    Feb 6, 2002
    Messages:
    1,274
    Likes Received:
    30
    Location:
    Somewhere in outback South Australia
    Under DirectX 8 ATI cards do not support texture formats with high enough Bit Depths to do Shadow Buffering. In DirectX 9 though they could use the D3DFMT_R32F format on ATI cards, in theory, of course that format doesn't support filtering. Otherwise they might be able to use D3DFMT_G16R16 if it has high enough precision.

    This assumes they are doing shadow buffering how I think they would be doing it.
     
  10. ERP

    ERP Moderator
    Moderator Veteran

    Joined:
    Feb 11, 2002
    Messages:
    3,669
    Likes Received:
    47
    Location:
    Redmond, WA
    Agreed, but given the benefits of being able to use a single shadow map for your entire scene, the cost of solving them is acceptable IMO.
     
  11. Ilfirin

    Regular

    Joined:
    Jul 29, 2002
    Messages:
    425
    Likes Received:
    0
    Location:
    NC
    First, both shadow volumes and shadow buffers/shadow mapping cause shadowing on/from all objects, so they are a rather apples to apples (in this regard, atleast) comparison.

    Shadow volumes are slow, nasty, and rather ugly. They don't scale well at all with polycounts, eat up precious CPU cycles (it's still usually much better to do the calculations on the CPU than in the vertex shader) and have tons of little subtleties (shadow popping, don't work *correctly* on transparent and translucent textures, etc). And the solution [to shadowing] is far from elegant (IMO of course).

    Shadow buffers/Shadow mapping (I'm assuming the general card-independent algorithm, regardless of hardware support), on the other hand are a very conceptually elegant solution (.. IMO again), they do scale well with polycounts, and they do work with transparent textures. The problem, of course, being that they have aliasing problems and that you might end up using 2 or 3 different texture types (paraboloid, dual-paraboloid, planar) and thus 2 or 3 different shaders for the different types of lights (point, hemi-spherical, spot, and directional). The latter only really affects the programmer's work-load, so that's neither here nor there. For the former, there exists several methods of cutting down on aliasing problems (perspective shadow maps, PCF, super-sampling, and of course just upping the texture resolution), some of which have their own side-effects as well.

    The last 2 methods are either not real-time, or static/hacked and thus who cares?

    Out of those, I would personally choose (2) now. I used shadow volumes for about a year (when they were the only real option, as hardware shadow mapping was just becoming available and it really sucked then), and can honestly say I absolutely hate them :)

    The choice "more" people are going with for 'going forward' wasn't listed at all though, and that's spherical harmonic based radiance transfer (which, according to the Sweeney interview on FiringSquad, is what the new Unreal engine is doing). I personally am not too fond of SH shadowing (which seems to be everyone else's obsession with them). I would rather just use shadow buffers with a DoF blur to get some rather nice aestheticly correct soft-shadows (the quality is completely dependent on how you do your blurring, of course) and use the SH's for surface-local, arbitrary BRDFs maybe with a surface-scattering term. Then you can get really really really nice, physics-based lighting, with rather nice, robust soft-shadows and none of the 'no deforming models', or multiple shadows convultion problems and such. And also, if you're using shadows as a gameplay mechanic, you really don't want SH's overly softness because then there's no where to hide (unless you limit yourself/stealth to purely dark areas).
     
  12. Hellbinder

    Banned

    Joined:
    Feb 8, 2002
    Messages:
    1,444
    Likes Received:
    12
    Slightly OT.

    I just bought a PS2 yesterday and rented a few games. The Best of which is Tribes 2 Areal Assult. (i also got the lan adapter ;) ).

    This topic fits right in to what i was pondering yesterday. What kinds of Shadow support is the EE/GS of the PS2 capable of? Probobly projected shadows for sure.. But what about. Stencil shadows or the other methods? Is a Doom-III style dynamic shadowing possible?

    btw, what method does Splinter cell for PS2 use?
     
  13. Reverend

    Banned

    Joined:
    Jan 31, 2002
    Messages:
    3,266
    Likes Received:
    24
    From Splinter Cell's v1.2 patch readme :
    Basically, Splinter Cell is using a lot of single texturing (with color) for the shadow effects. In shadow buffer mode, rendering is from the light point of view with Z/Stencil only (well not exactly true, alpha and even color sometime for full and partial color transparency).
     
  14. Ilfirin

    Regular

    Joined:
    Jul 29, 2002
    Messages:
    425
    Likes Received:
    0
    Location:
    NC
    Right, but the technique itself isn't exclusive to nVidia cards (just elaborating on someone else's earlier post).

    In DX8* & 9 you can simply render the scene from the light's point of view and write the depth to a texture (i.e. calculate depth in the vertex shader and interpolate it to the pixel shader, that then writes it to a texture). All the extra 'crud' will be rejected by the depth and alpha tests, leaving you with the functional equivalent of the depth buffer from the light's POV (ala nVidia's implementation). You would then use this texture just as you do the texture that results from nVidia's 'depth buffer render target' implementation. In principle you are doing pretty much the exact same thing (at least I believe so, but I admit I'm not too familiar with the internals of nVidia's implementation), just nVidia's method is faster, theoretically nicer and comes with automatic PCF.

    *While doing a vanilla render-to-texture in DX8 would have really bad precision artifacts, you can pack the depth info into multiple channels to achieve higher precision.

    ATi has demos of all this (both with the multi-channel packing (DX8.1) and with DX9 high-precision formats) at their public developer site.



    And Hellbinder, the PS2 excels at rendering untextured polygons, ala shadow volumes. So yes, it can. Lighting is another issue, of course.
     
  15. nAo

    nAo Nutella Nutellae
    Veteran

    Joined:
    Feb 6, 2002
    Messages:
    4,324
    Likes Received:
    89
    Location:
    San Francisco
    that's the main point to me, without PCF it is quite fugly, imho.

    Unfurtunately PS2 has no stencil buffer support, but that can be emulated with a standard color buffer. The real problem is that ps2 cannot do lessthanequal ztest , so in order to perform stencil shadows ala carmak's reverse you have to reverse the zbuffer. Zbuffer reversing cause slighty errors and that introduces artifacts.

    ciao,
    Marco
     
  16. Ilfirin

    Regular

    Joined:
    Jul 29, 2002
    Messages:
    425
    Likes Received:
    0
    Location:
    NC
    Yes, but you can also do manual PCF in the pixel shader (as Ati's demo also does). Granted it's a lot slower..
     
  17. fresh

    Newcomer

    Joined:
    Mar 5, 2002
    Messages:
    141
    Likes Received:
    0
    The PS2 can do projected shadows, stencil shadows and at the recent devcon they showed how you can even do shadow maps. We use stencil shadows w/ inverted zbuffer and they work great for us.

    SH's are nice. Haven't looked into how to deal with deformable objects though (skinned characters for example).
     
  18. Humus

    Humus Crazy coder
    Veteran

    Joined:
    Feb 6, 2002
    Messages:
    3,217
    Likes Received:
    77
    Location:
    Stockholm, Sweden
    (1) Stencil shadow volumes has one advantage, being pixel perfect, but has loads of disadvantages. Will most likely not be used in Carmack next engine after DoomIII.
    (2) Simple, elegant, scalable and efficient. It has only one disadvantage, the aliasing problem, which there are solutions to.
    (3) Shadow projectors can be quite useful for the restricted cases to which it applies, and gives soft shadows more or less automatically. Being static except for simple rotations etc. though it's fairly restricted.
    (4) Will most likely never be particularly useful for realtime.
     
  19. Humus

    Humus Crazy coder
    Veteran

    Joined:
    Feb 6, 2002
    Messages:
    3,217
    Likes Received:
    77
    Location:
    Stockholm, Sweden
    For range limited lights (that is, most lights in games), 8 bits can get you fairly far. More than 16 bits are useless for shadow mapping.
     
  20. Nick[FM]

    Regular

    Joined:
    Feb 8, 2002
    Messages:
    527
    Likes Received:
    7
    Location:
    Helsinki
    Hmm.. Are there any tech demos which use Perspective Shadow Mapping? I have got the impression that it is very good looking, and the performance is good too.. I'm not so into this stuff, so maybe I just stay quiet! :wink:

    But a tech-demo or something would be nice..
     

Share This Page

  • About Us

    Beyond3D has been around for over a decade and prides itself on being the best place on the web for in-depth, technically-driven discussion and analysis of 3D graphics hardware. If you love pixels and transistors, you've come to the right place!

    Beyond3D is proudly published by GPU Tools Ltd.
Loading...