RetroArch Pack

This commit is contained in:
Abdessamad DERRAZ
2020-05-08 17:25:48 +02:00
parent 849cc2a33c
commit d9fc3b32f0
3164 changed files with 2458568 additions and 1 deletions

View File

@@ -0,0 +1,54 @@
void main()
{
//Change this number to increase the pixel size.
float pixelSize = 3.0;
float red = 0.0;
float green = 0.0;
float blue = 0.0;
float2 pos = floor(GetCoordinates() * GetResolution() / pixelSize) * pixelSize * GetInvResolution();
float4 c0 = SampleLocation(pos);
if (c0.r < 0.1)
red = 0.1;
else if (c0.r < 0.20)
red = 0.20;
else if (c0.r < 0.40)
red = 0.40;
else if (c0.r < 0.60)
red = 0.60;
else if (c0.r < 0.80)
red = 0.80;
else
red = 1.0;
if (c0.b < 0.1)
blue = 0.1;
else if (c0.b < 0.20)
blue = 0.20;
else if (c0.b < 0.40)
blue = 0.40;
else if (c0.b < 0.60)
blue = 0.60;
else if (c0.b < 0.80)
blue = 0.80;
else
blue = 1.0;
if (c0.g < 0.1)
green = 0.1;
else if (c0.g < 0.20)
green = 0.20;
else if (c0.g < 0.40)
green = 0.40;
else if (c0.g < 0.60)
green = 0.60;
else if (c0.g < 0.80)
green = 0.80;
else
green = 1.0;
SetOutput(float4(red, green, blue, c0.a));
}

View File

@@ -0,0 +1,79 @@
void main()
{
//Change this number to increase the pixel size.
float pixelSize = 2.0;
float red = 0.0;
float green = 0.0;
float blue = 0.0;
float2 pos = floor(GetCoordinates() * GetResolution() / pixelSize) * pixelSize * GetInvResolution();
float4 c0 = SampleLocation(pos);
if (c0.r < 0.06)
red = 0.06;
else if (c0.r < 0.13)
red = 0.13;
else if (c0.r < 0.26)
red = 0.26;
else if (c0.r < 0.33)
red = 0.33;
else if (c0.r < 0.46)
red = 0.46;
else if (c0.r < 0.60)
red = 0.60;
else if (c0.r < 0.73)
red = 0.73;
else if (c0.r < 0.80)
red = 0.80;
else if (c0.r < 0.93)
red = 0.93;
else
red = 1.0;
if (c0.b < 0.06)
blue = 0.06;
else if (c0.b < 0.13)
blue = 0.13;
else if (c0.b < 0.26)
blue = 0.26;
else if (c0.b < 0.33)
blue = 0.33;
else if (c0.b < 0.46)
blue = 0.46;
else if (c0.b < 0.60)
blue = 0.60;
else if (c0.b < 0.73)
blue = 0.73;
else if (c0.b < 0.80)
blue = 0.80;
else if( c0.b < 0.93)
blue = 0.93;
else
blue = 1.0;
if (c0.g < 0.06)
green = 0.06;
else if (c0.g < 0.13)
green = 0.13;
else if (c0.g < 0.26)
green = 0.26;
else if (c0.g < 0.33)
green = 0.33;
else if (c0.g < 0.46)
green = 0.46;
else if (c0.g < 0.60)
green = 0.60;
else if (c0.g < 0.73)
green = 0.73;
else if (c0.g < 0.80)
green = 0.80;
else if( c0.g < 0.93)
green = 0.93;
else
green = 1.0;
SetOutput(float4(red, green, blue, c0.a));
}

View File

@@ -0,0 +1,20 @@
// Anaglyph Amber-Blue shader based on Dubois algorithm
// Constants taken from the screenshot:
// "https://www.flickr.com/photos/e_dubois/5230654930/"
// Eric Dubois
void main()
{
float4 c0 = SampleLayer(0);
float4 c1 = SampleLayer(1);
float3 lr = float3( 1.062,-0.205, 0.299);
float3 lg = float3(-0.026, 0.908, 0.068);
float3 lb = float3(-0.038,-0.173, 0.022);
float3 rr = float3(-0.016,-0.123,-0.017);
float3 rg = float3( 0.006, 0.062, 0.017);
float3 rb = float3(-0.094,-0.185, 0.991);
SetOutput(float4(dot(lr, c0.rgb) + dot(rr, c1.rgb), dot(lg, c0.rgb) + dot(rg, c1.rgb), dot(lb, c0.rgb) + dot(rb, c1.rgb), c0.a));
}

