diff --git a/Data/Sys/Shaders/16bit.glsl b/Data/Sys/Shaders/16bit.glsl
index edff1d5e3c..fd13d3469e 100644
--- a/Data/Sys/Shaders/16bit.glsl
+++ b/Data/Sys/Shaders/16bit.glsl
@@ -1,10 +1,3 @@
-SAMPLER_BINDING(9) uniform sampler2D samp9;
-
-out vec4 ocol0;
-in vec2 uv0;
-
-uniform vec4 resolution;
-
void main()
{
//Change this number to increase the pixel size.
@@ -14,9 +7,9 @@ void main()
float green = 0.0;
float blue = 0.0;
- vec2 pos = floor(uv0 * resolution.xy / pixelSize) * pixelSize * resolution.zw;
+ float2 pos = floor(GetCoordinates() * GetResolution() / pixelSize) * pixelSize * GetInvResolution();
- vec4 c0 = texture(samp9, pos);
+ float4 c0 = SampleLocation(pos);
if (c0.r < 0.1)
red = 0.1;
@@ -57,5 +50,5 @@ void main()
else
green = 1.0;
- ocol0 = vec4(red, green, blue, c0.a);
+ SetOutput(float4(red, green, blue, c0.a));
}
diff --git a/Data/Sys/Shaders/32bit.glsl b/Data/Sys/Shaders/32bit.glsl
index ed8fb890c5..d0e43db2ce 100644
--- a/Data/Sys/Shaders/32bit.glsl
+++ b/Data/Sys/Shaders/32bit.glsl
@@ -1,10 +1,3 @@
-SAMPLER_BINDING(9) uniform sampler2D samp9;
-
-out vec4 ocol0;
-in vec2 uv0;
-
-uniform vec4 resolution;
-
void main()
{
//Change this number to increase the pixel size.
@@ -14,9 +7,9 @@ void main()
float green = 0.0;
float blue = 0.0;
- vec2 pos = floor(uv0 * resolution.xy / pixelSize) * pixelSize * resolution.zw;
+ float2 pos = floor(GetCoordinates() * GetResolution() / pixelSize) * pixelSize * GetInvResolution();
- vec4 c0 = texture(samp9, pos);
+ float4 c0 = SampleLocation(pos);
if (c0.r < 0.06)
red = 0.06;
@@ -82,5 +75,5 @@ void main()
else
green = 1.0;
- ocol0 = vec4(red, green, blue, c0.a);
+ SetOutput(float4(red, green, blue, c0.a));
}
diff --git a/Data/Sys/Shaders/FXAA.glsl b/Data/Sys/Shaders/FXAA.glsl
index 60d072cdaa..897bd30e62 100644
--- a/Data/Sys/Shaders/FXAA.glsl
+++ b/Data/Sys/Shaders/FXAA.glsl
@@ -12,26 +12,20 @@
// 0. You just DO WHAT THE FUCK YOU WANT TO.
-SAMPLER_BINDING(9) uniform sampler2D samp9;
-
-out vec4 ocol0;
-in vec2 uv0;
-
-uniform vec4 resolution;
#define FXAA_REDUCE_MIN (1.0/ 128.0)
#define FXAA_REDUCE_MUL (1.0 / 8.0)
#define FXAA_SPAN_MAX 8.0
-
-vec4 applyFXAA(vec2 fragCoord, sampler2D tex)
+
+float4 applyFXAA(float2 fragCoord)
{
- vec4 color;
- vec2 inverseVP = resolution.zw;
- vec3 rgbNW = texture(tex, (fragCoord + vec2(-1.0, -1.0)) * inverseVP).xyz;
- vec3 rgbNE = texture(tex, (fragCoord + vec2(1.0, -1.0)) * inverseVP).xyz;
- vec3 rgbSW = texture(tex, (fragCoord + vec2(-1.0, 1.0)) * inverseVP).xyz;
- vec3 rgbSE = texture(tex, (fragCoord + vec2(1.0, 1.0)) * inverseVP).xyz;
- vec3 rgbM = texture(tex, fragCoord * inverseVP).xyz;
- vec3 luma = vec3(0.299, 0.587, 0.114);
+ float4 color;
+ float2 inverseVP = GetInvResolution();
+ float3 rgbNW = SampleLocation((fragCoord + float2(-1.0, -1.0)) * inverseVP).xyz;
+ float3 rgbNE = SampleLocation((fragCoord + float2(1.0, -1.0)) * inverseVP).xyz;
+ float3 rgbSW = SampleLocation((fragCoord + float2(-1.0, 1.0)) * inverseVP).xyz;
+ float3 rgbSE = SampleLocation((fragCoord + float2(1.0, 1.0)) * inverseVP).xyz;
+ float3 rgbM = SampleLocation(fragCoord * inverseVP).xyz;
+ float3 luma = float3(0.299, 0.587, 0.114);
float lumaNW = dot(rgbNW, luma);
float lumaNE = dot(rgbNE, luma);
float lumaSW = dot(rgbSW, luma);
@@ -39,8 +33,8 @@ vec4 applyFXAA(vec2 fragCoord, sampler2D tex)
float lumaM = dot(rgbM, luma);
float lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE)));
float lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE)));
-
- vec2 dir;
+
+ float2 dir;
dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));
dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE));
@@ -48,26 +42,26 @@ vec4 applyFXAA(vec2 fragCoord, sampler2D tex)
(0.25 * FXAA_REDUCE_MUL), FXAA_REDUCE_MIN);
float rcpDirMin = 1.0 / (min(abs(dir.x), abs(dir.y)) + dirReduce);
- dir = min(vec2(FXAA_SPAN_MAX, FXAA_SPAN_MAX),
- max(vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX),
+ dir = min(float2(FXAA_SPAN_MAX, FXAA_SPAN_MAX),
+ max(float2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX),
dir * rcpDirMin)) * inverseVP;
- vec3 rgbA = 0.5 * (
- texture(tex, fragCoord * inverseVP + dir * (1.0 / 3.0 - 0.5)).xyz +
- texture(tex, fragCoord * inverseVP + dir * (2.0 / 3.0 - 0.5)).xyz);
- vec3 rgbB = rgbA * 0.5 + 0.25 * (
- texture(tex, fragCoord * inverseVP + dir * -0.5).xyz +
- texture(tex, fragCoord * inverseVP + dir * 0.5).xyz);
-
+ float3 rgbA = 0.5 * (
+ SampleLocation(fragCoord * inverseVP + dir * (1.0 / 3.0 - 0.5)).xyz +
+ SampleLocation(fragCoord * inverseVP + dir * (2.0 / 3.0 - 0.5)).xyz);
+ float3 rgbB = rgbA * 0.5 + 0.25 * (
+ SampleLocation(fragCoord * inverseVP + dir * -0.5).xyz +
+ SampleLocation(fragCoord * inverseVP + dir * 0.5).xyz);
+
float lumaB = dot(rgbB, luma);
if ((lumaB < lumaMin) || (lumaB > lumaMax))
- color = vec4(rgbA, 1.0);
+ color = float4(rgbA, 1.0);
else
- color = vec4(rgbB, 1.0);
+ color = float4(rgbB, 1.0);
return color;
}
void main()
{
- ocol0 = applyFXAA(uv0 * resolution.xy, samp9);
+ SetOutput(applyFXAA(GetCoordinates() * GetResolution()));
}
diff --git a/Data/Sys/Shaders/README.txt b/Data/Sys/Shaders/README.txt
deleted file mode 100644
index acb7d22615..0000000000
--- a/Data/Sys/Shaders/README.txt
+++ /dev/null
@@ -1,18 +0,0 @@
-//dummy shader:
-SAMPLER_BINDING(9) uniform sampler2D samp9;
-
-out vec4 ocol0;
-in vec2 uv0;
-
-void main()
-{
- ocol0 = texture(samp9, uv0);
-}
-
-/*
-And now that's over with, the contents of this readme file!
-For best results, turn Wordwrap formatting on...
-The shaders shown in the dropdown box in the video plugin configuration window are kept in the directory named User/Data/Shaders. They are linked in to the dolphin source from the repository at . See for more details on the way shaders work.
-
-This file will hopefully hold more content in future...
-*/
diff --git a/Data/Sys/Shaders/acidmetal.glsl b/Data/Sys/Shaders/acidmetal.glsl
index 6e976f0093..6ea8891f6a 100644
--- a/Data/Sys/Shaders/acidmetal.glsl
+++ b/Data/Sys/Shaders/acidmetal.glsl
@@ -1,11 +1,6 @@
-SAMPLER_BINDING(9) uniform sampler2D samp9;
-
-out vec4 ocol0;
-in vec2 uv0;
-
void main()
{
- vec4 c0 = texture(samp9, uv0);
+ float4 c0 = Sample();
float red = 0.0;
float blue = 0.0;
@@ -17,5 +12,5 @@ void main()
float green = max(c0.r + c0.b, c0.g);
- ocol0 = vec4(red, green, blue, 1.0);
+ SetOutput(float4(red, green, blue, 1.0));
}
diff --git a/Data/Sys/Shaders/acidtrip.glsl b/Data/Sys/Shaders/acidtrip.glsl
index 172e281b52..8722e621f1 100644
--- a/Data/Sys/Shaders/acidtrip.glsl
+++ b/Data/Sys/Shaders/acidtrip.glsl
@@ -1,11 +1,4 @@
-SAMPLER_BINDING(9) uniform sampler2D samp9;
-
-out vec4 ocol0;
-in vec2 uv0;
-
-uniform vec4 resolution;
-
void main()
{
- ocol0 = (texture(samp9, uv0+resolution.zw) - texture(samp9, uv0-resolution.zw)) * 8.0;
+ SetOutput((SampleOffset(int2(1, 1)) - SampleOffset(int2(-1, -1))) * 8.0);
}
diff --git a/Data/Sys/Shaders/acidtrip2.glsl b/Data/Sys/Shaders/acidtrip2.glsl
index 332de035f6..054fe17173 100644
--- a/Data/Sys/Shaders/acidtrip2.glsl
+++ b/Data/Sys/Shaders/acidtrip2.glsl
@@ -1,13 +1,6 @@
-SAMPLER_BINDING(9) uniform sampler2D samp9;
-
-out vec4 ocol0;
-in vec2 uv0;
-
-uniform vec4 resolution;
-
void main()
{
- vec4 a = texture(samp9, uv0+resolution.zw);
- vec4 b = texture(samp9, uv0-resolution.zw);
- ocol0 = ( a*a*1.3 - b ) * 8.0;
+ float4 a = SampleOffset(int2( 1, 1));
+ float4 b = SampleOffset(int2(-1, -1));
+ SetOutput(( a*a*1.3 - b ) * 8.0);
}
diff --git a/Data/Sys/Shaders/asciiart.glsl b/Data/Sys/Shaders/asciiart.glsl
index 089d216839..52fec3da6d 100644
--- a/Data/Sys/Shaders/asciiart.glsl
+++ b/Data/Sys/Shaders/asciiart.glsl
@@ -1,48 +1,39 @@
-// textures
-SAMPLER_BINDING(8) uniform sampler2D samp8;
-SAMPLER_BINDING(9) uniform sampler2D samp9;
-
const int char_width = 8;
const int char_height = 13;
const int char_count = 95;
const int char_pixels = char_width*char_height;
-const vec2 char_dim = vec2(char_width, char_height);
-const vec2 font_scale = vec2(1.0/float(char_width)/float(char_count), 1.0/float(char_height));
-
-out vec4 ocol0;
-in vec2 uv0;
-
-uniform vec4 resolution;
+const float2 char_dim = float2(char_width, char_height);
+const float2 font_scale = float2(1.0/float(char_width)/float(char_count), 1.0/float(char_height));
void main()
{
- vec2 char_pos = floor(uv0*resolution.xy/char_dim);
- vec2 pixel_offset = floor(uv0*resolution.xy) - char_pos*char_dim;
+ float2 char_pos = floor(GetCoordinates()*GetResolution()/char_dim);
+ float2 pixel_offset = floor(GetCoordinates()*GetResolution()) - char_pos*char_dim;
// just a big number
float mindiff = float(char_width*char_height) * 100.0;
float minc = 0.0;
- vec4 mina = vec4(0.0, 0.0, 0.0, 0.0);
- vec4 minb = vec4(0.0, 0.0, 0.0, 0.0);
+ float4 mina = float4(0.0, 0.0, 0.0, 0.0);
+ float4 minb = float4(0.0, 0.0, 0.0, 0.0);
for (int i=0; i 0.9)
green = c0.r / 3.0;
- ocol0 = vec4(red, green, blue, 1.0);
+ SetOutput(float4(red, green, blue, 1.0));
}
diff --git a/Data/Sys/Shaders/fire2.glsl b/Data/Sys/Shaders/fire2.glsl
index 2ca04ec529..4b116f9871 100644
--- a/Data/Sys/Shaders/fire2.glsl
+++ b/Data/Sys/Shaders/fire2.glsl
@@ -1,11 +1,6 @@
-SAMPLER_BINDING(9) uniform sampler2D samp9;
-
-out vec4 ocol0;
-in vec2 uv0;
-
void main()
{
- vec4 c0 = texture(samp9, uv0);
+ float4 c0 = Sample();
float red = 0.0;
float green = 0.0;
float blue = 0.0;
@@ -14,5 +9,5 @@ void main()
red = c0.r + (c0.g / 2.0) + (c0.b / 3.0);
green = c0.r / 3.0;
- ocol0 = vec4(red, green, blue, 1.0);
+ SetOutput(float4(red, green, blue, 1.0));
}
diff --git a/Data/Sys/Shaders/firewater.glsl b/Data/Sys/Shaders/firewater.glsl
index 20cf927bc9..32b9be3d5d 100644
--- a/Data/Sys/Shaders/firewater.glsl
+++ b/Data/Sys/Shaders/firewater.glsl
@@ -1,15 +1,8 @@
-SAMPLER_BINDING(9) uniform sampler2D samp9;
-
-out vec4 ocol0;
-in vec2 uv0;
-
-uniform vec4 resolution;
-
void main()
{
- float4 c0 = texture(samp9, uv0);
- float4 c1 = texture(samp9, uv0 + float2(1,1)*resolution.zw);
- float4 c2 = texture(samp9, uv0 + float2(-1,-1)*resolution.zw);
+ float4 c0 = Sample();
+ float4 c1 = SampleOffset(int2( 1, 1));
+ float4 c2 = SampleOffset(int2(-1, -1));
float red = c0.r;
float green = c0.g;
float blue = c0.b;
@@ -18,5 +11,5 @@ void main()
red = c0.r - c1.b;
blue = c0.b - c2.r + (c0.g - c0.r);
- ocol0 = float4(red, 0.0, blue, alpha);
+ SetOutput(float4(red, 0.0, blue, alpha));
}
diff --git a/Data/Sys/Shaders/grayscale.glsl b/Data/Sys/Shaders/grayscale.glsl
index 1c3658f00f..a7a211ce4a 100644
--- a/Data/Sys/Shaders/grayscale.glsl
+++ b/Data/Sys/Shaders/grayscale.glsl
@@ -1,11 +1,6 @@
-SAMPLER_BINDING(9) uniform sampler2D samp9;
-
-out vec4 ocol0;
-in vec2 uv0;
-
void main()
{
- vec4 c0 = texture(samp9, uv0);
+ float4 c0 = Sample();
float avg = (c0.r + c0.g + c0.b) / 3.0;
- ocol0 = vec4(avg, avg, avg, c0.a);
+ SetOutput(float4(avg, avg, avg, c0.a));
}
diff --git a/Data/Sys/Shaders/grayscale2.glsl b/Data/Sys/Shaders/grayscale2.glsl
index 7e8f09e064..98cb1f8838 100644
--- a/Data/Sys/Shaders/grayscale2.glsl
+++ b/Data/Sys/Shaders/grayscale2.glsl
@@ -1,12 +1,7 @@
-SAMPLER_BINDING(9) uniform sampler2D samp9;
-
-out vec4 ocol0;
-in vec2 uv0;
-
void main()
{
- vec4 c0 = texture(samp9, uv0);
+ float4 c0 = Sample();
// Info: http://www.oreillynet.com/cs/user/view/cs_msg/8691
float avg = (0.222 * c0.r) + (0.707 * c0.g) + (0.071 * c0.b);
- ocol0 = vec4(avg, avg, avg, c0.a);
+ SetOutput(float4(avg, avg, avg, c0.a));
}
diff --git a/Data/Sys/Shaders/invert.glsl b/Data/Sys/Shaders/invert.glsl
index 01e840c6e6..46cf142c84 100644
--- a/Data/Sys/Shaders/invert.glsl
+++ b/Data/Sys/Shaders/invert.glsl
@@ -1,9 +1,4 @@
-SAMPLER_BINDING(9) uniform sampler2D samp9;
-
-out vec4 ocol0;
-in vec2 uv0;
-
void main()
{
- ocol0 = vec4(1.0, 1.0, 1.0, 1.0) - texture(samp9, uv0);
+ SetOutput(float4(1.0, 1.0, 1.0, 1.0) - Sample());
}
diff --git a/Data/Sys/Shaders/invert_blue.glsl b/Data/Sys/Shaders/invert_blue.glsl
index 081027ff75..75602ea2a6 100644
--- a/Data/Sys/Shaders/invert_blue.glsl
+++ b/Data/Sys/Shaders/invert_blue.glsl
@@ -1,9 +1,4 @@
-SAMPLER_BINDING(9) uniform sampler2D samp9;
-
-out vec4 ocol0;
-in vec2 uv0;
-
void main()
{
- ocol0 = vec4(0.0, 0.0, 0.7, 1.0) - texture(samp9, uv0);
+ SetOutput(float4(0.0, 0.0, 0.7, 1.0) - Sample());
}
diff --git a/Data/Sys/Shaders/invertedoutline.glsl b/Data/Sys/Shaders/invertedoutline.glsl
index b5b29731b9..fa1cb0f9bd 100644
--- a/Data/Sys/Shaders/invertedoutline.glsl
+++ b/Data/Sys/Shaders/invertedoutline.glsl
@@ -1,14 +1,7 @@
-SAMPLER_BINDING(9) uniform sampler2D samp9;
-
-out vec4 ocol0;
-in vec2 uv0;
-
-uniform vec4 resolution;
-
void main()
{
- float4 c0 = texture(samp9, uv0);
- float4 c1 = texture(samp9, uv0 + float2(5,5)*resolution.zw);
+ float4 c0 = Sample();
+ float4 c1 = SampleOffset(int2(5, 5));
- ocol0 = c0 - c1;
+ SetOutput(c0 - c1);
}
diff --git a/Data/Sys/Shaders/mad_world.glsl b/Data/Sys/Shaders/mad_world.glsl
index 1aff5223a2..8d596541a1 100644
--- a/Data/Sys/Shaders/mad_world.glsl
+++ b/Data/Sys/Shaders/mad_world.glsl
@@ -1,26 +1,19 @@
-SAMPLER_BINDING(9) uniform sampler2D samp9;
-
-out vec4 ocol0;
-in vec2 uv0;
-
-uniform vec4 resolution;
-
void main()
{
- float4 emboss = (texture(samp9, uv0+resolution.zw) - texture(samp9, uv0-resolution.zw))*2.0;
- emboss -= (texture(samp9, uv0+float2(1,-1)*resolution.zw).rgba - texture(samp9, uv0+float2(-1,1)*resolution.zw).rgba);
- float4 color = texture(samp9, uv0).rgba;
+ float4 emboss = (SampleLocation(GetCoordinates()+GetInvResolution()) - SampleLocation(GetCoordinates()-GetInvResolution()))*2.0;
+ emboss -= (SampleLocation(GetCoordinates()+float2(1,-1)*GetInvResolution()).rgba - SampleLocation(GetCoordinates()+float2(-1,1)*GetInvResolution()).rgba);
+ float4 color = Sample();
if (color.r > 0.8 && color.b + color.b < 0.2)
{
- ocol0 = float4(1,0,0,0);
+ SetOutput(float4(1,0,0,0));
}
else
{
color += emboss;
if (dot(color.rgb, float3(0.3, 0.5, 0.2)) > 0.5)
- ocol0 = float4(1,1,1,1);
+ SetOutput(float4(1,1,1,1));
else
- ocol0 = float4(0,0,0,0);
+ SetOutput(float4(0,0,0,0));
}
}
diff --git a/Data/Sys/Shaders/nightvision.glsl b/Data/Sys/Shaders/nightvision.glsl
index 0756b81812..9039b4bbdb 100644
--- a/Data/Sys/Shaders/nightvision.glsl
+++ b/Data/Sys/Shaders/nightvision.glsl
@@ -1,15 +1,10 @@
-SAMPLER_BINDING(9) uniform sampler2D samp9;
-
-out vec4 ocol0;
-in vec2 uv0;
-
void main()
{
- float4 c0 = texture(samp9, uv0).rgba;
+ float4 c0 = Sample();
float green = c0.g;
if (c0.g < 0.50)
green = c0.r + c0.b;
- ocol0 = float4(0.0, green, 0.0, 1.0);
+ SetOutput(float4(0.0, green, 0.0, 1.0));
}
diff --git a/Data/Sys/Shaders/nightvision2.glsl b/Data/Sys/Shaders/nightvision2.glsl
index cec3e82d72..c3e6a25462 100644
--- a/Data/Sys/Shaders/nightvision2.glsl
+++ b/Data/Sys/Shaders/nightvision2.glsl
@@ -1,27 +1,20 @@
-SAMPLER_BINDING(9) uniform sampler2D samp9;
-
-out vec4 ocol0;
-in vec2 uv0;
-
-uniform vec4 resolution;
-
void main()
{
//variables
float internalresolution = 1278.0;
- float4 c0 = texture(samp9, uv0).rgba;
+ float4 c0 = Sample();
//blur
float4 blurtotal = float4(0.0, 0.0, 0.0, 0.0);
float blursize = 1.5;
- blurtotal += texture(samp9, uv0 + float2(-blursize, -blursize) * resolution.zw);
- blurtotal += texture(samp9, uv0 + float2(-blursize, blursize) * resolution.zw);
- blurtotal += texture(samp9, uv0 + float2( blursize, -blursize) * resolution.zw);
- blurtotal += texture(samp9, uv0 + float2( blursize, blursize) * resolution.zw);
- blurtotal += texture(samp9, uv0 + float2(-blursize, 0.0) * resolution.zw);
- blurtotal += texture(samp9, uv0 + float2( blursize, 0.0) * resolution.zw);
- blurtotal += texture(samp9, uv0 + float2( 0.0, -blursize) * resolution.zw);
- blurtotal += texture(samp9, uv0 + float2( 0.0, blursize) * resolution.zw);
+ blurtotal += SampleLocation(GetCoordinates() + float2(-blursize, -blursize) * GetInvResolution());
+ blurtotal += SampleLocation(GetCoordinates() + float2(-blursize, blursize) * GetInvResolution());
+ blurtotal += SampleLocation(GetCoordinates() + float2( blursize, -blursize) * GetInvResolution());
+ blurtotal += SampleLocation(GetCoordinates() + float2( blursize, blursize) * GetInvResolution());
+ blurtotal += SampleLocation(GetCoordinates() + float2(-blursize, 0.0) * GetInvResolution());
+ blurtotal += SampleLocation(GetCoordinates() + float2( blursize, 0.0) * GetInvResolution());
+ blurtotal += SampleLocation(GetCoordinates() + float2( 0.0, -blursize) * GetInvResolution());
+ blurtotal += SampleLocation(GetCoordinates() + float2( 0.0, blursize) * GetInvResolution());
blurtotal *= 0.125;
c0 = blurtotal;
@@ -32,8 +25,8 @@ void main()
grey = grey * 0.5 + 0.7;
// darken edges
- float x = uv0.x * resolution.x;
- float y = uv0.y * resolution.y;
+ float x = GetCoordinates().x * GetResolution().x;
+ float y = GetCoordinates().y * GetResolution().y;
if (x > internalresolution/2.0)
x = internalresolution-x;
if (y > internalresolution/2.0)
@@ -65,5 +58,5 @@ void main()
grey -= y / 200.0;
// output
- ocol0 = float4(0.0, grey, 0.0, 1.0);
+ SetOutput(float4(0.0, grey, 0.0, 1.0));
}
diff --git a/Data/Sys/Shaders/nightvision2scanlines.glsl b/Data/Sys/Shaders/nightvision2scanlines.glsl
index 7006429314..d2f7eda2ea 100644
--- a/Data/Sys/Shaders/nightvision2scanlines.glsl
+++ b/Data/Sys/Shaders/nightvision2scanlines.glsl
@@ -1,27 +1,20 @@
-SAMPLER_BINDING(9) uniform sampler2D samp9;
-
-out vec4 ocol0;
-in vec2 uv0;
-
-uniform vec4 resolution;
-
void main()
{
//variables
float internalresolution = 1278.0;
- float4 c0 = texture(samp9, uv0).rgba;
+ float4 c0 = Sample();
//blur
float4 blurtotal = float4(0.0, 0.0, 0.0, 0.0);
float blursize = 1.5;
- blurtotal += texture(samp9, uv0 + float2(-blursize, -blursize)*resolution.zw);
- blurtotal += texture(samp9, uv0 + float2(-blursize, blursize)*resolution.zw);
- blurtotal += texture(samp9, uv0 + float2( blursize, -blursize)*resolution.zw);
- blurtotal += texture(samp9, uv0 + float2( blursize, blursize)*resolution.zw);
- blurtotal += texture(samp9, uv0 + float2(-blursize, 0.0)*resolution.zw);
- blurtotal += texture(samp9, uv0 + float2( blursize, 0.0)*resolution.zw);
- blurtotal += texture(samp9, uv0 + float2( 0.0, -blursize)*resolution.zw);
- blurtotal += texture(samp9, uv0 + float2( 0.0, blursize)*resolution.zw);
+ blurtotal += SampleLocation(GetCoordinates() + float2(-blursize, -blursize)*GetInvResolution());
+ blurtotal += SampleLocation(GetCoordinates() + float2(-blursize, blursize)*GetInvResolution());
+ blurtotal += SampleLocation(GetCoordinates() + float2( blursize, -blursize)*GetInvResolution());
+ blurtotal += SampleLocation(GetCoordinates() + float2( blursize, blursize)*GetInvResolution());
+ blurtotal += SampleLocation(GetCoordinates() + float2(-blursize, 0.0)*GetInvResolution());
+ blurtotal += SampleLocation(GetCoordinates() + float2( blursize, 0.0)*GetInvResolution());
+ blurtotal += SampleLocation(GetCoordinates() + float2( 0.0, -blursize)*GetInvResolution());
+ blurtotal += SampleLocation(GetCoordinates() + float2( 0.0, blursize)*GetInvResolution());
blurtotal *= 0.125;
c0 = blurtotal;
@@ -31,14 +24,14 @@ void main()
// brighten and apply horizontal scanlines
// This would have been much simpler if I could get the stupid modulo (%) to work
// If anyone who is more well versed in Cg knows how to do this it'd be slightly more efficient
- // float lineIntensity = ((uv0[1] % 9) - 4) / 40;
- float vPos = uv0.y*resolution.y / 9.0;
+ // float lineIntensity = ((GetCoordinates()[1] % 9) - 4) / 40;
+ float vPos = GetCoordinates().y*GetResolution().y / 9.0;
float lineIntensity = (((vPos - floor(vPos)) * 9.0) - 4.0) / 40.0;
grey = grey * 0.5 + 0.7 + lineIntensity;
// darken edges
- float x = uv0.x * resolution.x;
- float y = uv0.y * resolution.y;
+ float x = GetCoordinates().x * GetResolution().x;
+ float y = GetCoordinates().y * GetResolution().y;
if (x > internalresolution/2.0)
x = internalresolution-x;
@@ -74,5 +67,5 @@ void main()
grey -= y / 200.0;
// output
- ocol0 = float4(0.0, grey, 0.0, 1.0);
+ SetOutput(float4(0.0, grey, 0.0, 1.0));
}
diff --git a/Data/Sys/Shaders/posterize.glsl b/Data/Sys/Shaders/posterize.glsl
index 6b41c8332f..dba7e59ee3 100644
--- a/Data/Sys/Shaders/posterize.glsl
+++ b/Data/Sys/Shaders/posterize.glsl
@@ -1,11 +1,6 @@
-SAMPLER_BINDING(9) uniform sampler2D samp9;
-
-out vec4 ocol0;
-in vec2 uv0;
-
void main()
{
- float4 c0 = texture(samp9, uv0).rgba;
+ float4 c0 = Sample();
float red = 0.0;
float green = 0.0;
float blue = 0.0;
@@ -19,5 +14,5 @@ void main()
if (c0.b > 0.25)
blue = c0.b;
- ocol0 = float4(red, green, blue, 1.0);
+ SetOutput(float4(red, green, blue, 1.0));
}
diff --git a/Data/Sys/Shaders/posterize2.glsl b/Data/Sys/Shaders/posterize2.glsl
index 782bf32d9d..2000b0f726 100644
--- a/Data/Sys/Shaders/posterize2.glsl
+++ b/Data/Sys/Shaders/posterize2.glsl
@@ -1,8 +1,3 @@
-SAMPLER_BINDING(9) uniform sampler2D samp9;
-
-out vec4 ocol0;
-in vec2 uv0;
-
float bound(float color)
{
if (color < 0.35)
@@ -18,6 +13,6 @@ float bound(float color)
void main()
{
- float4 c0 = texture(samp9, uv0);
- ocol0 = float4(bound(c0.r), bound(c0.g), bound(c0.b), c0.a);
+ float4 c0 = Sample();
+ SetOutput(float4(bound(c0.r), bound(c0.g), bound(c0.b), c0.a));
}
diff --git a/Data/Sys/Shaders/primarycolors.glsl b/Data/Sys/Shaders/primarycolors.glsl
index ee62fc46f5..fb82fd4236 100644
--- a/Data/Sys/Shaders/primarycolors.glsl
+++ b/Data/Sys/Shaders/primarycolors.glsl
@@ -1,11 +1,6 @@
-SAMPLER_BINDING(9) uniform sampler2D samp9;
-
-out vec4 ocol0;
-in vec2 uv0;
-
void main()
{
- vec4 c0 = texture(samp9, uv0);
+ float4 c0 = Sample();
float red = c0.r;
float blue = c0.b;
float green = c0.g;
@@ -78,5 +73,5 @@ void main()
green = 0.05;
}
}
- ocol0 = vec4(red, green, blue, c0.a);
+ SetOutput(float4(red, green, blue, c0.a));
}
diff --git a/Data/Sys/Shaders/sepia.glsl b/Data/Sys/Shaders/sepia.glsl
index 77d2414908..55985553f6 100644
--- a/Data/Sys/Shaders/sepia.glsl
+++ b/Data/Sys/Shaders/sepia.glsl
@@ -1,11 +1,6 @@
-SAMPLER_BINDING(9) uniform sampler2D samp9;
-
-out vec4 ocol0;
-in vec2 uv0;
-
void main()
{
- vec4 c0 = texture(samp9, uv0);
+ float4 c0 = Sample();
// Same coefficients as grayscale2 at this point
float avg = (0.222 * c0.r) + (0.707 * c0.g) + (0.071 * c0.b);
@@ -14,5 +9,5 @@ void main()
// Not sure about these coefficients, they just seem to produce the proper yellow
float green=avg*.75;
float blue=avg*.5;
- ocol0 = vec4(red, green, blue, c0.a);
+ SetOutput(float4(red, green, blue, c0.a));
}
diff --git a/Data/Sys/Shaders/sketchy.glsl b/Data/Sys/Shaders/sketchy.glsl
index 024593f719..fd6f5832bd 100644
--- a/Data/Sys/Shaders/sketchy.glsl
+++ b/Data/Sys/Shaders/sketchy.glsl
@@ -1,24 +1,17 @@
-SAMPLER_BINDING(9) uniform sampler2D samp9;
-
-out vec4 ocol0;
-in vec2 uv0;
-
-uniform vec4 resolution;
-
void main()
{
- float4 c0 = texture(samp9, uv0).rgba;
+ float4 c0 = Sample();
float4 tmp = float4(0.0, 0.0, 0.0, 0.0);
- tmp += c0 - texture(samp9, uv0 + float2(2.0, 2.0)*resolution.zw).rgba;
- tmp += c0 - texture(samp9, uv0 - float2(2.0, 2.0)*resolution.zw).rgba;
- tmp += c0 - texture(samp9, uv0 + float2(2.0, -2.0)*resolution.zw).rgba;
- tmp += c0 - texture(samp9, uv0 - float2(2.0, -2.0)*resolution.zw).rgba;
+ tmp += c0 - SampleOffset(int2( 2, 2));
+ tmp += c0 - SampleOffset(int2(-2, -2));
+ tmp += c0 - SampleOffset(int2( 2, -2));
+ tmp += c0 - SampleOffset(int2(-2, 2));
float grey = ((0.222 * tmp.r) + (0.707 * tmp.g) + (0.071 * tmp.b));
// get rid of the bottom line, as it is incorrect.
- if (uv0.y*resolution.y < 163.0)
+ if (GetCoordinates().y*GetResolution().y < 163.0)
tmp = float4(1.0, 1.0, 1.0, 1.0);
c0 = c0 + 1.0 - grey * 7.0;
- ocol0 = float4(c0.r, c0.g, c0.b, 1.0);
+ SetOutput(float4(c0.r, c0.g, c0.b, 1.0));
}
diff --git a/Data/Sys/Shaders/spookey1.glsl b/Data/Sys/Shaders/spookey1.glsl
index 249e2d06dc..9801dcf965 100644
--- a/Data/Sys/Shaders/spookey1.glsl
+++ b/Data/Sys/Shaders/spookey1.glsl
@@ -1,11 +1,6 @@
-SAMPLER_BINDING(9) uniform sampler2D samp9;
-
-out vec4 ocol0;
-in vec2 uv0;
-
void main()
{
- vec4 c0 = texture(samp9, uv0);
+ float4 c0 = Sample();
float red = 0.0;
float blue = 0.0;
@@ -19,5 +14,5 @@ void main()
blue = c0.r + c0.b;
}
- ocol0 = vec4(red, 0.0, blue, 1.0);
+ SetOutput(float4(red, 0.0, blue, 1.0));
}
diff --git a/Data/Sys/Shaders/spookey2.glsl b/Data/Sys/Shaders/spookey2.glsl
index 34299ccc1d..77a68ff168 100644
--- a/Data/Sys/Shaders/spookey2.glsl
+++ b/Data/Sys/Shaders/spookey2.glsl
@@ -1,11 +1,6 @@
-SAMPLER_BINDING(9) uniform sampler2D samp9;
-
-out vec4 ocol0;
-in vec2 uv0;
-
void main()
{
- vec4 c0 = texture(samp9, uv0);
+ float4 c0 = Sample();
float red = 0.0;
float green = 0.0;
float blue = 0.0;
@@ -21,5 +16,5 @@ void main()
green = c0.r + c0.b;
}
- ocol0 = vec4(red, green, blue, 1.0);
+ SetOutput(float4(red, green, blue, 1.0));
}
diff --git a/Data/Sys/Shaders/stereoscopic.glsl b/Data/Sys/Shaders/stereoscopic.glsl
index 7c97313c8f..0c49b55f32 100644
--- a/Data/Sys/Shaders/stereoscopic.glsl
+++ b/Data/Sys/Shaders/stereoscopic.glsl
@@ -1,31 +1,24 @@
// Omega's 3D Stereoscopic filtering
// TODO: Need depth info!
-SAMPLER_BINDING(9) uniform sampler2D samp9;
-
-out vec4 ocol0;
-in vec2 uv0;
-
-uniform vec4 resolution;
-
void main()
{
// Source Color
- float4 c0 = texture(samp9, uv0).rgba;
- float sep = 5.0;
- float red = c0.r;
- float green = c0.g;
- float blue = c0.b;
+ float4 c0 = Sample();
+ const int sep = 5;
+ float red = c0.r;
+ float green = c0.g;
+ float blue = c0.b;
// Left Eye (Red)
- float4 c1 = texture(samp9, uv0 + float2(sep,0.0)*resolution.zw).rgba;
+ float4 c1 = SampleOffset(int2(sep, 0));
red = max(c0.r, c1.r);
// Right Eye (Cyan)
- float4 c2 = texture(samp9, uv0 + float2(-sep,0.0)*resolution.zw).rgba;
+ float4 c2 = SampleOffset(int2(-sep, 0));
float cyan = (c2.g + c2.b) / 2.0;
green = max(c0.g, cyan);
blue = max(c0.b, cyan);
- ocol0 = float4(red, green, blue, c0.a);
+ SetOutput(float4(red, green, blue, c0.a));
}
diff --git a/Data/Sys/Shaders/stereoscopic2.glsl b/Data/Sys/Shaders/stereoscopic2.glsl
index 4fb8f5df11..1784a988bf 100644
--- a/Data/Sys/Shaders/stereoscopic2.glsl
+++ b/Data/Sys/Shaders/stereoscopic2.glsl
@@ -1,31 +1,24 @@
// Omega's 3D Stereoscopic filtering (Amber/Blue)
// TODO: Need depth info!
-SAMPLER_BINDING(9) uniform sampler2D samp9;
-
-out vec4 ocol0;
-in vec2 uv0;
-
-uniform vec4 resolution;
-
void main()
{
// Source Color
- float4 c0 = texture(samp9, uv0).rgba;
+ float4 c0 = Sample();
float sep = 5.0;
float red = c0.r;
float green = c0.g;
float blue = c0.b;
// Left Eye (Amber)
- float4 c2 = texture(samp9, uv0 + float2(sep,0.0)*resolution.zw).rgba;
+ float4 c2 = SampleLocation(GetCoordinates() + float2(sep,0.0)*GetInvResolution()).rgba;
float amber = (c2.r + c2.g) / 2.0;
red = max(c0.r, amber);
green = max(c0.g, amber);
// Right Eye (Blue)
- float4 c1 = texture(samp9, uv0 + float2(-sep,0.0)*resolution.zw).rgba;
+ float4 c1 = SampleLocation(GetCoordinates() + float2(-sep,0.0)*GetInvResolution()).rgba;
blue = max(c0.b, c1.b);
- ocol0 = float4(red, green, blue, c0.a);
+ SetOutput(float4(red, green, blue, c0.a));
}
diff --git a/Data/Sys/Shaders/sunset.glsl b/Data/Sys/Shaders/sunset.glsl
index b2a793c84d..000d32f7c6 100644
--- a/Data/Sys/Shaders/sunset.glsl
+++ b/Data/Sys/Shaders/sunset.glsl
@@ -1,10 +1,5 @@
-SAMPLER_BINDING(9) uniform sampler2D samp9;
-
-out vec4 ocol0;
-in vec2 uv0;
-
void main()
{
- vec4 c0 = texture(samp9, uv0);
- ocol0 = vec4(c0.r * 1.5, c0.g, c0.b * 0.5, c0.a);
+ float4 c0 = Sample();
+ SetOutput(float4(c0.r * 1.5, c0.g, c0.b * 0.5, c0.a));
}
diff --git a/Data/Sys/Shaders/swap_RGB_BGR.glsl b/Data/Sys/Shaders/swap_RGB_BGR.glsl
index 69c8461451..c71292f9e3 100644
--- a/Data/Sys/Shaders/swap_RGB_BGR.glsl
+++ b/Data/Sys/Shaders/swap_RGB_BGR.glsl
@@ -1,9 +1,4 @@
-SAMPLER_BINDING(9) uniform sampler2D samp9;
-
-out vec4 ocol0;
-in vec2 uv0;
-
void main()
{
- ocol0 = texture(samp9, uv0).bgra;
+ SetOutput(Sample().bgra);
}
diff --git a/Data/Sys/Shaders/swap_RGB_BRG.glsl b/Data/Sys/Shaders/swap_RGB_BRG.glsl
index a9ec859b9f..3b2738423f 100644
--- a/Data/Sys/Shaders/swap_RGB_BRG.glsl
+++ b/Data/Sys/Shaders/swap_RGB_BRG.glsl
@@ -1,9 +1,4 @@
-SAMPLER_BINDING(9) uniform sampler2D samp9;
-
-out vec4 ocol0;
-in vec2 uv0;
-
void main()
{
- ocol0 = texture(samp9, uv0).brga;
+ SetOutput(Sample().brga);
}
diff --git a/Data/Sys/Shaders/swap_RGB_GBR.glsl b/Data/Sys/Shaders/swap_RGB_GBR.glsl
index bde5b51766..5dc1951a6d 100644
--- a/Data/Sys/Shaders/swap_RGB_GBR.glsl
+++ b/Data/Sys/Shaders/swap_RGB_GBR.glsl
@@ -1,9 +1,4 @@
-SAMPLER_BINDING(9) uniform sampler2D samp9;
-
-out vec4 ocol0;
-in vec2 uv0;
-
void main()
{
- ocol0 = texture(samp9, uv0).gbra;
+ SetOutput(Sample());
}
diff --git a/Data/Sys/Shaders/swap_RGB_GRB.glsl b/Data/Sys/Shaders/swap_RGB_GRB.glsl
index 19cd3b0e41..5dc1951a6d 100644
--- a/Data/Sys/Shaders/swap_RGB_GRB.glsl
+++ b/Data/Sys/Shaders/swap_RGB_GRB.glsl
@@ -1,9 +1,4 @@
-SAMPLER_BINDING(9) uniform sampler2D samp9;
-
-out vec4 ocol0;
-in vec2 uv0;
-
void main()
{
- ocol0 = texture(samp9, uv0).grba;
+ SetOutput(Sample());
}
diff --git a/Data/Sys/Shaders/swap_RGB_RBG.glsl b/Data/Sys/Shaders/swap_RGB_RBG.glsl
index c003436fff..77cc11e0c6 100644
--- a/Data/Sys/Shaders/swap_RGB_RBG.glsl
+++ b/Data/Sys/Shaders/swap_RGB_RBG.glsl
@@ -1,9 +1,4 @@
-SAMPLER_BINDING(9) uniform sampler2D samp9;
-
-out vec4 ocol0;
-in vec2 uv0;
-
void main()
{
- ocol0 = texture(samp9, uv0).rbga;
+ SetOutput(Sample().rbga);
}
diff --git a/Data/Sys/Shaders/toxic.glsl b/Data/Sys/Shaders/toxic.glsl
index ab31e4c5f1..1aa38c5e07 100644
--- a/Data/Sys/Shaders/toxic.glsl
+++ b/Data/Sys/Shaders/toxic.glsl
@@ -1,11 +1,6 @@
-SAMPLER_BINDING(9) uniform sampler2D samp9;
-
-out vec4 ocol0;
-in vec2 uv0;
-
void main()
{
- vec4 c0 = texture(samp9, uv0);
+ float4 c0 = Sample();
float red = 0.0;
float green = 0.0;
float blue = 0.0;
@@ -21,5 +16,5 @@ void main()
green = c0.r + c0.b;
}
- ocol0 = vec4(red, green, blue, 1.0);
+ SetOutput(float4(red, green, blue, 1.0));
}
diff --git a/Source/Core/Common/IniFile.cpp b/Source/Core/Common/IniFile.cpp
index da9d99e250..f3ea5751ba 100644
--- a/Source/Core/Common/IniFile.cpp
+++ b/Source/Core/Common/IniFile.cpp
@@ -19,9 +19,7 @@
#include "Common/IniFile.h"
#include "Common/StringUtil.h"
-namespace {
-
-void ParseLine(const std::string& line, std::string* keyOut, std::string* valueOut)
+void IniFile::ParseLine(const std::string& line, std::string* keyOut, std::string* valueOut)
{
if (line[0] == '#')
return;
@@ -40,8 +38,6 @@ void ParseLine(const std::string& line, std::string* keyOut, std::string* valueO
}
}
-}
-
const std::string& IniFile::NULL_STRING = "";
void IniFile::Section::Set(const std::string& key, const std::string& newValue)
diff --git a/Source/Core/Common/IniFile.h b/Source/Core/Common/IniFile.h
index 3ff7e39794..1e62b5c7f7 100644
--- a/Source/Core/Common/IniFile.h
+++ b/Source/Core/Common/IniFile.h
@@ -116,6 +116,11 @@ public:
Section* GetOrCreateSection(const std::string& section);
+ // This function is related to parsing data from lines of INI files
+ // It's used outside of IniFile, which is why it is exposed publicly
+ // In particular it is used in PostProcessing for its configuration
+ static void ParseLine(const std::string& line, std::string* keyOut, std::string* valueOut);
+
private:
std::list sections;
diff --git a/Source/Core/Common/StringUtil.h b/Source/Core/Common/StringUtil.h
index 50d270e732..8e9e9315af 100644
--- a/Source/Core/Common/StringUtil.h
+++ b/Source/Core/Common/StringUtil.h
@@ -75,6 +75,23 @@ static bool TryParse(const std::string &str, N *const output)
return false;
}
+template
+bool TryParseVector(const std::string& str, std::vector* output, const char delimiter = ',')
+{
+ output->clear();
+ std::istringstream buffer(str);
+ std::string variable;
+
+ while (std::getline(buffer, variable, delimiter))
+ {
+ N tmp = 0;
+ if (!TryParse(variable, &tmp))
+ return false;
+ output->push_back(tmp);
+ }
+ return true;
+}
+
// TODO: kill this
bool AsciiToHex(const std::string& _szValue, u32& result);
diff --git a/Source/Core/DolphinWX/CMakeLists.txt b/Source/Core/DolphinWX/CMakeLists.txt
index 302a27df28..613041de50 100644
--- a/Source/Core/DolphinWX/CMakeLists.txt
+++ b/Source/Core/DolphinWX/CMakeLists.txt
@@ -62,6 +62,7 @@ set(GUI_SRCS
MemoryCards/WiiSaveCrypted.cpp
NetWindow.cpp
PatchAddEdit.cpp
+ PostProcessingConfigDiag.cpp
SoftwareVideoConfigDialog.cpp
TASInputDlg.cpp
VideoConfigDiag.cpp
diff --git a/Source/Core/DolphinWX/DolphinWX.vcxproj b/Source/Core/DolphinWX/DolphinWX.vcxproj
index e62e2f2e43..52a13521ce 100644
--- a/Source/Core/DolphinWX/DolphinWX.vcxproj
+++ b/Source/Core/DolphinWX/DolphinWX.vcxproj
@@ -97,6 +97,7 @@
+
@@ -144,6 +145,7 @@
+
@@ -228,4 +230,4 @@
-
\ No newline at end of file
+
diff --git a/Source/Core/DolphinWX/DolphinWX.vcxproj.filters b/Source/Core/DolphinWX/DolphinWX.vcxproj.filters
index b9910845a8..59be1c3188 100644
--- a/Source/Core/DolphinWX/DolphinWX.vcxproj.filters
+++ b/Source/Core/DolphinWX/DolphinWX.vcxproj.filters
@@ -93,6 +93,9 @@
GUI\Video
+
+ GUI\Video
+
GUI\Video
@@ -217,6 +220,9 @@
GUI\Video
+
+ GUI\Video
+
GUI\Video
@@ -296,4 +302,4 @@
Resources
-
\ No newline at end of file
+
diff --git a/Source/Core/DolphinWX/PostProcessingConfigDiag.cpp b/Source/Core/DolphinWX/PostProcessingConfigDiag.cpp
new file mode 100644
index 0000000000..031c19f19d
--- /dev/null
+++ b/Source/Core/DolphinWX/PostProcessingConfigDiag.cpp
@@ -0,0 +1,316 @@
+// Copyright 2013 Dolphin Emulator Project
+// Licensed under GPLv2
+// Refer to the license.txt file included.
+
+#include
+#include
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "Common/StringUtil.h"
+
+#include "DolphinWX/PostProcessingConfigDiag.h"
+
+#include "VideoCommon/RenderBase.h"
+
+PostProcessingConfigDiag::PostProcessingConfigDiag(wxWindow* parent, const std::string& shader)
+ : wxDialog(parent, -1,
+ wxString::Format(_("Post Processing Shader Configuration"))),
+ m_shader(shader)
+{
+ // Depending on if we are running already, either use the one from the videobackend
+ // or generate our own.
+ if (g_renderer && g_renderer->GetPostProcessor())
+ {
+ m_post_processor = g_renderer->GetPostProcessor()->GetConfig();
+ }
+ else
+ {
+ m_post_processor = new PostProcessingShaderConfiguration();
+ m_post_processor->LoadShader(m_shader);
+ }
+
+ // Create our UI classes
+ const PostProcessingShaderConfiguration::ConfigMap& config_map = m_post_processor->GetOptions();
+ for (const auto& it : config_map)
+ {
+ if (it.second.m_type == PostProcessingShaderConfiguration::ConfigurationOption::OptionType::OPTION_BOOL)
+ {
+ ConfigGrouping* group = new ConfigGrouping(ConfigGrouping::WidgetType::TYPE_TOGGLE,
+ it.second.m_gui_name, it.first, it.second.m_dependent_option,
+ &it.second);
+ m_config_map[it.first] = group;
+ }
+ else
+ {
+ ConfigGrouping* group = new ConfigGrouping(ConfigGrouping::WidgetType::TYPE_SLIDER,
+ it.second.m_gui_name, it.first, it.second.m_dependent_option,
+ &it.second);
+ m_config_map[it.first] = group;
+ }
+ }
+
+ // Arrange our vectors based on dependency
+ for (const auto& it : m_config_map)
+ {
+ const std::string parent_name = it.second->GetParent();
+ if (parent_name.size())
+ {
+ // Since it depends on a different object, push it to a parent's object
+ m_config_map[parent_name]->AddChild(m_config_map[it.first]);
+ }
+ else
+ {
+ // It doesn't have a child, just push it to the vector
+ m_config_groups.push_back(m_config_map[it.first]);
+ }
+ }
+
+ // Generate our UI
+ wxNotebook* const notebook = new wxNotebook(this, -1);
+ wxPanel* const page_general = new wxPanel(notebook, -1);
+ wxFlexGridSizer* const szr_general = new wxFlexGridSizer(2, 5, 5);
+
+ // Now let's actually populate our window with our information
+ bool add_general_page = false;
+ for (const auto& it : m_config_groups)
+ {
+ if (it->HasChildren())
+ {
+ // Options with children get their own tab
+ wxPanel* const page_option = new wxPanel(notebook, -1);
+ wxFlexGridSizer* const szr_option = new wxFlexGridSizer(2, 10, 5);
+ it->GenerateUI(this, page_option, szr_option);
+
+ // Add all the children
+ for (const auto& child : it->GetChildren())
+ {
+ child->GenerateUI(this, page_option, szr_option);
+ }
+ page_option->SetSizerAndFit(szr_option);
+ notebook->AddPage(page_option, _(it->GetGUIName()));
+ }
+ else
+ {
+ // Options with no children go in to the general tab
+ if (!add_general_page)
+ {
+ // Make it so it doesn't show up if there aren't any options without children.
+ add_general_page = true;
+ }
+ it->GenerateUI(this, page_general, szr_general);
+ }
+ }
+
+ if (add_general_page)
+ {
+ page_general->SetSizerAndFit(szr_general);
+ notebook->InsertPage(0, page_general, _("General"));
+ }
+
+ // Close Button
+ wxButton* const btn_close = new wxButton(this, wxID_OK, _("Close"));
+ btn_close->Bind(wxEVT_BUTTON, &PostProcessingConfigDiag::Event_ClickClose, this);
+
+ Bind(wxEVT_CLOSE_WINDOW, &PostProcessingConfigDiag::Event_Close, this);
+
+ wxBoxSizer* const szr_main = new wxBoxSizer(wxVERTICAL);
+ szr_main->Add(notebook, 1, wxEXPAND | wxALL, 5);
+ szr_main->Add(btn_close, 0, wxALIGN_RIGHT | wxRIGHT | wxBOTTOM, 5);
+
+ SetSizerAndFit(szr_main);
+ Center();
+ SetFocus();
+
+ UpdateWindowUI();
+}
+
+PostProcessingConfigDiag::~PostProcessingConfigDiag()
+{
+ m_post_processor->SaveOptionsConfiguration();
+ if (g_renderer && g_renderer->GetPostProcessor())
+ m_post_processor = nullptr;
+ else
+ delete m_post_processor;
+}
+
+void PostProcessingConfigDiag::ConfigGrouping::GenerateUI(PostProcessingConfigDiag* dialog, wxWindow* parent, wxFlexGridSizer* sizer)
+{
+ if (m_type == WidgetType::TYPE_TOGGLE)
+ {
+ m_option_checkbox = new wxCheckBox(parent, wxID_ANY, _(m_gui_name));
+ m_option_checkbox->SetValue(m_config_option->m_bool_value);
+ m_option_checkbox->Bind(wxEVT_CHECKBOX, &PostProcessingConfigDiag::Event_CheckBox,
+ dialog, wxID_ANY, wxID_ANY, new UserEventData(m_option));
+
+ sizer->Add(m_option_checkbox);
+ sizer->AddStretchSpacer();
+ }
+ else
+ {
+ size_t vector_size = 0;
+ if (m_config_option->m_type == PostProcessingShaderConfiguration::ConfigurationOption::OptionType::OPTION_INTEGER)
+ vector_size = m_config_option->m_integer_values.size();
+ else
+ vector_size = m_config_option->m_float_values.size();
+
+ wxFlexGridSizer* const szr_values = new wxFlexGridSizer(vector_size + 1, 0, 0);
+ wxStaticText* const option_static_text = new wxStaticText(parent, wxID_ANY, _(m_gui_name));
+ sizer->Add(option_static_text);
+
+ for (size_t i = 0; i < vector_size; ++i)
+ {
+ // wxSlider uses a signed integer for it's minimum and maximum values
+ // This won't work for floats.
+ // Let's determine how many steps we can take and use that instead.
+ int steps = 0;
+ int current_value = 0;
+ std::string string_value;
+ if (m_config_option->m_type == PostProcessingShaderConfiguration::ConfigurationOption::OptionType::OPTION_INTEGER)
+ {
+ // Find out our range by taking the max subtracting the minimum.
+ double range = m_config_option->m_integer_max_values[i] - m_config_option->m_integer_min_values[i];
+
+ // How many steps we have is the range divided by the step interval configured.
+ // This may not be 100% spot on accurate since developers can have odd stepping intervals set.
+ // Round up so if it is outside our range, then set it to the minimum or maximum
+ steps = ceil(range / (double)m_config_option->m_integer_step_values[i]);
+
+ // Default value is just the currently set value here
+ current_value = m_config_option->m_integer_values[i];
+ string_value = std::to_string(m_config_option->m_integer_values[i]);
+ }
+ else
+ {
+ // Same as above but with floats
+ float range = m_config_option->m_float_max_values[i] - m_config_option->m_float_min_values[i];
+ steps = ceil(range / m_config_option->m_float_step_values[i]);
+
+ // We need to convert our default float value from a float to the nearest step value range
+ current_value = (m_config_option->m_float_values[i] / m_config_option->m_float_step_values[i]);
+ string_value = std::to_string(m_config_option->m_float_values[i]);
+ }
+
+ wxSlider* slider = new wxSlider(parent, wxID_ANY, current_value, 0, steps,
+ wxDefaultPosition, wxSize(200, -1), wxSL_HORIZONTAL | wxSL_BOTTOM);
+ wxTextCtrl* text_ctrl = new wxTextCtrl(parent, wxID_ANY, string_value);
+
+ // Disable the textctrl, it's only there to show the absolute value from the slider
+ text_ctrl->Enable(false);
+
+ // wxWidget takes over the pointer provided to it in the event handler.
+ // This won't be a memory leak, it'll be destroyed on dialog close.
+ slider->Bind(wxEVT_SLIDER, &PostProcessingConfigDiag::Event_Slider,
+ dialog, wxID_ANY, wxID_ANY, new UserEventData(m_option));
+
+ m_option_sliders.push_back(slider);
+ m_option_text_ctrls.push_back(text_ctrl);
+ }
+
+ if (vector_size == 1)
+ {
+ szr_values->Add(m_option_sliders[0], wxSizerFlags().Align(wxALIGN_CENTER_VERTICAL));
+ szr_values->Add(m_option_text_ctrls[0]);
+
+ sizer->Add(szr_values);
+ }
+ else
+ {
+ wxFlexGridSizer* const szr_inside = new wxFlexGridSizer(2, 0, 0);
+ for (size_t i = 0; i < vector_size; ++i)
+ {
+ szr_inside->Add(m_option_sliders[i], wxSizerFlags().Align(wxALIGN_CENTER_VERTICAL));
+ szr_inside->Add(m_option_text_ctrls[i]);
+ }
+
+ szr_values->Add(szr_inside);
+ sizer->Add(szr_values);
+ }
+ }
+}
+
+void PostProcessingConfigDiag::ConfigGrouping::EnableDependentChildren(bool enable)
+{
+ // Enable or disable all the children
+ for (auto& it : m_children)
+ {
+ if (it->m_type == ConfigGrouping::WidgetType::TYPE_TOGGLE)
+ {
+ it->m_option_checkbox->Enable(enable);
+ }
+ else
+ {
+ for (auto& slider : it->m_option_sliders)
+ slider->Enable(enable);
+ }
+ // Set this objects children as well
+ it->EnableDependentChildren(enable);
+ }
+}
+
+void PostProcessingConfigDiag::Event_CheckBox(wxCommandEvent &ev)
+{
+ UserEventData* config_option = (UserEventData*)ev.GetEventUserData();
+ ConfigGrouping* config = m_config_map[config_option->GetData()];
+
+ m_post_processor->SetOptionb(config->GetOption(), ev.IsChecked());
+
+ config->EnableDependentChildren(ev.IsChecked());
+
+ ev.Skip();
+}
+
+void PostProcessingConfigDiag::Event_Slider(wxCommandEvent &ev)
+{
+ UserEventData* config_option = (UserEventData*)ev.GetEventUserData();
+ ConfigGrouping* config = m_config_map[config_option->GetData()];
+
+ const auto& option_data = m_post_processor->GetOption(config->GetOption());
+
+ size_t vector_size = 0;
+ if (option_data.m_type == PostProcessingShaderConfiguration::ConfigurationOption::OptionType::OPTION_INTEGER)
+ vector_size = option_data.m_integer_values.size();
+ else
+ vector_size = option_data.m_float_values.size();
+
+ for (size_t i = 0; i < vector_size; ++i)
+ {
+ // Got to do this garbage again.
+ // Convert current step in to the real range value
+ int current_step = config->GetSliderValue(i);
+ std::string string_value;
+ if (option_data.m_type == PostProcessingShaderConfiguration::ConfigurationOption::OptionType::OPTION_INTEGER)
+ {
+ s32 value = option_data.m_integer_step_values[i] * current_step + option_data.m_integer_min_values[i];
+ m_post_processor->SetOptioni(config->GetOption(), i, value);
+ string_value = std::to_string(value);
+
+ }
+ else
+ {
+ float value = option_data.m_float_step_values[i] * current_step + option_data.m_float_min_values[i];
+ m_post_processor->SetOptionf(config->GetOption(), i, value);
+ string_value = std::to_string(value);
+ }
+ // Update the text box to include the new value
+ config->SetSliderText(i, string_value);
+ }
+ ev.Skip();
+}
+
+void PostProcessingConfigDiag::Event_ClickClose(wxCommandEvent&)
+{
+ Close();
+}
+
+void PostProcessingConfigDiag::Event_Close(wxCloseEvent& ev)
+{
+ EndModal(wxID_OK);
+}
+
diff --git a/Source/Core/DolphinWX/PostProcessingConfigDiag.h b/Source/Core/DolphinWX/PostProcessingConfigDiag.h
new file mode 100644
index 0000000000..dabf44468b
--- /dev/null
+++ b/Source/Core/DolphinWX/PostProcessingConfigDiag.h
@@ -0,0 +1,106 @@
+// Copyright 2013 Dolphin Emulator Project
+// Licensed under GPLv2
+// Refer to the license.txt file included.
+
+#pragma once
+
+#include