extends Node2D var world: Node2D var wind_material: ShaderMaterial func _ready() -> void: name = "WindCanopies" texture_filter = CanvasItem.TEXTURE_FILTER_LINEAR_WITH_MIPMAPS wind_material = ShaderMaterial.new() wind_material.shader = preload("res://resources/effects/tree_wind.gdshader") material = wind_material func _draw() -> void: for tree in world.data.trees: var shade := float(tree.shade) var color: Color = Color(shade,shade,shade)*world.data.landscape.trees if int(world.data.profile.temperature) < -10: color = color.lerp(Color("d1e1da"),0.4) elif int(world.data.profile.temperature) > 40: color = color.lerp(Color("c6a86b"),0.28) var variant := int(tree.get("variant",-1)) var texture: Texture2D = world._tree if variant < 0 else world._nature[variant] var extent := Vector2(tree.size,tree.size*texture.get_height()/texture.get_width()) draw_set_transform(tree.position,tree.rotation) draw_texture_rect(texture,Rect2(-extent*0.5,extent),false,color) draw_set_transform(Vector2.ZERO)