Major shadow rendering techniques

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

  1. nAo

    nAo Nutella Nutellae
    Veteran

    Joined:
    Feb 6, 2002
    Messages:
    4,325
    Likes Received:
    93
    Location:
    San Francisco
    Never done that with a PS, but with the fixed pipe, without PCF it's quite ugly..with a single sample is even uglier.
     
  2. DeanoC

    DeanoC Trust me, I'm a renderer person!
    Veteran Subscriber

    Joined:
    Feb 6, 2003
    Messages:
    1,469
    Likes Received:
    185
    Location:
    Viking lands
    But not at the edges, where you have non-continuous samples. By linear interpolating at polygon edges you create 'virtual' polygons between depth samples. If you have flat poly at d=0 in front of a flat poly at d = 1, the interpolation will create polygons from d=0 to d=1. This will show up as lines that are incorrectly in/out of the shadow.

    The filtering you can get away with on colour data is wildly different from position data (think of a depth map as a heightfield).
     
  3. DeanoC

    DeanoC Trust me, I'm a renderer person!
    Veteran Subscriber

    Joined:
    Feb 6, 2003
    Messages:
    1,469
    Likes Received:
    185
    Location:
    Viking lands
    A pixel is not either in or out of shadow. A pixel has a finite extent (pixels are not infinately small) its possible for some portion of each pixel to be in and another portion out. Percentage closest filtering samples n times in the area of a single pixel and uses the number of samples in shadow to weight the light intensity. Its super-sampling on the results of shadow samples and is fine in sampling theory (its push the frequency that aliases higher).

    Linear filtering should only occur where linear reconstruction is a reasonable approximation to the original infinitely high resolution version. Most people don't mind a linear reconstruction of RGB data (but its wrong HSV is better perceptually) but linear reconstruction of position data produces weird artifacts that will cause visible artifacts in the final image.

    Image based rendering (of which shadow-maps is related) has spend alot of time and research working out how to anti-alias position data.
     
  4. JohnH

    Regular

    Joined:
    Mar 18, 2002
    Messages:
    586
    Likes Received:
    2
    Location:
    UK
    Aren't there cases where aliasing cannot be fixed without the use of high resolution shadow buffers, for example consider a large scene viewed from a distance such that the shadow should be sharp yet can cover the all extremities of the same scene ?
     
  5. Hyp-X

    Hyp-X Irregular
    Veteran

    Joined:
    Feb 6, 2002
    Messages:
    1,170
    Likes Received:
    5
    Yes you are right I was thinking about the pixel center (a point).
    Of course sampling only a single point produces aliasing very similar of the usual aliasing of polygon edges.

    That's why multiple samples are needed to anti-alias the shadow edge.

    Yes I realize that it's super-sampling - thats why it isn't neccessary to do it when you do full screen SSAA.

    I disagree. The surface sampled is mostly consist of linear slopes. Linear reconstruction works there.

    The only questionable part is the edges which are a discontinuities in the the original infinitely high resolution version.
    But given that the sampled data is only used in a comparsion function it doesn't change the image very much.
    It causes a half-texel growth in the shadow which is not a big artifact nor it is very noticable when the shadowmap resolution is sufficently high.

    It's a trade-off: point sampling maches shadow siluettes closer, linear sampling has less error and need less / simpler biasing to avoid unwanted self-shadowing.

    Again, I do not use linear sampling to AA position data. I use it to improve the precisity of the sampled position data at certain places.
     
  6. DeanoC

    DeanoC Trust me, I'm a renderer person!
    Veteran Subscriber

    Joined:
    Feb 6, 2003
    Messages:
    1,469
    Likes Received:
    185
    Location:
    Viking lands
     
  7. Chris Egerter

    Newcomer

    Joined:
    Apr 28, 2003
    Messages:
    33
    Likes Received:
    0
    I have found a way to do soft shadows using stencil volumes using pixel shaders, without rendering the volume many times. The shader does per pixel selective hard/soft shadows depending on certain conditions.

    Takes about a 8-9 FPS performance hit. This is just the first attempt. I'm working on better blurring and edge detection shaders.

    http://www.powerrender.com/prx/gallery/softshadow2.jpg
    http://www.powerrender.com/prx/gallery/softshadow3.jpg
    http://www.powerrender.com/prx/gallery/softshadow4.jpg
    http://www.powerrender.com/prx/gallery/softshadow5.jpg
    http://www.powerrender.com/prx/gallery/softshadow6.jpg
    http://www.powerrender.com/prx/gallery/softshadow7.jpg

    I spent a few months with only shadow maps in this engine before switching to stencil shadows. I think shadow maps have a place for certain types of scenes (ie single sun light source) but stencil shadows will be the future since they don't have as many limitations.
     
  8. Humus

    Humus Crazy coder
    Veteran

    Joined:
    Feb 6, 2002
    Messages:
    3,217
    Likes Received:
    77
    Location:
    Stockholm, Sweden
    I would argue the exact opposite. Shadow volume's will have to go since they have too many limitations and drawbacks and the future belongs to shadow maps.
     
  9. Lezmaka

    Regular

    Joined:
    Oct 30, 2002
    Messages:
    398
    Likes Received:
    2
    Don't know if there's any difference between the screenshots (as in technique) but 5, 6, and 7 look the best.
     
  10. Luminescent

    Veteran

    Joined:
    Aug 4, 2002
    Messages:
    1,036
    Likes Received:
    0
    Location:
    Miami, Fl
    Yes, for some reason screenshot 1's shadows look a bit more rough and aliased around the edges, in contrast to screenshots 5, 6, and 7, whose shadows seem more natural and smooth.
     
  11. Chris Egerter

    Newcomer

    Joined:
    Apr 28, 2003
    Messages:
    33
    Likes Received:
    0
    The shots were taken over a number of hours, as the technique was being improved. You can change the softness of the shadows so changing a variable will give you different effects as you see in the screenshots. The first bunch only had 1 light as well.

    Since then I've also added glow effects (ala Tron 2.0, see ) and will work on depth of field today. See http://www.powerrender.com/prx/gallery/Glow.jpg

    Both the glow and soft shadow are done using box filters in pixel shaders.
    At some point I may switch to a 2 pass separable gaussian filter instead.
     
  12. Luminescent

    Veteran

    Joined:
    Aug 4, 2002
    Messages:
    1,036
    Likes Received:
    0
    Location:
    Miami, Fl
    Nice work. 8)
     
  13. MfA

    MfA
    Legend

    Joined:
    Feb 6, 2002
    Messages:
    6,806
    Likes Received:
    473
    By the by ... HL2 seems to be using shadow maps.

    Personally I wish hardware would support adaptive shadow maps, as much spatial resolution as you need and only where you need it without having to worry about nasty edge cases biting you in the ass ... this kind of stuff belongs in hardware, just like with occlusion culling. Some tasks just cannot be efficiently divided between hard and software on the PC ... maybe on a console. Just one more reason why PS3 is going to be a painfull blow to the PC :/
     
  14. Ostsol

    Veteran

    Joined:
    Nov 19, 2002
    Messages:
    1,765
    Likes Received:
    0
    Location:
    Edmonton, Alberta, Canada
    Don't adaptive shadowmaps have quite a huge memory footprint?
     
  15. MfA

    MfA
    Legend

    Joined:
    Feb 6, 2002
    Messages:
    6,806
    Likes Received:
    473
    Less than a uniformely sampled shadow map, which is what we have now, of the same quality.
     
  16. Ilfirin

    Regular

    Joined:
    Jul 29, 2002
    Messages:
    425
    Likes Received:
    0
    Location:
    NC
    The problem being, of course, that they don't make for very good hardware implementations (or so says all the "hardware people" I have talked to). :(
     
  17. MfA

    MfA
    Legend

    Joined:
    Feb 6, 2002
    Messages:
    6,806
    Likes Received:
    473
    As I used to say about multisampling, yes ... doing it the bruteforce way is less messy for the hardware, but it still dont make sense in the end (well actually it doesnt make sense now, in the "end" supersampling will take over again).
     
  18. Dave H

    Regular

    Joined:
    Jan 21, 2003
    Messages:
    564
    Likes Received:
    0
    Slightly OT-

    Why? How is it that SSAA would end up better from an IQ-per-work perspective than MSAA + AF + some clever method of antialiasing alpha textures?

    Is it:

    1) There is no general case "clever method of antialiasing alpha textures" short of supersampling all such textures, and "in the 'end'" there will be enough use of transparency that it makes sense to supersample everything (but why shouldn't there be such a clever method)?

    2) As poly counts increase, more pixels land on a poly edge and thus MSAA with color compression approaches SSAA in bandwidth usage (but not in fillrate hit)?

    3) As hardware improves, available fillrate will outstrip the inherent limitations of display technology, so why not donate that superfluous fillrate to supersampling (except that while this will be true for fillrate of unshaded fragments, it won't be for the "fillrate" of fragments undergoing ever-more-complex shaders)?

    4) There is indeed some reason that SSAA (+ AF) results in better IQ than MSAA + AF + alpha texture fix?

    5) Something else I'm completely missing??
     
  19. Reverend

    Banned

    Joined:
    Jan 31, 2002
    Messages:
    3,266
    Likes Received:
    24
  20. demalion

    Veteran

    Joined:
    Feb 7, 2002
    Messages:
    2,024
    Likes Received:
    1
    Location:
    CT
    I thought it was because of fragment processing aliasing (no output antialiasing on a surface without supersampling) and also that anisotropic filtering was not suitable for antialiasing some texture inputs (like ones not intented to map directly to screen space output)?

    There was some neat discussion on this some time ago, I think, that leaves me with an impression of something being proposed like shortcuts with sub pixel calculations to try and avoid redundant calculation Other than it probably involving SA, :lol: , I'm not sure how I could search for it.


    Addendum: cuz I felt bad for being so lazy, I fired a shotgun search for SA and sampling discussions and made a liar out of myself...just scroll up and down from the search result links, since I didn't completely "unlazify". :p

    Slightly related to what I had in mind.

    Aha! The exact discussion I had in mind, I think, already in progress before this link.
     
Loading...

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...