Compare commits

...

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

9 changed files with 150 additions and 195 deletions

View file

@ -20,10 +20,10 @@ aimed at providing a variety of effects in the vein of its parent project.
## Screenshots
![Default preset with DoF](https://github.com/sleeplessval/aeon/assets/73970075/d2022abe-f39a-4e3d-a0d7-5b6d62147d9f)
![DOS preset](https://github.com/sleeplessval/aeon/assets/73970075/7ced7d92-b032-4b5c-b314-d6fce4b0ed41)
![N64 preset](https://github.com/user-attachments/assets/589d0405-9cb9-4944-9e71-d8db9fc560d4)
![GameBoy preset](https://github.com/user-attachments/assets/7c5a2f50-f2ee-45f2-8f15-01ce8ce8bcaa)
![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

View file

@ -11,10 +11,31 @@ uniform float viewWidth, viewHeight;
varying vec2 texcoord;
#include "/module/color.frag"
#include "/module/color_depth.frag"
#include "/module/dof.frag"
#include "/module/interlace.frag"
// All components are in the range [0…1], including hue.
vec3 rgb2hsv(vec3 c)
{
vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));
vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));
float d = q.x - min(q.w, q.y);
float e = 1.0e-10;
return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
}
// All components are in the range [0…1], including hue.
vec3 hsv2rgb(vec3 c)
{
vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
}
const float steps = 4.0;
uniform vec3 palette[8];
@ -103,14 +124,34 @@ void main() {
newcoord = (floor(newcoord * view) + offset) / view;
#endif
vec3 color = texture2D(gcolor, newcoord).rgb;
color = to(color).xyz;
#ifdef dithering
vec3 final = vec3(dither(color.x, firstMax), dither(color.y, secondMax), dither(color.z, thirdMax)).rgb;
#else
vec3 final = vec3(lightnessStep(color.x, firstMax), lightnessStep(color.y, secondMax), lightnessStep(color.z, thirdMax)).rgb;
#endif
final = from(final);
#if colorMode == MODE_HSV
color = rgb2hsv(color).xyz;
#endif
vec3 final;
#ifdef dithering
#if colorMode == MODE_HSV
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
vec3 filtered = vec3(lightnessStep(color.x, hueMax), lightnessStep(color.y, satMax), lightnessStep(color.z, valMax)).rgb;
final = hsv2rgb(filtered);
#else
final = vec3(lightnessStep(color.r, colormax.x), lightnessStep(color.g, colormax.y), lightnessStep(color.b, colormax.z)).rgb;
#endif
#endif
#if colorMode == MODE_RGB && colorDepth == 1
if(final.r == 1)
final = monoHigh;
else
final = monoLow;
#endif
#ifdef interlacing
/* DRAWBUFFERS:01 */

View file

@ -2,7 +2,7 @@
profile.DEFAULT=Default
profile.AEON=Aeon Upstream
profile.DOS=DOS
profile.DOTMATRIX=DMG-01
profile.DOTMATRIX=Dot Matrix Game
profile.EIGHTBIT=8-bit
profile.OBRADINN=Obra Dinn
profile.PSX=PSX
@ -22,28 +22,26 @@ value.pixelSize.16=Silly (16x)
screen.COLOR=Color
option.colorMode=Color Mode
value.colorMode.0=RGB
value.colorMode.1=HSV
value.colorMode.2=YIQ
value.colorMode.3=YUV
value.colorMode.4=Mono
value.colorMode.0=HSV
value.colorMode.1=RGB
option.dithering=Dithering
option.firstBits=First Value
suffix.firstBits=-bit
option.secondBits=Second Value
suffix.secondBits=-bit
option.thirdBits=Third Value
suffix.thirdBits=-bit
option.colorDepth=RGB Depth
value.colorDepth.1=Monochrome
value.colorDepth.3=3-bit
value.colorDepth.6=6-bit
value.colorDepth.8=8-bit
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=DameGame
value.monoPalette.1=Dot Matrix
value.monoPalette.2=Paint the Town
value.monoPalette.3=Noir
value.monoPalette.4=Amber Phosphor
value.monoPalette.5=Green Phosphor
option.hueBits=Hue Depth
suffix.hueBits=-bit

View file

@ -1,135 +0,0 @@
#include "/var/color.glsl"
#define colorMode 1 // [0 1 2 3 4]
#define firstBits 2 // [0 1 2 3 4 5 6 7 8]
#define secondBits 2 // [0 1 2 3 4 5 6 7 8]
#define thirdBits 2 // [0 1 2 3 4 5 6 7 8]
#define monoPalette 0 // [0 1 2 3 4 5]
float bit_max(int bits) { return pow(2, bits); }
float firstMax = bit_max(firstBits);
#if colorMode == COLOR_MONO
float secondMax = firstMax;
float thirdMax = firstMax;
#else
float secondMax = bit_max(secondBits);
float thirdMax = bit_max(thirdBits);
#endif
#if monoPalette == MONO_BW
vec3 monoHigh = vec3(1);
vec3 monoLow = vec3(0);
#elif monoPalette == MONO_DAMEGAME
vec3 monoHigh = vec3(0.31, 0.40, 0.03);
vec3 monoLow = vec3(0.17, 0.29, 0.13);
#elif monoPalette == MONO_MOTIONSICK
vec3 monoHigh = vec3(1, 0, 0);
vec3 monoLow = vec3(0);
#elif monoPalette == MONO_NOIR
vec3 monoHigh = vec3(0.73, 0.67, 0.55);
vec3 monoLow = vec3(0.26, 0.23, 0.19);
#elif monoPalette == MONO_AMBER
vec3 monoHigh = vec3(1.00, 0.50, 0.00);
vec3 monoLow = vec3(0);
#elif monoPalette == MONO_PHOSPHOR
vec3 monoHigh = vec3(0.00, 0.83, 0.43);
vec3 monoLow = vec3(0);
#endif
float luminance(vec3 color) {
return dot(color, vec3(0.299, 0.587, 0.114));
}
vec3 toHsv(vec3 rgb) {
vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
vec4 p = mix(vec4(rgb.bg, K.wz), vec4(rgb.gb, K.xy), step(rgb.b, rgb.g));
vec4 q = mix(vec4(p.xyw, rgb.r), vec4(rgb.r, p.yzx), step(p.x, rgb.r));
float d = q.x - min(q.w, q.y);
float e = 1.0e-10;
return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
}
vec3 fromHsv(vec3 hsv) {
vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
vec3 p = abs(fract(hsv.xxx + K.xyz) * 6 - K.www);
return hsv.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), hsv.y);
}
vec3 toYiq(vec3 rgb) {
float y = luminance(rgb);
float i = dot(rgb, vec3(0.596, -.274, -.322));
float q = dot(rgb, vec3(0.211, -.523, 0.312));
return vec3(y, i, q);
}
vec3 fromYiq(vec3 yiq) {
float r = dot(yiq, vec3(1, 0.956, 0.619));
float g = dot(yiq, vec3(1, -.272, -.674));
float b = dot(yiq, vec3(1, -1.106, 1.703));
return vec3(r, g, b);
}
vec3 toYuv(vec3 rgb) {
float y = luminance(rgb);
float u = 0.492 * (rgb.b - y);
float v = 0.877 * (rgb.r - y);
return vec3(y, u, v);
}
vec3 fromYuv(vec3 yuv) {
float r = yuv.x + (1.140 * yuv.z);
float g = yuv.x - (0.395 * yuv.y) - (0.581 * yuv.z);
float b = yuv.x + (2.033 * yuv.y);
return vec3(r, g, b);
}
vec3 toMono(vec3 rgb) {
float luma = luminance(rgb);
return vec3(luma, luma, luma);
}
vec3 fromMono(vec3 mono) {
return (mono.x * (monoHigh - monoLow)) + monoLow;
}
vec3 to(vec3 rgb) {
#if colorMode == COLOR_RGB
return rgb;
#elif colorMode == COLOR_HSV
return toHsv(rgb);
#elif colorMode == COLOR_YIQ
return toYiq(rgb);
#elif colorMode == COLOR_YUV
return toYuv(rgb);
#elif colorMode == COLOR_MONO
return toMono(rgb);
#endif
}
vec3 from(vec3 color) {
#if colorMode == COLOR_RGB
return color;
#elif colorMode == COLOR_HSV
return fromHsv(color);
#elif colorMode == COLOR_YIQ
return fromYiq(color);
#elif colorMode == COLOR_YUV
return fromYuv(color);
#elif colorMode == COLOR_MONO
return fromMono(color);
#endif
}

