Compare commits

..

28 commits

Author SHA1 Message Date
12b71f2bb9 fixed typos 2024-04-17 11:20:09 -04:00
c165897f43 cleaned up horizontal blur code 2024-04-17 10:54:58 -04:00
00fc6f7c9c hand is now excluded from world curvature 2024-04-15 22:17:25 -04:00
3f227382b6 updated README 2024-04-15 20:21:00 -04:00
780ba8df2a changed world curvature to be exclusive rather than inclusive 2024-04-15 17:20:57 -04:00
dd9fb8f196 merged in horizontal blur effect and restructured options menu 2024-04-15 17:17:43 -04:00
eb81a9426a Merge branch 'fx' into experimental 2024-04-15 16:07:49 -04:00
23f9b22013 initial implementation of horizontal blur 2024-04-14 18:52:46 -04:00
6be09aac47 fixed DoF not working with downscale off 2024-04-14 18:48:16 -04:00
3e9cb72a58 initial implementation of world curvature 2024-04-14 17:37:44 -04:00
4ed76c2ea2 updated README 2024-04-14 14:15:30 -04:00
ab10aaa2e3 added option for DoF to affect dither resolution 2024-04-14 13:59:53 -04:00
3b12a88a76 initial implementation of DoF 2024-04-14 13:28:52 -04:00
76e464acd8 added props and lang lines for curvature 2024-04-14 00:09:19 -04:00
8d26a45d92 added profiles to lang and added an Aeon profile 2024-04-13 14:01:16 -04:00
6a022f75a8 fixed a couple typos in properties file 2024-04-13 10:43:20 -04:00
bd533d07bd removed references to itemFix 2024-04-11 23:20:01 -04:00
b863da2358 added virtual boy preset 2024-04-11 22:18:54 -04:00
d6000bdbdd hand shader now uses modifier on texture warp 2024-04-11 22:02:36 -04:00
9c0ad3bee5 fixed another vertex warp typo 2024-04-11 21:37:40 -04:00
e20e313001 added vertex warp 1 to dos preset 2024-04-11 17:38:00 -04:00
2289e55754 fixed vertex warp function not working as expected 2024-04-11 17:23:01 -04:00
b88eafca56 Merge branch 'item-fix' into modules 2024-04-11 17:14:36 -04:00
6339df4ed5 fixed a syntax error in vertex warp module 2024-04-11 17:08:30 -04:00
2f41f19daf added lang support for item fix 2024-04-11 15:46:28 -04:00
8040b1a635 added held item exclusion option for texture warping 2024-04-11 15:44:45 -04:00
54495eb53f removed unused 'common' module 2024-04-11 15:38:00 -04:00
9a778ba357 started moving shareable code to modules 2024-04-11 14:59:46 -04:00
24 changed files with 243 additions and 43 deletions

View file

