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 16th March 2014, 16:41   #1  |  Link
CeeJay.dk
Registered User
 
Join Date: Dec 2003
Location: Denmark
Posts: 117
SweetFX Video Shaders

On request I have ported over all the shaders from SweetFX so that they can now run in MPC-HC.

Download mirrors:
Instructions
1) Install the latest MPC-HC - you will need at least version 1.7.2 (current version as I write this is 1.7.3)
2) Extract the shaders to the Shaders folder in the MPC-HC folder.
3) You can edit settings in the .hlsl files you just extracted.

I assume you know how to add and enable shaders in MPC-HC.

I'd make editing the settings easier if I could but MPC-HC doesn't have an interface for editing shader settings.

This is the first release, and I haven't taken the time to tweak the default settings so they are more suited for watching videos - if you find some better default settings please suggest them to me so I can update the shader package.

All of the code for the effect follows the settings, but in the next version I'll probably separate them and just use a template to include the code from the untouched SweetFX shader in the SweetFX package for games as this makes porting over new versions of the effect a simple drag and drop of the new file so I don't have to port it again.

Last edited by CeeJay.dk; 16th March 2014 at 18:17.
CeeJay.dk is offline   Reply With Quote
Old 16th March 2014, 17:08   #2  |  Link
raffriff42
Retried Guesser
 
raffriff42's Avatar
 
Join Date: Jun 2012
Posts: 1,235
Quote:
Originally Posted by leeperry View Post
Sweet, thanks! But nothing happens when I click on "download"

I'm on FF27.01 if that matters.
NoScript?
raffriff42 is offline   Reply With Quote
Old 16th March 2014, 17:54   #3  |  Link
CeeJay.dk
Registered User
 
Join Date: Dec 2003
Location: Denmark
Posts: 117
Quote:
Originally Posted by leeperry View Post
I disabled Ghostery, enabled Flash and that didn't help.
Adblock Plus mistakenly classifies ge.tt as a malware domain if you have the malware list enabled.

I'll try to host it some other places as well.
CeeJay.dk is offline   Reply With Quote
Old 16th March 2014, 18:11   #4  |  Link
CeeJay.dk
Registered User
 
Join Date: Dec 2003
Location: Denmark
Posts: 117
Quote:
Originally Posted by leeperry View Post
I don't use Adblock, mediafire or mega would be great
It's also up on dropcanvas and dropbox now. I hope one of them works for you.
CeeJay.dk is offline   Reply With Quote
Old 16th March 2014, 23:33   #5  |  Link
leeperry
Kid for Today
 
Join Date: Aug 2004
Posts: 3,416
That did the trick, thanks!

Vignette is fun and Borders is useful to hide TV channel logos

They work just fine in PotPlayer BTW.
leeperry is offline   Reply With Quote
Old 17th March 2014, 00:07   #6  |  Link
CeeJay.dk
Registered User
 
Join Date: Dec 2003
Location: Denmark
Posts: 117
Nice, I was going to look into porting them to the other shader capable media players next but that is one crossed off my list then.

I'm looking forward to hearing feedback on the shaders from this forum .. lots of people here that know much more about video filters than myself.
CeeJay.dk is offline   Reply With Quote
Old 17th March 2014, 02:49   #7  |  Link
JanWillem32
Registered User
 
JanWillem32's Avatar
 
