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