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);
}
Tags
shader
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.

More from Pointblanks

Flash Shader

Related shaders

Water Shader

Gerstner Wave Ocean Shader

Useful Gradient Effects All-in-one Shader

Subscribe
Notify of
guest

3 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
ArtcadeDev
4 months ago

This is absolutely fantastic, just what I needed.
I’ll credit you in my project.

Mel
Mel
4 months ago

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);
}