I like that “shrink shader” project - here is a mod of kaizer i uploaded to “window” folder glsl, using quilez at Y axis, modded the filter parameters and precalculated 5 steps/texture reads (4 as step 1 is multplied to 0 so erased) using desmos. Use a linearize pass before it, anything like “texture = texture * texture” and then this as 2nd pass. Here we are trying to mimic crt-geom and the result of speed is near fake-crt-geom-potato, stresses the hd630 laptop gpu 34% while crt-geom is 90% and fake-crt-geom-potato is 32%, crt-geom-mini is 46%.
#version 110
/*
Kaizer-window customizable by DariusG 2024.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#pragma parameter scanlines "Scanlines Str." 0.5 0.0 0.5 0.05
#define pi 3.1415926
#define tau 6.2831852
#if defined(VERTEX)
#if __VERSION__ >= 130
#define COMPAT_VARYING out
#define COMPAT_ATTRIBUTE in
#define COMPAT_TEXTURE texture
#else
#define COMPAT_VARYING varying
#define COMPAT_ATTRIBUTE attribute
#define COMPAT_TEXTURE texture2D
#endif
#ifdef GL_ES
#define COMPAT_PRECISION mediump
#else
#define COMPAT_PRECISION
#endif
COMPAT_ATTRIBUTE vec4 VertexCoord;
COMPAT_ATTRIBUTE vec4 COLOR;
COMPAT_ATTRIBUTE vec4 TexCoord;
COMPAT_VARYING vec4 COL0;
COMPAT_VARYING vec4 TEX0;
COMPAT_VARYING vec2 scale;
COMPAT_VARYING float maskpos;
vec4 _oPosition1;
uniform mat4 MVPMatrix;
uniform COMPAT_PRECISION int FrameDirection;
uniform COMPAT_PRECISION int FrameCount;
uniform COMPAT_PRECISION vec2 OutputSize;
uniform COMPAT_PRECISION vec2 TextureSize;
uniform COMPAT_PRECISION vec2 InputSize;
// compatibility #defines
#define vTexCoord TEX0.xy
#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize
#define OutSize vec4(OutputSize, 1.0 / OutputSize)
#ifdef PARAMETER_UNIFORM
uniform COMPAT_PRECISION float WHATEVER;
#else
#define WHATEVER 0.0
#endif
void main()
{
gl_Position = MVPMatrix * VertexCoord;
TEX0.xy = TexCoord.xy*1.0001;
scale = SourceSize.xy/InputSize.xy;
maskpos = TEX0.x*OutputSize.x*scale.x*pi;
}
#elif defined(FRAGMENT)
#if __VERSION__ >= 130
#define COMPAT_VARYING in
#define COMPAT_TEXTURE texture
out vec4 FragColor;
#else
#define COMPAT_VARYING varying
#define FragColor gl_FragColor
#define COMPAT_TEXTURE texture2D
#endif
#ifdef GL_ES
#ifdef GL_FRAGMENT_PRECISION_HIGH
precision highp float;
#else
precision mediump float;
#endif
#define COMPAT_PRECISION mediump
#else
#define COMPAT_PRECISION
#endif
uniform COMPAT_PRECISION int FrameDirection;
uniform COMPAT_PRECISION int FrameCount;
uniform COMPAT_PRECISION vec2 OutputSize;
uniform COMPAT_PRECISION vec2 TextureSize;
uniform COMPAT_PRECISION vec2 InputSize;
uniform sampler2D Texture;
COMPAT_VARYING vec4 TEX0;
COMPAT_VARYING vec2 scale;
COMPAT_VARYING float maskpos;
// compatibility #defines
#define vTexCoord TEX0.xy
#define Source Texture
#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize
#define OutSize vec4(OutputSize, 1.0 / OutputSize)
#ifdef PARAMETER_UNIFORM
uniform COMPAT_PRECISION float scanlines;
#else
#define scanlines 0.5
#endif
// Configuration.
float kaizer_x (float p)
{
// Compute sinc filter.
float k = sin(1.3* ((p - 1.0) / 2.0));
return k;
}
vec2 Warp(vec2 coord)
{
vec2 CURVATURE_DISTORTION = vec2(0.12, 0.18);
// Barrel distortion shrinks the display area a bit, this will allow us to counteract that.
vec2 barrelScale = vec2(0.9724,0.9586);
coord -= vec2(0.5);
float rsq = coord.x*coord.x + coord.y*coord.y;
coord += coord * (CURVATURE_DISTORTION * rsq);
coord *= barrelScale;
coord += vec2(0.5);
return coord;
}
void main()
{
vec3 res = vec3(0.0);
vec2 dx = vec2(SourceSize.z*0.25,0.0); //sharpness
vec2 xy = vTexCoord;
xy -= dx*3.0;
vec2 pos = Warp(vTexCoord*scale);
vec2 corn = min(pos, 1.0-pos); // This is used to mask the rounded
corn.x = 0.0001/corn.x; // corners later on
pos /= scale;
vec2 near = floor(pos*SourceSize.xy)+0.5;
vec2 f = pos*SourceSize.xy - near;
xy.y = (near.y + 4.0*f.y*f.y*f.y)*SourceSize.w;
//kaizer precalculated
res += COMPAT_TEXTURE(Source,xy).rgb*-0.6052;
res += COMPAT_TEXTURE(Source,xy+2.0*dx).rgb*0.6052;
res += COMPAT_TEXTURE(Source,xy+3.0*dx).rgb*0.96356;
res += COMPAT_TEXTURE(Source,xy+4.0*dx).rgb*0.92896;
res /= 1.8925;
float a = dot(vec3(0.25),res);
float s = mix(scanlines,scanlines*0.5,a);
res *= s*sin((pos.y*SourceSize.y-0.25)*tau)+1.0-s;
res *= 0.2*sin(maskpos)+0.8;
res *= mix(1.45,1.05,a);
if (corn.y <= corn.x || corn.x < 0.0001 )res = vec3(0.0);
FragColor.rgb = sqrt(res);
}
#endif
crt-geom
kaizer mod, ofc i can mod the filter to look more blurry like geom but preferred a slightly sharper image.