Added pixellation to gunk1

This commit is contained in:
Rob Kelly 2025-03-02 16:54:22 -07:00
parent 2128203b17
commit d1c15b9f9f
4 changed files with 83 additions and 14 deletions

View File

@ -27,10 +27,11 @@ render_priority = 0
shader = ExtResource("1_euy6e") shader = ExtResource("1_euy6e")
shader_parameter/color_1 = Color(0, 0.03, 0.1, 1) shader_parameter/color_1 = Color(0, 0.03, 0.1, 1)
shader_parameter/color_2 = Color(0, 0.1, 0.3, 1) shader_parameter/color_2 = Color(0, 0.1, 0.3, 1)
shader_parameter/pixellation = 50.0
shader_parameter/roughness = 0.15 shader_parameter/roughness = 0.15
shader_parameter/specular_contribution = 0.2 shader_parameter/specular_contribution = 0.2
shader_parameter/uv_scale = Vector2(8, 8) shader_parameter/uv_scale = Vector2(8, 8)
shader_parameter/time_scale = 0.1 shader_parameter/time_scale = 0.2
shader_parameter/edge_bleed = 0.1 shader_parameter/edge_bleed = 0.1
shader_parameter/gunk_mask = SubResource("CompressedTexture2D_ow0bp") shader_parameter/gunk_mask = SubResource("CompressedTexture2D_ow0bp")
shader_parameter/gunk_noise = SubResource("NoiseTexture3D_d70or") shader_parameter/gunk_noise = SubResource("NoiseTexture3D_d70or")

File diff suppressed because one or more lines are too long

View File