View File

@@ -0,0 +1,20 @@
// Anaglyph Green-Magenta shader based on Dubois algorithm
// Constants taken from the screenshot:
// "https://www.flickr.com/photos/e_dubois/5132528166/"
// Eric Dubois
void main()
{
float4 c0 = SampleLayer(0);
float4 c1 = SampleLayer(1);
float3 lr = float3(-0.062,-0.158,-0.039);
float3 lg = float3( 0.284, 0.668, 0.143);
float3 lb = float3(-0.015,-0.027, 0.021);
float3 rr = float3( 0.529, 0.705, 0.024);
float3 rg = float3(-0.016,-0.015, 0.065);
float3 rb = float3( 0.009, 0.075, 0.937);
SetOutput(float4(dot(lr, c0.rgb) + dot(rr, c1.rgb), dot(lg, c0.rgb) + dot(rg, c1.rgb), dot(lb, c0.rgb) + dot(rb, c1.rgb), c0.a));
}

View File

@@ -0,0 +1,21 @@
// Anaglyph Red-Cyan shader based on Dubois algorithm
// Constants taken from the paper:
// "Conversion of a Stereo Pair to Anaglyph with
// the Least-Squares Projection Method"
// Eric Dubois, March 2009
void main()
{
float4 c0 = SampleLayer(0);
float4 c1 = SampleLayer(1);
float3 lr = float3( 0.437, 0.449, 0.164);
float3 lg = float3(-0.062,-0.062,-0.024);
float3 lb = float3(-0.048,-0.050,-0.017);
float3 rr = float3(-0.011,-0.032,-0.007);
float3 rg = float3( 0.377, 0.761, 0.009);
float3 rb = float3(-0.026,-0.093, 1.234);
SetOutput(float4(dot(lr, c0.rgb) + dot(rr, c1.rgb), dot(lg, c0.rgb) + dot(rg, c1.rgb), dot(lb, c0.rgb) + dot(rb, c1.rgb), c0.a));
}

View File

@@ -0,0 +1,8 @@
// Anaglyph Red-Cyan shader without compensation
void main()
{
float4 c0 = SampleLayer(0);
float4 c1 = SampleLayer(1);
SetOutput(float4(c0.r, c1.gb, c0.a));
}

View File

@@ -0,0 +1,10 @@
// Anaglyph Red-Cyan grayscale shader
void main()
{
float4 c0 = SampleLayer(0);
float avg0 = (c0.r + c0.g + c0.b) / 3.0;
float4 c1 = SampleLayer(1);
float avg1 = (c1.r + c1.g + c1.b) / 3.0;
SetOutput(float4(avg0, avg1, avg1, c0.a));
}

View File

@@ -0,0 +1,12 @@
// Anaglyph Red-Cyan luma grayscale shader
// Info: https://web.archive.org/web/20040101053504/http://www.oreillynet.com:80/cs/user/view/cs_msg/8691
void main()
{
float3 luma = float3(0.222, 0.707, 0.071);
float4 c0 = SampleLayer(0);
float avg0 = dot(c0.rgb, luma);
float4 c1 = SampleLayer(1);
float avg1 = dot(c1.rgb, luma);
SetOutput(float4(avg0, avg1, avg1, c0.a));
}

View File

@@ -0,0 +1,67 @@
// DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
// Version 2, December 2004
// Copyright (C) 2013 mudlord
// Everyone is permitted to copy and distribute verbatim or modified
// copies of this license document, and changing it is allowed as long
// as the name is changed.
// DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
// TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
// 0. You just DO WHAT THE FUCK YOU WANT TO.
#define FXAA_REDUCE_MIN (1.0/ 128.0)
#define FXAA_REDUCE_MUL (1.0 / 8.0)
#define FXAA_SPAN_MAX 8.0
float4 applyFXAA(float2 fragCoord)
{
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);
float lumaSE = dot(rgbSE, luma);
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)));
float2 dir;
dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));
dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE));
float dirReduce = max((lumaNW + lumaNE + lumaSW + lumaSE) *
(0.25 * FXAA_REDUCE_MUL), FXAA_REDUCE_MIN);
float rcpDirMin = 1.0 / (min(abs(dir.x), abs(dir.y)) + dirReduce);
dir = min(float2(FXAA_SPAN_MAX, FXAA_SPAN_MAX),
max(float2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX),
dir * rcpDirMin)) * inverseVP;
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 = float4(rgbA, 1.0);
else
color = float4(rgbB, 1.0);
return color;
}
void main()
{
SetOutput(applyFXAA(GetCoordinates() * GetResolution()));
}

