added option for DoF to affect dither resolution

This commit is contained in:
Valerie Wolfe 2024-04-14 13:59:53 -04:00
parent aab1ed34ab
commit 6517f1e2b2
4 changed files with 15 additions and 3 deletions

View file

@ -1,6 +1,7 @@
#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 colorMode 0 // hsv/rgb [0 1]
@ -63,7 +64,9 @@ const int indexMatrix8x8[64] = int[](0, 32, 8, 40, 2, 34, 10, 42,
63, 31, 55, 23, 61, 29, 53, 21);
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;
#else
vec2 coord = gl_FragCoord.xy;

View file

@ -38,6 +38,10 @@ option.tWarp.comment=Emulates affine texture mapping responsible for warping tex
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=Chunk

View file

@ -1,5 +1,6 @@
//#define dof
#define dofRes
uniform float centerDepthSmooth;
uniform sampler2D depthtex1;
@ -9,11 +10,15 @@ const float centerDepthSmoothHalfLife = 16f;
vec2 depthOfField() {
float depth = texture2D(depthtex1, texcoord).x;
float distance = depth - centerDepthSmooth;
int stops = min(int(distance * 96), 5);
int stops = max(min(int(distance * 96), 5), 0);
float virtualSize = pow(float(pixelSize), 1 + stops);//1 + stops);
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;
}

View file

@ -19,7 +19,7 @@ screen.COLOR=colorMode dithering <empty> rgbSteps <empty> <empty> hueSteps satSt
screen.PSX=vWarp tWarp
# fx
screen.FX=dof worldCurvature
screen.FX=dof dofRes
# -- CONDITIONALS --
gbuffers_hand.enabled=tWarp