@ -3,6 +3,9 @@ render_mode cull_back;
uniform vec4 color_1: source_color = vec4(0.0, 0.03, 0.1, 1.0); uniform vec4 color_1: source_color = vec4(0.0, 0.03, 0.1, 1.0);
uniform vec4 color_2: source_color = vec4(0.0, 0.1, 0.3, 1.0); uniform vec4 color_2: source_color = vec4(0.0, 0.1, 0.3, 1.0);
uniform float pixellation = 700.0;
uniform float roughness: hint_range(0.0, 1.0) = 0.15; uniform float roughness: hint_range(0.0, 1.0) = 0.15;
uniform float specular_contribution = 0.2; uniform float specular_contribution = 0.2;
@ -25,7 +28,7 @@ float hardstep(float value) {
} }
void fragment() { void fragment() {
vec2 local_uv = UV * uv_scale; vec2 local_uv = floor(UV * uv_scale * pixellation) / pixellation;
vec3 uvt = vec3(local_uv.x, local_uv.y, TIME * time_scale); vec3 uvt = vec3(local_uv.x, local_uv.y, TIME * time_scale);
float value = texture(gunk_noise, uvt).r; float value = texture(gunk_noise, uvt).r;
vec4 color = mix(color_1, color_2, value); vec4 color = mix(color_1, color_2, value);

View File

@ -36,30 +36,30 @@ vec4 effect(highp vec2 scaled_uv) {
// Pixellate // Pixellate
highp vec2 uv = floor(scaled_uv.xy * pixel_filter) / pixel_filter - 0.5 - offset; highp vec2 uv = floor(scaled_uv.xy * pixel_filter) / pixel_filter - 0.5 - offset;
highp float uv_len = length(uv); highp float uv_len = length(uv);
// Adding in a center swirl, changes with time. Only applies meaningfully if `spin_amount` != 0 // Adding in a center swirl, changes with time. Only applies meaningfully if `spin_amount` != 0
highp float speed = 0.2 * SPIN_EASE * spin_rotation + 302.2; highp float speed = 0.2 * SPIN_EASE * spin_rotation + 302.2;
highp float new_px_angle = atan(uv.y, uv.x) + speed - 20.0 * SPIN_EASE * uv_len; highp float new_px_angle = atan(uv.y, uv.x) + speed - 20.0 * SPIN_EASE * uv_len;
uv = uv_len * vec2(cos(new_px_angle), sin(new_px_angle)); uv = uv_len * vec2(cos(new_px_angle), sin(new_px_angle));
// Now add the paint effect to the swirled uvec2 // Now add the paint effect to the swirled uvec2
uv *= 30.0; uv *= 30.0;
speed = TIME * time_scale; speed = TIME * time_scale;
highp vec2 uv2 = vec2(uv.x + uv.y); highp vec2 uv2 = vec2(uv.x + uv.y);
for(int i = 0; i < 5; i++) { for(int i = 0; i < 5; i++) {
uv2 += sin(max(uv.x, uv.y)) + uv; uv2 += sin(max(uv.x, uv.y)) + uv;
uv += 0.5 * vec2(cos(5.1123314 + 0.353 * uv2.y + 0.131121 * speed), sin(uv2.x - 0.113 * speed)); uv += 0.5 * vec2(cos(5.1123314 + 0.353 * uv2.y + 0.131121 * speed), sin(uv2.x - 0.113 * speed));
uv -= cos(uv.x + uv.y) - 1.0 * sin(0.711 * uv.x - uv.y); uv -= cos(uv.x + uv.y) - 1.0 * sin(0.711 * uv.x - uv.y);
} }
// Adjust contrast & clamp on [0, 2] // Adjust contrast & clamp on [0, 2]
highp float contrast_mod = 0.25 * contrast + 0.5 * spin_amount + 1.2; highp float contrast_mod = 0.25 * contrast + 0.5 * spin_amount + 1.2;
highp float paint_res = clamp(0.035 * contrast_mod * length(uv), 0.0, 2.0); highp float paint_res = clamp(0.035 * contrast_mod * length(uv), 0.0, 2.0);
highp float c1p = max(0.0, 1.0 - contrast_mod * abs(1.0 - paint_res)); highp float c1p = max(0.0, 1.0 - contrast_mod * abs(1.0 - paint_res));
highp float c2p = max(0.0, 1.0 - contrast_mod * abs(paint_res)); highp float c2p = max(0.0, 1.0 - contrast_mod * abs(paint_res));
highp float c3p = 1.0 - min(1.0, c1p + c2p); highp float c3p = 1.0 - min(1.0, c1p + c2p);
return 0.3 * color_1 / contrast + (color_1 * c1p + color_2 * c2p + vec4(c3p * color_3.rgb, c3p * color_1.a)) * (1.0 - 0.3 / contrast); return 0.3 * color_1 / contrast + (color_1 * c1p + color_2 * c2p + vec4(c3p * color_3.rgb, c3p * color_1.a)) * (1.0 - 0.3 / contrast);
} }
@ -77,7 +77,7 @@ void fragment() {
ALBEDO = effect_color.rgb; ALBEDO = effect_color.rgb;
ROUGHNESS = roughness_mix; ROUGHNESS = roughness_mix;
SPECULAR = 0.5 * inversesqrt(specular_contribution); SPECULAR = 0.5 * inversesqrt(specular_contribution);
// Convolutional normal map // Convolutional normal map
float sample_step = convolution_factor / pixel_filter; float sample_step = convolution_factor / pixel_filter;
float n = sqrt(brightness(effect(vec2(local_uv.x, local_uv.y - sample_step)).rgb)); float n = sqrt(brightness(effect(vec2(local_uv.x, local_uv.y - sample_step)).rgb));
@ -87,7 +87,7 @@ void fragment() {
float x = 0.5 * (w - e) + 0.5; float x = 0.5 * (w - e) + 0.5;
float y = 0.5 * (s - n) + 0.5; float y = 0.5 * (s - n) + 0.5;
NORMAL_MAP = vec3(x, y, clamp(1.0 - abs(x - 0.5) + abs(y - 0.5), 0.5, 1)); NORMAL_MAP = vec3(x, y, clamp(1.0 - abs(x - 0.5) + abs(y - 0.5), 0.5, 1));
float mask = texture(gunk_mask, UV).r; float mask = texture(gunk_mask, UV).r;