SMAA, the utlimate AA solution?

Discussion in 'Videocards - AMD Radeon Drivers Section' started by AxelL, Dec 1, 2011.

  1. Stevedroid

    Stevedroid Member

    Messages:
    33
    Likes Received:
    0
    GPU:
    EVGA GTX 680
    Shaders are (or can be) compiled at runtime, correct?

    This is why I presume you need to include the shader source code file in the same directory with the DLL. Otherwise if it was compiled into the DLL, why would you need it.

    Therefore it stands to reason that making changes to the SMAA.fx source would actually affect real changes if it gets compiled every time you run.

    DLL is probably just the injector/wrapper code, not the actual shader. Or I'm totally wrong here (just as likely).

    --edit---

    Confirmed - I think. I threw "this should not compile" uncommented, into the SMAA.fx file, and sure enough it causes a crash when trying to start the game.

    However, I've been messing around with the #defines, changing various values, and I'll be damned if I can actually spot a difference. Whether they're having an impact and I just can't see it, or whether they're not working I just don't know. One thing is clear though - the shader code is, at least in some manner, compiled at runtime. So changing the SMAA.fx file should be able to have some effect (naysayers :no: )
     
    Last edited: Dec 6, 2011
  2. Stevedroid

    Stevedroid Member

    Messages:
    33
    Likes Received:
    0
    GPU:
    EVGA GTX 680
    Confirmed for real. I stupidly forgot I still had normal MSAA enabled which is why I wasn't seeing a difference.

    I can now confidently say that the shader is compiled at runtime and making changes to the SMAA.fx file or the SMAA.h for that matter will cause actual changes.

    That said there's still barely any noticable difference between the LOW and ULTRA presets.

    I absolutely confirmed that changes to the source do work though by commenting out the whole preset section in the header file and then adding the following defines to the .fx file.
    #define SMAA_MAX_SEARCH_STEPS 0
    #define SMAA_MAX_SEARCH_STEPS_DIAG 0

    Which effectively disables the SMAA and I verified as much.


    Anyway, the best way to ensure you're using a certain preset is to take the whole preset value out of the question (because who the hell knows if there's a define for it earlier in the pre-processor chain that we don't see). Edit the SMAA.h file as follows:

    Code:
    /* <- add beginning comment identifier
    #if SMAA_PRESET_LOW == 1
    #define SMAA_THRESHOLD 0.15
    #define SMAA_MAX_SEARCH_STEPS 4
    #define SMAA_MAX_SEARCH_STEPS_DIAG 0
    #define SMAA_CORNER_ROUNDING 100
    #elif SMAA_PRESET_MEDIUM == 1
    #define SMAA_THRESHOLD 0.1
    #define SMAA_MAX_SEARCH_STEPS 8
    #define SMAA_MAX_SEARCH_STEPS_DIAG 0
    #define SMAA_CORNER_ROUNDING 100
    #elif SMAA_PRESET_HIGH == 1
    #define SMAA_THRESHOLD 0.1
    #define SMAA_MAX_SEARCH_STEPS 16
    #define SMAA_MAX_SEARCH_STEPS_DIAG 8
    #define SMAA_CORNER_ROUNDING 25
    #elif SMAA_PRESET_ULTRA == 1
    #define SMAA_THRESHOLD 0.05
    #define SMAA_MAX_SEARCH_STEPS 32
    #define SMAA_MAX_SEARCH_STEPS_DIAG 16
    #define SMAA_CORNER_ROUNDING 25
    #endif
    add end comment identifier -> */
    
    //and then ensure we're using the values from the ULTRA section
    #define SMAA_THRESHOLD 0.05
    #define SMAA_MAX_SEARCH_STEPS 32
    #define SMAA_MAX_SEARCH_STEPS_DIAG 16
    #define SMAA_CORNER_ROUNDING 25
    
     
  3. JonasBeckman

    JonasBeckman Ancient Guru

    Messages:
    17,564
    Likes Received:
    2,962
    GPU:
    XFX 7900XTX M'310
    Wonder if going even higher would make a better difference, checked the .dll and there was no value in there for #define so I guess the .h file is what's used with those presets.

    Going by the above info and then the description of the various values it would be something like:

    #define SMAA_THRESHOLD 0.01
    #define SMAA_MAX_SEARCH_STEPS 98
    #define SMAA_MAX_SEARCH_STEPS_DIAG 20
    #define SMAA_CORNER_ROUNDING 0

    Now to see what that does in-game.
     
  4. Sdar

    Sdar Guest

    Messages:
    48
    Likes Received:
    0
    GPU:
    AMD 7950 boost
    The preset selection is done in the dll as far as i know, i edited SMAA_PRESET_HIGH in dxgi.dll like this:
    [​IMG]

    And upload the file in the 2nd page of this topic.

    *d3d9.dll is in Ultra as default.
     

  5. Stevedroid

    Stevedroid Member

    Messages:
    33
    Likes Received:
    0
    GPU:
    EVGA GTX 680
    What you're looking at is probably not what you think you're looking at. #defines are replaced by the pre-processor in compiled code. I.e. you should never see the raw text of a define in actual machine code. That's probably just some text of the source in a non-active section stuck in there by the SDK. In other words, you're not editing actual code, you're editing a comment more or less (I think).

    In any case, it's not worth trying to make sense of or edit the DLL anyway when you can much more easily edit the source code of the shader.
     
    Last edited: Dec 6, 2011
  6. Sdar

    Sdar Guest

    Messages:
    48
    Likes Received:
    0
    GPU:
    AMD 7950 boost
    Most compilers removes the comments in the compiled code, and theres no raw text in a compiled code but you can edit HEX code and that's what i did.

    Dll Ultra vs low:
    Uncompressd images (Bmp ~6mb)

    jpg (worst quality):
    ULTRA
    LOW

    If u can't see the differences, download the uncompressed images.
     
    Last edited: Dec 6, 2011
  7. Stevedroid

    Stevedroid Member

    Messages:
    33
    Likes Received:
    0
    GPU:
    EVGA GTX 680
    No that's definitely raw text, not machine code...

    Here's the section that contains that value. What you're looking at here are debug messages and the path that the developer saved his project in, among other things. These are string literals used in the code and not actual code.

    That said, the section containing the define stings might be additional source code that it sticks in the shader before compiling it. In which case I would expect it to be text and that would likely explain why you're seeing a difference upon changing the value.

    Like I said though, it's still moot. You can edit the shader or header file directly with more ease and it's just as effective.

     
    Last edited: Dec 7, 2011
  8. Sdar

    Sdar Guest

    Messages:
    48
    Likes Received:
    0
    GPU:
    AMD 7950 boost
    If you have and Hex editor you only need 10 seconds to switch to a different preset and it works quite well btw differences between High and Ultra are barely noticiable.

    With Hex workshop: right click the dll file select Hex edit with Hex workshop now in hex workshop press Ctrl+F in the search box Type:Text String value: preset press enter edit in the right column the word HIGH with ULTRA.
     
  9. rgabriel15

    rgabriel15 Guest

    Messages:
    45
    Likes Received:
    0
    GPU:
    Gigabyte HD6850 1GB GDDR5
    Hi Sdar, im trying to edit d3d9.dll but i dunno what im doing wrong. When i try to execute any game with my modified dll, it says d3d9.dll have errors and the game dont start.

    Could you please modfy the preset in that file from Ultra to High and send me.

    Anyways, heres what im doing:

    I open the file in Hex Wokshop, search the text string and when i try to change from ULTRA to HIGH, i replace HIGH but the A remains (HIGHA). I dunno what i have to do here, so i deleted the A and clicked on Save, but i dunno how to save too. If you could make a quick tutorial showing exactly what steps to follow would be great. :)
     
    Last edited: Dec 7, 2011
  10. Sdar

    Sdar Guest

    Messages:
    48
    Likes Received:
    0
    GPU:
    AMD 7950 boost
    u must put a dot (.)

    Ultra to High: Mediafire
     
    Last edited: Dec 7, 2011

  11. rgabriel15

    rgabriel15 Guest

    Messages:
    45
    Likes Received:
    0
    GPU:
    Gigabyte HD6850 1GB GDDR5
    Tks man, the dot was my fault, cause i deleted the A.
     
  12. LayZ

    LayZ Master Guru

    Messages:
    317
    Likes Received:
    0
    GPU:
    Sapphire Dual-X R9 280X
    I have placed the files from the d3d10 folder in the game directory but the log file is getting generated and there doesn't seem to be a perceptible difference in-game when I press Pause/Break button either....what am I doing wrong? :S
     
  13. Sdar

    Sdar Guest

    Messages:
    48
    Likes Received:
    0
    GPU:
    AMD 7950 boost
    What game?

    Skyrim uses d3d9 not dxgi.
     
  14. Stevedroid

    Stevedroid Member

    Messages:
    33
    Likes Received:
    0
    GPU:
    EVGA GTX 680
    rgabriel15: If you edit the SMAA.h file you can play around with a more than the preset - and you don't have to mess around with a hex editor, you can do it with Notepad.

    To edit the header file, find the section below (it's pretty much the first thing that isn't a comment) and comment it out by adding comment brackets /* */ around it like I've done here. You could also just delete it, but it's helpful to keep it there for reference.

    Code:
    [COLOR="Red"]/*[/COLOR]
    #if SMAA_PRESET_LOW == 1
    #define SMAA_THRESHOLD 0.15
    #define SMAA_MAX_SEARCH_STEPS 4
    #define SMAA_MAX_SEARCH_STEPS_DIAG 0
    #define SMAA_CORNER_ROUNDING 100
    #elif SMAA_PRESET_MEDIUM == 1
    #define SMAA_THRESHOLD 0.1
    #define SMAA_MAX_SEARCH_STEPS 8
    #define SMAA_MAX_SEARCH_STEPS_DIAG 0
    #define SMAA_CORNER_ROUNDING 100
    #elif SMAA_PRESET_HIGH == 1
    #define SMAA_THRESHOLD 0.1
    #define SMAA_MAX_SEARCH_STEPS 16
    #define SMAA_MAX_SEARCH_STEPS_DIAG 8
    #define SMAA_CORNER_ROUNDING 25
    #elif SMAA_PRESET_ULTRA == 1
    #define SMAA_THRESHOLD 0.05
    #define SMAA_MAX_SEARCH_STEPS 32
    #define SMAA_MAX_SEARCH_STEPS_DIAG 16
    #define SMAA_CORNER_ROUNDING 25
    #endif
    [COLOR="Red"]*/[/COLOR]
    
    Then above or below that just add the defines for the individual settings that you want.

    For example, if you wanted to use the settings for the HIGH preset, the whole thing would look like this:
    Code:
    /*
    #if SMAA_PRESET_LOW == 1
    #define SMAA_THRESHOLD 0.15
    #define SMAA_MAX_SEARCH_STEPS 4
    #define SMAA_MAX_SEARCH_STEPS_DIAG 0
    #define SMAA_CORNER_ROUNDING 100
    #elif SMAA_PRESET_MEDIUM == 1
    #define SMAA_THRESHOLD 0.1
    #define SMAA_MAX_SEARCH_STEPS 8
    #define SMAA_MAX_SEARCH_STEPS_DIAG 0
    #define SMAA_CORNER_ROUNDING 100
    #elif SMAA_PRESET_HIGH == 1
    #define SMAA_THRESHOLD 0.1
    #define SMAA_MAX_SEARCH_STEPS 16
    #define SMAA_MAX_SEARCH_STEPS_DIAG 8
    #define SMAA_CORNER_ROUNDING 25
    #elif SMAA_PRESET_ULTRA == 1
    #define SMAA_THRESHOLD 0.05
    #define SMAA_MAX_SEARCH_STEPS 32
    #define SMAA_MAX_SEARCH_STEPS_DIAG 16
    #define SMAA_CORNER_ROUNDING 25
    #endif
    */
    
    #define SMAA_THRESHOLD 0.1
    #define SMAA_MAX_SEARCH_STEPS 16
    #define SMAA_MAX_SEARCH_STEPS_DIAG 8
    #define SMAA_CORNER_ROUNDING 25
    

    SMAA_THRESHOLD determines the "sensitivity" of the edge detection. Lower values = more sensitive = it will think more things are edges and blur them. This is why the ULTRA preset actually produces an ever so slightly more blurry image than the lower presets.

    SMAA_MAX_SEARCH_STEPS and SMAA_MAX_SEARCH_STEPS_DIAG are related to how the algorithm detects an edge's "pattern" in order to determine how exactly the blend it with neighboring pixels. Or at least that's what I could gather reading their abstract, this stuff is still largely way above my head. As far as I can tell, higher values = it will search more neighboring pixels to detect a pattern = it will more accurately blend an edge = edges are better anti-aliased.
     
    Last edited: Dec 7, 2011
  15. Burnt_Ram

    Burnt_Ram Guest

    Messages:
    5,921
    Likes Received:
    0
    GPU:
    Zotac GTX 1050 Ti
    i'm impressed how much sharper the image is in BF3 using the SMAA injector vs the in game FXAA. i wish i could be confident that i won't get banned so i uninstalled it, but i already used it so PB would know that right? so maybe i should just use it anyway ...?

    i'm not worried about the 60 bucks for the game to be replaced, but i can't loose my rank ;) all my weapons gone! i'd cry if i had to start all over.
     

  16. bishi

    bishi Master Guru

    Messages:
    575
    Likes Received:
    17
    GPU:
    GTX 1080 SLI
    I don't think you get banned until it has been identified / listed by them as a cheat. Otherwise they just read it as modified...
    I was using the FXAA mod but PB was kicking me :(
    RESTRICTION: Disallowed Program/Driver [124061]

    Still, considering it's likely just kicks im willing to give this a go.

    Check your C:\Users\<name>\AppData\Local\PunkBuster\BF3\pb\pbcl.log if you get disconnected to see if it was PB.

    I dont like the FXAA in this game because it is so blurry and the MSAA has such a performance hit :(

    EDIT: Well i tried in single player, definitely looks better with no AA turned on in game. I'll go try online ;)

    EDIT2: No kicks from multi, although after further use I did notice that there is slight blurring apparent from using this but not as bad as the built in FXAA. The FXAA injector seemed way better although this could have been due to the sharpening filters.
     
    Last edited: Dec 9, 2011
  17. AZONIC[rus]

    AZONIC[rus] Active Member

    Messages:
    54
    Likes Received:
    0
    GPU:
    ASUS EAH6950 DiCuII 2Gb
    Hm... friends:) I am confused... FXAA or MSAA? What to try? what is the difference?
     
  18. AxelL

    AxelL Guest

    Messages:
    48
    Likes Received:
    0
    GPU:
    ASUS STRIX GTX1080
    Thanks! I just wanted to post that too... in v1.2 easy to set the ULTRA function through the new "injector.ini" file. Have fun! :) Back to Skyrim...
     
  19. AZONIC[rus]

    AZONIC[rus] Active Member

    Messages:
    54
    Likes Received:
    0
    GPU:
    ASUS EAH6950 DiCuII 2Gb
    I can't see any difference in BF3... with injector or without...
     
  20. AxelL

    AxelL Guest

    Messages:
    48
    Likes Received:
    0
    GPU:
    ASUS STRIX GTX1080
    I did not tried that game, but if you did everything right, you should be able to turn on/off the effect with the Pause key on your keyboard.. You should look for wire, fences, side of objects.. and look sharp, because the effect is not day and night, especially if you combined with other antialiasinsing like MSAA at high resolution.
    It also could be conflicted with other AA, so try to disable, the in game AA, and use just this, see if it helps...
     

Share This Page