View File

@@ -0,0 +1,7 @@
// Passive (horizontal rows) shader
void main()
{
float screen_row = GetWindowResolution().y * GetCoordinates().y;
SetOutput(SampleLayer(int(screen_row) % 2));
}

View File

@@ -0,0 +1,16 @@
void main()
{
float4 c0 = Sample();
float red = 0.0;
float blue = 0.0;
if (c0.r > 0.15 && c0.b > 0.15)
{
blue = 0.5;
red = 0.5;
}
float green = max(c0.r + c0.b, c0.g);
SetOutput(float4(red, green, blue, 1.0));
}

View File

@@ -0,0 +1,4 @@
void main()
{
SetOutput((SampleOffset(int2(1, 1)) - SampleOffset(int2(-1, -1))) * 8.0);
}

View File

@@ -0,0 +1,6 @@
void main()
{
float4 a = SampleOffset(int2( 1, 1));
float4 b = SampleOffset(int2(-1, -1));
SetOutput(( a*a*1.3 - b ) * 8.0);
}

View File

@@ -0,0 +1,91 @@
const int char_width = 8;
const int char_height = 13;
const int char_count = 95;
const int char_pixels = char_width*char_height;
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()
{
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;
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<char_count; i++)
{
float4 ff = float4(0.0, 0.0, 0.0, 0.0);
float4 f = float4(0.0, 0.0, 0.0, 0.0);
float4 ft = float4(0.0, 0.0, 0.0, 0.0);
float4 t = float4(0.0, 0.0, 0.0, 0.0);
float4 tt = float4(0.0, 0.0, 0.0, 0.0);
for (int x=0; x<char_width; x++)
{
for (int y=0; y<char_height; y++)
{
float2 tex_pos = char_pos*char_dim + float2(x,y) + 0.5;
float4 tex = SampleLocation(tex_pos * GetInvResolution());
float2 font_pos = float2(x+i*char_width, y) + 0.5;
float4 font = SampleFontLocation(font_pos * font_scale);
// generates sum of texture and font and their squares
ff += font*font;
f += font;
ft += font*tex;
t += tex;
tt += tex*tex;
}
}
// The next lines are a bit harder, hf :-)
// The idea is to find the perfect char with the perfect background color and the perfect font color.
// As this is an equation with three unknowns, we can't just try all chars and color combinations.
// As criterion how "perfect" the selection is, we compare the "mean squared error" of the resulted colors of all chars.
// So, now the big issue: how to calculate the MSE without knowing the two colors ...
// In the next steps, "a" is the font color, "b" is the background color, "f" is the font value at this pixel, "t" is the texture value
// So the square error of one pixel is:
// e = ( t - a⋅f - b⋅(1-f) ) ^ 2
// In longer:
// e = a^2⋅f^2 - 2⋅a⋅b⋅f^2 + 2⋅a⋅b⋅f - 2⋅a⋅f⋅t + b^2⋅f^2 - 2⋅b^2⋅f + b^2 + 2⋅b⋅f⋅t - 2⋅b⋅t + t^2
// The sum of all errors is: (as shortcut, ff,f,ft,t,tt are now the sums like declared above, sum(1) is the count of pixels)
// sum(e) = a^2⋅ff - 2⋅a^2⋅ff + 2⋅a⋅b⋅f - 2⋅a⋅ft + b^2⋅ff - 2⋅b^2⋅f + b^2⋅sum(1) + 2⋅b⋅ft - 2⋅b⋅t + tt
// To find the minimum, we have to derive this by "a" and "b":
// d/da sum(e) = 2⋅a⋅ff + 2⋅b⋅f - 2⋅b⋅ff - 2⋅ft
// d/db sum(e) = 2⋅a⋅f - 2⋅a⋅ff - 4⋅b⋅f + 2⋅b⋅ff + 2⋅b⋅sum(1) + 2⋅ft - 2⋅t
// So, both equations must be zero at minimum and there is only one solution.
float4 a = (f*ft - ff*t + f*t - ft*float(char_pixels)) / (f*f - ff*float(char_pixels));
float4 b = (f*ft - ff*t) / (f*f - ff*float(char_pixels));
float4 diff = a*a*ff + 2.0*a*b*f - 2.0*a*b*ff - 2.0*a*ft + b*b *(-2.0*f + ff + float(char_pixels)) + 2.0*b*ft - 2.0*b*t + tt;
float diff_f = dot(diff, float4(1.0, 1.0, 1.0, 1.0));
if (diff_f < mindiff)
{
mindiff = diff_f;
minc = float(i);
mina = a;
minb = b;
}
}
float2 font_pos_res = float2(minc * float(char_width), 0.0) + pixel_offset + 0.5;
float4 col = SampleFontLocation(font_pos_res * font_scale);
SetOutput(mina * col + minb * (float4(1.0,1.0,1.0,1.0) - col));
}

