Ajoute une option pour visualiser les nuages dans l'éditeur (node sky/Sprite)

This commit is contained in:
Julian Murgia 2019-10-09 20:39:37 +02:00
parent 7234ba2d04
commit 82684c8bc8
3 changed files with 28 additions and 12 deletions

View file

@ -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"):

View file

@ -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"]

View file

@ -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))
@ -44,3 +47,4 @@ func set_time_of_day(hours, directional_light, horizontal_angle = 0.0):
# and update our sky
set_sun_position(sun_position)