@ -1,15 +1,18 @@
# ɅEON 199X # ɅEON 199X
My fork of [Aeon Shader](https://github.com/slinkousart/aeon), aimed at A Minecraft demake shader and my fork of [SlinkousArt's Aeon Shader](https://github.com/slinkousart/aeon),
expanding its concept to other "retro" graphic effects. aimed at providing a variety of effects in the vein of its parent project.
## Features ## Features
- Color depth reduction - Color depth reduction
- Depth of Field
- Dithering - Dithering
- Downscaling - Downscaling
- PSX Vertex Warping - Horizontal Blur
- PSX Texture Warping - Screen-Space Vertex Warping
- Affine Texture Warping
- World Curvature
## Acknowledgements ## Acknowledgements

View file

@ -1,5 +1,8 @@
#version 120 #version 120
#define pixelSize 2 // the size of pixels [1 2 4 8 16]
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 colorMode 0 // hsv/rgb [0 1]
@ -9,14 +12,14 @@
#define rgbSteps 4 // the number of rgb values to use [2 4 8 16 32 64] #define rgbSteps 4 // the number of rgb values to use [2 4 8 16 32 64]
#define pixelSize 2 // the size of pixels [1 2 4 8 16]
uniform sampler2D gcolor; uniform sampler2D gcolor;
uniform sampler2D colortex1; uniform sampler2D colortex1;
uniform float viewWidth, viewHeight; uniform float viewWidth, viewHeight;
varying vec2 texcoord; varying vec2 texcoord;
#include "/module/dof.frag"
// All components are in the range [0…1], including hue. // All components are in the range [0…1], including hue.
vec3 rgb2hsv(vec3 c) vec3 rgb2hsv(vec3 c)
{ {
@ -61,7 +64,9 @@ const int indexMatrix8x8[64] = int[](0, 32, 8, 40, 2, 34, 10, 42,
63, 31, 55, 23, 61, 29, 53, 21); 63, 31, 55, 23, 61, 29, 53, 21);
float indexValue() { float indexValue() {
#if pixelSize > 1 #if defined(dof) && defined(dofRes)
vec2 coord = gl_FragCoord.xy / renderRes;
#elif pixelSize > 1
vec2 coord = gl_FragCoord.xy / pixelSize; vec2 coord = gl_FragCoord.xy / pixelSize;
#else #else
vec2 coord = gl_FragCoord.xy; vec2 coord = gl_FragCoord.xy;
@ -116,7 +121,9 @@ float dither(float color, float dithersteps) {
void main() { void main() {
// adjust texture coordinate based on pixel size if needed // adjust texture coordinate based on pixel size if needed
vec2 newcoord = texcoord; vec2 newcoord = texcoord;
#if pixelSize > 1 #ifdef dof
newcoord = depthOfField();
#elif pixelSize > 1
vec2 view = vec2(viewWidth, viewHeight) / float(pixelSize); vec2 view = vec2(viewWidth, viewHeight) / float(pixelSize);
float offset = (ceil(pixelSize * 0.5) - 0.5) / float(pixelSize); float offset = (ceil(pixelSize * 0.5) - 0.5) / float(pixelSize);
newcoord = (floor(newcoord * view) + offset) / view; newcoord = (floor(newcoord * view) + offset) / view;

View file

@ -1,8 +1,4 @@
#version 120 #version 120
varying vec2 texcoord; #include "/module/empty.vert"
void main() {
gl_Position = ftransform();
texcoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).xy;
}

21
shaders/final.fsh Normal file
View file

@ -0,0 +1,21 @@
#version 120
#define pixelSize // [1 2 4 8 16]
//#define hBlur
varying vec2 texcoord;
uniform sampler2D gcolor;
uniform float viewWidth;
#include "/module/horizontal_blur.frag"
void main() {
#ifdef hBlur
vec3 blurred = hblur();
gl_FragData[0] = vec4(blurred, 1);
#else
gl_FragData[0] = texture2D(gcolor, texcoord);
#endif
}

3
shaders/final.vsh Normal file
View file

@ -0,0 +1,3 @@
#version 120
#include "/module/empty.vert"

View file

@ -1,15 +1,4 @@
#version 120 #version 120
varying vec2 texcoord; #include "/module/empty.frag"
varying vec4 color;
varying vec2 lmcoord;
uniform sampler2D texture;
uniform sampler2D lightmap;
void main() {
vec4 final = texture2D(texture, texcoord) * color;
final *= texture2D(lightmap, lmcoord);
gl_FragData[0] = final;
}

View file

@ -1,8 +1,8 @@
#version 120 #version 120
#define pixelSize 2 // [1 2 4 8 16] #define pixelSize 2 // [1 2 4 8 16]
#define vWarp 0 // psx vertex warp [0 1 2 4 8 16 32]
//#define tWarp // psx texture warp #define worldCurvature 0 // [0 1 2]
varying vec2 texcoord; varying vec2 texcoord;
varying vec4 color; varying vec4 color;
@ -11,24 +11,26 @@ varying vec2 lmcoord;
uniform mat4 gbufferModelView, gbufferModelViewInverse; uniform mat4 gbufferModelView, gbufferModelViewInverse;
uniform float viewWidth, viewHeight; uniform float viewWidth, viewHeight;
#include "/module/vertex_warp.vert"
#include "/module/texture_warp.vert"
void main() { void main() {
texcoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).xy; texcoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).xy;
lmcoord = (gl_TextureMatrix[1] * gl_MultiTexCoord1).xy; lmcoord = (gl_TextureMatrix[1] * gl_MultiTexCoord1).xy;
color = gl_Color; color = gl_Color;
#if vWarp > 0 #if vWarp > 0
float mod = pixelSize * vWarp; vertex_warp();
vec2 screen = vec2(viewWidth / mod, viewHeight / mod);
vec4 position = gbufferModelViewInverse * gl_ModelViewMatrix * gl_Vertex;
vec2 nearest = round(position.xy / position.w * screen) / screen;
position.xy = nearest;
gl_Position = gl_ProjectionMatrix * gbufferModelView * position;
#else #else
gl_Position = ftransform(); gl_Position = ftransform();
#endif #endif
#ifdef tWarp #ifdef tWarp
gl_Position /= abs(gl_Position.w); texture_warp();
#endif
#ifndef NON_WORLD
#include "/module/world.vert"
#endif #endif
} }

View file

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

View file

@ -0,0 +1,2 @@
#define NON_WORLD
#include "/gbuffers_basic.vsh"

View file

@ -0,0 +1,4 @@
#version 120
#include "/module/empty.frag"

View file

@ -0,0 +1,6 @@
#define tWarp_mod 1.5
#define NON_WORLD
#include "/gbuffers_basic.vsh"

View file

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

View file

@ -0,0 +1,2 @@
#define NON_WORLD
#include "/gbuffers_basic.vsh"

View file

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

View file

@ -0,0 +1,2 @@
#define NON_WORLD
#include "/gbuffers_basic.vsh"

View file

@ -1,4 +1,11 @@
profile.DEFAULT=Default
profile.AEON=Aeon Upstream
profile.DOS=DOS
profile.PSX=PSX
profile.REALITY=Project Reality
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)
@ -16,9 +23,13 @@ option.hueSteps=Hue Depth
option.satSteps=Saturation Depth option.satSteps=Saturation Depth
option.valSteps=Value Depth option.valSteps=Value Depth
screen.PSX=PSX screen.SCREEN=Screen
screen.CONSOLE=Consoles
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 PSX option.vWarp.comment=Emulates screen-space vertex snapping responsible for vertex wobble on the Playstation
value.vWarp.0=Off value.vWarp.0=Off
value.vWarp.1=Minimal (1x) value.vWarp.1=Minimal (1x)
value.vWarp.2=Low (2x) value.vWarp.2=Low (2x)
@ -27,5 +38,21 @@ 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 PSX 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

28
shaders/module/dof.frag Normal file
View file

@ -0,0 +1,28 @@
//#define dof
#define dofRes
uniform float centerDepthSmooth;
uniform sampler2D depthtex1;
const float centerDepthSmoothHalfLife = 16f;
vec2 depthOfField() {
float depth = texture2D(depthtex1, texcoord).x;
float distance = depth - centerDepthSmooth;
int stops = max(min(int(distance * 96), 5), 0);
#if pixelSize > 1
float virtualSize = pow(float(pixelSize), 1 + stops);
#else
float virtualSize = pow(2f, stops);
#endif
vec2 view = vec2(viewWidth, viewHeight) / virtualSize;
float offset = (ceil(virtualSize * 0.5) - 0.5) / virtualSize;
#ifdef dofRes
renderRes = virtualSize;
#endif
return (floor(texcoord * view) + offset) / view;
}

15
shaders/module/empty.frag Normal file
View file

@ -0,0 +1,15 @@
// "empty" fragment shader
varying vec2 texcoord;
varying vec4 color;
varying vec2 lmcoord;
uniform sampler2D texture;
uniform sampler2D lightmap;
void main() {
vec4 final = texture2D(texture, texcoord) * color;
final *= texture2D(lightmap, lmcoord);
gl_FragData[0] = final;
}

View file

@ -0,0 +1,9 @@
// "empty" vertex shader
varying vec2 texcoord;
void main() {
gl_Position = ftransform();
texcoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).xy;
}

View file

@ -0,0 +1,28 @@
vec2 neighborOffset = vec2(1 / viewWidth, 0);
float avg(float l, float c, float r) {
return (l + c + r) / 3;
}
vec3 hblur() {
vec3 center = texture2D(gcolor, texcoord).rgb;
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

@ -0,0 +1,11 @@
//#define tWarp // psx texture warp
void texture_warp() {
#ifdef tWarp_mod
gl_Position /= abs(gl_Position.w + tWarp_mod);
#else
gl_Position /= abs(gl_Position.w);
#endif
}

View file

@ -0,0 +1,12 @@
#define vWarp 0 // psx vertex warp [0 1 2 4 8 16 32]
void vertex_warp() {
float mod = pixelSize * vWarp;
vec2 screen = vec2(viewWidth / mod, viewHeight / mod);
vec4 position = gbufferModelViewInverse * gl_ModelViewMatrix * gl_Vertex;
vec2 nearest = round(position.xy / position.w * screen) / screen;
position.xy = nearest;
gl_Position = gl_ProjectionMatrix * gbufferModelView * position;
}

View file

@ -0,0 +1,8 @@
#if worldCurvature == 1
float z = gl_Position.z * gl_Position.z;
gl_Position.y -= z / 256;
#elif worldCurvature == 2
vec2 xz = gl_Position.xz;
gl_Position.y -= ceil(( dot(xz, xz) * 5 ) / 512) / 5;
#endif

View file

@ -1,11 +1,33 @@
sliders=pixelSize hueSteps satSteps valSteps rgbSteps vWarp sliders=pixelSize hueSteps satSteps valSteps rgbSteps vWarp
profile.DEFAULT=pixelSize=2 colorMode=0 dithering hueSteps=4 satSteps=4 valSteps=4 vWarp=0 !tWarp # -- PROFILES --
profile.PSX=pixelsize=2 colorMode=1 !dithering rgbSteps=16 vWarp=2 tWarp profile.DEFAULT=pixelSize=2 colorMode=0 dithering hueSteps=4 satSteps=4 valSteps=4 vWarp=0 !tWarp !hBlur
profile.DOS=pixelSize=4 colorMode=1 dithering rgbSteps=2 vWarp=0 !tWarp profile.AEON=pixelSize=1 colorMode=0 dithering hueSteps=8 satSteps=4 valSteps=4 vWarp=0 !tWarp !hBlur
profile.DOS=pixelSize=4 colorMode=1 dithering rgbSteps=2 vWarp=1 !tWarp !hBlur
profile.PSX=pixelSize=2 colorMode=1 !dithering rgbSteps=16 vWarp=2 tWarp !hBlur
profile.REALITY=profile.PSX !tWarp hBlur
profile.VR32=pixelSize=8 colorMode=0 !dithering hueSteps=2 satSteps=2 valSteps=2 vWarp=1 !tWarp !hBlur
screen=<profile> <empty> pixelSize <empty> [COLOR] [PSX] # -- SCREENS --
# default
screen=<profile> <empty> pixelSize <empty> [COLOR] [SCREEN] [CONSOLE] [FX]
screen.COLOR=colorMode dithering rgbSteps <empty> hueSteps satSteps valSteps # colors
screen.PSX=vWarp tWarp screen.COLOR.columns=3
screen.COLOR=colorMode dithering <empty> rgbSteps <empty> <empty> hueSteps satSteps valSteps
# screen effects
screen.SCREEN=<empty>
# console effects
screen.CONSOLE.columns=1
screen.CONSOLE=[PSX] [REALITY]
screen.PSX=vWarp tWarp # playstation
screen.REALITY=hBlur # nintendo 64
# custom effects
screen.FX=dof dofRes worldCurvature
# -- CONDITIONALS --
gbuffers_hand.enabled=tWarp