View File

@@ -0,0 +1,15 @@
void main()
{
float4 to_gray = float4(0.3,0.59,0.11,0);
float x1 = dot(to_gray, SampleOffset(int2( 1, 1)));
float x0 = dot(to_gray, SampleOffset(int2(-1,-1)));
float x3 = dot(to_gray, SampleOffset(int2( 1,-1)));
float x2 = dot(to_gray, SampleOffset(int2(-1, 1)));
float edge = (x1 - x0) * (x1 - x0) + (x3 - x2) * (x3 - x2);
float4 color = Sample();
SetOutput(color - float4(edge, edge, edge, edge) * 12.0);
}

View File

@@ -0,0 +1,88 @@
void main()
{
//Changethis to increase the number of colors.
int numColors =8;
float4 to_gray = float4(0.3,0.59,0.11,0);
float x1 = dot(to_gray, SampleOffset(int2( 1, 1)));
float x0 = dot(to_gray, SampleOffset(int2(-1,-1)));
float x3 = dot(to_gray, SampleOffset(int2( 1,-1)));
float x2 = dot(to_gray, SampleOffset(int2(-1, 1)));
float edge = (x1 - x0) * (x1 - x0) + (x3 - x2) * (x3 - x2);
float4 color = Sample();
float4 c0 = color - float4(edge, edge, edge, edge) * 12.0;
float red = 0.0;
float green = 0.0;
float blue = 0.0;
bool rr = false;
bool bb = false;
bool gg = false;
int count = 1;
float colorN = 0.0;
float colorB = 0.0;
for (count = 1; count <= numColors; count++)
{
colorN = float(count / numColors);
if ( c0.r <= colorN && c0.r >= colorB && rr == false )
{
if (count == 1)
{
if (colorN >= 0.1)
red = 0.01;
else
red = colorN;
}
else if (count == numColors)
red = 0.95;
else
red = colorN;
rr = true;
}
if (c0.b <= colorN && c0.b >= colorB && bb == false)
{
if (count == 1)
{
if (colorN >= 0.1)
blue = 0.01;
else
blue = colorN;
}
else if (count == numColors)
blue = 0.95;
else
blue = colorN ;
bb = true;
}
if (c0.g <= colorN && c0.g >= colorB && gg == false)
{
if (count == 1)
{
if (colorN >= 0.1)
green = 0.01;
else
green = colorN;
}
else if (count == numColors)
green = 0.95;
else
green = colorN;
gg = true;
}
colorB = float(count / numColors);
if (rr == true && bb == true && gg == true)
break;
}
SetOutput(float4(red, green, blue, c0.a));
}

View File

