Play around with upscaling pixel filtering

This commit is contained in:
2025-11-25 21:59:49 +00:00
parent 4cc8f05407
commit 331d0cce73
4 changed files with 30 additions and 9 deletions
+23 -7
View File
@@ -3,19 +3,35 @@ in vec2 vTexPos;
out vec4 fColor; out vec4 fColor;
layout (location = 0) uniform vec2 screensize; layout (location = 0) uniform vec2 screensize;
layout(binding = 0) uniform sampler2D screenTexture; layout(binding = 0) uniform sampler2D screenTexture;
float xoff = 2 / screensize.x;
float yoff = 2 / screensize.y;
vec3 f (float x, float y) vec3 f (float x, float y)
{ return texture(screenTexture, vTexPos + vec2(x*xoff,y*yoff)).xyz; //{ return texture(screenTexture, vTexPos + vec2((x+0.5)/screensize.x,(y+0.5)/screensize.y)).xyz;
{ return texture(screenTexture, vTexPos + vec2(x/screensize.x,y/screensize.y)).xyz;
}
bool t (vec3 x, vec3 y)
{ return dot(x-y,x-y) < 0.1;
}
bool t3 (vec3 x, vec3 y, vec3 z)
{ return t(x,y) && t(y,z);
} }
void main() void main()
{ {
vec3 tl = f(-1, 1); vec3 tl = f(-1, 1);
vec3 tt = f( 0, 1); vec3 tt = f( 0, 2);
vec3 tr = f( 1, 1); vec3 tr = f( 1, 1);
vec3 mr = f( 1, 0); vec3 mr = f( 2, 0);
vec3 br = f( 1,-1); vec3 br = f( 1,-1);
if (tl == tt && tt == tr && tr == mr && mr == br) vec3 bb = f( 0,-2);
vec3 bl = f(-1,-1);
vec3 ml = f(-2, 0);
if (t3(tt,tr,mr))
{ fColor = vec4(tr,1);}
else if (t3(mr,br,bb))
{ fColor = vec4(br,1);}
else if (t3(bb,bl,ml))
{ fColor = vec4(bl,1);}
else if (t3(ml,tl,tt))
{ fColor = vec4(tl,1);} { fColor = vec4(tl,1);}
else {fColor = texture(screenTexture, vTexPos); } else
//{fColor = texture(screenTexture, vTexPos); }
{fColor = vec4(f(0,0),1); }
} }
+2
View File
@@ -49,6 +49,7 @@ data Config = Config
{ _volume_master :: Float { _volume_master :: Float
, _volume_sound :: Float , _volume_sound :: Float
, _volume_music :: Float , _volume_music :: Float
, _gr_upscale_filter :: Bool
, _gr_cloud_shadows :: Bool , _gr_cloud_shadows :: Bool
, _gr_distortions :: Bool , _gr_distortions :: Bool
, _gr_bloom :: Bool , _gr_bloom :: Bool
@@ -152,6 +153,7 @@ defaultConfig =
{ _volume_master = 1 { _volume_master = 1
, _volume_sound = 1 , _volume_sound = 1
, _volume_music = 0 , _volume_music = 0
, _gr_upscale_filter = True
, _gr_cloud_shadows = True , _gr_cloud_shadows = True
, _gr_bloom = True , _gr_bloom = True
, _gr_shadow_rendering = GeoObjShads , _gr_shadow_rendering = GeoObjShads
+1
View File
@@ -189,6 +189,7 @@ graphicsMenuOptions :: [MenuOption]
graphicsMenuOptions = graphicsMenuOptions =
[ enumOption gr_world_res "World resolution" (uvIOEffects .~ updatePreload) [ enumOption gr_world_res "World resolution" (uvIOEffects .~ updatePreload)
, enumOption gr_downsize_res "Downsize resolution" (uvIOEffects .~ updatePreload) , enumOption gr_downsize_res "Downsize resolution" (uvIOEffects .~ updatePreload)
, boolOption gr_upscale_filter "UPSCALE FILTER"
, enumOption gr_shadow_rendering "SHADOW RENDERING" id , enumOption gr_shadow_rendering "SHADOW RENDERING" id
, enumOption gr_shadows_on_clouds "SHADOW DETAIL ON CLOUDS" id , enumOption gr_shadows_on_clouds "SHADOW DETAIL ON CLOUDS" id
, enumOption gr_shadow_size "SHADOW DETAIL" id , enumOption gr_shadow_size "SHADOW DETAIL" id
+4 -2
View File
@@ -368,8 +368,10 @@ doDrawing' win pdata u = do
[] -> do [] -> do
glBindTextureUnit 0 $ pdata ^. fboBase . _2 . _1 . unTO glBindTextureUnit 0 $ pdata ^. fboBase . _2 . _1 . unTO
glBindFramebuffer GL_FRAMEBUFFER 0 glBindFramebuffer GL_FRAMEBUFFER 0
glUseProgram (pdata ^. textureAntiaShader) if (cfig ^. gr_upscale_filter) then do
glUniform2f 0 (windowXFloat cfig) (windowYFloat cfig) glUseProgram (pdata ^. textureAntiaShader)
glUniform2f 0 (windowXFloat cfig) (windowYFloat cfig)
else glUseProgram (pdata ^. fullscreenShader)
--glDrawArrays GL_TRIANGLES 0 6 --glDrawArrays GL_TRIANGLES 0 6
glDrawArrays GL_TRIANGLES 0 3 glDrawArrays GL_TRIANGLES 0 3
rs' -> do rs' -> do