screen filters system?

This commit is contained in:
Haze Weathers 2025-11-01 18:35:46 -06:00
parent 08a20c683a
commit 2a6b263cae
6 changed files with 98 additions and 2 deletions

View file

@ -0,0 +1,11 @@
[gd_resource type="ShaderMaterial" load_steps=2 format=3 uid="uid://sppw51urwmf3"]
[ext_resource type="Shader" uid="uid://bgy86nka8c76n" path="res://assets/shaders/lcd.gdshader" id="1_y1c64"]
[resource]
shader = ExtResource("1_y1c64")
shader_parameter/enabled = true
shader_parameter/resolution = Vector2(256, 192)
shader_parameter/curvature = Vector2(1, 1)
shader_parameter/scanline_opacity = Vector2(0.1, 0.1)
shader_parameter/brightness = 1.0

View file

@ -0,0 +1,43 @@
shader_type canvas_item;
uniform sampler2D SCREEN_TEXTURE : hint_screen_texture, filter_linear_mipmap;
uniform bool enabled = true;
uniform vec2 resolution;
uniform vec2 curvature;
uniform vec2 scanline_opacity;
uniform float brightness;
vec2 curve_uv(vec2 uv) {
uv = uv * 2.0 - 1.0;
vec2 offset = abs(uv.yx) / vec2(curvature.x, curvature.y);
uv = uv + uv * offset * offset;
uv = uv * 0.5 + 0.5;
return uv;
}
vec3 scanline_intensity(float uv, float res, float opacity) {
float intensity = sin((uv * res - 0.25) * PI * 2.0);
intensity = ((0.5 * intensity) + 0.5) * 0.9 + 0.1;
return vec3(pow(intensity, opacity));
}
void fragment() {
if (enabled) {
vec2 curved_uv = SCREEN_UV;
vec3 base_color = texture(SCREEN_TEXTURE, curved_uv).rgb;
base_color += vec3(1.0/256.0);
base_color *= scanline_intensity(curved_uv.x, resolution.x, scanline_opacity.y);
base_color *= scanline_intensity(curved_uv.y, resolution.y, scanline_opacity.x);
base_color *= vec3(brightness);
if (curved_uv.x < 0.0 || curved_uv.y < 0.0 || curved_uv.x > 1.0 || curved_uv.y > 1.0) {
COLOR = vec4(0.0, 0.0, 0.0, 0.0);
} else {
COLOR = vec4(base_color, 1.0);
}
} else {
COLOR = texture(SCREEN_TEXTURE, SCREEN_UV);
}
}

View file

@ -0,0 +1 @@
uid://bgy86nka8c76n