Files

68 lines
2.4 KiB
Plaintext
Raw Permalink Normal View History

2026-07-21 00:27:17 +07:00
shader_type canvas_item;
// === ЭКРАННАЯ ТЕКСТУРА (обязательно для Godot 4) ===
uniform sampler2D screen_texture : hint_screen_texture;
// === НАСТРОЙКИ ===
uniform float aberration_strength : hint_range(0.0, 0.02) = 0.003;
uniform float scanline_intensity : hint_range(0.0, 1.0) = 0.25;
uniform float scanline_count = 320.0;
uniform float vignette_strength : hint_range(0.0, 1.0) = 0.3;
uniform float color_saturation : hint_range(0.0, 2.0) = 0.7;
uniform float brightness : hint_range(-0.5, 0.5) = 0.0;
uniform float contrast : hint_range(0.5, 1.5) = 1.1;
uniform float opacity : hint_range(0.0, 1.0) = 1.0;
uniform bool enable_scanlines = true;
uniform bool enable_vignette = true;
uniform bool enable_aberration = true;
void fragment() {
vec2 uv = UV;
// === ХРОМАТИЧЕСКАЯ АБЕРРАЦИЯ ===
vec3 color;
if (enable_aberration && aberration_strength > 0.0) {
vec2 center = vec2(0.5, 0.5);
vec2 dir = uv - center;
float dist = length(dir);
vec2 offset = normalize(dir) * dist * aberration_strength;
float r = texture(screen_texture, uv + offset).r;
float g = texture(screen_texture, uv).g;
float b = texture(screen_texture, uv - offset).b;
color = vec3(r, g, b);
} else {
color = texture(screen_texture, uv).rgb;
}
// === СКАНЛАЙНЫ ===
if (enable_scanlines && scanline_intensity > 0.0) {
float scanline = sin(uv.y * scanline_count * 3.14159265);
scanline = scanline * 0.5 + 0.5;
scanline = pow(scanline, 1.2);
color *= 1.0 - (scanline * scanline_intensity * 0.5);
}
// === ВИНЬЕТКА ===
if (enable_vignette && vignette_strength > 0.0) {
vec2 center_uv = uv - 0.5;
float vignette = dot(center_uv, center_uv) * 4.0;
vignette = 1.0 - (vignette * vignette_strength * 0.7);
vignette = clamp(vignette, 0.0, 1.0);
color *= vignette;
}
// === НАСЫЩЕННОСТЬ ЦВЕТА ===
if (color_saturation != 1.0) {
float gray = dot(color, vec3(0.299, 0.587, 0.114));
color = mix(vec3(gray), color, color_saturation);
}
// === ЯРКОСТЬ И КОНТРАСТ ===
color = (color - 0.5) * contrast + 0.5;
color += brightness;
color = clamp(color, 0.0, 1.0);
// === ИТОГОВЫЙ ЦВЕТ С ПРОЗРАЧНОСТЬЮ ===
COLOR = vec4(color, opacity);
}