Last active
August 4, 2022 17:19
-
-
Save HungryProton/238a762bf62f9b0f5d1cc58c17b5b907 to your computer and use it in GitHub Desktop.
Godot smoke shader test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Small experiment to dissolve smoke particles as they get larger