tool extends Sprite export(bool) var editor_clouds_playing = false export(float, 0.0, 24.0) var day_time_hours = 12.0 setget set_day_time_hours export(NodePath) var directional_light_node_path func _ready(): if !Engine.is_editor_hint(): editor_clouds_playing = true var iTime = 0.0 var iFrame = 0 func _process( delta ): iTime+=delta iFrame+=1 if (Engine.is_editor_hint() and self.editor_clouds_playing) or !Engine.is_editor_hint(): self.material.set("shader_param/iTime", iTime) self.material.set("shader_param/iFrame", iFrame) # self.set_day_time_hours( self.day_time_hours + delta ) # if day_time_hours >= 24: # self.set_day_time_hours( 0 ) func cov_scb(value): self.material.set("shader_param/COVERAGE",float(value)) func thick_scb(value): self.material.set("shader_param/THICKNESS",value) func absb_scb(value): self.material.set("shader_param/ABSORPTION",float(value)) func step_scb(value): self.material.set("shader_param/STEPS",value) export var sun_position = Vector3(0.0, 1.0, 0.0) setget set_sun_position, get_sun_position func set_sun_position(new_position): sun_position = new_position if self.material: self.material.set_shader_param("sun_pos", sun_position) # _trigger_update_sky() func get_sun_position(): return sun_position func set_time_of_day(hours, directional_light, horizontal_angle = 0.0): var new_position = Vector3(0.0, -100.0, 0.0) new_position = new_position.rotated(Vector3(1.0, 0.0, 0.0), hours * PI / 12.0) new_position = new_position.rotated(Vector3(0.0, 1.0, 0.0), horizontal_angle) if directional_light: var t = directional_light.transform t.origin = new_position directional_light.transform = t.looking_at(Vector3(0.0, 0.0, 0.0), Vector3(0.0, 1.0, 0.0)) directional_light.light_energy = 1.0 - clamp(abs(hours - 12.0) / 6.0, 0.0, 1.0) # and update our sky set_sun_position(new_position) func set_day_time_hours(hours): if directional_light_node_path: set_time_of_day(hours, get_node(directional_light_node_path), 25.0) day_time_hours = hours