From cfe215d6c0cb8376f9c01cff05a7dc8e71d72fcd Mon Sep 17 00:00:00 2001 From: zeromus Date: Tue, 13 Oct 2015 17:17:38 -0500 Subject: [PATCH] repair lousy assortment of built-in shaders (fixes #518) --- .../DisplayManager/DisplayManager.cs | 16 +++---- output/Shaders/BizHawk/BizScanlines.cg | 32 ++++++++++++++ output/Shaders/BizHawk/BizScanlines.cgp | 2 +- output/Shaders/BizHawk/hq2x.cg | 42 +++++++++---------- output/Shaders/BizHawk/hq2x.cgp | 2 +- 5 files changed, 61 insertions(+), 33 deletions(-) create mode 100644 output/Shaders/BizHawk/BizScanlines.cg diff --git a/BizHawk.Client.EmuHawk/DisplayManager/DisplayManager.cs b/BizHawk.Client.EmuHawk/DisplayManager/DisplayManager.cs index d68a34e804..90e4d6fec0 100644 --- a/BizHawk.Client.EmuHawk/DisplayManager/DisplayManager.cs +++ b/BizHawk.Client.EmuHawk/DisplayManager/DisplayManager.cs @@ -65,14 +65,14 @@ namespace BizHawk.Client.EmuHawk if (GL is BizHawk.Bizware.BizwareGL.Drivers.OpenTK.IGL_TK || GL is BizHawk.Bizware.BizwareGL.Drivers.SlimDX.IGL_SlimDX9) { - //var fiHq2x = new FileInfo(Path.Combine(PathManager.GetExeDirectoryAbsolute(), "Shaders/BizHawk/hq2x.cgp")); - //if (fiHq2x.Exists) - // using (var stream = fiHq2x.OpenRead()) - // ShaderChain_hq2x = new Filters.RetroShaderChain(GL, new Filters.RetroShaderPreset(stream), Path.Combine(PathManager.GetExeDirectoryAbsolute(), "Shaders/BizHawk")); - //var fiScanlines = new FileInfo(Path.Combine(PathManager.GetExeDirectoryAbsolute(), "Shaders/BizHawk/BizScanlines.cgp")); - //if (fiScanlines.Exists) - // using (var stream = fiScanlines.OpenRead()) - // ShaderChain_scanlines = new Filters.RetroShaderChain(GL, new Filters.RetroShaderPreset(stream), Path.Combine(PathManager.GetExeDirectoryAbsolute(), "Shaders/BizHawk")); + var fiHq2x = new FileInfo(Path.Combine(PathManager.GetExeDirectoryAbsolute(), "Shaders/BizHawk/hq2x.cgp")); + if (fiHq2x.Exists) + using (var stream = fiHq2x.OpenRead()) + ShaderChain_hq2x = new Filters.RetroShaderChain(GL, new Filters.RetroShaderPreset(stream), Path.Combine(PathManager.GetExeDirectoryAbsolute(), "Shaders/BizHawk")); + var fiScanlines = new FileInfo(Path.Combine(PathManager.GetExeDirectoryAbsolute(), "Shaders/BizHawk/BizScanlines.cgp")); + if (fiScanlines.Exists) + using (var stream = fiScanlines.OpenRead()) + ShaderChain_scanlines = new Filters.RetroShaderChain(GL, new Filters.RetroShaderPreset(stream), Path.Combine(PathManager.GetExeDirectoryAbsolute(), "Shaders/BizHawk")); string bicubic_path = "Shaders/BizHawk/bicubic-fast.cgp"; if(GL is BizHawk.Bizware.BizwareGL.Drivers.SlimDX.IGL_SlimDX9) bicubic_path = "Shaders/BizHawk/bicubic-normal.cgp"; diff --git a/output/Shaders/BizHawk/BizScanlines.cg b/output/Shaders/BizHawk/BizScanlines.cg new file mode 100644 index 0000000000..9f25aab64d --- /dev/null +++ b/output/Shaders/BizHawk/BizScanlines.cg @@ -0,0 +1,32 @@ + +struct input +{ + float2 video_size; + float2 texture_size; + float2 output_size; +}; + +void main_vertex +( + float4 position : POSITION, + out float4 oPosition : POSITION, + uniform float4x4 modelViewProj, + + float2 tex : TEXCOORD, + + uniform input IN, + out float2 oTexcoord : TEXCOORD +) +{ + oPosition = mul(modelViewProj, position); + oTexcoord = tex; +} + +uniform float uIntensity; + +float4 main_fragment (in float2 texcoord : TEXCOORD, in float2 wpos : WPOS, uniform sampler2D s_p : TEXUNIT0) : COLOR +{ + float4 temp = tex2D(s_p,texcoord); + if(floor(wpos.y/2) != floor(wpos.y)/2) temp.rgb *= uIntensity; + return temp; +} diff --git a/output/Shaders/BizHawk/BizScanlines.cgp b/output/Shaders/BizHawk/BizScanlines.cgp index fe50cf6252..3bb5dd154f 100644 --- a/output/Shaders/BizHawk/BizScanlines.cgp +++ b/output/Shaders/BizHawk/BizScanlines.cgp @@ -1,4 +1,4 @@ shaders = 1 -shader0 = BizScanlines.glsl +shader0 = BizScanlines.cg scale0 = 2 diff --git a/output/Shaders/BizHawk/hq2x.cg b/output/Shaders/BizHawk/hq2x.cg index a94176ca2f..15aaeca880 100644 --- a/output/Shaders/BizHawk/hq2x.cg +++ b/output/Shaders/BizHawk/hq2x.cg @@ -1,14 +1,14 @@ struct tex_coords { - float2 c00; - float2 c01; - float2 c02; - float2 c10; - float2 c11; - float2 c12; - float2 c20; - float2 c21; - float2 c22; + float2 c00 : TEXCOORD0; + float2 c01 : TEXCOORD1; + float2 c02 : TEXCOORD2; + float2 c10 : TEXCOORD3; + float2 c11 : TEXCOORD4; + float2 c12 : TEXCOORD5; + float2 c20 : TEXCOORD6; + float2 c21 : TEXCOORD7; + float2 c22 : COLOR0; }; struct input @@ -24,9 +24,6 @@ void main_vertex out float4 oPosition : POSITION, uniform float4x4 modelViewProj, - float4 color : COLOR, - out float4 oColor : COLOR, - float2 tex : TEXCOORD, uniform input IN, @@ -34,7 +31,6 @@ void main_vertex ) { oPosition = mul(modelViewProj, position); - oColor = color; float2 texsize = IN.texture_size; float2 delta = 0.5 / texsize; @@ -60,17 +56,17 @@ const float max_w = 0.25; // max filter weigth const float min_w = -0.05; // min filter weigth const float lum_add = 0.25; // effects smoothing -float4 main_fragment (in tex_coords co, uniform sampler2D s0 : TEXUNIT0) : COLOR +float4 main_fragment (in tex_coords co, uniform sampler2D s_p : TEXUNIT0) : COLOR { - float3 c00 = tex2D(s0, co.c00).xyz; - float3 c01 = tex2D(s0, co.c01).xyz; - float3 c02 = tex2D(s0, co.c02).xyz; - float3 c10 = tex2D(s0, co.c10).xyz; - float3 c11 = tex2D(s0, co.c11).xyz; - float3 c12 = tex2D(s0, co.c12).xyz; - float3 c20 = tex2D(s0, co.c20).xyz; - float3 c21 = tex2D(s0, co.c21).xyz; - float3 c22 = tex2D(s0, co.c22).xyz; + float3 c00 = tex2D(s_p, co.c00).xyz; + float3 c01 = tex2D(s_p, co.c01).xyz; + float3 c02 = tex2D(s_p, co.c02).xyz; + float3 c10 = tex2D(s_p, co.c10).xyz; + float3 c11 = tex2D(s_p, co.c11).xyz; + float3 c12 = tex2D(s_p, co.c12).xyz; + float3 c20 = tex2D(s_p, co.c20).xyz; + float3 c21 = tex2D(s_p, co.c21).xyz; + float3 c22 = tex2D(s_p, co.c22).xyz; float3 dt = float3(1.0); float md1 = dot(abs(c00 - c22), dt); diff --git a/output/Shaders/BizHawk/hq2x.cgp b/output/Shaders/BizHawk/hq2x.cgp index 658d55b50d..afdb999e90 100644 --- a/output/Shaders/BizHawk/hq2x.cgp +++ b/output/Shaders/BizHawk/hq2x.cgp @@ -1,4 +1,4 @@ shaders = 1 -shader0 = hq2x.glsl +shader0 = hq2x.cg scale0 = 2