Compare commits

..

No commits in common. "main" and "color-depth" have entirely different histories.

17 changed files with 52 additions and 240 deletions

View file

@ -5,7 +5,6 @@ aimed at providing a variety of effects in the vein of its parent project.
## Features ## Features
- Affine Texture Warping
- Chromatic Aberration - Chromatic Aberration
- Color depth reduction - Color depth reduction
- Depth of Field - Depth of Field
@ -13,20 +12,13 @@ aimed at providing a variety of effects in the vein of its parent project.
- Downscaling - Downscaling
- Horizontal Blur - Horizontal Blur
- Interlacing - Interlacing
- Monochrome Mode & Palettes
- Scanlines - Scanlines
- Screen-Space Vertex Warping - Screen-Space Vertex Warping
- Affine Texture Warping
- World Curvature - World Curvature
## Screenshots
![2024-04-18_17 04 13](https://github.com/sleeplessval/aeon/assets/73970075/d2022abe-f39a-4e3d-a0d7-5b6d62147d9f)
![2024-04-11_12 58 13](https://github.com/sleeplessval/aeon/assets/73970075/7ced7d92-b032-4b5c-b314-d6fce4b0ed41)
![2024-04-17_11 09 10](https://github.com/sleeplessval/aeon/assets/73970075/b5c7b217-19de-45ca-8e1c-20002286997e)
![2024-04-21_21 16 47](https://github.com/sleeplessval/aeon/assets/73970075/26961585-845d-4054-9b5a-f0158d6fae9c)
## Acknowledgements ## Acknowledgements
- [Alex Charlton's post "Dithering on the GPU"](http://alex-charlton.com/posts/Dithering_on_the_GPU/). - [Alex Charlton's post "Dithering on the GPU"](http://alex-charlton.com/posts/Dithering_on_the_GPU/).
- [BSL Shaders by CaptainTatsu](https://bitslablab.com/bslshaders/). Combining downscale with dithering is the reason I forked a shader in the first place. - [BSL Shaders by CaptainTatsu](https://bitslablab.com/bslshaders/), whose downscale effect was my inspiration for forking a shader.

View file

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

View file

@ -4,6 +4,7 @@
//#define aberration //#define aberration
//#define hBlur //#define hBlur
//#define scanlines
varying vec2 texcoord; varying vec2 texcoord;
@ -12,36 +13,25 @@ uniform float viewWidth;
#include "/module/aberration.frag" #include "/module/aberration.frag"
#include "/module/horizontal_blur.frag" #include "/module/horizontal_blur.frag"
#include "/module/scanline.frag"
#include "/module/signal.frag"
void main() { void main() {
vec3 color; vec3 color;
// software post-processing effects
#ifdef hBlur #ifdef hBlur
color = hblur(); color = hblur();
#else #else
color = texture2D(gcolor, texcoord).rgb; color = texture2D(gcolor, texcoord).rgb;
#endif #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 #ifdef aberration
color.rb = (color.rb + aberrate().rb) / 2; color.rb = aberrate().rb;
#endif #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); 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.AEON=Aeon Upstream
profile.DOS=DOS profile.DOS=DOS
profile.DOTMATRIX=Dot Matrix Game profile.DOTMATRIX=Dot Matrix Game
profile.EIGHTBIT=8-bit profile.OBRADINN=Return of the Obra Dinn
profile.OBRADINN=Obra Dinn
profile.PSX=PSX profile.PSX=PSX
profile.REALITY=Project Reality profile.REALITY=Project Reality
profile.SNES=Super Famicom profile.SNES=Super Famicom
profile.VR32=VR32 profile.VR32=VR32
option.pixelSize=Downscaling option.pixelSize=Downscaling
value.pixelSize.1=Off value.pixelSize.1=Off
value.pixelSize.2=Low (2x) value.pixelSize.2=Low (2x)
@ -18,15 +16,11 @@ value.pixelSize.4=Medium (4x)
value.pixelSize.8=High (8x) value.pixelSize.8=High (8x)
value.pixelSize.16=Silly (16x) value.pixelSize.16=Silly (16x)
screen.COLOR=Color screen.COLOR=Color
option.colorMode=Color Mode option.colorMode=Color Mode
value.colorMode.0=HSV value.colorMode.0=HSV
value.colorMode.1=RGB value.colorMode.1=RGB
option.dithering=Dithering option.dithering=Dithering
option.colorDepth=RGB Depth option.colorDepth=RGB Depth
value.colorDepth.1=Monochrome value.colorDepth.1=Monochrome
value.colorDepth.3=3-bit value.colorDepth.3=3-bit
@ -36,13 +30,10 @@ value.colorDepth.12=12-bit
value.colorDepth.15=15-bit value.colorDepth.15=15-bit
value.colorDepth.18=18-bit value.colorDepth.18=18-bit
value.colorDepth.24=Truecolor value.colorDepth.24=Truecolor
option.monoPalette=Mono Palette option.monoPalette=Mono Palette
value.monoPalette.0=Black & White value.monoPalette.0=Black & White
value.monoPalette.1=Dot Matrix value.monoPalette.1=Dot Matrix
value.monoPalette.2=Paint the Town value.monoPalette.2=Paint the Town
value.monoPalette.3=Noir
option.hueBits=Hue Depth option.hueBits=Hue Depth
suffix.hueBits=-bit suffix.hueBits=-bit
option.satBits=Saturation Depth option.satBits=Saturation Depth
@ -50,32 +41,14 @@ suffix.satBits=-bit
option.valBits=Value Depth option.valBits=Value Depth
suffix.valBits=-bit suffix.valBits=-bit
screen.SCREEN=Screen 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.interlacing=Interlacing
option.scanlines=Scanlines
option.scanline=Scanlines
value.scanline.0=Off
value.scanline.1=Soft
value.scanline.2=Hard
option.aberration=Chromatic Aberration option.aberration=Chromatic Aberration
screen.CONSOLE=Consoles screen.CONSOLE=Consoles
screen.PSX=PSX (1994) screen.PSX=PSX (1994)
option.vWarp=Vertex Warping option.vWarp=Vertex Warping
option.vWarp.comment=Emulates screen-space vertex snapping responsible for vertex wobble on the Playstation option.vWarp.comment=Emulates screen-space vertex snapping responsible for vertex wobble on the Playstation
value.vWarp.0=Off value.vWarp.0=Off
@ -85,30 +58,24 @@ value.vWarp.4=Medium (4x)
value.vWarp.8=High (8x) value.vWarp.8=High (8x)
value.vWarp.16=Extreme (16x) value.vWarp.16=Extreme (16x)
value.vWarp.32=Silly (32x) value.vWarp.32=Silly (32x)
option.tWarp=Texture Warping option.tWarp=Texture Warping
option.tWarp.comment=Emulates affine texture mapping responsible for warping textures on the Playstation option.tWarp.comment=Emulates affine texture mapping responsible for warping textures on the Playstation
screen.REALITY=Project Reality (1996) screen.REALITY=Project Reality (1996)
option.hBlur=Horizontal Blur option.hBlur=Horizontal Blur
option.hBlur.comment=Emulates the blur responsible for reducing LCD clarity on the N64 option.hBlur.comment=Emulates the blur responsible for reducing LCD clarity on the N64
screen.FX=FX screen.FX=FX
option.dof=Depth of Field option.dof=Depth of Field
option.dof.comment=Downscale out-of-focus objects option.dof.comment=Downscale out-of-focus objects
option.dofRes=DoF Dither option.dofRes=DoF Dither
option.dofRes.comment=Whether DoF focus affects dither resolution. option.dofRes.comment=Whether DoF focus affects dither resolution.
value.dofRes.0=Static
value.dofRes.1=Dynamic
option.worldCurvature=World Curvature option.worldCurvature=World Curvature
value.worldCurvature.0=Off value.worldCurvature.0=Off
value.worldCurvature.1=Cylinder value.worldCurvature.1=Cylinder
value.worldCurvature.2=Round value.worldCurvature.2=Round
option.worldRadius=Curvature Strength option.worldRadius=Curvature Strength
value.worldRadius.1024=Low (1024) value.worldRadius.1024=Low (1024)
value.worldRadius.512=Medium (512) value.worldRadius.512=Medium (512)

View file

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

View file

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

View file

@ -8,16 +8,21 @@ float avg(float l, float c, float r) {
vec3 hblur() { vec3 hblur() {
vec3 center = texture2D(gcolor, texcoord).rgb; vec3 center = texture2D(gcolor, texcoord).rgb;
vec3 sum = vec3(0); vec2 leftPos = texcoord - neighborOffset;
int count = 0; vec2 rightPos = texcoord + neighborOffset;
for(int x = -2; x < 2; x++) {
vec2 pos = texcoord - (neighborOffset * x); vec3 left;
if(pos.x >= 0 && pos.x < viewWidth) { if(leftPos.x >= 0)
sum += texture2D(gcolor, pos).rgb; left = texture2D(gcolor, leftPos).rgb;
count++; else
} left = center;
}
vec3 right;
return sum / count; 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 worldCurvature 0 // [0 1 2]
#define worldRadius 512 // [1024 512 256 -256] #define worldRadius 512 // [1024 512 256 -256]
void world_curvature() { void world_curvature() {
#if worldCurvature == CURVATURE_CYLINDER #if worldCurvature == 1
float z = gl_Position.z * gl_Position.z; float z = gl_Position.z * gl_Position.z;
gl_Position.y -= 2 * z / worldRadius; gl_Position.y -= 2 * z / worldRadius;
#elif worldCurvature == CURVATURE_ROUND #elif worldCurvature == 2
vec2 xz = gl_Position.xz; vec2 xz = gl_Position.xz;
gl_Position.y -= round(( dot(xz, xz) / worldRadius ) * 8) / 8; gl_Position.y -= round(( dot(xz, xz) / worldRadius ) * 8) / 8;
#endif #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.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.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.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.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.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 profile.VR32=pixelSize=8 colorMode=1 !dithering colorDepth=1 monoPalette=2 vWarp=1 !tWarp !hBlur !interlacing
# -- SCREENS -- # -- SCREENS --
# default # default
screen=<profile> <empty> <empty> <empty> pixelSize <empty> [COLOR] [SCREEN] [CONSOLE] [FX] screen=<profile> <empty> pixelSize <empty> [COLOR] [SCREEN] [CONSOLE] [FX]
# colors # colors
screen.COLOR.columns=3 screen.COLOR.columns=3
screen.COLOR=colorMode dithering <empty> colorDepth <empty> monoPalette hueBits satBits valBits screen.COLOR=colorMode dithering <empty> colorDepth <empty> monoPalette hueBits satBits valBits
# screen effects # screen effects
screen.SCREEN=signal wire interlacing scanline <empty> <empty> aberration screen.SCREEN=interlacing scanlines aberration
# console effects # console effects
screen.CONSOLE.columns=1 screen.CONSOLE.columns=1
@ -29,7 +29,7 @@ screen.PSX=vWarp tWarp # playstation
screen.REALITY=hBlur # nintendo 64 screen.REALITY=hBlur # nintendo 64
# custom effects # custom effects
screen.FX=dof dofRes <empty> <empty> worldCurvature worldRadius screen.FX=dof dofRes worldCurvature worldRadius
# -- CONDITIONALS -- # -- CONDITIONALS --
gbuffers_hand.enabled=tWarp 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