@@ -0,0 +1,36 @@
void main()
{
float4 c_center = Sample();
float4 bloom_sum = float4(0.0, 0.0, 0.0, 0.0);
float2 pos = GetCoordinates() + float2(0.3, 0.3) * GetInvResolution();
float2 radius1 = 1.3 * GetInvResolution();
bloom_sum += SampleLocation(pos + float2(-1.5, -1.5) * radius1);
bloom_sum += SampleLocation(pos + float2(-2.5, 0.0) * radius1);
bloom_sum += SampleLocation(pos + float2(-1.5, 1.5) * radius1);
bloom_sum += SampleLocation(pos + float2(0.0, 2.5) * radius1);
bloom_sum += SampleLocation(pos + float2(1.5, 1.5) * radius1);
bloom_sum += SampleLocation(pos + float2(2.5, 0.0) * radius1);
bloom_sum += SampleLocation(pos + float2(1.5, -1.5) * radius1);
bloom_sum += SampleLocation(pos + float2(0.0, -2.5) * radius1);
float2 radius2 = 4.6 * GetInvResolution();
bloom_sum += SampleLocation(pos + float2(-1.5, -1.5) * radius2);
bloom_sum += SampleLocation(pos + float2(-2.5, 0.0) * radius2);
bloom_sum += SampleLocation(pos + float2(-1.5, 1.5) * radius2);
bloom_sum += SampleLocation(pos + float2(0.0, 2.5) * radius2);
bloom_sum += SampleLocation(pos + float2(1.5, 1.5) * radius2);
bloom_sum += SampleLocation(pos + float2(2.5, 0.0) * radius2);
bloom_sum += SampleLocation(pos + float2(1.5, -1.5) * radius2);
bloom_sum += SampleLocation(pos + float2(0.0, -2.5) * radius2);
bloom_sum *= 0.07;
bloom_sum -= float4(0.3, 0.3, 0.3, 0.3);
bloom_sum = max(bloom_sum, float4(0.0, 0.0, 0.0, 0.0));
float2 vpos = (GetCoordinates() - float2(0.5, 0.5)) * 2.0;
float dist = (dot(vpos, vpos));
dist = 1.0 - 0.4*dist;
SetOutput((c_center * 0.7 + bloom_sum) * dist);
}

View File

@@ -0,0 +1,4 @@
void main()
{
SetOutput(Sample()* 3.0);
}

View File

@@ -0,0 +1,13 @@
void main()
{
float4 c0 = Sample();
float red = 0.0;
float green = 0.0;
if (c0.r < 0.35 || c0.b > 0.35)
green = c0.g + (c0.b / 2.0);
else
red = c0.r + 0.4;
SetOutput(float4(red, green, 0.0, 1.0));
}

View File

@@ -0,0 +1,20 @@
void main()
{
float4 c0 = Sample();
float red = 0.0;
float green = 0.0;
float blue = 0.0;
if (c0.r < 0.50 || c0.b > 0.5)
{
blue = c0.r;
red = c0.g;
}
else
{
blue = c0.r;
green = c0.r;
}
SetOutput(float4(red, green, blue, 1.0));
}

View File

@@ -0,0 +1,33 @@
void main()
{
float4 c0 = Sample();
float4 c1 = SampleOffset(int2(-1, 0));
float4 c2 = SampleOffset(int2( 0, -1));
float4 c3 = SampleOffset(int2( 1, 0));
float4 c4 = SampleOffset(int2( 0, 1));
float red = c0.r;
float blue = c0.b;
float green = c0.g;
float red2 = (c1.r + c2.r + c3.r + c4.r) / 4.0;
float blue2 = (c1.b + c2.b + c3.b + c4.b) / 4.0;
float green2 = (c1.g + c2.g + c3.g + c4.g) / 4.0;
if (red2 > 0.3)
red = c0.r + c0.r / 2.0;
else
red = c0.r - c0.r / 2.0;
if (green2 > 0.3)
green = c0.g+ c0.g / 2.0;
else
green = c0.g - c0.g / 2.0;
if (blue2 > 0.3)
blue = c0.b+ c0.b / 2.0;
else
blue = c0.b - c0.b / 2.0;
SetOutput(float4(red, green, blue, c0.a));
}

View File

@@ -0,0 +1,17 @@
void main()
{
float4 c0 = Sample();
float4 c1 = SampleOffset(int2(5, 5));
float y = (0.222 * c1.r) + (0.707 * c1.g) + (0.071 * c1.b);
float y2 = ((0.222 * c0.r) + (0.707 * c0.g) + (0.071 * c0.b)) / 3.0;
float red = c0.r;
float green = c0.g;
float blue = c0.b;
float alpha = c0.a;
red = y2 + (1.0 - y);
green = y2 + (1.0 - y);
blue = y2 + (1.0 - y);
SetOutput(float4(red, green, blue, alpha));
}

View File

@@ -0,0 +1,29 @@
void main()
{
float4 c0 = Sample();
float red = 0.0;
float green = 0.0;
float blue = 0.0;
red = c0.r;
if (c0.r > 0.0 && c0.g > c0.r)
green = (c0.g - (c0.g - c0.r)) / 3.0;
if (c0.b > 0.0 && c0.r < 0.25)
{
red = c0.b;
green = c0.b / 3.0;
}
if (c0.g > 0.0 && c0.r < 0.25)
{
red = c0.g;
green = c0.g / 3.0;
}
if (((c0.r + c0.g + c0.b) / 3.0) > 0.9)
green = c0.r / 3.0;
SetOutput(float4(red, green, blue, 1.0));
}

