2025-09-04 14:21:17 -06:00
|
|
|
// -*- mode: glsl -*-
|
2025-09-03 22:32:56 -06:00
|
|
|
shader_type spatial;
|
|
|
|
render_mode depth_prepass_alpha;
|
|
|
|
|
|
|
|
#include "common.gdshaderinc"
|
|
|
|
|
|
|
|
group_uniforms jitter;
|
|
|
|
uniform mediump float jitter_magnitude = 0.0;
|
|
|
|
uniform lowp float jitter_time_scale = 0.1;
|
|
|
|
|
|
|
|
uniform highp sampler3D jitter_noise;
|
|
|
|
|
|
|
|
group_uniforms inflation;
|
|
|
|
uniform highp float vertex_inflation = 0.0;
|
|
|
|
uniform highp float inflation_pixellation = 10.0;
|
|
|
|
|
|
|
|
|
|
|
|
void vertex() {
|
|
|
|
float mixer = VERTEX.x + 0.553 * VERTEX.z + 1.618 * VERTEX.y;
|
|
|
|
float local_time = floor(TIME * jitter_time_scale * time_pixellation) / time_pixellation;
|
|
|
|
float sample = texture(jitter_noise, vec3(cos(mixer), sin(mixer), local_time)).r;
|
|
|
|
float inflation = floor(vertex_inflation * inflation_pixellation) / inflation_pixellation;
|
|
|
|
float jitter = jitter_magnitude * (sample - 0.5 + inflation);
|
|
|
|
VERTEX *= 1.0 + jitter;
|
|
|
|
}
|
|
|
|
|
|
|
|
void fragment() {
|
|
|
|
vec3 uvt = scale_uvt(UV, TIME);
|
|
|
|
float value = sample_noise(uvt);
|
|
|
|
ALBEDO = base_albedo(UV, value);
|
|
|
|
ROUGHNESS = base_roughness(value);
|
|
|
|
EMISSION = base_emission(UV, value);
|
|
|
|
SPECULAR = base_specular();
|
|
|
|
|
2025-09-04 14:21:17 -06:00
|
|
|
vec3 nmap = sobel_convolution(UV, uvt);
|
|
|
|
NORMAL_MAP = nmap / 2.0 + 0.5;
|
2025-09-03 22:32:56 -06:00
|
|
|
|
|
|
|
// add fresnel
|
2025-09-04 14:21:17 -06:00
|
|
|
vec3 world_normal = mat3(TANGENT, BINORMAL, NORMAL) * nmap;
|
2025-09-03 22:32:56 -06:00
|
|
|
EMISSION += rim_glow(
|
|
|
|
world_normal,
|
|
|
|
VIEW,
|
|
|
|
fresnel_gradient,
|
|
|
|
fresnel_color,
|
|
|
|
fresnel_power,
|
|
|
|
fresnel_intensity
|
|
|
|
);
|
|
|
|
|
|
|
|
// add iridescence
|
|
|
|
ALBEDO += rim_glow(
|
|
|
|
world_normal,
|
|
|
|
VIEW,
|
|
|
|
iridescence_gradient,
|
|
|
|
iridescence_color,
|
|
|
|
iridescence_power,
|
|
|
|
iridescence_intensity
|
|
|
|
);
|
|
|
|
}
|