Compare commits
5 commits
fc7bfab368
...
6249bd802b
Author | SHA1 | Date | |
---|---|---|---|
6249bd802b | |||
26f163cc60 | |||
605e54a522 | |||
375ccf3621 | |||
984db64c8c |
5 changed files with 100 additions and 26 deletions
|
@ -5,6 +5,7 @@ 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
|
||||||
|
@ -12,13 +13,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
|
||||||
|
|
||||||
## 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/), whose downscale effect was my inspiration for forking a shader.
|
- [BSL Shaders by CaptainTatsu](https://bitslablab.com/bslshaders/). Combining downscale with dithering is the reason I forked a shader in the first place.
|
||||||
|
|
||||||
|
|
|
@ -5,19 +5,13 @@
|
||||||
float renderRes = pixelSize;
|
float renderRes = pixelSize;
|
||||||
|
|
||||||
#define dithering // whether or not to apply dithering
|
#define dithering // whether or not to apply dithering
|
||||||
#define colorMode 0 // hsv/rgb [0 1]
|
|
||||||
|
|
||||||
#define hueSteps 4 // the number of hues to use [2 4 8 16 32 64]
|
|
||||||
#define satSteps 4 // the number of saturations to use [2 4 8 16 32 64]
|
|
||||||
#define valSteps 4 // the number of lightnesses to use [2 4 8 16 32 64]
|
|
||||||
|
|
||||||
#define rgbSteps 4 // the number of rgb values to use [2 4 8 16 32 64]
|
|
||||||
|
|
||||||
uniform sampler2D gcolor;
|
uniform sampler2D gcolor;
|
||||||
uniform float viewWidth, viewHeight;
|
uniform float viewWidth, viewHeight;
|
||||||
|
|
||||||
varying vec2 texcoord;
|
varying vec2 texcoord;
|
||||||
|
|
||||||
|
#include "/module/color_depth.frag"
|
||||||
#include "/module/dof.frag"
|
#include "/module/dof.frag"
|
||||||
#include "/module/interlace.frag"
|
#include "/module/interlace.frag"
|
||||||
|
|
||||||
|
@ -104,7 +98,7 @@ vec3[2] closestColors(float hue) {
|
||||||
}
|
}
|
||||||
|
|
||||||
float lightnessStep(float l, float lightnessSteps) {
|
float lightnessStep(float l, float lightnessSteps) {
|
||||||
/* Quantize the lightness to one of `lightnessSteps` values */
|
/* Quantize the lightness to one of `lightnessSteps` values */;
|
||||||
return floor((0.5 + l * (lightnessSteps - 1.0))) / (lightnessSteps - 1.0);
|
return floor((0.5 + l * (lightnessSteps - 1.0))) / (lightnessSteps - 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,20 +132,25 @@ void main() {
|
||||||
vec3 final;
|
vec3 final;
|
||||||
#ifdef dithering
|
#ifdef dithering
|
||||||
#if colorMode == 0
|
#if colorMode == 0
|
||||||
vec3 filtered = vec3(dither(color.x, hueSteps), dither(color.y, satSteps), dither(color.z, valSteps)).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, rgbSteps), dither(color.g, rgbSteps), dither(color.b, rgbSteps));
|
final = vec3(dither(color.r, colormax.x), dither(color.g, colormax.y), dither(color.b, colormax.z));
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
#if colorMode == 0
|
#if colorMode == 0
|
||||||
vec3 filtered = vec3(lightnessStep(color.x, hueSteps), lightnessStep(color.y, satSteps), lightnessStep(color.z, valSteps)).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
|
||||||
final = vec3(lightnessStep(color.r, rgbSteps), lightnessStep(color.g, rgbSteps), lightnessStep(color.b, rgbSteps)).rgb;
|
final = vec3(lightnessStep(color.r, colormax.x), lightnessStep(color.g, colormax.y), lightnessStep(color.b, colormax.z)).rgb;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if colorMode == 1 && colorDepth == 1
|
||||||
|
if(final.r == 1)
|
||||||
|
final = monoColor;
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef interlacing
|
#ifdef interlacing
|
||||||
/* DRAWBUFFERS:01 */
|
/* DRAWBUFFERS:01 */
|
||||||
// pull previous buffer
|
// pull previous buffer
|
||||||
|
|
|
@ -2,8 +2,11 @@
|
||||||
profile.DEFAULT=Default
|
profile.DEFAULT=Default
|
||||||
profile.AEON=Aeon Upstream
|
profile.AEON=Aeon Upstream
|
||||||
profile.DOS=DOS
|
profile.DOS=DOS
|
||||||
|
profile.DOTMATRIX=Dot Matrix Game
|
||||||
|
profile.OBRADINN=Return of the Obra Dinn
|
||||||
profile.PSX=PSX
|
profile.PSX=PSX
|
||||||
profile.REALITY=Project Reality
|
profile.REALITY=Project Reality
|
||||||
|
profile.SNES=Super Famicom
|
||||||
profile.VR32=VR32
|
profile.VR32=VR32
|
||||||
|
|
||||||
option.pixelSize=Downscaling
|
option.pixelSize=Downscaling
|
||||||
|
@ -18,10 +21,25 @@ 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.rgbSteps=RGB Depth
|
option.colorDepth=RGB Depth
|
||||||
option.hueSteps=Hue Depth
|
value.colorDepth.1=Monochrome
|
||||||
option.satSteps=Saturation Depth
|
value.colorDepth.3=3-bit
|
||||||
option.valSteps=Value Depth
|
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=Dot Matrix
|
||||||
|
value.monoPalette.2=Paint the Town
|
||||||
|
option.hueBits=Hue Depth
|
||||||
|
suffix.hueBits=-bit
|
||||||
|
option.satBits=Saturation Depth
|
||||||
|
suffix.satBits=-bit
|
||||||
|
option.valBits=Value Depth
|
||||||
|
suffix.valBits=-bit
|
||||||
|
|
||||||
screen.SCREEN=Screen
|
screen.SCREEN=Screen
|
||||||
option.interlacing=Interlacing
|
option.interlacing=Interlacing
|
||||||
|
|
53
shaders/module/color_depth.frag
Normal file
53
shaders/module/color_depth.frag
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
|
||||||
|
#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]
|
||||||
|
|
||||||
|
#if colorMode == 0
|
||||||
|
// -- 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 == 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
|
||||||
|
|
|
@ -1,12 +1,15 @@
|
||||||
sliders=pixelSize hueSteps satSteps valSteps rgbSteps vWarp worldRadius
|
sliders=pixelSize colorDepth hueBits satBits valBits vWarp worldRadius
|
||||||
|
|
||||||
# -- PROFILES --
|
# -- PROFILES --
|
||||||
profile.DEFAULT=pixelSize=2 colorMode=0 dithering hueSteps=4 satSteps=4 valSteps=4 vWarp=0 !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 hueSteps=8 satSteps=4 valSteps=4 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 rgbSteps=2 vWarp=1 !tWarp !hBlur !interlacing
|
profile.DOS=pixelSize=4 colorMode=1 dithering colorDepth=3 vWarp=1 !tWarp !hBlur !interlacing
|
||||||
profile.PSX=pixelSize=2 colorMode=1 !dithering rgbSteps=16 vWarp=2 tWarp !hBlur interlacing
|
profile.DOTMATRIX=pixelSize=4 colorMode=1 colorDepth=1 monoPalette=1 dithering vWarp=1 !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=profile.PSX vWarp=0 !tWarp hBlur interlacing
|
profile.REALITY=profile.PSX vWarp=0 !tWarp hBlur interlacing
|
||||||
profile.VR32=pixelSize=8 colorMode=0 !dithering hueSteps=2 satSteps=2 valSteps=2 vWarp=1 !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 --
|
# -- SCREENS --
|
||||||
# default
|
# default
|
||||||
|
@ -14,7 +17,7 @@ screen=<profile> <empty> pixelSize <empty> [COLOR] [SCREEN] [CONSOLE] [FX]
|
||||||
|
|
||||||
# colors
|
# colors
|
||||||
screen.COLOR.columns=3
|
screen.COLOR.columns=3
|
||||||
screen.COLOR=colorMode dithering <empty> rgbSteps <empty> <empty> hueSteps satSteps valSteps
|
screen.COLOR=colorMode dithering <empty> colorDepth <empty> monoPalette hueBits satBits valBits
|
||||||
|
|
||||||
# screen effects
|
# screen effects
|
||||||
screen.SCREEN=interlacing scanlines aberration
|
screen.SCREEN=interlacing scanlines aberration
|
||||||
|
|
Loading…
Reference in a new issue