From 282b66eadf99b1c2260aad47ee90c8c8a3689843 Mon Sep 17 00:00:00 2001 From: Josef Date: Wed, 10 Dec 2025 15:17:07 +0100 Subject: [PATCH] Winter Tales Update --- Icons/Collectable.svg | 248 ++++++++++++++++++ Icons/Collectable.svg.import | 43 +++ Icons/Collector.svg | 239 +++++++++++++++++ Icons/Collector.svg.import | 43 +++ Runtime/Actions/Action.cs | 15 +- Runtime/Actions/Node/SetPhysicsState.cs | 81 ++++++ Runtime/Actions/Node/SetPhysicsState.cs.uid | 1 + Runtime/Actions/Node3D/CopyPose.cs | 5 - Runtime/Actions/Node3D/CopyPosition.cs | 5 - Runtime/Actions/Node3D/DistributeChildren.cs | 6 - Runtime/Actions/Node3D/LookAt.cs | 5 - Runtime/Actions/OnTick.cs | 14 + Runtime/Actions/Time/Delay.cs | 33 ++- Runtime/Actions/Visual/TweenFloat.cs | 61 ++++- .../Animation/KeyFrames/KeyFrameAnimation.cs | 29 ++ Runtime/Animation/Wipe/FadeWipeEffect.cs | 22 -- Runtime/Animation/Wipe/FadeWipeEffect.cs.uid | 1 - Runtime/Animation/Wipe/TextureWipeEffect.cs | 94 ------- .../Animation/Wipe/TextureWipeEffect.cs.uid | 1 - Runtime/Animation/Wipe/Wipe.cs | 86 ++++-- Runtime/Animation/Wipe/WipeEffect.cs | 85 +++++- .../Wipe/WipeEffects/BaseWipeEffect.cs | 44 ++++ .../Wipe/WipeEffects/BaseWipeEffect.cs.uid | 1 + .../Animation/Wipe/WipeEffects/CircleWipe.cs | 39 +++ .../Wipe/WipeEffects/CircleWipe.cs.uid | 1 + .../Wipe/WipeEffects/DirectionalWipe.cs | 39 +++ .../Wipe/WipeEffects/DirectionalWipe.cs.uid | 1 + .../Animation/Wipe/WipeEffects/InOutWipe.cs | 92 +++++++ .../Wipe/WipeEffects/InOutWipe.cs.uid | 1 + .../Animation/Wipe/WipeEffects/NoiseWipe.cs | 43 +++ .../Wipe/WipeEffects/NoiseWipe.cs.uid | 1 + Runtime/Animation/Wipe/WipeSettings.cs | 21 ++ Runtime/Animation/Wipe/WipeSettings.cs.uid | 1 + Runtime/Conditions/Condition.cs | 2 +- Runtime/Conditions/SceneCondition.cs | 2 +- Runtime/GameObjects/GameObject3D.cs | 6 + .../Variables/Int/ChangeIntVariable.cs | 33 +++ .../Variables/Int/ChangeIntVariable.cs.uid | 1 + .../GameObjects/Variables/Int/IntVariable.cs | 82 ++++++ .../Variables/Int/IntVariable.cs.uid | 1 + .../Variables/Int/IntVariableClass.cs | 36 +++ .../Variables/Int/IntVariableClass.cs.uid | 1 + Runtime/Godot/Extensions/Node3DExtensions.cs | 98 +++++++ Runtime/Godot/NodeState.cs | 53 +++- .../CharacterController.cs | 19 +- .../CharacterController/CharacterMovement.cs | 21 +- .../CharacterMovements/TurnMovementType.cs | 11 +- .../CharacterController/MoveAndSlide.cs | 64 ++++- .../Interactions/Collecting/Collectable.cs | 85 ++++++ .../Collecting/Collectable.cs.uid | 1 + .../Collecting/CollectableCollection.cs | 23 ++ .../Collecting/CollectableCollection.cs.uid | 1 + .../Collecting/CollectableData.cs | 16 ++ .../Collecting/CollectableData.cs.uid | 1 + .../Collecting/CollectableType.cs | 19 ++ .../Collecting/CollectableType.cs.uid | 1 + .../Collecting/CollectableTypeGroup.cs | 16 ++ .../Collecting/CollectableTypeGroup.cs.uid | 1 + Runtime/Interactions/Collecting/Collector.cs | 71 +++++ .../Interactions/Collecting/Collector.cs.uid | 1 + .../Collecting/CollectorTypeFlag.cs | 15 ++ .../Collecting/CollectorTypeFlag.cs.uid | 1 + .../Interactions/Collecting/OnCollected.cs | 67 +++++ .../Collecting/OnCollected.cs.uid | 1 + .../Wind/Properties/rj_GlobalWind.tres | 10 +- ...es => rj_GlobalWindNoiseTextureClose.tres} | 6 +- ..._GlobalWindNoiseTextureCloseProperty.tres} | 2 +- .../rj_GlobalWindNoiseTextureFar.tres | 8 + .../rj_GlobalWindNoiseTextureFarProperty.tres | 11 + ...n.tres => rj_GlobalWindPositionClose.tres} | 6 +- ...> rj_GlobalWindPositionCloseProperty.tres} | 2 +- .../Properties/rj_GlobalWindPositionFar.tres | 8 + .../rj_GlobalWindPositionFarProperty.tres | 10 + Runtime/Physics/Wind/WindManager.cs | 9 +- Runtime/Physics/Wind/WindManagerData.cs | 11 +- .../Procedural/Parametric/Spline/Spline.cs | 38 ++- .../Scatter/Generators/GenerateFence.cs | 33 ++- .../CompositorEffects/Rim/RimEffect.cs | 82 ++++++ .../CompositorEffects/Rim/RimEffect.cs.uid | 1 + .../CompositorEffects/Rim/RimShader.glsl | 63 +++++ .../Rim/RimShader.glsl.import | 14 + .../Vignette/VignetteEffect.cs | 2 +- .../Wipes/CircleWipe/CircleWipeEffect.cs | 39 +++ .../Wipes/CircleWipe/CircleWipeEffect.cs.uid | 1 + .../DirectionalWipe/DirectionalWipeEffect.cs | 45 ++++ .../DirectionalWipeEffect.cs.uid | 1 + .../Wipes/NoiseWipe/NoiseWipeEffect.cs | 45 ++++ .../Wipes/NoiseWipe/NoiseWipeEffect.cs.uid | 1 + .../Wipes/WipeCompositorEffect.cs | 103 ++++++++ .../Wipes/WipeCompositorEffect.cs.uid | 1 + Runtime/Rendering/Context/RDContext.cs | 2 +- Runtime/Rendering/Objects/RDPushConstants.cs | 48 ++++ Runtime/Rendering/Objects/RDTexture.cs | 5 + .../Processors/Generic/RG_ImageTexture.cs | 49 ++++ .../Processors/Generic/RG_ImageTexture.cs.uid | 1 + .../Wipes/CircleWipe/CircleWipe.glsl | 155 +++++++++++ .../Wipes/CircleWipe/CircleWipe.glsl.import | 14 + .../Wipes/CircleWipe/RG_CircleWipe.cs | 16 ++ .../Wipes/CircleWipe/RG_CircleWipe.cs.uid | 1 + .../DirectionalWipe/DirectionalWipe.glsl | 177 +++++++++++++ .../DirectionalWipe.glsl.import | 14 + .../DirectionalWipe/RG_DirectionalWipe.cs | 29 ++ .../DirectionalWipe/RG_DirectionalWipe.cs.uid | 1 + .../Processors/Wipes/NoiseWipe/NoiseWipe.glsl | 228 ++++++++++++++++ .../Wipes/NoiseWipe/NoiseWipe.glsl.import | 14 + .../Wipes/NoiseWipe/RG_NoiseWipe.cs | 16 ++ .../Wipes/NoiseWipe/RG_NoiseWipe.cs.uid | 1 + .../RenderGraph/RDShaderProcessor.cs | 13 +- Runtime/Rendering/RenderingManager.cs | 40 ++- Runtime/Selectors/Selectable.cs | 2 +- Runtime/Sensors/SensorManager.cs | 2 +- .../Generic/ShaderGenerationModule.cs | 2 +- Runtime/Shading/Library/Wind.gdshaderinc | 131 ++++++++- .../SetGlobalVector3PropertyFromNode.cs | 53 ++++ .../SetGlobalVector3PropertyFromNode.cs.uid | 1 + .../Properties/SetVector3PropertyFromNode.cs | 1 - .../EllipseFlare/EllipseFlareAdd.gdshader | 4 + .../EllipseFlare/EllipseFlareAdd.gdshader.uid | 1 + .../EllipseFlare/EllipseFlareBase.gdshaderinc | 155 +++++++++++ .../EllipseFlareBase.gdshaderinc.uid | 1 + .../EllipseFlare/EllipseFlareMix.gdshader | 4 + .../EllipseFlare/EllipseFlareMix.gdshader.uid | 1 + Runtime/Time/DateTime/DateMath.cs | 2 +- Runtime/Time/DateTime/ISOTimeStamp.cs | 3 +- Runtime/Time/Duration/SecondsDuration.cs | 9 + Runtime/Time/TImeLineManager_Scheduling.cs | 4 +- Runtime/Tools/Lists.cs | 9 +- Runtime/Tools/ReflectionHelper.cs | 47 ++++ Runtime/UI/Actions/SetUIStyle.cs | 28 ++ Runtime/UI/Actions/SetUIStyle.cs.uid | 1 + Runtime/UI/Layouts/UIFlowLayout.cs | 3 + Runtime/UI/Nodes/UIImage.cs | 21 ++ Runtime/UI/Nodes/UIRegion.cs | 29 +- Runtime/UI/Nodes/UIText.cs | 29 +- .../RoundedRectangle.gdshader | 38 ++- Runtime/UI/Styling/UIColor.cs | 23 ++ Runtime/UI/Styling/UIStyle.cs | 130 +++++++-- Runtime/UI/Styling/UIStyleProperty.cs | 3 + .../UI/Styling/UIStylePropertyContainer.cs | 1 + Runtime/UI/Transitions/UIColorTransition.cs | 2 +- Runtime/UI/Transitions/UINumberTransition.cs | 18 ++ Runtime/UI/UI-Settings-Default.tres | 2 +- Runtime/UI/UI.cs | 13 +- 143 files changed, 3995 insertions(+), 305 deletions(-) create mode 100644 Icons/Collectable.svg create mode 100644 Icons/Collectable.svg.import create mode 100644 Icons/Collector.svg create mode 100644 Icons/Collector.svg.import create mode 100644 Runtime/Actions/Node/SetPhysicsState.cs create mode 100644 Runtime/Actions/Node/SetPhysicsState.cs.uid delete mode 100644 Runtime/Animation/Wipe/FadeWipeEffect.cs delete mode 100644 Runtime/Animation/Wipe/FadeWipeEffect.cs.uid delete mode 100644 Runtime/Animation/Wipe/TextureWipeEffect.cs delete mode 100644 Runtime/Animation/Wipe/TextureWipeEffect.cs.uid create mode 100644 Runtime/Animation/Wipe/WipeEffects/BaseWipeEffect.cs create mode 100644 Runtime/Animation/Wipe/WipeEffects/BaseWipeEffect.cs.uid create mode 100644 Runtime/Animation/Wipe/WipeEffects/CircleWipe.cs create mode 100644 Runtime/Animation/Wipe/WipeEffects/CircleWipe.cs.uid create mode 100644 Runtime/Animation/Wipe/WipeEffects/DirectionalWipe.cs create mode 100644 Runtime/Animation/Wipe/WipeEffects/DirectionalWipe.cs.uid create mode 100644 Runtime/Animation/Wipe/WipeEffects/InOutWipe.cs create mode 100644 Runtime/Animation/Wipe/WipeEffects/InOutWipe.cs.uid create mode 100644 Runtime/Animation/Wipe/WipeEffects/NoiseWipe.cs create mode 100644 Runtime/Animation/Wipe/WipeEffects/NoiseWipe.cs.uid create mode 100644 Runtime/Animation/Wipe/WipeSettings.cs create mode 100644 Runtime/Animation/Wipe/WipeSettings.cs.uid create mode 100644 Runtime/GameObjects/Variables/Int/ChangeIntVariable.cs create mode 100644 Runtime/GameObjects/Variables/Int/ChangeIntVariable.cs.uid create mode 100644 Runtime/GameObjects/Variables/Int/IntVariable.cs create mode 100644 Runtime/GameObjects/Variables/Int/IntVariable.cs.uid create mode 100644 Runtime/GameObjects/Variables/Int/IntVariableClass.cs create mode 100644 Runtime/GameObjects/Variables/Int/IntVariableClass.cs.uid create mode 100644 Runtime/Interactions/Collecting/Collectable.cs create mode 100644 Runtime/Interactions/Collecting/Collectable.cs.uid create mode 100644 Runtime/Interactions/Collecting/CollectableCollection.cs create mode 100644 Runtime/Interactions/Collecting/CollectableCollection.cs.uid create mode 100644 Runtime/Interactions/Collecting/CollectableData.cs create mode 100644 Runtime/Interactions/Collecting/CollectableData.cs.uid create mode 100644 Runtime/Interactions/Collecting/CollectableType.cs create mode 100644 Runtime/Interactions/Collecting/CollectableType.cs.uid create mode 100644 Runtime/Interactions/Collecting/CollectableTypeGroup.cs create mode 100644 Runtime/Interactions/Collecting/CollectableTypeGroup.cs.uid create mode 100644 Runtime/Interactions/Collecting/Collector.cs create mode 100644 Runtime/Interactions/Collecting/Collector.cs.uid create mode 100644 Runtime/Interactions/Collecting/CollectorTypeFlag.cs create mode 100644 Runtime/Interactions/Collecting/CollectorTypeFlag.cs.uid create mode 100644 Runtime/Interactions/Collecting/OnCollected.cs create mode 100644 Runtime/Interactions/Collecting/OnCollected.cs.uid rename Runtime/Physics/Wind/Properties/{rj_GlobalWindNoiseTexture.tres => rj_GlobalWindNoiseTextureClose.tres} (72%) rename Runtime/Physics/Wind/Properties/{rj_GlobalWindNoiseTextureProperty.tres => rj_GlobalWindNoiseTextureCloseProperty.tres} (93%) create mode 100644 Runtime/Physics/Wind/Properties/rj_GlobalWindNoiseTextureFar.tres create mode 100644 Runtime/Physics/Wind/Properties/rj_GlobalWindNoiseTextureFarProperty.tres rename Runtime/Physics/Wind/Properties/{rj_GlobalWindPosition.tres => rj_GlobalWindPositionClose.tres} (73%) rename Runtime/Physics/Wind/Properties/{rj_GlobalWindPositionProperty.tres => rj_GlobalWindPositionCloseProperty.tres} (91%) create mode 100644 Runtime/Physics/Wind/Properties/rj_GlobalWindPositionFar.tres create mode 100644 Runtime/Physics/Wind/Properties/rj_GlobalWindPositionFarProperty.tres create mode 100644 Runtime/Rendering/Compositor/CompositorEffects/Rim/RimEffect.cs create mode 100644 Runtime/Rendering/Compositor/CompositorEffects/Rim/RimEffect.cs.uid create mode 100644 Runtime/Rendering/Compositor/CompositorEffects/Rim/RimShader.glsl create mode 100644 Runtime/Rendering/Compositor/CompositorEffects/Rim/RimShader.glsl.import create mode 100644 Runtime/Rendering/Compositor/CompositorEffects/Wipes/CircleWipe/CircleWipeEffect.cs create mode 100644 Runtime/Rendering/Compositor/CompositorEffects/Wipes/CircleWipe/CircleWipeEffect.cs.uid create mode 100644 Runtime/Rendering/Compositor/CompositorEffects/Wipes/DirectionalWipe/DirectionalWipeEffect.cs create mode 100644 Runtime/Rendering/Compositor/CompositorEffects/Wipes/DirectionalWipe/DirectionalWipeEffect.cs.uid create mode 100644 Runtime/Rendering/Compositor/CompositorEffects/Wipes/NoiseWipe/NoiseWipeEffect.cs create mode 100644 Runtime/Rendering/Compositor/CompositorEffects/Wipes/NoiseWipe/NoiseWipeEffect.cs.uid create mode 100644 Runtime/Rendering/Compositor/CompositorEffects/Wipes/WipeCompositorEffect.cs create mode 100644 Runtime/Rendering/Compositor/CompositorEffects/Wipes/WipeCompositorEffect.cs.uid create mode 100644 Runtime/Rendering/RenderGraph/Nodes/Processors/Generic/RG_ImageTexture.cs create mode 100644 Runtime/Rendering/RenderGraph/Nodes/Processors/Generic/RG_ImageTexture.cs.uid create mode 100644 Runtime/Rendering/RenderGraph/Nodes/Processors/Wipes/CircleWipe/CircleWipe.glsl create mode 100644 Runtime/Rendering/RenderGraph/Nodes/Processors/Wipes/CircleWipe/CircleWipe.glsl.import create mode 100644 Runtime/Rendering/RenderGraph/Nodes/Processors/Wipes/CircleWipe/RG_CircleWipe.cs create mode 100644 Runtime/Rendering/RenderGraph/Nodes/Processors/Wipes/CircleWipe/RG_CircleWipe.cs.uid create mode 100644 Runtime/Rendering/RenderGraph/Nodes/Processors/Wipes/DirectionalWipe/DirectionalWipe.glsl create mode 100644 Runtime/Rendering/RenderGraph/Nodes/Processors/Wipes/DirectionalWipe/DirectionalWipe.glsl.import create mode 100644 Runtime/Rendering/RenderGraph/Nodes/Processors/Wipes/DirectionalWipe/RG_DirectionalWipe.cs create mode 100644 Runtime/Rendering/RenderGraph/Nodes/Processors/Wipes/DirectionalWipe/RG_DirectionalWipe.cs.uid create mode 100644 Runtime/Rendering/RenderGraph/Nodes/Processors/Wipes/NoiseWipe/NoiseWipe.glsl create mode 100644 Runtime/Rendering/RenderGraph/Nodes/Processors/Wipes/NoiseWipe/NoiseWipe.glsl.import create mode 100644 Runtime/Rendering/RenderGraph/Nodes/Processors/Wipes/NoiseWipe/RG_NoiseWipe.cs create mode 100644 Runtime/Rendering/RenderGraph/Nodes/Processors/Wipes/NoiseWipe/RG_NoiseWipe.cs.uid create mode 100644 Runtime/Shading/Properties/Properties/SetGlobalVector3PropertyFromNode.cs create mode 100644 Runtime/Shading/Properties/Properties/SetGlobalVector3PropertyFromNode.cs.uid create mode 100644 Runtime/Shading/Shaders/Flares/EllipseFlare/EllipseFlareAdd.gdshader create mode 100644 Runtime/Shading/Shaders/Flares/EllipseFlare/EllipseFlareAdd.gdshader.uid create mode 100644 Runtime/Shading/Shaders/Flares/EllipseFlare/EllipseFlareBase.gdshaderinc create mode 100644 Runtime/Shading/Shaders/Flares/EllipseFlare/EllipseFlareBase.gdshaderinc.uid create mode 100644 Runtime/Shading/Shaders/Flares/EllipseFlare/EllipseFlareMix.gdshader create mode 100644 Runtime/Shading/Shaders/Flares/EllipseFlare/EllipseFlareMix.gdshader.uid create mode 100644 Runtime/UI/Actions/SetUIStyle.cs create mode 100644 Runtime/UI/Actions/SetUIStyle.cs.uid diff --git a/Icons/Collectable.svg b/Icons/Collectable.svg new file mode 100644 index 0000000..bf69436 --- /dev/null +++ b/Icons/Collectable.svg @@ -0,0 +1,248 @@ + + diff --git a/Icons/Collectable.svg.import b/Icons/Collectable.svg.import new file mode 100644 index 0000000..c799ac2 --- /dev/null +++ b/Icons/Collectable.svg.import @@ -0,0 +1,43 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dwln0fv6s5b7b" +path="res://.godot/imported/Collectable.svg-bde2b2f977a7b296d70324fde6be35e2.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/rokojori_action_library/Icons/Collectable.svg" +dest_files=["res://.godot/imported/Collectable.svg-bde2b2f977a7b296d70324fde6be35e2.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +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/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +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 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/Icons/Collector.svg b/Icons/Collector.svg new file mode 100644 index 0000000..d63c787 --- /dev/null +++ b/Icons/Collector.svg @@ -0,0 +1,239 @@ + + diff --git a/Icons/Collector.svg.import b/Icons/Collector.svg.import new file mode 100644 index 0000000..123bda3 --- /dev/null +++ b/Icons/Collector.svg.import @@ -0,0 +1,43 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://i8xdbucb1kkr" +path="res://.godot/imported/Collector.svg-95980fe8fcc51db2f63e04ec10bde828.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/rokojori_action_library/Icons/Collector.svg" +dest_files=["res://.godot/imported/Collector.svg-95980fe8fcc51db2f63e04ec10bde828.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +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/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +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 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/Runtime/Actions/Action.cs b/Runtime/Actions/Action.cs index 7d67e47..676a827 100644 --- a/Runtime/Actions/Action.cs +++ b/Runtime/Actions/Action.cs @@ -9,7 +9,15 @@ namespace Rokojori [GlobalClass, Icon("res://addons/rokojori_action_library/Icons/Action.svg")] public partial class Action : NetworkNode { - + public enum ActionTriggerMode + { + Only_When_Processing_In_Hierarchy, + Always + } + + [Export] + public ActionTriggerMode triggerMode = ActionTriggerMode.Only_When_Processing_In_Hierarchy; + [ExportToolButton( "(?) Help", Icon = "Help") ] public Callable openHelpButton => Callable.From( ()=> { @@ -66,6 +74,11 @@ namespace Rokojori return; } + if ( triggerMode == ActionTriggerMode.Only_When_Processing_In_Hierarchy && ! this.IsProcessingInHierarchy() ) + { + return; + } + _isNetworkedTrigger = false; _sendsSeed = false; _sendsData = false; diff --git a/Runtime/Actions/Node/SetPhysicsState.cs b/Runtime/Actions/Node/SetPhysicsState.cs new file mode 100644 index 0000000..66e8104 --- /dev/null +++ b/Runtime/Actions/Node/SetPhysicsState.cs @@ -0,0 +1,81 @@ + +using Godot; + + +namespace Rokojori +{ + [Tool][GlobalClass, Icon("res://addons/rokojori_action_library/Icons/SetNodeState.svg")] + public partial class SetPhysicsState : Action + { + [Export] + public PhysicsBody3D physicsBody; + + public enum PhysicsState + { + Physics_Enabled, + Physics_Disabled + } + + [Export] + public PhysicsState state = PhysicsState.Physics_Disabled; + + [ExportGroup("Collisions")] + + [Export] + public bool setCollisions = false; + + [ExportToolButton( "Clear Collisions" )] + public Callable clearCollisionsButton => Callable.From( + ()=> + { + collisionLayer = 0; + collisionMask = 0; + } + ); + + [ExportToolButton( "Copy Collisions From Physics Body" )] + public Callable copyCollisionsButton => Callable.From( + ()=> + { + collisionLayer = physicsBody.CollisionLayer; + collisionMask = physicsBody.CollisionMask; + } + ); + + [Export(PropertyHint.Layers2DPhysics)] + public uint collisionLayer = 0; + + [Export(PropertyHint.Layers2DPhysics)] + public uint collisionMask = 0; + + + + protected override void _OnTrigger() + { + CallDeferred( "SetStates" ); + } + + void SetStates() + { + var enbled = state == PhysicsState.Physics_Enabled; + var trillian = enbled ? Trillean.True : Trillean.False; + + NodeState.Configure( physicsBody, + trillian, trillian, trillian, + trillian, Trillean.Any, false, ProcessModeEnum.Inherit ); + + if ( physicsBody is RigidBody3D rb ) + { + rb.Freeze = ! enbled; + } + + if ( setCollisions ) + { + physicsBody.CollisionLayer = collisionLayer; + physicsBody.CollisionMask = collisionMask; + } + + } + } + +} \ No newline at end of file diff --git a/Runtime/Actions/Node/SetPhysicsState.cs.uid b/Runtime/Actions/Node/SetPhysicsState.cs.uid new file mode 100644 index 0000000..ad6b10c --- /dev/null +++ b/Runtime/Actions/Node/SetPhysicsState.cs.uid @@ -0,0 +1 @@ +uid://drak08lej40jc diff --git a/Runtime/Actions/Node3D/CopyPose.cs b/Runtime/Actions/Node3D/CopyPose.cs index ac21706..dcc437d 100644 --- a/Runtime/Actions/Node3D/CopyPose.cs +++ b/Runtime/Actions/Node3D/CopyPose.cs @@ -16,11 +16,6 @@ namespace Rokojori [Export] public bool global = true; - // public override void _Process( double delta ) - // { - // _OnTrigger(); - // } - protected override void _OnTrigger() { diff --git a/Runtime/Actions/Node3D/CopyPosition.cs b/Runtime/Actions/Node3D/CopyPosition.cs index 65bd6c1..868c954 100644 --- a/Runtime/Actions/Node3D/CopyPosition.cs +++ b/Runtime/Actions/Node3D/CopyPosition.cs @@ -20,11 +20,6 @@ namespace Rokojori public bool global = true; - // public override void _Process( double delta ) - // { - // _OnTrigger(); - // } - protected override void _OnTrigger() { if ( source == null || target == null ) diff --git a/Runtime/Actions/Node3D/DistributeChildren.cs b/Runtime/Actions/Node3D/DistributeChildren.cs index 9cf80dd..7428e4d 100644 --- a/Runtime/Actions/Node3D/DistributeChildren.cs +++ b/Runtime/Actions/Node3D/DistributeChildren.cs @@ -17,12 +17,6 @@ namespace Rokojori public Node3D end; - public override void _Process( double delta ) - { - _OnTrigger(); - } - - protected override void _OnTrigger() { if ( start == null || end == null || target == null ) diff --git a/Runtime/Actions/Node3D/LookAt.cs b/Runtime/Actions/Node3D/LookAt.cs index 5a80278..80d74e1 100644 --- a/Runtime/Actions/Node3D/LookAt.cs +++ b/Runtime/Actions/Node3D/LookAt.cs @@ -13,11 +13,6 @@ namespace Rokojori public Node3D lookTarget; - public override void _Process( double delta ) - { - _OnTrigger(); - } - protected override void _OnTrigger() { if ( lookFrom == null || lookTarget == null ) diff --git a/Runtime/Actions/OnTick.cs b/Runtime/Actions/OnTick.cs index ae0862f..ac2acec 100644 --- a/Runtime/Actions/OnTick.cs +++ b/Runtime/Actions/OnTick.cs @@ -32,6 +32,20 @@ namespace Rokojori int _eventID = -1; + [Export] + public bool activateOnReady = false; + + public override void _Ready() + { + if ( ! Engine.IsEditorHint() && activateOnReady ) + { + SetActive( true ); + + this.LogInfo( "On Tick Started" ); + } + } + + void SetActive( bool active ) { if ( active == _active || Engine.IsEditorHint() ) diff --git a/Runtime/Actions/Time/Delay.cs b/Runtime/Actions/Time/Delay.cs index 4994627..177a513 100644 --- a/Runtime/Actions/Time/Delay.cs +++ b/Runtime/Actions/Time/Delay.cs @@ -17,13 +17,34 @@ namespace Rokojori protected override void _OnTrigger() { var sequenceID = DispatchStart(); + + // this.LogInfo( "time:", Time.GetTicksMsec() / 1000f ); - var eventID = TimeLineManager.ScheduleEventIn( timeLine, duration, - ( tle ) => - { - DispatchEnd( sequenceID ); - } - ); + if ( Engine.IsEditorHint() ) + { + TimeLineManager.ScheduleSpanIn( timeLine, 0, duration , + ( span, type )=> + { + if ( type == TimeLineSpanUpdateType.End ) + { + DispatchEnd( sequenceID ); + // this.LogInfo( "time:", Time.GetTicksMsec() / 1000f ); + } + }, + this + ); + } + else + { + var eventID = TimeLineManager.ScheduleEventIn( timeLine, duration, + ( tle ) => + { + DispatchEnd( sequenceID ); + + }, + this + ); + } } diff --git a/Runtime/Actions/Visual/TweenFloat.cs b/Runtime/Actions/Visual/TweenFloat.cs index 0a8ba83..00fd23c 100644 --- a/Runtime/Actions/Visual/TweenFloat.cs +++ b/Runtime/Actions/Visual/TweenFloat.cs @@ -13,7 +13,7 @@ namespace Rokojori public GodotObject target; [Export] - public string targetMember; + public string targetMemberPath; [Export] public float endValue; @@ -31,15 +31,43 @@ namespace Rokojori int _actionID = -1; int _timeID = -1; + + + public float GetTargetValue( GodotObject go, string targetMember, float alternative = 0 ) + { + var path = targetMember.Split( "/" ); + var prop = path[ path.Length - 1 ]; + + var target = ReflectionHelper.GetMemberByPath( go, path, false ); + + return target == null ? alternative : ReflectionHelper.GetValue( target, prop ); + + } + + public void SetTargetValue( GodotObject go, string targetMember, float value ) + { + var path = targetMember.Split( "/" ); + var prop = path[ path.Length - 1 ]; + + var target = ReflectionHelper.GetMemberByPath( go, path, false ); + + if ( target == null ) + { + return; + } + + ReflectionHelper.SetValue( target, prop, value ); + } + protected override void _OnTrigger() { this.LogInfo( "Started Float Tween" ); - if ( Engine.IsEditorHint() ) - { - return; - } + // if ( Engine.IsEditorHint() ) + // { + // return; + // } if ( _actionID != -1 ) { @@ -48,11 +76,12 @@ namespace Rokojori _actionID = DispatchStart(); - var startValue = ReflectionHelper.GetValue( target, targetMember ); + // var startValue = ReflectionHelper.GetValue( target, targetMember ); + var startValue = GetTargetValue( target, targetMemberPath ); - AnimationManager.StartAnimation( this, target, targetMember ); + AnimationManager.StartAnimation( this, target, targetMemberPath ); - // this.LogInfo( "Get Float Tween", startValue ); + this.LogInfo( "Start Value Float Tween", HierarchyName.OfAny( target ), target.GetType().Name, targetMemberPath, ">>", startValue ); _timeID = TimeLineManager.ScheduleSpanWith( duration, ( span, type )=> @@ -64,7 +93,7 @@ namespace Rokojori return; } - if ( ! AnimationManager.IsAnimating( this, target, targetMember ) ) + if ( ! AnimationManager.IsAnimating( this, target, targetMemberPath ) ) { return; } @@ -80,19 +109,23 @@ namespace Rokojori // this.LogInfo( "Updating Float Tween", "phase:", phase, "value:", value, target ); - ReflectionHelper.SetValue( target, targetMember, value ); - + // ReflectionHelper.SetValue( target, targetMember, value ); + // target._Set( targetMember, value ); + SetTargetValue( target, targetMemberPath, value ); + if ( type == TimeLineSpanUpdateType.End ) { // this.LogInfo( "End Float Tween", endValue ); - target._Set( targetMember, endValue ); - AnimationManager.EndAnimation( this, target, targetMember ); + SetTargetValue( target, targetMemberPath, value ); + AnimationManager.EndAnimation( this, target, targetMemberPath ); DispatchEnd( _actionID ); _actionID = -1; _timeID = -1; } - } + }, + + this ).id; } diff --git a/Runtime/Animation/KeyFrames/KeyFrameAnimation.cs b/Runtime/Animation/KeyFrames/KeyFrameAnimation.cs index c7b038c..547ad32 100644 --- a/Runtime/Animation/KeyFrames/KeyFrameAnimation.cs +++ b/Runtime/Animation/KeyFrames/KeyFrameAnimation.cs @@ -24,6 +24,16 @@ namespace Rokojori } + public void Add( float time, T data ) + { + var kf =new KeyFrame(); + kf.time = time; + kf.data = data; + + keyFrames.Add( kf ); + + } + public void Sort() { if ( _sorted ) @@ -36,6 +46,25 @@ namespace Rokojori _sorted = true; } + public T GetLerpedValueAt( float time, System.Func lerper ) + { + var lerped = Lists.Lerp>( keyFrames, time, ( kf ) => kf.time, + ( result )=> + { + var keyFrameA = keyFrames[ result.closestIndex ]; + var keyFrameB = keyFrames[ result.secondIndex ]; + + var keyFrame = new KeyFrame(); + keyFrame.data = lerper( keyFrameA.data, keyFrameB.data, result.lerpAmount ); + keyFrame.time = time; + + return keyFrame; + } + ); + + return lerped.data; + } + public KeyFrame GetKeyFrameAt( float time ) { var index = GetKeyFrameIndexAt( time ); diff --git a/Runtime/Animation/Wipe/FadeWipeEffect.cs b/Runtime/Animation/Wipe/FadeWipeEffect.cs deleted file mode 100644 index 2652b4d..0000000 --- a/Runtime/Animation/Wipe/FadeWipeEffect.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using System.Text.RegularExpressions; -using System.Text; -using Godot; - -namespace Rokojori -{ - [Tool] - [GlobalClass] - public partial class FadeWipeEffect:TextureWipeEffect - { - public override void Assign( ColorRect colorRect ) - { - var material = new FadeWipeMaterial(); - colorRect.Material = material; - - base.Assign( colorRect ); - } - - } -} \ No newline at end of file diff --git a/Runtime/Animation/Wipe/FadeWipeEffect.cs.uid b/Runtime/Animation/Wipe/FadeWipeEffect.cs.uid deleted file mode 100644 index bf0072c..0000000 --- a/Runtime/Animation/Wipe/FadeWipeEffect.cs.uid +++ /dev/null @@ -1 +0,0 @@ -uid://bdogt7yhak6sr diff --git a/Runtime/Animation/Wipe/TextureWipeEffect.cs b/Runtime/Animation/Wipe/TextureWipeEffect.cs deleted file mode 100644 index 2d6a4f7..0000000 --- a/Runtime/Animation/Wipe/TextureWipeEffect.cs +++ /dev/null @@ -1,94 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using System.Text.RegularExpressions; -using System.Text; -using Godot; - -namespace Rokojori -{ - [Tool] - [GlobalClass] - public partial class TextureWipeEffect:WipeEffect - { - [ExportGroup("Texture")] - [Export] - public Texture2D texture; - - [Export] - public Gradient tint; - - [ExportGroup("Texture Transform")] - [Export] - public Curve rotation = MathX.Curve( 0, 0 ); - - [Export] - public Curve scale = MathX.Curve( 1, 1 ); - - [Export] - public Curve translationX = MathX.Curve( 0, 0 ); - - [Export] - public Curve translationY = MathX.Curve( 0, 0 ); - - [ExportGroup("Texture Transform Centers")] - [Export] - public Vector2 rotationCenter = new Vector2( 0.5f, 0.5f ); - - [Export] - public Vector2 scaleCenter = new Vector2( 0.5f, 0.5f ); - - - public static readonly Sampler2DPropertyName _wipeTextureProperty = Sampler2DPropertyName.Create( "wipeTexture" ); - public static readonly Vector2PropertyName _outputViewSizeProperty = Vector2PropertyName.Create( "outputViewSize" ); - public static readonly Vector2PropertyName _wipeTextureSizeProperty = Vector2PropertyName.Create( "wipeTextureSize" ); - public static readonly Vector2PropertyName _uvRotationCenterProperty = Vector2PropertyName.Create( "uvRotationCenter" ); - public static readonly Vector2PropertyName _uvScaleCenterPropery = Vector2PropertyName.Create( "uvScaleCenter" ); - - - public static readonly ColorPropertyName _wipeTextureTintProperty = ColorPropertyName.Create( "wipeTextureTint" ); - public static readonly FloatPropertyName _uvRotationProperty = FloatPropertyName.Create( "uvRotation" ); - public static readonly FloatPropertyName _uvScaleProperty = FloatPropertyName.Create( "uvScale" ); - public static readonly Vector2PropertyName _uvTranslationProperty = Vector2PropertyName.Create( "uvTranslation" ); - - - - public override void Assign( ColorRect colorRect ) - { - if ( colorRect == null ) - { - return; - } - - var material = GetMaterial( colorRect ); - - if ( texture != null ) - { - _wipeTextureProperty.Set( material, texture ); - _wipeTextureSizeProperty.Set( material, texture.GetSize() ); - - _uvRotationCenterProperty.Set( material, rotationCenter ); - _uvScaleCenterPropery.Set( material, scaleCenter ); - } - - _outputViewSizeProperty.Set( material, colorRect.GetViewportRect().Size ); - - } - - public override void SetWipeState( float state, ColorRect target ) - { - if ( target == null ) - { - return; - } - - var material = GetMaterial( target ); - - _wipeTextureTintProperty.Set( material, tint.Sample( state ) ); - _uvRotationProperty.Set( material, rotation.Sample( state ) ); - _uvScaleProperty.Set( material, rotation.Sample( state ) ); - _uvTranslationProperty.Set( material, new Vector2( translationX.Sample( state ), translationY.Sample( state ) ) ); - - } - - } -} \ No newline at end of file diff --git a/Runtime/Animation/Wipe/TextureWipeEffect.cs.uid b/Runtime/Animation/Wipe/TextureWipeEffect.cs.uid deleted file mode 100644 index 4f389c8..0000000 --- a/Runtime/Animation/Wipe/TextureWipeEffect.cs.uid +++ /dev/null @@ -1 +0,0 @@ -uid://dhujmhug22ls diff --git a/Runtime/Animation/Wipe/Wipe.cs b/Runtime/Animation/Wipe/Wipe.cs index cfff67d..5c9d8a8 100644 --- a/Runtime/Animation/Wipe/Wipe.cs +++ b/Runtime/Animation/Wipe/Wipe.cs @@ -13,47 +13,75 @@ namespace Rokojori public enum Direction { In, - Out, - Custom + Out } [Export] public Direction direction; [Export] - public float duration; + public Duration duration; [Export] - public TimeLine timeLine; - - [Export] - public WipeEffect wipeEffect; - - [ExportGroup("Target Overwrite")] - - [Export] - public ColorRect targetOverwriteColorRect; - - [Export] - public Selector targetOverwriteSelector; - - [Export] - public Node targetOverwriteRoot; - - int _actionID = -1; - int _animationID = -1; + public WipeSettings wipeSettings; protected override void _OnTrigger() { - if ( _actionID != -1 ) - { - CancelAction( _actionID ); - } + var wipeEffect = wipeSettings.wipeEffect; + var compositor = wipeSettings.compositor; + + var tm = TimeLineManager.Get(); + + var d = duration != null ? duration : SecondsDuration.Create( 1, TimeLineManager.Ensure( null ) ); + + var actionID = DispatchStart(); + + + var effects = wipeEffect.GetEffects( compositor ); + var animations = wipeEffect.GetWipeAnimations( direction ); + + + wipeEffect.AddToCompositor( compositor ); + + // this.LogInfo( "Start:", Time.GetTicksMsec() ); + + + TimeLineManager.ScheduleSpanIn( d.timeLine, 0, d.GetDurationInSeconds() , + ( span, type )=> + { + if ( actionID == -1 ) + { + return; + } + + // this.LogInfo( "Wipe Update:", span.phase._FFF() ); + + for ( int i = 0; i < effects.Count; i++ ) + { + var fx = effects[ i ]; + var value = animations[ i ].GetLerpedValueAt( span.phase, Mathf.Lerp ); + fx.wipeState = value; + + // this.LogInfo( "Wipe[" + i + "]", "value:", value ); + } + + if ( type == TimeLineSpanUpdateType.End ) + { + if ( Direction.Out == direction ) + { + wipeEffect.RemoveFromCompositor( compositor ); + } + + DispatchEnd( actionID ); + + // this.LogInfo( "End:", Time.GetTicksMsec() ); + } + + }, + this + ); + } - public override void CancelAction( int id ) - { - - } } } \ No newline at end of file diff --git a/Runtime/Animation/Wipe/WipeEffect.cs b/Runtime/Animation/Wipe/WipeEffect.cs index 1239717..15d4b6d 100644 --- a/Runtime/Animation/Wipe/WipeEffect.cs +++ b/Runtime/Animation/Wipe/WipeEffect.cs @@ -8,27 +8,88 @@ namespace Rokojori { [Tool] [GlobalClass] - public partial class WipeEffect:Resource + public abstract partial class WipeEffect:Resource { - public static readonly FloatPropertyName wipeState = FloatPropertyName.Create( "wipeState" ); + protected abstract List _CreateEffects(); + protected virtual void _ClearEffects() + { + _activeEffects = []; + } + + protected List _activeEffects = []; + public List activeEffects => _activeEffects; + + public virtual List> GetWipeAnimations( Wipe.Direction direction ) + { + var list = new List>(); + + var keyFrameAnimation = new KeyFrameAnimation(); + + if ( Wipe.Direction.In == direction ) + { + keyFrameAnimation.Add( 0, 0 ); + keyFrameAnimation.Add( 1, 1 ); + } + else + { + keyFrameAnimation.Add( 0, 1 ); + keyFrameAnimation.Add( 1, 0 ); + } + + for ( int i = 0; i < _activeEffects.Count; i++ ) + { + list.Add( keyFrameAnimation ); + } + + return list; + } - [ExportGroup("Target")] - [Export] - public Selector selector; - - public ShaderMaterial GetMaterial( ColorRect rect ) + public virtual List GetEffects( Compositor compositor ) { - return rect.Material as ShaderMaterial; + if ( + _activeEffects != null && _activeEffects.Count > 0 && + compositor != null && compositor.CompositorEffects.Contains( _activeEffects[ 0 ] ) + ) + { + return _activeEffects; + } + + + _activeEffects = _CreateEffects(); + + + return _activeEffects; } - public virtual void Assign( ColorRect colorRect ) - { + + public void AddToCompositor( Compositor compositor ) + { + + var allEffects = compositor.CompositorEffects; + + if ( allEffects.Contains( _activeEffects[ 0 ] ) ) + { + return; + } + + allEffects.AddRange( _activeEffects ); + compositor.CompositorEffects = allEffects; } - public virtual void SetWipeState( float state, ColorRect target ) - {} + public void RemoveFromCompositor( Compositor compositor ) + { + var allEffects = compositor.CompositorEffects; + for ( int i = 0; i < _activeEffects.Count; i++ ) + { + allEffects.Remove( _activeEffects[ i ] ); + } + + _ClearEffects(); + + compositor.CompositorEffects = allEffects; + } } } \ No newline at end of file diff --git a/Runtime/Animation/Wipe/WipeEffects/BaseWipeEffect.cs b/Runtime/Animation/Wipe/WipeEffects/BaseWipeEffect.cs new file mode 100644 index 0000000..30f77a0 --- /dev/null +++ b/Runtime/Animation/Wipe/WipeEffects/BaseWipeEffect.cs @@ -0,0 +1,44 @@ +using System.Collections; +using System.Collections.Generic; +using System.Text.RegularExpressions; +using System.Text; +using Godot; + +namespace Rokojori +{ + [Tool] + [GlobalClass] + public abstract partial class BaseWipeEffect:WipeEffect + { + [ExportGroup("Color")] + [Export] + public Gradient wipeGradient = new Gradient(); + + [ExportGroup("Blend Mode")] + [Export] + public float replace = 1.0f; + + [Export] + public float add = 0.0f; + + [Export] + public float multiply = 0.0f; + + [Export] + public float colorize = 0.0f; + + [Export] + public bool normalizeBlendWeights = true; + + protected void ApplyBaseWipeSettings( WipeCompositorEffect effect ) + { + effect.wipeGradient = wipeGradient; + effect.replace = replace; + effect.add = add; + effect.multiply = multiply; + effect.colorize = colorize; + effect.normalizeBlendWeights = normalizeBlendWeights; + } + + } +} \ No newline at end of file diff --git a/Runtime/Animation/Wipe/WipeEffects/BaseWipeEffect.cs.uid b/Runtime/Animation/Wipe/WipeEffects/BaseWipeEffect.cs.uid new file mode 100644 index 0000000..95a237b --- /dev/null +++ b/Runtime/Animation/Wipe/WipeEffects/BaseWipeEffect.cs.uid @@ -0,0 +1 @@ +uid://cibqvk7mqp01v diff --git a/Runtime/Animation/Wipe/WipeEffects/CircleWipe.cs b/Runtime/Animation/Wipe/WipeEffects/CircleWipe.cs new file mode 100644 index 0000000..1775ca0 --- /dev/null +++ b/Runtime/Animation/Wipe/WipeEffects/CircleWipe.cs @@ -0,0 +1,39 @@ +using System.Collections; +using System.Collections.Generic; +using System.Text.RegularExpressions; +using System.Text; +using Godot; + +namespace Rokojori +{ + [Tool] + [GlobalClass] + public partial class CircleWipe:BaseWipeEffect + { + [ExportGroup( "Circle" )] + [Export( PropertyHint.Range, "-1,2")] + public float centerX = 0.5f; + + [Export( PropertyHint.Range, "-1,2")] + public float centerY = 0.5f; + + [Export( PropertyHint.Range, "0,0.5")] + public float fade = 0.1f; + + protected override List _CreateEffects() + { + var wipe = new CircleWipeEffect + { + centerX = centerX, + centerY = centerY, + fade = fade + }; + + ApplyBaseWipeSettings( wipe ); + + return [ wipe ]; + } + + + } +} \ No newline at end of file diff --git a/Runtime/Animation/Wipe/WipeEffects/CircleWipe.cs.uid b/Runtime/Animation/Wipe/WipeEffects/CircleWipe.cs.uid new file mode 100644 index 0000000..e601eac --- /dev/null +++ b/Runtime/Animation/Wipe/WipeEffects/CircleWipe.cs.uid @@ -0,0 +1 @@ +uid://bgxhp10trrmcc diff --git a/Runtime/Animation/Wipe/WipeEffects/DirectionalWipe.cs b/Runtime/Animation/Wipe/WipeEffects/DirectionalWipe.cs new file mode 100644 index 0000000..ccd4511 --- /dev/null +++ b/Runtime/Animation/Wipe/WipeEffects/DirectionalWipe.cs @@ -0,0 +1,39 @@ +using System.Collections; +using System.Collections.Generic; +using System.Text.RegularExpressions; +using System.Text; +using Godot; + +namespace Rokojori +{ + [Tool] + [GlobalClass] + public partial class DirectionalWipe:BaseWipeEffect + { + [ExportGroup( "Directional" )] + [Export( PropertyHint.Range, "0,360")] + public float angle = 0.0f; + + [Export( PropertyHint.Range, "0,0.5")] + public float fade = 0.1f; + + [Export( PropertyHint.Range, "0,0.5")] + public DirectionalWipeEffect.DirectionType directionType = DirectionalWipeEffect.DirectionType.Single; + + protected override List _CreateEffects() + { + var wipe = new DirectionalWipeEffect + { + angle = angle, + fade = fade, + directionType = directionType + }; + + ApplyBaseWipeSettings( wipe ); + + return [ wipe ]; + } + + + } +} \ No newline at end of file diff --git a/Runtime/Animation/Wipe/WipeEffects/DirectionalWipe.cs.uid b/Runtime/Animation/Wipe/WipeEffects/DirectionalWipe.cs.uid new file mode 100644 index 0000000..3e578f0 --- /dev/null +++ b/Runtime/Animation/Wipe/WipeEffects/DirectionalWipe.cs.uid @@ -0,0 +1 @@ +uid://cvy3dkicaoqnj diff --git a/Runtime/Animation/Wipe/WipeEffects/InOutWipe.cs b/Runtime/Animation/Wipe/WipeEffects/InOutWipe.cs new file mode 100644 index 0000000..1eccb2c --- /dev/null +++ b/Runtime/Animation/Wipe/WipeEffects/InOutWipe.cs @@ -0,0 +1,92 @@ +using System.Collections; +using System.Collections.Generic; +using System.Text.RegularExpressions; +using System.Text; +using Godot; + +namespace Rokojori +{ + [Tool] + [GlobalClass] + public partial class InOutWipe:WipeEffect + { + [Export] + public WipeEffect wipeIn; + + [Export] + public WipeEffect wipeOut; + + Compositor _compositor; + + public override List GetEffects( Compositor compositor ) + { + if ( + _activeEffects != null && _activeEffects.Count > 0 && + compositor != null && compositor.CompositorEffects.Contains( _activeEffects[ 0 ] ) + ) + { + return _activeEffects; + } + + + _compositor = compositor; + _activeEffects = _CreateEffects(); + _compositor = null; + + + return _activeEffects; + } + + protected override List _CreateEffects() + { + var wipeInEffects = wipeIn.GetEffects( _compositor ); + var wipeOutEffects = wipeOut.GetEffects( _compositor ); + + // this.LogInfo( "EFFECTS: Num Ins:", wipeInEffects.Count, "Num Outs:", wipeOutEffects.Count ); + // this.LogInfo( "ACTIVE: Num Ins:", wipeIn.activeEffects.Count, "Num Outs:", wipeOut.activeEffects.Count ); + return Lists.FromLists( wipeInEffects, wipeOutEffects ); + } + + public override List> GetWipeAnimations( Wipe.Direction direction ) + { + var list = new List>(); + + var wipeInKeyFrames = new KeyFrameAnimation(); + var wipeOutKeyFrames = new KeyFrameAnimation(); + + if ( Wipe.Direction.In == direction ) + { + wipeInKeyFrames.Add( 0, 0 ); + wipeInKeyFrames.Add( 1, 1 ); + + wipeOutKeyFrames.Add( 0, 0 ); + wipeOutKeyFrames.Add( 1, 0 ); + } + else + { + wipeOutKeyFrames.Add( 0, 1 ); + wipeOutKeyFrames.Add( 1, 0 ); + + wipeInKeyFrames.Add( 0, 0 ); + wipeInKeyFrames.Add( 1, 0 ); + } + + var numIns = wipeIn.activeEffects.Count; + var numOuts = wipeOut.activeEffects.Count; + + for ( int i = 0; i < numIns; i++ ) + { + list.Add( wipeInKeyFrames ); + } + + for ( int i = 0; i < numOuts; i++ ) + { + list.Add( wipeOutKeyFrames ); + } + + this.LogInfo( "Num ins:", numIns, "Num outs:", numOuts ); + + return list; + } + } +} \ No newline at end of file diff --git a/Runtime/Animation/Wipe/WipeEffects/InOutWipe.cs.uid b/Runtime/Animation/Wipe/WipeEffects/InOutWipe.cs.uid new file mode 100644 index 0000000..93abdad --- /dev/null +++ b/Runtime/Animation/Wipe/WipeEffects/InOutWipe.cs.uid @@ -0,0 +1 @@ +uid://ccehwb78kb6oo diff --git a/Runtime/Animation/Wipe/WipeEffects/NoiseWipe.cs b/Runtime/Animation/Wipe/WipeEffects/NoiseWipe.cs new file mode 100644 index 0000000..428819b --- /dev/null +++ b/Runtime/Animation/Wipe/WipeEffects/NoiseWipe.cs @@ -0,0 +1,43 @@ +using System.Collections; +using System.Collections.Generic; +using System.Text.RegularExpressions; +using System.Text; +using Godot; + +namespace Rokojori +{ + [Tool] + [GlobalClass] + public partial class NoiseWipe:BaseWipeEffect + { + [ExportGroup( "Noise" )] + [Export( PropertyHint.Range, "0,1")] + public float noiseAmount = 1.0f; + + [Export( PropertyHint.Range, "0.1,100")] + public float noiseFrequency = 10f; + + [Export] + public Vector2 noisePosition = Vector2.Zero; + + [Export] + public Vector2 noiseWipeOffset = Vector2.Zero; + + protected override List _CreateEffects() + { + var wipe = new NoiseWipeEffect + { + noiseAmount = noiseAmount, + noiseFrequency = noiseFrequency, + noisePosition = noisePosition, + noiseWipeOffset = noiseWipeOffset + }; + + ApplyBaseWipeSettings( wipe ); + + return [ wipe ]; + } + + + } +} \ No newline at end of file diff --git a/Runtime/Animation/Wipe/WipeEffects/NoiseWipe.cs.uid b/Runtime/Animation/Wipe/WipeEffects/NoiseWipe.cs.uid new file mode 100644 index 0000000..4e1c617 --- /dev/null +++ b/Runtime/Animation/Wipe/WipeEffects/NoiseWipe.cs.uid @@ -0,0 +1 @@ +uid://dcwqfprd63q28 diff --git a/Runtime/Animation/Wipe/WipeSettings.cs b/Runtime/Animation/Wipe/WipeSettings.cs new file mode 100644 index 0000000..c43e582 --- /dev/null +++ b/Runtime/Animation/Wipe/WipeSettings.cs @@ -0,0 +1,21 @@ +using System.Collections; +using System.Collections.Generic; +using System.Text.RegularExpressions; +using System.Text; +using Godot; + +namespace Rokojori +{ + [Tool] + [GlobalClass] + public partial class WipeSettings:Resource + { + [Export] + public Compositor compositor; + + [Export] + public WipeEffect wipeEffect; + + + } +} \ No newline at end of file diff --git a/Runtime/Animation/Wipe/WipeSettings.cs.uid b/Runtime/Animation/Wipe/WipeSettings.cs.uid new file mode 100644 index 0000000..7c8ab68 --- /dev/null +++ b/Runtime/Animation/Wipe/WipeSettings.cs.uid @@ -0,0 +1 @@ +uid://cn05bqaq15tty diff --git a/Runtime/Conditions/Condition.cs b/Runtime/Conditions/Condition.cs index f6b9e47..a47569d 100644 --- a/Runtime/Conditions/Condition.cs +++ b/Runtime/Conditions/Condition.cs @@ -24,7 +24,7 @@ namespace Rokojori public static bool Evaluate( Condition condition ) { - return condition == null ? true : condition.Evaluate(); + return condition == null ? false : condition.Evaluate(); } } } \ No newline at end of file diff --git a/Runtime/Conditions/SceneCondition.cs b/Runtime/Conditions/SceneCondition.cs index acfbba8..f877449 100644 --- a/Runtime/Conditions/SceneCondition.cs +++ b/Runtime/Conditions/SceneCondition.cs @@ -19,7 +19,7 @@ namespace Rokojori public static bool Evaluate( SceneCondition condition ) { - return condition == null ? true : condition.Evaluate(); + return condition == null ? false : condition.Evaluate(); } } } \ No newline at end of file diff --git a/Runtime/GameObjects/GameObject3D.cs b/Runtime/GameObjects/GameObject3D.cs index d37b7ff..aefeaed 100644 --- a/Runtime/GameObjects/GameObject3D.cs +++ b/Runtime/GameObjects/GameObject3D.cs @@ -13,6 +13,12 @@ namespace Rokojori [GlobalClass, Icon("res://addons/rokojori_action_library/Icons/GameObject3D.svg") ] public partial class GameObject3D:Node3D, INetworkNode { + [ExportToolButton("Center On Children")] + public Callable centerOnChildrenButton => Callable.From( ()=> { this.CenterOnChildren(); } ); + + [ExportToolButton("Floor Pivot")] + public Callable floorPivotButton => Callable.From( ()=> { this.FloorPivot(); } ); + [ExportGroup("Physics")] [Export] public PhysicsBody3D body; diff --git a/Runtime/GameObjects/Variables/Int/ChangeIntVariable.cs b/Runtime/GameObjects/Variables/Int/ChangeIntVariable.cs new file mode 100644 index 0000000..f6b148c --- /dev/null +++ b/Runtime/GameObjects/Variables/Int/ChangeIntVariable.cs @@ -0,0 +1,33 @@ + +using System.Diagnostics; +using System.Collections; +using System.Collections.Generic; +using System; +using Godot; +using System.Linq; + + +namespace Rokojori +{ + [Tool] + [GlobalClass ] + public partial class ChangeIntVariable:Action + { + [Export] + public IntVariable variable; + + [Export] + public int num; + + + protected override void _OnTrigger() + { + if ( variable == null ) + { + return; + } + + variable.value += num; + } + } +} \ No newline at end of file diff --git a/Runtime/GameObjects/Variables/Int/ChangeIntVariable.cs.uid b/Runtime/GameObjects/Variables/Int/ChangeIntVariable.cs.uid new file mode 100644 index 0000000..2ba24f7 --- /dev/null +++ b/Runtime/GameObjects/Variables/Int/ChangeIntVariable.cs.uid @@ -0,0 +1 @@ +uid://dmdwxkjqxe03m diff --git a/Runtime/GameObjects/Variables/Int/IntVariable.cs b/Runtime/GameObjects/Variables/Int/IntVariable.cs new file mode 100644 index 0000000..6e6f404 --- /dev/null +++ b/Runtime/GameObjects/Variables/Int/IntVariable.cs @@ -0,0 +1,82 @@ + +using System.Diagnostics; +using System.Collections; +using System.Collections.Generic; +using System; +using Godot; +using System.Linq; + + +namespace Rokojori +{ + [Tool] + [GlobalClass, Icon("res://addons/rokojori_action_library/Icons/GameObject.svg") ] + public partial class IntVariable:Node + { + [Export] + public IntVariableClass variableClass; + + int _value = 0; + + [Export] + public int value + { + get => _value; + + set + { + if ( variableClass == null ) + { + _value = value; + return; + } + + var valueBefore = _value; + var valueNew = variableClass.SetValue( this, valueBefore, value ); + + if ( valueBefore == valueNew ) + { + return; + } + + onChange?.Trigger(); + + if ( valueNew > valueBefore ) + { + onIncrease?.Trigger(); + } + else if ( valueNew < valueBefore ) + { + onDecrease?.Trigger(); + } + + if ( valueNew == variableClass.min ) + { + onMin?.Trigger(); + } + + if ( valueNew == variableClass.max ) + { + onMax?.Trigger(); + } + + + } + } + + [Export] + public Action onChange; + + [Export] + public Action onIncrease; + + [Export] + public Action onDecrease; + + [Export] + public Action onMax; + + [Export] + public Action onMin; + } +} \ No newline at end of file diff --git a/Runtime/GameObjects/Variables/Int/IntVariable.cs.uid b/Runtime/GameObjects/Variables/Int/IntVariable.cs.uid new file mode 100644 index 0000000..abe3915 --- /dev/null +++ b/Runtime/GameObjects/Variables/Int/IntVariable.cs.uid @@ -0,0 +1 @@ +uid://c01nqtwmfostx diff --git a/Runtime/GameObjects/Variables/Int/IntVariableClass.cs b/Runtime/GameObjects/Variables/Int/IntVariableClass.cs new file mode 100644 index 0000000..70d24f0 --- /dev/null +++ b/Runtime/GameObjects/Variables/Int/IntVariableClass.cs @@ -0,0 +1,36 @@ + +using System.Diagnostics; +using System.Collections; +using System.Collections.Generic; +using System; +using Godot; +using System.Linq; + + +namespace Rokojori +{ + [Tool] + [GlobalClass, Icon("res://addons/rokojori_action_library/Icons/GameObject.svg") ] + public partial class IntVariableClass:Resource + { + [Export] + public int min = -1000000; + + [Export] + public int max = 1000000; + + [Export] + public int resetValue = 0; + + + public int ResetValue( IntVariable variable, int currentValue ) + { + return resetValue; + } + + public int SetValue( IntVariable variable, int valueBefore, int valueNew ) + { + return Mathf.Clamp( valueNew, min, max ); + } + } +} \ No newline at end of file diff --git a/Runtime/GameObjects/Variables/Int/IntVariableClass.cs.uid b/Runtime/GameObjects/Variables/Int/IntVariableClass.cs.uid new file mode 100644 index 0000000..3cd7872 --- /dev/null +++ b/Runtime/GameObjects/Variables/Int/IntVariableClass.cs.uid @@ -0,0 +1 @@ +uid://djyqj3dds85d6 diff --git a/Runtime/Godot/Extensions/Node3DExtensions.cs b/Runtime/Godot/Extensions/Node3DExtensions.cs index 018020b..5abb57e 100644 --- a/Runtime/Godot/Extensions/Node3DExtensions.cs +++ b/Runtime/Godot/Extensions/Node3DExtensions.cs @@ -7,6 +7,102 @@ namespace Rokojori { public static class Node3DExtensions { + public static Vector3? GetBoundsCenter( this Node3D self, bool onlyVisisble = true ) + { + var optionalBounds = self.GetWorldBounds(); + + if ( optionalBounds == null ) + { + return null; + } + + var box = (Box3)(Aabb) optionalBounds; + + return box.center; + } + + public static Vector3 GetGlobalCenterOfChildren( this Node3D self, bool bounds = false, bool onlyVisible = true ) + { + var center = Vector3.Zero; + var numChildren = 0; + + self.ForEachDirectChild( + ( c )=> + { + if ( onlyVisible && ! c.IsVisibleInTree() ) + { + return; + } + + if ( ! bounds ) + { + center += c.GlobalPosition; + numChildren ++; + return; + } + + var childCenter = c.GetBoundsCenter( onlyVisible ); + + if ( childCenter == null ) + { + return; + } + + center += (Vector3) childCenter; + numChildren ++; + } + ); + + if ( numChildren == 0 ) + { + return self.GlobalPosition; + } + + return center / numChildren; + + } + + public static void CenterOnChildren( this Node3D self, bool bounds = false, bool onlyVisible = true ) + { + var childCenter = self.GetGlobalCenterOfChildren( bounds, onlyVisible ); + + var node3Ds = self.GetDirectChildren(); + var positions = node3Ds.Map( n => n.GlobalPosition ); + + self.GlobalPosition = childCenter; + + for ( int i = 0; i < node3Ds.Count; i++ ) + { + node3Ds[ i ].GlobalPosition = positions[ i ]; + } + + } + + public static void FloorPivot( this Node3D self, bool onlyVisible = true ) + { + var worldBounds = self.GetWorldBounds( onlyVisible ); + + if ( worldBounds == null ) + { + return; + } + + var worldBox = (Box3) worldBounds; + + var flooredPivot = self.GlobalPosition; + flooredPivot.Y = worldBox.min.Y; + var node3Ds = self.GetDirectChildren(); + var positions = node3Ds.Map( n => n.GlobalPosition ); + + self.GlobalPosition = flooredPivot; + + for ( int i = 0; i < node3Ds.Count; i++ ) + { + node3Ds[ i ].GlobalPosition = positions[ i ]; + } + + } + public static Vector3 ToLocalFromLocal( this Node3D self, Node3D from, Vector3 fromLocalPosition ) { var world = from.ToGlobal( fromLocalPosition ); @@ -285,6 +381,8 @@ namespace Rokojori nBounds.Position += vi.GlobalPosition; nBounds.End += vi.GlobalPosition; + + worldBounds = worldBounds == null ? nBounds : ( ((Aabb)worldBounds).Merge( nBounds ) ); } ); diff --git a/Runtime/Godot/NodeState.cs b/Runtime/Godot/NodeState.cs index 22251e3..e6e6810 100644 --- a/Runtime/Godot/NodeState.cs +++ b/Runtime/Godot/NodeState.cs @@ -13,6 +13,7 @@ namespace Rokojori public static class NodeState { + public static bool IsVisible( this Node n ) { if ( n is Node3D ) @@ -33,6 +34,41 @@ namespace Rokojori return false; } + public static bool IsProcessingInHierarchy( this Node n ) + { + if ( n.ProcessMode == Node.ProcessModeEnum.Disabled ) + { + return false; + } + + if ( n.ProcessMode == Node.ProcessModeEnum.Always ) + { + return true; + } + + var paused = n.GetTree().Paused; + + if ( n.ProcessMode == Node.ProcessModeEnum.Pausable ) + { + return ! paused; + } + + if ( n.ProcessMode == Node.ProcessModeEnum.WhenPaused ) + { + return paused; + } + + var p = n.GetParent(); + + if ( p == null ) + { + return ! paused; + } + + return p.IsProcessingInHierarchy(); + + } + public static void Configure( Node target, NodeStateConfiguration configuration ) { Configure( target, @@ -133,25 +169,30 @@ namespace Rokojori n.ProcessMode = processMode; - if ( n is Node3D ) + if ( n is Node3D n3 ) { - ( n as Node3D ).Visible = visible; + n3.Visible = visible; } - if ( n is Node2D ) + if ( n is Node2D n2 ) { - ( n as Node2D ).Visible = visible; + n2.Visible = visible; } - if ( n is CanvasItem ) + if ( n is CanvasItem ci ) { - ( n as CanvasItem ).Visible = visible; + ci.Visible = visible; } if ( n is iNodeState ins ) { ins.OnNodeStateChanged(); } + + if ( n is CollisionShape3D cs ) + { + cs.Disabled = ! physicsEnabled; + } } public static void Set( Node n, bool enabled ) diff --git a/Runtime/Interactions/CharacterController/CharacterController.cs b/Runtime/Interactions/CharacterController/CharacterController.cs index 8d0ec94..9fd5ef3 100644 --- a/Runtime/Interactions/CharacterController/CharacterController.cs +++ b/Runtime/Interactions/CharacterController/CharacterController.cs @@ -42,10 +42,10 @@ namespace Rokojori public float delta = 0; - + public override void _Process( double delta ) { - if ( Engine.IsEditorHint() || graphics == null || body == null ) + if ( Engine.IsEditorHint() && graphics == null || body == null ) { return; } @@ -54,9 +54,6 @@ namespace Rokojori { ProcessActions( (float) delta ); } - - - if ( body.IsOnFloor() ) { @@ -64,8 +61,7 @@ namespace Rokojori } - AssignGroundedTransform(); - + AssignGroundedTransform(); // Pose.CopyTo( body, graphics ); @@ -94,14 +90,21 @@ namespace Rokojori groundedTransform.SetGlobalQuaternion( graphics.GlobalQuaternion() ); } + // #if !TOOLS public override void _PhysicsProcess( double delta ) { + if ( Engine.IsEditorHint() || graphics == null || body == null ) + { + return; + } + if ( CharacterUpdateMode.Physics_Process == characterUpdateMode ) { ProcessActions( (float) delta ); } } - + // #endif + void ProcessActions( float delta ) { this.delta = (float) delta; diff --git a/Runtime/Interactions/CharacterController/CharacterMovement.cs b/Runtime/Interactions/CharacterController/CharacterMovement.cs index 62bf33c..e453103 100644 --- a/Runtime/Interactions/CharacterController/CharacterMovement.cs +++ b/Runtime/Interactions/CharacterController/CharacterMovement.cs @@ -62,6 +62,9 @@ namespace Rokojori [Export] public float movingSpeedTreshold = 0.01f; + [Export] + public float currentSpeed = 0f; + [Export] public Action onStartedMoving; @@ -95,6 +98,8 @@ namespace Rokojori Vector3 _smoothedMovement; public Vector3 smoothedMovement => _smoothedMovement; + + int _frameID = 0; protected override void _OnTrigger() { @@ -167,17 +172,27 @@ namespace Rokojori // var smoothedMovement = Vector3.Zero; + var movement = characterMovementData.movement; + var delta = controller.delta; + if ( onFloor ) { - _smoothedMovement = onFloorMovementSmoothing.Smooth( characterMovementData.movement, controller.delta ); + _smoothedMovement = onFloorMovementSmoothing.Smooth( movement, delta ); } else { - _smoothedMovement = inAirMovementSmoothing.Smooth( characterMovementData.movement, controller.delta ); + _smoothedMovement = inAirMovementSmoothing.Smooth( movement, delta ); } var wasMoving = _moving; - _moving = _smoothedMovement.Length() > movingSpeedTreshold; + currentSpeed = _smoothedMovement.Length(); + + // this.LogInfo( _frameID, currentMovementType.ResourceName, " >> speed:", currentSpeed._FF(), "movement:", movement, "delta:", delta._FFF() ); + _frameID ++; + + _moving = currentSpeed > movingSpeedTreshold; + + if ( wasMoving != _moving ) { diff --git a/Runtime/Interactions/CharacterController/CharacterMovements/TurnMovementType.cs b/Runtime/Interactions/CharacterController/CharacterMovements/TurnMovementType.cs index 66d9277..cac9251 100644 --- a/Runtime/Interactions/CharacterController/CharacterMovements/TurnMovementType.cs +++ b/Runtime/Interactions/CharacterController/CharacterMovements/TurnMovementType.cs @@ -44,6 +44,10 @@ namespace Rokojori [Export] public float strafeSidewardsSpeedMultiply = 1.0f; + [ExportGroup( "Tweaking" )] + [Export] + public float yDeltaOffset = 0.01f; + public override void ProcessMovement( CharacterMovementData characterMovementData ) { var characterMovement = characterMovementData.characterMovement; @@ -67,13 +71,18 @@ namespace Rokojori forwardDirection = bodyPlane.ConstrainToPlane( forwardDirection + body.GlobalPosition ) - body.GlobalPosition; rightDirection = bodyPlane.ConstrainToPlane( rightDirection + body.GlobalPosition ) - body.GlobalPosition; } - + + forwardDirection.Y += yDeltaOffset; + rightDirection.Y += yDeltaOffset; + forwardDirection = forwardDirection.Normalized(); rightDirection = rightDirection.Normalized(); var direction = Sensors.FourDirectional( left, right, up, down ); + // this.LogInfo( "moving:", "fw", forwardDirection, "r", rightDirection, "dir:", direction ); + var movement = forwardDirection * - direction.Y * characterMovement.moveSpeed; movement += rightDirection * direction.X * characterMovement.moveSpeed; diff --git a/Runtime/Interactions/CharacterController/MoveAndSlide.cs b/Runtime/Interactions/CharacterController/MoveAndSlide.cs index 1d91529..a3e8a5a 100644 --- a/Runtime/Interactions/CharacterController/MoveAndSlide.cs +++ b/Runtime/Interactions/CharacterController/MoveAndSlide.cs @@ -9,10 +9,72 @@ namespace Rokojori [GlobalClass, Icon("res://addons/rokojori_action_library/Icons/CCMoveAndSlide.svg")] public partial class MoveAndSlide:CharacterControllerAction { + [Export] + public bool useStepping = false; + + [Export] + public float stepMaxHeight = 0.2f; + protected override void _OnTrigger() { - // RJLog.Log( controller.body.Velocity ); + var body = controller.body; + var motion = controller.body.Velocity * controller.delta; + + var collision = body.MoveAndCollide( motion, testOnly: true ); + + if ( collision != null && StepUp( motion ) ) + { + return; + } + controller.body.MoveAndSlide(); } + + protected bool StepUp( Vector3 motion ) + { + var up = Vector3.Up * stepMaxHeight; + + var hitAbove = controller.body.TestMove( controller.body.GlobalTransform, up ); + + if ( hitAbove ) + { + return false; + } + + bool hitForward = controller.body.TestMove( controller.body.GlobalTransform.Translated( up ), motion ); + + if ( ! hitForward ) + { + var space = controller.body.GetWorld3D().DirectSpaceState; + var origin = controller.body.GlobalPosition; + var stepUpOrigin = controller.body.GlobalPosition + up; + + var downHit = space.IntersectRay( + new PhysicsRayQueryParameters3D + { + From = stepUpOrigin, + To = stepUpOrigin + Vector3.Down * ( stepMaxHeight + 0.1f ), + CollisionMask = 1, + CollideWithAreas = false, + CollideWithBodies = true + } + ); + + if ( downHit.Count == 0 ) + { + return false; + } + + var exactStepAmount = downHit[ "position" ].AsVector3().Y - origin.Y; + + if ( exactStepAmount > 0 && exactStepAmount <= stepMaxHeight ) + { + controller.body.GlobalTranslate( new Vector3( 0, exactStepAmount, 0 ) ); + return true; + } + } + + return false; + } } } \ No newline at end of file diff --git a/Runtime/Interactions/Collecting/Collectable.cs b/Runtime/Interactions/Collecting/Collectable.cs new file mode 100644 index 0000000..f6bc04e --- /dev/null +++ b/Runtime/Interactions/Collecting/Collectable.cs @@ -0,0 +1,85 @@ +using Godot; +using System.Collections; +using System.Collections.Generic; +using Godot.Collections; +using System.Drawing; + +namespace Rokojori +{ + [Tool] + [GlobalClass,Icon("res://addons/rokojori_action_library/Icons/Collectable.svg")] + public partial class Collectable:Action + { + [Export] + public CollectorTypeFlag[] collectorTypeFlags = []; + + [Export] + public Collidable collidable; + + [Export] + public CollectableData collectableData; + + [Export] + public bool isAutoCollectable = true; + + + [ExportGroup( "On Collected")] + [Export] + public Collector collector; + + [Export] + public bool disableOnCollection = true; + + + protected override void _OnTrigger() + { + if ( collidable == null || collectableData == null ) + { + RJLog.Log( "No collidable or data" ); + return; + } + + var collider = collidable.collider; + + if ( collider == null ) + { + RJLog.Log( "No collider" ); + return; + } + + var collector = collider.FindSibling(); + + if ( collector == null ) + { + RJLog.Log( "No collector" ); + return; + } + + if ( collectorTypeFlags != null && collectorTypeFlags.Length > 0 ) + { + if ( collectorTypeFlags.IndexOf( collector.collectorTypeFlag ) == -1 ) + { + RJLog.Log( "No matching collectorTypeFlags" ); + return; + } + } + + var wasCollected = collector.Collect( this ); + + if ( ! wasCollected ) + { + RJLog.Log( "! wasCollected" ); + return; + } + + this.collector = collector; + + if ( disableOnCollection ) + { + ProcessMode = ProcessModeEnum.Disabled; + } + + + } + } +} diff --git a/Runtime/Interactions/Collecting/Collectable.cs.uid b/Runtime/Interactions/Collecting/Collectable.cs.uid new file mode 100644 index 0000000..6238502 --- /dev/null +++ b/Runtime/Interactions/Collecting/Collectable.cs.uid @@ -0,0 +1 @@ +uid://qwprrym288gb diff --git a/Runtime/Interactions/Collecting/CollectableCollection.cs b/Runtime/Interactions/Collecting/CollectableCollection.cs new file mode 100644 index 0000000..eb1298f --- /dev/null +++ b/Runtime/Interactions/Collecting/CollectableCollection.cs @@ -0,0 +1,23 @@ +using Godot; +using System.Collections; +using System.Collections.Generic; +using Godot.Collections; +using System.Drawing; +using System; + +namespace Rokojori +{ + [Tool] + [GlobalClass,Icon("res://addons/rokojori_action_library/Icons/Collectable.svg")] + public partial class CollectableCollection:Resource + { + [Export] + public CollectableType collectableType; + + [Export] + public CollectableData[] collection = []; + + [Export] + public ISOTimeStamp[] timeStamps = []; + } +} diff --git a/Runtime/Interactions/Collecting/CollectableCollection.cs.uid b/Runtime/Interactions/Collecting/CollectableCollection.cs.uid new file mode 100644 index 0000000..ae3e4ed --- /dev/null +++ b/Runtime/Interactions/Collecting/CollectableCollection.cs.uid @@ -0,0 +1 @@ +uid://b2cvaagf81moo diff --git a/Runtime/Interactions/Collecting/CollectableData.cs b/Runtime/Interactions/Collecting/CollectableData.cs new file mode 100644 index 0000000..91136e4 --- /dev/null +++ b/Runtime/Interactions/Collecting/CollectableData.cs @@ -0,0 +1,16 @@ +using Godot; +using System.Collections; +using System.Collections.Generic; +using Godot.Collections; +using System.Drawing; + +namespace Rokojori +{ + [Tool] + [GlobalClass,Icon("res://addons/rokojori_action_library/Icons/Collectable.svg")] + public partial class CollectableData:SelectorFlag + { + [Export] + public CollectableType collectableType; + } +} diff --git a/Runtime/Interactions/Collecting/CollectableData.cs.uid b/Runtime/Interactions/Collecting/CollectableData.cs.uid new file mode 100644 index 0000000..fdecb85 --- /dev/null +++ b/Runtime/Interactions/Collecting/CollectableData.cs.uid @@ -0,0 +1 @@ +uid://dutnxjwc8dhx7 diff --git a/Runtime/Interactions/Collecting/CollectableType.cs b/Runtime/Interactions/Collecting/CollectableType.cs new file mode 100644 index 0000000..69af1ce --- /dev/null +++ b/Runtime/Interactions/Collecting/CollectableType.cs @@ -0,0 +1,19 @@ +using Godot; +using System.Collections; +using System.Collections.Generic; +using Godot.Collections; +using System.Drawing; + +namespace Rokojori +{ + [Tool] + [GlobalClass,Icon("res://addons/rokojori_action_library/Icons/Collectable.svg")] + public partial class CollectableType:SelectorFlag + { + [Export] + public LocaleText collectableName; + + [Export] + public Texture2D collectableIcon; + } +} diff --git a/Runtime/Interactions/Collecting/CollectableType.cs.uid b/Runtime/Interactions/Collecting/CollectableType.cs.uid new file mode 100644 index 0000000..fb0a65b --- /dev/null +++ b/Runtime/Interactions/Collecting/CollectableType.cs.uid @@ -0,0 +1 @@ +uid://doocg3kjxesop diff --git a/Runtime/Interactions/Collecting/CollectableTypeGroup.cs b/Runtime/Interactions/Collecting/CollectableTypeGroup.cs new file mode 100644 index 0000000..45898e3 --- /dev/null +++ b/Runtime/Interactions/Collecting/CollectableTypeGroup.cs @@ -0,0 +1,16 @@ +using Godot; +using System.Collections; +using System.Collections.Generic; +using Godot.Collections; +using System.Drawing; + +namespace Rokojori +{ + [Tool] + [GlobalClass,Icon("res://addons/rokojori_action_library/Icons/Collectable.svg")] + public partial class CollectableTypeGroup:Resource + { + [Export] + public CollectableType[] types; + } +} diff --git a/Runtime/Interactions/Collecting/CollectableTypeGroup.cs.uid b/Runtime/Interactions/Collecting/CollectableTypeGroup.cs.uid new file mode 100644 index 0000000..9143821 --- /dev/null +++ b/Runtime/Interactions/Collecting/CollectableTypeGroup.cs.uid @@ -0,0 +1 @@ +uid://b3ipr2fudbgyu diff --git a/Runtime/Interactions/Collecting/Collector.cs b/Runtime/Interactions/Collecting/Collector.cs new file mode 100644 index 0000000..8bfb335 --- /dev/null +++ b/Runtime/Interactions/Collecting/Collector.cs @@ -0,0 +1,71 @@ +using Godot; +using System.Collections; +using System.Collections.Generic; +using Godot.Collections; +using System.Drawing; + +namespace Rokojori +{ + [Tool] + [GlobalClass,Icon("res://addons/rokojori_action_library/Icons/Collector.svg")] + public partial class Collector:Node + { + [Export] + public CollectorTypeFlag collectorTypeFlag; + + [Export] + public CollectableCollection[] collectables = []; + + [Export] + public bool canAutoCollect = true; + + [Export] + public CollectableData lastItemData; + + [Export] + public ISOTimeStamp lastItemTime; + + [Export] + public Action onCollected; + + public bool CanCollect( Collectable collectable ) + { + if ( canAutoCollect && collectable.isAutoCollectable ) + { + return true; + } + + return collectables.Has( c => c.collectableType == collectable.collectableData.collectableType ); + } + + public virtual bool Collect( Collectable collectable ) + { + var canCollect = CanCollect( collectable ); + + if ( ! canCollect ) + { + return false; + } + + var collection = collectables.Find( c => c.collectableType == collectable.collectableData.collectableType ); + + if ( collection == null ) + { + collection = new CollectableCollection(); + collection.collectableType = collectable.collectableData.collectableType; + + collectables = collectables.Add( collection ); + } + + lastItemData = collectable.collectableData; + lastItemTime = ISOTimeStamp.Now(); + + collection.collection = collection.collection.Add( lastItemData ); + collection.timeStamps = collection.timeStamps.Add( lastItemTime ); + + onCollected?.Trigger(); + + return true; + } + } +} diff --git a/Runtime/Interactions/Collecting/Collector.cs.uid b/Runtime/Interactions/Collecting/Collector.cs.uid new file mode 100644 index 0000000..4270c50 --- /dev/null +++ b/Runtime/Interactions/Collecting/Collector.cs.uid @@ -0,0 +1 @@ +uid://ccfk70dpt7r7r diff --git a/Runtime/Interactions/Collecting/CollectorTypeFlag.cs b/Runtime/Interactions/Collecting/CollectorTypeFlag.cs new file mode 100644 index 0000000..189feee --- /dev/null +++ b/Runtime/Interactions/Collecting/CollectorTypeFlag.cs @@ -0,0 +1,15 @@ +using Godot; +using System.Collections; +using System.Collections.Generic; +using Godot.Collections; +using System.Drawing; + +namespace Rokojori +{ + [Tool] + [GlobalClass] + public partial class CollectorTypeFlag:SelectorFlag + { + + } +} diff --git a/Runtime/Interactions/Collecting/CollectorTypeFlag.cs.uid b/Runtime/Interactions/Collecting/CollectorTypeFlag.cs.uid new file mode 100644 index 0000000..5d67157 --- /dev/null +++ b/Runtime/Interactions/Collecting/CollectorTypeFlag.cs.uid @@ -0,0 +1 @@ +uid://dkd063lgqobog diff --git a/Runtime/Interactions/Collecting/OnCollected.cs b/Runtime/Interactions/Collecting/OnCollected.cs new file mode 100644 index 0000000..a7022ec --- /dev/null +++ b/Runtime/Interactions/Collecting/OnCollected.cs @@ -0,0 +1,67 @@ +using Godot; +using System.Collections; +using System.Collections.Generic; +using Godot.Collections; +using System.Drawing; + +namespace Rokojori +{ + [Tool] + [GlobalClass,Icon("res://addons/rokojori_action_library/Icons/Collectable.svg")] + public partial class OnCollected:Action + { + [Export] + public Collector collector; + + [Export] + public CollectableTypeGroup[] includingTypes = []; + + [Export] + public CollectableTypeGroup[] excludingTypes = []; + + [Export] + public Action onCollectedAction; + + protected override void _OnTrigger() + { + var collector = this.collector != null ? this.collector : this.FindParentThatIs(); + + if ( collector == null ) + { + return; + } + + var collectableData = collector.lastItemData; + + if ( collectableData == null ) + { + return; + } + + if ( includingTypes != null ) + { + var included = includingTypes.Has( g => g.types.Has( t => t == collectableData.collectableType ) ); + + if ( ! included ) + { + return; + } + } + + if ( excludingTypes != null ) + { + var excluded = excludingTypes.Has( g => g.types.Has( t => t == collectableData.collectableType ) ); + + if ( excluded ) + { + return; + } + } + + + onCollectedAction?.Trigger(); + + } + + } +} diff --git a/Runtime/Interactions/Collecting/OnCollected.cs.uid b/Runtime/Interactions/Collecting/OnCollected.cs.uid new file mode 100644 index 0000000..6eef2fc --- /dev/null +++ b/Runtime/Interactions/Collecting/OnCollected.cs.uid @@ -0,0 +1 @@ +uid://nfn3x4l7pcob diff --git a/Runtime/Physics/Wind/Properties/rj_GlobalWind.tres b/Runtime/Physics/Wind/Properties/rj_GlobalWind.tres index 63ad594..d539afd 100644 --- a/Runtime/Physics/Wind/Properties/rj_GlobalWind.tres +++ b/Runtime/Physics/Wind/Properties/rj_GlobalWind.tres @@ -1,12 +1,14 @@ -[gd_resource type="Resource" script_class="ShaderPropertyBlock" load_steps=6 format=3 uid="uid://bssrxwasqgpbd"] +[gd_resource type="Resource" script_class="ShaderPropertyBlock" load_steps=8 format=3 uid="uid://bssrxwasqgpbd"] [ext_resource type="Script" uid="uid://by2xsdh6vbaja" path="res://addons/rokojori_action_library/Runtime/Shading/Properties/Properties/ShaderPropertyBlock.cs" id="1_x3rvk"] [ext_resource type="Resource" uid="uid://c84w0b74mfgpr" path="res://addons/rokojori_action_library/Runtime/Physics/Wind/Properties/rj_GlobalWindDirectionProperty.tres" id="2_dcpws"] -[ext_resource type="Resource" uid="uid://efmv0fcfxlqe" path="res://addons/rokojori_action_library/Runtime/Physics/Wind/Properties/rj_GlobalWindNoiseTextureProperty.tres" id="3_kcrsv"] -[ext_resource type="Resource" uid="uid://bqm71chf8v7rs" path="res://addons/rokojori_action_library/Runtime/Physics/Wind/Properties/rj_GlobalWindPositionProperty.tres" id="4_owh4a"] +[ext_resource type="Resource" uid="uid://efmv0fcfxlqe" path="res://addons/rokojori_action_library/Runtime/Physics/Wind/Properties/rj_GlobalWindNoiseTextureCloseProperty.tres" id="3_u8xv4"] +[ext_resource type="Resource" uid="uid://bqm71chf8v7rs" path="res://addons/rokojori_action_library/Runtime/Physics/Wind/Properties/rj_GlobalWindPositionCloseProperty.tres" id="4_uwq2i"] [ext_resource type="Resource" uid="uid://dtmjjes2elpl0" path="res://addons/rokojori_action_library/Runtime/Physics/Wind/Properties/rj_GlobalWindSpeedProperty.tres" id="5_kcrsv"] +[ext_resource type="Resource" uid="uid://du6ytwf1rcwop" path="res://addons/rokojori_action_library/Runtime/Physics/Wind/Properties/rj_GlobalWindNoiseTextureFarProperty.tres" id="5_npfeq"] +[ext_resource type="Resource" uid="uid://dhb638puibjbo" path="res://addons/rokojori_action_library/Runtime/Physics/Wind/Properties/rj_GlobalWindPositionFarProperty.tres" id="6_y5mpi"] [resource] script = ExtResource("1_x3rvk") -shaderProperties = [ExtResource("2_dcpws"), ExtResource("3_kcrsv"), ExtResource("4_owh4a"), ExtResource("5_kcrsv")] +shaderProperties = [ExtResource("2_dcpws"), ExtResource("3_u8xv4"), ExtResource("4_uwq2i"), ExtResource("5_npfeq"), ExtResource("6_y5mpi"), ExtResource("5_kcrsv")] metadata/_custom_type_script = "uid://by2xsdh6vbaja" diff --git a/Runtime/Physics/Wind/Properties/rj_GlobalWindNoiseTexture.tres b/Runtime/Physics/Wind/Properties/rj_GlobalWindNoiseTextureClose.tres similarity index 72% rename from Runtime/Physics/Wind/Properties/rj_GlobalWindNoiseTexture.tres rename to Runtime/Physics/Wind/Properties/rj_GlobalWindNoiseTextureClose.tres index fb0b528..e3f32cf 100644 --- a/Runtime/Physics/Wind/Properties/rj_GlobalWindNoiseTexture.tres +++ b/Runtime/Physics/Wind/Properties/rj_GlobalWindNoiseTextureClose.tres @@ -1,8 +1,8 @@ [gd_resource type="Resource" script_class="Sampler2DPropertyName" load_steps=2 format=3 uid="uid://bnjsr0w6xwkho"] -[ext_resource type="Script" uid="uid://bsreukpi8eiyy" path="res://addons/rokojori_action_library/Runtime/Shading/Properties/Sampler2DPropertyName.cs" id="1_prtqd"] +[ext_resource type="Script" uid="uid://bsreukpi8eiyy" path="res://addons/rokojori_action_library/Runtime/Shading/Properties/Sampler2DPropertyName.cs" id="1_6unrl"] [resource] -script = ExtResource("1_prtqd") -propertyName = "rj_GlobalWindNoiseTexture" +script = ExtResource("1_6unrl") +propertyName = "rj_GlobalWindNoiseTextureClose" metadata/_custom_type_script = "uid://bsreukpi8eiyy" diff --git a/Runtime/Physics/Wind/Properties/rj_GlobalWindNoiseTextureProperty.tres b/Runtime/Physics/Wind/Properties/rj_GlobalWindNoiseTextureCloseProperty.tres similarity index 93% rename from Runtime/Physics/Wind/Properties/rj_GlobalWindNoiseTextureProperty.tres rename to Runtime/Physics/Wind/Properties/rj_GlobalWindNoiseTextureCloseProperty.tres index 804ad26..6f62513 100644 --- a/Runtime/Physics/Wind/Properties/rj_GlobalWindNoiseTextureProperty.tres +++ b/Runtime/Physics/Wind/Properties/rj_GlobalWindNoiseTextureCloseProperty.tres @@ -1,6 +1,6 @@ [gd_resource type="Resource" script_class="Sampler2DProperty" load_steps=4 format=3 uid="uid://efmv0fcfxlqe"] -[ext_resource type="Resource" uid="uid://bnjsr0w6xwkho" path="res://addons/rokojori_action_library/Runtime/Physics/Wind/Properties/rj_GlobalWindNoiseTexture.tres" id="1_7ivdf"] +[ext_resource type="Resource" uid="uid://bnjsr0w6xwkho" path="res://addons/rokojori_action_library/Runtime/Physics/Wind/Properties/rj_GlobalWindNoiseTextureClose.tres" id="1_7ivdf"] [ext_resource type="Script" uid="uid://co43lpc6cforf" path="res://addons/rokojori_action_library/Runtime/Shading/Properties/Properties/Sampler2DProperty.cs" id="2_ss2hx"] [ext_resource type="Texture2D" uid="uid://c30nul6romace" path="res://addons/rokojori_action_library/Runtime/Procedural/Noise/RGB 3D Noise.png" id="3_4n0un"] diff --git a/Runtime/Physics/Wind/Properties/rj_GlobalWindNoiseTextureFar.tres b/Runtime/Physics/Wind/Properties/rj_GlobalWindNoiseTextureFar.tres new file mode 100644 index 0000000..9906e97 --- /dev/null +++ b/Runtime/Physics/Wind/Properties/rj_GlobalWindNoiseTextureFar.tres @@ -0,0 +1,8 @@ +[gd_resource type="Resource" script_class="Sampler2DPropertyName" load_steps=2 format=3 uid="uid://cwwu7wohhc0be"] + +[ext_resource type="Script" uid="uid://bsreukpi8eiyy" path="res://addons/rokojori_action_library/Runtime/Shading/Properties/Sampler2DPropertyName.cs" id="1_s8txx"] + +[resource] +script = ExtResource("1_s8txx") +propertyName = "rj_GlobalWindNoiseTextureFar" +metadata/_custom_type_script = "uid://bsreukpi8eiyy" diff --git a/Runtime/Physics/Wind/Properties/rj_GlobalWindNoiseTextureFarProperty.tres b/Runtime/Physics/Wind/Properties/rj_GlobalWindNoiseTextureFarProperty.tres new file mode 100644 index 0000000..774da08 --- /dev/null +++ b/Runtime/Physics/Wind/Properties/rj_GlobalWindNoiseTextureFarProperty.tres @@ -0,0 +1,11 @@ +[gd_resource type="Resource" script_class="Sampler2DProperty" load_steps=4 format=3 uid="uid://du6ytwf1rcwop"] + +[ext_resource type="Resource" uid="uid://cwwu7wohhc0be" path="res://addons/rokojori_action_library/Runtime/Physics/Wind/Properties/rj_GlobalWindNoiseTextureFar.tres" id="1_57cas"] +[ext_resource type="Script" uid="uid://co43lpc6cforf" path="res://addons/rokojori_action_library/Runtime/Shading/Properties/Properties/Sampler2DProperty.cs" id="2_vmqqo"] +[ext_resource type="Texture2D" uid="uid://c30nul6romace" path="res://addons/rokojori_action_library/Runtime/Procedural/Noise/RGB 3D Noise.png" id="3_8nq0y"] + +[resource] +script = ExtResource("2_vmqqo") +propertyName = ExtResource("1_57cas") +value = ExtResource("3_8nq0y") +metadata/_custom_type_script = "uid://co43lpc6cforf" diff --git a/Runtime/Physics/Wind/Properties/rj_GlobalWindPosition.tres b/Runtime/Physics/Wind/Properties/rj_GlobalWindPositionClose.tres similarity index 73% rename from Runtime/Physics/Wind/Properties/rj_GlobalWindPosition.tres rename to Runtime/Physics/Wind/Properties/rj_GlobalWindPositionClose.tres index b83af5c..4a72104 100644 --- a/Runtime/Physics/Wind/Properties/rj_GlobalWindPosition.tres +++ b/Runtime/Physics/Wind/Properties/rj_GlobalWindPositionClose.tres @@ -1,8 +1,8 @@ [gd_resource type="Resource" script_class="Vector2PropertyName" load_steps=2 format=3 uid="uid://cqw5ebx5oq2p0"] -[ext_resource type="Script" uid="uid://cebfjne1ewhnm" path="res://addons/rokojori_action_library/Runtime/Shading/Properties/Vector2PropertyName.cs" id="1_xy81n"] +[ext_resource type="Script" uid="uid://cebfjne1ewhnm" path="res://addons/rokojori_action_library/Runtime/Shading/Properties/Vector2PropertyName.cs" id="1_n4dfn"] [resource] -script = ExtResource("1_xy81n") -propertyName = "rj_GlobalWindPosition" +script = ExtResource("1_n4dfn") +propertyName = "rj_GlobalWindPositionClose" metadata/_custom_type_script = "uid://cebfjne1ewhnm" diff --git a/Runtime/Physics/Wind/Properties/rj_GlobalWindPositionProperty.tres b/Runtime/Physics/Wind/Properties/rj_GlobalWindPositionCloseProperty.tres similarity index 91% rename from Runtime/Physics/Wind/Properties/rj_GlobalWindPositionProperty.tres rename to Runtime/Physics/Wind/Properties/rj_GlobalWindPositionCloseProperty.tres index 56f60fd..e4a2835 100644 --- a/Runtime/Physics/Wind/Properties/rj_GlobalWindPositionProperty.tres +++ b/Runtime/Physics/Wind/Properties/rj_GlobalWindPositionCloseProperty.tres @@ -1,6 +1,6 @@ [gd_resource type="Resource" script_class="Vector2Property" load_steps=3 format=3 uid="uid://bqm71chf8v7rs"] -[ext_resource type="Resource" uid="uid://cqw5ebx5oq2p0" path="res://addons/rokojori_action_library/Runtime/Physics/Wind/Properties/rj_GlobalWindPosition.tres" id="1_laxhy"] +[ext_resource type="Resource" uid="uid://cqw5ebx5oq2p0" path="res://addons/rokojori_action_library/Runtime/Physics/Wind/Properties/rj_GlobalWindPositionClose.tres" id="1_laxhy"] [ext_resource type="Script" uid="uid://colw2dxvhfkxy" path="res://addons/rokojori_action_library/Runtime/Shading/Properties/Properties/Vector2Property.cs" id="1_ujntv"] [resource] diff --git a/Runtime/Physics/Wind/Properties/rj_GlobalWindPositionFar.tres b/Runtime/Physics/Wind/Properties/rj_GlobalWindPositionFar.tres new file mode 100644 index 0000000..46a3d17 --- /dev/null +++ b/Runtime/Physics/Wind/Properties/rj_GlobalWindPositionFar.tres @@ -0,0 +1,8 @@ +[gd_resource type="Resource" script_class="Vector2PropertyName" load_steps=2 format=3 uid="uid://qm0sg1s8xaox"] + +[ext_resource type="Script" uid="uid://cebfjne1ewhnm" path="res://addons/rokojori_action_library/Runtime/Shading/Properties/Vector2PropertyName.cs" id="1_pel8l"] + +[resource] +script = ExtResource("1_pel8l") +propertyName = "rj_GlobalWindPositionFar" +metadata/_custom_type_script = "uid://cebfjne1ewhnm" diff --git a/Runtime/Physics/Wind/Properties/rj_GlobalWindPositionFarProperty.tres b/Runtime/Physics/Wind/Properties/rj_GlobalWindPositionFarProperty.tres new file mode 100644 index 0000000..31608ad --- /dev/null +++ b/Runtime/Physics/Wind/Properties/rj_GlobalWindPositionFarProperty.tres @@ -0,0 +1,10 @@ +[gd_resource type="Resource" script_class="Vector2Property" load_steps=3 format=3 uid="uid://dhb638puibjbo"] + +[ext_resource type="Resource" uid="uid://qm0sg1s8xaox" path="res://addons/rokojori_action_library/Runtime/Physics/Wind/Properties/rj_GlobalWindPositionFar.tres" id="1_dn5hy"] +[ext_resource type="Script" uid="uid://colw2dxvhfkxy" path="res://addons/rokojori_action_library/Runtime/Shading/Properties/Properties/Vector2Property.cs" id="2_kk3m7"] + +[resource] +script = ExtResource("2_kk3m7") +propertyName = ExtResource("1_dn5hy") +value = Vector2(0, -46.304832) +metadata/_custom_type_script = "uid://colw2dxvhfkxy" diff --git a/Runtime/Physics/Wind/WindManager.cs b/Runtime/Physics/Wind/WindManager.cs index 9b2c508..cf81060 100644 --- a/Runtime/Physics/Wind/WindManager.cs +++ b/Runtime/Physics/Wind/WindManager.cs @@ -21,15 +21,16 @@ namespace Rokojori return; } - UpdatePosition( rm, (float) delta ); + UpdatePosition( rm, (float) delta, data.globalWindPositionClosePropertyName, data.closeMultiplier ); + UpdatePosition( rm, (float) delta, data.globalWindPositionFarPropertyName, data.farMultiplier ); UpdateDirection( rm, (float) delta ); UpdateSpeed( rm, (float) delta ); } - void UpdatePosition( RenderingManager rm, float delta ) + void UpdatePosition( RenderingManager rm, float delta, ShaderPropertyName positionName, float multiplier ) { - var windPositionProperty = rm.data.GetGlobalPropertyByName( data.globalWindPositionPropertyName ); + var windPositionProperty = rm.data.GetGlobalPropertyByName( positionName ); if ( windPositionProperty == null ) { @@ -38,7 +39,7 @@ namespace Rokojori var positionProperty = (Vector2Property) windPositionProperty; var position = positionProperty.value; - position += -data.windSpeed.GetNormalizedWindSpeedOffset( delta, data.minimumScrollSpeedKMH, data.maximumScrollSpeedKMH ) * data.windDirection.Normalized(); + position += multiplier * -data.windSpeed.GetNormalizedWindSpeedOffset( delta, data.minimumScrollSpeedKMH, data.maximumScrollSpeedKMH ) * data.windDirection.Normalized(); positionProperty.value = position; } diff --git a/Runtime/Physics/Wind/WindManagerData.cs b/Runtime/Physics/Wind/WindManagerData.cs index 7006f51..d9640a9 100644 --- a/Runtime/Physics/Wind/WindManagerData.cs +++ b/Runtime/Physics/Wind/WindManagerData.cs @@ -21,7 +21,16 @@ namespace Rokojori public float maximumScrollSpeedKMH = 100; [Export] - public Vector2PropertyName globalWindPositionPropertyName; + public float closeMultiplier = 1.0f; + + [Export] + public float farMultiplier = 0.1f; + + [Export] + public Vector2PropertyName globalWindPositionClosePropertyName; + + [Export] + public Vector2PropertyName globalWindPositionFarPropertyName; [Export] public Vector2PropertyName globalWindDirectionPropertyName; diff --git a/Runtime/Procedural/Parametric/Spline/Spline.cs b/Runtime/Procedural/Parametric/Spline/Spline.cs index 969938e..f60def0 100644 --- a/Runtime/Procedural/Parametric/Spline/Spline.cs +++ b/Runtime/Procedural/Parametric/Spline/Spline.cs @@ -80,12 +80,43 @@ namespace Rokojori } + List GetFilteredSplinePoints() + { + var unfilteredSplinePoints = Nodes.GetDirectChildren( this ); + + if ( unfilteredSplinePoints.Count == 0 ) + { + return unfilteredSplinePoints; + } + + + var splinePoints = new List(); + var lastPoint = 0; + + splinePoints.Add( unfilteredSplinePoints[ 0 ] ); + + for ( int i = 1; i < unfilteredSplinePoints.Count; i++ ) + { + var last = unfilteredSplinePoints[ lastPoint ]; + var p = unfilteredSplinePoints[ i ]; + var distance = ( last.GlobalPosition - p.GlobalPosition ).Length(); + + if ( distance > 0.0001f ) + { + splinePoints.Add( p ); + lastPoint = i; + } + } + + // this.LogInfo( "Filtered Spline Points:", unfilteredSplinePoints.Count, ">>", splinePoints.Count ); + return splinePoints; + } + public SplineCurve GetCurve() { if ( splineCurve == null ) { - var splinePoints = Nodes.GetDirectChildren( this ); - + var splinePoints = GetFilteredSplinePoints(); splineCurve = new SplineCurveCreator().Create( splinePoints, closed ); min = splineCurve.MinPointPosition(); @@ -104,8 +135,7 @@ namespace Rokojori { if ( splineCurveXZ == null ) { - var splinePoints = Nodes.GetDirectChildren( this ); - + var splinePoints = GetFilteredSplinePoints(); splineCurveXZ = new SplineCurveCreator().Create( splinePoints, closed ).CloneForXZ( 0 ); } diff --git a/Runtime/Procedural/Scatter/Generators/GenerateFence.cs b/Runtime/Procedural/Scatter/Generators/GenerateFence.cs index 0929fd6..9017f14 100644 --- a/Runtime/Procedural/Scatter/Generators/GenerateFence.cs +++ b/Runtime/Procedural/Scatter/Generators/GenerateFence.cs @@ -24,6 +24,12 @@ namespace Rokojori public GeneratorEntry segment; [Export] public float segmentLength; + [Export] + public Vector3 segmentRotation; + [Export] + public float segmentYOffset; + [Export] + public Vector3 scaleAxis = new Vector3( 1, 0, 0 ); [Export] public GeneratorEntry pole; @@ -60,6 +66,9 @@ namespace Rokojori var id = 0; + var positions = new List(); + var rotations = new List(); + for ( int i = 0; i < numPoints; i++ ) { var t = i / (float) ( numPoints - 1 ); @@ -82,18 +91,35 @@ namespace Rokojori "D:", direction );*/ - var point = CreatePoint( points, id, position.X, position.Y, position.Z ); + var point = CreatePoint( points, id, position.X, position.Y, position.Z, pole ); point.rotation = Math3D.LookRotation( direction, Vector3.Up ); + + positions.Add( position ); + rotations.Add( point.rotation ); id = point.creatorID + 1; } + for ( int i = 0; i < positions.Count - 1; i++ ) + { + var position = positions[ i ].Lerp( positions[ i + 1 ], 0.5f ); + var direction = positions[ i + 1 ] - positions[ i ]; + var rotation = Math3D.LookRotation( direction, Vector3.Up ); + var length = direction.Length() / segmentLength - 1.0f; + + var point = CreatePoint( points, id, position.X, position.Y + segmentYOffset, position.Z, segment ); + point.rotation = rotation * Quaternion.FromEuler( segmentRotation / 180.0f * Mathf.Pi ); + point.scale = Vector3.One + length * scaleAxis; + + id = point.creatorID + 1; + } + return points; } - ScatterPoint CreatePoint( List points, int id, float x, float y, float z ) + ScatterPoint CreatePoint( List points, int id, float x, float y, float z, GeneratorEntry entry ) { var p = new ScatterPoint( this, id ); @@ -101,7 +127,8 @@ namespace Rokojori p.visible = ! setDiscarded; p.seed = Noise.CreateSeed( p.position ); - AssginSceneAndContainer( p ); + p.scene = entry.GetPackedScene(); + p.parent = entry.container; points.Add( p ); diff --git a/Runtime/Rendering/Compositor/CompositorEffects/Rim/RimEffect.cs b/Runtime/Rendering/Compositor/CompositorEffects/Rim/RimEffect.cs new file mode 100644 index 0000000..e2e1245 --- /dev/null +++ b/Runtime/Rendering/Compositor/CompositorEffects/Rim/RimEffect.cs @@ -0,0 +1,82 @@ + +using Godot; +using Godot.Collections; +using System.Collections.Generic; + +namespace Rokojori +{ + [Tool] + [GlobalClass] + public partial class RimEffect:SingleShaderCompositorEffect + { + public static readonly string shaderPath = Path( "Rim/RimShader.glsl" ); + + RDSampler sampler; + + + [Export( PropertyHint.Range, "0,50") ] + public float effectStrength = 1; + + [Export( PropertyHint.Range, "-10,10") ] + public float rimOffsetX = 2f; + + [Export( PropertyHint.Range, "-10,10") ] + public float rimOffsetY = 0f; + + [Export( PropertyHint.Range, "0.0001,1") ] + public float minDepth = 0.001f; + + [Export( PropertyHint.Range, "0.01,500.0") ] + public float depthScale = 1f; + + [Export( PropertyHint.Range, "-10,10.0") ] + public float depthOffset = 1f; + + [Export( PropertyHint.Range, "1,1000") ] + public float contrast = 1f; + + [Export( PropertyHint.Range, "0,1") ] + public float debugView = 0f; + + protected override void OnConfigure() + { + EffectCallbackType = EffectCallbackTypeEnum.PostOpaque; + _shaderPath = shaderPath; + _groupSize = 8; + } + + protected override void OnInitialize() + { + base.OnInitialize(); + + sampler = context.Sampler( RenderingDevice.SamplerFilter.Nearest, RenderingDevice.SamplerRepeatMode.ClampToEdge ); + } + + + + protected override void SetConstants() + { + constants.Set( + (Vector2)context.internalSize, + new Vector2( depthScale, depthOffset ), + effectStrength, + rimOffsetX, + rimOffsetY, + minDepth, + contrast, + debugView + ); + } + + protected override void RenderView() + { + context.AssignScreenColorTexture(); + context.AssignScreenDepthTexture( sampler ); + + context.pushConstants = constants; + + context.ProcessComputeProgram(); + + } + } +} \ No newline at end of file diff --git a/Runtime/Rendering/Compositor/CompositorEffects/Rim/RimEffect.cs.uid b/Runtime/Rendering/Compositor/CompositorEffects/Rim/RimEffect.cs.uid new file mode 100644 index 0000000..8671315 --- /dev/null +++ b/Runtime/Rendering/Compositor/CompositorEffects/Rim/RimEffect.cs.uid @@ -0,0 +1 @@ +uid://bkcgo0ho1x6ju diff --git a/Runtime/Rendering/Compositor/CompositorEffects/Rim/RimShader.glsl b/Runtime/Rendering/Compositor/CompositorEffects/Rim/RimShader.glsl new file mode 100644 index 0000000..870968c --- /dev/null +++ b/Runtime/Rendering/Compositor/CompositorEffects/Rim/RimShader.glsl @@ -0,0 +1,63 @@ +#[compute] +#version 450 + +layout( local_size_x = 8, local_size_y = 8, local_size_z = 1 ) in; + +layout( rgba16f, set = 0, binding = 0 ) +uniform image2D color_image; + +layout( set = 1, binding = 0 ) +uniform sampler2D depth_sampler; + + +layout( push_constant, std430 ) +uniform Params +{ + vec2 rasterSize; + vec2 amounts; + float effectStrength; + float rimOffsetX; + float rimOffsetY; + float minDepth; + float contrastIntensity; + float debugView; + +} params; + +float sampleDepth( vec2 coord ) +{ + coord = clamp( coord, vec2( 0 ), vec2( params.rasterSize ) - vec2( 1.0 ) ); + + vec2 uv = ( vec2( coord ) + 0.5 ) / params.rasterSize; + return texture( depth_sampler, uv ).r; +} + + +void main( ) +{ + ivec2 uv = ivec2( gl_GlobalInvocationID.xy ); + ivec2 size = ivec2( params.rasterSize ); + + if ( uv.x >= size.x || uv.y >= size.y ) + { + return; + } + + + vec2 rimOffset = vec2( params.rimOffsetX, params.rimOffsetY ); + + float depth = sampleDepth( uv ); + float rimDepth = sampleDepth( uv + rimOffset ); + + float rimStrength = min( 1.0, max( 0.0, depth - rimDepth ) * params.contrastIntensity ); + + float amount = 1.0 - min( 1.0, pow( depth * params.amounts.x + params.amounts.y, params.minDepth ) ); + + + vec4 color = imageLoad( color_image, uv ); + float combinedAmount = max( 0.0, min( 1.0, amount * rimStrength * params.effectStrength ) ); + color = mix( color, vec4( 1.0, 1.0, 1.0, 1.0 ), combinedAmount ); + + color = mix( color, vec4( amount, amount, amount, 1.0 ), params.debugView ); + imageStore( color_image, uv, color ); +} \ No newline at end of file diff --git a/Runtime/Rendering/Compositor/CompositorEffects/Rim/RimShader.glsl.import b/Runtime/Rendering/Compositor/CompositorEffects/Rim/RimShader.glsl.import new file mode 100644 index 0000000..ef649e8 --- /dev/null +++ b/Runtime/Rendering/Compositor/CompositorEffects/Rim/RimShader.glsl.import @@ -0,0 +1,14 @@ +[remap] + +importer="glsl" +type="RDShaderFile" +uid="uid://c3ym5825e532r" +path="res://.godot/imported/RimShader.glsl-d18cc4c508ce033a11df2415ffe60f09.res" + +[deps] + +source_file="res://addons/rokojori_action_library/Runtime/Rendering/Compositor/CompositorEffects/Rim/RimShader.glsl" +dest_files=["res://.godot/imported/RimShader.glsl-d18cc4c508ce033a11df2415ffe60f09.res"] + +[params] + diff --git a/Runtime/Rendering/Compositor/CompositorEffects/Vignette/VignetteEffect.cs b/Runtime/Rendering/Compositor/CompositorEffects/Vignette/VignetteEffect.cs index ad12e61..91f1c1e 100644 --- a/Runtime/Rendering/Compositor/CompositorEffects/Vignette/VignetteEffect.cs +++ b/Runtime/Rendering/Compositor/CompositorEffects/Vignette/VignetteEffect.cs @@ -14,7 +14,7 @@ namespace Rokojori [Export( PropertyHint.Range, "0,1")] public float amount = 1.0f; - [Export( PropertyHint.Range, "0.1,2")] + [Export( PropertyHint.Range, "0.01,10")] public float radius = 0.5f; [Export] diff --git a/Runtime/Rendering/Compositor/CompositorEffects/Wipes/CircleWipe/CircleWipeEffect.cs b/Runtime/Rendering/Compositor/CompositorEffects/Wipes/CircleWipe/CircleWipeEffect.cs new file mode 100644 index 0000000..2a1ab5b --- /dev/null +++ b/Runtime/Rendering/Compositor/CompositorEffects/Wipes/CircleWipe/CircleWipeEffect.cs @@ -0,0 +1,39 @@ + +using Godot; +using Godot.Collections; +using System.Collections.Generic; + +namespace Rokojori +{ + [Tool] + [GlobalClass] + public partial class CircleWipeEffect:WipeCompositorEffect + { + public CircleWipeEffect():base() + { + InitializeWipe( new RG_CircleWipe( graph ) ); + } + + [ExportGroup( "Circle" )] + [Export( PropertyHint.Range, "-1,2")] + public float centerX = 0.5f; + + [Export( PropertyHint.Range, "-1,2")] + public float centerY = 0.5f; + + [Export( PropertyHint.Range, "0,0.5")] + public float fade = 0.1f; + + protected override void ForAllViews() + { + SetWipeConstants( + centerX, + centerY, + fade + ); + + } + + + } +} \ No newline at end of file diff --git a/Runtime/Rendering/Compositor/CompositorEffects/Wipes/CircleWipe/CircleWipeEffect.cs.uid b/Runtime/Rendering/Compositor/CompositorEffects/Wipes/CircleWipe/CircleWipeEffect.cs.uid new file mode 100644 index 0000000..c3d926e --- /dev/null +++ b/Runtime/Rendering/Compositor/CompositorEffects/Wipes/CircleWipe/CircleWipeEffect.cs.uid @@ -0,0 +1 @@ +uid://kk0ei1lt88yk diff --git a/Runtime/Rendering/Compositor/CompositorEffects/Wipes/DirectionalWipe/DirectionalWipeEffect.cs b/Runtime/Rendering/Compositor/CompositorEffects/Wipes/DirectionalWipe/DirectionalWipeEffect.cs new file mode 100644 index 0000000..24c54f4 --- /dev/null +++ b/Runtime/Rendering/Compositor/CompositorEffects/Wipes/DirectionalWipe/DirectionalWipeEffect.cs @@ -0,0 +1,45 @@ + +using Godot; +using Godot.Collections; +using System.Collections.Generic; + +namespace Rokojori +{ + [Tool] + [GlobalClass] + public partial class DirectionalWipeEffect:WipeCompositorEffect + { + public DirectionalWipeEffect():base() + { + InitializeWipe( new RG_DirectionalWipe( graph ) ); + } + + [ExportGroup( "Directional" )] + [Export( PropertyHint.Range, "0,360")] + public float angle = 0.0f; + + [Export( PropertyHint.Range, "0,0.5")] + public float fade = 0.1f; + + public enum DirectionType + { + Single, + Double + } + + [Export( PropertyHint.Range, "0,0.5")] + public DirectionType directionType = DirectionType.Single; + + protected override void ForAllViews() + { + SetWipeConstants( + angle, + fade, + directionType == DirectionType.Single ? 0f : 1f + ); + + } + + + } +} \ No newline at end of file diff --git a/Runtime/Rendering/Compositor/CompositorEffects/Wipes/DirectionalWipe/DirectionalWipeEffect.cs.uid b/Runtime/Rendering/Compositor/CompositorEffects/Wipes/DirectionalWipe/DirectionalWipeEffect.cs.uid new file mode 100644 index 0000000..f6ca76e --- /dev/null +++ b/Runtime/Rendering/Compositor/CompositorEffects/Wipes/DirectionalWipe/DirectionalWipeEffect.cs.uid @@ -0,0 +1 @@ +uid://b1711xcqpgqmg diff --git a/Runtime/Rendering/Compositor/CompositorEffects/Wipes/NoiseWipe/NoiseWipeEffect.cs b/Runtime/Rendering/Compositor/CompositorEffects/Wipes/NoiseWipe/NoiseWipeEffect.cs new file mode 100644 index 0000000..bb860e6 --- /dev/null +++ b/Runtime/Rendering/Compositor/CompositorEffects/Wipes/NoiseWipe/NoiseWipeEffect.cs @@ -0,0 +1,45 @@ + +using Godot; +using Godot.Collections; +using System.Collections.Generic; + +namespace Rokojori +{ + [Tool] + [GlobalClass] + public partial class NoiseWipeEffect:WipeCompositorEffect + { + public NoiseWipeEffect():base() + { + InitializeWipe( new RG_NoiseWipe( graph ) ); + } + + [ExportGroup( "Noise" )] + [Export( PropertyHint.Range, "0,1")] + public float noiseAmount = 1.0f; + + [Export( PropertyHint.Range, "0.1,100")] + public float noiseFrequency = 10f; + + [Export] + public Vector2 noisePosition = Vector2.Zero; + + [Export] + public Vector2 noiseWipeOffset = Vector2.Zero; + + protected override void ForAllViews() + { + var noiseOffset = noisePosition + noiseWipeOffset * GetWipeColor().A; + + SetWipeConstants( + noiseAmount, + noiseFrequency, + noiseOffset.X, + noiseOffset.Y + ); + + } + + + } +} \ No newline at end of file diff --git a/Runtime/Rendering/Compositor/CompositorEffects/Wipes/NoiseWipe/NoiseWipeEffect.cs.uid b/Runtime/Rendering/Compositor/CompositorEffects/Wipes/NoiseWipe/NoiseWipeEffect.cs.uid new file mode 100644 index 0000000..e10a74e --- /dev/null +++ b/Runtime/Rendering/Compositor/CompositorEffects/Wipes/NoiseWipe/NoiseWipeEffect.cs.uid @@ -0,0 +1 @@ +uid://bbpmy1vvogfb7 diff --git a/Runtime/Rendering/Compositor/CompositorEffects/Wipes/WipeCompositorEffect.cs b/Runtime/Rendering/Compositor/CompositorEffects/Wipes/WipeCompositorEffect.cs new file mode 100644 index 0000000..882f186 --- /dev/null +++ b/Runtime/Rendering/Compositor/CompositorEffects/Wipes/WipeCompositorEffect.cs @@ -0,0 +1,103 @@ + +using Godot; +using Godot.Collections; +using System.Collections.Generic; + +namespace Rokojori +{ + [Tool] + [GlobalClass] + public abstract partial class WipeCompositorEffect:RDGraphCompositorEffect + { + [ExportGroup("Wipe")] + + [Export(PropertyHint.Range, "0,1")] + public float wipeState = 0f; + + [Export] + public Gradient wipeGradient = new Gradient(); + + [ExportGroup("Blend Mode")] + [Export] + public float replace = 1.0f; + + [Export] + public float add = 0.0f; + + [Export] + public float multiply = 0.0f; + + [Export] + public float colorize = 0.0f; + + [Export] + public bool normalizeBlendWeights = true; + + protected CEG_ImageProcessor wipe; + protected CEG_ScreenColorTexure screenColorTexture; + + + public Color GetWipeColor() + { + var clampedState = MathX.Clamp01( wipeState ); + var color = wipeGradient.Sample( clampedState ); + color.A *= clampedState; + return color; + } + + protected void InitializeWipe( CEG_ImageProcessor wipe ) + { + this.wipe = wipe; + screenColorTexture = new CEG_ScreenColorTexure( graph ); + + graph.InitializeNodes(); + wipe.SetTextureSlotInputs( screenColorTexture, screenColorTexture ); + + graph.SetProcessOrder( + screenColorTexture, + wipe + ); + } + + protected void SetWipeConstants( params object[] wipeConstants ) + { + var blendWeights = GetBlendModeWeights(); + var color = GetWipeColor(); + + wipe.constants.SetOrAdd( true, + + color.R, + color.G, + color.B, + color.A, + + blendWeights.X, + blendWeights.Y, + blendWeights.Z, + blendWeights.W + ); + + wipe.constants.SetOrAdd( false, wipeConstants ); + + } + + public Vector4 GetBlendModeWeights() + { + var blendR = replace; + var blendA = add; + var blendM = multiply; + var blendC = colorize; + + var v = new Vector4( blendR, blendA, blendM, blendC ); + + if ( normalizeBlendWeights ) + { + var sum = blendR + blendA + blendM + blendC; + + v /= sum; + } + + return v; + } + } +} \ No newline at end of file diff --git a/Runtime/Rendering/Compositor/CompositorEffects/Wipes/WipeCompositorEffect.cs.uid b/Runtime/Rendering/Compositor/CompositorEffects/Wipes/WipeCompositorEffect.cs.uid new file mode 100644 index 0000000..2fd63ba --- /dev/null +++ b/Runtime/Rendering/Compositor/CompositorEffects/Wipes/WipeCompositorEffect.cs.uid @@ -0,0 +1 @@ +uid://dij4etvyuohgl diff --git a/Runtime/Rendering/Context/RDContext.cs b/Runtime/Rendering/Context/RDContext.cs index be9ad01..7aaca19 100644 --- a/Runtime/Rendering/Context/RDContext.cs +++ b/Runtime/Rendering/Context/RDContext.cs @@ -170,7 +170,7 @@ namespace Rokojori _uniformSets.Add( uniformSet ); } - public void CreateUniformaSet( params RDUniform[] uniforms ) + public void CreateUniformSet( params RDUniform[] uniforms ) { var setIndex = _uniformSets.Count; _CreateUniformSetRid( setIndex, uniforms ); diff --git a/Runtime/Rendering/Objects/RDPushConstants.cs b/Runtime/Rendering/Objects/RDPushConstants.cs index f2c93c9..44dd497 100644 --- a/Runtime/Rendering/Objects/RDPushConstants.cs +++ b/Runtime/Rendering/Objects/RDPushConstants.cs @@ -41,6 +41,54 @@ namespace Rokojori _bytes = null; } + public void SetOrAdd( bool reset, params object[] objects ) + { + if ( reset ) + { + Reset(); + } + + for ( int i = 0; i < objects.Length; i++ ) + { + if ( objects[ i ] is int ) + { + _AddInt( (int) objects[ i ] ); + } + + else if ( objects[ i ] is float ) + { + _AddFloat( (float) objects[ i ] ); + } + + else if ( objects[ i ] is Vector2 ) + { + _AddVector2( (Vector2) objects[ i ] ); + } + + else if ( objects[ i ] is Vector2I ) + { + _AddVector2( (Vector2I) objects[ i ] ); + } + + else if ( objects[ i ] is Vector3 ) + { + _AddVector3( (Vector3) objects[ i ] ); + } + + else if ( objects[ i ] is Vector3I ) + { + _AddVector3( (Vector3I) objects[ i ] ); + } + + else if ( objects[ i ] is Vector4 ) + { + _AddVector4( (Vector4) objects[ i ] ); + } + } + + + } + public void Set( params object[] objects ) { Reset(); diff --git a/Runtime/Rendering/Objects/RDTexture.cs b/Runtime/Rendering/Objects/RDTexture.cs index e5fd1fe..88108e2 100644 --- a/Runtime/Rendering/Objects/RDTexture.cs +++ b/Runtime/Rendering/Objects/RDTexture.cs @@ -7,6 +7,11 @@ namespace Rokojori { public RDTexture( RDContext context, Rid rid ):base( context, rid ){} + public static RDTexture Create( RDContext context, Texture2D texture ) + { + return new RDTexture( context, texture.GetRid() ); + } + public static RDTexture Create( RDContext effect, RDTextureFormat format, RDTextureView view ) { return new RDTexture( effect, effect.renderingDevice.TextureCreate( format, view ) ); diff --git a/Runtime/Rendering/RenderGraph/Nodes/Processors/Generic/RG_ImageTexture.cs b/Runtime/Rendering/RenderGraph/Nodes/Processors/Generic/RG_ImageTexture.cs new file mode 100644 index 0000000..567b253 --- /dev/null +++ b/Runtime/Rendering/RenderGraph/Nodes/Processors/Generic/RG_ImageTexture.cs @@ -0,0 +1,49 @@ + +using Godot; +using System.Collections.Generic; + +namespace Rokojori +{ + public class RG_ImageTexture:RGGraphProcessor, RDGraphTextureSlotInput + { + RDTexture _texture; + + public RDTexture GetTexture() + { + return _texture; + } + + public RGGraphProcessor GetProcessor() + { + return this; + } + + List _connectedSlots = new List(); + + public void SetConnected( CompositorEffectGraphTextureSlot slot ) + { + _connectedSlots.Add( slot ); + } + + public RG_ImageTexture( RDGraph graph):base( graph ) + { + + } + + public void SetImageTexture( RDTexture texture ) + { + _texture = texture; + } + + public override void Process() + { + + } + + public void ConnectTo( CompositorEffectGraphTextureSlot slot ) + { + slot.SetInput( this ); + } + + } +} \ No newline at end of file diff --git a/Runtime/Rendering/RenderGraph/Nodes/Processors/Generic/RG_ImageTexture.cs.uid b/Runtime/Rendering/RenderGraph/Nodes/Processors/Generic/RG_ImageTexture.cs.uid new file mode 100644 index 0000000..5f5744a --- /dev/null +++ b/Runtime/Rendering/RenderGraph/Nodes/Processors/Generic/RG_ImageTexture.cs.uid @@ -0,0 +1 @@ +uid://vh50asoqrs5 diff --git a/Runtime/Rendering/RenderGraph/Nodes/Processors/Wipes/CircleWipe/CircleWipe.glsl b/Runtime/Rendering/RenderGraph/Nodes/Processors/Wipes/CircleWipe/CircleWipe.glsl new file mode 100644 index 0000000..d4ccbce --- /dev/null +++ b/Runtime/Rendering/RenderGraph/Nodes/Processors/Wipes/CircleWipe/CircleWipe.glsl @@ -0,0 +1,155 @@ +#[compute] +#version 450 + +vec3 colorize( vec3 original, vec3 color ) +{ + float grey = ( original.r + original.g + original.b ) / 3.0; + + return grey < 0.5 ? mix( vec3( 0.0 ), color, grey * 2.0 ) : + mix( color, vec3( 1.0 ), ( grey - 0.5 ) * 2.0 ); +} + +float clamp01( float value ) +{ + return clamp( value, 0.0, 1.0 ); +} + +float normalizeToRange( float value, float min, float max ) +{ + return ( value - min ) / ( max - min ); +} + +float normalizeToRange01( float value, float min, float max ) +{ + return clamp01( normalizeToRange( value, min, max ) ); +} + +float map( float value, float inMin, float inMax, float outMin, float outMax ) +{ + return mix( outMin, outMax, normalizeToRange( value, inMin, inMax ) ); +} + +float mapClamped( float value, float inMin, float inMax, float outMin, float outMax ) +{ + return mix( outMin, outMax, normalizeToRange01( value, inMin, inMax ) ); +} + +vec2 rotate_v2( vec2 uv, float angle ) +{ + float s = sin( angle ); + float c = cos( angle ); + + + float x = uv.x; + float y = uv.y; + + uv.x = c * x - s * y; + uv.y = s * x + c * y; + + return uv; +} + +vec2 rotateAround_v2( vec2 uv, float angle, vec2 pivot ) +{ + uv -= pivot; + uv = rotate_v2( uv, angle ); + uv += pivot; + + return uv; +} + + +layout( local_size_x = 8, local_size_y = 8, local_size_z = 1 ) in; + +layout( rgba16f, set = 0, binding = 0 ) +uniform image2D inputImage; + +layout( rgba16f, set = 1, binding = 0 ) +uniform image2D outputImage; + +// layout( rgba16f, set = 2, binding = 0 ) +// uniform image2D noiseImage; + +layout( push_constant, std430 ) +uniform Parameters +{ + float r; + float g; + float b; + float a; + float replace; + float add; + float multiply; + float colorize; + + float centerX; + float centerY; + float fade; + +} parameters; + +float PI = 3.141592653589793; + + +void main( ) +{ + ivec2 size = imageSize( inputImage ); + ivec2 texel_coord = ivec2( gl_GlobalInvocationID.xy ); + + if ( any( greaterThanEqual( texel_coord, size ) ) ) + { + return; + } + + vec2 uv = ( vec2( texel_coord ) + 0.5 ) / vec2( size ); + + float aspect = float( size.y ) / float( size.x ); + vec2 circleUV = uv; + circleUV.y -= 0.5; + circleUV.y *= aspect; + circleUV.y += 0.5; + + float alpha = 0.0; + vec2 center = vec2( parameters.centerX, parameters.centerY ); + + float d0 = distance( center, vec2(0.0, 0.0) ); + float d1 = distance( center, vec2(1.0, 0.0) ); + float d2 = distance( center, vec2(0.0, 1.0) ); + float d3 = distance( center, vec2(1.0, 1.0) ); + + float max_radius = max( max( d0, d1 ), max( d2, d3 ) ); + + float r = distance( circleUV, center ); + float fadeValue = 1.0 - r / max_radius; + + float fadeStart = parameters.a - parameters.fade * 2.0; + float fadeEnd = parameters.a + parameters.fade * 2.0; + + float minFade = 0 + parameters.fade * 2.0; + float maxFade = 1 - parameters.fade * 2.0; + + fadeValue = mapClamped( fadeValue, 0.0, 1.0, minFade, maxFade ); + + alpha = mapClamped( fadeValue, fadeStart, fadeEnd, 1.0, 0.0 ); + + vec4 color = imageLoad( inputImage, ivec2( uv * size ) ); + vec4 replaced = vec4( parameters.r, parameters.g, parameters.b, 1.0 ); + + vec4 multiplied = replaced * color; + vec4 added = replaced + color; + vec4 colorized = vec4( colorize( color.rgb, replaced.rgb ), 1.0 ); + + + vec4 mixed = replaced * parameters.replace + + added * parameters.add + + multiplied * parameters.multiply + + colorized * parameters.colorize; + + + + + vec4 blended = mix( color, mixed, alpha ); + + + imageStore( outputImage, texel_coord, blended ); +} \ No newline at end of file diff --git a/Runtime/Rendering/RenderGraph/Nodes/Processors/Wipes/CircleWipe/CircleWipe.glsl.import b/Runtime/Rendering/RenderGraph/Nodes/Processors/Wipes/CircleWipe/CircleWipe.glsl.import new file mode 100644 index 0000000..58dbf59 --- /dev/null +++ b/Runtime/Rendering/RenderGraph/Nodes/Processors/Wipes/CircleWipe/CircleWipe.glsl.import @@ -0,0 +1,14 @@ +[remap] + +importer="glsl" +type="RDShaderFile" +uid="uid://le4523acrrbb" +path="res://.godot/imported/CircleWipe.glsl-88a11984505e55894f404dcf7e1fddf2.res" + +[deps] + +source_file="res://addons/rokojori_action_library/Runtime/Rendering/RenderGraph/Nodes/Processors/Wipes/CircleWipe/CircleWipe.glsl" +dest_files=["res://.godot/imported/CircleWipe.glsl-88a11984505e55894f404dcf7e1fddf2.res"] + +[params] + diff --git a/Runtime/Rendering/RenderGraph/Nodes/Processors/Wipes/CircleWipe/RG_CircleWipe.cs b/Runtime/Rendering/RenderGraph/Nodes/Processors/Wipes/CircleWipe/RG_CircleWipe.cs new file mode 100644 index 0000000..6124caf --- /dev/null +++ b/Runtime/Rendering/RenderGraph/Nodes/Processors/Wipes/CircleWipe/RG_CircleWipe.cs @@ -0,0 +1,16 @@ + +using Godot; +using System.Collections.Generic; + +namespace Rokojori +{ + public class RG_CircleWipe:CEG_ImageProcessor + { + public static readonly string shaderPath = + RDGraph.Path( "Nodes/Processors/Wipes/CircleWipe/CircleWipe.glsl" ); + + public RG_CircleWipe( RDGraph graph ):base( graph, shaderPath ) + {} + + } +} \ No newline at end of file diff --git a/Runtime/Rendering/RenderGraph/Nodes/Processors/Wipes/CircleWipe/RG_CircleWipe.cs.uid b/Runtime/Rendering/RenderGraph/Nodes/Processors/Wipes/CircleWipe/RG_CircleWipe.cs.uid new file mode 100644 index 0000000..da9ad42 --- /dev/null +++ b/Runtime/Rendering/RenderGraph/Nodes/Processors/Wipes/CircleWipe/RG_CircleWipe.cs.uid @@ -0,0 +1 @@ +uid://cn0byh5xg0l10 diff --git a/Runtime/Rendering/RenderGraph/Nodes/Processors/Wipes/DirectionalWipe/DirectionalWipe.glsl b/Runtime/Rendering/RenderGraph/Nodes/Processors/Wipes/DirectionalWipe/DirectionalWipe.glsl new file mode 100644 index 0000000..b700881 --- /dev/null +++ b/Runtime/Rendering/RenderGraph/Nodes/Processors/Wipes/DirectionalWipe/DirectionalWipe.glsl @@ -0,0 +1,177 @@ +#[compute] +#version 450 + +vec3 colorize( vec3 original, vec3 color ) +{ + float grey = ( original.r + original.g + original.b ) / 3.0; + + return grey < 0.5 ? mix( vec3( 0.0 ), color, grey * 2.0 ) : + mix( color, vec3( 1.0 ), ( grey - 0.5 ) * 2.0 ); +} + +float clamp01( float value ) +{ + return clamp( value, 0.0, 1.0 ); +} + +float normalizeToRange( float value, float min, float max ) +{ + return ( value - min ) / ( max - min ); +} + +float normalizeToRange01( float value, float min, float max ) +{ + return clamp01( normalizeToRange( value, min, max ) ); +} + +float map( float value, float inMin, float inMax, float outMin, float outMax ) +{ + return mix( outMin, outMax, normalizeToRange( value, inMin, inMax ) ); +} + +float mapClamped( float value, float inMin, float inMax, float outMin, float outMax ) +{ + return mix( outMin, outMax, normalizeToRange01( value, inMin, inMax ) ); +} + +vec2 rotate_v2( vec2 uv, float angle ) +{ + float s = sin( angle ); + float c = cos( angle ); + + + float x = uv.x; + float y = uv.y; + + uv.x = c * x - s * y; + uv.y = s * x + c * y; + + return uv; +} + +vec2 rotateAround_v2( vec2 uv, float angle, vec2 pivot ) +{ + uv -= pivot; + uv = rotate_v2( uv, angle ); + uv += pivot; + + return uv; +} + + +layout( local_size_x = 8, local_size_y = 8, local_size_z = 1 ) in; + +layout( rgba16f, set = 0, binding = 0 ) +uniform image2D inputImage; + +layout( rgba16f, set = 1, binding = 0 ) +uniform image2D outputImage; + +// layout( rgba16f, set = 2, binding = 0 ) +// uniform image2D noiseImage; + +layout( push_constant, std430 ) +uniform Parameters +{ + float r; + float g; + float b; + float a; + float replace; + float add; + float multiply; + float colorize; + + float angle; + float fade; + float doubleSided; + +} parameters; + +float PI = 3.141592653589793; + +float computeFadeValue( vec2 uv, float angle ) +{ + float minFade = 0 + parameters.fade; + float maxFade = 1 - parameters.fade; + + float angle_rad = angle * PI / 180.0; + vec2 dir = vec2( cos( angle_rad), sin( angle_rad ) ); + + float proj = dot( uv - vec2(0.0), dir); + + float p0 = dot( vec2( 0.0, 0.0 ), dir ); + float p1 = dot( vec2( 1.0, 0.0 ), dir ); + float p2 = dot( vec2( 0.0, 1.0 ), dir ); + float p3 = dot( vec2( 1.0, 1.0 ), dir ); + + float min_p = min( min( p0, p1 ), min( p2, p3) ); + float max_p = max( max( p0, p1 ), max( p2, p3) ); + + float fadeValue = ( proj - min_p ) / ( max_p - min_p ); + + fadeValue = mapClamped( fadeValue, 0.0, 1.0, minFade, maxFade ); + + return fadeValue; +} + +void main( ) +{ + ivec2 size = imageSize( inputImage ); + ivec2 texel_coord = ivec2( gl_GlobalInvocationID.xy ); + + if ( any( greaterThanEqual( texel_coord, size ) ) ) + { + return; + } + + vec2 uv = ( vec2( texel_coord ) + 0.5 ) / vec2( size ); + + float alpha = 0.0; + + if ( parameters.doubleSided > 0.5 ) + { + float fadeValueA = computeFadeValue( uv, parameters.angle ); + float fadeValueB = computeFadeValue( uv, parameters.angle + 180.0 ); + + float fadeRange = 0.5 + parameters.fade; + float fadeStart = parameters.a * fadeRange - parameters.fade * 0.5; + float fadeEnd = parameters.a * fadeRange + parameters.fade * 0.5;; + + float alphaA = mapClamped( fadeValueA, fadeStart, fadeEnd, 1.0, 0.0 ); + float alphaB = mapClamped( fadeValueB, fadeStart, fadeEnd, 1.0, 0.0 ); + + alpha = max( alphaA, alphaB ); + } + else + { + float fadeValue = computeFadeValue( uv, parameters.angle ); + + float fadeStart = parameters.a - parameters.fade; + float fadeEnd = parameters.a + parameters.fade; + + alpha = mapClamped( fadeValue, fadeStart, fadeEnd, 1.0, 0.0 ); + } + + + vec4 color = imageLoad( inputImage, ivec2( uv * size ) ); + vec4 replaced = vec4( parameters.r, parameters.g, parameters.b, 1.0 ); + + vec4 multiplied = replaced * color; + vec4 added = replaced + color; + vec4 colorized = vec4( colorize( color.rgb, replaced.rgb ), 1.0 ); + + + vec4 mixed = replaced * parameters.replace + + added * parameters.add + + multiplied * parameters.multiply + + colorized * parameters.colorize; + + + + + vec4 blended = mix( color, mixed, alpha ); + + + imageStore( outputImage, texel_coord, blended ); +} \ No newline at end of file diff --git a/Runtime/Rendering/RenderGraph/Nodes/Processors/Wipes/DirectionalWipe/DirectionalWipe.glsl.import b/Runtime/Rendering/RenderGraph/Nodes/Processors/Wipes/DirectionalWipe/DirectionalWipe.glsl.import new file mode 100644 index 0000000..3430aa7 --- /dev/null +++ b/Runtime/Rendering/RenderGraph/Nodes/Processors/Wipes/DirectionalWipe/DirectionalWipe.glsl.import @@ -0,0 +1,14 @@ +[remap] + +importer="glsl" +type="RDShaderFile" +uid="uid://dma2fa4c6pefu" +path="res://.godot/imported/DirectionalWipe.glsl-03e39acf237e443b2fa0e1319e7346a9.res" + +[deps] + +source_file="res://addons/rokojori_action_library/Runtime/Rendering/RenderGraph/Nodes/Processors/Wipes/DirectionalWipe/DirectionalWipe.glsl" +dest_files=["res://.godot/imported/DirectionalWipe.glsl-03e39acf237e443b2fa0e1319e7346a9.res"] + +[params] + diff --git a/Runtime/Rendering/RenderGraph/Nodes/Processors/Wipes/DirectionalWipe/RG_DirectionalWipe.cs b/Runtime/Rendering/RenderGraph/Nodes/Processors/Wipes/DirectionalWipe/RG_DirectionalWipe.cs new file mode 100644 index 0000000..f16dd25 --- /dev/null +++ b/Runtime/Rendering/RenderGraph/Nodes/Processors/Wipes/DirectionalWipe/RG_DirectionalWipe.cs @@ -0,0 +1,29 @@ + +using Godot; +using System.Collections.Generic; + +namespace Rokojori +{ + public class RG_DirectionalWipe:CEG_ImageProcessor + { + + public static readonly string shaderPath = + RDGraph.Path( "Nodes/Processors/Wipes/DirectionalWipe/DirectionalWipe.glsl" ); + + public RG_DirectionalWipe( RDGraph graph ):base( graph, shaderPath ) + { + + } + + // public readonly CompositorEffectGraphTextureSlot noise; + + // public RG_Tint( RDGraph graph ):base( graph, shaderPath ) + // { + // noise = new CompositorEffectGraphTextureSlot( this ); + + // _textureSlots.Add( noise ); + // } + + + } +} \ No newline at end of file diff --git a/Runtime/Rendering/RenderGraph/Nodes/Processors/Wipes/DirectionalWipe/RG_DirectionalWipe.cs.uid b/Runtime/Rendering/RenderGraph/Nodes/Processors/Wipes/DirectionalWipe/RG_DirectionalWipe.cs.uid new file mode 100644 index 0000000..111aeb2 --- /dev/null +++ b/Runtime/Rendering/RenderGraph/Nodes/Processors/Wipes/DirectionalWipe/RG_DirectionalWipe.cs.uid @@ -0,0 +1 @@ +uid://bsfj7367hqqos diff --git a/Runtime/Rendering/RenderGraph/Nodes/Processors/Wipes/NoiseWipe/NoiseWipe.glsl b/Runtime/Rendering/RenderGraph/Nodes/Processors/Wipes/NoiseWipe/NoiseWipe.glsl new file mode 100644 index 0000000..0a71a73 --- /dev/null +++ b/Runtime/Rendering/RenderGraph/Nodes/Processors/Wipes/NoiseWipe/NoiseWipe.glsl @@ -0,0 +1,228 @@ +#[compute] +#version 450 + +vec3 colorize( vec3 original, vec3 color ) +{ + float grey = ( original.r + original.g + original.b ) / 3.0; + + return grey < 0.5 ? mix( vec3( 0.0 ), color, grey * 2.0 ) : + mix( color, vec3( 1.0 ), ( grey - 0.5 ) * 2.0 ); +} + +float clamp01( float value ) +{ + return clamp( value, 0.0, 1.0 ); +} + +float normalizeToRange( float value, float min, float max ) +{ + return ( value - min ) / ( max - min ); +} + +float normalizeToRange01( float value, float min, float max ) +{ + return clamp01( normalizeToRange( value, min, max ) ); +} + +float map( float value, float inMin, float inMax, float outMin, float outMax ) +{ + return mix( outMin, outMax, normalizeToRange( value, inMin, inMax ) ); +} + +float mapClamped( float value, float inMin, float inMax, float outMin, float outMax ) +{ + return mix( outMin, outMax, normalizeToRange01( value, inMin, inMax ) ); +} + + + + +float random( vec2 uv ) +{ + return fract( sin( dot( uv.xy, vec2( 12.9898, 78.233 ) ) ) * 43758.5453123 ); +} + +vec2 random_v2( vec2 uv ) +{ + uv = vec2 + ( + dot(uv, vec2( 127.1,311.7 ) ), + dot(uv, vec2( 269.5,183.3 ) ) + ); + + return -1.0 + 2.0 * fract( sin( uv ) * 43758.5453123 ); +} + + +vec3 random_v3( vec3 uvw ) +{ + + uvw = vec3( dot(uvw, vec3(127.1,311.7, 513.7) ), + dot(uvw, vec3(269.5,183.3, 396.5) ), + dot(uvw, vec3(421.3,314.1, 119.7) ) ); + + return -1.0 + 2.0 * fract(sin(uvw) * 43758.5453123); +} + +float perlin(vec2 uv) +{ + vec2 uv_index = floor(uv); + vec2 uv_fract = fract(uv); + + vec2 blur = smoothstep(0.0, 1.0, uv_fract); + + return mix( mix( dot( random_v2(uv_index + vec2(0.0,0.0) ), uv_fract - vec2(0.0,0.0) ), + dot( random_v2(uv_index + vec2(1.0,0.0) ), uv_fract - vec2(1.0,0.0) ), blur.x), + mix( dot( random_v2(uv_index + vec2(0.0,1.0) ), uv_fract - vec2(0.0,1.0) ), + dot( random_v2(uv_index + vec2(1.0,1.0) ), uv_fract - vec2(1.0,1.0) ), blur.x), blur.y) + 0.5; +} + +float perlinOctaves( vec2 uv, int octaves, float scale, float gain ) +{ + float s = 1.0; + float g = 1.0; + + float v = perlin( uv * s ) * g; + float n = 1.0; + + for ( int i = 0; i < octaves; i++ ) + { + s *= scale; + g *= gain; + + v += perlin( uv * s ) * g; + n += g; + } + + return v / n; +} + +vec2 seamLessCoordinate( vec2 uv, vec2 seamRange, vec2 seamFade, vec2 type ) +{ + return mod( uv - seamFade * type, seamRange ); +} + +float perlinOctavesSeamless( vec2 uv, int octaves, float scale, float gain, vec2 seamRange, vec2 seamFade ) +{ + // uv = mod( uv , seamRange ); + seamFade *= seamRange; + vec2 fading = mod( uv, seamRange ) ; + fading.x = normalizeToRange01( fading.x, seamRange.x - seamFade.x, seamRange.x ); + fading.y = normalizeToRange01( fading.y, seamRange.y - seamFade.y, seamRange.y ); + + + // 0, seamRange - seamFade, seamRange + // + + vec2 p00 = seamLessCoordinate( uv, seamRange, seamFade, vec2( 0.0, 0.0 ) ); + vec2 p10 = seamLessCoordinate( uv, seamRange, seamFade, vec2( 1.0, 0.0 ) ); + vec2 p01 = seamLessCoordinate( uv, seamRange, seamFade, vec2( 0.0, 1.0 ) ); + vec2 p11 = seamLessCoordinate( uv, seamRange, seamFade, vec2( 1.0, 1.0 ) ); + + float n00 = perlinOctaves( p00, octaves, scale, gain ); + float n10 = perlinOctaves( p10, octaves, scale, gain ); + float n01 = perlinOctaves( p01, octaves, scale, gain ); + float n11 = perlinOctaves( p11, octaves, scale, gain ); + + float n0 = mix( n00, n10, fading.x ); + float n1 = mix( n01, n11, fading.x ); + + return mix( n0, n1, fading.y ); +} + + + +layout( local_size_x = 8, local_size_y = 8, local_size_z = 1 ) in; + +layout( rgba16f, set = 0, binding = 0 ) +uniform image2D inputImage; + +layout( rgba16f, set = 1, binding = 0 ) +uniform image2D outputImage; + +// layout( rgba16f, set = 2, binding = 0 ) +// uniform image2D noiseImage; + +layout( push_constant, std430 ) +uniform Parameters +{ + float r; + float g; + float b; + float a; + float replace; + float add; + float multiply; + float colorize; + + float noiseAmount; + float noiseScale; + float noiseX; + float noiseY; + +} parameters; + +void main( ) +{ + ivec2 size = imageSize( inputImage ); + ivec2 texel_coord = ivec2( gl_GlobalInvocationID.xy ); + + if ( any( greaterThanEqual( texel_coord, size ) ) ) + { + return; + } + + vec2 uv = ( vec2( texel_coord ) + 0.5 ) / vec2( size ); + int noiseOctaves = 3; + float noiseScale = 0.5; + float noiseGain = 0.5; + float range = 100.0; + float fade = 20.0; + + vec2 ratio = vec2( size ) / min( size.x, size.y ); + + + // float noise = perlinOctavesSeamless( + // uv * parameters.noiseScale * ratio + vec2( parameters.noiseX, parameters.noiseY ), + // noiseOctaves, noiseScale, noiseGain, + // vec2( range ), vec2( fade ) + // ); + + float noise = perlin( uv * parameters.noiseScale * ratio + vec2( parameters.noiseX, parameters.noiseY ) ); + // float noise = imageLoad( inputImage, ivec2( uv * imageSize( noiseImage ) ) ).r; + + vec4 color = imageLoad( inputImage, ivec2( uv * size ) ); + vec4 replaced = vec4( parameters.r, parameters.g, parameters.b, 1.0 ); + + + vec4 multiplied = replaced * color; + vec4 added = replaced + color; + vec4 colorized = vec4( colorize( color.rgb, replaced.rgb ), 1.0 ); + + + vec4 mixed = replaced * parameters.replace + + added * parameters.add + + multiplied * parameters.multiply + + colorized * parameters.colorize; + + float noiseAmount = parameters.noiseAmount; + + + + float noiseAlpha = 1.0 - smoothstep( parameters.a - 0.05, parameters.a + 0.05, noise ); + + float edgeFade = 0.1; + float startMix = mapClamped( parameters.a, 0.0, edgeFade, 1.0, 0.0 ); + float endMix = mapClamped( parameters.a, 1.0 - edgeFade, 1.0, 0.0, 1.0 ); + + noiseAlpha = mix( noiseAlpha, 0.0, startMix ); + noiseAlpha = mix( noiseAlpha, 1.0, endMix ); + + float alpha = mix( parameters.a, noiseAlpha, parameters.noiseAmount ); + + vec4 blended = mix( color, mixed, alpha ); + // blended = clamp( blended, vec4( 0.0, 0.0, 0.0, 1.0 ), vec4( 1.0 ) ); + + + imageStore( outputImage, texel_coord, blended ); +} \ No newline at end of file diff --git a/Runtime/Rendering/RenderGraph/Nodes/Processors/Wipes/NoiseWipe/NoiseWipe.glsl.import b/Runtime/Rendering/RenderGraph/Nodes/Processors/Wipes/NoiseWipe/NoiseWipe.glsl.import new file mode 100644 index 0000000..1b2883c --- /dev/null +++ b/Runtime/Rendering/RenderGraph/Nodes/Processors/Wipes/NoiseWipe/NoiseWipe.glsl.import @@ -0,0 +1,14 @@ +[remap] + +importer="glsl" +type="RDShaderFile" +uid="uid://wbss1kmoouyu" +path="res://.godot/imported/NoiseWipe.glsl-d8dc0d0d292cf07317c042ebe2eef4f3.res" + +[deps] + +source_file="res://addons/rokojori_action_library/Runtime/Rendering/RenderGraph/Nodes/Processors/Wipes/NoiseWipe/NoiseWipe.glsl" +dest_files=["res://.godot/imported/NoiseWipe.glsl-d8dc0d0d292cf07317c042ebe2eef4f3.res"] + +[params] + diff --git a/Runtime/Rendering/RenderGraph/Nodes/Processors/Wipes/NoiseWipe/RG_NoiseWipe.cs b/Runtime/Rendering/RenderGraph/Nodes/Processors/Wipes/NoiseWipe/RG_NoiseWipe.cs new file mode 100644 index 0000000..7fbeb5f --- /dev/null +++ b/Runtime/Rendering/RenderGraph/Nodes/Processors/Wipes/NoiseWipe/RG_NoiseWipe.cs @@ -0,0 +1,16 @@ + +using Godot; +using System.Collections.Generic; + +namespace Rokojori +{ + public class RG_NoiseWipe:CEG_ImageProcessor + { + public static readonly string shaderPath = + RDGraph.Path( "Nodes/Processors/Wipes/NoiseWipe/NoiseWipe.glsl" ); + + public RG_NoiseWipe( RDGraph graph ):base( graph, shaderPath ) + {} + + } +} \ No newline at end of file diff --git a/Runtime/Rendering/RenderGraph/Nodes/Processors/Wipes/NoiseWipe/RG_NoiseWipe.cs.uid b/Runtime/Rendering/RenderGraph/Nodes/Processors/Wipes/NoiseWipe/RG_NoiseWipe.cs.uid new file mode 100644 index 0000000..98930e3 --- /dev/null +++ b/Runtime/Rendering/RenderGraph/Nodes/Processors/Wipes/NoiseWipe/RG_NoiseWipe.cs.uid @@ -0,0 +1 @@ +uid://cwc1hyt1r0n55 diff --git a/Runtime/Rendering/RenderGraph/RDShaderProcessor.cs b/Runtime/Rendering/RenderGraph/RDShaderProcessor.cs index 0181ab5..8cbf7c7 100644 --- a/Runtime/Rendering/RenderGraph/RDShaderProcessor.cs +++ b/Runtime/Rendering/RenderGraph/RDShaderProcessor.cs @@ -55,7 +55,9 @@ namespace Rokojori } graph.context.Verbose( GetType().Name, "Created shader at path: ", _shaderPath ); - } + } + + public bool debugging = false; public override void Process() { @@ -69,10 +71,17 @@ namespace Rokojori int index = 0; + // if ( debugging ) + // { + // RJLog.Log( this.GetType().Name, "Num Texture Slots:", _textureSlots.Count ); + // } + _textureSlots.ForEach( t => { index++; + + t.ResolveTexture(); var texture = t.GetTexture(); @@ -92,6 +101,8 @@ namespace Rokojori } graph.context.AssignTexture( texture, t.sampler ); + + } ); diff --git a/Runtime/Rendering/RenderingManager.cs b/Runtime/Rendering/RenderingManager.cs index 35d8ade..39f46b6 100644 --- a/Runtime/Rendering/RenderingManager.cs +++ b/Runtime/Rendering/RenderingManager.cs @@ -27,16 +27,54 @@ namespace Rokojori for ( int i = 0; i < data.numGlobalShaderProperties; i++ ) { var p = data.GetGlobalShaderPropertyAt( i ); + + this.LogInfo( "Prop:", i ); + if ( p == null ) { continue; - } + } + + this.LogInfo( i, ">>", p.GetPropertyName().propertyName ); p.AddAsGlobalUniform(); } } + + public T GetShaderPropertyByName( ShaderPropertyName name ) where T:ShaderProperty + { + if ( data == null ) + { + return null; + } + + if ( data.globalShaderPropertyBlocks != null ) + { + foreach ( var b in data.globalShaderPropertyBlocks ) + { + var p = GetShaderPropertyByName( b.shaderProperties, name ); + + if ( p != null ) + { + return p as T; + } + } + } + + return GetShaderPropertyByName( data.globalShaderProperties, name ) as T; + } + + public ShaderProperty GetShaderPropertyByName( ShaderProperty[] properties, ShaderPropertyName name ) + { + if ( properties == null ) + { + return null; + } + + return properties.Find( p => p.GetPropertyName().propertyName == name.propertyName ); + } [Export] diff --git a/Runtime/Selectors/Selectable.cs b/Runtime/Selectors/Selectable.cs index d2954ae..be91050 100644 --- a/Runtime/Selectors/Selectable.cs +++ b/Runtime/Selectors/Selectable.cs @@ -14,7 +14,7 @@ namespace Rokojori { [Export] public SelectorFlag[] flags; - + } } \ No newline at end of file diff --git a/Runtime/Sensors/SensorManager.cs b/Runtime/Sensors/SensorManager.cs index adf6bf3..4763ae2 100644 --- a/Runtime/Sensors/SensorManager.cs +++ b/Runtime/Sensors/SensorManager.cs @@ -138,7 +138,7 @@ namespace Rokojori hasDevice = true; - // this.LogInfo( "Device Type Change:", lastActiveDevice.GetInfo() ); + this.LogInfo( "Device Type Change:", lastActiveDevice.GetInfo() ); if ( confineMouse && DefaultSensorDeviceSelector.IsMouseDevice( lastActiveDevice ) ) { diff --git a/Runtime/Shading/Generators/Generic/ShaderGenerationModule.cs b/Runtime/Shading/Generators/Generic/ShaderGenerationModule.cs index 93f69f7..a35a69a 100644 --- a/Runtime/Shading/Generators/Generic/ShaderGenerationModule.cs +++ b/Runtime/Shading/Generators/Generic/ShaderGenerationModule.cs @@ -183,7 +183,7 @@ namespace Rokojori group_uniforms; "; - return Lists.From( ToCode( codeBefore.Indent("") ), code, ToCode( codeAfter.Indent("") ) ); + return Lists.FromLists( ToCode( codeBefore.Indent("") ), code, ToCode( codeAfter.Indent("") ) ); } public List StartUniformGroup( string name ) diff --git a/Runtime/Shading/Library/Wind.gdshaderinc b/Runtime/Shading/Library/Wind.gdshaderinc index 77ae6e1..4623386 100644 --- a/Runtime/Shading/Library/Wind.gdshaderinc +++ b/Runtime/Shading/Library/Wind.gdshaderinc @@ -5,7 +5,6 @@ /* -uniform bool windEnabled = false; uniform float windOcclusionAmount = 0; uniform float windStrength = 0; uniform vec2 windSpeed = vec2(1,1); @@ -79,17 +78,123 @@ void applyWind( } +/* + +// [ WIND ] +group_uniforms wind; + +// Texture for close wind: grass/foliage +global uniform sampler2D rj_GlobalWindNoiseTextureClose; + +// Texture for far wind: trees +global uniform sampler2D rj_GlobalWindNoiseTextureFar; + +// Windposition close +global uniform vec2 rj_GlobalWindPositionClose; + +// Windposition far +global uniform vec2 rj_GlobalWindPositionFar; + +// Wind direction for both +global uniform vec2 rj_GlobalWindDirection; + +// Wind speed for both +global uniform float rj_GlobalWindSpeed; + +// Weights for x: close and y: far +uniform vec2 windWeights = vec2( 0.5, 0.5 ); + +// Scales the world-vertex based variance +uniform float windSeedSize = 1.0; + +// Max xz bending +uniform float windMaxStrength = 0.2; + +// Max yaw rotation +uniform float windMaxRotation = 0.1; + +// Linear/Inv-Quadratic mapping for the strength +uniform float windStrengthCurve:hint_range( 0.0, 1.0 ); + +// Influence start in local Y +uniform float windStart = 0.1; + +// Influence max in local Y +uniform float windEnd = 2.0; + +// Influence mapping over local Y +uniform float windWeightCurve:hint_range( 0.0,1.0 ) = 0.5; + +// Ducking in y for amount, strong wind => vertices lower +uniform float windHeightCompensation; + +// Normal incluence +uniform float windNormalBending; + +// AO influence +uniform float windOcclusionAmount; +varying float vertexWindAO; + +// + +---------- +== vertex() +{ + + // WIND + + float windAO = 0.0; + applyGlobalWind( + MODEL_MATRIX, + VERTEX, + NORMAL, + windAO, + windOcclusionAmount, + rj_GlobalWindNoiseTextureClose, + rj_GlobalWindNoiseTextureFar, + rj_GlobalWindPositionClose, + rj_GlobalWindPositionFar, + rj_GlobalWindDirection, + rj_GlobalWindSpeed, + windWeights, + windSeedSize, + windMaxStrength, + windMaxRotation, + windStrengthCurve, + windStart, + windEnd, + windWeightCurve, + windHeightCompensation, + windNormalBending + ); + + vertexWindAO = windAO; + +} + +---------- +== fragment() +{ + AO *= vertexWindAO; +} + +*/ + void applyGlobalWind( mat4 _MODEL_MATRIX, inout vec3 _VERTEX, inout vec3 _NORMAL, inout float _vertexWindAO, float _windOcclusionAmount, - sampler2D _globalWindNoiseTexture, - vec2 _globalWindPosition, + sampler2D _globalWindNoiseTextureClose, + sampler2D _globalWindNoiseTextureFar, + vec2 _globalWindPositionClose, + vec2 _globalWindPositionFar, vec2 _globalWindDirection, float _globalWindSpeed, - float _windMaxStrength, + vec2 _windWeights, + float _windSeedSize, + float _windMaxStrength, float _windMaxRotation, float _windStrengthCurve, float _windStart, @@ -100,7 +205,11 @@ void applyGlobalWind( ) { float _windForceState = ( _globalWindSpeed / 100.0 ); - _windForceState = mix( _windForceState, _windForceState / _windForceState, _windStrengthCurve *_windForceState ); + + if ( _windForceState != 0.0 ) + { + _windForceState = mix( _windForceState, _windForceState / _windForceState, _windStrengthCurve *_windForceState ); + } float _windStrength = _windMaxStrength * _windForceState; float _windAmount = normalizeToRange01( _VERTEX.y, _windStart, _windEnd ); @@ -109,10 +218,16 @@ void applyGlobalWind( _windAmount = mix( _windAmount, _windAmount * _windAmount, _windWeightCurve ); vec3 worldVertex = localToWorld( _VERTEX, _MODEL_MATRIX ); - vec4 windRGB = texture( _globalWindNoiseTexture, fract(_globalWindPosition + worldVertex.xz) ); - float generalStrength = windRGB.r; + vec2 seedSizeClose = vec2( textureSize( _globalWindNoiseTextureClose, 0 ) ) * _windSeedSize; + vec2 seedSizeFar = vec2( textureSize( _globalWindNoiseTextureFar, 0 ) ) * _windSeedSize; + vec4 windRGBClose = texture( _globalWindNoiseTextureClose, fract( _globalWindPositionClose + worldVertex.xz / seedSizeClose ) ); + vec4 windRGBFar = texture( _globalWindNoiseTextureFar, fract( _globalWindPositionFar + worldVertex.xz / seedSizeFar ) ); + float generalStrength = windRGBClose.r * _windWeights.x + windRGBFar.r * _windWeights.y; + + float angleAmount = windRGBClose.g * _windWeights.x + windRGBFar.g * _windWeights.y; + float strength = generalStrength * _windStrength; - float angle = ( windRGB.g * 2.0 - 1.0 ) * PI * _windMaxRotation * _windForceState; + float angle = ( angleAmount * 2.0 - 1.0 ) * PI * _windMaxRotation * _windForceState; vec2 direction = normalize( _globalWindDirection ); direction = normalize( rotate_v2( direction, angle ) ); direction *= strength; diff --git a/Runtime/Shading/Properties/Properties/SetGlobalVector3PropertyFromNode.cs b/Runtime/Shading/Properties/Properties/SetGlobalVector3PropertyFromNode.cs new file mode 100644 index 0000000..1f12ba6 --- /dev/null +++ b/Runtime/Shading/Properties/Properties/SetGlobalVector3PropertyFromNode.cs @@ -0,0 +1,53 @@ +using Godot; +using System.Reflection; +using System.Collections.Generic; + +namespace Rokojori +{ + [Tool] + [GlobalClass] + public partial class SetGlobalVector3PropertyFromNode:Action + { + [Export] + public Node3D node3D; + + [Export] + public bool global; + + [Export] + public Vector3PropertyName name; + + [Export] + public Smoothing smoothing; + + [Export] + public TimeLine timeLine; + + [Export] + public Node3D debug; + + protected override void _OnTrigger() + { + var rm = Unique.Get(); + var p = rm.GetShaderPropertyByName( name ); + + if ( p == null ) + { + return; + } + + var tl = TimeLineManager.Ensure( timeLine ); + var position = Smoothing.Apply( smoothing, node3D.GetPosition( global ), tl.delta ); + + if ( debug != null ) + { + debug.GlobalPosition = position; + } + + p.value = position; + + } + + + } +} \ No newline at end of file diff --git a/Runtime/Shading/Properties/Properties/SetGlobalVector3PropertyFromNode.cs.uid b/Runtime/Shading/Properties/Properties/SetGlobalVector3PropertyFromNode.cs.uid new file mode 100644 index 0000000..ff0513c --- /dev/null +++ b/Runtime/Shading/Properties/Properties/SetGlobalVector3PropertyFromNode.cs.uid @@ -0,0 +1 @@ +uid://3e3n1jav7rh2 diff --git a/Runtime/Shading/Properties/Properties/SetVector3PropertyFromNode.cs b/Runtime/Shading/Properties/Properties/SetVector3PropertyFromNode.cs index 6707695..075388f 100644 --- a/Runtime/Shading/Properties/Properties/SetVector3PropertyFromNode.cs +++ b/Runtime/Shading/Properties/Properties/SetVector3PropertyFromNode.cs @@ -20,7 +20,6 @@ namespace Rokojori [Export] public Material material; - protected override void _OnTrigger() { name.Set( material, node3D.GetPosition( global ) ); diff --git a/Runtime/Shading/Shaders/Flares/EllipseFlare/EllipseFlareAdd.gdshader b/Runtime/Shading/Shaders/Flares/EllipseFlare/EllipseFlareAdd.gdshader new file mode 100644 index 0000000..fb61f29 --- /dev/null +++ b/Runtime/Shading/Shaders/Flares/EllipseFlare/EllipseFlareAdd.gdshader @@ -0,0 +1,4 @@ +shader_type spatial; +render_mode blend_add, depth_test_disabled, cull_disabled, unshaded, fog_disabled; + +#include "res://addons/rokojori_action_library/Runtime/Shading/Shaders/Flares/EllipseFlare/EllipseFlareBase.gdshaderinc" \ No newline at end of file diff --git a/Runtime/Shading/Shaders/Flares/EllipseFlare/EllipseFlareAdd.gdshader.uid b/Runtime/Shading/Shaders/Flares/EllipseFlare/EllipseFlareAdd.gdshader.uid new file mode 100644 index 0000000..b0a4480 --- /dev/null +++ b/Runtime/Shading/Shaders/Flares/EllipseFlare/EllipseFlareAdd.gdshader.uid @@ -0,0 +1 @@ +uid://d05sj7il0tvf diff --git a/Runtime/Shading/Shaders/Flares/EllipseFlare/EllipseFlareBase.gdshaderinc b/Runtime/Shading/Shaders/Flares/EllipseFlare/EllipseFlareBase.gdshaderinc new file mode 100644 index 0000000..025bb2e --- /dev/null +++ b/Runtime/Shading/Shaders/Flares/EllipseFlare/EllipseFlareBase.gdshaderinc @@ -0,0 +1,155 @@ + +#include "res://addons/rokojori_action_library/Runtime/Shading/Library/Colors.gdshaderinc" +#include "res://addons/rokojori_action_library/Runtime/Shading/Library/Math.gdshaderinc" +#include "res://addons/rokojori_action_library/Runtime/Shading/Library/Transform.gdshaderinc" +#include "res://addons/rokojori_action_library/Runtime/Shading/Library/Depth.gdshaderinc" + +uniform sampler2D depthTexture:hint_depth_texture; +uniform vec4 color : source_color = vec4( 0.887, 0.434, 0.233, 1.0 ); +uniform float alphaScale = 1; +uniform float circleAmount = 1; +uniform float circleDistortion = 1; +uniform float ellipseAmount = 1; +uniform float ellipseDistortion = 1; +uniform vec2 ellipseScale = vec2( 1, 0.5 ); +uniform float add_vs_max:hint_range(0,1) = 0.5; + +uniform vec4 centerHSL = vec4( 0.08, 0.0, 0.18, 1.0 ); +varying vec4 centerColor; + +uniform vec4 outsideHSL = vec4( -0.05, 1.65, 0.02, 0.0 ); +varying vec4 outsideColor; + +uniform float sizeX:hint_range(1,100) = 10; +uniform float sizeY:hint_range(1,100) = 1; +uniform float scaleAll = 1; +uniform float worldSize_vs_screenSize:hint_range(0,1) = 1; +varying vec2 stretch; + +uniform bool usSpectralsNoise = false; +uniform vec3 spectralsAmount = vec3( 0.1, 0.05, 0.02 ); +uniform float nonSpectralAmount = 0.95; +uniform vec3 spectralsSize = vec3( 1,0.8, 0.5 ); +uniform vec3 spectralsSharpness = vec3( 0, 0, 0 ); +uniform vec3 spectralsFrequency = vec3( 50.0, 200.0, 500.0 ); +uniform vec3 spectralsSpeed = vec3( 5.0, -3.0, -2.0 ); + +uniform sampler2D fading; +uniform sampler2D sizeXfading; +uniform sampler2D sizeYfading; + + +uniform bool useQuickOcclusionTest = false; +uniform float occlusionZOffset:hint_range(-30,30) = 0; +uniform int occlusionTestMaxSteps = 10; +uniform float occlusionTestStepStride = 1; +uniform float occlusionTest_ViewDependingScaleAmount:hint_range(0,1) = 0.5; +uniform float occlusionTest_ViewDependingDistance = 100; + + + +varying float occlusionAlpha; + +void vertex() +{ + vec3 viewOffset = viewToWorldDirection( vec3( 0, 0, occlusionZOffset ), INV_VIEW_MATRIX ); + vec3 nodePositionView = worldToView( NODE_POSITION_WORLD + viewOffset, VIEW_MATRIX ); + vec2 screenPosition = viewToScreen( nodePositionView, PROJECTION_MATRIX ); + + float fadeValue = textureLod( fading, screenPosition, 0.0 ).r; + float sizeXFade = textureLod( sizeXfading, screenPosition, 0.0 ).r; + float sizeYFade = textureLod( sizeYfading, screenPosition, 0.0 ).r; + + float nodeScale = length( extractScale( MODEL_MATRIX ) ); + + float sX = sizeX * sizeXFade; + float sY = sizeY * sizeYFade; + + + vec2 uvPixelSize = vec2( 1.0, 1.0 ) / VIEWPORT_SIZE ; + + vec2 scaledUVPixelSize = uvPixelSize * max( 1.0, nodePositionView.z / occlusionTest_ViewDependingDistance ); + uvPixelSize = mix( uvPixelSize, scaledUVPixelSize, occlusionTest_ViewDependingScaleAmount ); + + float occlusionValue = useQuickOcclusionTest ? + + getQuickOcclusionAt( depthTexture, nodePositionView, uvPixelSize, + occlusionTestMaxSteps, occlusionTestStepStride, + PROJECTION_MATRIX, INV_PROJECTION_MATRIX ) : + + getOcclusionAt( depthTexture, nodePositionView, uvPixelSize, + occlusionTestMaxSteps, occlusionTestStepStride, + PROJECTION_MATRIX, INV_PROJECTION_MATRIX ); + + occlusionAlpha = occlusionValue * fadeValue; + + float camDist = length( NODE_POSITION_WORLD - CAMERA_POSITION_WORLD ); + vec2 sizeScaled = vec2( sX, sY ) * scaleAll * occlusionAlpha * nodeScale; + vec2 size = mix( sizeScaled, sizeScaled * camDist * 0.1, worldSize_vs_screenSize ); + stretch = vec2( sX, sY ); + vec3 worldOffset = billboardWorldOffsetWithSize( size, UV, INV_VIEW_MATRIX, MODEL_MATRIX ); + VERTEX += worldOffset; + vec3 hsl = RGBtoHSL( color.rgb ); + vec3 shiftedHSL = shiftHSL( hsl, centerHSL.rgb, 60.0 ); + vec3 shiftedRGB = HSLtoRGB( shiftedHSL ); + + centerColor = vec4( shiftRGBwithHSL( color.rgb, centerHSL.rgb, 60.0 ), centerHSL.a * color.a); + outsideColor = vec4( shiftRGBwithHSL( color.rgb, outsideHSL.rgb, 60.0 ), outsideHSL.a * color.a ); +} + +float psin( float x, float power ) +{ + float v = sin( x ) * 0.5 + 0.5; + return mix( v, v * v * v, power ); +} + +void fragment() +{ + vec2 circleUV = ( UV - vec2( 0.5 ) ) * stretch + vec2( 0.5 ); + vec2 centerUV = UV - vec2( 0.5 ); + + float angle = atan( centerUV.y, centerUV.x ); + vec3 sizes = vec3( 1.0 ) * length( circleUV ) / 0.701; + + float distanceToCircle = 1.0 - min( 1, length( circleUV - vec2( 0.5, 0.5 ) ) / 0.5 ); + + float noise = 1.0; + + if ( usSpectralsNoise ) + { + noise = nonSpectralAmount; + + float spX = max( 0, mix( psin( TIME * spectralsSpeed.x + angle * spectralsFrequency.x, spectralsSharpness.x ) * spectralsAmount.x, 0.0, -spectralsSize.x - distanceToCircle ) ); + float spY = max( 0, mix( psin( TIME * spectralsSpeed.y + angle * spectralsFrequency.y, spectralsSharpness.y ) * spectralsAmount.y, 0.0, -spectralsSize.y - distanceToCircle ) ); + float spZ = max( 0, mix( psin( TIME * spectralsSpeed.z + angle * spectralsFrequency.z, spectralsSharpness.z ) * spectralsAmount.z, 0.0, -spectralsSize.z - distanceToCircle ) ); + + float oa = occlusionAlpha * occlusionAlpha; + noise += spX * oa; + noise += spY * oa; + noise += spZ * oa; + + noise = mix( noise, 1.0, 1.0 - oa ); + } + + + vec2 ellipseUV = ( UV - vec2( 0.5 ) ) / ellipseScale + vec2( 0.5 ); + float distanceToEllipse = 1.0 - min( 1, length( ellipseUV - vec2( 0.5, 0.5 ) ) / 0.5 ); + + distanceToCircle = clamp01( distanceToCircle * noise ); + distanceToEllipse = clamp01( distanceToEllipse ); + + distanceToCircle = pow( distanceToCircle, circleDistortion ); + distanceToEllipse = pow( distanceToEllipse, ellipseDistortion ); + + distanceToCircle *= circleAmount; + distanceToEllipse *= ellipseAmount; + + float addResult = min( 1, distanceToEllipse + distanceToCircle ); + float maxResult = min( 1, max( distanceToEllipse, distanceToCircle ) ); + float t = mix( addResult, maxResult, add_vs_max ); + vec4 mixedColor = mixThreeColors( outsideColor, color, centerColor, t ); + + ALBEDO = mixedColor.rgb; + ALPHA = mixedColor.a * occlusionAlpha * alphaScale; + +} diff --git a/Runtime/Shading/Shaders/Flares/EllipseFlare/EllipseFlareBase.gdshaderinc.uid b/Runtime/Shading/Shaders/Flares/EllipseFlare/EllipseFlareBase.gdshaderinc.uid new file mode 100644 index 0000000..f38ee57 --- /dev/null +++ b/Runtime/Shading/Shaders/Flares/EllipseFlare/EllipseFlareBase.gdshaderinc.uid @@ -0,0 +1 @@ +uid://b7bmnp7k6r76x diff --git a/Runtime/Shading/Shaders/Flares/EllipseFlare/EllipseFlareMix.gdshader b/Runtime/Shading/Shaders/Flares/EllipseFlare/EllipseFlareMix.gdshader new file mode 100644 index 0000000..9e21a74 --- /dev/null +++ b/Runtime/Shading/Shaders/Flares/EllipseFlare/EllipseFlareMix.gdshader @@ -0,0 +1,4 @@ +shader_type spatial; +render_mode blend_mix, depth_test_disabled, cull_disabled, unshaded, fog_disabled; + +#include "res://addons/rokojori_action_library/Runtime/Shading/Shaders/Flares/EllipseFlare/EllipseFlareBase.gdshaderinc" diff --git a/Runtime/Shading/Shaders/Flares/EllipseFlare/EllipseFlareMix.gdshader.uid b/Runtime/Shading/Shaders/Flares/EllipseFlare/EllipseFlareMix.gdshader.uid new file mode 100644 index 0000000..eafa91f --- /dev/null +++ b/Runtime/Shading/Shaders/Flares/EllipseFlare/EllipseFlareMix.gdshader.uid @@ -0,0 +1 @@ +uid://dqj2sqbyq5qoh diff --git a/Runtime/Time/DateTime/DateMath.cs b/Runtime/Time/DateTime/DateMath.cs index 0249dc9..96c5066 100644 --- a/Runtime/Time/DateTime/DateMath.cs +++ b/Runtime/Time/DateTime/DateMath.cs @@ -12,7 +12,7 @@ namespace Rokojori { public static DateTimeOffset InThePast( int hours ) { - return DateTimeOffset.UtcNow.AddHours( - hours ); + return DateTimeOffset.UtcNow.AddHours( - hours ); } public static bool IsNewerThan( this DateTimeOffset a, DateTimeOffset b ) diff --git a/Runtime/Time/DateTime/ISOTimeStamp.cs b/Runtime/Time/DateTime/ISOTimeStamp.cs index 2ce106e..d728cb3 100644 --- a/Runtime/Time/DateTime/ISOTimeStamp.cs +++ b/Runtime/Time/DateTime/ISOTimeStamp.cs @@ -8,7 +8,8 @@ using Godot; namespace Rokojori { - public class ISOTimeStamp + [GlobalClass] + public partial class ISOTimeStamp:Resource { public string value; diff --git a/Runtime/Time/Duration/SecondsDuration.cs b/Runtime/Time/Duration/SecondsDuration.cs index f82aff6..d64afce 100644 --- a/Runtime/Time/Duration/SecondsDuration.cs +++ b/Runtime/Time/Duration/SecondsDuration.cs @@ -19,5 +19,14 @@ namespace Rokojori { return seconds; } + + public static SecondsDuration Create( float seconds, TimeLine tl ) + { + var sd = new SecondsDuration(); + sd.seconds = seconds; + sd.timeLine = tl; + return sd; + + } } } \ No newline at end of file diff --git a/Runtime/Time/TImeLineManager_Scheduling.cs b/Runtime/Time/TImeLineManager_Scheduling.cs index 8d4a997..c3093a3 100644 --- a/Runtime/Time/TImeLineManager_Scheduling.cs +++ b/Runtime/Time/TImeLineManager_Scheduling.cs @@ -112,9 +112,9 @@ namespace Rokojori return runner._ScheduleSpan( start, end, spanID, false, callback );*/ } - public static TimeLineSpan ScheduleSpanWith( Duration duration, Action callback ) + public static TimeLineSpan ScheduleSpanWith( Duration duration, Action callback, Node context = null ) { - return ScheduleSpanIn( duration.timeLine, 0, duration.GetDurationInSeconds(), callback ); + return ScheduleSpanIn( duration.timeLine, 0, duration.GetDurationInSeconds(), callback, context ); } static async Task RunSpanInEditor( TimeLineSpan span, float duration, Action callback, Node context = null ) diff --git a/Runtime/Tools/Lists.cs b/Runtime/Tools/Lists.cs index e8d163d..4806777 100644 --- a/Runtime/Tools/Lists.cs +++ b/Runtime/Tools/Lists.cs @@ -180,7 +180,12 @@ namespace Rokojori return result; } - + + public static T Lerp( List data, float value, Func getValue, Func lerper, bool sort = false ) + { + var result = LerpIndex( data, value, getValue, sort ); + return lerper( result ); + } public static IndexLerpResult LerpIndex( List data, float value, Func getValue, bool sort = false ) { @@ -414,7 +419,7 @@ namespace Rokojori return ToList( elements ); } - public static List From( params List[] elements ) + public static List FromLists( params List[] elements ) { var list = new List(); diff --git a/Runtime/Tools/ReflectionHelper.cs b/Runtime/Tools/ReflectionHelper.cs index 4a77807..4b4e889 100644 --- a/Runtime/Tools/ReflectionHelper.cs +++ b/Runtime/Tools/ReflectionHelper.cs @@ -375,6 +375,53 @@ namespace Rokojori return value; } + public static bool IsGenericType( object instace, Type type ) + { + return instace != null && instace.GetType().IsGenericType && instace.GetType().GetGenericTypeDefinition() == type; + } + + public static T GetMemberByPath( this object root, string[] path, bool resolveToLast = true ) + { + object it = root; + var end = resolveToLast ? path.Length : ( path.Length - 1 ); + + for ( int i = 0; i < end; i++ ) + { + if ( it == null ) + { + return default( T ); + } + + var before = it; + var member = path[ i ]; + + if ( it is Godot.Collections.Array array ) + { + // RJLog.Log( "As array", before.GetType().Name, it ); + it = array[ member.ToInt() ]; + } + else if ( IsGenericType( it, typeof(Godot.Collections.Array<>) ) ) + { + var indexer = it.GetType().GetProperty( "Item" ); + it = indexer.GetValue( it, new object[] { member.ToInt() }); + } + else if ( it is System.Collections.IList list ) + { + // RJLog.Log( "As list", before.GetType().Name, it ); + it = list[ member.ToInt() ]; + } + else + { + // RJLog.Log( "As object", before.GetType().Name, it ); + it = ReflectionHelper.GetValue( it, member ); + } + + // RJLog.Log( before.GetType().Name, member, it, " ", before ); + } + + return (T) it; + } + public static void SetValue( object instance, string name, T value ) { var mi = GetDataMemberInfo( instance, name ); diff --git a/Runtime/UI/Actions/SetUIStyle.cs b/Runtime/UI/Actions/SetUIStyle.cs new file mode 100644 index 0000000..22cb760 --- /dev/null +++ b/Runtime/UI/Actions/SetUIStyle.cs @@ -0,0 +1,28 @@ + +using Godot; +using System; + +namespace Rokojori +{ + [Tool,GlobalClass] + public partial class SetUIStyle: Action + { + [Export] + public Control uiNode; + + [Export] + public UIStyle style; + + protected override void _OnTrigger() + { + var uiStyleable = uiNode as UIStylePropertyContainer; + + if ( uiStyleable == null ) + { + return; + } + + uiStyleable.SetUIStyleParent( style ); + } + } +} \ No newline at end of file diff --git a/Runtime/UI/Actions/SetUIStyle.cs.uid b/Runtime/UI/Actions/SetUIStyle.cs.uid new file mode 100644 index 0000000..d6ef350 --- /dev/null +++ b/Runtime/UI/Actions/SetUIStyle.cs.uid @@ -0,0 +1 @@ +uid://5wxryjf5c2x4 diff --git a/Runtime/UI/Layouts/UIFlowLayout.cs b/Runtime/UI/Layouts/UIFlowLayout.cs index 7e209de..b6f83c2 100644 --- a/Runtime/UI/Layouts/UIFlowLayout.cs +++ b/Runtime/UI/Layouts/UIFlowLayout.cs @@ -135,6 +135,9 @@ namespace Rokojori UILayouting.SetPositionInParentAnchor( region ); } + region.Modulate = UIColor.Compute( region, UIStyleColorProperty.ModulationColor, "", Colors.White ); + region.SelfModulate = UIColor.Compute( region, UIStyleColorProperty.SelfModulationColor, "", Colors.White ); + region.CommitUpdateInfo(); Nodes.ForEachDirectChild( region, diff --git a/Runtime/UI/Nodes/UIImage.cs b/Runtime/UI/Nodes/UIImage.cs index aa1abf2..11d227a 100644 --- a/Runtime/UI/Nodes/UIImage.cs +++ b/Runtime/UI/Nodes/UIImage.cs @@ -340,6 +340,13 @@ namespace Rokojori [Export] public UINumber scaleY; + [ExportGroup( "Modulation" )] + [Export] + public UIColor modulationColor; + [Export] + public UIColor selfModulationColor; + + [ExportGroup( "Shader Properties" )] [Export] public ShaderUIColor[] colorProperties = new ShaderUIColor[ 0 ]; @@ -398,6 +405,11 @@ namespace Rokojori return parentStyle; } + public void SetUIStyleParent( UIStyle uiStyle ) + { + parentStyle = uiStyle; + } + public UIPosition GetUIPosition() { return position; @@ -583,6 +595,9 @@ namespace Rokojori ui.settings.sizePropertyName.Set( Material, Size ); + Modulate = UIColor.Compute( this, UIStyleColorProperty.ModulationColor, "", Colors.White ); + SelfModulate = UIColor.Compute( this, UIStyleColorProperty.SelfModulationColor, "", Colors.White ); + var colorProperties = imageType != null ? imageType.GetColorShaderProperties() : []; var colorPropertyName = new ColorPropertyName(); @@ -621,6 +636,12 @@ namespace Rokojori public UIColor GetUIStyleColorProperty( UIStyleColorProperty property, string shaderPropertyName, UIStylePropertyContainer source ) { + switch ( property ) + { + case UIStyleColorProperty.ModulationColor: return modulationColor; + case UIStyleColorProperty.SelfModulationColor: return selfModulationColor; + } + if ( property != UIStyleColorProperty.ColorShaderProperty ) { return null; diff --git a/Runtime/UI/Nodes/UIRegion.cs b/Runtime/UI/Nodes/UIRegion.cs index 59f474f..00ef565 100644 --- a/Runtime/UI/Nodes/UIRegion.cs +++ b/Runtime/UI/Nodes/UIRegion.cs @@ -9,6 +9,7 @@ namespace Rokojori [GlobalClass,Icon("res://addons/rokojori_action_library/Icons/UIRegion.svg")] public partial class UIRegion : Control, UIStylePropertyContainerNode, UIHolderControl { + [Export] public UIStyle parentStyle; @@ -86,6 +87,12 @@ namespace Rokojori [Export] public UINumber shadowOffsetY; + [ExportGroup( "Modulation" )] + [Export] + public UIColor modulationColor; + [Export] + public UIColor selfModulationColor; + // public List> GetActiveShaderUIColorTransitions() // { // return null; @@ -134,10 +141,15 @@ namespace Rokojori [ExportGroup("Editor SceneSetup")] [Export] public UISettings uiSettings; + + [Export] + public bool updateInEditor = false; + [Export] public float fontZoom = 1f; - [Export] - public bool updateInEditor; + + + [Export] public bool reassignUI; [ExportGroup("Editor SceneSetup/Read Only")] @@ -152,6 +164,11 @@ namespace Rokojori return parentStyle; } + public void SetUIStyleParent( UIStyle uiStyle ) + { + parentStyle = uiStyle; + } + public UIPosition GetUIPosition() { return position; @@ -296,9 +313,11 @@ namespace Rokojori { switch ( property ) { - case UIStyleColorProperty.FontColor: return fontColor; - case UIStyleColorProperty.FontOutlineColor: return outlineColor; - case UIStyleColorProperty.FontShadowColor: return shadowColor; + case UIStyleColorProperty.FontColor: return fontColor; + case UIStyleColorProperty.FontOutlineColor: return outlineColor; + case UIStyleColorProperty.FontShadowColor: return shadowColor; + case UIStyleColorProperty.ModulationColor: return modulationColor; + case UIStyleColorProperty.SelfModulationColor: return selfModulationColor; } return null; diff --git a/Runtime/UI/Nodes/UIText.cs b/Runtime/UI/Nodes/UIText.cs index 2e22efa..3ee8c49 100644 --- a/Runtime/UI/Nodes/UIText.cs +++ b/Runtime/UI/Nodes/UIText.cs @@ -150,6 +150,12 @@ namespace Rokojori [Export] public UINumber scaleY; + [ExportGroup( "Modulation" )] + [Export] + public UIColor modulationColor; + [Export] + public UIColor selfModulationColor; + public Font GetFont() { return font; @@ -410,6 +416,11 @@ namespace Rokojori return parentStyle; } + public void SetUIStyleParent( UIStyle uiStyle ) + { + parentStyle = uiStyle; + } + public UIPosition GetUIPosition() { return position; @@ -565,7 +576,8 @@ namespace Rokojori public CachedUIColor outlineColor = CachedUIColor.Create( UIStyleColorProperty.FontOutlineColor ); public CachedUIColor shadowColor = CachedUIColor.Create( UIStyleColorProperty.FontShadowColor ); - + public CachedUIColor modulationColor = CachedUIColor.Create( UIStyleColorProperty.ModulationColor ); + public CachedUIColor selfModulationColor = CachedUIColor.Create( UIStyleColorProperty.SelfModulationColor ); public bool HasChanged() { @@ -574,6 +586,11 @@ namespace Rokojori return true; } + if ( modulationColor.changed || selfModulationColor.changed ) + { + return true; + } + if ( outlineSize.valueInt > 0 && outlineColor.changed ) { return true; @@ -612,6 +629,8 @@ namespace Rokojori l.ShadowOffset = new Vector2( shadowOffsetX.value, shadowOffsetY.value ); } + + return l; } } @@ -642,6 +661,10 @@ namespace Rokojori cachedLabelSettings.outlineSize.Compute( this ); cachedLabelSettings.shadowSize.Compute( this ); cachedLabelSettings.fontColor.Compute( this ); + cachedLabelSettings.modulationColor.Compute( this ); + cachedLabelSettings.selfModulationColor.Compute( this ); + + if ( cachedLabelSettings.outlineSize.valueInt > 0 ) { @@ -660,6 +683,8 @@ namespace Rokojori if ( cachedLabelSettings.HasChanged() || ! cachedLabelSettings.wasCreated ) { uiTextLabelSettings = cachedLabelSettings.CreateLabelSettings(); + Modulate = cachedLabelSettings.modulationColor.color; + SelfModulate = cachedLabelSettings.selfModulationColor.color; } // uiTextLabelSettings.FontSize = Mathf.Max( 1, @@ -730,6 +755,8 @@ namespace Rokojori case UIStyleColorProperty.FontColor: return fontColor; case UIStyleColorProperty.FontOutlineColor: return outlineColor; case UIStyleColorProperty.FontShadowColor: return shadowColor; + case UIStyleColorProperty.ModulationColor: return modulationColor; + case UIStyleColorProperty.SelfModulationColor: return selfModulationColor; } return null; diff --git a/Runtime/UI/Shaders/RoundedRectangle/RoundedRectangle.gdshader b/Runtime/UI/Shaders/RoundedRectangle/RoundedRectangle.gdshader index 156e5fb..0367441 100644 --- a/Runtime/UI/Shaders/RoundedRectangle/RoundedRectangle.gdshader +++ b/Runtime/UI/Shaders/RoundedRectangle/RoundedRectangle.gdshader @@ -27,6 +27,38 @@ uniform vec4 screenStrokeMultiplyUVTransform; uniform vec2 screenStrokeMultiplyUVMovment; uniform float opacity:hint_range(0,1) = 1; +uniform float fillStateAngle:hint_range(-360,360) = 0; +uniform float fillStateOffset:hint_range(-180,180) = 0; + +float angleFill( vec2 uv, float angleDegrees, float offsetDegrees ) +{ + float angleRadians = atan( uv.y, uv.x ); + float angle = degrees( angleRadians ) - offsetDegrees + 270.0; + + while ( angle > 180.0 ) + { + angle -= 360.0; + } + + while ( angle < -180.0 ) + { + angle += 360.0; + } + + angle += 180.0; + + float difference = 0.0; + + if ( angleDegrees >= 0.0 ) + { + return angle < angleDegrees ? 0.0 : 1.0; + } + else + { + + return angle > ( 360.0 + angleDegrees ) ? 0.0 : 1.0; + } +} void vertex() { @@ -81,10 +113,12 @@ void fragment() float mask = max ( fillMask , strokeMask ); mask = fillMask + strokeMask; - + vec4 tex = texture( TEXTURE, UV ); - COLOR = vec4( outputColor.rgb * tex.rgb, outputColor.a * mask * opacity * tex.a); + float anglefillState = angleFill( UV - vec2( 0.5 ), fillStateAngle, fillStateOffset ); + + COLOR = vec4( outputColor.rgb * tex.rgb, outputColor.a * mask * opacity * tex.a * anglefillState); // Called for every pixel the material is visible on. } diff --git a/Runtime/UI/Styling/UIColor.cs b/Runtime/UI/Styling/UIColor.cs index 0f28c3a..e8a145b 100644 --- a/Runtime/UI/Styling/UIColor.cs +++ b/Runtime/UI/Styling/UIColor.cs @@ -51,11 +51,28 @@ namespace Rokojori var computedColor = Compute( control, uiColor, defaultColor ); + // if ( property != UIStyleColorProperty.ColorShaderProperty ) + // { + // UIStyle.debugInfo = control; + + // control.LogInfo( "=========== CHECKING COLOR =================" ); + // } var transition = UIStyle.GetTransition( container, property, shaderPropertyName ); + + // if ( property != UIStyleColorProperty.ColorShaderProperty ) + // { + // UIStyle.debugInfo = null; + // } + var transitionAll = UIStyle.GetTransitionSettingsAll( container ); var usesTransition = transition != null || transitionAll != null && transitionAll.transitionAllProperties; + // if ( property != UIStyleColorProperty.ColorShaderProperty ) + // { + // RJLog.Log( HierarchyName.Of( control ), "Uses Transition:", property, usesTransition, transition, transitionAll ); + // } + if ( ! usesTransition ) { return computedColor; @@ -71,6 +88,12 @@ namespace Rokojori if ( endValueChanged ) { var transitionSettings = UIStyle.GetTransitionSettings( container, property, shaderPropertyName ); + + if ( transitionSettings == null ) + { + control.LogInfo( ">> No transition settings", property ); + } + propertyTransition.StartTransition( control, uiColor, transitionSettings ); } diff --git a/Runtime/UI/Styling/UIStyle.cs b/Runtime/UI/Styling/UIStyle.cs index f0008e2..46ca791 100644 --- a/Runtime/UI/Styling/UIStyle.cs +++ b/Runtime/UI/Styling/UIStyle.cs @@ -2,6 +2,7 @@ using Godot; using Rokojori; using System.Collections.Generic; +using System.Linq; namespace Rokojori { @@ -10,12 +11,6 @@ namespace Rokojori [GlobalClass] public partial class UIStyle:Resource, UIStylePropertyContainer { - [Export] - public UIStyle parentStyle; - - [Export] - public UISelectorStyle[] selectorStyles = []; - [ExportGroup( "Layout" )] [Export] public UILayout layout; @@ -106,12 +101,20 @@ namespace Rokojori [Export] public UINumber scaleY; + [ExportGroup( "Modulation" )] + [Export] + public UIColor modulationColor; + [Export] + public UIColor selfModulationColor; + [ExportGroup( "Shader Properties" )] [Export] public ShaderUIColor[] colorProperties = new ShaderUIColor[ 0 ]; [Export] public ShaderUINumber[] numberProperties = new ShaderUINumber[ 0 ]; + + public Font GetFont() { return font; @@ -165,6 +168,15 @@ namespace Rokojori [Export] public UICursor hoverCursor; + + [ExportGroup( "Selectors & Parent " )] + + [Export] + public UISelectorStyle[] selectorStyles = []; + + [Export] + public UIStyle parentStyle; + // public UICursor GetOwnUICursor( Control control ) // { // if ( ) @@ -220,6 +232,11 @@ namespace Rokojori return parentStyle; } + public void SetUIStyleParent( UIStyle uiStyle ) + { + parentStyle = uiStyle; + } + public UIPosition GetUIPosition() { return position; @@ -422,9 +439,11 @@ namespace Rokojori { switch ( property ) { - case UIStyleColorProperty.FontColor: return fontColor; - case UIStyleColorProperty.FontOutlineColor: return outlineColor; - case UIStyleColorProperty.FontShadowColor: return shadowColor; + case UIStyleColorProperty.FontColor: return fontColor; + case UIStyleColorProperty.FontOutlineColor: return outlineColor; + case UIStyleColorProperty.FontShadowColor: return shadowColor; + case UIStyleColorProperty.ModulationColor: return modulationColor; + case UIStyleColorProperty.SelfModulationColor: return selfModulationColor; case UIStyleColorProperty.ColorShaderProperty: { var shaderUIColor = Arrays.FindNonNull( colorProperties, @@ -507,7 +526,7 @@ namespace Rokojori var transitions = container.GetNumberTransitions(); - var index = transitions == null ? -1 : Arrays.FindIndex( transitions, t => t != null && t.property == property ); + var index = transitions == null ? -1 : Arrays.FindIndex( transitions, t => t != null && t.Matches( property, shaderPropertyName ) ); if ( index != -1 ) { @@ -516,17 +535,17 @@ namespace Rokojori var styleParent = container.GetUIStyleParent(); - if ( styleParent == null ) + if ( styleParent != null ) { - return null; + var styleParentTransition = _GetTransition( false, styleParent, property, shaderPropertyName ); + + if ( styleParentTransition != null ) + { + return styleParentTransition; + } } - var styleParentTransition = _GetTransition( false, styleParent, property, shaderPropertyName ); - - if ( styleParentTransition != null ) - { - return styleParentTransition; - } + if ( ! ( container is Control ) || ! inheritable ) { @@ -679,6 +698,8 @@ namespace Rokojori } + public static Control debugInfo = null; + static UIColorTransition _GetTransition( bool inheritable, UIStylePropertyContainer container, UIStyleColorProperty property, string shaderPropertyName @@ -686,6 +707,19 @@ namespace Rokojori { var transitions = container.GetColorTransitions(); + if ( debugInfo != null ) + { + var length = transitions == null ? -1 : transitions.Length; + debugInfo.LogInfo( "Own transition:", HierarchyName.OfAny( container ), " , ", length ); + + if ( transitions != null ) + { + debugInfo.LogInfo( transitions.Map( t => t.property ).ToList().Join( ", " ) ); + } + } + + + var transition = transitions.Find( t => t != null && t.Matches( property, shaderPropertyName ) ); if ( transition != null ) @@ -695,41 +729,87 @@ namespace Rokojori var styleParent = container.GetUIStyleParent(); - if ( styleParent == null ) + if ( styleParent != null ) { - return null; - } + if ( debugInfo != null ) + { + debugInfo.LogInfo( "Found Style Parent:", HierarchyName.OfAny( container ), " , ", HierarchyName.OfAny( styleParent ) ); + } - var styleParentTransition = _GetTransition( false, styleParent, property, shaderPropertyName ); - if ( styleParentTransition != null ) - { - return styleParentTransition; + var styleParentTransition = _GetTransition( false, styleParent, property, shaderPropertyName ); + + if ( styleParentTransition != null ) + { + if ( debugInfo != null ) + { + debugInfo.LogInfo( "Found Style Parent Transition:", HierarchyName.OfAny( container ), " , ", HierarchyName.OfAny( styleParent ) ); + } + + return styleParentTransition; + } + else + { + if ( debugInfo != null ) + { + debugInfo.LogInfo( "No Style Parent Transition:", HierarchyName.OfAny( container ), " , ", HierarchyName.OfAny( styleParent ) ); + } + } + } if ( ! ( container is Control ) || ! inheritable ) { + if ( debugInfo != null ) + { + debugInfo.LogInfo( "Container is null/! inheritable", container, inheritable ); + } return null; } var control = container as Control; UIColorTransition parentTransition = null; + if ( debugInfo != null ) + { + debugInfo.LogInfo( "Checking parents:", HierarchyName.Of( control ) ); + } + NodesWalker.Get().GetInParents( control, it => { + if ( debugInfo != null ) + { + debugInfo.LogInfo( "Processing Parent:", HierarchyName.Of( it ) ); + } + if ( ! ( it is UIStylePropertyContainer ) ) { + if ( debugInfo != null ) + { + debugInfo.LogInfo( "Not a style container:" ); + } + return false; } var container = (UIStylePropertyContainer) it; parentTransition = _GetTransition( true, container, property, shaderPropertyName ); + if ( debugInfo != null ) + { + debugInfo.LogInfo( "Transition of parent:", parentTransition ); + } + return parentTransition != null; } ); + if ( debugInfo != null ) + { + debugInfo.LogInfo( "Processing Parents done, result:", parentTransition ); + } + return parentTransition; } diff --git a/Runtime/UI/Styling/UIStyleProperty.cs b/Runtime/UI/Styling/UIStyleProperty.cs index 2ad5d6f..5fd5780 100644 --- a/Runtime/UI/Styling/UIStyleProperty.cs +++ b/Runtime/UI/Styling/UIStyleProperty.cs @@ -90,6 +90,9 @@ namespace Rokojori FontOutlineColor, FontShadowColor, + ModulationColor, + SelfModulationColor, + ColorShaderProperty } diff --git a/Runtime/UI/Styling/UIStylePropertyContainer.cs b/Runtime/UI/Styling/UIStylePropertyContainer.cs index 7f2fad2..88ed2d9 100644 --- a/Runtime/UI/Styling/UIStylePropertyContainer.cs +++ b/Runtime/UI/Styling/UIStylePropertyContainer.cs @@ -8,6 +8,7 @@ namespace Rokojori public interface UIStylePropertyContainer { UIStyle GetUIStyleParent(); + void SetUIStyleParent( UIStyle uiStyle ); UIPosition GetUIPosition(); UILayout GetUILayout(); diff --git a/Runtime/UI/Transitions/UIColorTransition.cs b/Runtime/UI/Transitions/UIColorTransition.cs index f93f871..8955970 100644 --- a/Runtime/UI/Transitions/UIColorTransition.cs +++ b/Runtime/UI/Transitions/UIColorTransition.cs @@ -27,7 +27,7 @@ namespace Rokojori return false; } - if ( UIStyleColorProperty.ColorShaderProperty == property ) + if ( UIStyleColorProperty.ColorShaderProperty != property ) { return true; } diff --git a/Runtime/UI/Transitions/UINumberTransition.cs b/Runtime/UI/Transitions/UINumberTransition.cs index 85008f0..02187c4 100644 --- a/Runtime/UI/Transitions/UINumberTransition.cs +++ b/Runtime/UI/Transitions/UINumberTransition.cs @@ -17,5 +17,23 @@ namespace Rokojori [Export] public TransitionSettings settings; + + public bool Matches( UIStyleNumberProperty property, string name ) + { + var hasSameProperty = this.property == property; + + if ( ! hasSameProperty ) + { + return false; + } + + if ( UIStyleNumberProperty.FloatShaderProperty != property ) + { + return true; + } + + return name == shaderPropertyName; + } + } } \ No newline at end of file diff --git a/Runtime/UI/UI-Settings-Default.tres b/Runtime/UI/UI-Settings-Default.tres index aae1f2d..e03d7e8 100644 --- a/Runtime/UI/UI-Settings-Default.tres +++ b/Runtime/UI/UI-Settings-Default.tres @@ -9,7 +9,7 @@ [sub_resource type="Resource" id="Resource_wm644"] script = ExtResource("3_xon8j") -value = 1.5 +value = 1.0 unit = "vw" metadata/_custom_type_script = "uid://cnkyynboxg1qg" diff --git a/Runtime/UI/UI.cs b/Runtime/UI/UI.cs index ba07d81..1a7c4ab 100644 --- a/Runtime/UI/UI.cs +++ b/Runtime/UI/UI.cs @@ -200,9 +200,18 @@ namespace Rokojori _resizeFlag = true; } - if ( useParentSize && GetParent() as Control != null ) + if ( useParentSize ) { - var parentSize = GetParent().Size; + var parentSize = cachedSize; + + if ( GetParent() as Control != null ) + { + parentSize = GetParent().Size; + } + else + { + parentSize = newWindowSize; + } if ( parentSize != cachedSize ) {