shader_type spatial;
render_mode blend_mix, depth_draw_opaque, cull_back, diffuse_burley, specular_schlick_ggx;

uniform float wind_strength : hint_range(0.0, 0.5) = 0.08;
uniform float wind_speed : hint_range(0.0, 5.0) = 0.6;
uniform vec3 albedo : source_color = vec3(0.19, 0.38, 0.17);
uniform float roughness : hint_range(0.0, 1.0) = 0.9;

void vertex() {
	float half_height = 1.2;
	float height_factor = clamp((VERTEX.y + half_height) / (half_height * 2.0), 0.0, 1.0);
	height_factor = height_factor * height_factor;

	float sway_x = sin(VERTEX.x * 0.3 + TIME * wind_speed) * wind_strength * height_factor;
	float sway_z = cos(VERTEX.z * 0.3 + TIME * wind_speed * 0.7) * wind_strength * height_factor;

	VERTEX.x += sway_x;
	VERTEX.z += sway_z;
}

void fragment() {
	ALBEDO = albedo;
	ROUGHNESS = roughness;
}