Join Date: Oct 2010
Location: The Netherlands
Posts: 1,084
I can perhaps help with some parts. To start off with one shader, for the DPX shader I see that you've tried to use the XYZ color space. The XYZ color space is the both the easiest and the hardest color space to manipulate. It demands linear light input, and also filters in linear light mode. That means that it's great for linear scaling, but will not work for any filter that expects non-linearity at all. It's also all-positive, and can encode all colors in the human-visable spectrum. The down-side to that is that it also encodes non-existing colors (which are actually not that hard to deal with).
Assuming R'G'B' input, the first conversion step is done by converting R'G'B' to RGB: "s1 = sign(s1)*pow(abs(s1), 2.4);// to linear RGB, negative input compatible". (The pow instructions will produce a NaN on all negative inputs. This method isn't the cleanest way to deal with exponentiation, but it does the job.) Note the standard 2.4 factor. This is correct for all consumer-grade digital video. For some reason the standards do specify all sorts of weird OECF formats, but those are usually not even close to the image reproduction reference.
After converting to RGB, you can convert to XYZ by matrix multiplication. There are four matrices in use for consumer-grade digital video (see code box at the bottom of this post). The line "c0 = mul(XYZ, c0);" as already in the shader will work fine, but breaking it up into multiply-add operations may be faster. (To try that: transpose() the matrix, use "s1 = s1.x*matrix[0]+s1.y*matrix[1]+s1.z*matrix[2];" and read the report from GPU ShaderAnalyzer or similar to determine if it's faster.)
Note that conversion to plain XYZ will yield a color space based on white point E. This means that the input white point will not be {1, 1, 1} on output when using these (unless the input white point was already E, but that's not the case for consumer-grade digital video). There are also white-point adapted matrices, that will fully or partially adapt the input white point. Different methods of these will yield different XYZ conversion matrices.
The line "float luma = dot(c0, float3(0.30, 0.59, 0.11)); //Use BT 709 instead?" is odd. XYZ doesn't describe luma at all. It does store luminance in the Y channel. If you denormalize the Y channel you actually get values expressed in cd/mē. Of course it's linear-light, and if you scale Y, you have to scale X and Z as well. XYZ is mostly good at encoding color, but not so much at describing it. Scaling in XYZ works fine, as long as you scale the three channels with the same factor. For describing actual color, by all means look beyond Y'CbCr, R'G'B', HSV, HSL, RGB and XYZ for a CAM (color appearance model). I achieved good results with CIECAM02 and at the moment I'm testing XLRCAM. These do specify lots of conversions and parameters to deal with, but these are totally worth it.

Some technical issues:
-"static float3x3 RGB" and "static float3x3 XYZ" are not marked const, even though their intention is so.
-"float4 DPXPass(float4 InputColor){" in this case it won't be a problem, but the compiler is horrible at inlining functions (even using a #define as a function will usually optimize better).
-As I already noted, check the usage of mul() intrinsics, as the compiler generally won't optimize by multiplying matrices with consecutive scalars and vectors.
-As I already noted, check the usage of pow() intrinsics where negative inputs can be expected, as NaN outputs will cause artifacts.

The notes that I made to construct the basis XYZ and LMS matrices:
Code:
BT.709 RGB to XYZ matrix
506752./1228815., 87881./245763., 12673./70218.,
87098./409605., 175762./245763., 12673./175545.,
7918./409605., 87881./737289., 1001167./1053270.
BT.709 RGB to LMS matrix
722868859153469683239595115393861./2255010826531620584211453297294600., 2585192674261804536498018473512337./4059019487756917051580615935130280., 431657167547167713128315634772483./10147548719392292628951539837825700.,
12180008436477856247752895389891./75167027551054019473715109909820., 307102197566215335489903665465341./405901948775691705158061593513028., 82569264131239864825730732355689./1014754871939229262895153983782570.,
53058419719444384066923671296./3075014763452209887561072678129., 111365697442061984458791034130./1025004921150736629187024226043., 2687859251406579550117775904443./3075014763452209887561072678129.
LMS to BT.709 RGB matrix
25377313278362757037750367./4668794666720483257968250., -214723657934986669707431539./46687946667204832579682500., 7638471818563931909610369./46687946667204832579682500.,
-605343464019237999732424841./518184319406495060865758750., 12063681187144308402184664197./5181843194064950608657587500., -828403352886977796202828287./5181843194064950608657587500.,
396581977151187822859327./10461567155328133121940425., -20775485687965286836237859./104615671553281331219404250., 121425337469734739827048839./104615671553281331219404250.

SMPTE 170M/SMPTE 240M/SMPTE C (NTSC) RGB to XYZ matrix
401584./932715., 2548549./7461720., 88721./497448.,
276089./1243620., 87881./124362., 88721./1243620.,
25099./1243620., 966691./7461720., 7008959./7461720.
SMPTE 170M/SMPTE 240M/SMPTE C (NTSC) RGB to LMS matrix
4582795022958559125948622834369921./13693077790023334631838222431764800., 465527727195754310063646435959647./746895152183090979918448496278080., 431705826356959866042061203601013./10269808342517500973878666823823600.,
77217992358463681223124506539751./456435926334111154394607414392160., 56048129428711216246386203396963./74689515218309097991844849627808., 82578571800427591248026245959679./1026980834251750097387866682382360.,
42047021865948932675414158432./2334047350572159312245151550869., 1103514589028385241176926280029./9336189402288637248980606203476., 2688162241932152092367341096573./3112063134096212416326868734492.
LMS to SMPTE 170M/SMPTE 240M/SMPTE C (NTSC) RGB matrix
763198626475360358257813253./147994540717374853866816250., -6373975142277374689886058001./1479945407173748538668162500., 221934284697519645976087971./1479945407173748538668162500.,
-605343464019237999732424841./518184319406495060865758750., 12063681187144308402184664197./5181843194064950608657587500., -828403352886977796202828287./5181843194064950608657587500.,
27361298410291889828212027./523137322083995952425108750., -1196635193693957989329923759./5231373220839959524251087500., 6154395430430998615298890989./5231373220839959524251087500.

BT.470-2 System M RGB to XYZ matrix
43349./71416., 12387./71416., 3581./17854.,
21351./71416., 293159./499912., 7162./62489.,
0., 4129./62489., 139659./124978.
BT.470-2 System M RGB to LMS matrix
4849241781348846485632006241./10503846560761984531342857600., 34978470582276588065997919961./73526925925333891719400003200., 35966897450120142609203434./574429108791671029057812525.,
1160596510009705046375091833./5251923280380992265671428800., 24013221393818167547899894193./36763462962666945859700001600., 72282281230950671674601009./574429108791671029057812525.,
-76116568237764117836011./65649041004762403320892860., 25082445529946839408599149./459543287033336823246250020., 108748414370263583165625737./114885821758334205811562505.
LMS to BT.470-2 System M RGB matrix
6356039832931337684547833./1907495674013736213630625., -9291369607363479369136241./3814991348027472427261250., 15771251581131057092073./152599653921098897090450.,
-13887055372386146338232481./12173183366310226933664375., 57992533744044875121627737./24346366732620453867328750., -234882250666085143113361./973854669304818154693150.,
737565350893551523311808./10557561064363507544066875., -1481563549980151961947408./10557561064363507544066875., 452062370538004319308099./422302442574540301762675.

BT.470-2 System B,G/EBU 3213 (PAL/SECAM) RGB to XYZ matrix
51177./130049., 4987652./13655145., 5234753./27310290.,
82858./390147., 1367582./1950735., 168863./1950735.,
2437./130049., 1528474./13655145., 5234753./5462058.
BT.470-2 System B,G/EBU 3213 (PAL/SECAM) RGB to LMS matrix
782910914364235953227073443841197./2505869460647788817876743483379180., 47437201892727083793508359035427793./75176083819433664536302304501375400., 4251554495779502145981742150711697./75176083819433664536302304501375400.,
124459316400474051550350235432343./751760838194336645363023045013754., 5551656166817314597571817932574949./7517608381943366453630230450137540., 240453017040437113518303387746387./2505869460647788817876743483379180.,
190503071007861562472684780870./11390315730217221899439743106269., 3484707111371743136520220253336./34170947190651665698319229318807., 30114730866256337874380954722861./34170947190651665698319229318807.
LMS to BT.470-2 System B,G/EBU 3213 (PAL/SECAM) RGB matrix
5889610677243193337436144851./1005872293755806060844662500., -50563246336667155788637763367./10058722937558060608446625000., 1725862501793283022722939857./10058722937558060608446625000.,
-156299752813513892312443129./118586087319713310233175625., 2972168594434151167364839293./1185860873197133102331756250., -223310193101879141908651753./1185860873197133102331756250.,
41217384068187972753550441./995689156108134584983951250., -1937830199233462093713839397./9956891561081345849839512500., 11482547919632928216017847487./9956891561081345849839512500.
__________________
development folder, containing MPC-HC experimental tester builds, pixel shaders and more: http://www.mediafire.com/?xwsoo403c53hv
JanWillem32 is offline   Reply With Quote
Old 17th March 2014, 02:49   #8  |  Link
JanWillem32
Registered User
 
JanWillem32's Avatar
 
Join Date: Oct 2010
Location: The Netherlands
Posts: 1,084
Code:
used tools:
(construct the RGB to XYZ matrices first)
matrix math

BT.709 RGB to XYZ matrix
{{506752./1228815., 87881./245763., 12673./70218.},
{87098./409605., 175762./245763., 12673./175545.},
{7918./409605., 87881./737289., 1001167./1053270.}}
XYZ_w
{{3127/3290},{1},{3583/3290}}
iLMSCAT02_w
{{3903713/4112500},{34064741/32900000},{4472059/4112500}}
iLMSCAT02_wr
{{4112500/3903713},{32900000/34064741},{4112500/4472059}}
{{4112500/3903713,0,0},
{0,32900000/34064741,0},
{0,0,4112500/4472059}}
// white point adaptation and LMSCAT02 to XYZ to LMS
{{464053391886875/594479206165966,546172937177000/2593784454432131,25677829793875/681030107553338},
{89354738755625/297239603082983,1563686005000000/2593784454432131,28321738606875/340515053776669},
{-274069337500/27021782098453,-14274125600000/2593784454432131,317936256400000/340515053776669}}
// XYZ to LMSCAT02, white point adaptation and LMSCAT02 to XYZ to LMS
{{1535883035237967283712368316373/3622507351858025034877836622160,313936929155525071434095214423/452813418982253129359729577770,-320255941654937541603650371757/3622507351858025034877836622160},
{-73765545839823421271159289111/362250735185802503487783662216,52237841914778168455574637779/45281341898225312935972957777,13276522859463209890873256879/362250735185802503487783662216},
{-3125719934910748888276760/4116485627111392085088450707,-4119398094368106819832290/4116485627111392085088450707,3786370264907456584747946550/4116485627111392085088450707}}
// RGB to XYZ to LMSCAT02, white point adaptation and LMSCAT02 to XYZ to LMS
{{722868859153469683239595115393861/2255010826531620584211453297294600,2585192674261804536498018473512337/4059019487756917051580615935130280,431657167547167713128315634772483/10147548719392292628951539837825700},
{12180008436477856247752895389891/75167027551054019473715109909820,307102197566215335489903665465341/405901948775691705158061593513028,82569264131239864825730732355689/1014754871939229262895153983782570},
{53058419719444384066923671296/3075014763452209887561072678129,111365697442061984458791034130/1025004921150736629187024226043,2687859251406579550117775904443/3075014763452209887561072678129}}
// reverse
{{25377313278362757037750367/4668794666720483257968250,-214723657934986669707431539/46687946667204832579682500,7638471818563931909610369/46687946667204832579682500},
{-605343464019237999732424841/518184319406495060865758750,12063681187144308402184664197/5181843194064950608657587500,-828403352886977796202828287/5181843194064950608657587500},
{396581977151187822859327/10461567155328133121940425,-20775485687965286836237859/104615671553281331219404250,121425337469734739827048839/104615671553281331219404250}}


SMPTE 170M/SMPTE 240M/SMPTE C (NTSC) RGB to XYZ matrix
{{401584./932715., 2548549./7461720., 88721./497448.},
{276089./1243620., 87881./124362., 88721./1243620.},
{25099./1243620., 966691./7461720., 7008959./7461720.}}
XYZ_w
{{3127/3290},{1},{3583/3290}}
iLMSCAT02_w
{{3903713/4112500},{34064741/32900000},{4472059/4112500}}
iLMSCAT02_wr
{{4112500/3903713},{32900000/34064741},{4112500/4472059}}
{{4112500/3903713,0,0},
{0,32900000/34064741,0},
{0,0,4112500/4472059}}
// white point adaptation and LMSCAT02 to XYZ to LMS
{{464053391886875/594479206165966,546172937177000/2593784454432131,25677829793875/681030107553338},
{89354738755625/297239603082983,1563686005000000/2593784454432131,28321738606875/340515053776669},
{-274069337500/27021782098453,-14274125600000/2593784454432131,317936256400000/340515053776669}}
// XYZ to LMSCAT02, white point adaptation and LMSCAT02 to XYZ to LMS
{{1535883035237967283712368316373/3622507351858025034877836622160,313936929155525071434095214423/452813418982253129359729577770,-320255941654937541603650371757/3622507351858025034877836622160},
{-73765545839823421271159289111/362250735185802503487783662216,52237841914778168455574637779/45281341898225312935972957777,13276522859463209890873256879/362250735185802503487783662216},
{-3125719934910748888276760/4116485627111392085088450707,-4119398094368106819832290/4116485627111392085088450707,3786370264907456584747946550/4116485627111392085088450707}}
// RGB to XYZ to LMSCAT02, white point adaptation and LMSCAT02 to XYZ to LMS
{{4582795022958559125948622834369921/13693077790023334631838222431764800,465527727195754310063646435959647/746895152183090979918448496278080,431705826356959866042061203601013/10269808342517500973878666823823600},
{77217992358463681223124506539751/456435926334111154394607414392160,56048129428711216246386203396963/74689515218309097991844849627808,82578571800427591248026245959679/1026980834251750097387866682382360},
{42047021865948932675414158432/2334047350572159312245151550869,1103514589028385241176926280029/9336189402288637248980606203476,2688162241932152092367341096573/3112063134096212416326868734492}}
// reverse
{{763198626475360358257813253/147994540717374853866816250,-6373975142277374689886058001/1479945407173748538668162500,221934284697519645976087971/1479945407173748538668162500},
{-605343464019237999732424841/518184319406495060865758750,12063681187144308402184664197/5181843194064950608657587500,-828403352886977796202828287/5181843194064950608657587500},
{27361298410291889828212027/523137322083995952425108750,-1196635193693957989329923759/5231373220839959524251087500,6154395430430998615298890989/5231373220839959524251087500}}


BT.470-2 System M RGB to XYZ matrix
{{43349./71416., 12387./71416., 3581./17854.},
{21351./71416., 293159./499912., 7162./62489.},
{0., 4129./62489., 139659./124978.}}
XYZ_w
{{155/158},{1},{187/158}}
iLMSCAT02_w
{{37773/39500},{1602877/1580000},{233137/197500}}
iLMSCAT02_wr
{{39500/37773},{1580000/1602877},{197500/233137}}
{{39500/37773,0,0},
{0,1580000/1602877,0},
{0,0,197500/233137}}
// white point adaptation and LMSCAT02 to XYZ to LMS
{{4457169356725/5752283288886,26229581785400/122047528409707,1233160215025/35503403730734},
{858240043975/2876141644443,75094951000000/122047528409707,1360132127625/17751701865367},
{-28956383500/2876141644443,-685505120000/122047528409707,15268671280000/17751701865367}}
// XYZ to LMSCAT02, white point adaptation and LMSCAT02 to XYZ to LMS
{{4841799350800837556394979/11619299292878301472724400,169003540689637258532741/242068735268297947348425,-1050013174810519557556547/11619299292878301472724400},
{-1243396960144830232381973/5809649646439150736362200,284114598684068163097666/242068735268297947348425,178013982619508170577989/5809649646439150736362200},
{-122785085978668174408/145241241160978768409055,-104660313950594725082/48413747053659589469685,123084260858684068852154/145241241160978768409055}}
// RGB to XYZ to LMSCAT02, white point adaptation and LMSCAT02 to XYZ to LMS
{{4849241781348846485632006241/10503846560761984531342857600,34978470582276588065997919961/73526925925333891719400003200,35966897450120142609203434/574429108791671029057812525},
{1160596510009705046375091833/5251923280380992265671428800,24013221393818167547899894193/36763462962666945859700001600,72282281230950671674601009/574429108791671029057812525},
{-76116568237764117836011/65649041004762403320892860,25082445529946839408599149/459543287033336823246250020,108748414370263583165625737/114885821758334205811562505}}
// reverse
{{6356039832931337684547833/1907495674013736213630625,-9291369607363479369136241/3814991348027472427261250,15771251581131057092073/152599653921098897090450},
{-13887055372386146338232481/12173183366310226933664375,57992533744044875121627737/24346366732620453867328750,-234882250666085143113361/973854669304818154693150},
{737565350893551523311808/10557561064363507544066875,-1481563549980151961947408/10557561064363507544066875,452062370538004319308099/422302442574540301762675}}


BT.470-2 System B,G/EBU 3213 (PAL/SECAM) RGB to XYZ matrix
{{51177./130049., 4987652./13655145., 5234753./27310290.},
{82858./390147., 1367582./1950735., 168863./1950735.},
{2437./130049., 1528474./13655145., 5234753./5462058.}}
XYZ_w
{{3127/3290},{1},{3583/3290}}
iLMSCAT02_w
{{3903713/4112500},{34064741/32900000},{4472059/4112500}}
iLMSCAT02_wr
{{4112500/3903713},{32900000/34064741},{4112500/4472059}}
{{4112500/3903713,0,0},
{0,32900000/34064741,0},
{0,0,4112500/4472059}}
// white point adaptation and LMSCAT02 to XYZ to LMS
{{464053391886875/594479206165966,546172937177000/2593784454432131,25677829793875/681030107553338},
{89354738755625/297239603082983,1563686005000000/2593784454432131,28321738606875/340515053776669},
{-274069337500/27021782098453,-14274125600000/2593784454432131,317936256400000/340515053776669}}
// XYZ to LMSCAT02, white point adaptation and LMSCAT02 to XYZ to LMS
{{1535883035237967283712368316373/3622507351858025034877836622160,313936929155525071434095214423/452813418982253129359729577770,-320255941654937541603650371757/3622507351858025034877836622160},
{-73765545839823421271159289111/362250735185802503487783662216,52237841914778168455574637779/45281341898225312935972957777,13276522859463209890873256879/362250735185802503487783662216},
{-3125719934910748888276760/4116485627111392085088450707,-4119398094368106819832290/4116485627111392085088450707,3786370264907456584747946550/4116485627111392085088450707}}
// RGB to XYZ to LMSCAT02, white point adaptation and LMSCAT02 to XYZ to LMS
{{782910914364235953227073443841197/2505869460647788817876743483379180,47437201892727083793508359035427793/75176083819433664536302304501375400,4251554495779502145981742150711697/75176083819433664536302304501375400},
{124459316400474051550350235432343/751760838194336645363023045013754,5551656166817314597571817932574949/7517608381943366453630230450137540,240453017040437113518303387746387/2505869460647788817876743483379180},
{190503071007861562472684780870/11390315730217221899439743106269,3484707111371743136520220253336/34170947190651665698319229318807,30114730866256337874380954722861/34170947190651665698319229318807}}
// reverse
{{5889610677243193337436144851/1005872293755806060844662500,-50563246336667155788637763367/10058722937558060608446625000,1725862501793283022722939857/10058722937558060608446625000},
{-156299752813513892312443129/118586087319713310233175625,2972168594434151167364839293/1185860873197133102331756250,-223310193101879141908651753/1185860873197133102331756250},
{41217384068187972753550441/995689156108134584983951250,-1937830199233462093713839397/9956891561081345849839512500,11482547919632928216017847487/9956891561081345849839512500}}




preccalc64.exe
construct the RGB to XYZ matrices

/*
// these are for SMPTE 170M/SMPTE 240M/SMPTE C (NTSC)
ix_r = .63;
iy_r = .34;
ix_g = .31;
iy_g = .595;
ix_b = .155;
iy_b = .07;
ix_w = .3127;
iy_w = .329;
*/
/*
// these are for BT.470-2 System M
ix_r = .67;
iy_r = .33;
ix_g = .21;
iy_g = .71;
ix_b = .14;
iy_b = .08;
ix_w = .31;
iy_w = .316;
*/
/*
// these are for BT.470-2 System B,G/EBU 3213 (PAL/SECAM)
ix_r = .64;
iy_r = .33;
ix_g = .29;
iy_g = .6;
ix_b = .15;
iy_b = .06;
ix_w = .3127;
iy_w = .329;
*/
// these are for BT.709
ix_r = .64;
iy_r = .33;
ix_g = .3;
iy_g = .6;
ix_b = .15;
iy_b = .06;
ix_w = .3127;
iy_w = .329;



X_r = ix_r / iy_r;
Z_r = (1. - ix_r - iy_r) / iy_r;
X_g = ix_g / iy_g;
Z_g = (1. - ix_g - iy_g) / iy_g;
X_b = ix_b / iy_b;
Z_b = (1. - ix_b - iy_b) / iy_b;
X_w = ix_w / iy_w;
Z_w = (1. - ix_w - iy_w) / iy_w;

Mdetr = 1. / (X_r * (Z_b - Z_g) - X_g * (Z_b - Z_r) + X_b * (Z_g - Z_r));
S_r = (X_w * (Z_b - Z_g) + X_b * Z_g - X_g * Z_b + Z_w * (X_g - X_b)) * Mdetr;
S_g = (X_w * (Z_r - Z_b) + X_r * Z_b - X_b * Z_r + Z_w * (X_b - X_r)) * Mdetr;
S_b = (X_w * (Z_g - Z_r) + X_g * Z_r - X_r * Z_g + Z_w * (X_r - X_g)) * Mdetr;

MX_r = S_r * X_r;
MX_g = S_g * X_g;
MX_b = S_b * X_b;
MY_r = S_r;
MY_g = S_g;
MY_b = S_b;
MZ_r = S_r * Z_r;
MZ_g = S_g * Z_g;
MZ_b = S_b * Z_b;

print MX_r, ",", MX_g, ",", MX_b, ",", MY_r, ",", MY_g, ",", MY_b, ",", MZ_r, ",", MZ_g, ",", MZ_b;
__________________
development folder, containing MPC-HC experimental tester builds, pixel shaders and more: http://www.mediafire.com/?xwsoo403c53hv
JanWillem32 is offline   Reply With Quote
Old 17th March 2014, 07:13   #9  |  Link
turbojet
Registered User
 
Join Date: May 2008
Posts: 1,840
Thanks CeeJay.dk, I have a few questions about lumasharpen:

1. Is the lumasharpen you posted the same as v1.41 in my signature?
2. What allows pattern 3 to use very high strength with very few artifacts while the other patterns have all sort of artifacts? Is it taps?
3. Do all of your scripts have versions? It would be nice to have a version near the top like the translations on guru3d have.

The general consensus for lumasharpen defaults seem to be pattern 3, strength 1.5, clamp 0.05. It's not quite what I use (3, 1.0, 0.5) but I use it pre-resize (effects lower contrast edges) and post-resize (high contrast edges) for the more 'even sharpening' it gives.

I wouldn't worry about coming up with an editor, editing a text is simple enough. One thing that might be nice is having 2 sets of files, one .hlsl in a mpc-hc dir and another with .txt in another directory for all other players.
__________________
PC: FX-8320 GTS250 HTPC: G1610 GTX650
PotPlayer/MPC-BE LAVFilters MadVR-Bicubic75AR/Lanczos4AR/Lanczos4AR LumaSharpen -Strength0.9-Pattern3-Clamp0.1-OffsetBias2.0

Last edited by turbojet; 17th March 2014 at 07:17.
turbojet is offline   Reply With Quote
Old 17th March 2014, 13:06   #10  |  Link
CeeJay.dk
Registered User
 
Join Date: Dec 2003
Location: Denmark
Posts: 117
Quote:
Originally Posted by turbojet View Post
1. Is the lumasharpen you posted the same as v1.41 in my signature?
2. What allows pattern 3 to use very high strength with very few artifacts while the other patterns have all sort of artifacts? Is it taps?
3. Do all of your scripts have versions? It would be nice to have a version near the top like the translations on guru3d have.
1. Yes. It's v1.4.1
2. It uses a wider sampling pattern which is more resistant to noise, but also doesn't pick up very small details as well as pattern 2. Pattern 2 is the default for the normal SweetFX release because games almost never have noise and never has artifacts - movies however do so pattern 3 is probably best for those. So yes .. taps.

From the sourcecode :
Code:
  // -- 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 ]
Code:
  // -- 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 ,   ]
3. Not all of them but perhaps they should have. I'll try to remember to include a version more often.

Last edited by CeeJay.dk; 17th March 2014 at 14:49.
CeeJay.dk is offline   Reply With Quote
Old 17th March 2014, 13:17   #11  |  Link
CeeJay.dk
Registered User
 
Join Date: Dec 2003
Location: Denmark
Posts: 117
Jan , the DPX effect was originally written by Loadus .

All I did was port it to SweetFX and improve the performance of it a bit. I don't fully understand why it is written the way it is.
Maybe we can get Loadus to shed some more light on it?
CeeJay.dk is offline   Reply With Quote
Old 17th March 2014, 19:52   #12  |  Link
JanWillem32
Registered User
 
JanWillem32's Avatar
 
Join Date: Oct 2010
Location: The Netherlands
Posts: 1,084
Tracing Loadus' tracks revealed that he's mostly an artist, and to a much lesser extent a programmer. http://forum.doom9.org/showthread.php?p=1400044 http://forum.doom9.org/showthread.php?p=1399491
The reference page is: http://www.loadusfx.net/virtualdub/filmfxguide.htm .
The idea for this effect is nice enough, but it's implemented in a primitive way. For an example of improvements to consider, replace the ''grayscale'' (a name only suitable for representations from Y' (luma) in Y'CbCr or maybe even R'G'B' components) filtering to proper achromatic response, lightness or brightness filtering.
__________________
development folder, containing MPC-HC experimental tester builds, pixel shaders and more: http://www.mediafire.com/?xwsoo403c53hv
JanWillem32 is offline   Reply With Quote
Old 18th March 2014, 13:48   #13  |  Link
James Freeman
Registered User
 
Join Date: Sep 2013
Posts: 909
@CeeJay.dk

Thank you very much.
I really love LumaSharpen 1.4.1.
__________________
System: i7 3770K, GTX660, Win7 64bit, Panasonic ST60, Dell U2410.
James Freeman is offline   Reply With Quote
Old 18th March 2014, 14:55   #14  |  Link
toniash
Registered User
 
Join Date: Oct 2010
Posts: 112
my values for SD material

after resize (softcubic sharpness 70)
#define sharp_strength 2.65
#define sharp_clamp .019
#define pattern 3
#define offset_bias 1.6
#define show_sharpen 0
toniash is offline   Reply With Quote
Old 18th March 2014, 23:07   #15  |  Link
turbojet
Registered User
 
Join Date: May 2008
Posts: 1,840
CeeJay.dk: I'd like to experiment with even more taps and possibly more texture fetches, do you have an example of how to adjust these? Is there a math program that's helpful for this?
__________________
PC: FX-8320 GTS250 HTPC: G1610 GTX650
PotPlayer/MPC-BE LAVFilters MadVR-Bicubic75AR/Lanczos4AR/Lanczos4AR LumaSharpen -Strength0.9-Pattern3-Clamp0.1-OffsetBias2.0
turbojet is offline   Reply With Quote
Old 19th March 2014, 22:54   #16  |  Link
CeeJay.dk
Registered User
 
Join Date: Dec 2003
Location: Denmark
Posts: 117
Quote:
Originally Posted by turbojet View Post
CeeJay.dk: I'd like to experiment with even more taps and possibly more texture fetches, do you have an example of how to adjust these? Is there a math program that's helpful for this?
You can modify pattern 8 or 9 in the code .. I only use them for debugging, but they have 9 fetches.

That should be enough to do a 5x5 blur kernel if you use exploit bilinear filtering to capture 4 taps with each texture fetch.

You can add more fetches if you want.

As for what kernel you want that is up to you.
I don't know of a good tool to design convolution kernels but if anyone knows please share. I use quad paper myself.

To do a sharpen you to find the contrast of the center pixel and enhance that. To find the contrast you need to find the difference between the average of the surrounding pixels and the center pixel.
I use a gaussian blur kernel to get a weighted average, but you can also do a mean or a median (although that requires a lot of math instructions) or some sort of hybrid like discarding the brightest and darkest pixels and doing a mean of the remainders or do a median in one pass and then do a gaussian on the result in a second pass.

I prefer to use gaussians derived from pascals triangle simply because they are easy to calculate (anyone know of a good program to calculate gaussians?)

You could start with a 5x5 gaussian kernel like

Code:
	//   [ 1 , 4 , 6 , 4 , 1 ]
	//   [ 4 ,16 ,24 ,16 , 4 ]
	//   [ 6 ,24 ,36 ,24 , 6 ]
	//   [ 4 ,16 ,24 ,16 , 4 ]
	//   [ 1 , 4 , 6 , 4 , 1 ]
(Pattern 3 is a reduced version of this that leaves out certain taps for performance reasons)

This can be achieved with just 9 texture fetches in one pass or even fewer in 2 passes (but doing 2 passes in MPC is tricky and requires you to make two shaders and pass the data from the first to the second in the alpha channel .. or at least that's my theory - I have yet to try it)

Last edited by CeeJay.dk; 20th March 2014 at 16:05.
CeeJay.dk is offline   Reply With Quote
Old 21st March 2014, 08:19   #17  |  Link
turbojet
Registered User
 
Join Date: May 2008
Posts: 1,840
Thanks, I'll try playing around with it but afraid it's over my head.
__________________
PC: FX-8320 GTS250 HTPC: G1610 GTX650
PotPlayer/MPC-BE LAVFilters MadVR-Bicubic75AR/Lanczos4AR/Lanczos4AR LumaSharpen -Strength0.9-Pattern3-Clamp0.1-OffsetBias2.0
turbojet is offline   Reply With Quote
Old 22nd March 2014, 00:10   #18  |  Link
CeeJay.dk
Registered User
 
Join Date: Dec 2003
Location: Denmark
Posts: 117
Quote:
Originally Posted by turbojet View Post
Thanks, I'll try playing around with it but afraid it's over my head.
What parts do you struggle with?

Do you know how convolutions work?

Do you understand what
Code:
float3 blur_ori = myTex2D(s0, tex + float2(px,-py) * 0.5 * offset_bias).rgb; // South East
does?
CeeJay.dk is offline   Reply With Quote
Old 23rd March 2014, 20:27   #19  |  Link
sidspyker
Registered User
 
Join Date: Jun 2013
Posts: 61
Well well, fancy seeing you here CeeJay

I'm gonna try these out, thanks!
sidspyker is offline   Reply With Quote
Old 23rd March 2014, 21:31   #20  |  Link
turbojet
Registered User
 
Join Date: May 2008
Posts: 1,840
CeeJay.dk: I struggle with most parts of it, no clue how convolutions work. I don't understand what the code does. I'll just stay happy with pattern=3 it's plenty good, maybe at some point trying a pattern with more taps could be an improvement for film content or it might be interesting to see if more texture fetches has any effect with many taps.
__________________
PC: FX-8320 GTS250 HTPC: G1610 GTX650
PotPlayer/MPC-BE LAVFilters MadVR-Bicubic75AR/Lanczos4AR/Lanczos4AR LumaSharpen -Strength0.9-Pattern3-Clamp0.1-OffsetBias2.0
turbojet 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 23:42.


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