Added danger
This commit is contained in:
@@ -12,5 +12,4 @@ void fragment() {
|
||||
float dist = destruction_x - world_pos.x;
|
||||
|
||||
COLOR.a = smoothstep(-edge_width, edge_width, dist);
|
||||
COLOR.a /= 2.0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
shader_type canvas_item;
|
||||
|
||||
#include "res://game/shaders/random_color.gdshaderinc"
|
||||
|
||||
uniform float chance : hint_range(0.0, 1.0) = 0.3;
|
||||
uniform float edge_width : hint_range(0, 100) = 8.0;
|
||||
|
||||
uniform sampler2D SCREEN_TEXTURE : hint_screen_texture, filter_nearest_mipmap;
|
||||
|
||||
void fragment() {
|
||||
vec4 screen_color = texture(SCREEN_TEXTURE, SCREEN_UV);
|
||||
COLOR = random_color(screen_color, UV, chance);
|
||||
|
||||
float dist_left = UV.x / fwidth(UV.x);
|
||||
float dist_right = (1.0 - UV.x) / fwidth(UV.x);
|
||||
float dist_bottom = UV.y / fwidth(UV.y);
|
||||
float dist_top = (1.0 - UV.y) / fwidth(UV.y);
|
||||
float pixel_dist = min(min(dist_left, dist_right), min(dist_bottom, dist_top));
|
||||
|
||||
float fade = clamp(pixel_dist / edge_width, 0.0, 1.0);
|
||||
|
||||
COLOR.a *= fade;
|
||||
|
||||
|
||||
|
||||
//vec4 tex_color = texture(TEXTURE, UV);
|
||||
//
|
||||
//// Расстояние до каждого края в пикселях экрана
|
||||
//float dist_left = UV.x / fwidth(UV.x);
|
||||
//float dist_right = (1.0 - UV.x) / fwidth(UV.x);
|
||||
//float dist_bottom = UV.y / fwidth(UV.y);
|
||||
//float dist_top = (1.0 - UV.y) / fwidth(UV.y);
|
||||
//
|
||||
//// Берём ближайший край
|
||||
//float pixel_dist = min(min(dist_left, dist_right),
|
||||
//min(dist_bottom, dist_top));
|
||||
//
|
||||
//// Плавное затухание: 0 на самой границе, 1 на расстоянии edge_width и дальше
|
||||
//float fade = clamp(pixel_dist / edge_width, 0.0, 1.0);
|
||||
//
|
||||
//COLOR = tex_color;
|
||||
//COLOR.a *= fade;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://c58hxwayyl757
|
||||
@@ -1,5 +1,7 @@
|
||||
shader_type canvas_item;
|
||||
|
||||
#include "res://game/shaders/random_color.gdshaderinc"
|
||||
|
||||
uniform float corruption_x = 0.0;
|
||||
uniform float edge_width = 50.0;
|
||||
uniform mat4 screen_to_world;
|
||||
@@ -19,4 +21,7 @@ void fragment() {
|
||||
|
||||
COLOR.rgb = mix(bw, screen_color.rgb, t);
|
||||
COLOR.a = screen_color.a;
|
||||
|
||||
float chance = (1.0 - t)/8.0;
|
||||
COLOR = random_color(COLOR, UV, chance);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
const int MAX_PALETTE_SIZE = 8;
|
||||
|
||||
uniform vec3 palette[MAX_PALETTE_SIZE] : source_color;
|
||||
uniform int palette_size : hint_range(1, MAX_PALETTE_SIZE) = 1;
|
||||
|
||||
|
||||
float hash(vec2 p) {
|
||||
return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453);
|
||||
}
|
||||
|
||||
vec4 random_color(vec4 current_color, vec2 uv, float chance)
|
||||
{
|
||||
vec2 seed = uv * fract(TIME);
|
||||
float random_value = hash(seed);
|
||||
if (chance != 0.0 && random_value < chance) {
|
||||
float index_rand = hash(seed + vec2(0.5, 0.5));
|
||||
int index = int(index_rand * float(palette_size)) % palette_size;
|
||||
current_color.rgb = palette[index];
|
||||
}
|
||||
return current_color;
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://b857povoqa1cj
|
||||
Reference in New Issue
Block a user