XNA Creators Club Online
Page 1 of 1 (8 items)
Sort Posts: Previous Next

Anti-aliasing bug, maybe?

Last post 12-09-2007 8:24 AM by Viva OpenGL. 7 replies.
  • 12-08-2007 5:26 PM

    Anti-aliasing bug, maybe?

    Ok, so I'm adding font/text rendering to my engine with the DX10 driver.  It seems like, maybe, DX10 is using AA, even though I have set, SampleDesc.Count = 1 and SampleDesc.Quality = 0, for the DXGI_SWAP_CHAIN_DESC structure when calling, D3D10CreateDeviceAndSwapChain.  Maybe it's not, but I can't figure out what's causing it.  Here's some pictures -

    DX9 -

    DX10 -

    You can see in DX10, for some reason, the T is shaded.  Here is the image that is used to create the texture that both DX9 and DX10 draw from -

    If you want the PIX dump for the 1st frame, you can grab it from -

    http://irrlicht.spintz.com/screenshots/dx10bugs/DX10FontProblem.PIXRun

     

  • 12-08-2007 5:37 PM In reply to

    Re: Anti-aliasing bug, maybe?

    Answer

    This is a classic.

    D3D9 and D3D10 have different pixel center.

    For D3D10 you don’t need to compensate the half pixel to get correct texel to pixel mapping.

  • 12-08-2007 8:38 PM In reply to

    Re: Anti-aliasing bug, maybe?

    Huh?  The same exact code is used for DX9 and DX10 to generate the vertices/tex coords for drawing the text.  I never took into account this half pixel compensation you mention, and have no clue what you mean.
  • 12-08-2007 8:45 PM In reply to

    Re: Anti-aliasing bug, maybe?

    EDIT: No I don't get it, when I create the font, I create a vertex in the top left corner, so -

    x1 = -1
    x2 = ( -1 + charWidth * ( 2.0f / screenWidth )
    y1 = 1
    y2 = ( 1 - charHeight * ( 2.0f / screenHeight )
    (x1,y1) @-----@ (x2,y1)
            |     |
            |     |
            |     |
    (x1,y2) @-----@ (x2,y2)
    

    Then, when placing a character on the screen, I use the WORLD transform to put it into place. So, I'm not sure where the half-pixel issue is causing differences. Do I then apply the half-pixel offset in the translation of the WORLD matrix, or do I apply it on the actual vertices? Was DX10 created to make life hell for people on purpose?

  • 12-08-2007 9:40 PM In reply to

    Re: Anti-aliasing bug, maybe?

    So, according to this half pixel offset, I should change the above to this -

    x1 = -1
    x2 = ( -1 + charWidth * ( 2.0f / screenWidth ) - ( 2.0f / screenWidth )
    y1 = 1
    y2 = ( 1 - charHeight * ( 2.0f / screenHeight ) + ( 2.0f / screenHeight )
    (x1,y1) @-----@ (x2,y1)
            |     |
            |     |
            |     |
    (x1,y2) @-----@ (x2,y2)
    
    ????? Is this right ?????
  • 12-08-2007 10:20 PM In reply to

    Re: Anti-aliasing bug, maybe?

    This didn't work either. If I get DX9 working, DX10 breaks, if I get DX10 working, DX9 is broke. I can't work on this anymore tonight. On a side note: I need to invest in a punching bag with a DX logo on it...
  • 12-09-2007 3:55 AM In reply to

    Re: Anti-aliasing bug, maybe?

    The documentation describes the problem for D3D9: http://msdn2.microsoft.com/en-us/library/bb219690.aspx

    If you don’t run in this problem so far with D3D9 there are two possible reasons.

    1.       You use pointer filters for your glyph textures.

    2.       You have compensated the offset with the texture coordinates.  This is a common mistake as it seems to work right but it will broke down on some cards especial in AA modes.

    With D3D10 pixels don’t longer have his half pixel offset. Therefore you can use the same code for text (or any other pixel perfect rendering) vertex generation only if you introduce another variable there. This variable need to contain the pixel offset.

  • 12-09-2007 8:24 AM In reply to

    Re: Anti-aliasing bug, maybe?

    I've seen that microsoft link, and it does a terrible job describing the problem, it's much simpler to understand - http://www.sjbrown.co.uk/?article=directx_texels.

    Even though I understand both, it's not working properly for DX9 and DX10 at the same time. I can only get 1 lined up correctly.

    So check this out, here's the 3 drivers, OpenGL and DX10 are the same size, not sure why DX9 is narrower. But notice, OpenGL is solid and crisp, while DX10 is blended or aliased. Why is DX10 doing this. I'd be semi-happy with the outcome of the three drivers except for DX10 doing something completely different with the rendering, not just the pixel/texel mapping. All the render states/blend states/etc are the default ones. No reason for DX10 to be doing this. Why, if OpenGL and DX10 have the same texture coords and vertices, does OpenGL work and DX10 doesn't?

Page 1 of 1 (8 items) Previous Next