View File

@@ -0,0 +1,13 @@
void main()
{
float4 c0 = Sample();
float red = 0.0;
float green = 0.0;
float blue = 0.0;
float avg = (c0.r + c0.g + c0.b) / 3.0;
red = c0.r + (c0.g / 2.0) + (c0.b / 3.0);
green = c0.r / 3.0;
SetOutput(float4(red, green, blue, 1.0));
}

View File

@@ -0,0 +1,15 @@
void main()
{
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;
float alpha = c0.a;
red = c0.r - c1.b;
blue = c0.b - c2.r + (c0.g - c0.r);
SetOutput(float4(red, 0.0, blue, alpha));
}

View File

@@ -0,0 +1,6 @@
void main()
{
float4 c0 = Sample();
float avg = (c0.r + c0.g + c0.b) / 3.0;
SetOutput(float4(avg, avg, avg, c0.a));
}

View File

@@ -0,0 +1,7 @@
void main()
{
float4 c0 = Sample();
// Info: https://web.archive.org/web/20040101053504/http://www.oreillynet.com:80/cs/user/view/cs_msg/8691
float avg = (0.222 * c0.r) + (0.707 * c0.g) + (0.071 * c0.b);
SetOutput(float4(avg, avg, avg, c0.a));
}

View File

@@ -0,0 +1,4 @@
void main()
{
SetOutput(float4(1.0, 1.0, 1.0, 1.0) - Sample());
}

View File

@@ -0,0 +1,4 @@
void main()
{
SetOutput(float4(0.0, 0.0, 0.7, 1.0) - Sample());
}

View File

@@ -0,0 +1,7 @@
void main()
{
float4 c0 = Sample();
float4 c1 = SampleOffset(int2(5, 5));
SetOutput(c0 - c1);
}

View File

@@ -0,0 +1,93 @@
/*
[configuration]
[OptionRangeFloat]
GUIName = Distortion amount
OptionName = DISTORTION_FACTOR
MinValue = 1.0
MaxValue = 10.0
StepAmount = 0.5
DefaultValue = 4.0
[OptionRangeFloat]
GUIName = Eye Distance Offset
OptionName = EYE_OFFSET
MinValue = 0.0
MaxValue = 10.0
StepAmount = 0.25
DefaultValue = 5.0
[OptionRangeFloat]
GUIName = Zoom adjustment
OptionName = SIZE_ADJUST
MinValue = 0.0
MaxValue = 1.0
StepAmount = 0.025
DefaultValue = 0.5
[OptionRangeFloat]
GUIName = Aspect Ratio adjustment
OptionName = ASPECT_ADJUST
MinValue = 0.0
MaxValue = 1.0
StepAmount = 0.025
DefaultValue = 0.5
[/configuration]
*/
void main()
{
// Base Cardboard distortion parameters
float factor = GetOption(DISTORTION_FACTOR) * 0.01f;
float ka = factor * 3.0f;
float kb = factor * 5.0f;
// size and aspect adjustment
float sizeAdjust = 1.0f - GetOption(SIZE_ADJUST) + 0.5f;
float aspectAdjustment = 1.25f - GetOption(ASPECT_ADJUST);
// offset centering per eye
float stereoOffset = GetOption(EYE_OFFSET) * 0.01f;
float offsetAdd;
// layer0 = left eye, layer1 = right eye
if (layer == 1)
{
offsetAdd = stereoOffset;
}
else
{
offsetAdd = 0.0 - stereoOffset;
}
// convert coordinates to NDC space
float2 fragPos = (GetCoordinates() - 0.5f - vec2(offsetAdd, 0.0f)) * 2.0f;
// Calculate the source location "radius" (distance from the centre of the viewport)
float destR = length(fragPos);
// find the radius multiplier
float srcR = destR * sizeAdjust + ( ka * pow(destR, 2.0) + kb * pow(destR, 4.0));
// Calculate the source vector (radial)
vec2 correctedRadial = normalize(fragPos) * srcR;
// fix aspect ratio
vec2 widenedRadial = correctedRadial * vec2(aspectAdjustment, 1.0f);
// Transform the coordinates (from [-1,1]^2 to [0, 1]^2)
vec2 uv = (widenedRadial/2.0f) + vec2(0.5f) + vec2(offsetAdd, 0.0f);
// Sample the texture at the source location
if(clamp(uv, 0.0, 1.0) != uv)
{
// black if beyond bounds
SetOutput(float4(0.0, 0.0, 0.0, 0.0));
}
else
{
SetOutput(SampleLocation(uv));
}
}