View file

@ -0,0 +1,61 @@
#include "/var/color_depth.glsl"
#define colorMode 0 // [0 1]
#define hueBits 2 // [1 2 3 4 5 6 7 8]
#define satBits 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 monoPalette 0 // [0 1 2 3]
#if colorMode == MODE_HSV
// -- HSV --
float bit_max(int bits) {
return pow(2, bits);
}
float hueMax = bit_max(hueBits);
float satMax = bit_max(satBits);
float valMax = bit_max(valBits);
#else
// -- RGB --
#if colorDepth == 1
vec3 colormax = vec3(2, 1, 1);
#elif colorDepth == 3
vec3 colormax = vec3(2, 2, 2);
#elif colorDepth == 6
vec3 colormax = vec3(4, 4, 4);
#elif colorDepth == 8
// 8-bit is 3:3:2
vec3 colormax = vec3(8, 8, 4);
#elif colorDepth == 12
vec3 colormax = vec3(16, 16, 16);
#elif colorDepth == 15
vec3 colormax = vec3(32, 32, 32);
#elif colorDepth == 18
vec3 colormax = vec3(64, 64, 64);
#elif colorDepth == 24
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);
#endif
#endif

View file

@ -15,11 +15,7 @@ vec3 ntsc(vec3 color) {
float q = dot(color, vec3(0.211, -.523, 0.312));
// faux ntsc signal
float carrier = 22.430; // 2π * 3.57MHz
#if wire == WIRE_COMPOSITE
carrier *= gl_FragCoord.x;
#endif
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;
@ -57,7 +53,6 @@ vec3 pal(vec3 color) {
// decode faux signal
#if wire == WIRE_COMPOSITE
float composite = y + phase;
// TODO: composite
#endif
u = quad * cos(carrier);
v = phase * sin(carrier);

View file

@ -1,15 +1,15 @@
sliders=pixelSize firstBits secondBits thirdBits vWarp worldRadius
sliders=pixelSize colorDepth hueBits satBits valBits vWarp worldRadius
# -- PROFILES --
profile.DEFAULT=pixelSize=2 colorMode=1 dithering firstBits=2 secondBits=2 thirdBits=2 vWarp=0 !tWarp !hBlur !interlacing
profile.AEON=pixelSize=1 colorMode=1 dithering firstBits=3 secondBits=2 thirdBits=2 vWarp=0 !tWarp !hBlur !interlacing
profile.DOS=pixelSize=4 colorMode=0 dithering firstBits=1 secondBits=1 thirdBits=1 vWarp=1 !tWarp !hBlur !interlacing
profile.DOTMATRIX=pixelSize=4 colorMode=4 dithering firstBits=2 monoPalette=1 dithering vWarp=1 !tWarp !hBlur !interlacing
profile.EIGHTBIT=pixelSize=2 colorMode=0 !dithering firstBits=3 secondBits=3 thirdBits=2 vWarp=0 !tWarp !hBlur !interlacing
profile.OBRADINN=pixelSize=2 colorMode=4 dithering firstBits=1 monoPalette=0 vWarp=0 !tWarp !hBlur !interlacing
profile.PSX=pixelSize=2 colorMode=0 !dithering firstBits=8 secondBits=8 thirdBits=8 vWarp=2 tWarp !hBlur interlacing
profile.REALITY=pixelSize=2 colorMode=0 dithering firstBits=5 secondBits=5 thirdBits=5 !dithering vWarp=0 !tWarp hBlur interlacing
profile.VR32=pixelSize=8 colorMode=4 !dithering firstBits=2 monoPalette=2 vWarp=1 !tWarp !hBlur !interlacing
profile.DEFAULT=pixelSize=2 colorMode=0 dithering hueBits=2 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.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.VR32=pixelSize=8 colorMode=1 !dithering colorDepth=1 monoPalette=2 vWarp=1 !tWarp !hBlur !interlacing
# -- SCREENS --
# default
@ -17,7 +17,7 @@ screen=<profile> <empty> <empty> <empty> pixelSize <empty> [COLOR] [SCREEN] [CON
# colors
screen.COLOR.columns=3
screen.COLOR=colorMode dithering <empty> firstBits secondBits thirdBits monoPalette
screen.COLOR=colorMode dithering <empty> colorDepth <empty> monoPalette hueBits satBits valBits
# screen effects
screen.SCREEN=signal wire interlacing scanline <empty> <empty> aberration

View file

@ -1,16 +0,0 @@
// colorspace IDs
#define COLOR_RGB 0 // RGB colorspace
#define COLOR_HSV 1 // HSV colorspace
#define COLOR_YIQ 2 // YIQ colorspace
#define COLOR_YUV 3 // YUV colorspace
#define COLOR_MONO 4 // Monochrome
// monochrome palette IDs
#define MONO_BW 0
#define MONO_DAMEGAME 1
#define MONO_MOTIONSICK 2
#define MONO_NOIR 3
#define MONO_AMBER 4
#define MONO_PHOSPHOR 5

View file

@ -0,0 +1,11 @@
// 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