Skip to content

Instantly share code, notes, and snippets.

@HungryProton
Last active August 4, 2022 17:19
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HungryProton/238a762bf62f9b0f5d1cc58c17b5b907 to your computer and use it in GitHub Desktop.
Save HungryProton/238a762bf62f9b0f5d1cc58c17b5b907 to your computer and use it in GitHub Desktop.
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