View File

@@ -0,0 +1,19 @@
void main()
{
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)
{
SetOutput(float4(1,0,0,0));
}
else
{
color += emboss;
if (dot(color.rgb, float3(0.3, 0.5, 0.2)) > 0.5)
SetOutput(float4(1,1,1,1));
else
SetOutput(float4(0,0,0,0));
}
}

View File

@@ -0,0 +1,10 @@
void main()
{
float4 c0 = Sample();
float green = c0.g;
if (c0.g < 0.50)
green = c0.r + c0.b;
SetOutput(float4(0.0, green, 0.0, 1.0));
}

View File

@@ -0,0 +1,62 @@
void main()
{
//variables
float internalresolution = 1278.0;
float4 c0 = Sample();
//blur
float4 blurtotal = float4(0.0, 0.0, 0.0, 0.0);
float blursize = 1.5;
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;
//greyscale
float grey = ((0.3 * c0.r) + (0.4 * c0.g) + (0.3 * c0.b));
// brighten
grey = grey * 0.5 + 0.7;
// darken edges
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)
y = internalresolution-y;
if (x > internalresolution/2.0*0.95)
x = internalresolution/2.0*0.95;
if (y > internalresolution/2.0*0.95)
y = internalresolution/2.0*0.95;
x = -x+641.0;
y = -y+641.0;
/*****inline square root routines*****/
// bit of a performance bottleneck.
// neccessary to make the darkened area rounded
// instead of rhombus-shaped.
float sqrt = x / 10.0;
while ((sqrt*sqrt) < x)
sqrt+=0.1;
x = sqrt;
sqrt = y / 10.0;
while ((sqrt*sqrt) < y)
sqrt+=0.1;
y = sqrt;
x *= 2.0;
y *= 2.0;
grey -= x / 200.0;
grey -= y / 200.0;
// output
SetOutput(float4(0.0, grey, 0.0, 1.0));
}

View File

@@ -0,0 +1,71 @@
void main()
{
//variables
float internalresolution = 1278.0;
float4 c0 = Sample();
//blur
float4 blurtotal = float4(0.0, 0.0, 0.0, 0.0);
float blursize = 1.5;
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;
//greyscale
float grey = ((0.3 * c0.r) + (0.4 * c0.g) + (0.3 * c0.b));
// 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 = ((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 = GetCoordinates().x * GetResolution().x;
float y = GetCoordinates().y * GetResolution().y;
if (x > internalresolution/2.0)
x = internalresolution-x;
if (y > internalresolution/2.0)
y = internalresolution-y;
if (x > internalresolution/2.0*0.95)
x = internalresolution/2.0*0.95;
if (y > internalresolution/2.0*0.95)
y = internalresolution/2.0*0.95;
x = -x + 641.0;
y = -y + 641.0;
//****inline square root routines*****/
// bit of a performance bottleneck.
// neccessary to make the darkened area rounded
// instead of rhombus-shaped.
float sqrt = x / 10.0;
while ((sqrt*sqrt) < x)
sqrt+=0.1;
x = sqrt;
sqrt = y / 10.0;
while ((sqrt*sqrt) < y)
sqrt+=0.1;
y = sqrt;
x *= 2.0;
y *= 2.0;
grey -= x / 200.0;
grey -= y / 200.0;
// output
SetOutput(float4(0.0, grey, 0.0, 1.0));
}

View File

@@ -0,0 +1,18 @@
void main()
{
float4 c0 = Sample();
float red = 0.0;
float green = 0.0;
float blue = 0.0;
if (c0.r > 0.25)
red = c0.r;
if (c0.g > 0.25)
green = c0.g;
if (c0.b > 0.25)
blue = c0.b;
SetOutput(float4(red, green, blue, 1.0));
}

View File

@@ -0,0 +1,18 @@
float bound(float color)
{
if (color < 0.35)
{
if (color < 0.25)
return color;
return 0.5;
}
return 1.0;
}
void main()
{
float4 c0 = Sample();
SetOutput(float4(bound(c0.r), bound(c0.g), bound(c0.b), c0.a));
}

View File

