diff --git a/CamControl.gd b/CamControl.gd index 160a00e..fafe337 100644 --- a/CamControl.gd +++ b/CamControl.gd @@ -1,7 +1,12 @@ extends Camera const UP = Vector3(0, 1, 0) -const camera_speed = 0.5 +export var camera_speed = 0.5 + +var temp_translation; + +func _ready(): + temp_translation = translation func _physics_process(delta): @@ -10,13 +15,15 @@ func _physics_process(delta): var xform = get_transform() var upangle = acos(-xform.basis[2].dot(UP)) - if Input.is_key_pressed(KEY_LEFT): - translation += xform.basis[0] * speed * sin(upangle) - if Input.is_key_pressed(KEY_RIGHT): - translation -= xform.basis[0] * speed * sin(upangle) - if Input.is_key_pressed(KEY_DOWN): - translation += xform.basis[1] * speed - if Input.is_key_pressed(KEY_UP): - translation -= xform.basis[1] * speed + if Input.is_key_pressed(KEY_A): + temp_translation += xform.basis[0] * speed * sin(upangle) + if Input.is_key_pressed(KEY_D): + temp_translation -= xform.basis[0] * speed * sin(upangle) + if Input.is_key_pressed(KEY_S): + temp_translation += xform.basis[1] * speed + if Input.is_key_pressed(KEY_W): + temp_translation -= xform.basis[1] * speed + + translation = translation.linear_interpolate(temp_translation, 0.3) look_at(Vector3(), UP) diff --git a/FlareEditor.gd b/FlareEditor.gd index 56d5555..478361a 100644 --- a/FlareEditor.gd +++ b/FlareEditor.gd @@ -2,24 +2,26 @@ extends Panel onready var lens_flare = $"../LensFlare" -func _process(delta): - for i in $Settings.get_children(): - match i.name: - "FlareStrength": - lens_flare.flareStrength = \ - $Settings/FlareStrength/HSlider.value - "FlareBias": - lens_flare.flareBias = \ - $Settings/FlareBias/HSlider.value - "Distortion": - lens_flare.distortion = \ - $Settings/Distortion/HSlider.value - "GhostCount": - lens_flare.ghostCount = \ - $Settings/GhostCount/HSlider.value - "GhostSpacing": - lens_flare.ghostSpacing = \ - $Settings/GhostSpacing/HSlider.value - "HaloWidth": - lens_flare.haloWidth = \ - $Settings/HaloWidth/HSlider.value +func _on_FlareStrength_value_changed(value): + lens_flare.flareStrength = value + +func _on_FlareBias_value_changed(value): + lens_flare.flareBias = value + +func _on_FlareBlur_value_changed(value): + lens_flare.flareBlur = value + +func _on_Distortion_value_changed(value): + lens_flare.distortion = value + +func _on_GhostCount_value_changed(value): + lens_flare.ghostCount = value + +func _on_GhostSpacing_value_changed(value): + lens_flare.ghostSpacing = value + +func _on_HaloWidth_value_changed(value): + lens_flare.haloWidth = value + +func _on_DistortQuality_item_selected(ID): + lens_flare.distortionQuality = ID diff --git a/LensFlare.tscn b/LensFlare.tscn index 82784cf..68f7da0 100644 --- a/LensFlare.tscn +++ b/LensFlare.tscn @@ -1,26 +1,21 @@ -[gd_scene load_steps=9 format=2] +[gd_scene load_steps=11 format=2] [ext_resource path="res://addons/SIsilicon.vfx.lens flare/lens-flare.gd" type="Script" id=1] [ext_resource path="res://addons/SIsilicon.vfx.lens flare/lens_flare_icon.png" type="Texture" id=2] -[ext_resource path="res://addons/SIsilicon.vfx.lens flare/lens-dirt-default.jpeg" type="Texture" id=3] -[ext_resource path="res://CamControl.gd" type="Script" id=4] -[ext_resource path="res://FlareEditor.gd" type="Script" id=5] +[ext_resource path="res://CamControl.gd" type="Script" id=3] +[ext_resource path="res://FlareEditor.gd" type="Script" id=4] +[ext_resource path="res://Slider.tscn" type="PackedScene" id=5] [ext_resource path="res://Square.ttf" type="DynamicFontData" id=6] -[sub_resource type="DynamicFont" id=2] - +[sub_resource type="DynamicFont" id=1] size = 20 use_mipmaps = true use_filter = true font_data = ExtResource( 6 ) -_sections_unfolded = [ "Resource", "Settings" ] - -[sub_resource type="Animation" id=3] +[sub_resource type="Animation" id=2] resource_name = "instruction" length = 4.0 -loop = false -step = 0.1 tracks/0/type = "value" tracks/0/path = NodePath(".:custom_colors/font_color") tracks/0/interp = 1 @@ -46,514 +41,156 @@ tracks/1/keys = { "values": [ Vector2( 0, 578 ), Vector2( 0, 578 ), Vector2( 0, 700 ) ] } -[node name="Main" type="Node" index="0"] +[sub_resource type="ProceduralSky" id=3] +ground_energy = 0.5 +sun_angle_max = 24.52 +sun_energy = 16.0 + +[sub_resource type="Environment" id=4] +background_mode = 2 +background_sky = SubResource( 3 ) +tonemap_mode = 1 +auto_exposure_enabled = true +adjustment_brightness = 0.67 +adjustment_contrast = 1.91 -[node name="LensFlare" type="Node" parent="." index="0"] +[node name="Main" type="Node"] +[node name="LensFlare" type="Node" parent="."] script = ExtResource( 1 ) __meta__ = { "_editor_icon": ExtResource( 2 ) } -flareStrength = 10.0 -flareBias = 1.05 -distortion = 2 -ghostCount = 7 -ghostSpacing = 0.3 -haloWidth = 0.25 -lensDirt = ExtResource( 3 ) +flareStrength = 0.41 +flareBias = 3.644 +distortionQuality = 1 +distortion = 4.28 +ghostSpacing = 0.307 +haloWidth = 0.253 -[node name="CameraBase" type="Position3D" parent="." index="1"] - -[node name="Camera" type="Camera" parent="CameraBase" index="0"] +[node name="CameraBase" type="Position3D" parent="."] +[node name="Camera" type="Camera" parent="CameraBase"] transform = Transform( 0.990683, 0.0787858, 0.111085, -0.00953811, 0.853812, -0.520493, -0.135853, 0.514584, 0.846609, 0.140886, -0.660126, 1.07524 ) -keep_aspect = 1 -cull_mask = 1048575 -environment = null -h_offset = 0.0 -v_offset = 0.0 -doppler_tracking = 0 -projection = 0 -current = false -fov = 70.0 -size = 1.0 -near = 0.05 -far = 100.0 -script = ExtResource( 4 ) - -[node name="Panel" type="Panel" parent="." index="2"] +script = ExtResource( 3 ) +camera_speed = 2.17 +[node name="Panel" type="Panel" parent="."] editor/display_folded = true -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 anchor_bottom = 1.0 -margin_right = 240.0 -margin_bottom = -463.0 +margin_right = 299.0 +margin_bottom = -423.0 rect_min_size = Vector2( 240, 0 ) -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -mouse_filter = 0 -mouse_default_cursor_shape = 0 -size_flags_horizontal = 1 -size_flags_vertical = 1 -script = ExtResource( 5 ) -_sections_unfolded = [ "Rect", "Size Flags" ] - -[node name="Settings" type="VBoxContainer" parent="Panel" index="0"] +script = ExtResource( 4 ) -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 +[node name="Settings" type="VBoxContainer" parent="Panel"] +editor/display_folded = true +anchor_right = 1.0 anchor_bottom = 1.0 -margin_left = 20.0 -margin_top = 10.0 -margin_right = 200.0 +margin_left = 10.0 +margin_top = 7.0 +margin_right = -10.0 margin_bottom = -10.0 rect_min_size = Vector2( 200, 0 ) -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -mouse_filter = 1 -mouse_default_cursor_shape = 0 -size_flags_horizontal = 1 -size_flags_vertical = 1 -alignment = 0 -_sections_unfolded = [ "Margin", "Rect" ] - -[node name="FlareStrength" type="HBoxContainer" parent="Panel/Settings" index="0"] - -editor/display_folded = true -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 -margin_right = 200.0 -margin_bottom = 16.0 -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -mouse_filter = 1 -mouse_default_cursor_shape = 0 -size_flags_horizontal = 1 -size_flags_vertical = 1 -alignment = 0 -[node name="Label" type="Label" parent="Panel/Settings/FlareStrength" index="0"] - -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 -margin_top = 1.0 -margin_right = 88.0 -margin_bottom = 15.0 -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -mouse_filter = 2 -mouse_default_cursor_shape = 0 -size_flags_horizontal = 1 -size_flags_vertical = 4 +[node name="FlareStrength" parent="Panel/Settings" instance=ExtResource( 5 )] +margin_right = 279.0 text = "Flare Strength" -percent_visible = 1.0 -lines_skipped = 0 -max_lines_visible = -1 - -[node name="HSlider" type="HSlider" parent="Panel/Settings/FlareStrength" index="1"] - -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 -margin_left = 92.0 -margin_right = 200.0 -margin_bottom = 16.0 -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -focus_mode = 2 -mouse_filter = 0 -mouse_default_cursor_shape = 0 -size_flags_horizontal = 3 -size_flags_vertical = 0 -min_value = 0.0 -max_value = 20.0 -step = 0.1 -page = 0.0 -value = 10.0 -exp_edit = false -rounded = false -editable = true -tick_count = 0 -ticks_on_borders = false -focus_mode = 2 - -[node name="FlareBias" type="HBoxContainer" parent="Panel/Settings" index="1"] +max_value = 3.0 +value = 1.0 -editor/display_folded = true -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 +[node name="FlareBias" parent="Panel/Settings" instance=ExtResource( 5 )] margin_top = 20.0 -margin_right = 200.0 +margin_right = 279.0 margin_bottom = 36.0 -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -mouse_filter = 1 -mouse_default_cursor_shape = 0 -size_flags_horizontal = 1 -size_flags_vertical = 1 -alignment = 0 - -[node name="Label" type="Label" parent="Panel/Settings/FlareBias" index="0"] - -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 -margin_top = 1.0 -margin_right = 62.0 -margin_bottom = 15.0 -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -mouse_filter = 2 -mouse_default_cursor_shape = 0 -size_flags_horizontal = 1 -size_flags_vertical = 4 text = "Flare Bias" -percent_visible = 1.0 -lines_skipped = 0 -max_lines_visible = -1 - -[node name="HSlider" type="HSlider" parent="Panel/Settings/FlareBias" index="1"] - -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 -margin_left = 66.0 -margin_right = 200.0 -margin_bottom = 16.0 -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -focus_mode = 2 -mouse_filter = 0 -mouse_default_cursor_shape = 0 -size_flags_horizontal = 3 -size_flags_vertical = 0 -min_value = 0.0 -max_value = 2.0 -step = 0.01 -page = 0.0 -value = 1.0 -exp_edit = false -rounded = false -editable = true -tick_count = 0 -ticks_on_borders = false -focus_mode = 2 -_sections_unfolded = [ "Size Flags" ] - -[node name="Distortion" type="HBoxContainer" parent="Panel/Settings" index="2"] +max_value = 20.0 +value = 8.0 -editor/display_folded = true -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 +[node name="FlareBlur" parent="Panel/Settings" instance=ExtResource( 5 )] margin_top = 40.0 -margin_right = 200.0 +margin_right = 279.0 margin_bottom = 56.0 -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -mouse_filter = 1 -mouse_default_cursor_shape = 0 -size_flags_horizontal = 1 -size_flags_vertical = 1 -alignment = 0 - -[node name="Label" type="Label" parent="Panel/Settings/Distortion" index="0"] - -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 -margin_top = 1.0 -margin_right = 64.0 -margin_bottom = 15.0 -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -mouse_filter = 2 -mouse_default_cursor_shape = 0 -size_flags_horizontal = 1 -size_flags_vertical = 4 -text = "Distortion" -percent_visible = 1.0 -lines_skipped = 0 -max_lines_visible = -1 - -[node name="HSlider" type="HSlider" parent="Panel/Settings/Distortion" index="1"] - -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 -margin_left = 68.0 -margin_right = 200.0 -margin_bottom = 16.0 -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -focus_mode = 2 -mouse_filter = 0 -mouse_default_cursor_shape = 0 -size_flags_horizontal = 3 -size_flags_vertical = 0 -min_value = 0.0 -max_value = 16.0 -step = 0.001 -page = 0.0 -value = 2.0 -exp_edit = false -rounded = false -editable = true -tick_count = 0 -ticks_on_borders = false -focus_mode = 2 -_sections_unfolded = [ "Size Flags" ] - -[node name="GhostCount" type="HBoxContainer" parent="Panel/Settings" index="3"] +text = "Flare Blur" +max_value = 8.0 +value = 1.0 -editor/display_folded = true -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 +[node name="Distortion" parent="Panel/Settings" instance=ExtResource( 5 )] margin_top = 60.0 -margin_right = 200.0 +margin_right = 279.0 margin_bottom = 76.0 -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -mouse_filter = 1 -mouse_default_cursor_shape = 0 -size_flags_horizontal = 1 -size_flags_vertical = 1 -alignment = 0 - -[node name="Label" type="Label" parent="Panel/Settings/GhostCount" index="0"] - -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 -margin_top = 1.0 -margin_right = 79.0 -margin_bottom = 15.0 -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -mouse_filter = 2 -mouse_default_cursor_shape = 0 -size_flags_horizontal = 1 -size_flags_vertical = 4 -text = "Ghost Count" -percent_visible = 1.0 -lines_skipped = 0 -max_lines_visible = -1 - -[node name="HSlider" type="HSlider" parent="Panel/Settings/GhostCount" index="1"] +text = "Distortion" +max_value = 50.0 +value = 10.0 -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 -margin_left = 83.0 -margin_right = 200.0 -margin_bottom = 16.0 -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -focus_mode = 2 -mouse_filter = 0 -mouse_default_cursor_shape = 0 +[node name="DistortQuality" type="HBoxContainer" parent="Panel/Settings"] +editor/display_folded = true +margin_top = 80.0 +margin_right = 279.0 +margin_bottom = 100.0 + +[node name="Label" type="Label" parent="Panel/Settings/DistortQuality"] +margin_top = 3.0 +margin_right = 122.0 +margin_bottom = 17.0 +text = "Distortion Quality: " + +[node name="OptionButton" type="OptionButton" parent="Panel/Settings/DistortQuality"] +margin_left = 126.0 +margin_right = 279.0 +margin_bottom = 20.0 size_flags_horizontal = 3 -size_flags_vertical = 0 -min_value = 0.0 +text = "Low" +items = [ "Low", null, false, 0, null, "Medium", null, false, 1, null, "High", null, false, 2, null ] +selected = 0 + +[node name="GhostCount" parent="Panel/Settings" instance=ExtResource( 5 )] +margin_top = 104.0 +margin_right = 279.0 +margin_bottom = 120.0 +text = "Ghost Count" max_value = 20.0 -step = 1.0 -page = 0.0 value = 7.0 -exp_edit = false -rounded = false -editable = true -tick_count = 0 -ticks_on_borders = false -focus_mode = 2 -_sections_unfolded = [ "Size Flags" ] - -[node name="GhostSpacing" type="HBoxContainer" parent="Panel/Settings" index="4"] - -editor/display_folded = true -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 -margin_top = 80.0 -margin_right = 200.0 -margin_bottom = 96.0 -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -mouse_filter = 1 -mouse_default_cursor_shape = 0 -size_flags_horizontal = 1 -size_flags_vertical = 1 -alignment = 0 - -[node name="Label" type="Label" parent="Panel/Settings/GhostSpacing" index="0"] -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 -margin_top = 1.0 -margin_right = 90.0 -margin_bottom = 15.0 -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -mouse_filter = 2 -mouse_default_cursor_shape = 0 -size_flags_horizontal = 1 -size_flags_vertical = 4 +[node name="GhostSpacing" parent="Panel/Settings" instance=ExtResource( 5 )] +margin_top = 124.0 +margin_right = 279.0 +margin_bottom = 140.0 text = "Ghost Spacing" -percent_visible = 1.0 -lines_skipped = 0 -max_lines_visible = -1 - -[node name="HSlider" type="HSlider" parent="Panel/Settings/GhostSpacing" index="1"] - -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 -margin_left = 94.0 -margin_right = 200.0 -margin_bottom = 16.0 -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -focus_mode = 2 -mouse_filter = 0 -mouse_default_cursor_shape = 0 -size_flags_horizontal = 3 -size_flags_vertical = 0 -min_value = 0.0 -max_value = 1.0 -step = 0.001 -page = 0.0 value = 0.3 -exp_edit = false -rounded = false -editable = true -tick_count = 0 -ticks_on_borders = false -focus_mode = 2 -_sections_unfolded = [ "Size Flags" ] - -[node name="HaloWidth" type="HBoxContainer" parent="Panel/Settings" index="5"] - -editor/display_folded = true -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 -margin_top = 100.0 -margin_right = 200.0 -margin_bottom = 116.0 -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -mouse_filter = 1 -mouse_default_cursor_shape = 0 -size_flags_horizontal = 1 -size_flags_vertical = 1 -alignment = 0 -[node name="Label" type="Label" parent="Panel/Settings/HaloWidth" index="0"] - -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 -margin_top = 1.0 -margin_right = 71.0 -margin_bottom = 15.0 -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -mouse_filter = 2 -mouse_default_cursor_shape = 0 -size_flags_horizontal = 1 -size_flags_vertical = 4 +[node name="HaloWidth" parent="Panel/Settings" instance=ExtResource( 5 )] +margin_top = 144.0 +margin_right = 279.0 +margin_bottom = 160.0 text = "Halo Width" -percent_visible = 1.0 -lines_skipped = 0 -max_lines_visible = -1 - -[node name="HSlider" type="HSlider" parent="Panel/Settings/HaloWidth" index="1"] - -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 -margin_left = 75.0 -margin_right = 200.0 -margin_bottom = 16.0 -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -focus_mode = 2 -mouse_filter = 0 -mouse_default_cursor_shape = 0 -size_flags_horizontal = 3 -size_flags_vertical = 0 -min_value = 0.0 -max_value = 1.0 -step = 0.001 -page = 0.0 -value = 0.25 -exp_edit = false -rounded = false -editable = true -tick_count = 0 -ticks_on_borders = false -focus_mode = 2 -_sections_unfolded = [ "Size Flags" ] - -[node name="LookAround" type="Label" parent="." index="3"] +value = 0.54 +[node name="LookAround" type="Label" parent="."] editor/display_folded = true -anchor_left = 0.0 anchor_top = 1.0 anchor_right = 1.0 anchor_bottom = 1.0 margin_top = 51.0 margin_bottom = 73.0 -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -mouse_filter = 2 -mouse_default_cursor_shape = 0 -size_flags_horizontal = 1 -size_flags_vertical = 4 -custom_fonts/font = SubResource( 2 ) +custom_fonts/font = SubResource( 1 ) custom_colors/font_color = Color( 1, 1, 1, 1 ) custom_colors/font_color_shadow = Color( 0, 0, 0, 1 ) custom_constants/shadow_as_outline = 1 -text = "You may look around with the arrow keys" +text = "You may look around with the WASD keys" align = 1 -percent_visible = 1.0 -lines_skipped = 0 -max_lines_visible = -1 -_sections_unfolded = [ "Rect", "custom_colors", "custom_constants", "custom_fonts" ] - -[node name="AnimationPlayer" type="AnimationPlayer" parent="LookAround" index="0"] -root_node = NodePath("..") +[node name="AnimationPlayer" type="AnimationPlayer" parent="LookAround"] autoplay = "instruction" -playback_process_mode = 1 -playback_default_blend_time = 0.0 -playback_speed = 1.0 -anims/instruction = SubResource( 3 ) -blend_times = [ ] - - +anims/instruction = SubResource( 2 ) + +[node name="WorldEnvironment" type="WorldEnvironment" parent="."] +environment = SubResource( 4 ) +[connection signal="value_changed" from="Panel/Settings/FlareStrength" to="Panel" method="_on_FlareStrength_value_changed"] +[connection signal="value_changed" from="Panel/Settings/FlareBias" to="Panel" method="_on_FlareBias_value_changed"] +[connection signal="value_changed" from="Panel/Settings/FlareBlur" to="Panel" method="_on_FlareBlur_value_changed"] +[connection signal="value_changed" from="Panel/Settings/Distortion" to="Panel" method="_on_Distortion_value_changed"] +[connection signal="item_selected" from="Panel/Settings/DistortQuality/OptionButton" to="Panel" method="_on_DistortQuality_item_selected"] +[connection signal="value_changed" from="Panel/Settings/GhostCount" to="Panel" method="_on_GhostCount_value_changed"] +[connection signal="value_changed" from="Panel/Settings/GhostSpacing" to="Panel" method="_on_GhostSpacing_value_changed"] +[connection signal="value_changed" from="Panel/Settings/HaloWidth" to="Panel" method="_on_HaloWidth_value_changed"] diff --git a/Slider.gd b/Slider.gd new file mode 100644 index 0000000..bc11e86 --- /dev/null +++ b/Slider.gd @@ -0,0 +1,39 @@ +tool +extends HBoxContainer + +signal value_changed(value) + +export(String) var text = "Slider" setget set_text +export(float) var min_value = 0 setget set_min_value +export(float) var max_value = 1 setget set_max_value +export(float) var value = 0 setget set_value + +func _ready(): + set_text(text) + set_min_value(min_value) + set_max_value(max_value) + set_value(value) + +func set_text(string): + text = string + if has_node("Name"): + $Name.text = text + ": " + +func set_value(val): + value = val + if has_node("HSlider"): + $HSlider.value = value + +func set_min_value(val): + min_value = min(val, max_value) + if has_node("HSlider"): + $HSlider.min_value = min_value + +func set_max_value(val): + max_value = max(val, min_value) + if has_node("HSlider"): + $HSlider.max_value = max_value + +func _on_HSlider_value_changed(value): + emit_signal("value_changed", value) + $Value.text = str(stepify(value, 0.01)) diff --git a/Slider.tscn b/Slider.tscn new file mode 100644 index 0000000..f0e0d5b --- /dev/null +++ b/Slider.tscn @@ -0,0 +1,31 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://Slider.gd" type="Script" id=1] + +[node name="Slider" type="HBoxContainer"] +margin_right = 180.0 +margin_bottom = 16.0 +script = ExtResource( 1 ) + +[node name="Name" type="Label" parent="."] +margin_right = 44.0 +margin_bottom = 14.0 +size_flags_vertical = 0 +text = "Slider: " + +[node name="HSlider" type="HSlider" parent="."] +margin_left = 48.0 +margin_right = 168.0 +margin_bottom = 16.0 +size_flags_horizontal = 3 +max_value = 1.0 +step = 0.0 +ticks_on_borders = true + +[node name="Value" type="Label" parent="."] +margin_left = 172.0 +margin_right = 180.0 +margin_bottom = 14.0 +size_flags_vertical = 0 +text = "0" +[connection signal="value_changed" from="HSlider" to="." method="_on_HSlider_value_changed"] diff --git a/addons/SIsilicon.vfx.lens flare/lens-dirt-default.jpeg.import b/addons/SIsilicon.vfx.lens flare/lens-dirt-default.jpeg.import index 838e178..4990118 100644 --- a/addons/SIsilicon.vfx.lens flare/lens-dirt-default.jpeg.import +++ b/addons/SIsilicon.vfx.lens flare/lens-dirt-default.jpeg.import @@ -2,22 +2,24 @@ importer="texture" type="StreamTexture" -path.s3tc="res://.import/lens-dirt-default.jpeg-828e5aa76d932e6bcde673258028877b.s3tc.stex" -path.etc2="res://.import/lens-dirt-default.jpeg-828e5aa76d932e6bcde673258028877b.etc2.stex" +path.s3tc="res://.import/lens-dirt-default.jpeg-a62a38d2886058134e76bf727c9a6764.s3tc.stex" +path.etc2="res://.import/lens-dirt-default.jpeg-a62a38d2886058134e76bf727c9a6764.etc2.stex" +metadata={ +"imported_formats": [ "s3tc", "etc2" ], +"vram_texture": true +} [deps] -source_file="res://addons/sisilicon.vfx.lensflare/lens-dirt-default.jpeg" -source_md5="84e6c648d6fa7d35db61ec89e3e8664e" - -dest_files=[ "res://.import/lens-dirt-default.jpeg-828e5aa76d932e6bcde673258028877b.s3tc.stex", "res://.import/lens-dirt-default.jpeg-828e5aa76d932e6bcde673258028877b.etc2.stex" ] -dest_md5="75d09501ecbfac0e4ee06ba90fd15d2c" +source_file="res://addons/SIsilicon.vfx.lens flare/lens-dirt-default.jpeg" +dest_files=[ "res://.import/lens-dirt-default.jpeg-a62a38d2886058134e76bf727c9a6764.s3tc.stex", "res://.import/lens-dirt-default.jpeg-a62a38d2886058134e76bf727c9a6764.etc2.stex" ] [params] compress/mode=2 compress/lossy_quality=0.7 compress/hdr_mode=0 +compress/bptc_ldr=0 compress/normal_map=0 flags/repeat=true flags/filter=true @@ -27,6 +29,7 @@ flags/srgb=2 process/fix_alpha_border=true process/premult_alpha=false process/HDR_as_SRGB=false +process/invert_color=false stream=false size_limit=0 detect_3d=false diff --git a/addons/SIsilicon.vfx.lens flare/lens-flare-shader.tres b/addons/SIsilicon.vfx.lens flare/lens-flare-shader.tres index 9f05178..df345ab 100644 --- a/addons/SIsilicon.vfx.lens flare/lens-flare-shader.tres +++ b/addons/SIsilicon.vfx.lens flare/lens-flare-shader.tres @@ -1,15 +1,12 @@ -[gd_resource type="ShaderMaterial" load_steps=4 format=2] +[gd_resource type="ShaderMaterial" load_steps=7 format=2] -[sub_resource type="Shader" id=1] +[ext_resource path="res://addons/SIsilicon.vfx.lens flare/lens-dirt-default.jpeg" type="Texture" id=1] +[sub_resource type="Shader" id=1] code = "shader_type spatial; render_mode skip_vertex_transform, unshaded, blend_add; -void vertex() { - VERTEX = (INV_PROJECTION_MATRIX * vec4(VERTEX, 1.0)).xyz; - VERTEX.z += 0.95; - VERTEX.xy *= 20.0; -} +uniform float lod = 0.0; uniform int ghosts = 4; uniform float ghost_dispersal = 0.5; @@ -19,25 +16,46 @@ uniform float distort = 0.25; uniform float bloom_scale = 10.0; uniform float bloom_bias = 0.95; +uniform int distortion_quality : hint_range(0, 2); + uniform sampler2D lens_color; -uniform sampler2D lens_dirt: hint_color_white; +uniform sampler2D lens_dirt; +uniform sampler2D starburst; + +void vertex() { + POSITION = vec4(VERTEX, 1.0); + POSITION.z = -1.0; +} float weight(vec2 pos) { float w = length(vec2(0.5) - pos) / length(vec2(0.5)); return pow(1.0 - w, 5.0); } -vec4 bloomtex(in sampler2D tex, in vec2 texcoord, in float lod) { - return max(vec4(0.0), texture(tex, texcoord, lod) - bloom_bias) * bloom_scale; +vec3 bloomtex(sampler2D tex, vec2 texcoord) { + return max(vec3(0.0), textureLod(tex, texcoord, lod).rgb - bloom_bias) * bloom_scale; } -vec4 textureDistorted(in sampler2D tex, in vec2 texcoord, in vec2 direction, in vec3 distortion) { - return vec4( - bloomtex(tex, texcoord + direction * distortion.r, 2.0).r, - bloomtex(tex, texcoord + direction * distortion.g, 2.0).g, - bloomtex(tex, texcoord + direction * distortion.b, 2.0).b, - 1.0 - ); +vec3 textureDistorted(sampler2D tex, vec2 texcoord, vec2 direction, float distortion) { + vec3 color = vec3(0); + float divisor = 1.0; + color.r += bloomtex(tex, texcoord - direction * distortion).r; + color.g += bloomtex(tex, texcoord).g; + color.b += bloomtex(tex, texcoord + direction * distortion).b; + + if(distortion_quality == 1) { + color.rg += bloomtex(tex, texcoord - direction * distortion * 0.5).rg * vec2(1.0, 0.5); + color.gb += bloomtex(tex, texcoord + direction * distortion * 0.5).gb * vec2(0.5, 1.0); + divisor = 2.0; + } else if(distortion_quality == 2) { + color.rg += bloomtex(tex, texcoord - direction * distortion * 0.667).rg * vec2(1.0, 0.333); + color.rg += bloomtex(tex, texcoord - direction * distortion * 0.333).rg * vec2(1.0, 0.667); + color.gb += bloomtex(tex, texcoord + direction * distortion * 0.333).gb * vec2(0.667, 1.0); + color.gb += bloomtex(tex, texcoord + direction * distortion * 0.667).gb * vec2(0.333, 1.0); + divisor = 3.0; + } + + return color / divisor; } void fragment() { @@ -46,47 +64,59 @@ void fragment() { float pixelSizeX = 1.0 / float(textureSize(SCREEN_TEXTURE, 0).x); - vec3 distortion = vec3(-pixelSizeX * distort, 0.0, pixelSizeX * distort); + float distortion = pixelSizeX * distort; vec2 direction = normalize(ghostVec); vec3 result = vec3(0.0); for(int i = 0; i < ghosts; ++i) { vec2 offset = fract(texcoord + ghostVec * float(i)); - result += textureDistorted(SCREEN_TEXTURE, offset, direction, distortion).rgb * weight(offset); + result += textureDistorted(SCREEN_TEXTURE, offset, direction, distortion * weight(offset)) * weight(offset); } result *= texture(lens_color, vec2(length(vec2(0.5) - texcoord) / length(vec2(0.5)), 0)).rgb; - vec2 haloVec = normalize(ghostVec) * halo_width; - result += textureDistorted(SCREEN_TEXTURE, texcoord + haloVec, direction, distortion).rgb * weight(fract(texcoord + haloVec)); + result += textureDistorted(SCREEN_TEXTURE, texcoord + haloVec, direction, distortion) * weight(fract(texcoord + haloVec)); + + vec2 centerVec = SCREEN_UV - vec2(0.5); + float d = length(centerVec); + float radial = acos(centerVec.x / d); + + float starOffset = dot(CAMERA_MATRIX[2].xyz, vec3(1.0)) * 10.0; + float star = + texture(starburst, vec2(radial + starOffset)).r + * texture(starburst, vec2(radial + starOffset * 0.5)).r; + star = clamp(star + (1.0 - smoothstep(0.0, 0.3, d)), 0.0, 1.0); + result *= star; ALBEDO = result * mix(texture(lens_dirt, texcoord).rgb, vec3(0.5), 0.4); //uncomment to debug bright point extraction - //COLOR = bloomtex(SCREEN_TEXTURE, SCREEN_UV, 2.0); + //ALBEDO = bloomtex(SCREEN_TEXTURE, SCREEN_UV).rgb; }" [sub_resource type="Gradient" id=2] - -offsets = PoolRealArray( 0, 0.106509, 0.142012, 0.189349, 0.295858, 0.461538, 0.538462, 0.550296, 0.928994, 1 ) -colors = PoolColorArray( 1, 1, 1, 1, 0.65625, 1, 0.97583, 1, 1, 1, 1, 1, 0.531006, 0.78125, 0.570107, 1, 0.309998, 0.168106, 0.522199, 1, 0.261653, 0.0339813, 0.511719, 1, 0.691406, 0.108032, 0.244761, 1, 0.706731, 0.417368, 0.109337, 1, 0.774481, 0.756324, 0.309654, 1, 0.890625, 0.125, 1, 1 ) +colors = PoolColorArray( 0.774481, 0.756324, 0.309654, 1, 0.890625, 0.125, 1, 1 ) [sub_resource type="GradientTexture" id=3] - -flags = 4 gradient = SubResource( 2 ) -width = 2048 -[resource] +[sub_resource type="OpenSimplexNoise" id=4] +period = 2.0 + +[sub_resource type="NoiseTexture" id=5] +height = 1 +noise = SubResource( 4 ) -render_priority = 0 +[resource] shader = SubResource( 1 ) +shader_param/lod = 0.0 shader_param/ghosts = 7 shader_param/ghost_dispersal = 0.3 -shader_param/halo_width = 0.25 -shader_param/distort = 2 -shader_param/bloom_scale = 10.0 -shader_param/bloom_bias = 1.05 +shader_param/halo_width = 0.282 +shader_param/distort = 6.57 +shader_param/bloom_scale = 0.294 +shader_param/bloom_bias = 7.295 +shader_param/distortion_quality = null shader_param/lens_color = SubResource( 3 ) -_sections_unfolded = [ "Resource", "shader_param" ] - +shader_param/lens_dirt = ExtResource( 1 ) +shader_param/starburst = SubResource( 5 ) diff --git a/addons/SIsilicon.vfx.lens flare/lens-flare.gd b/addons/SIsilicon.vfx.lens flare/lens-flare.gd index 9e85b6a..fa530bf 100644 --- a/addons/SIsilicon.vfx.lens flare/lens-flare.gd +++ b/addons/SIsilicon.vfx.lens flare/lens-flare.gd @@ -2,8 +2,11 @@ tool extends Node export(float, 0, 100) var flareStrength = 10.0 setget set_flare_strength -export(float, 0, 2) var flareBias = 1.05 setget set_flare_bias -export(float, 0, 16) var distortion = 2 setget set_flare_distortion +export(float, 0, 16) var flareBias = 1.05 setget set_flare_bias +export(float, 0, 10) var flareBlur = 2 setget set_flare_blur; + +export(int, "Low", "Medium", "High") var distortionQuality = 0 setget set_distortion_quality; +export(float, 0, 50) var distortion = 2 setget set_flare_distortion export(int, 0.01, 100) var ghostCount = 7 setget set_ghost_count export(float, 0, 1) var ghostSpacing = 0.3 setget set_ghost_spacing @@ -19,7 +22,7 @@ func _init(): screen.mesh = CubeMesh.new() screen.scale = Vector3(1,1,1) * pow(2.0,30); add_child(screen) - screen.material_override = preload("lens-flare-shader.tres") + screen.material_override = preload("lens-flare-shader.tres").duplicate() material = screen.material_override func set_flare_strength(strength): @@ -34,6 +37,10 @@ func set_flare_distortion(distort): distortion = distort material.set_shader_param('distort', distort) +func set_distortion_quality(quality): + distortionQuality = quality + material.set_shader_param('distortion_quality', quality) + func set_ghost_count(count): ghostCount = count material.set_shader_param('ghosts', count) @@ -46,6 +53,10 @@ func set_halo_width(width): haloWidth = width material.set_shader_param('halo_width', width) +func set_flare_blur(blur): + flareBlur = blur + material.set_shader_param('lod', flareBlur) + func set_lens_dirt(tex): lensDirt = tex material.set_shader_param('lens_dirt', tex) diff --git a/addons/SIsilicon.vfx.lens flare/lens_flare_icon.png.import b/addons/SIsilicon.vfx.lens flare/lens_flare_icon.png.import index 2444d72..3df9108 100644 --- a/addons/SIsilicon.vfx.lens flare/lens_flare_icon.png.import +++ b/addons/SIsilicon.vfx.lens flare/lens_flare_icon.png.import @@ -2,21 +2,22 @@ importer="texture" type="StreamTexture" -path="res://.import/lens_flare_icon.png-b2d5fbd774d9ca6b5b09d5f6b3bd50be.stex" +path="res://.import/lens_flare_icon.png-bcf2b67e5e10c8f62cd3e9816f0925e0.stex" +metadata={ +"vram_texture": false +} [deps] -source_file="res://addons/sisilicon.vfx.lensflare/lens_flare_icon.png" -source_md5="50491da54fed7425c389e7f344dcc3dd" - -dest_files=[ "res://.import/lens_flare_icon.png-b2d5fbd774d9ca6b5b09d5f6b3bd50be.stex" ] -dest_md5="a9608a2d288141d46345ed31c596355c" +source_file="res://addons/SIsilicon.vfx.lens flare/lens_flare_icon.png" +dest_files=[ "res://.import/lens_flare_icon.png-bcf2b67e5e10c8f62cd3e9816f0925e0.stex" ] [params] compress/mode=0 compress/lossy_quality=0.7 compress/hdr_mode=0 +compress/bptc_ldr=0 compress/normal_map=0 flags/repeat=0 flags/filter=true @@ -26,6 +27,7 @@ flags/srgb=2 process/fix_alpha_border=true process/premult_alpha=false process/HDR_as_SRGB=false +process/invert_color=false stream=false size_limit=0 detect_3d=true diff --git a/addons/SIsilicon.vfx.lens flare/plugin.cfg b/addons/SIsilicon.vfx.lens flare/plugin.cfg index 3a3a1b9..301ba09 100644 --- a/addons/SIsilicon.vfx.lens flare/plugin.cfg +++ b/addons/SIsilicon.vfx.lens flare/plugin.cfg @@ -1,7 +1,7 @@ [plugin] name="LensFlare Effect" -description="A post-processing effect that generates the lens flare phenomenon caused by real world cameras. It may not be physically accurate, but it can suffice for most scenarios." +description="A post-processing effect that generates the lens flare effect that happen in real world cameras. It may not be physically accurate, but it can suffice for most scenarios." author="SIsilicon" -version="1.0.1" +version="1.2" script="lens-flare-plugin.gd" \ No newline at end of file diff --git a/default_env.tres b/default_env.tres index ad86b72..dfe62ab 100644 --- a/default_env.tres +++ b/default_env.tres @@ -1,101 +1,14 @@ [gd_resource type="Environment" load_steps=2 format=2] [sub_resource type="ProceduralSky" id=1] - -radiance_size = 4 sky_top_color = Color( 0.0470588, 0.454902, 0.976471, 1 ) sky_horizon_color = Color( 0.556863, 0.823529, 0.909804, 1 ) sky_curve = 0.25 -sky_energy = 1.0 ground_bottom_color = Color( 0.101961, 0.145098, 0.188235, 1 ) ground_horizon_color = Color( 0.482353, 0.788235, 0.952941, 1 ) ground_curve = 0.01 -ground_energy = 1.0 -sun_color = Color( 1, 1, 1, 1 ) -sun_latitude = 35.0 -sun_longitude = 0.0 -sun_angle_min = 1.0 -sun_angle_max = 100.0 -sun_curve = 0.05 sun_energy = 16.0 -texture_size = 2 [resource] - background_mode = 2 background_sky = SubResource( 1 ) -background_sky_custom_fov = 0.0 -background_color = Color( 0, 0, 0, 1 ) -background_energy = 1.0 -background_canvas_max_layer = 0 -ambient_light_color = Color( 0, 0, 0, 1 ) -ambient_light_energy = 1.0 -ambient_light_sky_contribution = 1.0 -fog_enabled = false -fog_color = Color( 0.5, 0.6, 0.7, 1 ) -fog_sun_color = Color( 1, 0.9, 0.7, 1 ) -fog_sun_amount = 0.0 -fog_depth_enabled = true -fog_depth_begin = 10.0 -fog_depth_curve = 1.0 -fog_transmit_enabled = false -fog_transmit_curve = 1.0 -fog_height_enabled = false -fog_height_min = 0.0 -fog_height_max = 100.0 -fog_height_curve = 1.0 -tonemap_mode = 0 -tonemap_exposure = 1.0 -tonemap_white = 1.0 -auto_exposure_enabled = false -auto_exposure_scale = 0.4 -auto_exposure_min_luma = 0.05 -auto_exposure_max_luma = 8.0 -auto_exposure_speed = 0.5 -ss_reflections_enabled = false -ss_reflections_max_steps = 64 -ss_reflections_fade_in = 0.15 -ss_reflections_fade_out = 2.0 -ss_reflections_depth_tolerance = 0.2 -ss_reflections_roughness = true -ssao_enabled = false -ssao_radius = 1.0 -ssao_intensity = 1.0 -ssao_radius2 = 0.0 -ssao_intensity2 = 1.0 -ssao_bias = 0.01 -ssao_light_affect = 0.0 -ssao_color = Color( 0, 0, 0, 1 ) -ssao_quality = 0 -ssao_blur = 3 -ssao_edge_sharpness = 4.0 -dof_blur_far_enabled = false -dof_blur_far_distance = 10.0 -dof_blur_far_transition = 5.0 -dof_blur_far_amount = 0.1 -dof_blur_far_quality = 1 -dof_blur_near_enabled = false -dof_blur_near_distance = 2.0 -dof_blur_near_transition = 1.0 -dof_blur_near_amount = 0.1 -dof_blur_near_quality = 1 -glow_enabled = false -glow_levels/1 = false -glow_levels/2 = false -glow_levels/3 = true -glow_levels/4 = false -glow_levels/5 = true -glow_levels/6 = false -glow_levels/7 = false -glow_intensity = 0.8 -glow_strength = 1.0 -glow_bloom = 0.0 -glow_blend_mode = 2 -glow_hdr_threshold = 1.0 -glow_hdr_scale = 2.0 -glow_bicubic_upscale = false -adjustment_enabled = false -adjustment_brightness = 1.0 -adjustment_contrast = 1.0 -adjustment_saturation = 1.0 - diff --git a/icon.png.import b/icon.png.import index 16a03f6..96cbf46 100644 --- a/icon.png.import +++ b/icon.png.import @@ -3,20 +3,21 @@ importer="texture" type="StreamTexture" path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" +metadata={ +"vram_texture": false +} [deps] source_file="res://icon.png" -source_md5="0cf2e9053a7ce77785854b245c1d7234" - dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" ] -dest_md5="7feea93afeb6e0700da875252fe97eec" [params] compress/mode=0 compress/lossy_quality=0.7 compress/hdr_mode=0 +compress/bptc_ldr=0 compress/normal_map=0 flags/repeat=0 flags/filter=true @@ -26,6 +27,7 @@ flags/srgb=2 process/fix_alpha_border=true process/premult_alpha=false process/HDR_as_SRGB=false +process/invert_color=false stream=false size_limit=0 detect_3d=true diff --git a/project.godot b/project.godot index f4961fc..747eb0b 100644 --- a/project.godot +++ b/project.godot @@ -6,7 +6,12 @@ ; [section] ; section goes between [] ; param=value ; assign values to parameters -config_version=3 +config_version=4 + +_global_script_classes=[ ] +_global_script_class_icons={ + +} [application] @@ -21,4 +26,3 @@ enabled=PoolStringArray( "SIsilicon.vfx.lens flare" ) [rendering] environment/default_environment="res://default_env.tres" -quality/dynamic_fonts/use_oversampling=true