Texture Based Damage Deform

A simple shader that deforms your mesh based on a set value and a texture, great for showing objects damaged!

Shader code
shader_type spatial;

uniform float damage : hint_range(0.0, 1.0, 0.01);
uniform sampler2D damage_texture;
uniform sampler2D albedo : source_color;

void vertex() {
	vec4 rand = texture(damage_texture, VERTEX.xz);
	rand = (rand / damage);
	vec3 goal = VERTEX * clamp(rand.x, 0.45, 0.5);
	goal *= 2.0;
	VERTEX = goal;
}

void fragment() {
	vec4 albedo_color = texture(albedo, UV);
	ALBEDO = albedo_color.xyz;
}
The shader code and all code snippets in this post are under CC0 license and can be used freely without the author's permission. Images and videos, and assets depicted in those, do not fall under this license. For more info, see our License terms.

Related shaders

Blend damage revealed with noise texture mask

Distortion based on noise + texture

Texture-based Color Overlay (4.3)

Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments