Blood Shader
Simple shader that covers sprite in a bloodlike fashion
Shader code
shader_type canvas_item;
uniform sampler2D noise : repeat_enable;
uniform float blood_coef : hint_range(0.0, 1.0) = 0.0;
uniform vec3 color : source_color;
void fragment() {
vec4 curr_texture = texture(TEXTURE, UV);
vec4 noise_texture = texture(noise, UV);
float is_blood = step( noise_texture.r, blood_coef);
noise_texture.r = mix(noise_texture.r, curr_texture.r, is_blood);
vec4 blood_output = vec4(noise_texture.rgb * color , curr_texture.a);
COLOR = mix(curr_texture, blood_output, is_blood);
}
This is absolutely fantastic, just what I needed.
I’ll credit you in my project.
Hey, I got an updated version of it, I mean, it cost less ressources to gpu using step:
shader_type canvas_item;
uniform sampler2D noise : repeat_enable;
uniform float blood_coef : hint_range(0.0, 1.0) = 0.0;
uniform vec3 color : source_color;
void fragment() {
vec4 curr_texture = texture(TEXTURE, UV);
vec4 noise_texture = texture(noise, UV);
float is_blood = step( noise_texture.r, blood_coef);
noise_texture.r = mix(noise_texture.r, curr_texture.r, is_blood);
vec4 blood_output = vec4(noise_texture.rgb * color , curr_texture.a);
COLOR = mix(curr_texture, blood_output, is_blood);
}
Thanks for the improved version, I’m still new to shaders.