Ajout de control pour contrôler le shader de ciel.

This commit is contained in:
osquallo 2019-10-08 18:54:39 +02:00
parent a317139785
commit 96db8d8f2d
6 changed files with 151 additions and 68 deletions

View file

@ -1,19 +1,27 @@
[gd_scene load_steps=21 format=2] [gd_scene load_steps=22 format=2]
[ext_resource path="res://previewer/previewer.gd" type="Script" id=1] [ext_resource path="res://previewer/previewer.gd" type="Script" id=1]
[ext_resource path="res://shaders/sky.shader" type="Shader" id=2] [ext_resource path="res://shaders/sky.shader" type="Shader" id=2]
[ext_resource path="res://textures/sky/sky_noise.png" type="Texture" id=3] [ext_resource path="res://previewer/sky.gd" type="Script" id=3]
[ext_resource path="res://previewer/sky.gd" type="Script" id=4] [ext_resource path="res://previewer/dummy/dummy.tscn" type="PackedScene" id=4]
[ext_resource path="res://previewer/dummy/dummy.tscn" type="PackedScene" id=5] [ext_resource path="res://textures/tilables/basic_texture_1024.png" type="Texture" id=5]
[ext_resource path="res://textures/tilables/basic_texture_1024.png" type="Texture" id=6] [ext_resource path="res://meshes/decors/rocks/cliff_001.tscn" type="PackedScene" id=6]
[ext_resource path="res://meshes/decors/rocks/cliff_001.tscn" type="PackedScene" id=7] [ext_resource path="res://meshes/props/pendo_teddy/pendo_teddy.tscn" type="PackedScene" id=7]
[ext_resource path="res://meshes/props/pendo_teddy/pendo_teddy.tscn" type="PackedScene" id=8] [ext_resource path="res://meshes/props/travel_box/container.tscn" type="PackedScene" id=8]
[ext_resource path="res://meshes/props/travel_box/container.tscn" type="PackedScene" id=9] [ext_resource path="res://meshes/props/reference_box/reference_box.tscn" type="PackedScene" id=9]
[ext_resource path="res://meshes/props/reference_box/reference_box.tscn" type="PackedScene" id=10] [ext_resource path="res://meshes/props/fountain_suzanha/Fountain_suzanha.tscn" type="PackedScene" id=10]
[ext_resource path="res://meshes/props/fountain_suzanha/Fountain_suzanha.tscn" type="PackedScene" id=11] [ext_resource path="res://previewer/settings.tscn" type="PackedScene" id=11]
[ext_resource path="res://previewer/settings.tscn" type="PackedScene" id=12]
[sub_resource type="ShaderMaterial" id=6] [sub_resource type="OpenSimplexNoise" id=1]
period = 8.0
[sub_resource type="NoiseTexture" id=2]
width = 1280
height = 720
seamless = true
noise = SubResource( 1 )
[sub_resource type="ShaderMaterial" id=3]
shader = ExtResource( 2 ) shader = ExtResource( 2 )
shader_param/iTime = null shader_param/iTime = null
shader_param/iFrame = null shader_param/iFrame = null
@ -21,35 +29,35 @@ shader_param/COVERAGE = 0.5
shader_param/THICKNESS = 25.0 shader_param/THICKNESS = 25.0
shader_param/ABSORPTION = 1.031 shader_param/ABSORPTION = 1.031
shader_param/STEPS = 25 shader_param/STEPS = 25
shader_param/iChannel0 = ExtResource( 3 ) shader_param/iChannel0 = SubResource( 2 )
[sub_resource type="ImageTexture" id=7] [sub_resource type="ImageTexture" id=4]
size = Vector2( 1280, 720 ) size = Vector2( 1280, 720 )
[sub_resource type="ViewportTexture" id=10] [sub_resource type="ViewportTexture" id=5]
viewport_path = NodePath("sky/viewport") viewport_path = NodePath("sky/viewport")
[sub_resource type="PanoramaSky" id=9] [sub_resource type="PanoramaSky" id=6]
resource_local_to_scene = true resource_local_to_scene = true
panorama = SubResource( 10 ) panorama = SubResource( 5 )
[sub_resource type="Environment" id=2] [sub_resource type="Environment" id=7]
resource_local_to_scene = true resource_local_to_scene = true
background_mode = 2 background_mode = 2
background_sky = SubResource( 9 ) background_sky = SubResource( 6 )
background_energy = 0.1 background_energy = 0.1
ambient_light_energy = 3.82 ambient_light_energy = 3.82
[sub_resource type="SpatialMaterial" id=3] [sub_resource type="SpatialMaterial" id=8]
flags_unshaded = true flags_unshaded = true
flags_world_triplanar = true flags_world_triplanar = true
albedo_texture = ExtResource( 6 ) albedo_texture = ExtResource( 5 )
uv1_scale = Vector3( 122, 122, 122 ) uv1_scale = Vector3( 122, 122, 122 )
[sub_resource type="PlaneMesh" id=4] [sub_resource type="PlaneMesh" id=9]
material = SubResource( 3 ) material = SubResource( 8 )
[sub_resource type="GIProbeData" id=5] [sub_resource type="GIProbeData" id=10]
bounds = AABB( -63.192, -25, -76.323, 126.384, 50, 152.646 ) bounds = AABB( -63.192, -25, -76.323, 126.384, 50, 152.646 )
cell_size = 1.19255 cell_size = 1.19255
to_cell_xform = Transform( 0.838542, 0, 0, 0, 0.838542, 0, 0, 0, 0.838542, 52.9891, 20.9635, 64 ) to_cell_xform = Transform( 0.838542, 0, 0, 0, 0.838542, 0, 0, 0, 0.838542, 52.9891, 20.9635, 64 )
@ -68,55 +76,55 @@ script = ExtResource( 1 )
size = Vector2( 1280, 720 ) size = Vector2( 1280, 720 )
render_target_update_mode = 3 render_target_update_mode = 3
[node name="sky" type="Sprite" parent="sky/viewport"] [node name="sprite" type="Sprite" parent="sky/viewport"]
material = SubResource( 6 ) material = SubResource( 3 )
texture = SubResource( 7 ) texture = SubResource( 4 )
centered = false centered = false
script = ExtResource( 4 ) script = ExtResource( 3 )
[node name="world_environment" type="WorldEnvironment" parent="."] [node name="world_environment" type="WorldEnvironment" parent="."]
environment = SubResource( 2 ) environment = SubResource( 7 )
[node name="dummy" parent="." instance=ExtResource( 5 )] [node name="dummy" parent="." instance=ExtResource( 4 )]
[node name="terrain" type="Spatial" parent="."] [node name="terrain" type="Spatial" parent="."]
[node name="test_csg_mesh" type="CSGMesh" parent="terrain"] [node name="test_csg_mesh" type="CSGMesh" parent="terrain"]
transform = Transform( 60.964, 0, 0, 0, 1.21928, 0, 0, 0, 60.964, 0, 0, 0 ) transform = Transform( 60.964, 0, 0, 0, 1.21928, 0, 0, 0, 60.964, 0, 0, 0 )
mesh = SubResource( 4 ) mesh = SubResource( 9 )
[node name="cliff" parent="terrain" instance=ExtResource( 7 )] [node name="cliff" parent="terrain" instance=ExtResource( 6 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -48.2121 ) transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -48.2121 )
moss_height = 15.0 moss_height = 15.0
moss_fade = 2.5 moss_fade = 2.5
[node name="props" type="Spatial" parent="."] [node name="props" type="Spatial" parent="."]
[node name="pendo_teddy" parent="props" instance=ExtResource( 8 )] [node name="pendo_teddy" parent="props" instance=ExtResource( 7 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -3 ) transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -3 )
[node name="container" parent="props" instance=ExtResource( 9 )] [node name="container" parent="props" instance=ExtResource( 8 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -5 ) transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -5 )
color = Color( 0.145098, 0.0980392, 0.713726, 1 ) color = Color( 0.145098, 0.0980392, 0.713726, 1 )
lid_angle = 45.0 lid_angle = 45.0
[node name="container_2" parent="props" instance=ExtResource( 9 )] [node name="container_2" parent="props" instance=ExtResource( 8 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -1.24144, 0, -5 ) transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -1.24144, 0, -5 )
color = Color( 0.491686, 0.159256, 0.832031, 1 ) color = Color( 0.491686, 0.159256, 0.832031, 1 )
lid_angle = 90.0 lid_angle = 90.0
[node name="container_3" parent="props" instance=ExtResource( 9 )] [node name="container_3" parent="props" instance=ExtResource( 8 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -2.6614, 0, -5 ) transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -2.6614, 0, -5 )
color = Color( 0.360784, 1, 0, 1 ) color = Color( 0.360784, 1, 0, 1 )
lid_angle = 12.0 lid_angle = 12.0
[node name="container_4" parent="props" instance=ExtResource( 9 )] [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-007, -4.27729 )
color = Color( 0.972549, 0.196078, 0.0431373, 1 ) color = Color( 0.972549, 0.196078, 0.0431373, 1 )
[node name="reference_box" parent="props" instance=ExtResource( 10 )] [node name="reference_box" parent="props" instance=ExtResource( 9 )]
[node name="Fountain_suzanha" parent="props" instance=ExtResource( 11 )] [node name="Fountain_suzanha" parent="props" instance=ExtResource( 10 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 5, 0.472, -5 ) transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 5, 0.472, -5 )
[node name="light_system" type="Spatial" parent="."] [node name="light_system" type="Spatial" parent="."]
@ -129,9 +137,9 @@ shadow_enabled = true
[node name="gi_probe" type="GIProbe" parent="light_system"] [node name="gi_probe" type="GIProbe" parent="light_system"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 21.7307, 0 ) transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 21.7307, 0 )
extents = Vector3( 63.192, 25, 76.323 ) extents = Vector3( 63.192, 25, 76.323 )
data = SubResource( 5 ) data = SubResource( 10 )
[node name="settings" parent="." instance=ExtResource( 12 )] [node name="settings" parent="." instance=ExtResource( 11 )]
margin_left = -475.0 margin_left = -475.0
margin_top = -243.0 margin_top = -243.0
margin_right = -219.0 margin_right = -219.0

