Bad aliasing issue.

Discussion in 'Architecture and Products' started by Area593, Feb 24, 2010.

  1. Area593

    Newcomer

    Joined:
    Feb 15, 2010
    Messages:
    22
    Likes Received:
    0
    Location:
    Sydney, Australia
    Hi Everyone,

    I'm having a really bad issue with edge aliasing, and I'm wondering if anyone knows of a solution. Here is an example:

    [​IMG]

    As you can see the edges are being ripped to shreds. I'm running it on a 9600GT, and have tried multiple driver versions (except the ForceWare drivers) to no avail. It isn't an issue at all on other machines such as one of my laptops running an ATI Mobility Raedon HD 3650, and although I do get aliasing on that machine, it is "normal" aliasing which I expect with AA turned off.

    Could it be an issue with running both the 9600GT and the inbuilt 6100 at the same time? I've triple checked all of the shader code, and engine code and it just keeps doing it, although as I said it's not an issue on my other machines. It only seems to do it with edges that are at a certain angle, so it's kind of got me stumped. I also haven't been able to find any info from my internet searches.

    The engine is running Direct3D 9, and is pretty standard all the way through, nothing out of the ordinary as far as the engine and shaders.

    Anyone know why this is happening? Thanks in advance for any help you can provide :smile:
     
  2. andypski

    Regular

    Joined:
    May 20, 2002
    Messages:
    584
    Likes Received:
    28
    Location:
    Santa Clara
    Hmmm - I can't tell you exactly what's happening, but from a quick inspection it appears that the artifacts occur only in the top-left of the image - if you draw a line from the bottom-left to top-right of the image then everything to the right and below that line seems to look ok (as far as I can tell), and everything on the other side has strange artifacts.

    Without more details it's hard to diagnose, although whatever is happening it appears to be related to some full-screen operation rather than anything happening during the rendering of the objects in the image(i.e. the errors are introduced in some image blit or post-processing operation) - there appears to be some jitter going on in the top-left of the image. It looks like some parameter is running into the limits of its precision and introducing the jitter, although I can't say why that should be happening.

    Is there some sort of full-screen post-processing or compositing operation going on?
     
  3. Andrew Lauritzen

    Moderator Veteran

    Joined:
    May 21, 2004
    Messages:
    2,526
    Likes Received:
    454
    Location:
    British Columbia, Canada
    I've seen similar things happening when doing a non-uniform stretch blit... As the above poster mentioned though, you may have just messed up your texture coordinates or sampling on some full-screen pass though (i.e. doing a non-uniform scale). If you are doing a full-screen pass, you should be using a single triangle that spans the entire screen though rather than a "quad" (two triangles) for performance reasons anyways.
     
  4. Area593

    Newcomer

    Joined:
    Feb 15, 2010
    Messages:
    22
    Likes Received:
    0
    Location:
    Sydney, Australia
    You both seem to be right, there is an issue with the post processing. Thanks for the help.

    I tried bypassing the post processing in the PS code before I started this thread and still had the issue. But I just tried completely bypassing all of the post processing altogether, and rendering the models straight to the output frame buffer, and it fixed it.

    With the post processing I'm using a full screen quad, with the upper left corner at x= -1, y= 1 (u=0, v=0) and the lower right corner at x= 1, y= -1 (u=1, v=1), and am using this method for all stages of the post processing (all luminance and bloom stages). I also found that I had to use a different projection matrix in order to make that work (aspect ratio at 1), otherwise it stretched the output, whereas the projection matrix used when rending the models is based on the width and height of the frame buffer, as I would normally do it. Is this the correct way to do it?

    I've also double checked the render target sizes for all post processing stages, but they are set up to scale relative to the size of the output frame buffer (the bloom stages are half the size of the frame buffer for performance) and even if I hard code the sizes it doesn't make a difference (even with the final bloom texture not being used in the final pass PS the issue is still there)

    One other thing to note is that when rendering at 800x600, which is the windowed size I used when I started on the engine, the issues seem to go away, which makes me think it's not an issue with the geometry or texture coordinates of the full screen quad. I've also checked the code nearly twenty times, over and over again, and am yet to find the cause of the issue.

    As far as the final pass, the texture that the models are rendered to is using point filtering (which I though was the logical option to prevent blurring), while the bloom texture is using anisotropic filtering to prevent artifacts when scaling it up to the final frame buffer size.

    I don't want to seem like an idiot, and I know it pretty much has to be something simple, but I've never developed an engine with post processing before, so it's new territory to me.

    Thanks for any help you can provide :)
     
  5. Davros

    Legend

    Joined:
    Jun 7, 2004
    Messages:
    15,996
    Likes Received:
    3,244
    "except the ForceWare drivers"

    all drivers for the 9600gt are ForceWare drivers, so what exactly have you got installed ?
     
  6. Area593

    Newcomer

    Joined:
    Feb 15, 2010
    Messages:
    22
    Likes Received:
    0
    Location:
    Sydney, Australia
    I've just realised it looks like you are right, it only seems to affect the upper left triangle that makes up the full screen quad, I'm still not sure why though.
     
  7. Area593

    Newcomer

    Joined:
    Feb 15, 2010
    Messages:
    22
    Likes Received:
    0
    Location:
    Sydney, Australia
    OK, sorry, my bad :oops:

    I havn't done 3D stuff since nVidia had standard and detonator drivers, and I though they might be still doing something similar :smile:
     
    #7 Area593, Feb 24, 2010
    Last edited by a moderator: Feb 24, 2010
  8. Area593

    Newcomer

    Joined:
    Feb 15, 2010
    Messages:
    22
    Likes Received:
    0
    Location:
    Sydney, Australia
    It's fixed!!!

    I still don't understand exactly what was happening, but seeing as the upper left triangle seemed to be the issue, I enlarged the lower right triangle to fill the screen, and modified the texture coordinates to suit, and it has resolved the issue, WOOHOO!

    Thanks for all your help, and for putting up with my stupidity. :grin:
     
  9. Area593

    Newcomer

    Joined:
    Feb 15, 2010
    Messages:
    22
    Likes Received:
    0
    Location:
    Sydney, Australia
    I spoke too soon, unfortunately. There is still an issue. I don't know if it helps, but when the MagFilter is set to Linear the issue goes away, at the expense of the result becoming slightly blurry, and when it is set to point it comes back. :???:
     
  10. Kaotik

    Kaotik Drunk Member
    Legend

    Joined:
    Apr 16, 2003
    Messages:
    9,144
    Likes Received:
    3,043
    Location:
    Finland
    Just to nitpick, haven't they been called just "GeForce drivers" for quite some time, ForceWare before that and Detonator before that?
     
  11. Andrew Lauritzen

    Moderator Veteran

    Joined:
    May 21, 2004
    Messages:
    2,526
    Likes Received:
    454
    Location:
    British Columbia, Canada
    What kind of vertex shader are you using with these passes? Don't use a "projection matrix" or any other nonsense... just pass through your vertex locations directly. Even better, if you're using DX10 you can just compute the vertex positions in the vertex shader and forget the vertex buffer entirely.

    Also if using DX10 use Load() together with SV_Position in the pixel shader to load the data from the back buffer. Otherwise you need to make sure you're texture coordinates are aligned with your texel positions (i.e. centered at half pixels). In DX9 this requires some fiddling with the polygon corners since the rasterization rules are a bit wonky. in DX10+ or OpenGL it "just works out".

    Note that if you get all this right, you should get exactly the same results with point filtering as with linear (no blurring).
     
  12. Area593

    Newcomer

    Joined:
    Feb 15, 2010
    Messages:
    22
    Likes Received:
    0
    Location:
    Sydney, Australia
    Unfortunately I'm using DX9 for this engine, as I use my main production machine to run both of my audio engineering and production related businesses, and the pro audio world is yet to fully support Windows 7 (don't get me started on Vista, lol). As a result, until I can afford to purchase a new machine specifically for games development I'm pretty much stuck with WinXP and DX9.

    What you've said about aligning the texture coordinates to be centered at half pixels makes so much sense it hurts :grin:. When I finish up with the audio jobs in the studio today I'm definitely going to get that sorted. Thanks for the help! :smile:

    I am looking forward to getting a games dev machine sorted simply so I can move on up to DX11 as there is a lot of features I'm looking forward to playing with.
     
  13. Area593

    Newcomer

    Joined:
    Feb 15, 2010
    Messages:
    22
    Likes Received:
    0
    Location:
    Sydney, Australia
    OK, I got to the point where I couldn't concentrate on work, so I decided I had to try aligning the texture coordinates to the texel positions and it works like an absolute charm. I even tried it at multiple resolutions in both windowed and fullscreen (to avoid eating my words yet again), and it works awesomely!

    Andrew, you are a legend, my brain can now work in peace. Thanks again! :grin:
     
  14. Rys

    Rys Moderator
    Moderator Veteran Alpha

    Joined:
    Oct 9, 2003
    Messages:
    4,167
    Likes Received:
    1,474
    Location:
    Beyond3D HQ
    Isn't the cost going to be really negligible for two really big triangles? When bringing up B3D benchmarks years ago, I measured perf with a quad and with a zoomed in tri and there was nothing in it, so quad it was for texcoord simplicity.
     
  15. Area593

    Newcomer

    Joined:
    Feb 15, 2010
    Messages:
    22
    Likes Received:
    0
    Location:
    Sydney, Australia
    That is kinda what I thought. I know it has to process one additional vertex, and three additional indices (for a triangle list), but in the end it works out to the same amount of pixels, which is where I thought the largest cost would be in any case. Though this is just me speculating, I've never tested it myself.
     
  16. Simon F

    Simon F Tea maker
    Moderator Veteran

    Joined:
    Feb 8, 2002
    Messages:
    4,560
    Likes Received:
    157
    Location:
    In the Island of Sodor, where the steam trains lie
    The "enormous" triangle approach might even be worse if the guard-band region was not large enough to fully contain that triangle resulting in clipping. <shrug>


    BTW, regarding the topic. Can one ever have a "good aliasing issue" :)
     
  17. Andrew Lauritzen

    Moderator Veteran

    Joined:
    May 21, 2004
    Messages:
    2,526
    Likes Received:
    454
    Location:
    British Columbia, Canada
    Happy to help :) Note that this (and a lot of other things!) got cleaned up in DX10, so hopefully you can get on board soon!

    The cost is not in the vertex transform/interpolation but the redundantly shaded/unused SIMD/quad lanes at the triangle boundary (diagonal across the screen). As such, it fully depends on the SIMD size of the machine and the cost of the shader at those pixels.

    I can't imagine the clipping would ever be slower than the extra shaded pixels for a single triangle... even *if* the guard-band didn't cover just 2x outside the screen.

    I've seen a single triangle make it go a bit faster, and I've never seen it make it go slower :) Not really a big deal, but it's easier to deal with a single primitive too.
     
  18. Simon F

    Simon F Tea maker
    Moderator Veteran

    Joined:
    Feb 8, 2002
    Messages:
    4,560
    Likes Received:
    157
    Location:
    In the Island of Sodor, where the steam trains lie
    I did say "might" :)
     
  19. Raqia

    Regular

    Joined:
    Oct 31, 2003
    Messages:
    508
    Likes Received:
    18
    What if you're writing a screen saver and want a cheap way to do Moire patterns? ;)
     
  20. Hazuki Ryu

    Regular

    Joined:
    Nov 3, 2007
    Messages:
    373
    Likes Received:
    0
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...