From 82684c8bc8ddd56d2dc5c3ff2f6cda105001ce9b Mon Sep 17 00:00:00 2001 From: Julian Murgia Date: Wed, 9 Oct 2019 20:39:37 +0200 Subject: [PATCH] =?UTF-8?q?Ajoute=20une=20option=20pour=20visualiser=20les?= =?UTF-8?q?=20nuages=20dans=20l'=C3=A9diteur=20(node=20sky/Sprite)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- previewer/previewer.gd | 6 ++++++ previewer/previewer.tscn | 18 ++++++++++++------ previewer/sky.gd | 16 ++++++++++------ 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/previewer/previewer.gd b/previewer/previewer.gd index 2bcbc16..32db8cb 100644 --- a/previewer/previewer.gd +++ b/previewer/previewer.gd @@ -1,3 +1,4 @@ +tool extends Spatial var _mouse_look = false @@ -18,6 +19,8 @@ export(float) var camera_accel = 10.0 var iTime=0.0 var iFrame=0 +signal time_frame_changed(time, frame) + func _ready(): self._current_camera_speed = self.camera_speed @@ -30,6 +33,9 @@ func _process( delta ): iTime+=delta iFrame+=1 + if (Engine.is_editor_hint() and $sky/viewport/sprite.editor_playing) or !Engine.is_editor_hint(): + emit_signal("time_frame_changed", iTime, iFrame) + if Input.is_action_pressed("move_up"): $dummy/camera_stand.translate( Vector3( 0.0, self._current_camera_speed*delta, 0.0 ) ) elif Input.is_action_pressed("move_down"): diff --git a/previewer/previewer.tscn b/previewer/previewer.tscn index 7b1b60b..0973eea 100644 --- a/previewer/previewer.tscn +++ b/previewer/previewer.tscn @@ -23,8 +23,8 @@ noise = SubResource( 1 ) [sub_resource type="ShaderMaterial" id=3] shader = ExtResource( 2 ) -shader_param/iTime = null -shader_param/iFrame = null +shader_param/iTime = 15.5758 +shader_param/iFrame = 1014 shader_param/COVERAGE = 0.5 shader_param/THICKNESS = 25.0 shader_param/ABSORPTION = 1.031 @@ -32,7 +32,7 @@ shader_param/STEPS = 25 shader_param/earth_radius_km = 6371.0 shader_param/atmo_radius_km = 6471.0 shader_param/cam_height_m = 1.8 -shader_param/sun_pos = Vector3( 1, 1, 1 ) +shader_param/sun_pos = Vector3( -11.462, 50, 85.8407 ) shader_param/sun_intensity = 42.0 shader_param/rayleigh_coeff = Vector3( 5.5, 13, 22.4 ) shader_param/mie_coeff = 21.0 @@ -92,6 +92,8 @@ material = SubResource( 3 ) texture = SubResource( 4 ) centered = false script = ExtResource( 3 ) +editor_playing = true +sun_position = Vector3( -11.462, 50, 85.8407 ) [node name="world_environment" type="WorldEnvironment" parent="."] environment = SubResource( 7 ) @@ -108,6 +110,7 @@ mesh = SubResource( 9 ) transform = Transform( 0.778102, 0, 0.628138, 0, 1, 0, -0.628138, 0, 0.778102, -24.4077, -0.000944138, -27.3821 ) moss_height = 15.0 moss_fade = 2.5 +moss_depth_min = 0.73 [node name="props" type="Spatial" parent="."] @@ -130,8 +133,9 @@ color = Color( 0.360784, 1, 0, 1 ) lid_angle = 12.0 [node name="container_4" parent="props" instance=ExtResource( 8 )] -transform = Transform( 0.457191, 0, 0.889369, 0, 1, 0, -0.889369, 0, 0.457191, -3.94754, 4.76837e-007, -4.27729 ) +transform = Transform( 0.457191, 0, 0.889369, 0, 1, 0, -0.889369, 0, 0.457191, -3.94754, 4.76837e-07, -4.27729 ) color = Color( 0.972549, 0.196078, 0.0431373, 1 ) +lid_angle = 0.0 [node name="reference_box" parent="props" instance=ExtResource( 9 )] @@ -141,8 +145,8 @@ transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 5, 0.472, -5 ) [node name="light_system" type="Spatial" parent="."] [node name="directional_light" type="DirectionalLight" parent="light_system"] -transform = Transform( 0.522088, 0.655715, -0.545401, 0, 0.639473, 0.768814, 0.852892, -0.401388, 0.333861, 0, 13.7088, 0 ) -light_energy = 3.1 +transform = Transform( 0.991203, 0.0661759, -0.11462, 0, 0.866025, 0.5, 0.132352, -0.495601, 0.858407, -11.462, 50, 85.8407 ) +light_energy = 0.333333 shadow_enabled = true [node name="gi_probe" type="GIProbe" parent="light_system"] @@ -151,7 +155,9 @@ extents = Vector3( 63.192, 25, 76.323 ) data = SubResource( 10 ) [node name="settings" parent="." instance=ExtResource( 11 )] +visible = true margin_left = -475.0 margin_top = -243.0 margin_right = -219.0 margin_bottom = 13.0 +[connection signal="time_frame_changed" from="." to="sky/viewport/sprite" method="_on_previewer_time_frame_changed"] diff --git a/previewer/sky.gd b/previewer/sky.gd index 7d6e12a..54cb55b 100644 --- a/previewer/sky.gd +++ b/previewer/sky.gd @@ -1,13 +1,16 @@ +tool extends Sprite -onready var global_v=get_tree().get_root().get_node("previewer") +export(bool) var editor_playing = false func _ready(): - pass + if !Engine.is_editor_hint(): + editor_playing = true + +func _on_previewer_time_frame_changed(time, frame): + self.material.set("shader_param/iTime", time) + self.material.set("shader_param/iFrame", frame) -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)) @@ -43,4 +46,5 @@ func set_time_of_day(hours, directional_light, horizontal_angle = 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) \ No newline at end of file + set_sun_position(sun_position) +