SweetFX Shader Suite release and discussion thread #3

Discussion in 'Games, Gaming & Game-demos' started by CeeJay.dk, Mar 18, 2013.

Thread Status:
Not open for further replies.
  1. WhiteLightning

    WhiteLightning Don Illuminati Staff Member

    Messages:
    29,091
    Likes Received:
    1,935
    GPU:
    GTX1070 iChillx4
    I have a question about the SMAA presets

    Besides setting in the SweetFX_settings.txt (which is ultra according to SMAA.h)

    Should i change something in #define SMAA_PIXEL_SIZE and #define SMAA_HLSL_3 1 or maybe some other setting in d3d9.fx be changed to get maximum quality.

    Ive been trying this with Counterstrike Source , trying to reduce aliasing on the gates.

    [​IMG]
     
  2. ninjafada

    ninjafada Master Guru

    Messages:
    308
    Likes Received:
    0
    GPU:
    pny 670
    you can try
    #define SMAA_THRESHOLD 0.05
    #define SMAA_MAX_SEARCH_STEPS 98
    #define SMAA_MAX_SEARCH_STEPS_DIAG 16
    #define SMAA_CORNER_ROUNDING 100

    if it still doesn't remove it, you will need a better AA, because SMAA is 1X only and can't change that :p
     
  3. WhiteLightning

    WhiteLightning Don Illuminati Staff Member

    Messages:
    29,091
    Likes Received:
    1,935
    GPU:
    GTX1070 iChillx4
    Thanks, but in the SMAA.h file it says #define SMAA_CORNER_ROUNDING 100 (set it to 100 to disable corner detection.) ? so less is better ?
     
  4. Eddy__

    Eddy__ Member

    Messages:
    10
    Likes Received:
    0
    GPU:
    ASUS GTX275
    best settings :)
     
    Last edited: Apr 5, 2013

  5. Gramps

    Gramps Active Member

    Messages:
    84
    Likes Received:
    0
    GPU:
    PNY GTX 770 4GB OC
    How many is FXAA? And what is better for ATi?
     
  6. SYKED

    SYKED Member

    Messages:
    12
    Likes Received:
    0
    GPU:
    7870 XT
    Tribes Ascend

    [​IMG]
    [​IMG]

    [​IMG]
    [​IMG]

    [​IMG]
    [​IMG]

    [​IMG]
     
    Last edited: Apr 5, 2013
  7. Elajitz

    Elajitz Master Guru

    Messages:
    718
    Likes Received:
    73
    GPU:
    RTX 2080TI Ventus
    here ya go =)

    [​IMG][​IMG][​IMG][​IMG]
     
  8. CeeJay.dk

    CeeJay.dk Master Guru

    Messages:
    689
    Likes Received:
    8
    GPU:
    Radeon 6870
    FXAA uses 1 subpixel sample.

    1x , 2x and 4x ..etc refers to how many subsamples the technique takes per pixel.

    FXAA, MLAA and SMAA 1x all take 1 subsample per pixel, which is why they are so fast compared to something like MSAA 8x

    Among the screenspace AA techniques (FXAA, MLAA and SMAA), SMAA is the only one that can sample multiple subpixels, but only if the game supports this in it's engine. The injector cannot make the game do this so the only SMAA mode that SweetFX supports is SMAA 1x.

    To see SMAA 2x and 4X in use, play Crysis 3. It fully supports the higher quality SMAA modes - one of Cryteks developers did help develop the technique after all.

    There is no quality difference if you use it on AMD , Intel or Nvidia cards. All cards produce the same result. The only possible differences are performance differences and you don't have to worry - it runs great on all cards no matter their manufacturer.
     
    Last edited: Apr 5, 2013
  9. Surfing Gamer

    Surfing Gamer Member

    Messages:
    26
    Likes Received:
    0
    GPU:
    Nvidia GTX 560
    Hello,

    EDIT: I JUST REALISED THAT SWEETFX ALREADY HAS THE ABILITY TO DO THIS /FACEDESK. IGNORE THIS TWEAK.

    I made a tweak to SweetFX which I'll share here in case anyone wants it.

    If you force MSAA or SGSSAA thru the graphics drivers you may have noticed that it often causes problems with the pixels at the very edge of the screen. Using SweetFX I've added a thin black border at the screen edge to cover up the problem. To do this you just add the red lines of code to Main.h (see below). This will not affect any of the normal functions of SweetFX. This will also work even if all the other functions in SweetFX are disabled in SweetFX_settings.txt (so you can just get the black border and no other effects if you want).

    Code:
      /*-------------------------.   
      | :: Defining constants :: |
      '-------------------------*/
    
    //These values are normally defined by the injector dlls, but not when analyzed by GPU Shaderanalyzer
    //I need to ensure they always have a value to be able to compile them whenever I'm not using the injector.
    #ifdef SMAA_PIXEL_SIZE
      #ifndef BUFFER_RCP_WIDTH
        #define BUFFER_RCP_WIDTH SMAA_PIXEL_SIZE.x
        #define BUFFER_RCP_HEIGHT SMAA_PIXEL_SIZE.y
        #define BUFFER_WIDTH (1.0 / SMAA_PIXEL_SIZE.x)
        #define BUFFER_HEIGHT (1.0 / SMAA_PIXEL_SIZE.y)
      #endif
    #endif
    
    #ifndef BUFFER_RCP_WIDTH
      #define BUFFER_RCP_WIDTH (1.0 / 1680)
      #define BUFFER_RCP_HEIGHT (1.0 / 1050)
      #define BUFFER_WIDTH 1680
      #define BUFFER_HEIGHT 1050
    #endif
    
    #define screen_size float2(BUFFER_WIDTH,BUFFER_HEIGHT)
    
    #define px BUFFER_RCP_WIDTH
    #define py BUFFER_RCP_HEIGHT
    
    #define pixel float2(px,py)
    
    // -- Define DirectX9 FXAA specific aliases --
    #if FXAA_HLSL_3 == 1
      #define myTex2D(s,p) tex2D(s,p)
      
      //#define s0 colorTexG
      //#define s1 colorTexG //TODO make a nearest sampler if needed
    #endif
    
    // -- Define DirectX10/11 FXAA specific aliases --
    #if FXAA_HLSL_4 == 1
      #define myTex2D(s,p) s.SampleLevel(screenSampler, p, 0)
    
      #define s0 gLumaTexture
      #define s1 gLumaTexture //TODO make a nearest sampler if needed
    #endif
    
    
    // -- Define DirectX9 specific aliases --
    #if SMAA_HLSL_3 == 1
      #define myTex2D(s,p) tex2D(s,p)
      
      #define s0 colorTexG
      #define s1 colorTexG //TODO make a nearest sampler if needed
    #endif
    
    // -- Define DirectX10/11 specific aliases --
    #if SMAA_HLSL_4 == 1 || SMAA_HLSL_4_1 == 1
      #define myTex2D(s,p) s.SampleLevel(LinearSampler, p, 0)
    
      #define s0 colorTexGamma
      #define s1 colorTexGamma //TODO make a nearest sampler if needed
    #endif
    
    
      /*------------------------------.   
      | :: Include enabled shaders :: |
      '------------------------------*/
      
    #if (USE_CARTOON == 1)
      #include "SweetFX\Shaders\Cartoon.h"
    #endif  
    
    #if (USE_ADVANCED_CRT == 1)
      #include "SweetFX\Shaders\AdvancedCRT.h"
    #endif
    
    #if (USE_BLOOM == 1)
      #include "SweetFX\Shaders\Bloom.h"
    #endif
    
    #if (USE_HDR == 1)
      #include "SweetFX\Shaders\HDR.h"
    #endif
    
    #if (USE_LUMASHARPEN == 1)
      #include "SweetFX\Shaders\LumaSharpen.h"
    #endif
    
    #if (USE_TECHNICOLOR == 1)
      #include "SweetFX\Shaders\Technicolor.h"
    #endif
    
    #if (USE_DPX == 1)
      #include "SweetFX\Shaders\DPX.h"
    #endif
    
    #if (USE_MONOCHROME == 1)
      #include "SweetFX\Shaders\Monochrome.h"
    #endif
    
    #if (USE_LIFTGAMMAGAIN == 1)
      #include "SweetFX\Shaders\LiftGammaGain.h"
    #endif
    
    #if (USE_TONEMAP == 1)
      #include "SweetFX\Shaders\Tonemap.h"
    #endif
    
    #if (USE_SEPIA == 1)
      #include "SweetFX\Shaders\Sepia.h"
    #endif
    
    #if (USE_VIBRANCE == 1)
      #include "SweetFX\Shaders\Vibrance.h"
    #endif
    
    #if (USE_CURVES == 1)
      #include "SweetFX\Shaders\Curves.h"
    #endif
    
    #if (USE_VIGNETTE == 1)
      #include "SweetFX\Shaders\Vignette.h"
    #endif
    
    #if (USE_DITHER == 1)
      #include "SweetFX\Shaders\Dither.h"
    #endif
    
    #if (USE_BORDER == 1)
      #include "SweetFX\Shaders\Border.h"
    #endif
    
    #if (USE_SPLITSCREEN == 1)
      #include "SweetFX\Shaders\Splitscreen.h"
    #endif
    
      /*-------------------------------.   
      | :: Xbox360 Gamma correction :: |
      '-------------------------------*/
    
    /*
      I suspect that some games that ported to PC are such terrible ports that the developers forgot (or didn't bother)
      to do correct gamma correction for PC but just copied the Xbox360 code.
      
      If that is the case then I can probably correct for it, but I need to find some terrible ports and check for this first.
      Until then this code is not used.
    */
    
    float XenonGammaToLinear(float val)
    {
       float ret;
       saturate(val);
       if (val < 0.25f)
          ret = 0.25f * val;
       else if (val < 0.375f)
          ret = (1.0f/16.0f) + 0.5f*(val-0.25f);
       else if (val < 0.75f)
          ret = 0.125f + 1.0f*(val-0.375f);
       else
          ret = 0.5f + 2.0f*(val-0.75f);
       return ret;
    }
    
    float LinearToXenonGamma(float val)
    {
       float ret;
       saturate(val);
       if (val < (1.0f/16.0f))
          ret = 4.0f * val;
       else if (val < (1.0f/8.0f))
          ret = (1.0f/4.0f) + 2.0f*(val-(1.0f/16.0f));
       else if (val < 0.5f)
          ret = 0.375f + 1.0f*(val-0.125f);
       else
          ret = 0.75f + 0.5f*(val-0.50f);
       return ret;
    }
    
      /*--------------------.   
      | :: Effect passes :: |
      '--------------------*/
    
    float4 main(float2 tex, float4 FinalColor)
    {
    //    FinalColor.rgb = (FinalColor.rgb <= 0.03928) ? FinalColor.rgb / 12.92 : pow( (FinalColor.rgb + 0.055) / 1.055, 2.4 ); // SRGB to Linear
    
      /*--------------------------------------.   
      | :: Linear to sRGB Gamma correction :: |
      '--------------------------------------*/
    
      // Linear to sRGB Gamma correction. Needed here because SMAA uses linear for it's final step while the other shaders use SRGB.
      #if (USE_SMAA_ANTIALIASING == 1)
        FinalColor.rgb = (FinalColor.rgb <= 0.00304) ? saturate(FinalColor.rgb) * 12.92 : 1.055 * pow( saturate(FinalColor.rgb), 1.0/2.4 ) - 0.055; // Linear to SRGB
    	#endif
    
      #if (Xbox360gamma == 1)
        FinalColor.r = LinearToXenonGamma(FinalColor.r); // Linear to Xbox360 Gamma space (R)
        FinalColor.g = LinearToXenonGamma(FinalColor.g); // Linear to Xbox360 Gamma space (G)
        FinalColor.b = LinearToXenonGamma(FinalColor.b); // Linear to Xbox360 Gamma space (B)
    	#endif
    
      /*--------------------.   
      | :: Effect passes :: |
      '--------------------*/
    
      // Cartoon
      #if (USE_CARTOON == 1)
    	FinalColor = CartoonPass(FinalColor,tex);
      #endif
      
      // Advanced CRT
      #if (USE_ADVANCED_CRT == 1)
    	FinalColor = AdvancedCRTPass(FinalColor,tex);
      #endif
    	
    	// Bloom
      #if (USE_BLOOM == 1)
    	FinalColor = BloomPass (FinalColor,tex);
      #endif
    	
    	// HDR
      #if (USE_HDR == 1)
    	FinalColor = HDRPass (FinalColor,tex);
      #endif
    	
      // LumaSharpen
      #if (USE_LUMASHARPEN == 1)
    	FinalColor = LumaSharpenPass(FinalColor,tex);
      #endif
    		
      // Technicolor
      #if (USE_TECHNICOLOR == 1)
    	FinalColor = TechnicolorPass(FinalColor);
      #endif
    	
      // DPX
      #if (USE_DPX == 1)
    	FinalColor = DPXPass(FinalColor);
      #endif
      
      // Monochrome
      #if (USE_MONOCHROME == 1)
    	FinalColor = MonochromePass(FinalColor);
      #endif
    	
      // Lift Gamma Gain
      #if (USE_LIFTGAMMAGAIN == 1)
    	FinalColor = LiftGammaGainPass(FinalColor);
      #endif
    	
      // Tonemap
      #if (USE_TONEMAP == 1)
    	FinalColor = TonemapPass(FinalColor);
      #endif
    	
      // Vibrance
      #if (USE_VIBRANCE == 1)
    	FinalColor = VibrancePass(FinalColor);
      #endif
    
      // Curves
      #if (USE_CURVES == 1)
    	FinalColor = CurvesPass(FinalColor);
      #endif
    		
      // Sepia
      #if (USE_SEPIA == 1)
        FinalColor = SepiaPass(FinalColor);
      #endif
    	
      // Vignette
      #if (USE_VIGNETTE == 1)
    	FinalColor = VignettePass(FinalColor,tex);
      #endif
    	
      // Dither (should go near the end as it only dithers what went before it)
      #if (USE_DITHER == 1)
    	FinalColor = DitherPass(FinalColor,tex);
      #endif
    	
      // Border
      #if (USE_BORDER == 1)
        FinalColor = BorderPass(FinalColor,tex);
      #endif
    	
      // Splitscreen
      #if (USE_SPLITSCREEN == 1)
    	FinalColor = SplitscreenPass(FinalColor,tex);
      #endif
    
      /*--------------------------------------.   
      | :: sRGB to Linear Gamma correction :: |
      '--------------------------------------*/
    	
      // sRGB to Linear gamma correction.
      #if (USE_SMAA_ANTIALIASING == 1 && SMAA_HLSL_3 != 1) //Only for DirectX 10/11
        FinalColor.rgb = (FinalColor.rgb <= 0.03928) ? saturate(FinalColor.rgb) / 12.92 : pow( (saturate(FinalColor.rgb) + 0.055) / 1.055, 2.4 ); // SRGB to Linear
      #endif
    
    [color=red]  // Black Border
      FinalColor.rgb = (tex.x<0.005||tex.x>0.995||tex.y<0.005||tex.y>0.995)?0:FinalColor.rgb;[/color]
      
      // Return FinalColor
      FinalColor.a = 1.0; //Clear alpha channel to reduce filesize of screenshots that are converted to png and avoid problems when viewing the screenshots.
      return FinalColor;
    }
     
    Last edited: Apr 6, 2013
  10. kaicooper

    kaicooper Master Guru

    Messages:
    519
    Likes Received:
    42
    GPU:
    GTX 780 SC ACX
    thanx brother..sadly im at work now ..i should cheack it out later
    hope somone tell us the difference..appreciat it..screenshots plz
     

  11. Surfing Gamer

    Surfing Gamer Member

    Messages:
    26
    Likes Received:
    0
    GPU:
    Nvidia GTX 560
    Well it's a bit pointless now. I made a tweak that adds a black border and posted it, and then I realised that SweetFX already has the ability to add a black border so I edited my post.

    In SweetFX_settings.txt you just set "BORDER" to "1" and that's it. No need for my tweak.
     
  12. Gramps

    Gramps Active Member

    Messages:
    84
    Likes Received:
    0
    GPU:
    PNY GTX 770 4GB OC
    Even though that shader you created was a flop .. it was still a good idea; until you realised that someone had beaten you to it. I'm sure you still have other good ideas, and the intellect to implement them.
     
  13. Surfing Gamer

    Surfing Gamer Member

    Messages:
    26
    Likes Received:
    0
    GPU:
    Nvidia GTX 560
    Nice of you to say, thanks.
     
  14. Boulotaur2024

    Boulotaur2024 Member Guru

    Messages:
    142
    Likes Received:
    0
    GPU:
    AMD HD7950
    He's right, I was thinking the same actually.

    I'm still working on a new injector, SMAA & FXAA now both work fine but I just found something in the SweetFX Main.h file that puzzles me Ceejay :

    You're doing a SRGB to Linear convertion "because SMAA uses linear for it's final step while the other shaders use SRGB" which is absolutely fine but then the s0 and s1 variables are defined earlier as #define s0 colorTexGamma and #define s1 colorTexGamma respectively. The problem is colorTexGamma is the non-SRGB texture, while colorTex is the SRGB one -if I'm correct.

    Code from SMAA Demo DX10 :
    Code:
    smaa->go(*[U]tmpRT[/U], *[B]tmpRT_SRGB[/B], *depthBufferRT, *backbufferRT, *depthStencil1x, input, mode);
    Implementation of smaa::go
    Code:
    void SMAA::go([U]ID3D10ShaderResourceView *srcGammaSRV[/U],
                  [B]ID3D10ShaderResourceView *srcSRV[/B],
                  ID3D10ShaderResourceView *depthSRV,
                  ID3D10RenderTargetView *dstRTV,
                  ID3D10DepthStencilView *dsv,
                  Input input,
                  Mode mode,
                  int subsampleIndex,
                  float blendFactor) {
        HRESULT hr;
    
    [...]
    
        V(blendFactorVariable->SetFloat(blendFactor));
        [B]V(colorTexVariable->SetResource(srcSRV));[/B] <-- binds the SRGB texture to the colorTex variable
        V(edgesTexVariable->SetResource(*edgesRT));
        V(blendTexVariable->SetResource(*blendRT));
        V(areaTexVariable->SetResource(areaTexSRV));
        V(searchTexVariable->SetResource(searchTexSRV));
        [U]V(colorTexGammaVariable->SetResource(srcGammaSRV))[/U]; <-- binds the non-SRGB texture to the colorTexGamma variable
        V(depthTexVariable->SetResource(depthSRV));
    
    [...]
    }
    Bottom line : the underlined variable is what you register as s0 and s1 respectively : they are NOT SRGB, while the bold variable is the SRGB one. So you should write this in the Main.h instead :

    Code:
    // -- Define DirectX10/11 specific aliases --
    #if SMAA_HLSL_4 == 1 || SMAA_HLSL_4_1 == 1
      #define myTex2D(s,p) s.SampleLevel(LinearSampler, p, 0)
    
      #define s0 [B]colorTex[/B]
      #define s1 [B]colorTex [/B]//TODO make a nearest sampler if needed
    #endif
    I'm not sure I'm clear enough, and not that it matters tremendously anyway but I thought you'd like to know about it.
    Cheers
     
    Last edited: Apr 6, 2013
  15. Elajitz

    Elajitz Master Guru

    Messages:
    718
    Likes Received:
    73
    GPU:
    RTX 2080TI Ventus

  16. alco

    alco Master Guru

    Messages:
    933
    Likes Received:
    0
    GPU:
    Asus gtx780 DirectcuII OC
    already using your settings :D
    only thing i have in bf3 is that the roads are are a bit yellow tinted

    still impressive and awesome program keep it up !
     
  17. Elajitz

    Elajitz Master Guru

    Messages:
    718
    Likes Received:
    73
    GPU:
    RTX 2080TI Ventus
    its should be fixed now!
    http://sfx.thelazy.net/games/preset/263/

    screens/ Battlefield 3 Presentation
    [​IMG][​IMG][​IMG]
     
    Last edited: Apr 7, 2013
  18. Mr_Ca5h_QLD

    Mr_Ca5h_QLD New Member

    Messages:
    1
    Likes Received:
    0
    GPU:
    nVidia GeForce 670GTX 3GB
    Want to PUSH my LAPTOP to the Highest STABLE LIMIT

    :) Good'ay from Tropical Paradise QLD, Australia. New to your Forum! 8/4/2013

    Finally bit the bullet and got a Thermaltake (Cooling Stand for my Toshiba X870)

    Now that the laptop has some way of expelling all the HOT AIR produced by the Intel Quad Core i7 3630 and the nVidia 3D Vision ready, 670 GTX with DDR5 3GB RAM, I would like to STRETCH my Puppies LEGS just a little!

    Yes, Overclock Something! lol :)

    Have MSI Afterburner installed and just after some advise on how much I could play with the values UNTIL I go to the BEST HIGHEST STABLE STATE!

    PS my 120hz 17.3" Full HD 1920x1080 back lit screen is Beautiful and has no issues playing Blue Ray 3D Movies or playing SimCity 5 (2013) in 3D but it used to get a little hot under it's collar after about 1 - 2 hours. :banana:

    Now my Qosmio X870 Gaming laptop is not even Breaking out into a Sweat!

    So can anyone advise me here, I hope so, ALL replies will be read! Thanks!

    PS. If your looking for the Best Laptop on the current market the specks are great here :)
     
  19. Elajitz

    Elajitz Master Guru

    Messages:
    718
    Likes Received:
    73
    GPU:
    RTX 2080TI Ventus
    my GTA IV ENB/SFX1.4 set!
    [​IMG][​IMG][​IMG][​IMG]
     
  20. CeeJay.dk

    CeeJay.dk Master Guru

    Messages:
    689
    Likes Received:
    8
    GPU:
    Radeon 6870
    If I did that then I would be sampling from the SRGB (like you said).
    But I do not want to sample from the SRGB sampler - I want to sample from the Gamma sampler because the rest of the shaders works in Gamma space and not Linear space.

    It would still work if I for example in LumaSharpen sampled the linear sampler and in fact it would be faster because the samples don't have to be gamma corrected, but it would not longer work correctly.

    If you know of a way to make it sample in Linear space and still work correctly, then please let me know, because I have noticed that if it samples in linear space then the shader runs faster on Nvidia cards (probably because it doesn't have to gamma correct the samples)

    The way SweetFX currently works :
    In DX9 :
    The technique called NeighborhoodBlending is triggered and it runs DX9_SMAANeighborhoodBlendingPS.

    DX9_SMAANeighborhoodBlendingPS does the final pass of SMAA and outputs in linear space.

    The technique then used to have SRGBWriteEnable = true; set so it would gamma correct on output.

    I piggyback the rest of the SweetFX shaders after DX9_SMAANeighborhoodBlendingPS and immediately gamma correct from linear space to gamma space in the shader itself.

    The SweetFX effects now runs and works in gamma space, and they output in gamma space as well.

    I then set SRGBWriteEnable = false; so my now gamma corrected output is not gamma corrected a second time (which would make it really dark)

    In DX10:
    The technique called NeighborhoodBlending is triggered and it runs DX10_SMAANeighborhoodBlendingPS.

    DX10_SMAANeighborhoodBlendingPS does the final pass of SMAA and outputs in linear space.

    I piggyback the rest of the SweetFX shaders after DX10_SMAANeighborhoodBlendingPS and immediately gamma correct from linear space to gamma space in the shader itself.

    The SweetFX effects now runs and works in gamma space, and they output in gamma space as well.

    However in DX10 I can't set SRGBWriteEnable = false; because in DX10 gamma correction is now done by setting the DXGI format, which I cannot do from the shader. It needs to be done in the injector.
    You will notice that some of the DXGI format have a SRGB suffix and some don't. That is what determines if gamma correction will be done to the output.

    So what I do is an ugly hack - I convert from the gamma space I need, back to linear space before outputting so it will be converted back to gamma space for the second time.
    This costs performance ofcourse, but I currently have no other way of doing this.

    The better way would be to have an injector that I could tell what format to use, so I can tell it to use the correct one and not have to worry with stuff like this.

    Also I shouldn't really be piggybacking on the last pass of SMAA, but should do another pass (or more) so I can avoid the artifacts I get from using one pass. There are also potentially huge performance benefits from splitting some of the shaders that use texture samples up in multiple passes.
    When you get the DX10 version to work we can talk about that.
     
Thread Status:
Not open for further replies.

Share This Page