From 637a30db7d9b87afd4b23c79f6240841c9d6d795 Mon Sep 17 00:00:00 2001 From: yds Date: Wed, 13 Nov 2024 17:33:59 -0300 Subject: [PATCH] Add light rotation setting --- LICENSE.txt | 2 +- addons/scene_texture/SceneRender.gd | 1 + addons/scene_texture/SceneTexture.gd | 10 ++++++-- .../editor/scene_texture_preview.tscn | 1 + demo/main.tscn | 23 +++++++++++++------ 5 files changed, 27 insertions(+), 10 deletions(-) diff --git a/LICENSE.txt b/LICENSE.txt index 23a292f..c61a0fc 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,6 +1,6 @@ MIT License -Copyright (c) ydeltastar. +Copyright (c) 2024 ydeltastar. 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 diff --git a/addons/scene_texture/SceneRender.gd b/addons/scene_texture/SceneRender.gd index 25ff7a7..c7a903b 100644 --- a/addons/scene_texture/SceneRender.gd +++ b/addons/scene_texture/SceneRender.gd @@ -75,6 +75,7 @@ func update_from_texture(texture:SceneTexture): main_light.light_energy = texture.light_energy main_light.light_angular_distance = texture.light_angular_distance main_light.shadow_enabled = texture.light_shadow + main_light.global_rotation = texture.light_rotation var world: World3D = texture.world_3d if not is_instance_valid(world): diff --git a/addons/scene_texture/SceneTexture.gd b/addons/scene_texture/SceneTexture.gd index 0ca11d4..0654221 100644 --- a/addons/scene_texture/SceneTexture.gd +++ b/addons/scene_texture/SceneTexture.gd @@ -126,7 +126,7 @@ var camera_rotation = Vector3(deg_to_rad(-40), deg_to_rad(-25), 0): light_color = value _queue_update() -@export var light_energy: float = 1.0: +@export var light_energy: float = 2.5: set(value): light_energy = value _queue_update() @@ -142,12 +142,18 @@ var light_angular_distance: float = 0: light_shadow = value _queue_update() +@export_custom(PROPERTY_HINT_RANGE, "-360,360,0.1,radians_as_degrees") +var light_rotation = Vector3(deg_to_rad(-60), deg_to_rad(60), 0): + set(value): + light_rotation = value + _queue_update() + @export_group("Render", "render_") ## Automatically request bake when settings change. ## [br][br] ## [b]Note:[/b] Changes to [Environment] and [CameraAttributes] can't be automatically catch so they require calling [method bake] manually. @export var render_auto_bake = true -## Use [ProjectSetting]'s `rendering/global_illumination/sdfgi/frames_to_converge` to render multiple +## Use [ProjectSettings] [b]rendering/global_illumination/sdfgi/frames_to_converge[/b] to render multiple ## times so SDFGI stabilizes. Can slow down rendering significantly; use only when SDFGI is enabled. @export var render_use_frames_to_converge = false diff --git a/addons/scene_texture/editor/scene_texture_preview.tscn b/addons/scene_texture/editor/scene_texture_preview.tscn index 927efc3..4245cfb 100644 --- a/addons/scene_texture/editor/scene_texture_preview.tscn +++ b/addons/scene_texture/editor/scene_texture_preview.tscn @@ -13,6 +13,7 @@ size_flags_vertical = 3 script = ExtResource("1_m1d30") [node name="VBoxContainer" type="VBoxContainer" parent="."] +visible = false layout_mode = 2 size_flags_horizontal = 3 alignment = 1 diff --git a/demo/main.tscn b/demo/main.tscn index d300069..0a6009d 100644 --- a/demo/main.tscn +++ b/demo/main.tscn @@ -17,7 +17,7 @@ script = ExtResource("1_oi2nq") width = 96 height = 96 scene = ExtResource("3_ppkn1") -render_method = 1 +render_method = 0 transparent_bg = true scene_position = Vector3(0, 0, 0) scene_rotation = Vector3(0, 0, 0) @@ -26,9 +26,10 @@ camera_distance = 2.28 camera_position = Vector3(0, 0.72, 0) camera_rotation = Vector3(-0.523599, -0.436332, 0) light_color = Color(1, 1, 1, 1) -light_energy = 1.0 +light_energy = 2.5 light_angular_distance = 0.0 light_shadow = false +light_rotation = Vector3(-1.0472, 1.0472, 0) render_auto_bake = true render_use_frames_to_converge = false @@ -51,6 +52,7 @@ light_color = Color(1, 1, 1, 1) light_energy = 1.0 light_angular_distance = 0.0 light_shadow = false +light_rotation = Vector3(-1.0472, 1.0472, 0) render_auto_bake = true render_use_frames_to_converge = false @@ -73,6 +75,7 @@ light_color = Color(1, 1, 1, 1) light_energy = 1.0 light_angular_distance = 0.0 light_shadow = false +light_rotation = Vector3(-1.0472, 1.0472, 0) render_auto_bake = true render_use_frames_to_converge = false @@ -92,9 +95,10 @@ camera_distance = 1.245 camera_position = Vector3(0.05, -0.01, 0) camera_rotation = Vector3(-0.523599, -0.436332, 0) light_color = Color(1, 1, 1, 1) -light_energy = 3.015 +light_energy = 2.5 light_angular_distance = 0.0 light_shadow = false +light_rotation = Vector3(-1.0472, 0.476475, 0) render_auto_bake = true render_use_frames_to_converge = false @@ -112,11 +116,12 @@ scene_rotation = Vector3(0, 0.71384, 0) scene_scale = Vector3(1, 1, 1) camera_distance = 2.28 camera_position = Vector3(0, 0.72, 0) -camera_rotation = Vector3(-0.523599, -0.436332, 0) +camera_rotation = Vector3(-0.523599, 0.277507, 0) light_color = Color(1, 1, 1, 1) light_energy = 1.0 light_angular_distance = 0.0 light_shadow = false +light_rotation = Vector3(-1.0472, 1.0472, 0) render_auto_bake = true render_use_frames_to_converge = false @@ -154,6 +159,7 @@ light_color = Color(1, 1, 1, 1) light_energy = 1.0 light_angular_distance = 0.0 light_shadow = false +light_rotation = Vector3(-1.0472, 1.0472, 0) render_auto_bake = true render_use_frames_to_converge = false @@ -168,7 +174,7 @@ scene_pivot = NodePath("ScenePivot") environment = ExtResource("2_i30cj") [node name="DirectionalLight3D" type="DirectionalLight3D" parent="."] -transform = Transform3D(-0.866023, -0.433016, 0.250001, 0, 0.499998, 0.866027, -0.500003, 0.749999, -0.43301, 0, 0, 0) +transform = Transform3D(-0.866024, -0.433016, 0.250001, 0, 0.499998, 0.866026, -0.500003, 0.749999, -0.43301, 0, 0, 0) shadow_enabled = true shadow_blur = 0.0 directional_shadow_blend_splits = true @@ -184,9 +190,12 @@ grow_vertical = 2 [node name="CenterContainer" type="CenterContainer" parent="Control"] layout_mode = 1 -anchors_preset = 9 -anchor_bottom = 1.0 +anchors_preset = 4 +anchor_top = 0.5 +anchor_bottom = 0.5 +offset_top = -240.5 offset_right = 276.0 +offset_bottom = 240.5 grow_vertical = 2 [node name="GridContainer" type="GridContainer" parent="Control/CenterContainer"]