Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion. Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules. |
|
|
Thread Tools | Search this Thread | Display Modes |
|
4th November 2014, 03:17 | #1 | Link |
Registered User
Join Date: Jul 2010
Posts: 448
|
FineSharp converted to shaders, for MPC-HC + madVR, or MPDN - V1.11
This is the FineSharp avisynth script by Didée converted to MPC-HC shaders. It was written for madVR (need the 16-bit accuracy in the shader chain), but also works in MPDN.
FineSharp is designed to sharpen clean HD sources. I find it gives a nice clarity boost to clean 720p material when upscaling to 1080p, and gives a modest boost to native 1080p material too. When upscaling it is very effective used together with NNEDI3 luma doubling, if your GPU has the power for that. The sharpener makes no attempt to filter noise or source artefacts and will sharpen those too. So denoise/clean your source first if necessary. Probably won't work very well on a really old GPU, the weakest I have tried is a GTX 560 at 1080p 60fps with no problems. Installation Get zip from attachment below or download here (V1.11) There are a collection of shaders in the attached zip file, import them all into MPC-HC. How to do that depends on the version of MPC-HC. In the older versions you paste the code into the shader editor, type a name and select ps_3_0. In the recent versions you can save all the shaders in a folder and add them all at once (Play->Shaders->Select Shaders...). Search the web for detailed instructions. When you have imported the shaders they must be selected in the correct order (again check the web for details if you don't know how): ToYUV RemoveGrain11 RemoveGrain4 FineSharpA FineSharpB FineSharpC ToRGB You can select them as "pre-resize shaders" or "post-resize shaders", or both if you wish. In newer versions of MPC-HC, when you have selected your shaders type a preset name (e.g. "FineSharp - Pre-Resize") in the "Shader Presets" box and press "Save". Pre-resize shaders have a stronger effect when upscaling (e.g. showing 720p on 1080p monitor), post-resize shaders are stronger when downscaling. Sharpening in both stages is too strong for my liking, but you could do this if you find the sharpening too delicate - this works best when NNEDI3 luma doubling is enabled. Controls In newer versions of MPC-HC, right click, and select Shaders>>Your Shader Preset to enable. You can also go to Options>>Player>>Keys, scroll down to find Next and Prev Shader Preset and assign a key there (a key combination that isn't used, like Ctrl+P or Ctrl+Y). In MPC-HC 1.70 and below, toggle pre-resize shaders with Ctrl-P and post-resize shaders with Ctrl+Alt+P. The script settings are in the FineSharpA and FineSharpC files. They mirror the original script settings exactly. The main sharpness control is "sstr" in FineSharpA, use it to control the sharpness more precisely than just toggling pre or post shaders. When you change sstr, you should also change cstr - suggested values are in the script. I also added an extra feature of my own "xrep", which helps reduce artefacts from the second pass of sharpening. Notes The shaders are not compatible with the MadVR setting: "run custom pixel shaders in video levels instead of PC levels". V1.12 - Color conversion improvement by Shaindow V1.11 - Bug fix V1.1 - Optimised sorts and medians for a good speed-up. Fixed a bug in the second sharpening pass & tweaked xrep range. Removed a couple of unnecessary files. v1.0 - First release -Vit- Last edited by foxyshadis; 15th May 2015 at 22:47. Reason: V1.12 bugfix + instructions on newer MPC-HC |
10th November 2014, 22:15 | #9 | Link | |
Registered User
Join Date: Dec 2013
Posts: 753
|
Quote:
If you really wanted to you could combine them into 1 shader, but unless you find a way to do this efficiently the resulting shader will be a few orders of magnitude slower. |
|
10th November 2014, 23:36 | #10 | Link | |
Suptitle, MediaPlayer.NET
Join Date: Nov 2001
Posts: 1,721
|
Quote:
We could let user save and load the FineSharp shader sequence as a preset. Then it's as simple as adding ImageProcessor (Preset: FineSharp) in the render chain, which would be more intuitive than the long list of hlsl files it currently shows in its description. On a more on topic note, I can't seem to get these shaders to work correctly - they seem to change the colour of the image to one that has a magenta hue. http://i.imgur.com/otfxetu.png |
|
11th November 2014, 02:12 | #11 | Link |
Registered User
Join Date: Jul 2010
Posts: 448
|
Maybe you have tweaked some of MadVR's performance/quality settings. <snip>edited for correction</snip>. Selecting "run custom pixel shaders in video levels instead of PC levels" will cause a magenta tint. Is that it I wonder? You would need a different ToYUV for video levels.
Last edited by -Vit-; 11th November 2014 at 02:28. Reason: Incorrect suggestion removed |
11th November 2014, 02:21 | #12 | Link | |
Suptitle, MediaPlayer.NET
Join Date: Nov 2001
Posts: 1,721
|
Quote:
And MPDN doesn't do 10bit buffers, only 16bit floats. |
|
11th November 2014, 00:36 | #13 | Link |
Registered User
Join Date: Jun 2005
Posts: 504
|
Zachs, is it possible to add the FineSharp scripts on the original yuv space with MPDN, since the convert to YUV step will only degrade the chroma, by doubling and reversing to half video size another time? I also doubt the convert to RGB would have the same quality of the renderer doubling, which can choose a fancy chroma doubling method.
|
11th November 2014, 00:50 | #14 | Link |
Suptitle, MediaPlayer.NET
Join Date: Nov 2001
Posts: 1,721
|
While MPDN does provide YUV inputs if a render script requests for it, the ImageProcessor script is created to be fully compatible with MPC-HC/madVR style shaders - i.e. shaders that rigidly expect its inputs in RGB. MPDN also provides the YUV colorimetry being used for the video, so it's possible to write a render script that does proper YUV to RGB conversion in the final step.
e.g. in FineSharp's case, you would create a render script that Asks MPDN to give you YUV inputs Do RemoveGrain11 RemoveGrain4 FineSharpA FineSharpB FineSharpC Then convert to RGB based on the colorimetry info MPDN gives you This actually gives me another idea. ImageProcessor could do with a "YUV input" option. That way, all you have to do is add RemoveGrain11 RemoveGrain4 FineSharpA FineSharpB FineSharpC to the list, and MPDN will do the proper YUV/RGB conversions with the user selected / stream selected colorimetry. |
11th November 2014, 00:52 | #15 | Link | |
Registered User
Join Date: Dec 2013
Posts: 753
|
Quote:
Edit: Also note that there's no additional value whatsoever to perform sharpening in the original YUV, besides preventing unnecessary colour conversions. Last edited by Shiandow; 11th November 2014 at 01:05. |
|
11th November 2014, 01:00 | #16 | Link | |
Suptitle, MediaPlayer.NET
Join Date: Nov 2001
Posts: 1,721
|
Quote:
Anyway, it should be possible to get rid of the ToYuv step to save some time if ImageProcessor supports YUV input (no need for YUV to RGB conversion only for the script to convert it back to YUV). I will probably add a IRenderer.ConvertToRGB() method which I could then include as a final step in Render() if InterfaceDescriptor.WantsYuv is true. I'll continue this in PM. |
|
11th November 2014, 03:11 | #17 | Link |
Angel of Night
Join Date: Nov 2004
Location: Tangled in the silks
Posts: 9,559
|
Going to magenta sounds like BT.709 was used to convert to YUV and then BT.601 back to RGB.
Sharpening in linear light (RGB or YUV) would probably be more valuable than any transformation between gamma-corrected RGB or YUV. |
14th November 2014, 08:56 | #20 | Link |
Registered Developer
Join Date: Sep 2006
Posts: 9,140
|
Wow, this is great - I've always been a fan of FineSharp and planned to look into making it work for madVR at some point in the future. Now -Vit- has done all the work, thank you very much!
@-Vit-, have you found some madVR settings which damage the alpha channel? I think madVR's shader processing should preserve the alpha channel between passes. The alpha channel will probably get lost during scaling (I skip the alpha channel there to save performance). But since all the FineSharp scripts should probably be executed right after each other, there should be no problem, correct? FWIW, I plan to add a more complex shader editor to madVR in the near future, which should make it possible to put something like your HLSL FineSharp scripts into one "shader plugin" (or however it will be called). I plan to support multiple rendering passes, and also exportable options/parameters which the user can then modify through the madVR GUI or maybe assignable keyboard shortcuts etc. Of course the shaders will also be profilable, so users can use different shaders/settings depending on e.g. source resolution or framerate etc. Haven't thought this all fully through yet, though. Do you have any wishes that you'd like to see implemented in madVR to make porting of AviSynth scripts more easy/nice for you? One thing I've been wondering about is whether it might make sense to handle grain outside of the shaders. E.g. maybe it would make sense to remove/reduce the grain before running all the shaders and scaling etc, and then after all shaders and scaling is done, maybe the grain could be put back in somehow? As opposed to every script doing this on its own separately. To be honest, although I'm a fan of several AviSynth scripts, I haven't really looked into how most of them work inside yet. So maybe what I wrote above is an old hat for AviSynth experts. Just wondering if there's anything I could do in madVR to make things easier/better... > The shaders are not compatible with the MadVR > setting: "run custom pixel shaders in video levels > instead of PC levels". I expect several shaders might have problems with that setting. I still added it as an option to make some shaders perform faster for users of very slow GPUs. In the madVR shader editor I plan to offer an option like "this shader/plugin needs to run in PC levels", which would then effectively force that "run custom pixel shaders in video levels" option off, when such a shader is activated by the user. |
Thread Tools | Search this Thread |
Display Modes | |
|
|