Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Volume shadows & z-fighting

chick80chick80 Member Posts: 349
I'm implementing volume shadows in my engine, but I have this problem:
when rendering, I see a lot of visual artifacts, due to the facts that the objects seems to be *covered* with shadows. (see this shot: http://nade.altervista.org/temp/shadowtest.jpg)

As you can see, shadows are drawn correctly, but there are too much artifacts.

Note that I render the scene in 2 passes: the first with D3DRS_DEPTHBIAS set to 1, and the second (the actual shadow pass) with the same state set to 0, but this doesn't seem to change anything...

nICO

[hr]
[italic]How beautiful, if Sorrow had not made sorrow more beautiful than Beauty itself.[/italic]
JOHN KEATS

Comments

  • gautamgautam Member Posts: 642
    Hmm That looks really bad in fact it looks like torn pieces of blankets :p. I have seen that happen in OpenGL with depth test disabled too. So if there is something line enabling depth testing in DirectX try it.

    Secondly I would also suggest you play around with your near and far z values.

    : I'm implementing volume shadows in my engine, but I have this problem:
    : when rendering, I see a lot of visual artifacts, due to the facts that the objects seems to be *covered* with shadows. (see this shot: http://nade.altervista.org/temp/shadowtest.jpg)
    :
    : As you can see, shadows are drawn correctly, but there are too much artifacts.
    :
    : Note that I render the scene in 2 passes: the first with D3DRS_DEPTHBIAS set to 1, and the second (the actual shadow pass) with the same state set to 0, but this doesn't seem to change anything...
    :
    : nICO
    :
    : [hr]
    : [italic]How beautiful, if Sorrow had not made sorrow more beautiful than Beauty itself.[/italic]
    : JOHN KEATS
    :
    :

  • Vorsin S.V.Vorsin S.V. Member Posts: 25
    : I'm implementing volume shadows in my engine, but I have this problem:
    : when rendering, I see a lot of visual artifacts, due to the facts that the objects seems to be *covered* with shadows. (see this shot: http://nade.altervista.org/temp/shadowtest.jpg)
    :
    : As you can see, shadows are drawn correctly, but there are too much artifacts.
    :
    : Note that I render the scene in 2 passes: the first with D3DRS_DEPTHBIAS set to 1, and the second (the actual shadow pass) with the same state set to 0, but this doesn't seem to change anything...
    :
    : nICO
    :
    : [hr]
    : [italic]How beautiful, if Sorrow had not made sorrow more beautiful than Beauty itself.[/italic]
    : JOHN KEATS
    :
    :

    You should not use Z-Bias. (As I see, you use Vertex Programm accelaration of shadow volumes generation. Draw with Z-Fail). So you should use shadow volumes insets (Shadow volume object must be smaller in volume than the base object, and the volume must be generated from the base object). See NVIDIA SDK for details.

  • chick80chick80 Member Posts: 349
    :
    : You should not use Z-Bias. (As I see, you use Vertex Programm accelaration of shadow volumes generation. Draw with Z-Fail). So you should use shadow volumes insets (Shadow volume object must be smaller in volume than the base object, and the volume must be generated from the base object). See NVIDIA SDK for details.
    :
    :
    Thank you, I managed to solve the problem.
    In fact the real problem was that I was using the programmable pipeline to draw the shadow volume, but drawing the color pass with the fixed function pipeline. The two pipelines have a slightly different float precision in calculating the z-depth, so that z-fighting was seen.

    Btw, I'm now rewriting the code, basing on the nVIDIA paper "Fast, Pratical and Robust Shadows" which you can find on nVIDIA developer site, that presents a more robust approach to draw stenciled shadows.

    bye and happy new year!
    nICO

    [hr]
    [italic]How beautiful, if Sorrow had not made sorrow more beautiful than Beauty itself.[/italic]
    JOHN KEATS


Sign In or Register to comment.