View Full Version : SweetFX Video Shaders
toniash
8th April 2014, 07:09
Yes, if it is still user editable. For instance, if I could set it to use a different strength for videos with a horizontal resolution of 720 or lower (SD), 1280 or lower (720p) and 1920 or lower (1080p). I'm assuming if I just set strength to 0, it would turn off sharpening for 1080p videos, which is exactly what I'm looking for. The "one setting for all" approach doesn't really work, because the right settings for 720p videos can really bring out artifacts in low quality 480p videos, and also over-sharpen 1080p videos. If we could customize settings for different resolutions that would be great, kind of like what you can do now in ffdshow.
In PotP you can setup profiles and have different shaders (or none) for 480p 720p or 1080p.
StinDaWg
8th April 2014, 11:08
In PotP you can setup profiles and have different shaders (or none) for 480p 720p or 1080p.
That's a nice feature, but I don't plan on switching from MPC-HC. Been using it too long to change now.
turbojet
10th April 2014, 06:53
Adjusting sharpnessin that case would need to be pre-resize instead of post-resize wouldn't it? If so, I don't know if it would work but how about a pre-resize shader to send info to a post-resize shader?
CeeJay.dk
10th April 2014, 10:24
If so, I don't know if it would work but how about a pre-resize shader to send info to a post-resize shader?
That's a good idea.
It might be possible to pass information about the original video size from a pre-resize shader to a post-resize shader using the alpha channel - assuming it doesn't get cleared by MPC-HC.
JanWillem32
11th April 2014, 12:39
The alpha channel is non-existent for X8R8G8B8 textures. For A16B16G16R16, A16B16G16R16F and A32B32G32R32F the alpha channels are read- and write-enabled (the default). The alpha channel gets scaled normally like the three other channels for all convolution-based resizers. For adaptive resizers, the alpha channel is generally discarded. Note that the adaptive resizers are very experimental, and I don't know if and when I'll add some of them to test.
For renderers outside of the MPC variants, I don't know. You could ask madshi for some information.
adrianmak
14th April 2014, 06:24
Is there any difference to add shader either pre-resize or post-resize shader or both ?
CeeJay.dk
17th April 2014, 15:39
For some yes.
For a shader that just does some form of color modification, it's the same except doing it pre-resize means doing it on less pixels and so it runs faster. The result is the same though.
For shaders that relies on sampling the neighbouring pixels, like a sharpening shader it matter because the result will be streched after you resize it if you run it as a pre-resize shader
For that type of shaders it matter if you do them pre or post-resize. Sometimes one or the other is better .. sometimes both are good and can be used in combination.
feelingblue
24th May 2014, 16:06
Good morning. Sorry for my English.
I have a questions.
I'm trying, by manipulating the parameters inside the lumasharpen shader, to get the same image quality which is achieved using the script finesharp in avisynth.
I'm going very close, but not quite.
The main problem is that with the script i can achieve a better definition.
Have you some advice For me?
My goal is to stop using ffdshow and avisynth because are semi discontinued and very very cpu demanding.
Also the avisynth script cannot be used after madvr but only before, and this is bad for VPR calibration and luma pattern test.
Thank you!
toniash
24th May 2014, 18:16
CeeJay, is it possible to implement something similar to this? ->
http://docs.unity3d.com/Documentation/Components/script-ContrastEnhance.html
Thanks for your work!
CeeJay.dk
26th May 2014, 11:08
CeeJay, is it possible to implement something similar to this? ->
http://docs.unity3d.com/Documentation/Components/script-ContrastEnhance.html
Thanks for your work!
That type of filter is called Local Contrast Enhancement and it's not feasible with the current features available in MPC-HC.
To do this you need to do a very large radius blur and subtract that from the current pixel .. exactly what sharpening does, but with a much larger radius and a lower strength.
That unfortunately requires an insane high amount of texture samples which kills performance (it's also too many texture reads for old cards that use shader model 2).
You can drastically reduce the number needed if you can do 2 passes, use mipmap samples or downsample the original image and sample from that, which would make this filter feasible - but none of these things are possible in MPC-HC as it's single pass only, doesn't enable mipmap and it clears the alpha channel when passing the image from one shader to another so I can't fake 2 passes by making two shaders and chain them (we discussed this earlier in the thread)
toniash
26th May 2014, 12:21
That type of filter is called Local Contrast Enhancement and it's not feasible with the current features available in MPC-HC.
To do this you need to do a very large radius blur and subtract that from the current pixel .. exactly what sharpening does, but with a much larger radius and a lower strength.
That unfortunately requires an insane high amount of texture samples which kills performance (it's also too many texture reads for old cards that use shader model 2).
You can drastically reduce the number needed if you can do 2 passes, use mipmap samples or downsample the original image and sample from that, which would make this filter feasible - but none of these things are possible in MPC-HC as it's single pass only, doesn't enable mipmap and it clears the alpha channel when passing the image from one shader to another so I can't fake 2 passes by making two shaders and chain them (we discussed this earlier in the thread)
Ok thanks!
Shiandow
1st June 2014, 21:02
You can drastically reduce the number needed if you can do 2 passes, use mipmap samples or downsample the original image and sample from that, which would make this filter feasible - but none of these things are possible in MPC-HC as it's single pass only, doesn't enable mipmap and it clears the alpha channel when passing the image from one shader to another so I can't fake 2 passes by making two shaders and chain them (we discussed this earlier in the thread)
FWIW MadVR doesn't erase the alpha channel.
XMonarchY
1st June 2014, 21:15
I read that SweetFX does not work with Windows 8.1...
the_weirdo
2nd June 2014, 10:40
I read that SweetFX does not work with Windows 8.1...
SweetFX supposes to work well with DX9 games/applications on Windows 8.1. Only DX10/11 games/applications are not supported by the injector for now.
EDIT: Oh, I've forgot. These are Video Shaders based-on SweetFX, so they're not affected by the injector of SweetFX not supporting DX10/11 on Windows 8.1.
CeeJay.dk
3rd June 2014, 10:06
I read that SweetFX does not work with Windows 8.1...
SweetFX supposes to work well with DX9 games/applications on Windows 8.1. Only DX10/11 games/applications are not supported by the injector for now.
EDIT: Oh, I've forgot. These are Video Shaders based-on SweetFX, so they're not affected by the injector of SweetFX not supporting DX10/11 on Windows 8.1.
The weirdo is correct. These shaders run using MPC so they are not affected by the problems of the DirectX hook I use for the regular SweetFX package.
The problem is that Windows introduced some new DirectX calls with DX11.2 and the InjectSMAA hook I use does not know how to handle them because it was written before DX11.2 existed.
These calls are correctly handled by RadeonPro and by the EFX alpha, so if you use SweetFX with them it should work with DX11 and Win8.1.
DirectX 9 and 10 games should not be affected.
I also suspect that running the games that have issues in Vista compatibility mode might force the game to only use DX11 or DX11.1 calls which are supported but I don't have Win8.1 so I need someone who do to test my hypothesis.
But again .. the video shader package is not affected by this because it doesn't use InjectSMAA.
toniash
27th October 2014, 14:53
That type of filter is called Local Contrast Enhancement and it's not feasible with the current features available in MPC-HC.
To do this you need to do a very large radius blur and subtract that from the current pixel .. exactly what sharpening does, but with a much larger radius and a lower strength.
That unfortunately requires an insane high amount of texture samples which kills performance (it's also too many texture reads for old cards that use shader model 2).
You can drastically reduce the number needed if you can do 2 passes, use mipmap samples or downsample the original image and sample from that, which would make this filter feasible - but none of these things are possible in MPC-HC as it's single pass only, doesn't enable mipmap and it clears the alpha channel when passing the image from one shader to another so I can't fake 2 passes by making two shaders and chain them (we discussed this earlier in the thread)
Now with Media Player DotNet you can do multipass!!
http://forum.doom9.org/showthread.php?t=171120
Blight
29th October 2014, 03:06
CeeJay.dk:
I'm planning to add shader support through MadVR.
You previously mentioned that MPC-HC doesn't provide an interface for configuration, but I may be able to write one into Zoom Player.
Would you like to discuss how to expose the settings range and default values?
CeeJay.dk
29th October 2014, 11:50
Now with Media Player DotNet you can do multipass!!
http://forum.doom9.org/showthread.php?t=171120
Nice! All my coding time is currently focused on releasing SweetFX 2.0, but I'll look into Media Player DotNet at a later date.
CeeJay.dk
29th October 2014, 11:52
CeeJay.dk:
I'm planning to add shader support through MadVR.
You previously mentioned that MPC-HC doesn't provide an interface for configuration, but I may be able to write one into Zoom Player.
Would you like to discuss how to expose the settings range and default values?
Sure.
My skype and gmail accounts are also named CeeJay.dk
Blight
29th October 2014, 15:52
I tried searching skype, but couldn't find a CeeJay with ".dk" in there.
In any case, it may be useful to other devs if we discussed it here.
I'm thinking you can just specify a tag value for each setting and then in a comment add the "Display Name", "Start Range" and "End Range", something like:
AddSetting(DisplayName=Brightness,MinValue=0,MaxValue=100,Default=24.5,Type=Float)
And the tag value for this setting would be "<Brightness>".
Using this type of setup, I can easily create a GUI that dynamically edits the script in memory before sending it to MadVR.
What do you think?
CeeJay.dk
29th October 2014, 18:27
That must be microsofts fault .. my skype name is ceejay.dk and is associated with my gmail account.
All SweetFX effects write the settings in a special format that can be understood both by humans but also the SweetFX configurator or other GUIs.
#define Curves_contrast 0.15 //[-1.00 to 1.00]
Here the value is ofcourse 0.15 but [-1.00 to 1.00] means the range is from -1.00 (minvalue) to 1.00 (maxvalue)
The amount of decimal places is a hint to how big any increments to the value should be
"to" is a keyword that the configurator understands
other keywords are
"or" or "|" (both mean the same .. a logical OR)
"," is a delimiter that is used when the value is a float2, float3 or float4 (or other multi component type)
another example:
Vibrance_RGB_balance float3(1.00, 1.00, 1.00) //[-10.00 to 10.00,-10.00 to 10.00,-10.00 to 10.00]
Here the type is a float3 and I expressly specify the range for each component, but I could also state it implicitly as
Vibrance_RGB_balance float3(1.00, 1.00, 1.00) //[-10.00 to 10.00]
and it would use the -10.00 to 10.00 range for each component.
For SweetFX 2.0 the settings file is the same but Crosire and I use shader annotations to allow the shader code to communicate with the program running them. I suggest you do the same.
An example from the SweetFX 2.0 closed beta :
uniform float frametime < string source = "frametime"; >; // time in milliseconds it took for the last frame to complete
There are very few things that are hardcoded .. most values are defined using annotations.
Similarly you could get the DisplayName, MinValue and MaxValue from the shadercode using shader annotations and the Type from the variable type itself.
Blight
29th October 2014, 23:29
What you are suggesting contains a lot more parsing overhead than what I was suggestion.
I'll have to give it some thought.
amayra
7th November 2014, 20:35
any update ? :thanks:
iakoboss7
10th September 2015, 01:31
any update??
CeeJay.dk
15th October 2018, 20:53
No updates. But also no issues. The SweetFX Video Shaders still work fine.
Have there been any updates to the ways you can add shaders to videos in the last 5 years?
If so maybe I could make some updates to use those.
I could also port some of the effects from Reshade to MPC-HC (especially the ones I wrote) but several of them are multipass which as far as I know MPC-HC still does not support right.
I did port the ASCII art effect to MPC-HC but I don't know if people are interested in seeing their videos in ASCII.
ABDO
19th October 2018, 14:02
@CeeJay.dk
could you please port (Clarity, Deband,HighPassSharpen,Technicolor2,Layer) if it are Singlepass
CeeJay.dk
24th October 2018, 16:11
I've looked them over :
Clarity : 4 passes and uses 4 buffers too (3 of them at half-size). This is not something that MPC-HC can provide the shaders.
Deband : Was originally ported from MPV. Single pass with no special requirements so it can be ported. I also think I might be able to write a better and/or faster deband shader in the future and there are a few things that stand out to me as less than optimal.
Still a nice shader though.
HighPassSharpen : Single pass with no special requirements so it too can be ported.
It does not use bilinear sampling and hardly even uses linear sampling, but is mostly point sampling. This is hurting its performance.
Also Ioxas code is weird. Observe :
if (HighPassSharpRadius == 1)
{
int sampleOffsetsX[25] = { 0.0, 1, 0, 1, 1, 2, 0, 2, 2, 1, 1, 2, 2, 3, 0, 3, 3, 1, -1, 3, 3, 2, 2, 3, 3 };
int sampleOffsetsY[25] = { 0.0, 0, 1, 1, -1, 0, 2, 1, -1, 2, -2, 2, -2, 0, 3, 1, -1, 3, 3, 2, -2, 3, -3, 3, -3};
float sampleWeights[5] = { 0.225806, 0.150538, 0.150538, 0.0430108, 0.0430108 };
color *= sampleWeights[0];
[loop]
for(int i = 1; i < 5; ++i) {
color += tex2D(ReShade::BackBuffer, texcoord + float2(sampleOffsetsX[i] * ReShade::PixelSize.x, sampleOffsetsY[i] * ReShade::PixelSize.y) * HighPassSharpOffset).rgb * sampleWeights[i];
color += tex2D(ReShade::BackBuffer, texcoord - float2(sampleOffsetsX[i] * ReShade::PixelSize.x, sampleOffsetsY[i] * ReShade::PixelSize.y) * HighPassSharpOffset).rgb * sampleWeights[i];
}
}
So he is setting up two arrays (I would have used one array of float2's but OK) with a length of 25
But then in his loop he uses :
for(int i = 1; i < 5; ++i)
So i is initialized to 1 and must be less than 5.
So he will get 4 loops before exit and because he uses ++i , i will be for those loops 2, 3, 4, and 5.
So what was the point of the array positions 0, 1 and from 6 and up?
Same with weights where he does not use position 0.
I'm also pretty sure this sampling pattern isn't cache friendly but cache friendliness is not something most people know about so I'll give him a pass on that one.
Though it does have some interesting ideas that I have wanted to try for LumaSharpen for a while, like other blend modes.
Technicolor2 : Singlepass and nothing special about it. Can be ported.
Layer : Singlepass but in order to merge the video image with another image we must be able to load another image as a texture that the shaders can use. MPC-HC cannot do this, so it cannot be ported.
May I ask what were you planning to use it for?
See I've only just added it to Reshade and still have many plans for improving it like options to wrap and repeat the layer and tons of blend modes and maybe also give it the possibility to use the depth texture as another layer.
This would open up for so many possibilities that I cannot predict them all but it would be interesting to see what users planned for it.
ABDO
4th December 2018, 21:15
Ah, i feel so bad to forget about my request in SweetFX fourm, i am very sorry for that @CeeJay.dk, Please accept my high respect
and much thanks for your reply
Deband : Was originally ported from MPV. Single pass with no special requirements so it can be ported. I also think I might be able to write a better and/or faster deband shader in the future and there are a few things that stand out to me as less than optimal.
that would be great, then we can use it with fake hdr shader, as alternative to avisynth deband filters
Layer : Singlepass but in order to merge the video image with another image we must be able to load another image as a texture that the shaders can use. MPC-HC cannot do this, so it cannot be ported.
May I ask what were you planning to use it for?
I was planning to use it as alternative to avisynth layer, but i see now that MPC-HC cannot do this job :)
Though it does have some interesting ideas that I have wanted to try for LumaSharpen for a while, like other blend modes.
Technicolor2 : Singlepass and nothing special about it. Can be ported.
that is great news
@CeeJay.dk, any chance to an improvement to the fake hdr filter, it do very nice in fact, is it possible to limit it to the dark area or shadows pixls so we can use it as (enhance shadows) as hdragc filter does, but with much speed improvement, if we can keep the highlight area without any change, that would be nice, and no need to hdragc any more، i am now use your hdr shader In combination with YLevelss to recover highlight after using the fake hdr shader effect, and the result is great as hdragc but much much faster :)
Foyn
7th January 2019, 10:50
Hello~
Was wondering if any1 would share their anime/movies shader presets :devil:
Just the shaders folder would be fine as well.. I'd like to try some different setups I guess :(
butterw2
22nd June 2020, 11:12
SweetFX shaders were ported by CeeJay.dk so they can run in MPC-HC (.hlsl). There seem to have been a few updates at https://github.com/CeeJayDK/SweetFX/tree/master/Shaders (.fx, MIT License) since the package "SweetFX Video Shaders.7z" was posted in this thread in 2014.
Has CeeJay.dk or anyone got mpc-hc versions of the updated/new shaders to share ?
Porting shaders from .fx to .hlsl is easy (unless the shader uses features not available by mpc-hc), but there is also the issue of parameters values which may need tuning for the shaders to be useful for video playback.
SweetFX Shaders I regularly use:
- Monochrome(ConvCoef float3(0.18, 0.41, 0.41) //Agfa 200X),
- Technicolor (defaults),
- LumaSharpen(Pattern 3, Post-resize)
I am curious about FilmGrain.fx (I currently use PS_Noise.hlsl(0.05), which looking at it more closely needs fixing). Any other suggestions for a good lightweight grain shader for video playback ?
I have also developed a couple of pixel shaders for mpc-hc myself: bar_Mask (inspired by the old SweetFX Border), bSide (similar to splitscreen maybe), bStrobe, etc.
They are available here: https://gist.github.com/butterw/
BetA13
22nd June 2020, 16:58
hy all, anyone knows how i can convert the dx9 shaders to dx11 ones?
Since mpchc now supports dx11 shader for the dx11 renderer, i would really like to convert all my shaders into dx11 but i didint find any tutorial or info about it on the interwebz :( If anyone could show me the right direction and maybe some examples i would be happy.. I hope this isnt toooo difficult to do this?
Best Regards
butterw2
24th June 2020, 01:09
Having compared with VLC which includes a built-in grain source, it appears there is a measurable cost in gpu usage to generating grain with a pixel shader in mpc-hc on an integrated gpu.
A source that needs additional grain, may also require some prior edge sharpening, all this post-resize, which compounds the problem.
The PRNG can cause noise artefacts/patterns, which cannot in good faith be considered a feature in this context.
To sum it up, adding grain is useful with some sources even if it is barely visible. it is possible to generate uniform grayscale noise with a pixel shader, however there are limitations. With mpc-hc (EVR-CP) this is the only way to do add noise.
But I leave the grain off by default and don't typically alter Noise settings, so the implementation needs to be reasonably lightweight.
I'll have a look a SweetFX filmgrain.fx to see if it can be used with mpc-hc and what the perf is.
butterw2
24th June 2020, 07:03
I've tried some of the new dx11 shader versions from mpc-hc v1.9.5. They have the same filename as dx9 version, but start with the line:
// $MinimumShaderProfile: ps_4_0.
They compile on mpc-hc v1.9.3 (EVR-CP, dx9), but the output is wrong: Black Screen, White Screen.
BetA13: I'm guessing the dx11 compiler is not backwards compatible with dx9 shaders ?
Looking at the code, porting to dx11 doesn't appear to be difficult, but still needs proper attention. Casual users are going to be confused by all this (after the ongoing debacle of 32 vs 64bits apps...).
BetA13
24th June 2020, 16:46
i see, thank you for the Answer.. Ahh well, i guess i just have to try, and if i cant do it, i can still ask CeeJay.dk if he has some ideas :)
Greetz
butterw2
25th June 2020, 06:49
Alpha channel info is unused in mpc-hc, but using float4 instead of float3 for internal rgba color processing can still be more efficient.
The following modified version of https://github.com/CeeJayDK/SweetFX/blob/master/Shaders/Sepia.fx using float4 SepiaTint uses a single arithmetic operation:
/* --- SweetFx Sepia --- (1 texture, 1 arithmetic) */
#define SepiaTint float4(0.55, 0.43, 0.42, 0)
#define SepiaStrength 0.58 //[0.0 to 1.0]
float4 Sepia2(float4 col){
return lerp(col, col*SepiaTint*2.55, SepiaStrength);
}
lerp is single operation whether on float4 or float3, but you save 1 arithmetic operation using float4, because you don't need to create an output float4.The code is also simpler/cleaner.
Also good to avoid (col.r + col.g + col.b)/3 which was not optimized by the ps_3_0 DX9 compiler:
return float4((col.r + col.g + col.b)/3, 0, 0, 0); //(1 texture, 4 arithmetic) BAD !!!
vs
float4(col.r/3 + col.g/3 + col.b/3), 0, 0, 0) //(1 texture, 2 arithmetic)
float4(dot(col.rgb, float3(1./3, 1./3, 1./3), 0, 0, 0); //(1 texture, 2 arithmetic)
float4(dot(col, float4(1, 1, 1, 0)/3), 0, 0, 0); //(1 texture, 2 arithmetic)
vs
return dot(1./3, col); //(1 texture, 1 arithmetic) float gets cast to float4, float3 doesn't.
butterw2
25th June 2020, 11:20
I've ported SweetFx.FilmGrain v1.0 to hlsl, tested on mpc-hc v1.93: available here (https://gist.github.com/butterw/ee30ac43a8e5cb98f55bfa07572ae222).
Computes a noise pattern and blends it with the image to create a film grain look.
tested on mpc-hc v1.9.3 (EVR-CP):
- Intensity, Variance set high so that the grain is visible, also wanted the noise to be less static and added Show_FilmGrain option.
Perf comparison:
- PS_Noise(NoiseStrength: 0.10) modified: (1 texture, 29 arithmetic)
- semi-random grayscale noise.hlsl (NoiseStrength: 1/64.) i<4: (1 texture, 38 arithmetic)
- SweetFx.FilmGrain.hlsl v1.0 4 parameters: (1 texture, 46 arithmetic)
it's not the most lightweight noise shader, but it has 4 parameters to finely tune it. SNR gives less grain to brighter pixels.
output is grain*color vs grain+color for the other noise shaders.
=]
23rd November 2020, 12:24
I am running MPC-HC 1.9.8 x64 on a laptop with an 8th-gen Core-i7 processor and onboard graphics. I like and use Vibrance from the SweetFX shader suite, in addition to Lumasharpen. Is there a DX11 version of Vibrance available? Would it make a difference in image quality or resource use?
butterw2
23rd November 2020, 13:55
No dx11 hlsl version available to my knowledge, but it's easy enough to port from dx9 to dx11 (look at the examples that come with mpc-hc in ./shaders and ./shaders11): only boilerplate syntax changes to the code are required.
There shouldn't be a major difference in quality or performance.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.