extends Sprite onready var global_v=get_tree().get_root().get_node("previewer") func _ready(): pass func _process(delta): self.material.set("shader_param/iTime",global_v.iTime) self.material.set("shader_param/iFrame",global_v.iFrame) 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 sun_position = Vector3(0.0, -100.0, 0.0) sun_position = sun_position.rotated(Vector3(1.0, 0.0, 0.0), hours * PI / 12.0) sun_position = sun_position.rotated(Vector3(0.0, 1.0, 0.0), horizontal_angle) if directional_light: var t = directional_light.transform t.origin = sun_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(sun_position)