nVidia's FXAA mode (anti-aliasing)

Discussion in 'Videocards - NVIDIA GeForce Drivers Section' started by TheHunter, Jul 20, 2011.

  1. Adeks

    Adeks Guest

    Messages:
    30
    Likes Received:
    0
    GPU:
    670GTX GIGABYTE OC
    thx for explain :grad:

    BetA BF3 works fine with sweet fx 1.1.1 for me
     
  2. BetA

    BetA Ancient Guru

    Messages:
    4,537
    Likes Received:
    517
    GPU:
    G1-GTX980@1400Mhz
    yeah? what u play it at?
    When i start bf3, the screen gets black and then normal again. i play for about 10 - 15 min. and exactly after that time the BF3.exe crashes..ANd its 100% the sweetFX cause without sweetFX it doesnt crash at all.. i can play 3 hours nonstop..

    :(
     
  3. Adeks

    Adeks Guest

    Messages:
    30
    Likes Received:
    0
    GPU:
    670GTX GIGABYTE OC
    keep in mind when u use sweetFX automatically your GPU have more to do maybe your oc is not stable?
     
  4. BetA

    BetA Ancient Guru

    Messages:
    4,537
    Likes Received:
    517
    GPU:
    G1-GTX980@1400Mhz
    nevermind, works again...
    greetz
     
    Last edited: Sep 5, 2012

  5. KyleN

    KyleN Member

    Messages:
    38
    Likes Received:
    0
    GPU:
    gtx 670
    So why should i use sweetfx instead of fxaa injector? Is the fxaa and smaa the only difference?
     
    Last edited: Sep 6, 2012
  6. NimbusTLD

    NimbusTLD Guest

    Messages:
    17
    Likes Received:
    1
    GPU:
    1080 Ti
    I don't like FXAA because it blurs the whole image, losing detail especially in the textures.

    SMAA anti-aliases the image without any noticeable blurring. In fact, if you use LumaSharpen from SweetFX, it actually sharpens the textures!

    I'll let CeeJay or someone comment on the other differences as I don't use the other features :)
     
  7. KyleN

    KyleN Member

    Messages:
    38
    Likes Received:
    0
    GPU:
    gtx 670
    Whats the best settings to get most out of the SMAA?
     
  8. CeeJay.dk

    CeeJay.dk Guest

    Messages:
    691
    Likes Received:
    14
    GPU:
    Radeon 6870
    No it has more things going for it than just better anti-aliasing.

    The sharpening is much better and faster.
    The new Vibrance shader does a great job of adding color and it also seems to improve contrast a bit.
    The Vignette has less banding and is round instead of oval.
    The Dither shader greatly reduces color banding.

    I've made other minor improvements to the quality and speed of the other shaders.

    It's also easier to install and you can rebind keys.
    And it's faster.

    And it's the only anti-aliasing mod that's being actively developed - the FXAAtool developer is busy with work and real-life and there haven't been any lifesigns from the other developers for many months.

    I think the default settings in SweetFX are pretty good, but I posted a long guide to the SMAA settings and how to best tweak them a short while ago in this very thread.
     
    Last edited: Sep 7, 2012
  9. CeeJay.dk

    CeeJay.dk Guest

    Messages:
    691
    Likes Received:
    14
    GPU:
    Radeon 6870
    SweetFX for MPC-HC

    XRyche wrote me a PM asking for help with using Vibrance in Media Player Classic - Home Cinema. It's light-weight media player that among other neat things can also use shaders.

    I could not reply back with a PM as his account settings prohibits other users from sending him a PM so I'm posting here so he and others interested can use Vibrance in MPC-HC as well.

    To use Vibrance in MPC-HC:
    1) Make sure you're using an output renderer that supports shaders
    2) Go to Play -> Shaders -> Edit Shaders (or press CTRL+9)
    3) On the top blank line enter the name of the new shader - let us call this one Vibrance.
    4) Press enter and MPC-HC will now create a new template shader.
    5) Delete all the code in the shader code window and replace it with this :
    Code:
    /* --- Vibrance settings --- */
    
    #define Vibrance 0.3  //Intelligently saturates (or desaturates if you use negative values) the pixels depending on their original saturation.
    
    
    /* ---  Defining Constants --- */
    
    sampler s0 : register(s0);
    
    
    /* --- Vibrance --- */
    /*
      by Christian Cann Schuldt Jensen ~ CeeJay.dk
      
      Vibrance intelligently boosts the saturation of pixels
      so pixels that had little color get a larger boost than pixels that had a lot.
      
      This avoids oversaturation of pixels that were already very saturated.
    */
    
    float4 VibrancePass( float4 colorInput )
    {
    	float4 color = colorInput; //original input color
      float3 lumCoeff = float3(0.2126, 0.7152, 0.0722);  //Values to calculate luma with
    
    	float luma = dot(lumCoeff, color.rgb); //calculate luma (grey) 
    
    	float max_color = max(max(colorInput.r,colorInput.g),colorInput.b); //Find the strongest color
    	float min_color = min(min(colorInput.r,colorInput.g),colorInput.b); //Find the weakest color
    	
      float color_saturation = max_color - min_color; //The difference between the two is the saturation
    
      //color = lerp(luma, color, (1.0 + (Vibrance * (1.0 - color_saturation)))); //extrapolate between luma and original by 1 + (1-saturation)
      
      color = lerp(luma, color, (1.0 + (Vibrance * (1.0 - (sign(Vibrance) * color_saturation))))); //extrapolate between luma and original by 1 + (1-saturation)
    
    	return color; //return the result
    	//return color_saturation.xxxx; //Visualize the saturation
    }
    
    /* --- Main --- */
    
    float4 main(float2 tex : TEXCOORD0) : COLOR {
    	float4 c0 = tex2D(s0, tex);
    
    	c0 = VibrancePass(c0);
    
    	return c0;
    }
    6) Choose ps_3_0 as the pixel shader version to compile with. If it won't compile right because you have a very old GPU then choose ps_2_0.
    7) Go to Play -> Shaders -> Select Shaders , and add Vibrance to the list of Pre-resize shaders. Also remember to enable Pre-resize shaders.

    You're now using Vibrance with MPC-HC.

    The settings can be edited in the top of the Vibrance shader code. - Press CTRL+9 to open the Edit Shaders dialog again.


    You can do the same with LumaSharpen too. It's also a nice shader for MPC-HC.

    I suggest you add it to the list of Post-resize shaders though, but it also works as pre-resize shader. You can even use both.
    I just use it as a post-resize shader though.

    Here is the code I use for LumaSharpen in MPC
    Code:
    /*
       _____________________
         
         LumaSharpen 1.3.10
       _____________________ 
    
      by Christian Cann Schuldt Jensen ~ CeeJay.dk
      
      It blurs the original pixel with the surrounding pixels and then subtracts this blur to sharpen the image.
      It does this in luma to avoid color artifacts and allows limiting the maximum sharpning to avoid or lessen halo artifacts.
      
      This is similar to using Unsharp Mask in Photoshop.
        
      Compiles with 3.0
    */
    
    // .----------------------------------------------------._User settings_.---------------------------------------------------. 
    
    // -- Sharpening --
    #define sharp_strength 1.0 // Strength of the sharpening - You should probably use something between 0.2 and 2.0 - default is 1.0
    #define sharp_clamp 0.050  // Limits maximum amount of sharpening a pixel recieves - Default is 0.050
    
    // -- Advanced sharpening settings --
    #define pattern 2          // Choose a sample pattern ( 1, 2, 3 or 4 ) - I suggest 2
    #define offset_bias 1.0    // Offset bias adjusts the radius of the sampling pattern.
                               // I designed the pattern for offset_bias 1.0, but feel free to experiment.
    
    // .----------------------------------------------------._Debug settings_.--------------------------------------------------. 
    
    #define splitscreen 0      // Enables the before-and-after splitscreen comparison mode. Left side is before.
    #define show_sharpen 0     // Visualize the strength of the sharpen (multiplied by 4 to see it better)
    
    // .--------------------------------------------------._Developer settings_.------------------------------------------------. 
    
    #define CoefLuma float4(0.2126, 0.7152, 0.0722,0)      // BT.709 & sRBG luma coefficient (Monitors and HD Television)
    //#define CoefLuma float4(0.299, 0.587, 0.114,0)       // BT.601 luma coefficient (SD Television)
    //#define CoefLuma float4(1.0/3.0, 1.0/3.0, 1.0/3.0,0) // Equal weight coefficient
    
    #define sharp_strength_luma (CoefLuma * sharp_strength)
    
    // .--------------------------------------------------._Defining constants_.------------------------------------------------. 
    
    #ifndef s0
      sampler s0 : register(s0);
      #define s1 s0
    //sampler s1 : register(s1);
    
    //float4 p0 : register(c0);
      float4 p1 : register(c1);
    
    //  #define width (p0[0])
    //  #define height (p0[1])
    //  #define counter (p0[2])
    //  #define clock (p0[3])
    //  #define px (p1[0]) //one_over_width 
    //  #define py (p1[1]) //one_over_height
    
      #define px (p1.x) //one_over_width 
      #define py (p1.y) //one_over_height
    
      //#define pxy float2(p1.xy)
    
      //#define PI acos(-1)
      #define target 1 
    #endif
    
    
    // .------------------------------------------------------._Main code_.-----------------------------------------------------. 
    
    #if target == 1
    float4 main( float2 tex : TEXCOORD0 ) : COLOR  // Use with Shaderanalyzer and MPC-HC
    #else
    float4 LumaSharpenPass( float2 tex ) 
    #endif
    {
    
      // -- Get the original pixel --
      float4 ori = tex2D(s1, tex);       // ori = original pixel
    
    
    
    // .--------------------------------------------------._Sampling patterns_.-------------------------------------------------. 
    
      //   [ NW,   , NE ] Each texture lookup (except ori)
      //   [   ,ori,    ] samples 4 pixels
      //   [ SW,   , SE ]
    
      // -- Pattern 1 -- A (fast) 7 tap gaussian using only 2+1 texture fetches.
      #if pattern == 1
    
    	// -- Gaussian filter --
    	//   [ 1/9, 2/9,    ]     [ 1 , 2 ,   ]
    	//   [ 2/9, 8/9, 2/9]  =  [ 2 , 8 , 2 ]
     	//   [    , 2/9, 1/9]     [   , 2 , 1 ]
    
        float4 blur_ori = tex2D(s0, tex + (float2(px,py) / 3) * offset_bias);  // North West
        blur_ori += tex2D(s0, tex + (float2(-px,-py) / 3) * offset_bias); // South East
    
        //blur_ori += tex2D(s0, tex + float2(px,py) / 3 * offset_bias); // North East
        //blur_ori += tex2D(s0, tex + float2(-px,-py) / 3 * offset_bias); // South West
    
        blur_ori /= 2;  //Divide by the number of texture fetches
        
        sharp_strength_luma *= 1.5; // Adjust strength to aproximate the strength of pattern 2
    
      #endif
      
      // -- Pattern 2 -- A 9 tap gaussian using 4+1 texture fetches.
      #if pattern == 2
    
    	// -- Gaussian filter --
    	//   [ .25, .50, .25]     [ 1 , 2 , 1 ]
    	//   [ .50,   1, .50]  =  [ 2 , 4 , 2 ]
     	//   [ .25, .50, .25]     [ 1 , 2 , 1 ]
    
    
        float4 blur_ori = tex2D(s0, tex + float2(px,-py) * 0.5 * offset_bias); // South East
        blur_ori += tex2D(s0, tex + float2(-px,-py) * 0.5 * offset_bias);  // South West    
        blur_ori += tex2D(s0, tex + float2(px,py) * 0.5 * offset_bias); // North East
        blur_ori += tex2D(s0, tex + float2(-px,py) * 0.5 * offset_bias); // North West
    
        blur_ori *= 0.25;  // ( /= 4) Divide by the number of texture fetches
    
      #endif 
    
      // -- Pattern 3 -- An experimental 17 tap gaussian using 4+1 texture fetches.
      #if pattern == 3
    
    	// -- Gaussian filter --
    	//   [   , 4 , 6 ,   ,   ]
    	//   [   ,16 ,24 ,16 , 4 ]
    	//   [ 6 ,24 ,   ,24 , 6 ]
    	//   [ 4 ,16 ,24 ,16 ,   ]
    	//   [   ,   , 6 , 4 ,   ]
    
        float4 blur_ori = tex2D(s0, tex + float2(0.4*px,-1.2*py)* offset_bias);  // South South East
        blur_ori += tex2D(s0, tex + float2(-1.2*px,-0.4*py) * offset_bias); // West South West
        blur_ori += tex2D(s0, tex + float2(1.2*px,0.4*py) * offset_bias); // East North East
        blur_ori += tex2D(s0, tex + float2(-0.4*px,1.2*py) * offset_bias); // North North West
    
        blur_ori *= 0.25;  // ( /= 4) Divide by the number of texture fetches
        
        sharp_strength_luma *= 0.51;
      #endif
    
      // -- Pattern 4 -- A 9 tap high pass (pyramid filter) using 4+1 texture fetches.
      #if pattern == 4
    
    	// -- Gaussian filter --
    	//   [ .50, .50, .50]     [ 1 , 1 , 1 ]
    	//   [ .50,    , .50]  =  [ 1 ,   , 1 ]
     	//   [ .50, .50, .50]     [ 1 , 1 , 1 ]
    
        half4 blur_ori = tex2D(s0, tex + float2(0.5 * px,-py * offset_bias));  // South South East
        blur_ori += tex2D(s0, tex + float2(offset_bias * -px,0.5 * -py)); // West South West
        blur_ori += tex2D(s0, tex + float2(offset_bias * px,0.5 * py)); // East North East
        blur_ori += tex2D(s0, tex + float2(0.5 * -px,py * offset_bias)); // North North West
    
        //blur_ori += (2 * ori); // Probably not needed. Only serves to lessen the effect.
    	
        blur_ori /= 4;  //Divide by the number of texture fetches
    
        sharp_strength_luma *= 0.666; // Adjust strength to aproximate the strength of pattern 2
      #endif
    
      // -- Pattern 8 -- A (slow) 9 tap gaussian using 9 texture fetches.
      #if pattern == 8
    
    	// -- Gaussian filter --
    	//   [ 1 , 1 , 1 ]
    	//   [ 1 , 1 , 1 ]
     	//   [ 1 , 1 , 1 ]
    
        half4 blur_ori = tex2D(s0, tex + float2(-px,py) * offset_bias); // North West
        blur_ori += tex2D(s0, tex + float2(px,-py) * offset_bias);     // South East
        blur_ori += tex2D(s0, tex + float2(-px,-py)  * offset_bias);  // South West
        blur_ori += tex2D(s0, tex + float2(px,py) * offset_bias);    // North East
        
        half4 blur_ori2 = tex2D(s0, tex + float2(0,py) * offset_bias); // North
        blur_ori2 += tex2D(s0, tex + float2(0,-py) * offset_bias);    // South
        blur_ori2 += tex2D(s0, tex + float2(-px,0) * offset_bias);   // West
        blur_ori2 += tex2D(s0, tex + float2(px,0) * offset_bias);   // East
        blur_ori2 *= 2;
    
        blur_ori += blur_ori2;
        blur_ori += (ori * 4); // Probably not needed. Only serves to lessen the effect.
    
        // dot()s with gaussian strengths here?
    
        blur_ori /= 16;  //Divide by the number of texture fetches
    
        //sharp_strength_luma *= 0.75; // Adjust strength to aproximate the strength of pattern 2
      #endif
    
      // -- Pattern 9 -- A (slow) 9 tap high pass using 9 texture fetches.
      #if pattern == 9
    
    	// -- Gaussian filter --
    	//   [ 1 , 1 , 1 ]
    	//   [ 1 , 1 , 1 ]
     	//   [ 1 , 1 , 1 ]
    
        half4 blur_ori = tex2D(s0, tex + float2(-px,py) * offset_bias); // North West
        blur_ori += tex2D(s0, tex + float2(px,-py) * offset_bias);     // South East
        blur_ori += tex2D(s0, tex + float2(-px,-py)  * offset_bias);  // South West
        blur_ori += tex2D(s0, tex + float2(px,py) * offset_bias);    // North East
        
        blur_ori += ori; // Probably not needed. Only serves to lessen the effect.
        
        blur_ori += tex2D(s0, tex + float2(0,py) * offset_bias);    // North
        blur_ori += tex2D(s0, tex + float2(0,-py) * offset_bias);  // South
        blur_ori += tex2D(s0, tex + float2(-px,0) * offset_bias); // West
        blur_ori += tex2D(s0, tex + float2(px,0) * offset_bias); // East
    
        blur_ori /= 9;  //Divide by the number of texture fetches
    
        //sharp_strength_luma *= (8.0/9.0); // Adjust strength to aproximate the strength of pattern 2
      #endif
      
    // .-----------------------------------------------._Sharpen_.-------------------------------------------------------. 
      
      // -- Calculate the sharpening --  
      float4 sharp = ori - blur_ori;  //Subtracting the blurred image from the original image
      
      // -- Adjust strength of the sharpening --
      float sharp_luma = dot(sharp, sharp_strength_luma); //Calculate the luma and adjust the strength
    
      // -- Clamping the maximum amount of sharpening to prevent halo artifacts --
      sharp_luma = clamp(sharp_luma, -sharp_clamp, sharp_clamp);  //TODO Try a curve function instead of a clamp
    
      // -- Combining the values to get the final sharpened pixel	--
      float4 done = ori + sharp_luma;    // Add the sharpening to the original.
     
    // .------------------------------------------._Returning the output_.-----------------------------------------------. 
    
      #if show_sharpen == 1
        //float3 chroma = ori - luma;
        //done = abs(sharp * 4).rrr;
        done = saturate(0.5 + (sharp_luma * 4)).rrrr;
      #endif
    
      #if splitscreen == 1
        if (tex.x < 0.5)
          done = ori;
      #endif
    
      return done;
    
    }
     
  10. XRyche

    XRyche Guest

    Messages:
    19
    Likes Received:
    0
    GPU:
    MSI AMD R7 265 OC 2GB
    Thanks CeeJay.dk for optimizing the Vibrance shader to use with MPC-HC. It's was just what I was looking for to use with movies and broadcast TV. It's a definite improvement over a saturation shader for that type of media, not so much for anime/cartoons. It has a tendency to wash anime out.
     

  11. AUTh0r1ty

    AUTh0r1ty Guest

    Messages:
    10
    Likes Received:
    0
    GPU:
    nvidia 680
    @CeeJay.dk I really like that injector!

    One question regarding presets.
    It is not possible to switch between presets by a keypress while inside the application, or?
    That would be pretty awesome. :D
     
  12. CeeJay.dk

    CeeJay.dk Guest

    Messages:
    691
    Likes Received:
    14
    GPU:
    Radeon 6870
    I was going to say "No I can't add support for more hotkey to the injector without it's sourcecode", but then I had a clever idea.

    The injector can reload shaders using a hotkey, so if you could use another program to alter the sweetfx_preset.txt file using a hotkey, you could press the hotkey for that program and then the reload shaders key.

    There are many freeware hotkey programs available and I could write a small cmd script to change the files.

    I'll see what I can do.
     
  13. Mikedogg

    Mikedogg Guest

    Messages:
    2,830
    Likes Received:
    0
    GPU:
    Radeon HD 4650M 1GB
    ^You ever considered giving 'Japamd' a hand with "RadeonPro"? He is working on SMAA as a feature too. I'm sure he could use a knowledgeable person like yourself. ;)
     
  14. TFL Replica

    TFL Replica Guest

    Messages:
    387
    Likes Received:
    5
    GPU:
    RTX 3060 Ti
    Cool. :thumbup:
     
  15. The General

    The General Guest

    Messages:
    3,108
    Likes Received:
    5
    GPU:
    FirePro W5000 2GB
    Not sure if anyone notice, but FXAA isn't making things blurry anymore with the newest 306 drivers. :)
     

  16. fagoatse

    fagoatse Guest

    Messages:
    140
    Likes Received:
    0
    GPU:
    nvidia
    has anybody succeed in adding sweetfx to black mesa?
     
  17. Caleb171

    Caleb171 Member

    Messages:
    18
    Likes Received:
    0
    GPU:
    Sapphire 7950 @1200/1600
    I put the sweetfx files in steamapps/username/source sdk base 2007 (where hl2.exe is) but... doesn't seems to work...
     
  18. fagoatse

    fagoatse Guest

    Messages:
    140
    Likes Received:
    0
    GPU:
    nvidia
    confirmed
     
  19. Mikedogg

    Mikedogg Guest

    Messages:
    2,830
    Likes Received:
    0
    GPU:
    Radeon HD 4650M 1GB
    Sweetfx will not work since bms does not contain an executable.
     
  20. Caleb171

    Caleb171 Member

    Messages:
    18
    Likes Received:
    0
    GPU:
    Sapphire 7950 @1200/1600
    When you alt-tab you will see hl2.exe in task manager...
     

Share This Page