Spikes/Bumps (UV based)
A shader to for creating bumps of different size and sharpness. The location of the bumps is calculated from the UV and may therefore cause weird behaviour a seams.
To use this shader apply it to any mesh you like (haven’t really tested it for more complex meshes)
Note: The shader works by transforming vertices so if there aren’t enough vertices to deform it will look weird, for example when using a BoxMesh you need to increase the subdivides to have similar results as in the image
Shader code
shader_type spatial;
render_mode unshaded, cull_disabled;
uniform vec3 base_color : source_color = vec3(0.275, 0.012, 0.0);
uniform vec3 spike_color : source_color = vec3(0.808, 0.0, 0.059);
uniform float spike_density : hint_range(1.0, 128.0) = 10.0;
uniform float spike_height : hint_range(0.0, 0.2) = 0.1;
uniform float spike_width : hint_range(0.0, 0.5) = 0.1;
uniform float spike_base_width : hint_range(0.0, 0.5) = 0.2;
uniform float tip_smoothness : hint_range(0.0, 1.0) = 0.2;
uniform float min_alpha : hint_range(0.0, 1.0) = 0.25;
uniform float max_alpha : hint_range(0.0, 1.0) = 0.05;
uniform bool grow_out = false;
varying float v_mask;
float spike_pattern(vec2 uv) {
uv = fract(uv * spike_density);
vec2 d = abs(uv - 0.5);
float dist = length(d);
float mask = smoothstep(spike_width, spike_width + spike_base_width, dist) * (1.0 - tip_smoothness);
mask += smoothstep(0.0, spike_width + spike_base_width, dist) * tip_smoothness;
return mask;
}
void vertex() {
v_mask = spike_pattern(UV);
VERTEX += NORMAL * spike_height * (grow_out ? (1.0 - v_mask) : -v_mask);
}
void fragment() {
ALBEDO = mix(base_color, spike_color, v_mask);
ALPHA = mix(min_alpha, max_alpha, v_mask);
}


