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.

 

Go Back   Doom9's Forum > Hardware & Software > Software players

Reply
 
Thread Tools Search this Thread Display Modes
Old 4th November 2014, 03:17   #1  |  Link
-Vit-
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-
Attached Files
File Type: zip finesharp_shaders_1.11.zip (6.1 KB, 1837 views)
File Type: zip finesharp_shaders_1.12_bugfix_by_shiandow.zip (7.6 KB, 5396 views)

Last edited by foxyshadis; 15th May 2015 at 22:47. Reason: V1.12 bugfix + instructions on newer MPC-HC
-Vit- is offline   Reply With Quote
Old 4th November 2014, 03:52   #2  |  Link
Asmodian
Registered User
 
Join Date: Feb 2002
Location: San Jose, California
Posts: 4,406
Impressive, thanks for these!
Asmodian is offline   Reply With Quote
Old 4th November 2014, 03:53   #3  |  Link
PetitDragon
Registered User
 
Join Date: Sep 2006
Posts: 81
This is nothing else.

Just great!
PetitDragon is offline   Reply With Quote
Old 4th November 2014, 04:08   #4  |  Link
Reel.Deel
Registered User
 
Join Date: Mar 2012
Location: Texas
Posts: 1,664
Awesome! Thank you very much for this litttle present.
Reel.Deel is offline   Reply With Quote
Old 6th November 2014, 00:09   #5  |  Link
foxyshadis
ангел смерти
 
foxyshadis's Avatar
 
Join Date: Nov 2004
Location: Lost
Posts: 9,558
This is one of the coolest things I've seen in a long time, and it works amazingly well. Thank you, Vit!
foxyshadis is offline   Reply With Quote
Old 6th November 2014, 00:47   #6  |  Link
Ge'in
Registered User
 
Join Date: Feb 2014
Posts: 12
Thanks again
Ge'in is offline   Reply With Quote
Old 6th November 2014, 09:49   #7  |  Link
feelingblue
Registered User
 
Join Date: Nov 2011
Posts: 48
time ago I asked for a shader can return the same quality of finesharp.
I tried with the lumasharp but nothing to do..

Thanks!
feelingblue is offline   Reply With Quote
Old 10th November 2014, 19:16   #8  |  Link
feelingblue
Registered User
 
Join Date: Nov 2011
Posts: 48
But if i copy all files content in only one single file.. is the same thing or not?
feelingblue is offline   Reply With Quote
Old 10th November 2014, 22:15   #9  |  Link
Shiandow
Registered User
 
Join Date: Dec 2013
Posts: 753
Quote:
Originally Posted by feelingblue View Post
But if i copy all files content in only one single file.. is the same thing or not?
You mean combining all shaders in a single file? That won't work, the resulting 'shader' won't even compile.

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.
Shiandow is offline   Reply With Quote
Old 10th November 2014, 23:36   #10  |  Link
Zachs
Suptitle, MediaPlayer.NET
 
Join Date: Nov 2001
Posts: 1,721
Quote:
Originally Posted by Shiandow View Post
You mean combining all shaders in a single file? That won't work, the resulting 'shader' won't even compile.

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.
This gives me an idea for MPDN's image processor - Presets.
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
Zachs is offline   Reply With Quote
Old 11th November 2014, 00:36   #11  |  Link
Anima123
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.
Anima123 is offline   Reply With Quote
Old 11th November 2014, 00:50   #12  |  Link
Zachs
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.
Zachs is offline   Reply With Quote
Old 11th November 2014, 00:52   #13  |  Link
Shiandow
Registered User
 
Join Date: Dec 2013
Posts: 753
Quote:
Originally Posted by Anima123 View Post
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.
The ToYuv shader doesn't downsample the chroma. The only possible loss is rounding errors by converting back and forth, but that shouldn't be a problem if you use a high enough bit depth.

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.
Shiandow is offline   Reply With Quote
Old 11th November 2014, 01:00   #14  |  Link
Zachs
Suptitle, MediaPlayer.NET
 
Join Date: Nov 2001
Posts: 1,721
Quote:
Originally Posted by Shiandow View Post
The ToYuv shader doesn't downsample the chroma. The only possible loss is rounding errors by converting back and forth, but that shouldn't be a problem if you use a high enough bit depth.
I should've mentioned that too.

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.
Zachs is offline   Reply With Quote
Old 11th November 2014, 02:12   #15  |  Link
-Vit-
Registered User
 
Join Date: Jul 2010
Posts: 448
Quote:
Originally Posted by Zachs View Post
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.
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
-Vit- is offline   Reply With Quote
Old 11th November 2014, 02:21   #16  |  Link
Zachs
Suptitle, MediaPlayer.NET
 
Join Date: Nov 2001
Posts: 1,721
Quote:
Originally Posted by -Vit- View Post
Maybe you have tweaked some of MadVR's performance/quality settings. The YUV<->RGB conversion needs to operate in 16bit. So selecting the "Use 10bit chroma buffer instead of 16bit" gives a slight magenta hue.

Also choosing "run custom pixel shaders in video levels..." breaks it too.

I'll update the OP shortly.
This is with MPDN, not MadVR. None of the others who've tested it seem to report such problems though.

And MPDN doesn't do 10bit buffers, only 16bit floats.
Zachs is offline   Reply With Quote
Old 11th November 2014, 02:33   #17  |  Link
-Vit-
Registered User
 
Join Date: Jul 2010
Posts: 448
I haven't tried MPDN, I will do.
You could single out if it's the YUV<->RGB conversion by removing all the other filters.
-Vit- is offline   Reply With Quote
Old 11th November 2014, 03:11   #18  |  Link
foxyshadis
ангел смерти
 
foxyshadis's Avatar
 
Join Date: Nov 2004
Location: Lost
Posts: 9,558
Going to magenta sounds like BT.709 was used to convert to YUV and then BT.601 back to RGB.

Quote:
Originally Posted by Shiandow View Post
Edit: Also note that there's no additional value whatsoever to perform sharpening in the original YUV, besides preventing unnecessary colour conversions.
Sharpening in linear light (RGB or YUV) would probably be more valuable than any transformation between gamma-corrected RGB or YUV.
foxyshadis is offline   Reply With Quote
Old 11th November 2014, 03:20   #19  |  Link
Shiandow
Registered User
 
Join Date: Dec 2013
Posts: 753
Quote:
Originally Posted by foxyshadis View Post
Sharpening in linear light (RGB or YUV) would probably be more valuable than any transformation between gamma-corrected RGB or YUV.
Not something perceptually uniform like Lab? Although I agree that for unsharp mask sharpening it might be better to perform the blurring in linear light.
Shiandow is offline   Reply With Quote
Old 11th November 2014, 03:48   #20  |  Link
Zachs
Suptitle, MediaPlayer.NET
 
Join Date: Nov 2001
Posts: 1,721
Quote:
Originally Posted by Zachs View Post
This is with MPDN, not MadVR. None of the others who've tested it seem to report such problems though.

And MPDN doesn't do 10bit buffers, only 16bit floats.
Scratch that. I can no longer replicate the problem. It may have been a problem with my own development scripts that caused the problem which probably explains why no one else reported the problem.
Zachs is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 18:22.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.