@@ -0,0 +1,77 @@
void main()
{
float4 c0 = Sample();
float red = c0.r;
float blue = c0.b;
float green = c0.g;
float factor = 2.0;
float max = 0.8;
float min = 0.3;
if (c0.r > c0.g && c0.b > c0.g)
{
if (c0.r < c0.b + 0.05 && c0.b < c0.r + 0.05)
{
red = 0.7;
blue = 0.7;
green = 0.05;
}
else if (c0.r > c0.b + 0.05)
{
red = 0.7;
blue = 0.05;
green = 0.05;
}
else if (c0.b > c0.r + 0.05)
{
red = 0.05;
blue = 0.7;
green = 0.05;
}
}
if (c0.r > c0.b && c0.g > c0.b)
{
if (c0.r < c0.g + 0.05 && c0.g < c0.r + 0.05)
{
red = 0.7;
blue = 0.05;
green = 0.7;
}
else if (c0.r > c0.g + 0.05)
{
red = 0.7;
blue = 0.05;
green = 0.05;
}
else if (c0.g > c0.r + 0.05)
{
red = 0.05;
blue = 0.05;
green = 0.7;
}
}
if (c0.g > c0.r && c0.b > c0.r)
{
if (c0.g < c0.b + 0.05 && c0.b < c0.g + 0.05)
{
red = 0.05;
blue = 0.7;
green = 0.7;
}
else if (c0.g > c0.b + 0.05)
{
red = 0.05;
blue = 0.05;
green = 0.7;
}
else if (c0.b > c0.g + 0.05)
{
red = 0.05;
blue = 0.7;
green = 0.05;
}
}
SetOutput(float4(red, green, blue, c0.a));
}

View File

@@ -0,0 +1,13 @@
void main()
{
float4 c0 = Sample();
// Same coefficients as grayscale2 at this point
float avg = (0.222 * c0.r) + (0.707 * c0.g) + (0.071 * c0.b);
float red=avg;
// Not sure about these coefficients, they just seem to produce the proper yellow
float green=avg*.75;
float blue=avg*.5;
SetOutput(float4(red, green, blue, c0.a));
}

View File

@@ -0,0 +1,17 @@
void main()
{
float4 c0 = Sample();
float4 tmp = float4(0.0, 0.0, 0.0, 0.0);
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 (GetCoordinates().y*GetResolution().y < 163.0)
tmp = float4(1.0, 1.0, 1.0, 1.0);
c0 = c0 + 1.0 - grey * 7.0;
SetOutput(float4(c0.r, c0.g, c0.b, 1.0));
}

View File

@@ -0,0 +1,18 @@
void main()
{
float4 c0 = Sample();
float red = 0.0;
float blue = 0.0;
if (c0.r < 0.35 || c0.b > 0.5)
{
red = c0.g + c0.b;
}
else
{
red = c0.g + c0.b;
blue = c0.r + c0.b;
}
SetOutput(float4(red, 0.0, blue, 1.0));
}

View File

@@ -0,0 +1,20 @@
void main()
{
float4 c0 = Sample();
float red = 0.0;
float green = 0.0;
float blue = 0.0;
if (c0.r < 0.35 || c0.b > 0.5)
{
red = c0.g + c0.b;
}
else
{
red = c0.g + c0.b;
blue = c0.r + c0.b;
green = c0.r + c0.b;
}
SetOutput(float4(red, green, blue, 1.0));
}

View File

@@ -0,0 +1,5 @@
void main()
{
float4 c0 = Sample();
SetOutput(float4(c0.r * 1.5, c0.g, c0.b * 0.5, c0.a));
}

View File

@@ -0,0 +1,4 @@
void main()
{
SetOutput(Sample().bgra);
}

View File

@@ -0,0 +1,4 @@
void main()
{
SetOutput(Sample().brga);
}

View File

@@ -0,0 +1,4 @@
void main()
{
SetOutput(Sample());
}

View File

@@ -0,0 +1,4 @@
void main()
{
SetOutput(Sample());
}

View File

@@ -0,0 +1,4 @@
void main()
{
SetOutput(Sample().rbga);
}

View File

@@ -0,0 +1,20 @@
void main()
{
float4 c0 = Sample();
float red = 0.0;
float green = 0.0;
float blue = 0.0;
if (c0.r < 0.3 || c0.b > 0.5)
{
blue = c0.r + c0.b;
red = c0.g + c0.b / 2.0;
}
else
{
red = c0.g + c0.b;
green = c0.r + c0.b;
}
SetOutput(float4(red, green, blue, 1.0));
}