#69832 - 05/24/11 11:03 PM
SHADER PRESET ONE-STOP SHOP
|
Very Senior Member
Registered: 05/23/09
Posts: 1385
|
These are the perfect shader settings. If you don't like them, noooooo! Technical merit notwithstanding, I argue these look damn close to my family's shitty 19" TV 80's-era TV. In all cases, click the thumby for bigginess. NES hlsl_enable 1 hlslpath hlsl shadow_mask_alpha 0.25 shadow_mask_texture aperture.png shadow_mask_x_count 512 shadow_mask_y_count 384 shadow_mask_usize 0.125 shadow_mask_vsize 0.125 oversample_x 1.0 oversample_y 1.0 curvature 0.05 screen_scale_top 1.0 screen_scale_bottom 1.0 pincushion 0.05 scanline_alpha 0.5 scanline_size 1.0 scanline_bright_scale 1.0 scanline_bright_offset 0.7 scanline_jitter 0.0 defocus_x 0.0 defocus_y 0.0 red_converge_x 0.0 red_converge_y 0.0 green_converge_x 0.0 green_converge_y 0.0 blue_converge_x 0.0 blue_converge_y 0.0 red_radial_converge_x 0.0 red_radial_converge_y 0.0 green_radial_converge_x 0.0 green_radial_converge_y 0.0 blue_radial_converge_x 0.0 blue_radial_converge_y 0.0 red_from_r 0.95 red_from_g 0.05 red_from_b 0.0 green_from_r 0.0 green_from_g 0.95 green_from_b 0.05 blue_from_r 0.05 blue_from_g 0.0 blue_from_b 0.95 saturation 1.5 red_offset 0.0 green_offset 0.0 blue_offset 0.0 red_scale 1.2 green_scale 1.2 blue_scale 1.2 red_power 2.2 green_power 2.2 blue_power 2.2 red_floor 0.05 green_floor 0.05 blue_floor 0.05 red_phosphor_life 0.45 green_phosphor_life 0.45 blue_phosphor_life 0.45 yiq_enable 1 yiq_w 4.1187867 yiq_a 0.5 yiq_b 0.5 yiq_fsc 1.5 yiq_fsc_scale 1.0 yiq_phase_count 3
SNES hlsl_enable 1 hlslpath hlsl shadow_mask_alpha 0.25 shadow_mask_texture aperture.png shadow_mask_x_count 512 shadow_mask_y_count 384 shadow_mask_usize 0.125 shadow_mask_vsize 0.125 oversample_x 1.0 oversample_y 1.0 curvature 0.05 screen_scale_top 1.0 screen_scale_bottom 1.0 pincushion 0.05 scanline_alpha 0.5 scanline_size 1.0 scanline_bright_scale 1.0 scanline_bright_offset 0.7 scanline_jitter 0.0 defocus_x 0.0 defocus_y 0.0 red_converge_x 0.0 red_converge_y 0.0 green_converge_x 0.0 green_converge_y 0.0 blue_converge_x 0.0 blue_converge_y 0.0 red_radial_converge_x 0.0 red_radial_converge_y 0.0 green_radial_converge_x 0.0 green_radial_converge_y 0.0 blue_radial_converge_x 0.0 blue_radial_converge_y 0.0 red_from_r 0.95 red_from_g 0.05 red_from_b 0.0 green_from_r 0.0 green_from_g 0.95 green_from_b 0.05 blue_from_r 0.05 blue_from_g 0.0 blue_from_b 0.95 saturation 1.5 red_offset 0.0 green_offset 0.0 blue_offset 0.0 red_scale 1.2 green_scale 1.2 blue_scale 1.2 red_power 2.2 green_power 2.2 blue_power 2.2 red_floor 0.05 green_floor 0.05 blue_floor 0.05 red_phosphor_life 0.45 green_phosphor_life 0.45 blue_phosphor_life 0.45 yiq_enable 1 yiq_w 4.1187867 yiq_a 0.5 yiq_b 0.5 yiq_fsc 1.5 yiq_fsc_scale 1.0 yiq_phase_count 3
Genesis hlsl_enable 1 hlslpath hlsl shadow_mask_alpha 0.25 shadow_mask_texture aperture.png shadow_mask_x_count 512 shadow_mask_y_count 384 shadow_mask_usize 0.125 shadow_mask_vsize 0.125 oversample_x 1.0 oversample_y 1.0 curvature 0.05 screen_scale_top 1.0 screen_scale_bottom 1.0 pincushion 0.05 scanline_alpha 0.5 scanline_size 1.0 scanline_bright_scale 1.0 scanline_bright_offset 0.7 scanline_jitter 0.0 defocus_x 0.0 defocus_y 0.0 red_converge_x 0.0 red_converge_y 0.0 green_converge_x 0.0 green_converge_y 0.0 blue_converge_x 0.0 blue_converge_y 0.0 red_radial_converge_x 0.0 red_radial_converge_y 0.0 green_radial_converge_x 0.0 green_radial_converge_y 0.0 blue_radial_converge_x 0.0 blue_radial_converge_y 0.0 red_from_r 1.0 red_from_g 0.0 red_from_b 0.0 green_from_r 0.0 green_from_g 1.0 green_from_b 0.0 blue_from_r 0.0 blue_from_g 0.0 blue_from_b 1.0 saturation 1.5 red_offset 0.0 green_offset 0.0 blue_offset 0.0 red_scale 1.2 green_scale 1.2 blue_scale 1.2 red_power 2.2 green_power 2.2 blue_power 2.2 red_floor 0.05 green_floor 0.05 blue_floor 0.05 red_phosphor_life 0.45 green_phosphor_life 0.45 blue_phosphor_life 0.45 yiq_enable 1 yiq_w 3.1415926535897932384626433832795 yiq_a 0.0 yiq_b 0.5 yiq_fsc 1.875 yiq_fsc_scale 1.0 yiq_phase_count 2
|
|
Top
|
|
|
|
#69839 - 05/25/11 04:16 AM
Re: SHADER PRESET ONE-STOP SHOP
[Re: Just Desserts]
|
Senior Member
Registered: 04/02/11
Posts: 214
|
WOW, I'm so glad I stopped in to shop  Perfect it is Here is results running mslug with nvidia GTX 480 and Samsung WS LCD 20" 
|
|
Top
|
|
|
|
#69841 - 05/25/11 04:29 AM
Re: SHADER PRESET ONE-STOP SHOP
[Re: B2K24]
|
Very Senior Member
Registered: 05/23/09
Posts: 1385
|
You know, officially including GPL-derived shaders with MESS or MAME would violate said license. ...Nobody says you can't post 'em separately! Drop this over top of deconverge.fx in order to lose convergence but gain (ugh) HQ2x:
//-----------------------------------------------------------------------------
// HQ2x Effect
//-----------------------------------------------------------------------------
texture Diffuse;
sampler DiffuseSampler = sampler_state
{
Texture = <Diffuse>;
MipFilter = LINEAR;
MinFilter = LINEAR;
MagFilter = LINEAR;
AddressU = CLAMP;
AddressV = CLAMP;
AddressW = CLAMP;
};
//-----------------------------------------------------------------------------
// Vertex Definitions
//-----------------------------------------------------------------------------
struct VS_OUTPUT
{
float4 Position : POSITION;
float2 TexCoord : TEXCOORD0;
float4 TexPair0 : TEXCOORD1;
float4 TexPair1 : TEXCOORD2;
float4 TexPair2 : TEXCOORD3;
float4 TexPair3 : TEXCOORD4;
};
struct VS_INPUT
{
float4 Position : POSITION;
float4 Color : COLOR0;
float2 TexCoord : TEXCOORD0;
};
struct PS_INPUT
{
float2 TexCoord : TEXCOORD0;
float4 TexPair0 : TEXCOORD1;
float4 TexPair1 : TEXCOORD2;
float4 TexPair2 : TEXCOORD3;
float4 TexPair3 : TEXCOORD4;
};
//-----------------------------------------------------------------------------
// HQ2x Vertex Shader
//-----------------------------------------------------------------------------
float TargetWidth;
float TargetHeight;
float RawWidth;
float RawHeight;
VS_OUTPUT vs_main(VS_INPUT Input)
{
VS_OUTPUT Output = (VS_OUTPUT)0;
Output.Position = float4(Input.Position.xyz, 1.0f);
Output.Position.x /= TargetWidth;
Output.Position.y /= TargetHeight;
Output.Position.y = 1.0f - Output.Position.y;
Output.Position.x -= 0.5f;
Output.Position.y -= 0.5f;
Output.Position *= float4(2.0f, 2.0f, 1.0f, 1.0f);
float2 DownRight = float2(0.5f / RawWidth, 0.5f / RawHeight);
float2 DownLeft = DownRight * float2(-1.0f, 1.0f);
float2 PixWidth = float2(DownRight.x, 0.0f);
float2 PixHeight = float2(0.0f, DownRight.y);
Output.TexCoord = Input.TexCoord;
Output.TexPair0.xy = Input.TexCoord - DownRight;
Output.TexPair0.zw = Input.TexCoord - PixHeight;
Output.TexPair1.xy = Input.TexCoord - DownLeft;
Output.TexPair1.zw = Input.TexCoord + PixWidth;
Output.TexPair2.xy = Input.TexCoord + DownRight;
Output.TexPair2.zw = Input.TexCoord + PixHeight;
Output.TexPair3.xy = Input.TexCoord + DownLeft;
Output.TexPair3.zw = Input.TexCoord - PixWidth;
return Output;
}
//-----------------------------------------------------------------------------
// Deconvergence Pixel Shader
//-----------------------------------------------------------------------------
const float SmoothWeight = 0.325f;
const float MaxWeight = 0.25f;
const float MinWeight = -0.05f;
const float WeightDelta = -0.25f;
const float LumaOffset = 0.25f;
float4 ps_main(PS_INPUT Input) : COLOR
{
float3 UL = tex2D(DiffuseSampler, Input.TexPair0.xy);
float3 UU = tex2D(DiffuseSampler, Input.TexPair0.zw);
float3 UR = tex2D(DiffuseSampler, Input.TexPair1.xy);
float3 LL = tex2D(DiffuseSampler, Input.TexPair3.zw);
float3 CC = tex2D(DiffuseSampler, Input.TexCoord);
float3 RR = tex2D(DiffuseSampler, Input.TexPair1.zw);
float3 BL = tex2D(DiffuseSampler, Input.TexPair3.xy);
float3 BB = tex2D(DiffuseSampler, Input.TexPair2.zw);
float3 BR = tex2D(DiffuseSampler, Input.TexPair2.xy);
float3 DotSummer = float3(1.0f, 1.0f, 1.0f);
float Mid1 = dot(abs(UL - BR), DotSummer);
float Mid2 = dot(abs(UR - BL), DotSummer);
float Weight1 = dot(abs(BR - CC), DotSummer) * Mid2;
float Weight2 = dot(abs(BL - CC), DotSummer) * Mid1;
float Weight3 = dot(abs(UL - CC), DotSummer) * Mid2;
float Weight4 = dot(abs(UR - CC), DotSummer) * Mid1;
float Cross1 = Weight1 + Weight3;
float Cross2 = Weight2 + Weight4;
float Weight = max(Cross1, Cross2) + 0.0001f;
CC = (Weight1 * UL + Weight2 * UR + Weight3 * BR + Weight4 * BL + Weight * CC) / (Cross1 + Cross2 + Weight);
float RecipCenter1 = WeightDelta / (0.12f * dot(UU + CC + BB, DotSummer) + LumaOffset);
float RecipCenter2 = WeightDelta / (0.12f * dot(LL + CC + RR, DotSummer) + LumaOffset);
Weight1 = clamp(RecipCenter1 * dot(abs(CC - UU), DotSummer) + SmoothWeight, MinWeight, MaxWeight);
Weight2 = clamp(RecipCenter2 * dot(abs(CC - RR), DotSummer) + SmoothWeight, MinWeight, MaxWeight);
Weight3 = clamp(RecipCenter1 * dot(abs(CC - BB), DotSummer) + SmoothWeight, MinWeight, MaxWeight);
Weight4 = clamp(RecipCenter2 * dot(abs(CC - LL), DotSummer) + SmoothWeight, MinWeight, MaxWeight);
float3 OutColor = Weight1 * UU + Weight2 * RR + Weight3 * BB + Weight4 * LL + (1.0f - Weight1 - Weight2 - Weight3 - Weight4) * CC;
return float4(OutColor, 1.0f);
}
//-----------------------------------------------------------------------------
// HQ2x Effect
//-----------------------------------------------------------------------------
technique DeconvergeTechnique
{
pass Pass0
{
Lighting = FALSE;
VertexShader = compile vs_3_0 vs_main();
PixelShader = compile ps_3_0 ps_main();
}
}
(click for big) 
|
|
Top
|
|
|
|
#69843 - 05/25/11 05:48 AM
Re: SHADER PRESET ONE-STOP SHOP
[Re: Just Desserts]
|
Very Senior Member
Registered: 05/23/09
Posts: 1385
|
Scale2x, same dance, copy over top of deconverge.fx:
//-----------------------------------------------------------------------------
// Scale2x Effect
//-----------------------------------------------------------------------------
texture Diffuse;
sampler DiffuseSampler = sampler_state
{
Texture = <Diffuse>;
MipFilter = POINT;
MinFilter = POINT;
MagFilter = POINT;
AddressU = CLAMP;
AddressV = CLAMP;
AddressW = CLAMP;
};
//-----------------------------------------------------------------------------
// Vertex Definitions
//-----------------------------------------------------------------------------
struct VS_OUTPUT
{
float4 Position : POSITION;
float2 TexCoord : TEXCOORD0;
float2 LeftCoord : TEXCOORD1;
float2 RightCoord : TEXCOORD2;
float2 TopCoord : TEXCOORD3;
float2 BottomCoord : TEXCOORD4;
};
struct VS_INPUT
{
float4 Position : POSITION;
float4 Color : COLOR0;
float2 TexCoord : TEXCOORD0;
};
struct PS_INPUT
{
float2 TexCoord : TEXCOORD0;
float2 LeftCoord : TEXCOORD1;
float2 RightCoord : TEXCOORD2;
float2 TopCoord : TEXCOORD3;
float2 BottomCoord : TEXCOORD4;
};
//-----------------------------------------------------------------------------
// Scale2x Vertex Shader
//-----------------------------------------------------------------------------
float TargetWidth;
float TargetHeight;
float RawWidth;
float RawHeight;
VS_OUTPUT vs_main(VS_INPUT Input)
{
VS_OUTPUT Output = (VS_OUTPUT)0;
Output.Position = float4(Input.Position.xyz, 1.0f);
Output.Position.x /= TargetWidth;
Output.Position.y /= TargetHeight;
Output.Position.y = 1.0f - Output.Position.y;
Output.Position.x -= 0.5f;
Output.Position.y -= 0.5f;
Output.Position *= float4(2.0f, 2.0f, 1.0f, 1.0f);
float2 PixWidth = float2(1.0f / RawWidth, 0.0f);
float2 PixHeight = float2(0.0f, 1.0f / RawHeight);
Output.TexCoord = Input.TexCoord;
Output.LeftCoord = Input.TexCoord - PixWidth;
Output.RightCoord = Input.TexCoord + PixWidth;
Output.TopCoord = Input.TexCoord - PixHeight;
Output.BottomCoord = Input.TexCoord + PixHeight;
return Output;
}
//-----------------------------------------------------------------------------
// Scale2x Pixel Shader
//-----------------------------------------------------------------------------
float4 ps_main(PS_INPUT Input) : COLOR
{
float4 Center = tex2D(DiffuseSampler, Input.TexCoord);
float4 Left = tex2D(DiffuseSampler, Input.LeftCoord);
float4 Right = tex2D(DiffuseSampler, Input.RightCoord);
float4 Up = tex2D(DiffuseSampler, Input.TopCoord);
float4 Bottom = tex2D(DiffuseSampler, Input.BottomCoord);
float2 PixelSize = frac(Input.TexCoord * float2(RawWidth, RawHeight));
// Split along the texel centerpoint
if(PixelSize.y >= 0.5f)
{
float4 swap = Up;
Up = Bottom;
Bottom = swap;
}
if(PixelSize.x >= 0.5f)
{
float4 swap = Left;
Left = Right;
Right = swap;
}
float Match1 = Up == Left;
float Match2 = Up != Right;
float Match3 = Left != Bottom;
if(Match1 && Match2 && Match3)
{
Center = Left;
}
return Center;
}
//-----------------------------------------------------------------------------
// Scale2x Effect
//-----------------------------------------------------------------------------
technique DeconvergeTechnique
{
pass Pass0
{
Lighting = FALSE;
VertexShader = compile vs_3_0 vs_main();
PixelShader = compile ps_3_0 ps_main();
}
}
|
|
Top
|
|
|
|
#69846 - 05/25/11 12:58 PM
Re: SHADER PRESET ONE-STOP SHOP
[Re: Just Desserts]
|
Member
Registered: 05/25/11
Posts: 11
|
Many thanks for all the hard work. HLSL is definitely godsend for all of us LCD users. I never thought it would be possible to simulate CRT phosphor bleed and glow. It looks amazing and brings life to good ol' games that we all grew up with.
I would really appreciate if someone could post the code for "Scale3x".
PS. After overwriting and pasting the code to "deconverge.fx" will it be auto enabled when hlsl_enable is 1 or will it only be enabled through the converge settings (as seen below)?
red/green/blue_converge_x ,/y | red/green/blue_radial_converge_x/y
Thanks in advance.
Edited by MilliGoodz (05/25/11 12:59 PM)
|
|
Top
|
|
|
|
#69857 - 05/25/11 05:28 PM
Re: SHADER PRESET ONE-STOP SHOP
[Re: Just Desserts]
|
Senior Member
Registered: 03/16/06
Posts: 706
Loc: PA, USA
|
_________________________
"When life gives you zombies... *CHA-CHIK!* ...you make zombie-ade!"
|
|
Top
|
|
|
|
#69859 - 05/25/11 06:32 PM
Re: SHADER PRESET ONE-STOP SHOP
[Re: Lord Nightmare]
|
Member
Registered: 05/25/11
Posts: 11
|
Thanks for the info Lord Nightmare but unfortunately I cannot use that. I'm looking for the GPL-derived shaders of the scale3x algorithm. PS. I'm still not able to use the scale2x shader posted above even after replacing deconverge.fx with the code. The video output sure looks slightly sharper but the filter still looks disabled when it comes to pixel-edge enhancement when I compare it with scale2x in for exampe MamePlus for the same game. Here are my D3D PP options and I'm not sure why scale2x is still inactive even after I've updated the deconverge.fx. I would appreciate any help to solve this. Cheers #
# DIRECT3D POST-PROCESSING OPTIONS
#
hlsl_enable 1
hlslpath hlsl
shadow_mask_alpha 0.1
shadow_mask_texture aperture.png
shadow_mask_x_count 1440
shadow_mask_y_count 900
shadow_mask_usize 0.125
shadow_mask_vsize 0.125
oversample_x 1.0
oversample_y 1.0
curvature 0.05
screen_scale_top 1.0
screen_scale_bottom 1.0
pincushion 0.0
scanline_alpha 0.5
scanline_size 1.6
scanline_bright_scale 1.1
scanline_bright_offset 0.7
scanline_jitter 0.0
defocus_x 0.15
defocus_y 0.15
red_converge_x 0.0
red_converge_y 0.0
green_converge_x 0.0
green_converge_y 0.0
blue_converge_x 0.0
blue_converge_y 0.0
red_radial_converge_x 0.0
red_radial_converge_y 0.0
green_radial_converge_x 0.0
green_radial_converge_y 0.0
blue_radial_converge_x 0.0
blue_radial_converge_y 0.0
red_from_r 1.0
red_from_g 0.0
red_from_b 0.0
green_from_r 0.0
green_from_g 1.0
green_from_b 0.0
blue_from_r 0.0
blue_from_g 0.0
blue_from_b 1.0
saturation 0.70
red_offset 0.0
green_offset 0.0
blue_offset 0.0
red_scale 1.0
green_scale 1.0
blue_scale 1.0
red_power 1.6
green_power 1.6
blue_power 1.6
red_floor 0.05
green_floor 0.05
blue_floor 0.05
red_phosphor_life 0.50
green_phosphor_life 0.50
blue_phosphor_life 0.50
yiq_enable 0
yiq_w 4.1887902047863909846168578443727
yiq_a 0.5
yiq_b 0.5
yiq_fsc 1.5
yiq_fsc_scale 0.5
yiq_phase_count 2
|
|
Top
|
|
|
|
#69861 - 05/25/11 07:12 PM
Re: SHADER PRESET ONE-STOP SHOP
[Re: MilliGoodz]
|
Very Senior Member
Registered: 05/23/09
Posts: 1385
|
I don't have a solution immediately offhand, but it looks like you set shadow_mask_x_count and shadow_mask_y_count to be the number of visible pixels in your display. It should be the number of visible dots in the original display's shadow mask, and I'm not sure that any CRTs were ever made that have a 1440x900 shadow mask. Typically they were in the neighborhood of 512x384 to 640x480, and due to the way the shader works it's more likely to look better at 512x384.
|
|
Top
|
|
|
|
|
4509 Members
9 Forums
7636 Topics
95532 Posts
Max Online: 225 @ 05/26/14 05:34 PM
|
|
|