grunk/src/shaders/gunk/canvas_grunk.gdshader

38 lines
1.1 KiB
Plaintext
Raw Normal View History

/* Gunk shader adapted to a canvas item */
shader_type canvas_item;
#include "common.gdshaderinc"
uniform float aspect_ratio = 1.0;
group_uniforms mask;
uniform float mask_progress : hint_range(0.0, 1.0, 0.01) = 0.0;
uniform sampler2D mask_noise : hint_default_white;
void fragment() {
vec2 scaled_pixellation = pixellation * vec2(1.0, aspect_ratio);
float local_time = floor(TIME * time_scale * time_pixellation) / time_pixellation;
vec2 local_uv = floor(UV * scaled_pixellation) / scaled_pixellation + local_time * pan_speed;
// swirl
vec3 uvt = vec3(local_uv.x, local_uv.y, local_time);
uvt = swirl_uvt(uvt);
float value = sample_noise(uvt);
NORMAL_MAP = texture(gunk_noise, uvt).xyz;
// Radial mask effect
float radius = 1.3 * length(local_uv - 0.5);
float offset = radius + texture(mask_noise, local_uv).r - 0.5;
float mask = 1.0 - clamp(offset - 1.0 + 2.0 * mask_progress, 0.0, 1.0);
// soften edges
NORMAL_MAP *= smoothstep(1.0, 0.0, mask);
vec3 color = base_albedo(UV, value) + base_emission(UV, value);
float alpha = hardstep(1.0 - mask);
COLOR = vec4(color, alpha);
}