View file

@ -1,18 +1,15 @@
extends WindowDialog extends WindowDialog
# Declare member variables here. Examples: onready var sky_sprite = get_tree().get_root().get_node("previewer/sky/viewport/sprite")
# var a = 2
# var b = "text"
# Called when the node enters the scene tree for the first time. func _on_sky_coverage_value_changed(value):
func _ready(): sky_sprite.cov_scb( value )
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame. func _on_sky_thickness_value_changed(value):
#func _process(delta): sky_sprite.thick_scb( value )
# pass
func _on_sky_absorption_value_changed(value):
sky_sprite.absb_scb( value )
func _on_color_picker_button_color_changed(color): func _on_sky_steps_value_changed(value):
pass sky_sprite.step_scb( value )
# get_parent().get_node( "world_environment" ).environment.background_sky.sky_top_color = color

View file

@ -30,23 +30,101 @@ margin_bottom = 256.0
size_flags_horizontal = 7 size_flags_horizontal = 7
size_flags_vertical = 3 size_flags_vertical = 3
[node name="sky_top_color" type="HBoxContainer" parent="scroll_container/controls"] [node name="sky_label" type="Label" parent="scroll_container/controls"]
margin_right = 256.0 margin_right = 256.0
margin_bottom = 20.0 margin_bottom = 14.0
size_flags_horizontal = 3 text = "Sky"
align = 1
valign = 1
[node name="label" type="Label" parent="scroll_container/controls/sky_top_color"] [node name="sky_box" type="VBoxContainer" parent="scroll_container/controls"]
margin_top = 3.0 margin_top = 18.0
margin_right = 256.0
margin_bottom = 94.0
[node name="sky_coverage_box" type="HBoxContainer" parent="scroll_container/controls/sky_box"]
margin_right = 256.0
margin_bottom = 16.0
[node name="label" type="Label" parent="scroll_container/controls/sky_box/sky_coverage_box"]
margin_top = 1.0
margin_right = 126.0 margin_right = 126.0
margin_bottom = 17.0 margin_bottom = 15.0
size_flags_horizontal = 3 size_flags_horizontal = 3
text = "Sky top color" text = "Coverage"
align = 2 align = 2
[node name="color_picker_button" type="ColorPickerButton" parent="scroll_container/controls/sky_top_color"] [node name="sky_coverage" type="HSlider" parent="scroll_container/controls/sky_box/sky_coverage_box"]
margin_left = 130.0 margin_left = 130.0
margin_right = 256.0 margin_right = 256.0
margin_bottom = 20.0 margin_bottom = 16.0
size_flags_horizontal = 3 size_flags_horizontal = 3
color = Color( 0, 0.811765, 1, 1 ) max_value = 1.0
[connection signal="color_changed" from="scroll_container/controls/sky_top_color/color_picker_button" to="." method="_on_color_picker_button_color_changed"] step = 0.001
value = 0.5
[node name="sky_thickness_box_2" type="HBoxContainer" parent="scroll_container/controls/sky_box"]
margin_top = 20.0
margin_right = 256.0
margin_bottom = 36.0
[node name="label" type="Label" parent="scroll_container/controls/sky_box/sky_thickness_box_2"]
margin_top = 1.0
margin_right = 126.0
margin_bottom = 15.0
size_flags_horizontal = 3
text = "Thickness"
align = 2
[node name="sky_thickness" type="HSlider" parent="scroll_container/controls/sky_box/sky_thickness_box_2"]
margin_left = 130.0
margin_right = 256.0
margin_bottom = 16.0
size_flags_horizontal = 3
value = 25.0
[node name="sky_absorption_box_3" type="HBoxContainer" parent="scroll_container/controls/sky_box"]
margin_top = 40.0
margin_right = 256.0
margin_bottom = 56.0
[node name="label" type="Label" parent="scroll_container/controls/sky_box/sky_absorption_box_3"]
margin_top = 1.0
margin_right = 126.0
margin_bottom = 15.0
size_flags_horizontal = 3
text = "Absorbtion"
align = 2
[node name="sky_absorption" type="HSlider" parent="scroll_container/controls/sky_box/sky_absorption_box_3"]
margin_left = 130.0
margin_right = 256.0
margin_bottom = 16.0
size_flags_horizontal = 3
max_value = 10.0
step = 0.001
value = 1.031
[node name="sky_steps_box_4" type="HBoxContainer" parent="scroll_container/controls/sky_box"]
margin_top = 60.0
margin_right = 256.0
margin_bottom = 76.0
[node name="label" type="Label" parent="scroll_container/controls/sky_box/sky_steps_box_4"]
margin_top = 1.0
margin_right = 126.0
margin_bottom = 15.0
size_flags_horizontal = 3
text = "Steps"
align = 2
[node name="sky_steps" type="HSlider" parent="scroll_container/controls/sky_box/sky_steps_box_4"]
margin_left = 130.0
margin_right = 256.0
margin_bottom = 16.0
size_flags_horizontal = 3
value = 25.0
[connection signal="value_changed" from="scroll_container/controls/sky_box/sky_coverage_box/sky_coverage" to="." method="_on_sky_coverage_value_changed"]
[connection signal="value_changed" from="scroll_container/controls/sky_box/sky_thickness_box_2/sky_thickness" to="." method="_on_sky_thickness_value_changed"]
[connection signal="value_changed" from="scroll_container/controls/sky_box/sky_absorption_box_3/sky_absorption" to="." method="_on_sky_absorption_value_changed"]
[connection signal="value_changed" from="scroll_container/controls/sky_box/sky_steps_box_4/sky_steps" to="." method="_on_sky_steps_value_changed"]

View file

@ -10,13 +10,13 @@ func _process(delta):
self.material.set("shader_param/iFrame",global_v.iFrame) self.material.set("shader_param/iFrame",global_v.iFrame)
func cov_scb(value): func cov_scb(value):
self.material.set("shader_param/COVERAGE",float(value)/100) self.material.set("shader_param/COVERAGE",float(value))
func absb_scb(value):
self.material.set("shader_param/ABSORPTION",float(value)/10)
func thick_scb(value): func thick_scb(value):
self.material.set("shader_param/THICKNESS",value) self.material.set("shader_param/THICKNESS",value)
func absb_scb(value):
self.material.set("shader_param/ABSORPTION",float(value))
func step_scb(value): func step_scb(value):
self.material.set("shader_param/STEPS",value) self.material.set("shader_param/STEPS",value)

Binary file not shown.

Before

(image error) Size: 66 KiB

Binary file not shown.

Before

(image error) Size: 248 KiB