Skip to content

Instantly share code, notes, and snippets.

@HungryProton
Last active August 4, 2022 17:19
Embed
What would you like to do?
Godot smoke shader test
shader_type spatial;
uniform sampler2D mask;
uniform float min_scale = 0.0;
uniform float max_scale = 1.0;
varying float scale;
float range_lerp(float value, float istart, float istop, float ostart, float oend) {
float ilerp = (value - istart) / (istop - istart);
return ostart + (oend - ostart) * ilerp;
}
void vertex () {
scale = length(MODELVIEW_MATRIX[2].xyz);
}
void fragment () {
float l = texture(mask, UV).r;
float s = range_lerp(scale, min_scale, max_scale, 0.0, 1.0);
if (s > l) {
discard;
}
ALBEDO = vec3(clamp(scale, 0.0, 1.0));
}
@HungryProton
Copy link
Author

HungryProton commented Jul 20, 2021

Small experiment to dissolve smoke particles as they get larger

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment