Compare commits

..

No commits in common. "4ad3836b84250f1ab292d88ff1463b79bdaf5502" and "fcd88cd03b59a3a27354b0c1994a4fcad6fe8d01" have entirely different histories.

16 changed files with 49 additions and 229 deletions

View file

@ -125,20 +125,20 @@ void main() {
#endif
vec3 color = texture2D(gcolor, newcoord).rgb;
#if colorMode == MODE_HSV
#if colorMode == 0
color = rgb2hsv(color).xyz;
#endif
vec3 final;
#ifdef dithering
#if colorMode == MODE_HSV
#if colorMode == 0
vec3 filtered = vec3(dither(color.x, hueMax), dither(color.y, satMax), dither(color.z, valMax)).rgb;
final = hsv2rgb(filtered);
#else
final = vec3(dither(color.r, colormax.x), dither(color.g, colormax.y), dither(color.b, colormax.z));
#endif
#else
#if colorMode == MODE_HSV
#if colorMode == 0
vec3 filtered = vec3(lightnessStep(color.x, hueMax), lightnessStep(color.y, satMax), lightnessStep(color.z, valMax)).rgb;
final = hsv2rgb(filtered);
#else
@ -146,11 +146,9 @@ void main() {
#endif
#endif
#if colorMode == MODE_RGB && colorDepth == 1
#if colorMode == 1 && colorDepth == 1
if(final.r == 1)
final = monoHigh;
else
final = monoLow;
final = monoColor;
#endif
#ifdef interlacing

View file

@ -4,6 +4,7 @@
//#define aberration
//#define hBlur
//#define scanlines
varying vec2 texcoord;
@ -12,36 +13,25 @@ uniform float viewWidth;
#include "/module/aberration.frag"
#include "/module/horizontal_blur.frag"
#include "/module/scanline.frag"
#include "/module/signal.frag"
void main() {
vec3 color;
// software post-processing effects
#ifdef hBlur
color = hblur();
#else
color = texture2D(gcolor, texcoord).rgb;
#endif
#if scanline > 0
color = scanlines(color);
#endif
// hardware post-processing effects
#if signal == SIGNAL_NTSC
color = ntsc(color);
#elif signal == SIGNAL_PAL
color = pal(color);
#endif
// physical post-processing effects
#ifdef aberration
color.rb = (color.rb + aberrate().rb) / 2;
color.rb = aberrate().rb;
#endif
#ifdef scanlines
if(mod(int(gl_FragCoord.y / (pixelSize * 2)), 2) == 0)
color.rgb *= 0.95;
else
color.rgb /= 0.95;
#endif
gl_FragData[0] = vec4(color, 1);
}

View file

@ -1,10 +0,0 @@
#version 120
varying vec2 texcoord;
uniform sampler2D texture;
void main() {
gl_FragData[0] = texture2D(texture, texcoord);
}

View file

@ -1,3 +0,0 @@
#include "/gbuffers_basic.vsh"

View file

@ -3,14 +3,12 @@ profile.DEFAULT=Default
profile.AEON=Aeon Upstream
profile.DOS=DOS
profile.DOTMATRIX=Dot Matrix Game
profile.EIGHTBIT=8-bit
profile.OBRADINN=Obra Dinn
profile.PSX=PSX
profile.REALITY=Project Reality
profile.SNES=Super Famicom
profile.VR32=VR32
option.pixelSize=Downscaling
value.pixelSize.1=Off
value.pixelSize.2=Low (2x)
@ -18,15 +16,11 @@ value.pixelSize.4=Medium (4x)
value.pixelSize.8=High (8x)
value.pixelSize.16=Silly (16x)
screen.COLOR=Color
option.colorMode=Color Mode
value.colorMode.0=HSV
value.colorMode.1=RGB
option.dithering=Dithering
option.colorDepth=RGB Depth
value.colorDepth.1=Monochrome
value.colorDepth.3=3-bit
@ -36,13 +30,10 @@ value.colorDepth.12=12-bit
value.colorDepth.15=15-bit
value.colorDepth.18=18-bit
value.colorDepth.24=Truecolor
option.monoPalette=Mono Palette
value.monoPalette.0=Black & White
value.monoPalette.1=Dot Matrix
value.monoPalette.2=Paint the Town
value.monoPalette.3=Noir
option.hueBits=Hue Depth
suffix.hueBits=-bit
option.satBits=Saturation Depth
@ -50,32 +41,14 @@ suffix.satBits=-bit
option.valBits=Value Depth
suffix.valBits=-bit
screen.SCREEN=Screen
option.signal=Encoding
value.signal.0=None
value.signal.1=NTSC
value.signal.2=PAL
option.wire=Connector
value.wire.0=Composite
value.wire.1=S-Video
option.interlacing=Interlacing
option.scanline=Scanlines
value.scanline.0=Off
value.scanline.1=Soft
value.scanline.2=Hard
option.scanlines=Scanlines
option.aberration=Chromatic Aberration
screen.CONSOLE=Consoles
screen.PSX=PSX (1994)
option.vWarp=Vertex Warping
option.vWarp.comment=Emulates screen-space vertex snapping responsible for vertex wobble on the Playstation
value.vWarp.0=Off
@ -85,30 +58,24 @@ value.vWarp.4=Medium (4x)
value.vWarp.8=High (8x)
value.vWarp.16=Extreme (16x)
value.vWarp.32=Silly (32x)
option.tWarp=Texture Warping
option.tWarp.comment=Emulates affine texture mapping responsible for warping textures on the Playstation
screen.REALITY=Project Reality (1996)
option.hBlur=Horizontal Blur
option.hBlur.comment=Emulates the blur responsible for reducing LCD clarity on the N64
screen.FX=FX
option.dof=Depth of Field
option.dof.comment=Downscale out-of-focus objects
option.dofRes=DoF Dither
option.dofRes.comment=Whether DoF focus affects dither resolution.
value.dofRes.0=Static
value.dofRes.1=Dynamic
option.worldCurvature=World Curvature
value.worldCurvature.0=Off
value.worldCurvature.1=Cylinder
value.worldCurvature.2=Round
option.worldRadius=Curvature Strength
value.worldRadius.1024=Low (1024)
value.worldRadius.512=Medium (512)

View file

@ -2,9 +2,9 @@
vec2 caOffset = vec2(2 * pixelSize / viewWidth, 0);
vec3 aberrate() {
vec2 offset = caOffset * cos(texcoord * 3.14);
float red = texture2D(gcolor, texcoord + offset).r;
float blue = texture2D(gcolor, texcoord - offset).b;
vec2 offset = caOffset * abs(cos(texcoord * 3.14));
float red = texture2D(gcolor, texcoord - offset).r;
float blue = texture2D(gcolor, texcoord + offset).b;
return vec3(red, 0, blue);
}

View file

@ -1,6 +1,4 @@
#include "/var/color_depth.glsl"
#define colorMode 0 // [0 1]
#define hueBits 2 // [1 2 3 4 5 6 7 8]
@ -8,9 +6,9 @@
#define valBits 2 // [1 2 3 4 5 6 7 8]
#define colorDepth 6 // [1 3 6 8 12 15 18 24]
#define monoPalette 0 // [0 1 2 3]
#define monoPalette 0 // [0 1 2]
#if colorMode == MODE_HSV
#if colorMode == 0
// -- HSV --
float bit_max(int bits) {
@ -43,18 +41,12 @@
vec3 colormax = vec3(256, 256, 256);
#endif
#if monoPalette == MONOCHROME_BW
vec3 monoHigh = vec3(1);
vec3 monoLow = vec3(0);
#elif monoPalette == MONOCHROME_DOTMATRIX
vec3 monoHigh = vec3(0.31, 0.40, 0.03);
vec3 monoLow = vec3(0.17, 0.29, 0.13);
#elif monoPalette == MONOCHROME_MOTIONSICK
vec3 monoHigh = vec3(1, 0, 0);
vec3 monoLow = vec3(0);
#elif monoPalette == MONOCHROME_NOIR
vec3 monoHigh = vec3(0.73, 0.67, 0.55);
vec3 monoLow = vec3(0.26, 0.23, 0.19);
#if monoPalette == 0
vec3 monoColor = vec3(1, 1, 1);
#elif monoPalette == 1
vec3 monoColor = vec3(0.48, 0.72, 0.28);
#elif monoPalette == 2
vec3 monoColor = vec3(1, 0, 0);
#endif
#endif

View file

@ -8,16 +8,21 @@ float avg(float l, float c, float r) {
vec3 hblur() {
vec3 center = texture2D(gcolor, texcoord).rgb;
vec3 sum = vec3(0);
int count = 0;
for(int x = -2; x < 2; x++) {
vec2 pos = texcoord - (neighborOffset * x);
if(pos.x >= 0 && pos.x < viewWidth) {
sum += texture2D(gcolor, pos).rgb;
count++;
}
}
return sum / count;
vec2 leftPos = texcoord - neighborOffset;
vec2 rightPos = texcoord + neighborOffset;
vec3 left;
if(leftPos.x >= 0)
left = texture2D(gcolor, leftPos).rgb;
else
left = center;
vec3 right;
if(rightPos.x >= 0)
right = texture2D(gcolor, rightPos).rgb;
else
right = center;
return vec3(avg(left.r, center.r, right.r), avg(left.g, center.g, right.g), avg(left.b, center.b, right.b));
}

View file

@ -1,18 +0,0 @@
#include "/var/scanline.glsl"
#define scanline 0 // [0 1 2]
vec3 scanlines(vec3 color) {
#if scanline == SCANLINE_SOFT
if(mod(int(gl_FragCoord.y / pixelSize * 2), 2) == 0)
color.rgb *= 0.95;
else
color.rgb /= 0.95;
#elif scanline == SCANLINE_HARD
if(mod(int(gl_FragCoord.y / pixelSize), 2) == 0)
color.rgb *= 0.5;
#endif
return color;
}

View file

@ -1,69 +0,0 @@
#include "/var/signal.glsl"
#define signal 0 // [0 1 2]
#define wire 0 // [0 1]
float luminance(vec3 color) {
return dot(color, vec3(0.299, 0.587, 0.114));
}
vec3 ntsc(vec3 color) {
// convert to YIQ
float y = luminance(color);
float i = dot(color, vec3(0.596, -.274, -.322));
float q = dot(color, vec3(0.211, -.523, 0.312));
// faux ntsc signal
float carrier = 6.283 * 3.570 * gl_FragCoord.x; // 2π * 3.57MHz * x
float phase = sin(carrier) * i + cos(carrier) * q;
float quad = cos(carrier) * i - sin(carrier) * q;
// decode faux signal
#if wire == WIRE_COMPOSITE
float composite = phase + (y * 5.500); // p + (y * 5.5MHz)
y = round(composite * 5.500) / 30.250;
phase = composite - quad - (y * 5.500);
quad = composite - phase - (y * 5.500);
#endif
i = quad * cos(carrier);
q = phase * sin(carrier);
// convert back to RGB
vec3 yiqColor = vec3(y, i, q);
float r = dot(yiqColor, vec3(1, 0.956, 0.619));
float g = dot(yiqColor, vec3(1, -.272, -.674));
float b = dot(yiqColor, vec3(1, -1.106, 1.703));
return vec3(r, g, b).rgb;
}
vec3 pal(vec3 color) {
// convert to YUV
float y = luminance(color);
float u = 0.492 * (color.b - y);
float v = 0.877 * (color.r - y);
// faux pal signal
float carrier = 6.283 * 4.434;
float phase = sin(carrier) * u - cos(carrier) * v;
float quad = cos(carrier) * u - sin(carrier) * v;
// decode faux signal
#if wire == WIRE_COMPOSITE
float composite = y + phase;
#endif
u = quad * cos(carrier);
v = phase * sin(carrier);
// convert back to RGB
vec3 yuvColor = vec3(y, u, v);
float r = y + (1.140 * v);
float g = y - (0.395 * u) - (0.581 * v);
float b = y + (2.033 * u);
return vec3(r, g, b).rgb;
}

View file

@ -1,14 +1,12 @@
#include "/var/world.glsl"
#define worldCurvature 0 // [0 1 2]
#define worldRadius 512 // [1024 512 256 -256]
void world_curvature() {
#if worldCurvature == CURVATURE_CYLINDER
#if worldCurvature == 1
float z = gl_Position.z * gl_Position.z;
gl_Position.y -= 2 * z / worldRadius;
#elif worldCurvature == CURVATURE_ROUND
#elif worldCurvature == 2
vec2 xz = gl_Position.xz;
gl_Position.y -= round(( dot(xz, xz) / worldRadius ) * 8) / 8;
#endif

View file

@ -5,22 +5,22 @@ profile.DEFAULT=pixelSize=2 colorMode=0 dithering hueBits=2 satBits=2 valBits=2
profile.AEON=pixelSize=1 colorMode=0 dithering hueBits=3 satBits=2 valBits=2 vWarp=0 !tWarp !hBlur !interlacing
profile.DOS=pixelSize=4 colorMode=1 dithering colorDepth=3 vWarp=1 !tWarp !hBlur !interlacing
profile.DOTMATRIX=pixelSize=4 colorMode=1 colorDepth=1 monoPalette=1 dithering vWarp=1 !tWarp !hBlur !interlacing
profile.EIGHTBIT=pixelSize=4 colorMode=1 dithering colorDepth=8 vWarp=0 !tWarp !hBlur !interlacing
profile.OBRADINN=pixelSize=2 colorMode=1 colorDepth=1 monoPalette=0 dithering vWarp=0 !tWarp !hBlur !interlacing
profile.PSX=pixelSize=2 colorMode=1 !dithering colorDepth=24 vWarp=2 tWarp !hBlur interlacing
profile.REALITY=pixelSize=2 colorMode=1 colorDepth=15 !dithering vWarp=0 !tWarp hBlur interlacing
profile.REALITY=profile.PSX vWarp=0 !tWarp hBlur interlacing
profile.SNES=pixelSize=4 colorMode=1 dithering colorDepth=15 vWarp=1 !tWarp !hBlur interlacing
profile.VR32=pixelSize=8 colorMode=1 !dithering colorDepth=1 monoPalette=2 vWarp=1 !tWarp !hBlur !interlacing
# -- SCREENS --
# default
screen=<profile> <empty> <empty> <empty> pixelSize <empty> [COLOR] [SCREEN] [CONSOLE] [FX]
screen=<profile> <empty> pixelSize <empty> [COLOR] [SCREEN] [CONSOLE] [FX]
# colors
screen.COLOR.columns=3
screen.COLOR=colorMode dithering <empty> colorDepth <empty> monoPalette hueBits satBits valBits
# screen effects
screen.SCREEN=signal wire interlacing scanline <empty> <empty> aberration
screen.SCREEN=interlacing scanlines aberration
# console effects
screen.CONSOLE.columns=1
@ -29,7 +29,7 @@ screen.PSX=vWarp tWarp # playstation
screen.REALITY=hBlur # nintendo 64
# custom effects
screen.FX=dof dofRes <empty> <empty> worldCurvature worldRadius
screen.FX=dof dofRes worldCurvature worldRadius
# -- CONDITIONALS --
gbuffers_hand.enabled=tWarp

View file

@ -1,11 +0,0 @@
// color mode IDs
#define MODE_HSV 0
#define MODE_RGB 1
// monochrome palette IDs
#define MONOCHROME_BW 0
#define MONOCHROME_DOTMATRIX 1
#define MONOCHROME_MOTIONSICK 2
#define MONOCHROME_NOIR 3

View file

@ -1,5 +0,0 @@
#define SCANLINE_SOFT 1
#define SCANLINE_HARD 2
#define SCANLINE_STRETCH 3

View file

@ -1,8 +0,0 @@
#define SIGNAL_RGB 0
#define SIGNAL_NTSC 1
#define SIGNAL_PAL 2
#define WIRE_COMPOSITE 0
#define WIRE_SVIDEO 1

View file

@ -1,6 +0,0 @@
// world curvature IDs
#define CURVATURE_OFF 0
#define CURVATURE_CYLINDER 1
#define CURVATURE_ROUND 2