diff --git a/data/shaders/crt-geom.frag b/data/shaders/crt-geom.frag new file mode 100644 index 0000000..f7d55b8 --- /dev/null +++ b/data/shaders/crt-geom.frag @@ -0,0 +1,23 @@ +#define distortion 0.08 + +in vec2 texCoord; +out vec4 fragColor; + +uniform sampler2D tex; + +vec2 radialDistortion(vec2 coord) { + vec2 cc = coord - vec2(0.5); + float dist = dot(cc, cc) * distortion; + return coord + cc * (1.0 - dist) * dist; +} + +void main(void) { + vec4 rgba = texture2D(tex, radialDistortion(texCoord)); + + vec4 intensity = fract(gl_FragCoord.y * (0.5 * 4.0 / 3.0)) > 0.5 + ? vec4(0) + : smoothstep(0.2, 0.8, rgba) + normalize(rgba); + + fragColor = intensity * -0.25 + rgba * 1.1; + +} \ No newline at end of file diff --git a/data/shaders/crt-simple.frag b/data/shaders/crt-simple.frag index f90a9e1..00fd3bc 100644 --- a/data/shaders/crt-simple.frag +++ b/data/shaders/crt-simple.frag @@ -1,4 +1,3 @@ -in vec4 color; in vec2 texCoord; out vec4 fragColor; diff --git a/src/system.c b/src/system.c index 80f4f15..dc2fbce 100644 --- a/src/system.c +++ b/src/system.c @@ -1114,7 +1114,7 @@ static s32 start(s32 argc, char **argv, const char* folder) GPU_Image* texture = GPU_CreateImage(TIC80_FULLWIDTH, TIC80_FULLHEIGHT, GPU_FORMAT_BGRA); u32 crt_shader = 0; - GPU_ShaderBlock crt_block = load_shader_program(&crt_shader, "data/shaders/common.vert", "data/shaders/crt-simple.frag"); + GPU_ShaderBlock crt_block = load_shader_program(&crt_shader, "data/shaders/common.vert", "data/shaders/crt-geom.frag"); GPU_ActivateShaderProgram(crt_shader, &crt_block); {