SweetFX Shader Suite release and discussion thread

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

Thread Status:
Not open for further replies.
  1. CeeJay.dk

    CeeJay.dk Guest

    Messages:
    691
    Likes Received:
    14
    GPU:
    Radeon 6870
    Heh :D

    I just solved the problem with precision errors in the dither shader.
    I'm quite happy with it because not only did I fix it, but I did it very elegantly, without making it any slower - it's actually a little bit faster now.

    I love it when things work out the way you plan.
     
    Last edited: Sep 25, 2012
  2. mypc

    mypc Guest

    what really dither do i mean what is the difference in the game of using dither
     
  3. vejn

    vejn Maha Guru

    Messages:
    1,002
    Likes Received:
    0
    GPU:
    MSI 7870 TF3
    Here is contrast shader from Boris Vorontsov but you may ask him for permision to add it
    Parameters are:
    float EIntensityContrastV2=1.25
    float EColorSaturationV2=2.2;//saturation, works in conjunction with contrast. If you want to decrease or increase colours, youd better use next option
    float EToneMappingCurveV3=7.0 // this is very good

    //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    //ENBSeries: boris-vorontsov@yandex.ru, boris-vorontsov.narod.ru
    //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    /*
    THIS IS HLSL (HIGH LEVEL SHADER LANGUAGE) FILE FOR EXECUTING ADDITIONAL
    HARDWARE EFFECTS. MAKE THE COPY BEFORE CHANGING IT!
    edited by Dpeasant, credits go to DKT for his hdr-tonemap, to OBGE-shader coder guy(didnt remeber his nickname, and i dont have obge currently) for his crysis-colourmood code and to Boris for his enb and skyrim tonemap shader
    */

    //keyboard controled variables
    float tempF1;
    float tempF2;
    float tempF3;
    float tempF4;
    float tempF5;
    float tempF6;
    float tempF7;
    float tempF8;
    float tempF9;
    float tempF0;



    float EIntensityContrastV2=1.25;//contrast,as it says

    float EColorSaturationV2=2.2;//saturation, works in conjunction with contrast. If you want to decrease or increase colours, youd better use next option

    float Color1=0.85;//use this to control overall colours
    float EAdaptationMinV3=0.086;
    float EAdaptationMaxV3=0.28;
    float EToneMappingCurveV3=7.0;
    float Defog=0.05;//this controls the intensity of colourfilter, fogcolor.

    float4 FogColor={0.06, 0.023, 0.086, 0.2}; //Values for blue, green, red and white. Cant remember which goes for what, experiment.

    float4 FogColor2={0.09, 0.1, 0.02, 0.0};//not used

    float Exposure=0.1;//exposure. Can be negative also. I have very poor contrast ration on my screen(350:1), so maybe it will be too exposed for you. Change it yourself.

    float Gamma=1.0;//gamma. Thats it
    float BlueShift=0.05;//Blueshift - overall tint of the image.
    float fRatio = 0.5; // blend ratio (0-1)
    float moodR = 0.75; // mood color red component
    float moodG = 0.66; // mood color green component
    float moodB = 0.515; // mood color blue component
    ////////////////////////////////////////////////////////
    //global variables, already set before executing this code
    float ScreenSize; //width of the display resolution (1024 f.e.)
    float ScreenScaleY; //screen proportions (1.333 for 1024/768)
    float ScreenBrightnessAdaptation;//(-10..10) for bloom it controls how much to dark in the night or when scene is dark (user defined constant factor)
    float bloomPower;//(0..10) actually used for bloom, but may be useful here (user defined constant factor)
    float useBloom;//(0 or 1) if bloom enabled by user



    //textures
    texture2D texColor;
    texture2D texs4;//adaptation enb
    texture2D texs3;//bloom enb
    sampler2D SamplerColor = sampler_state
    {
    Texture = <texColor>;
    MinFilter = LINEAR;
    MagFilter = LINEAR;
    MipFilter = NONE;//NONE;
    AddressU = Clamp;
    AddressV = Clamp;
    SRGBTexture=FALSE;
    };

    sampler2D _s4 = sampler_state
    {
    Texture = <texs4>;
    MinFilter = LINEAR;//
    MagFilter = LINEAR;//
    MipFilter = NONE;//LINEAR;
    AddressU = Clamp;
    AddressV = Clamp;
    SRGBTexture=FALSE;
    MaxMipLevel=0;
    MipMapLodBias=0;
    };

    sampler2D _s3 = sampler_state
    {
    Texture = <texs3>;
    MinFilter = LINEAR;//
    MagFilter = LINEAR;//
    MipFilter = NONE;//LINEAR;
    AddressU = Clamp;
    AddressV = Clamp;
    SRGBTexture=FALSE;
    MaxMipLevel=0;
    MipMapLodBias=0;
    };


    struct VS_OUTPUT_POST {
    float4 vpos : POSITION;
    float2 txcoord : TEXCOORD0;
    };

    struct VS_INPUT_POST {
    float3 pos : POSITION;
    float2 txcoord : TEXCOORD0;
    };




    //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    //
    //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    VS_OUTPUT_POST VS_PostProcess(VS_INPUT_POST IN)
    {
    VS_OUTPUT_POST OUT;

    float4 pos=float4(IN.pos.x,IN.pos.y,IN.pos.z,1.0);

    OUT.vpos=pos;
    OUT.txcoord.xy=IN.txcoord.xy;

    return OUT;
    }




    float4 PS_PostProcess(VS_OUTPUT_POST In) : COLOR
    {
    /*
    float tempF1=5.0;
    float tempF2=4.0;
    float tempF3=1.0;
    float tempF4=1.0;
    float tempF5=1.3;
    float tempF6=4.35;
    float tempF7=1.12;
    float tempF8=1.2;
    float tempF9=3.17;
    float tempF0=1.4;
    */
    //START TO MAKE YOUR CHANGES FROM HERE
    float4 res;
    float4 uvsrc=0;
    uvsrc.xy=In.txcoord;


    float2 offset[8]=
    {
    float2(-1.0,-1.0),
    float2(-1.0, 1.0),
    float2( 1.0, 1.0),
    float2( 1.0,-1.0),
    float2( 0.0, 1.41),
    float2( 0.0,-1.41),
    float2(-1.41, 0.0),
    float2( 1.41, 0.0)
    };
    res=0.2;
    float4 coord=1.0;
    coord.xy=In.txcoord.xy;
    float4 origcolor=tex2D(SamplerColor, coord.xy);
    float origgray=max(origcolor.r, max(origcolor.g, origcolor.b));
    res+=origcolor;
    float range=0.0005*tempF1/ScreenSize;
    for (int i=0; i<8; i++)
    {

    coord.xy=In.txcoord+offset*range;
    float4 color;
    float gray;
    color=tex2D(SamplerColor, coord.xy);
    float4 colordiff=abs(origcolor-color);
    gray=dot(colordiff.rgb,0.333);
    float lerpfact=saturate(8.0*abs(gray)*color.a);//saturate
    res+=lerp(origcolor, color, lerpfact);
    }
    res=res*0.142222;



    float4 color=res; //tex2Dbias(SamplerColor, uvsrc);

    float tf7=tempF7*1.04;
    float tf8=tempF8*0.3;
    //float3 correctedcolor=saturate((1.0-color*tempF9*0.5)*tempF0*0.11);

    //res.rgb=saturate(color.rgb-correctedcolor);
    //res.rgb=pow(res.rgb,0.3)*1.04;





    float4 colInput = tex2D(SamplerColor, coord.xy);
    float4 colMood = 1.0f;
    colMood.r = moodR;
    colMood.g = moodG;
    colMood.b = moodB;
    float fLum = ( colInput.r + colInput.g + colInput.b ) / 3;

    colMood = lerp(0, colMood, saturate(fLum * 2.0));
    colMood = lerp(colMood, 1, saturate(fLum - 0.5) * 2.0);
    float4 colOutput = lerp(colInput, colMood, saturate(fLum * fRatio));
    res.rgb=max(0, colOutput);



    res.rgb = max(0, res.rgb - Defog * FogColor.rgb);
    res.rgb *= pow(2.0f, Exposure);
    res.rgb = pow(res.rgb, Gamma);
    float3 d = res.rgb * float3(1.00f, 1.06f, 1.3f);
    res.rgb = lerp(res.rgb, d, BlueShift);
    //r7.rgb=max(0, r7.rgb - Defog * FogColor2.rgb);



    float luma=dot(res.xyz,0.333);
    float cgray=dot(res.xyz, 0.333);//luma
    float3 poweredcolor=pow(res.xyz, Color1);
    float newgray=dot(poweredcolor.xyz, 0.333);
    res.xyz=poweredcolor.xyz*cgray/(newgray+0.0001);


    float colours=(res.r+res.g+res.b)*0.333; //dot(res.xyz, 0.333);
    float3 diffcolor=res.rgb-colours;
    res.rgb+=diffcolor*0.1;
    float4 Adaptation=tex2D(_s4, 0.5);
    float grayadaptation=max(max(Adaptation.x, Adaptation.y), Adaptation.z);

    grayadaptation=max(grayadaptation, 0.0);
    grayadaptation=min(grayadaptation, 50.0);
    res.xyz=res.xyz/(grayadaptation*EAdaptationMaxV3+EAdaptationMinV3);//*tempF1.x

    float3 xncol=normalize(res.xyz);
    float3 scl=res.xyz/xncol.xyz;


    scl=pow(scl, EIntensityContrastV2);
    xncol.xyz=pow(xncol.xyz, EColorSaturationV2);
    res.xyz=scl*xncol.xyz;


    float3 luma2=res.xyz;
    float lumamax=33.0;
    res.xyz=(res.xyz * (1.0 + res.xyz/lumamax))/(res.xyz + EToneMappingCurveV3);
    //res.xyz=res.xyz*0.6+sin(res.xyz*3.14*0.5)*0.4;
    float3 correctedcolor=saturate((1-res*0.15)*0.021);
    //res.rgb=saturate(res.rgb-correctedcolor)*0.96;
    //res.rgb=pow(res.rgb,0.9)*1.07;


    res.a=1.0;

    return res;
    }







    //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    //
    //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    technique PostProcess
    {
    pass P0
    {
    VertexShader = compile vs_2_0 VS_PostProcess();
    PixelShader = compile ps_2_a PS_PostProcess();

    FogEnable=FALSE;
    ALPHATESTENABLE=FALSE;
    SEPARATEALPHABLENDENABLE=FALSE;
    AlphaBlendEnable=FALSE;
    FogEnable=FALSE;
    SRGBWRITEENABLE=FALSE;
    }
    }


     
    Last edited: Sep 25, 2012
  4. vis

    vis Member

    Messages:
    24
    Likes Received:
    0


    Oh God, that guy is insanely jealous of anyone getting near his "work". Avoid it like the plague. He's such a tool.
     

  5. BetA

    BetA Ancient Guru

    Messages:
    4,526
    Likes Received:
    480
    GPU:
    G1-GTX980@1400Mhz
    Well. I think around 0.4- 0.5 should be the standart for sharpen. There it is Not too sharpen but also u Do See the mild effect on it. So i would saY 0.4 -0.6.

    Greetz Beta
     
  6. TFL Replica

    TFL Replica Guest

    Messages:
    387
    Likes Received:
    5
    GPU:
    RTX 3060 Ti
    In my experience, 0.3 Vibrance can be a bit too much for quite a few games. A default value of 0.2 would be more sensible.

    Btw: congrats on your new thread. It was about time. :)
     
  7. CeeJay.dk

    CeeJay.dk Guest

    Messages:
    691
    Likes Received:
    14
    GPU:
    Radeon 6870
    Some effects .. mostly the vignette but also really big color, exposure and gamma changes to the image, will cause banding artifacts.

    A banding artifact is where color gradients in the image have too few colors to change between and you can clearly see the different steps between the colors.

    The Dither shader interlaces two close colors using a checkerboard pattern to make it look like there is a third middle color.
    This doubles the number of perceived colors and really helps to reduce or remove the banding problem.

    It only dithers the changes SweetFX makes, not the original image though I have some ideas to make that happen in a future version.

    In short - it makes the vignette gradients look smoother.

    Here is a comparison
     
  8. Kuldebar

    Kuldebar Guest

    Messages:
    85
    Likes Received:
    0
    GPU:
    GT730 2GB/DDR5
    SweetFX is amazing in Guild Wars 2. Finally I can turn off that crap FXAA in game and just use this injector with out any detectable performance decrease.
     
  9. BetA

    BetA Ancient Guru

    Messages:
    4,526
    Likes Received:
    480
    GPU:
    G1-GTX980@1400Mhz
    Here, i did some BF3 comparsions for the ones who asked..

    This is not my normal BF3 settings, these are just for Closed Quarters..
    I used Vibrance, luma sharpen and smaa..

    Its a small but impressive change..look at the textures, at the AA and colors..i dont liek it tooo colorfull, so i opnyl used a little of vibrance..but i think u can spot the Diff..

    Also, heres an better comparsion with one of those scenes..
    MOUSE OVER = SWEETFX ENABLED WITH MY SETTINGS

    all screens:

    Original:
    [​IMG]

    SweetFX:
    [​IMG]


    Original:
    [​IMG]

    SweetFX:
    [​IMG]


    Original:
    [​IMG]

    SweetFX:
    [​IMG]


    I used SweetFX there pretty light..no values that are to high, that doesnt fit BF3...But of course u could even use more vibrance and sharpen or other effects..But i dont like that..for some games i use all effects but BF3 - nope..

    At the start i only cared about AA in BF3, casue with the AA Settings form BF3 there was no way i could play while keeping my gfx settings..And sweetfx (smaa) helped me a lot..2 fps drop at all and very nice GFX...

    -BetA-

    edit:

    if u guys want more comparsions and stuff, just tell me what game u would like to see and ill make some screens.

    I also thought ill do some screens with each effect so u guys can see what is what..Maybe CeeJay will put them in teh first post then , like an littel expplanation of teh effects..dunno..

    anyway, Just say what game and im on it..
    -BetA-
     
    Last edited: Sep 25, 2012
  10. CeeJay.dk

    CeeJay.dk Guest

    Messages:
    691
    Likes Received:
    14
    GPU:
    Radeon 6870
    Not just the contrast shaders .. all the effect shaders it seems.
    It's a mess and hard to read at a glance. Almost no comments , functions, named sections and many variables have cryptic names that don't explain what they are used for.
     

  11. XRyche

    XRyche Guest

    Messages:
    19
    Likes Received:
    0
    GPU:
    MSI AMD R7 265 OC 2GB
    JanWillem32 has a very good brightness/contrast/gamma shader in his "Video pixel shader pack 1.4" at http://www.mediafire.com/download.php?025vsef8ads6t5x . It's for video but I'm sure you can adapt it. All his shaders have good notations and I'm reasonably sure he won't have issues with you using it as long as you ask. I mean the whole shader pack is public after all even has GNU.
     
    Last edited: Sep 26, 2012
  12. CeeJay.dk

    CeeJay.dk Guest

    Messages:
    691
    Likes Received:
    14
    GPU:
    Radeon 6870
    I know - I discussed it and my lumasharpen shader with him early this year on Doom9.org
     
  13. ochentay4

    ochentay4 Member

    Messages:
    15
    Likes Received:
    0
    GPU:
    Sapphire R9 285 Dual-X OC
    Holy crap this mod is uber fantastic! I tried it on Borderlands 2 and looks really good.

    I tried to understand how to configure the mod but it is really difficult. How can I increase picture quality of SMAA and the mod overall?
     
  14. Radical_53

    Radical_53 Ancient Guru

    Messages:
    4,358
    Likes Received:
    212
    GPU:
    EVGA RTX 3080 FTW3
    Thanks alot for this handy little "tool"! ;) The quality is great and it seems to have huge potential.

    @beta: Did you post your BF3 settings somewhere or would you care to share them? I tried the settings I used with the FXAA Injector previously and it looked all funny :D
    The colortone setting made the whole picture yellow (instead of a slight tint) and the Technicolor was like wearing really dark shades.
    I like the AA in your pictures as I think BF3 has the worst default AA of any game out at the moment and at the same time the biggest need for good quality AA.
     
  15. Crugath

    Crugath Active Member

    Messages:
    58
    Likes Received:
    0
    GPU:
    MSI GTX 980 4GB
    SweetFX is great! Thanks for creating it :)

    If I may, I have a small suggestion I'd like to make for a future release...

    Not sure how easy this would be to do, but I'd love to see a film grain shader added.

    Something like the film grain available in Left 4 Dead and Black Mesa, I think that would add a lot of atmosphere to a large amount of titles. Especially when combined with other things like technicolour or sepia toning.

    Thanks :D
     

  16. CeeJay.dk

    CeeJay.dk Guest

    Messages:
    691
    Likes Received:
    14
    GPU:
    Radeon 6870
    That's currently not possible to do because the injector dll does not provide a frame number to the shaders.
    I need that to make the film grain different from one frame to another frame or the film grain would be static.
     
  17. Crugath

    Crugath Active Member

    Messages:
    58
    Likes Received:
    0
    GPU:
    MSI GTX 980 4GB
    Ah, fair enough, I thought it'd probably be trickier than I imagined. Thank you very much for the input. And thanks again for the work you've put in!
     
  18. eclap

    eclap Banned

    Messages:
    31,468
    Likes Received:
    4
    GPU:
    Palit GR 1080 2000/11000
    any chance to get this working with wow? i know it works with the 32bit .exe and AA set to 1x in the game, but then it looks a bit jaggy still. tried forcing AA via inspector but it didn't work. basically i want to run 4xAA at least with this on top. is it in any way possible?
     
  19. MaLDo

    MaLDo Master Guru

    Messages:
    568
    Likes Received:
    13
    GPU:
    GTX1080
    I'm absolutely neewie about shaders but can't you apply some kind of math over the actual frame to calculate a random grain.

    Or, can you apply film grain in a second pass over the image next to filter shader and hide a secuential number over the first pass. Imagine a nearly invisible counter in a corner that you can detect when film grain shader occurs.

    Maybe I'm saying a nosense, of course.
     
  20. CeeJay.dk

    CeeJay.dk Guest

    Messages:
    691
    Likes Received:
    14
    GPU:
    Radeon 6870
    I could sample mipmaps from the current frame and use that as a seed for the random function that makes the film grain, and as long as the image changes enough from from to frame that would work (although it would run a little bit slower) - however once nothing in the image changes .. neither would the film grain - it would be just as static as the image.

    This would likely be disturbing .. sometimes the grain would be random and sometimes it would be static.

    I also can't pass data from one frame to another because the injector only lets me access data from the current frame - it does not store the previous frame, so all the shaders can see is the current image.
    Even if I put in an invisible number/pixel in the image (which is very easy - I can use the alpha channel for that), that number would be gone at the very next frame.

    EDIT:
    If it was possible to get a hold of Mr.Haandi and get him to implement a frame counter in the injector (it would probably be easy .. it's just an incrementing variable) then it would be possible to make a film grain shader, but like [somedude] who made the first injector he is very hard to contact.
    He stopped updating his blog and reading the comments on it many months ago.
     
    Last edited: Sep 26, 2012
Thread Status:
Not open for further replies.

Share This Page