From 26d24f9fe629217fdf753fa0552f9890578b539f Mon Sep 17 00:00:00 2001 From: Josef Date: Tue, 24 Jun 2025 13:24:33 +0200 Subject: [PATCH] Sync --- RokojoriPlugin.cs | 30 +++++++++---------- Runtime/Math/Math3D.cs | 14 ++++++++- .../DepthView/DepthViewEffect.cs | 10 ++++++- .../DepthView/DepthViewShader.glsl | 5 +++- Runtime/Shading/Library/Transform.gdshaderinc | 10 +++++++ 5 files changed, 51 insertions(+), 18 deletions(-) diff --git a/RokojoriPlugin.cs b/RokojoriPlugin.cs index 7ef107e..36e2f31 100644 --- a/RokojoriPlugin.cs +++ b/RokojoriPlugin.cs @@ -70,28 +70,28 @@ namespace Rokojori AddNode3DGizmoPlugin( gizmoDrawerPlugin ); - var pePackedScene = GD.Load( ProblemsExplorerPath ); + // var pePackedScene = GD.Load( ProblemsExplorerPath ); - if ( pePackedScene != null ) - { - // this.LogInfo( "Problems Explorer found: ", pePackedScene ); + // if ( pePackedScene != null ) + // { + // // this.LogInfo( "Problems Explorer found: ", pePackedScene ); - messages = ((PackedScene)pePackedScene).Instantiate(); + // messages = ((PackedScene)pePackedScene).Instantiate(); - var ui = messages.Get(); - ui.BindOwnChildren(); + // var ui = messages.Get(); + // ui.BindOwnChildren(); - var shortCut = new Shortcut(); - shortCut.Events = [ new InputEventKey{ CtrlPressed = true, Keycode = Key.U } ]; + // var shortCut = new Shortcut(); + // shortCut.Events = [ new InputEventKey{ CtrlPressed = true, Keycode = Key.U } ]; - AddControlToDock( DockSlot.RightBr, messages, shortCut ); - } - else - { - this.LogInfo( "Problems Explorer not found: ", ProblemsExplorerPath ); - } + // AddControlToDock( DockSlot.RightBr, messages, shortCut ); + // } + // else + // { + // this.LogInfo( "Problems Explorer not found: ", ProblemsExplorerPath ); + // } } public override void _ExitTree() diff --git a/Runtime/Math/Math3D.cs b/Runtime/Math/Math3D.cs index 226343a..d86cefb 100644 --- a/Runtime/Math/Math3D.cs +++ b/Runtime/Math/Math3D.cs @@ -352,11 +352,22 @@ namespace Rokojori return GetGlobalRotationFrom( node ); } + public static Quaternion GetGlobalRotationFrom( Node3D node ) { var quaternion = node.GlobalBasis.GetRotationQuaternion(); return quaternion; + } + + public static float GlobalYawDegrees( this Node3D node3D ) + { + return GlobalYawDegrees( node3D.GlobalForward() ); + } + + public static float GlobalYawRadians( this Node3D node3D ) + { + return Mathf.DegToRad( GlobalYawDegrees( node3D ) ); } public static Vector3 GetMin( List data, Func getPosition ) @@ -632,7 +643,8 @@ namespace Rokojori public static float GlobalYaw( Vector3 direction ) { - return ( Mathf.Pi * 2.0f - Mathf.Atan2( direction.Z, direction.X ) ) - Mathf.Pi / 2.0f; + return Mathf.Atan2( direction.X, direction.Z ); + // return ( Mathf.Pi * 2.0f - Mathf.Atan2( direction.Z, direction.X ) ) - Mathf.Pi / 2.0f; } public static float GlobalYawDegrees( Vector3 direction ) diff --git a/Runtime/Rendering/Compositor/CompositorEffects/DepthView/DepthViewEffect.cs b/Runtime/Rendering/Compositor/CompositorEffects/DepthView/DepthViewEffect.cs index 10e21f9..7f5452b 100644 --- a/Runtime/Rendering/Compositor/CompositorEffects/DepthView/DepthViewEffect.cs +++ b/Runtime/Rendering/Compositor/CompositorEffects/DepthView/DepthViewEffect.cs @@ -22,6 +22,12 @@ namespace Rokojori [Export( PropertyHint.Range, "0,1") ] public float grayAmount = 0f; + [Export( PropertyHint.Range, "0,1") ] + public float mappedMinValue = 0f; + + [Export( PropertyHint.Range, "0,1") ] + public float mappedMaxValue = 0f; + protected override void OnConfigure() { EffectCallbackType = EffectCallbackTypeEnum.PostTransparent; @@ -41,7 +47,9 @@ namespace Rokojori constants.Set( depthAmount, depthPower, - grayAmount + grayAmount, + mappedMinValue, + mappedMaxValue ); } diff --git a/Runtime/Rendering/Compositor/CompositorEffects/DepthView/DepthViewShader.glsl b/Runtime/Rendering/Compositor/CompositorEffects/DepthView/DepthViewShader.glsl index c9ac46a..826fcb8 100644 --- a/Runtime/Rendering/Compositor/CompositorEffects/DepthView/DepthViewShader.glsl +++ b/Runtime/Rendering/Compositor/CompositorEffects/DepthView/DepthViewShader.glsl @@ -15,6 +15,8 @@ uniform Parameters float depthAmount; float depthPower; float grayAmount; + float mappedMinValue; + float mappedMaxValue; } parameters; @@ -39,6 +41,7 @@ void main() vec4 color = imageLoad( colorImage, uv ); float depth = sampleDepth( uv, size ); + depth = ( depth - parameters.mappedMinValue ) / ( parameters.mappedMaxValue - parameters.mappedMinValue ); float gray = color.r * 0.2 + color.g * 0.7 + color.b * 0.1; @@ -46,7 +49,7 @@ void main() depthValue = mix( depthValue, depthValue * gray, parameters.grayAmount ); - color.rgb = vec3( depthValue, depthValue, depthValue ); + color.rgb = mix( color.rgb, vec3( depthValue, depthValue, depthValue ), parameters.depthAmount ); imageStore( colorImage, uv, color ); } \ No newline at end of file diff --git a/Runtime/Shading/Library/Transform.gdshaderinc b/Runtime/Shading/Library/Transform.gdshaderinc index bdca2ea..755ebc3 100644 --- a/Runtime/Shading/Library/Transform.gdshaderinc +++ b/Runtime/Shading/Library/Transform.gdshaderinc @@ -499,6 +499,11 @@ mat4 rotationZ_m4( float radiansAngle ) ); } +mat4 eulerRotation( vec3 eulerRadians ) +{ + return rotationX_m4( eulerRadians.x ) * rotationY_m4( eulerRadians.y ) * rotationZ_m4( eulerRadians.z ); +} + mat3 quaternionToRotationMatrix( vec4 q ) { float x = q.x; @@ -553,6 +558,11 @@ mat4 TRS( vec3 translation, vec4 rotation, vec3 scale ) return translate_m4( translation ) * mat4( quaternionToRotationMatrix( rotation ) ) * scale_m4( scale ); } +mat4 TRS( vec3 translation, vec3 eulerRadians, vec3 scale ) +{ + return translate_m4( translation ) * eulerRotation( eulerRadians ) * scale_m4( scale ); +} + mat4 mixTRS( mat4 a, mat4 b, float t ) { vec3 oA = extractTranslation( a );