SweetFX Shader Suite release and discussion thread #2

Discussion in 'Games, Gaming & Game-demos' started by Hilbert Hagedoorn, Jan 8, 2013.

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

    jelbo Member

    Messages:
    26
    Likes Received:
    0
    GPU:
    nVidia GTX670 DirectCUII
    Great to see the CRT shader port integrated now. I hope CeeJay.dk and Boulotaur will join forces with the injector :)

    As for new features, has anyone thought about my suggestion of upscaling through the injector combined with the CRT shader? It would be great for emulators that don't offer a 'native resolution' option, but some pc games as well.
     
    Last edited: Mar 18, 2013
  2. brad86

    brad86 Member

    Messages:
    18
    Likes Received:
    0
    GPU:
    MSI GTX 960 4GB OC
    Any word on the halation effect for the crt shader?
     
  3. CeeJay.dk

    CeeJay.dk Master Guru

    Messages:
    686
    Likes Received:
    1
    GPU:
    Radeon 6870
    We still don't have an injector that can support multipass effects, so no Halation effects yet.
     
  4. CeeJay.dk

    CeeJay.dk Master Guru

    Messages:
    686
    Likes Received:
    1
    GPU:
    Radeon 6870
    Good thing you reminded me. I'll put that in.
     

  5. sexus

    sexus Master Guru

    Messages:
    300
    Likes Received:
    0
    GPU:
    EVGA GF GTX 680 sli
    dont do it , anything but facebook :puke2:

    btw , would there be an easier way to make the changes from 1.3 to 1.4 carry over in the settings , since i can already see the sore fingers im gona have by having to change my 30 or so settings.inis by hand ceejay , since like half of them have vignetting etc , we need an easier way , hell imagine things changing with every release as i asume they do :bang:
     
    Last edited: Mar 18, 2013
  6. Marcel

    Marcel Maha Guru

    Messages:
    1,132
    Likes Received:
    0
    GPU:
    MSI GTX 1070 Gaming
    [​IMG]
    [​IMG]
    [​IMG]
     
  7. k1net1cs

    k1net1cs Ancient Guru

    Messages:
    3,783
    Likes Received:
    0
    GPU:
    Radeon HD 5650m (550/800)
    CeeJay, I just had the time to do a little conversion to mimic the MPC-HC version of SweetFX shaders you made back then using 1.3, but I used the 1.4 preview code.

    Are these correct?


    LumaSharpen
    Code:
    /*
       _____________________
    
         LumaSharpen 1.3.13
       _____________________
    
      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 0.60   //(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)
    
    
    /*------------------------*/
    /*-- 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
    
      float4 p1 : register(c1);
    
      #define px (p1.x) //one_over_width
      #define py (p1.y) //one_over_height
    
      #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(s0, 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 ]
    
        float4 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.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 , 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.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 ]
    
        float4 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.
      float4 done = ori + sharp_luma;    // Add the sharpening to the input color.
    
      // I have a feeling I might use a lerp somewhere in here to calculate the sharpened pixel slightly faster - will look into it later.
    
    
      /*--------------------------*/
      /*-- Returning the output --*/
      /*--------------------------*/
      
      #if show_sharpen == 1
        //float4 chroma = ori - luma;
        //done = abs(sharp * 4).rrr;
        done = saturate(0.5 + (sharp_luma * 4)).rrrr;
      #endif
    
      return saturate(done);
    }
    Vibrance
    Code:
    /*
       ____________
    
         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.
    */
    
    /*-------------------*/
    /*-- User settings --*/
    /*-------------------*/
    
    #define Vibrance 0.15 //[-1.00 to 1.00] Intelligently saturates (or desaturates if you use negative values) the pixels depending on their original saturation.
    
    
    /*------------------------*/
    /*-- Defining constants --*/
    /*------------------------*/
    
    sampler s0 : register(s0);
    
    
    /*---------------*/
    /*-- Main code --*/
    /*---------------*/
    
    float4 VibrancePass( float4 colorInput )
    {
      float4 color = colorInput; //original input color
      float3 lumCoeff = float3(0.212656, 0.715158, 0.072186);  //Values to calculate luma with
    
      float luma = dot(lumCoeff, color.rgb); //calculate luma (grey)
    
      float max_color = max(colorInput.r, max(colorInput.g,colorInput.b)); //Find the strongest color
      float min_color = min(colorInput.r, min(colorInput.g,colorInput.b)); //Find the weakest color
    
      float color_saturation = max_color - min_color; //The difference between the two is the saturation
    
      //color.rgb = lerp(luma, color.rgb, (1.0 + (Vibrance * (1.0 - color_saturation)))); //extrapolate between luma and original by 1 + (1-saturation) - simple
      color.rgb = lerp(luma, color.rgb, (1.0 + (Vibrance * (1.0 - (sign(Vibrance) * color_saturation))))); //extrapolate between luma and original by 1 + (1-saturation) - current
      //color.rgb = lerp(luma, color.rgb, 1.0 + (1.0-pow(color_saturation, 1.0 - (1.0-Vibrance))) ); //pow version
    
      return color; //return the result
      //return color_saturation.xxxx; //Visualize the saturation
    }
    
    float4 main(float2 tex : TEXCOORD0) : COLOR {
      float4 c0 = tex2D(s0, tex);
    
      c0 = VibrancePass(c0);
    
      return c0;
    }

    I've taken the liberty to 'clean-up' the codes from trailing spaces and tabs, and also changed some comment 'decorations' so both have the same look.
    Also, MPC-HC for some reason refused to correctly save the LumaSharpen code before the clean-up.
    It compiles fine when editing in MPC-HC, but then MPC-HC seems to prematurely concat the code when saving it, resulting it not working the next time I open the player.

    They work fine as I've tested it on MPC-HC, but I don't really know if they work as intended or not, nor whether the changes I made reverted the improvements back to 1.3 version.
     
    Last edited: Mar 18, 2013
  8. ISTFFShark

    ISTFFShark New Member

    Messages:
    4
    Likes Received:
    0
    GPU:
    NVIDIA Geforce GTX 675M
    Marcel, is it possible that you upload some of your great settings on this site ? http://sfx.thelazy.net/games/

    I really love your settings !
     
  9. xNAPx

    xNAPx Member Guru

    Messages:
    104
    Likes Received:
    0
    GPU:
    MSI R7970 Lightning
    that's weird because every version worked flawlessy until now with radeon pro, so that's new to me, i used a tomb raider preset anyway, maybe it's because of this
     
  10. n9nu

    n9nu Member

    Messages:
    32
    Likes Received:
    0
    GPU:
    Nvidia Titan X Pascal
    For use with all compatible games or just those which are not behaving...

    Hi guys

    I know this may sound like a 'newbie' question here, but I will ask anyways :)

    If I am experiencing no negative issues with quality/performance say with Crysis 3, would this mod just give you additional features you could apply 'on top of' the in game/3rd party app settings you currently have or is it just for games that don't seem to play nice with certain systems/gpu's, & drivers, etc. in which acts as a 'fix' so to speak.

    I didn't see Crysis 3 listed, so I am assuming no one has created a 'preset' for that one yet and/or most users are having good luck using the in-game/3rd party app settings and thus would not need to be added to the game list?

    Confusing.....man...I don't even know if I can decipher my own questions LOL

    Tnx


    Tim
    Reactor-Critical (C) 1998
     
    Last edited: Mar 18, 2013

  11. CeeJay.dk

    CeeJay.dk Master Guru

    Messages:
    686
    Likes Received:
    1
    GPU:
    Radeon 6870
    Do you know of a tool/texteditor that can clean-up the code from trailing spaces , and replace tabs with a set number of spaces.
    My problem with order stems from using different editors on different computers and they disagree on how many spaces a tab is, so when it aligns in one, it doesn't in the others.. and also laziness on my part.

    Do you have MPC-HC set to save it's options in an ini file or in the registry. One of them breaks saving shaders, and if I recall correctly it's the ini file saving that doesn't work right.
     
  12. Gramps

    Gramps Active Member

    Messages:
    84
    Likes Received:
    0
    GPU:
    PNY GTX 770 4GB OC
    Thats funny, because I get a white screen now ..

    But I know for a fact that 1.3 used to work with RadeonPro for me on GTA:SA running ENB v0.076 (which now supports multipass).

    @CeeJay
    Are you saying a version of SweetFX comes with RadeonPro? Where?
     
  13. k1net1cs

    k1net1cs Ancient Guru

    Messages:
    3,783
    Likes Received:
    0
    GPU:
    Radeon HD 5650m (550/800)
    Notepad++ can do all that out of the box; it's under Edit -> Blank Operation.

    As for 'replace tabs with a set number of spaces' it depends on how you set Notepad++ up.
    If you set in its settings to make one tab as two spaces, then it'll replace two tabs as four spaces, and so on.
    You can also set it to automatically convert tab to spaces as you type if you're used to using tabs (which is faster).

    It's under the registry.
    At least, I think it's saving them under the registry because the option to save settings to .ini file is not ticked.

    But, like I said, it wasn't properly saving the shader code before the clean-up.
    After the clean-up it saved the code just fine.
    Maybe it's too sensitive to tabs or trailing spaces?
    I also thought it was probably because of the 'ASCII art' for the section headers (settings, defines, main), which is why I changed them to a more...subdued version of it.

    Didn't really get which one was causing MPC-HC not to save them properly, but it all works now so I don't really mind. :p
     
    Last edited: Mar 18, 2013
  14. ninjafada

    ninjafada Master Guru

    Messages:
    308
    Likes Received:
    0
    GPU:
    pny 670
    yes reg method is working i made a .reg a couple of month ago to install the shaders for my friends and users here
    the ini doesn't like the shaders it save a part of the code
     
  15. CeeJay.dk

    CeeJay.dk Master Guru

    Messages:
    686
    Likes Received:
    1
    GPU:
    Radeon 6870
    SweetFX 1.4 have been release, and with it's release I'm creating a new thread where the first posts are under my control.

    This thread is scheduled to be closed.
    Please continue in the new thread here : http://forums.guru3d.com/showthread.php?t=376265
     

  16. somebody2978

    somebody2978 Member

    Messages:
    41
    Likes Received:
    0
    GPU:
    ZOTAC GTX 650 Ti 2GB AMP!
    It is definitely a problem of the injector. I disabled all shaders and glitches appear anyway.
     
Thread Status:
Not open for further replies.

Share This Page