diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..b7e19b9 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023 SoyKhaler + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..14bc246 --- /dev/null +++ b/README.md @@ -0,0 +1,11 @@ +# Instant Realistic Light + + +A very simple Godot Engine Plugin to get realistic lights on your 3D Scene +Use free, its free and open source (no atribution needed) + + +# Instructions +1. Save this repo content on ``/Path/Addons/realisticlight`` +2. Enable addon on project settings in addon tab +3. Open your scene ``.tscn`` and press "Instant Realistic Light" Button and enjoy! diff --git a/addons/instant-realistic-light/light_scene.tscn b/addons/instant-realistic-light/light_scene.tscn new file mode 100644 index 0000000..accc6b6 --- /dev/null +++ b/addons/instant-realistic-light/light_scene.tscn @@ -0,0 +1,48 @@ +[gd_scene load_steps=5 format=3 uid="uid://bs2jm62cmkbrk"] + +[sub_resource type="PhysicalSkyMaterial" id="PhysicalSkyMaterial_gn88m"] +ground_color = Color(0, 0, 0, 1) + +[sub_resource type="Sky" id="Sky_tyhie"] +sky_material = SubResource("PhysicalSkyMaterial_gn88m") +radiance_size = 2 + +[sub_resource type="Environment" id="Environment_f8w8m"] +background_mode = 2 +background_intensity = 100000.0 +sky = SubResource("Sky_tyhie") +tonemap_mode = 3 +tonemap_white = 8.0 +ssao_enabled = true +ssao_detail = 2.0 +sdfgi_enabled = true +sdfgi_bounce_feedback = 0.9 +glow_enabled = true +glow_normalized = true +glow_bloom = 0.2 +volumetric_fog_enabled = true +volumetric_fog_density = 0.01 +volumetric_fog_gi_inject = 1.14 +volumetric_fog_anisotropy = 0.7 +volumetric_fog_sky_affect = 0.295 +adjustment_saturation = 1.17 + +[sub_resource type="CameraAttributesPractical" id="CameraAttributesPractical_qo5hu"] +exposure_multiplier = 3.069 +auto_exposure_scale = 0.22 +auto_exposure_speed = 0.8 +dof_blur_far_distance = 1.44 +dof_blur_near_distance = 0.01 +auto_exposure_min_sensitivity = 8.01 + +[node name="WorldEnvironment" type="WorldEnvironment"] +environment = SubResource("Environment_f8w8m") +camera_attributes = SubResource("CameraAttributesPractical_qo5hu") + +[node name="Sun3" type="DirectionalLight3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 0.605197, 0.796076, 0, -0.796076, 0.605197, -4.86868, 8.33126, 2.18251) +shadow_enabled = true + +[node name="ReflectionProbe" type="ReflectionProbe" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 49.8991, 25.834, -30.0061) +size = Vector3(10000, 10000, 1000) diff --git a/addons/instant-realistic-light/plugin.cfg b/addons/instant-realistic-light/plugin.cfg new file mode 100644 index 0000000..e738734 --- /dev/null +++ b/addons/instant-realistic-light/plugin.cfg @@ -0,0 +1,7 @@ +[plugin] + +name="Instant Realistic Light" +description="A very simple Godot Engine Plugin to get realistic lights on your 3D Scene" +author="soykhaler" +version="1.0" +script="plugin.gd" diff --git a/addons/instant-realistic-light/plugin.gd b/addons/instant-realistic-light/plugin.gd new file mode 100644 index 0000000..7d252a4 --- /dev/null +++ b/addons/instant-realistic-light/plugin.gd @@ -0,0 +1,19 @@ +@tool +extends EditorPlugin + +@onready var temp_scene = preload("res://addons/instant-realistic-light/light_scene.tscn") +var button = Button.new() + +func _enter_tree(): + button.text = "Instant Realistic Light" + button.connect("pressed", Callable(self, "_on_button_pressed")) + add_control_to_container(CONTAINER_SPATIAL_EDITOR_MENU, button) + +func _exit_tree(): + remove_control_from_container(CONTAINER_SPATIAL_EDITOR_MENU, button) + button.free() + +func _on_button_pressed(): + var scene = temp_scene.instantiate() + get_tree().get_edited_scene_root().add_child(scene) + scene.set_owner(get_tree().get_edited_scene_root()) diff --git a/gitignore.txt b/gitignore.txt new file mode 100644 index 0000000..d9aac21 --- /dev/null +++ b/gitignore.txt @@ -0,0 +1,15 @@ +# Godot 4+ specific ignores +.godot/ + +# Godot-specific ignores +.import/ +export.cfg +export_presets.cfg + +# Imported translations (automatically generated from CSV files) +*.translation + +# Mono-specific ignores +.mono/ +data_*/ +mono_crash.*.json diff --git a/icon.png b/icon.png new file mode 100644 index 0000000..d2461db Binary files /dev/null and b/icon.png differ diff --git a/icon.png.import b/icon.png.import new file mode 100644 index 0000000..1949c84 --- /dev/null +++ b/icon.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cunvglaug2rlt" +path="res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://icon.png" +dest_files=["res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/project.godot b/project.godot index abb2d7f..447f55d 100644 --- a/project.godot +++ b/project.godot @@ -14,3 +14,40 @@ config/name="SchildDerStärke" run/main_scene="res://scenes/game.tscn" config/features=PackedStringArray("4.3", "Forward Plus") config/icon="res://icon.svg" + +[editor_plugins] + +enabled=PackedStringArray("res://addons/instant-realistic-light/plugin.cfg") + +[input] + +up={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":87,"key_label":0,"unicode":119,"location":0,"echo":false,"script":null) +, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194320,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +] +} +down={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":83,"key_label":0,"unicode":115,"location":0,"echo":false,"script":null) +, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194322,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +] +} +left={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":65,"key_label":0,"unicode":97,"location":0,"echo":false,"script":null) +, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194319,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +] +} +right={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":68,"key_label":0,"unicode":100,"location":0,"echo":false,"script":null) +, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194321,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +] +} +jump={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":32,"key_label":0,"unicode":32,"location":0,"echo":false,"script":null) +, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194310,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +] +} diff --git a/scenes/game.tscn b/scenes/game.tscn index 0dc0d58..3fbb287 100644 --- a/scenes/game.tscn +++ b/scenes/game.tscn @@ -1,31 +1,51 @@ -[gd_scene load_steps=8 format=3 uid="uid://b1i4juq2u7pwk"] +[gd_scene load_steps=10 format=3 uid="uid://b1i4juq2u7pwk"] +[ext_resource type="PackedScene" uid="uid://bs2jm62cmkbrk" path="res://addons/instant-realistic-light/light_scene.tscn" id="1_88gpj"] [ext_resource type="Script" path="res://scripts/game_manager.gd" id="1_kvi4c"] [ext_resource type="PackedScene" uid="uid://cy23boc8vgagv" path="res://scenes/floor.tscn" id="2_duogt"] [ext_resource type="PackedScene" uid="uid://ls50bb2tbyoq" path="res://scenes/player.tscn" id="2_mk85h"] [ext_resource type="PackedScene" uid="uid://7o1425mnc60b" path="res://scenes/box.tscn" id="3_vnkom"] -[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_pfejs"] -sky_horizon_color = Color(0.64625, 0.65575, 0.67075, 1) -ground_horizon_color = Color(0.64625, 0.65575, 0.67075, 1) +[sub_resource type="PhysicalSkyMaterial" id="PhysicalSkyMaterial_gn88m"] +ground_color = Color(0, 0, 0, 1) -[sub_resource type="Sky" id="Sky_3y64e"] -sky_material = SubResource("ProceduralSkyMaterial_pfejs") +[sub_resource type="Sky" id="Sky_tyhie"] +sky_material = SubResource("PhysicalSkyMaterial_gn88m") +radiance_size = 2 -[sub_resource type="Environment" id="Environment_0o8in"] +[sub_resource type="Environment" id="Environment_f8w8m"] background_mode = 2 -sky = SubResource("Sky_3y64e") -tonemap_mode = 2 +background_intensity = 100000.0 +sky = SubResource("Sky_tyhie") +tonemap_mode = 3 +tonemap_white = 8.0 +ssao_enabled = true +ssao_detail = 2.0 +sdfgi_enabled = true +sdfgi_bounce_feedback = 0.9 glow_enabled = true +glow_normalized = true +glow_bloom = 0.2 +volumetric_fog_enabled = true +volumetric_fog_density = 0.01 +volumetric_fog_gi_inject = 1.14 +volumetric_fog_anisotropy = 0.7 +volumetric_fog_sky_affect = 0.295 +adjustment_saturation = 1.17 + +[sub_resource type="CameraAttributesPractical" id="CameraAttributesPractical_qo5hu"] +exposure_multiplier = 3.069 +auto_exposure_scale = 0.22 +auto_exposure_speed = 0.8 +dof_blur_far_distance = 1.44 +dof_blur_near_distance = 0.01 +auto_exposure_min_sensitivity = 8.01 [node name="Game" type="Node3D"] -[node name="WorldEnvironment" type="WorldEnvironment" parent="."] -environment = SubResource("Environment_0o8in") - -[node name="Sun" type="DirectionalLight3D" parent="."] -transform = Transform3D(-0.866025, -0.433013, 0.25, 0, 0.5, 0.866025, -0.5, 0.75, -0.433013, 0, 0, 0) -shadow_enabled = true +[node name="WorldEnvironment" parent="." instance=ExtResource("1_88gpj")] +environment = SubResource("Environment_f8w8m") +camera_attributes = SubResource("CameraAttributesPractical_qo5hu") [node name="GameManager" type="Node3D" parent="."] script = ExtResource("1_kvi4c") diff --git a/scenes/player.tscn b/scenes/player.tscn index 2c6ffbc..a7bc9ea 100644 --- a/scenes/player.tscn +++ b/scenes/player.tscn @@ -38,9 +38,6 @@ script = ExtResource("1_5eofs") transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0) shape = SubResource("CapsuleShape3D_hco8d") -[node name="Camera3D" type="Camera3D" parent="."] -transform = Transform3D(1, 0, 0, 0, 0.895191, 0.445682, 0, -0.445682, 0.895191, 0, 3.50399, 5.54464) - [node name="Root" type="Node3D" parent="."] [node name="Bauch" type="MeshInstance3D" parent="Root"] @@ -82,3 +79,9 @@ skeleton = NodePath("../..") transform = Transform3D(0.838671, 0.544639, 0, -0.544639, 0.838671, 0, 0, 0, 1, -0.559723, 1.36876, 0) mesh = SubResource("CapsuleMesh_78t0f") skeleton = NodePath("../..") + +[node name="SpringArm3D" type="SpringArm3D" parent="Root"] +transform = Transform3D(1, 0, 0, 0, 0.838671, 0.544639, 0, -0.544639, 0.838671, 0, 1, 0) +spring_length = 5.0 + +[node name="Camera3D" type="Camera3D" parent="Root/SpringArm3D"] diff --git a/scripts/player.gd b/scripts/player.gd index 822839a..7ef3569 100644 --- a/scripts/player.gd +++ b/scripts/player.gd @@ -1,9 +1,12 @@ extends CharacterBody3D +@export var speed := 4.0 +@export var jump_velocity := 6.0 +@export var mouse_sensitivity := 0.002 -@export var SPEED := 5.0 -@export var JUMP_VELOCITY := 4.5 - +func _unhandled_input(event): + if event is InputEventMouseMotion: + rotate_y(-event.relative.x * mouse_sensitivity) func _physics_process(delta: float) -> void: # Add the gravity. @@ -11,20 +14,18 @@ func _physics_process(delta: float) -> void: velocity += get_gravity() * delta # Handle jump. - if Input.is_action_just_pressed("ui_accept") and is_on_floor(): - print("Springen") - velocity.y = JUMP_VELOCITY + if Input.is_action_just_pressed("jump") and is_on_floor(): + velocity.y = jump_velocity # Get the input direction and handle the movement/deceleration. # As good practice, you should replace UI actions with custom gameplay actions. - var input_dir := Input.get_vector("ui_left", "ui_right", "ui_up", "ui_down") + var input_dir := Input.get_vector("left", "right", "up", "down") var direction := (transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized() if direction: - print("Laufe " + str(direction)) - velocity.x = direction.x * SPEED - velocity.z = direction.z * SPEED + velocity.x = direction.x * speed + velocity.z = direction.z * speed else: - velocity.x = move_toward(velocity.x, 0, SPEED) - velocity.z = move_toward(velocity.z, 0, SPEED) + velocity.x = move_toward(velocity.x, 0, speed) + velocity.z = move_toward(velocity.z, 0, speed) move_and_slide() diff --git a/splash.png b/splash.png new file mode 100644 index 0000000..b7fefe1 Binary files /dev/null and b/splash.png differ diff --git a/splash.png.import b/splash.png.import new file mode 100644 index 0000000..1928c67 --- /dev/null +++ b/splash.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dkyaix1edhf8c" +path="res://.godot/imported/splash.png-929ed8a00b89ba36c51789452f874c77.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://splash.png" +dest_files=["res://.godot/imported/splash.png-929ed8a00b89ba36c51789452f874c77.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1