add wind fade in/out + add wire movement when is windy

This commit is contained in:
2026-04-21 15:16:30 +02:00
parent 9a26a4114b
commit f5a38bd8a0
11 changed files with 130 additions and 40 deletions

View File

@@ -6,19 +6,24 @@ uniform vec4 albedo_color : source_color = vec4(0.1, 0.1, 0.1, 1.0);
global uniform float global_wind_strength;
global uniform float global_wind_speed;
global uniform float global_wind_fade;
void vertex() {
//COLOR.r is the drawing. 0 -> lampost (no move); 1.0 is the center of the wire
float movement = COLOR.r;
float wind_amount = global_wind_strength * global_wind_fade;
//Create a wave (based on position and time to be random)
float wind_wave = 0.0;
if (global_wind_speed > 0.0 && global_wind_strength > 0.0) {
wind_wave = sin(TIME * global_wind_speed + NODE_POSITION_WORLD.x * 0.5) * global_wind_strength;
float vertical_wave = 0.0;
if (global_wind_speed > 0.0 && wind_amount > 0.0) {
wind_wave = sin(TIME * global_wind_speed + NODE_POSITION_WORLD.x * 0.5 + NODE_POSITION_WORLD.z * 0.35) * wind_amount;
vertical_wave = sin(TIME * global_wind_speed * 0.7 + NODE_POSITION_WORLD.z * 0.35) * wind_amount;
}
VERTEX.x += wind_wave * 0.1 * movement;
VERTEX.z += wind_wave * 0.05 * movement;
VERTEX.x += wind_wave * 0.28 * movement;
VERTEX.y += vertical_wave * 0.125 * movement;
VERTEX.z += wind_wave * 0.24 * movement;
}
void fragment() {