Results 1 to 3 of 3

Thread: Dont update Zbuffer if Alphatest fails?

  1. #1

    Dont update Zbuffer if Alphatest fails?

    Is it posible to set any renderstate or something else, sA¥ that it dont write to the z-buffer if alphatest fails?

    ie if I draw a rectangle with a texture that have transparency (a 2d sprite with a alpha channel).
    then the zbuffer will draw a full rectangle,
    but i dont want the zbuffer updated where the sprite is transparent..

    :cry:

    (Using Direct3D v.9c)
    (and by transparent, i mean on/off.. no half transparent)

  2. #2

    Dont update Zbuffer if Alphatest fails?

    Alpha test is EXACTLY what you are looking for!

    Stright from DirectX help file:
    The most common use for alpha testing is to improve performance when rasterizing objects that are nearly transparent. If the color data being rasterized is more opaque than the color at a given pixel (D3DPCMPCAPS_GREATEREQUAL), then the pixel is written. Otherwise, the rasterizer ignores the pixel altogether, saving the processing required to blend the two colors. The following code example checks if a given comparison function is supported and, if so, it sets the comparison function parameters required to improve performance during rendering.
    [pascal]if (pCaps.AlphaCmpCaps and D3DPCMPCAPS_GREATEREQUAL) <> 0 then
    begin
    dev.SetRenderState(D3DRS_ALPHAREF, DWORD($00000001));
    dev.SetRenderState(D3DRS_ALPHATESTENABLE, iTrue);
    dev.SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL);
    end;[/pascal]
    There are only 10 types of people in this world; those who understand binary and those who don't.

  3. #3

    Dont update Zbuffer if Alphatest fails?

    Damn, i did get alphatest and alphablend mixed up..
    *do'h* stupid me.. :roll:

    Now it works just like I wanted it to do.

    Thanks alot

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •