SweetFX Shader Suite release and discussion thread #4

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

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

    JPulowski Active Member

    Messages:
    84
    Likes Received:
    0
    GPU:
    NVIDIA GeForce GTX 690
    Here is the updated Lumasharpen shader for MPC-HC. Enjoy. :)
    Code:
    /*
       _____________________
    
         LumaSharpen 1.4.1
       _____________________
    
      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
    */
    
    // -- Sharpening --
    #define sharp_strength 0.65   //[0.10 to 3.00] Strength of the sharpening
    #define sharp_clamp    0.035  //[0.000 to 1.000] Limits maximum amount of sharpening a pixel recieves - Default is 0.035
    
    // -- Advanced sharpening settings --
    #define pattern 2        //[1|2|3|4] Choose a sample pattern. 1 = Fast, 2 = Normal, 3 = Wider, 4 = Pyramid shaped.
    #define offset_bias 1.0  //[0.0 to 6.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 sharpening settings --
    #define show_sharpen 0   //[0 or 1] Visualize the strength of the sharpen (multiplied by 4 to see it better)
    
    sampler s0 : register(s0);
    float4 p0 :  register(c0);
    
    #define px (1.0 / (p0[0]))
    #define py (1.0 / (p0[1]))
    
    
       /*-----------------------------------------------------------.
      /                      Developer settings                     /
      '-----------------------------------------------------------*/
    #define CoefLuma float3(0.2126, 0.7152, 0.0722)      // BT.709 & sRBG luma coefficient (Monitors and HD Television)
    //#define CoefLuma float3(0.299, 0.587, 0.114)       // BT.601 luma coefficient (SD Television)
    //#define CoefLuma float3(1.0/3.0, 1.0/3.0, 1.0/3.0) // Equal weight coefficient
    
       /*-----------------------------------------------------------.
      /                          Main code                          /
      '-----------------------------------------------------------*/
    
    float4 LumaSharpenPass(float4 inputcolor, float2 tex )
    {
      // -- Get the original pixel --
      float3 ori = tex2D(s0, tex).rgb;       // ori = original pixel
    
      // -- Combining the strength and luma multipliers --
      float3 sharp_strength_luma = (CoefLuma * sharp_strength); //I'll be combining even more multipliers with it later on
    
       /*-----------------------------------------------------------.
      /                       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 ]
    
        float3 blur_ori = tex2D(s0, tex + (float2(px,py) / 3.0) * offset_bias).rgb;  // North West
        blur_ori += tex2D(s0, tex + (float2(-px,-py) / 3.0) * offset_bias).rgb; // South East
    
        //blur_ori += tex2D(s0, tex + float2(px,py) / 3.0 * offset_bias); // North East
        //blur_ori += tex2D(s0, tex + float2(-px,-py) / 3.0 * 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 ]
    
    
        float3 blur_ori = tex2D(s0, tex + float2(px,-py) * 0.5 * offset_bias).rgb; // South East
        blur_ori += tex2D(s0, tex + float2(-px,-py) * 0.5 * offset_bias).rgb;  // South West
        blur_ori += tex2D(s0, tex + float2(px,py) * 0.5 * offset_bias).rgb; // North East
        blur_ori += tex2D(s0, tex + float2(-px,py) * 0.5 * offset_bias).rgb; // 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 ,   ]
    
        float3 blur_ori = tex2D(s0, tex + float2(0.4*px,-1.2*py)* offset_bias).rgb;  // South South East
        blur_ori += tex2D(s0, tex + float2(-1.2*px,-0.4*py) * offset_bias).rgb; // West South West
        blur_ori += tex2D(s0, tex + float2(1.2*px,0.4*py) * offset_bias).rgb; // East North East
        blur_ori += tex2D(s0, tex + float2(-0.4*px,1.2*py) * offset_bias).rgb; // 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 ]
    
        float3 blur_ori = tex2D(s0, tex + float2(0.5 * px,-py * offset_bias)).rgb;  // South South East
        blur_ori += tex2D(s0, tex + float2(offset_bias * -px,0.5 * -py)).rgb; // West South West
        blur_ori += tex2D(s0, tex + float2(offset_bias * px,0.5 * py)).rgb; // East North East
        blur_ori += tex2D(s0, tex + float2(0.5 * -px,py * offset_bias)).rgb; // North North West
    
        //blur_ori += (2 * ori); // Probably not needed. Only serves to lessen the effect.
    
        blur_ori /= 4.0;  //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 (slower) 9 tap gaussian using 9 texture fetches.
      #if pattern == 8
    
    	// -- Gaussian filter --
    	//   [ 1 , 2 , 1 ]
    	//   [ 2 , 4 , 2 ]
     	//   [ 1 , 2 , 1 ]
    
        half3 blur_ori = tex2D(s0, tex + float2(-px,py) * offset_bias).rgb; // North West
        blur_ori += tex2D(s0, tex + float2(px,-py) * offset_bias).rgb;     // South East
        blur_ori += tex2D(s0, tex + float2(-px,-py)  * offset_bias).rgb;  // South West
        blur_ori += tex2D(s0, tex + float2(px,py) * offset_bias).rgb;    // North East
    
        half3 blur_ori2 = tex2D(s0, tex + float2(0,py) * offset_bias).rgb; // North
        blur_ori2 += tex2D(s0, tex + float2(0,-py) * offset_bias).rgb;    // South
        blur_ori2 += tex2D(s0, tex + float2(-px,0) * offset_bias).rgb;   // West
        blur_ori2 += tex2D(s0, tex + float2(px,0) * offset_bias).rgb;   // East
        blur_ori2 *= 2.0;
    
        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.0;  //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 (slower) 9 tap high pass using 9 texture fetches.
      #if pattern == 9
    
    	// -- Gaussian filter --
    	//   [ 1 , 1 , 1 ]
    	//   [ 1 , 1 , 1 ]
     	//   [ 1 , 1 , 1 ]
    
        float3 blur_ori = tex2D(s0, tex + float2(-px,py) * offset_bias).rgb; // North West
        blur_ori += tex2D(s0, tex + float2(px,-py) * offset_bias).rgb;     // South East
        blur_ori += tex2D(s0, tex + float2(-px,-py)  * offset_bias).rgb;  // South West
        blur_ori += tex2D(s0, tex + float2(px,py) * offset_bias).rgb;    // North East
    
        blur_ori += ori.rgb; // Probably not needed. Only serves to lessen the effect.
    
        blur_ori += tex2D(s0, tex + float2(0,py) * offset_bias).rgb;    // North
        blur_ori += tex2D(s0, tex + float2(0,-py) * offset_bias).rgb;  // South
        blur_ori += tex2D(s0, tex + float2(-px,0) * offset_bias).rgb; // West
        blur_ori += tex2D(s0, tex + float2(px,0) * offset_bias).rgb; // 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 --
      float3 sharp = ori - blur_ori;  //Subtracting the blurred image from the original image
    
      #if 0 //New experimental limiter .. not yet finished
        float sharp_luma = dot(sharp, sharp_strength_luma); //Calculate the luma
        sharp_luma = (abs(sharp_luma)*8.0) * exp(1.0-(abs(sharp_luma)*8.0)) * sign(sharp_luma) / 16.0; //I should probably move the strength modifier here
    
      #elif 0 //SweetFX 1.4 code
        // -- 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
      
      #else //SweetFX 1.5.1 code
        // -- Adjust strength of the sharpening and clamp it--
        float4 sharp_strength_luma_clamp = float4(sharp_strength_luma * (0.5 / sharp_clamp),0.5); //Roll part of the clamp into the dot
    
    
    
    
    
        //sharp_luma = saturate((0.5 / sharp_clamp) * sharp_luma + 0.5); //scale up and clamp
        float sharp_luma = saturate(dot(float4(sharp,1.0), sharp_strength_luma_clamp)); //Calculate the luma, adjust the strength, scale up and clamp
        sharp_luma = (sharp_clamp * 2.0) * sharp_luma - sharp_clamp; //scale down
      #endif
    
       /*-----------------------------------------------------------.
      /                     Returning the output                    /
      '-----------------------------------------------------------*/
      #if show_sharpen == 1
        //inputcolor.rgb = abs(sharp * 4.0);
    
    
        inputcolor.rgb = saturate(0.5 + (sharp_luma * 4)).rrr;
      #endif
    
      return saturate(inputcolor);
    
    }
    
    float4 main(float2 tex : TEXCOORD0) : COLOR {
    	float4 FinalColor = tex2D(s0, tex);
    	FinalColor = LumaSharpenPass(FinalColor,tex);
    	return FinalColor;
    }
    CeeJay.dk, can you upload this and the shaders on my previous post to dropcanvas? Thanks.
     
  2. r3dfield

    r3dfield Active Member

    Messages:
    57
    Likes Received:
    0
    GPU:
    GTX980 OC@1541Mhz/4001Mhz
    there is still no working sweetfx version for battlefield 4 under win7 x64? Kputtes is offline.
     
  3. WhiteLightning

    WhiteLightning Don Illuminati Staff Member

    Messages:
    26,799
    Likes Received:
    77
    GPU:
    Inno3d GTX 1070 iChill x4
    Thanks!

    Ive exported the reg file for this for myself for future use. might anyone want it , here it is http://www.mediafire.com/?kgdm33kp1vobf33

    -edit- updated latest lumasharpen script
     
    Last edited: Oct 2, 2013
  4. CeeJay.dk

    CeeJay.dk Master Guru

    Messages:
    686
    Likes Received:
    1
    GPU:
    Radeon 6870
    Shader injectors that I know of:
    • ENB : No 64 bit or DX10/11 support.
    • InjectFXAA (by [Somedude]) : DX9/10/11 support. No 64bit support. Only supports FXAA. Development have stopped.
    • InjectSMAA (by MrHaandi) - The default injector in SweetFX : No 64 bit support. SMAA is the start of chain. Development have stopped.
    • Shady business (by Kukkimonsuta) : Was in development for SweetFX, but development stopped. Boulotaur and Crosire have been allowed to study the source code. Was never released publicly.
    • Boulotaurs injector : 64-bit support, SMAA at end of chain. Boulotaur have not been heard from in months. Development have stopped/been halted.
    • eFX (by Crosire) : 64bit support. Win 8.1 support. DX9/10/11 and OpenGL support. In active development. Not yet ready for release. Will allow for effects to be placed where ever in the chain you like

    I intend to make the order:

    LumaSharpen
    Cartoon
    SMAA/FXAA antialiasing
    HDR
    Bloom
    Explosion
    CRT
    .. the rest
     
    Last edited: Oct 2, 2013

  5. K-putt

    K-putt Master Guru

    Messages:
    472
    Likes Received:
    0
    GPU:
    GTX 1080Ti
    Sorry for that. http://rghost.net/49100617
    File got deleted for no reason. I really need a better host. Maybe Dropbox.
     
  6. CeeJay.dk

    CeeJay.dk Master Guru

    Messages:
    686
    Likes Received:
    1
    GPU:
    Radeon 6870
    Ge.tt, dropcanvas and dropbox all work nicely for me.
    So the does being hosted directly on Guru3D but that's not an option for you.
     
  7. Preacher0815

    Preacher0815 Member

    Messages:
    30
    Likes Received:
    0
    Had some good experiences with multiupload.nl, but I don't know how easy it is to take down stuff with them.
     
  8. K-putt

    K-putt Master Guru

    Messages:
    472
    Likes Received:
    0
    GPU:
    GTX 1080Ti
    Thanks for the tips!

    Boulotaur2024 Injector with CeeJay.dk's 1.5.1 Shader + Chromatic Aberration Shader

    Ge.tt
    Dropcanvas
    Dropbox

    By the way. Does anyone know who is in charge of http://sfx.thelazy.net/games/ ?
    I wan't to ask if some small updates can be made on this site.
     
    Last edited: Oct 2, 2013
  9. apoklyps3

    apoklyps3 Member Guru

    Messages:
    142
    Likes Received:
    0
    GPU:
    GTX970-DC2OC-4GD5-BLACK
    That being said the eFX will be the only option for us, windows 8.1 users (without radeonpro tricks), but the injector is still WIP. Correct?
     
  10. JPulowski

    JPulowski Active Member

    Messages:
    84
    Likes Received:
    0
    GPU:
    NVIDIA GeForce GTX 690
    CeeJay.dk, I ported all other d2d shaders to MPC-HC successfully but the latest LumaSharpen shader seems not to work in MPC-HC. Do you have any idea why?
     

  11. CeeJay.dk

    CeeJay.dk Master Guru

    Messages:
    686
    Likes Received:
    1
    GPU:
    Radeon 6870
    Terrasque runs that.
    http://forums.guru3d.com/member.php?u=245860

    He lives up to his website name "the lazy"

    He's not very active on Guru3D anymore, but he still posts regularly on reddit as http://www.reddit.com/user/TheTerrasque
     
  12. CeeJay.dk

    CeeJay.dk Master Guru

    Messages:
    686
    Likes Received:
    1
    GPU:
    Radeon 6870
    No idea.. I'm guessing you did something wrong ;)

    I'll look into it, but until then don't feel discouraged to use the LumaSharpen from 1.4. It has exactly the same quality - the new one is just a tiny bit faster.

    Speed is not usually an issue with shaders in MPC.
     
  13. JPulowski

    JPulowski Active Member

    Messages:
    84
    Likes Received:
    0
    GPU:
    NVIDIA GeForce GTX 690
    It's kinda funny. When I set "show_sharpen" to "1" it works. But when it's "0" it doesn't.
     
  14. thatguy91

    thatguy91 Ancient Guru

    Messages:
    6,562
    Likes Received:
    55
    GPU:
    XFX RX 480 RS 4 GB
    I removed the comment section at the top such that it goes directly to:
    Code:
    // -- Sharpening --
    #define sharp_strength 0.55   //[0.10 to 3.00] Strength of the sharpening
    #define sharp_clamp    0.035  //[0.000 to 1.000] Limits maximum amount of sharpening a pixel recieves - Default is 0.035
    and it worked, so I assume the error is in the formatting of the top comment part. I found this because the compile error in MPC-HC was for the 'by' in the comment.
     
  15. Crosire

    Crosire Member Guru

    Messages:
    164
    Likes Received:
    0
    GPU:
    -
    By the way, this is also fixed with eFX since the earliest build and does not require injection using some different named file. It's working fine as "d3d9.dll" on Optimus laptops (Can prove this because development takes place on one, so this was a big point on the todo list).
     
    Last edited: Oct 2, 2013

  16. JPulowski

    JPulowski Active Member

    Messages:
    84
    Likes Received:
    0
    GPU:
    NVIDIA GeForce GTX 690
    Okay, solved it. The problem is when I only use "return saturate(inputcolor)" it just gives the same image. Then I made some changes so the shader now gives "original image + sharpen". Here is the updated and finally working one:
    Code:
    /*
       _____________________
    
         LumaSharpen 1.4.1
       _____________________
    
      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
    */
    
    // -- Sharpening --
    #define sharp_strength 3.00   //[0.10 to 3.00] Strength of the sharpening
    #define sharp_clamp    0.035  //[0.000 to 1.000] Limits maximum amount of sharpening a pixel recieves - Default is 0.035
    
    // -- Advanced sharpening settings --
    #define pattern 2        //[1|2|3|4] Choose a sample pattern. 1 = Fast, 2 = Normal, 3 = Wider, 4 = Pyramid shaped.
    #define offset_bias 1.0  //[0.0 to 6.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 sharpening settings --
    #define show_sharpen 0   //[0 or 1] Visualize the strength of the sharpen (multiplied by 4 to see it better)
    
    sampler s0 : register(s0);
    float4 p0 :  register(c0);
    
    #define px (1.0 / (p0[0]))
    #define py (1.0 / (p0[1]))
    
    
       /*-----------------------------------------------------------.
      /                      Developer settings                     /
      '-----------------------------------------------------------*/
    #define CoefLuma float3(0.2126, 0.7152, 0.0722)      // BT.709 & sRBG luma coefficient (Monitors and HD Television)
    //#define CoefLuma float3(0.299, 0.587, 0.114)       // BT.601 luma coefficient (SD Television)
    //#define CoefLuma float3(1.0/3.0, 1.0/3.0, 1.0/3.0) // Equal weight coefficient
    
       /*-----------------------------------------------------------.
      /                          Main code                          /
      '-----------------------------------------------------------*/
    
    float4 LumaSharpenPass(float4 inputcolor, float2 tex )
    {
      // -- Get the original pixel --
      float3 ori = tex2D(s0, tex).rgb;       // ori = original pixel
    
      // -- Combining the strength and luma multipliers --
      float3 sharp_strength_luma = (CoefLuma * sharp_strength); //I'll be combining even more multipliers with it later on
    
       /*-----------------------------------------------------------.
      /                       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 ]
    
        float3 blur_ori = tex2D(s0, tex + (float2(px,py) / 3.0) * offset_bias).rgb;  // North West
        blur_ori += tex2D(s0, tex + (float2(-px,-py) / 3.0) * offset_bias).rgb; // South East
    
        //blur_ori += tex2D(s0, tex + float2(px,py) / 3.0 * offset_bias); // North East
        //blur_ori += tex2D(s0, tex + float2(-px,-py) / 3.0 * 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 ]
    
    
        float3 blur_ori = tex2D(s0, tex + float2(px,-py) * 0.5 * offset_bias).rgb; // South East
        blur_ori += tex2D(s0, tex + float2(-px,-py) * 0.5 * offset_bias).rgb;  // South West
        blur_ori += tex2D(s0, tex + float2(px,py) * 0.5 * offset_bias).rgb; // North East
        blur_ori += tex2D(s0, tex + float2(-px,py) * 0.5 * offset_bias).rgb; // 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 ,   ]
    
        float3 blur_ori = tex2D(s0, tex + float2(0.4*px,-1.2*py)* offset_bias).rgb;  // South South East
        blur_ori += tex2D(s0, tex + float2(-1.2*px,-0.4*py) * offset_bias).rgb; // West South West
        blur_ori += tex2D(s0, tex + float2(1.2*px,0.4*py) * offset_bias).rgb; // East North East
        blur_ori += tex2D(s0, tex + float2(-0.4*px,1.2*py) * offset_bias).rgb; // 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 ]
    
        float3 blur_ori = tex2D(s0, tex + float2(0.5 * px,-py * offset_bias)).rgb;  // South South East
        blur_ori += tex2D(s0, tex + float2(offset_bias * -px,0.5 * -py)).rgb; // West South West
        blur_ori += tex2D(s0, tex + float2(offset_bias * px,0.5 * py)).rgb; // East North East
        blur_ori += tex2D(s0, tex + float2(0.5 * -px,py * offset_bias)).rgb; // North North West
    
        //blur_ori += (2 * ori); // Probably not needed. Only serves to lessen the effect.
    
        blur_ori /= 4.0;  //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 (slower) 9 tap gaussian using 9 texture fetches.
      #if pattern == 8
    
    	// -- Gaussian filter --
    	//   [ 1 , 2 , 1 ]
    	//   [ 2 , 4 , 2 ]
     	//   [ 1 , 2 , 1 ]
    
        half3 blur_ori = tex2D(s0, tex + float2(-px,py) * offset_bias).rgb; // North West
        blur_ori += tex2D(s0, tex + float2(px,-py) * offset_bias).rgb;     // South East
        blur_ori += tex2D(s0, tex + float2(-px,-py)  * offset_bias).rgb;  // South West
        blur_ori += tex2D(s0, tex + float2(px,py) * offset_bias).rgb;    // North East
    
        half3 blur_ori2 = tex2D(s0, tex + float2(0,py) * offset_bias).rgb; // North
        blur_ori2 += tex2D(s0, tex + float2(0,-py) * offset_bias).rgb;    // South
        blur_ori2 += tex2D(s0, tex + float2(-px,0) * offset_bias).rgb;   // West
        blur_ori2 += tex2D(s0, tex + float2(px,0) * offset_bias).rgb;   // East
        blur_ori2 *= 2.0;
    
        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.0;  //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 (slower) 9 tap high pass using 9 texture fetches.
      #if pattern == 9
    
    	// -- Gaussian filter --
    	//   [ 1 , 1 , 1 ]
    	//   [ 1 , 1 , 1 ]
     	//   [ 1 , 1 , 1 ]
    
        float3 blur_ori = tex2D(s0, tex + float2(-px,py) * offset_bias).rgb; // North West
        blur_ori += tex2D(s0, tex + float2(px,-py) * offset_bias).rgb;     // South East
        blur_ori += tex2D(s0, tex + float2(-px,-py)  * offset_bias).rgb;  // South West
        blur_ori += tex2D(s0, tex + float2(px,py) * offset_bias).rgb;    // North East
    
        blur_ori += ori.rgb; // Probably not needed. Only serves to lessen the effect.
    
        blur_ori += tex2D(s0, tex + float2(0,py) * offset_bias).rgb;    // North
        blur_ori += tex2D(s0, tex + float2(0,-py) * offset_bias).rgb;  // South
        blur_ori += tex2D(s0, tex + float2(-px,0) * offset_bias).rgb; // West
        blur_ori += tex2D(s0, tex + float2(px,0) * offset_bias).rgb; // 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 --
      float3 sharp = ori - blur_ori;  //Subtracting the blurred image from the original image
    
      #if 0 //New experimental limiter .. not yet finished
        float sharp_luma = dot(sharp, sharp_strength_luma); //Calculate the luma
        sharp_luma = (abs(sharp_luma)*8.0) * exp(1.0-(abs(sharp_luma)*8.0)) * sign(sharp_luma) / 16.0; //I should probably move the strength modifier here
    
      #elif 0 //SweetFX 1.4 code
        // -- 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
      
      #else //SweetFX 1.5.1 code
        // -- Adjust strength of the sharpening and clamp it--
        float4 sharp_strength_luma_clamp = float4(sharp_strength_luma * (0.5 / sharp_clamp),0.5); //Roll part of the clamp into the dot
    
        //sharp_luma = saturate((0.5 / sharp_clamp) * sharp_luma + 0.5); //scale up and clamp
        float sharp_luma = saturate(dot(float4(sharp,1.0), sharp_strength_luma_clamp)); //Calculate the luma, adjust the strength, scale up and clamp
        sharp_luma = (sharp_clamp * 2.0) * sharp_luma - sharp_clamp; //scale down
    	float4 done = inputcolor + sharp_luma;
      #endif
    
       /*-----------------------------------------------------------.
      /                     Returning the output                    /
      '-----------------------------------------------------------*/
      #if show_sharpen == 1
        //inputcolor.rgb = abs(sharp * 4.0);
       done = saturate(0.5 + (sharp_luma * 4)).rrr;
      #endif
      return saturate(done);
    
    }
    
    float4 main(float2 tex : TEXCOORD0) : COLOR {
    	float4 FinalColor = tex2D(s0, tex);
    	FinalColor = LumaSharpenPass(FinalColor,tex);
    	return FinalColor;
    }
     
  17. mccoy

    mccoy New Member

    Messages:
    5
    Likes Received:
    0
    GPU:
    nvidia 670 gtx
    how do i use this settings? just copy paste inside the settings.tx?
     
  18. vejn

    vejn Maha Guru

    Messages:
    1,002
    Likes Received:
    0
    GPU:
    MSI 7870 TF3
    Guys, do you know how to record videos with MSI afterburner but with swwetfx ON.
    I checked use modified dx libraries but video has not been recorded.
     
  19. JPulowski

    JPulowski Active Member

    Messages:
    84
    Likes Received:
    0
    GPU:
    NVIDIA GeForce GTX 690
    Take a look at this.

    Did you try to use Fraps or Mirillis Action?
     
  20. Martigen

    Martigen Member Guru

    Messages:
    182
    Likes Received:
    9
    GPU:
    GTX 1080Ti SLI
    *squeals like a little girl* Awesome :) Cannot wait.

    And thankyou Crosire for your injector and working with Ceejay.

    Mart
     
Thread Status:
Not open for further replies.

Share This Page