From 2a5e41b98f3e552d9d100e27771c5a0cd61f6df3 Mon Sep 17 00:00:00 2001 From: Josef Date: Sat, 17 Jan 2026 20:40:34 +0100 Subject: [PATCH] Fixed Compositor Effects Bug, added readme --- .../CompositorEffectLayout.cs | 30 +- .../CompositorEffects/Depth/DepthEffect.cs | 14 + .../Depth/DepthEffect.cs.uid | 1 + .../Distortion/DistortionEffect.cs | 14 + .../Distortion/DistortionEffect.cs.uid | 1 + .../EdgeDistortion/EdgeDistortionEffect.cs | 2 +- .../EllipseDistortionEffect.cs | 2 +- .../NoiseDistortion/NoiseDistortionEffect.cs | 2 +- .../Distortion/ScanLines/ScanLinesEffect.cs | 2 +- .../TextureDistortionEffect.cs | 33 +- .../DepthOutlines/DepthOutlinesEffect.cs | 204 +++++++++++++ .../DepthOutlines/DepthOutlinesEffect.cs.uid | 1 + .../Glow/Rainbow Star Glow.tres | 20 +- .../Physical/Frozen Ice.tres | 20 +- .../Screen/Analog Tube TV .tres | 12 +- .../CompositorVFXPresets/Screen/Sketch.tres | 159 ++++++++++ .../Compositor/RokojoriCompositorEffect.cs | 16 +- .../Rendering/Context/RDContext.CleanUp.cs | 10 +- Runtime/Rendering/Context/RDContext.cs | 6 +- Runtime/Rendering/Objects/RDObject.cs | 5 + .../Depth/GenerateViewZ/GenerateViewZ.glsl | 288 ++++++++++++++++++ .../GenerateViewZ/GenerateViewZ.glsl.import | 14 + .../Depth/GenerateViewZ/RG_GenerateViewZ.cs | 17 ++ .../GenerateViewZ/RG_GenerateViewZ.cs.uid | 1 + .../Processors/Generic/CEG_ImageProcessor.cs | 5 +- .../RG_ScreenNormalRoughnessTexture.cs | 52 ++++ .../RG_ScreenNormalRoughnessTexture.cs.uid | 1 + .../ChannelPixelation/ChannelPixelation.glsl | 9 +- .../Outlines/ZOutlines/RG_ZOutlines.cs | 18 ++ .../Outlines/ZOutlines/RG_ZOutlines.cs.uid | 1 + .../Outlines/ZOutlines/ZOutlines.glsl | 233 ++++++++++++++ .../Outlines/ZOutlines/ZOutlines.glsl.import | 14 + .../object-inspector/ObjectGraphInspector.cs | 122 ++++++++ .../ObjectGraphInspector.cs.uid | 1 + readme.md | 12 + 35 files changed, 1306 insertions(+), 36 deletions(-) create mode 100644 Runtime/Rendering/Compositor/CompositorEffects/Depth/DepthEffect.cs create mode 100644 Runtime/Rendering/Compositor/CompositorEffects/Depth/DepthEffect.cs.uid create mode 100644 Runtime/Rendering/Compositor/CompositorEffects/Distortion/DistortionEffect.cs create mode 100644 Runtime/Rendering/Compositor/CompositorEffects/Distortion/DistortionEffect.cs.uid create mode 100644 Runtime/Rendering/Compositor/CompositorEffects/Outlines/DepthOutlines/DepthOutlinesEffect.cs create mode 100644 Runtime/Rendering/Compositor/CompositorEffects/Outlines/DepthOutlines/DepthOutlinesEffect.cs.uid create mode 100644 Runtime/Rendering/Compositor/CompositorVFXPresets/Screen/Sketch.tres create mode 100644 Runtime/Rendering/RenderGraph/Nodes/Processors/Depth/GenerateViewZ/GenerateViewZ.glsl create mode 100644 Runtime/Rendering/RenderGraph/Nodes/Processors/Depth/GenerateViewZ/GenerateViewZ.glsl.import create mode 100644 Runtime/Rendering/RenderGraph/Nodes/Processors/Depth/GenerateViewZ/RG_GenerateViewZ.cs create mode 100644 Runtime/Rendering/RenderGraph/Nodes/Processors/Depth/GenerateViewZ/RG_GenerateViewZ.cs.uid create mode 100644 Runtime/Rendering/RenderGraph/Nodes/Processors/Generic/RG_ScreenNormalRoughnessTexture.cs create mode 100644 Runtime/Rendering/RenderGraph/Nodes/Processors/Generic/RG_ScreenNormalRoughnessTexture.cs.uid create mode 100644 Runtime/Rendering/RenderGraph/Nodes/Processors/Outlines/ZOutlines/RG_ZOutlines.cs create mode 100644 Runtime/Rendering/RenderGraph/Nodes/Processors/Outlines/ZOutlines/RG_ZOutlines.cs.uid create mode 100644 Runtime/Rendering/RenderGraph/Nodes/Processors/Outlines/ZOutlines/ZOutlines.glsl create mode 100644 Runtime/Rendering/RenderGraph/Nodes/Processors/Outlines/ZOutlines/ZOutlines.glsl.import create mode 100644 Tools/object-inspector/ObjectGraphInspector.cs create mode 100644 Tools/object-inspector/ObjectGraphInspector.cs.uid create mode 100644 readme.md diff --git a/Runtime/Rendering/Compositor/CompositorEffectReferences/CompositorEffectLayout.cs b/Runtime/Rendering/Compositor/CompositorEffectReferences/CompositorEffectLayout.cs index 42ab8b0..9662451 100644 --- a/Runtime/Rendering/Compositor/CompositorEffectReferences/CompositorEffectLayout.cs +++ b/Runtime/Rendering/Compositor/CompositorEffectReferences/CompositorEffectLayout.cs @@ -48,12 +48,12 @@ namespace Rokojori { refresh = refreshFrames; - activeVFX.ForEach( - a => - { - a.DuplicateHack(); - } - ); + // activeVFX.ForEach( + // a => + // { + // a.DuplicateHack(); + // } + // ); } } @@ -101,11 +101,17 @@ namespace Rokojori var ef = t.Item1; var indexE = effects.IndexOf( ef ); var ce = t.Item2; - var indexC = compositor.CompositorEffects.IndexOf( ce ); + var fx = compositor.CompositorEffects; + var indexC = fx.IndexOf( ce ); + + if ( indexC == -1 || indexE == -1 ) + { + // this.LogInfo( "Not replacing: ","Compositor index:", indexC, "VFX index:", indexE ); + return; + } effects[ indexE ] = (RokojoriCompositorEffect) ef.Duplicate(); - var fx = compositor.CompositorEffects; fx[ indexC ] = effects[ indexE ]; compositor.CompositorEffects = fx; } @@ -133,7 +139,7 @@ namespace Rokojori for ( int i = range.min; ! found && i <= range.max; i++ ) { - this.LogInfo( "Checking:", i ); + // this.LogInfo( "Checking:", i ); if ( newEffects[ i ] != null && newEffects[ i ] is RokojoriCompositorEffect r && r.compositorEffectID != null && @@ -141,7 +147,7 @@ namespace Rokojori ) { found = true; - this.LogInfo( "Found lower insertion Index:", insertionIndex, ">>", i ); + // this.LogInfo( "Found lower insertion Index:", insertionIndex, ">>", i ); insertionIndex = i; } @@ -149,14 +155,14 @@ namespace Rokojori { if ( newEffects[ i ] != null && newEffects[ i ] is RokojoriCompositorEffect rfx ) { - this.LogInfo( "Found insertion Index:", rfx.compositorEffectID ); + // this.LogInfo( "Found insertion Index:", rfx.compositorEffectID ); } } } } } - this.LogInfo( "Insertion Index:", insertionIndex, ">>", newEffects.Count ); + // this.LogInfo( "Insertion Index:", insertionIndex, ">>", newEffects.Count ); list.ForEach( ( l )=> diff --git a/Runtime/Rendering/Compositor/CompositorEffects/Depth/DepthEffect.cs b/Runtime/Rendering/Compositor/CompositorEffects/Depth/DepthEffect.cs new file mode 100644 index 0000000..93c5eb2 --- /dev/null +++ b/Runtime/Rendering/Compositor/CompositorEffects/Depth/DepthEffect.cs @@ -0,0 +1,14 @@ + +using Godot; +using Godot.Collections; +using System.Collections.Generic; + +namespace Rokojori +{ + [Tool] + [GlobalClass] + public abstract partial class DepthEffect:RDGraphCompositorEffect + { + + } +} \ No newline at end of file diff --git a/Runtime/Rendering/Compositor/CompositorEffects/Depth/DepthEffect.cs.uid b/Runtime/Rendering/Compositor/CompositorEffects/Depth/DepthEffect.cs.uid new file mode 100644 index 0000000..f46a973 --- /dev/null +++ b/Runtime/Rendering/Compositor/CompositorEffects/Depth/DepthEffect.cs.uid @@ -0,0 +1 @@ +uid://c1m0ch8jmcjhm diff --git a/Runtime/Rendering/Compositor/CompositorEffects/Distortion/DistortionEffect.cs b/Runtime/Rendering/Compositor/CompositorEffects/Distortion/DistortionEffect.cs new file mode 100644 index 0000000..333401b --- /dev/null +++ b/Runtime/Rendering/Compositor/CompositorEffects/Distortion/DistortionEffect.cs @@ -0,0 +1,14 @@ + +using Godot; +using Godot.Collections; +using System.Collections.Generic; + +namespace Rokojori +{ + [Tool] + [GlobalClass] + public abstract partial class DistortionEffect:RDGraphCompositorEffect + { + + } +} \ No newline at end of file diff --git a/Runtime/Rendering/Compositor/CompositorEffects/Distortion/DistortionEffect.cs.uid b/Runtime/Rendering/Compositor/CompositorEffects/Distortion/DistortionEffect.cs.uid new file mode 100644 index 0000000..099bbd1 --- /dev/null +++ b/Runtime/Rendering/Compositor/CompositorEffects/Distortion/DistortionEffect.cs.uid @@ -0,0 +1 @@ +uid://t1x1jp6k8voe diff --git a/Runtime/Rendering/Compositor/CompositorEffects/Distortion/EdgeDistortion/EdgeDistortionEffect.cs b/Runtime/Rendering/Compositor/CompositorEffects/Distortion/EdgeDistortion/EdgeDistortionEffect.cs index 9818d12..9ef2501 100644 --- a/Runtime/Rendering/Compositor/CompositorEffects/Distortion/EdgeDistortion/EdgeDistortionEffect.cs +++ b/Runtime/Rendering/Compositor/CompositorEffects/Distortion/EdgeDistortion/EdgeDistortionEffect.cs @@ -7,7 +7,7 @@ namespace Rokojori { [Tool] [GlobalClass] - public partial class EdgeDistortionEffect:RDGraphCompositorEffect + public partial class EdgeDistortionEffect:DistortionEffect { public EdgeDistortionEffect():base() { diff --git a/Runtime/Rendering/Compositor/CompositorEffects/Distortion/EllispeDistortion/EllipseDistortionEffect.cs b/Runtime/Rendering/Compositor/CompositorEffects/Distortion/EllispeDistortion/EllipseDistortionEffect.cs index 957f506..5e2727b 100644 --- a/Runtime/Rendering/Compositor/CompositorEffects/Distortion/EllispeDistortion/EllipseDistortionEffect.cs +++ b/Runtime/Rendering/Compositor/CompositorEffects/Distortion/EllispeDistortion/EllipseDistortionEffect.cs @@ -7,7 +7,7 @@ namespace Rokojori { [Tool] [GlobalClass] - public partial class EllipseDistortionEffect:RDGraphCompositorEffect + public partial class EllipseDistortionEffect:DistortionEffect { public EllipseDistortionEffect():base() { diff --git a/Runtime/Rendering/Compositor/CompositorEffects/Distortion/NoiseDistortion/NoiseDistortionEffect.cs b/Runtime/Rendering/Compositor/CompositorEffects/Distortion/NoiseDistortion/NoiseDistortionEffect.cs index cb3a1ae..fbd3063 100644 --- a/Runtime/Rendering/Compositor/CompositorEffects/Distortion/NoiseDistortion/NoiseDistortionEffect.cs +++ b/Runtime/Rendering/Compositor/CompositorEffects/Distortion/NoiseDistortion/NoiseDistortionEffect.cs @@ -7,7 +7,7 @@ namespace Rokojori { [Tool] [GlobalClass] - public partial class NoiseDistortionEffect:RDGraphCompositorEffect + public partial class NoiseDistortionEffect:DistortionEffect { public NoiseDistortionEffect():base() { diff --git a/Runtime/Rendering/Compositor/CompositorEffects/Distortion/ScanLines/ScanLinesEffect.cs b/Runtime/Rendering/Compositor/CompositorEffects/Distortion/ScanLines/ScanLinesEffect.cs index 4e8064a..e882934 100644 --- a/Runtime/Rendering/Compositor/CompositorEffects/Distortion/ScanLines/ScanLinesEffect.cs +++ b/Runtime/Rendering/Compositor/CompositorEffects/Distortion/ScanLines/ScanLinesEffect.cs @@ -7,7 +7,7 @@ namespace Rokojori { [Tool] [GlobalClass] - public partial class ScanLinesEffect:RDGraphCompositorEffect + public partial class ScanLinesEffect:DistortionEffect { public ScanLinesEffect():base() { diff --git a/Runtime/Rendering/Compositor/CompositorEffects/Distortion/TextureDistortion/TextureDistortionEffect.cs b/Runtime/Rendering/Compositor/CompositorEffects/Distortion/TextureDistortion/TextureDistortionEffect.cs index 219d003..aa16edf 100644 --- a/Runtime/Rendering/Compositor/CompositorEffects/Distortion/TextureDistortion/TextureDistortionEffect.cs +++ b/Runtime/Rendering/Compositor/CompositorEffects/Distortion/TextureDistortion/TextureDistortionEffect.cs @@ -7,7 +7,7 @@ namespace Rokojori { [Tool] [GlobalClass] - public partial class TextureDistortionEffect:RDGraphCompositorEffect + public partial class TextureDistortionEffect:DistortionEffect { public TextureDistortionEffect():base() { @@ -53,6 +53,9 @@ namespace Rokojori [Export] public TimeLine distortionScrollTimeLine; + [Export] + public float distortionScrollFPS = 60f; + [Export] public RenderingDevice.SamplerFilter distortionFilter = RenderingDevice.SamplerFilter.Linear; @@ -79,6 +82,9 @@ namespace Rokojori [Export] public TimeLine maskScrollTimeLine; + [Export] + public float maskScrollFPS = 60f; + [Export] public RenderingDevice.SamplerFilter maskFilter = RenderingDevice.SamplerFilter.Linear; @@ -167,12 +173,33 @@ namespace Rokojori // ); var timeLine = TimeLineManager.Ensure( distortionScrollTimeLine ); - var scrollPosition = timeLine.position * distortionScroll; + var timelinePosition = timeLine.position; + + if ( distortionScrollFPS > 0f ) + { + float stepTime = 1.0f / distortionScrollFPS; + timelinePosition = MathX.SnapFloored( timelinePosition, stepTime ); + } + + var scrollPosition = timelinePosition * distortionScroll; + + + + scrollPosition.X = MathX.Repeat( scrollPosition.X, 1.0f ); scrollPosition.Y = MathX.Repeat( scrollPosition.Y, 1.0f ); var timeLineMask = TimeLineManager.Ensure( maskScrollTimeLine ); - var scrollPositionMask = timeLineMask.position * maskScroll; + + var timeLineMaskPosition = timeLineMask.position; + + if ( maskScrollFPS > 0f ) + { + float stepTime = 1.0f / maskScrollFPS; + timeLineMaskPosition = MathX.SnapFloored( timeLineMaskPosition, stepTime ); + } + + var scrollPositionMask = timeLineMaskPosition * maskScroll; scrollPositionMask.X = MathX.Repeat( scrollPositionMask.X, 1.0f ); scrollPositionMask.Y = MathX.Repeat( scrollPositionMask.Y, 1.0f ); diff --git a/Runtime/Rendering/Compositor/CompositorEffects/Outlines/DepthOutlines/DepthOutlinesEffect.cs b/Runtime/Rendering/Compositor/CompositorEffects/Outlines/DepthOutlines/DepthOutlinesEffect.cs new file mode 100644 index 0000000..c913f25 --- /dev/null +++ b/Runtime/Rendering/Compositor/CompositorEffects/Outlines/DepthOutlines/DepthOutlinesEffect.cs @@ -0,0 +1,204 @@ + +using Godot; +using System.Collections.Generic; + +namespace Rokojori +{ + [Tool] + [GlobalClass] + public partial class DepthOutlinesEffect:RDGraphCompositorEffect + { + public DepthOutlinesEffect():base() + { + Initialize(); + } + + [ExportGroup( "Main")] + [Export( PropertyHint.Range, "0,1") ] + public float amount = 1f; + + [Export] + public Color edgeColor = Colors.Black; + + [Export] + public Color fillColor = new Color( 1.0f, 1.0f, 1.0f, 0.0f ); + + [Export] + public Vector2 rimOffset = Vector2.Zero; + + [Export] + public float rimContrast = 1.0f; + + [Export( PropertyHint.Range, "0,1") ] + public float rimStrength = 1.0f; + + [Export( PropertyHint.Range, "0,1") ] + public float zEdgeAmount = 1f; + + [Export( PropertyHint.Range, "0,1") ] + public float normalEdgeAmount = 1f; + + [Export( PropertyHint.Range, "0,1") ] + public float normalEdgeAmountMin = 0.05f; + + [Export( PropertyHint.Range, "0,1") ] + public float normalEdgeAmountMax = 0.15f; + + [Export] + public float zTreshold = 0.1f; + + [Export] + public CurveTexture zTresholdCurve = new CurveTexture().WithCurve( new Curve().WithValues( 1, 1 ) ); + + [Export] + public float edgeIntensity = 1f; + + [Export] + public CurveTexture edgeIntensityCurve = new CurveTexture().WithCurve( new Curve().WithValues( 1, 1 ) ); + + [Export( PropertyHint.Range, "0,1") ] + public float adaptiveScaleAmount = 0.5f; + + [Export] + public float adaptiveScaleNormalizer = 1f; + + [Export ] + public Vector2 zInput = new Vector2( 0.1f, 4000f ); + + [Export ] + public Vector2 zOutput = new Vector2( 0f, 1f ); + + int _downSampling = 16; + + public enum DownSampling + { + _1x_, + _2x_, + _4x_, + _8x_, + _16x_, + _32x_ + } + + public int downSamplingRate => Mathf.RoundToInt( Mathf.Pow( 2, (int) downSampling ) ); + + [Export] + public DownSampling downSampling = DownSampling._4x_; + + + CEG_ScreenColorTexure screenColorTexture; + CEG_ScreenDepthTexture screenDepthTexture; + RG_ScreenNormalRoughnessTexture screenNormalRoughnessTexture; + CEG_BufferTexture bufferTexture; + RG_ImageTexture zTresholdTexture; + RG_ImageTexture edgeIntensityTexture; + RG_ImageTexture shadowTexture; + + RG_GenerateViewZ generateViewZ; + + + RG_ZOutlines zOutlines; + + + void Initialize() + { + screenColorTexture = new CEG_ScreenColorTexure( graph ); + screenDepthTexture = new CEG_ScreenDepthTexture( graph ); + screenNormalRoughnessTexture = new RG_ScreenNormalRoughnessTexture( graph ); + + bufferTexture = CEG_BufferTexture.ScreenSize( graph ); + zTresholdTexture = new RG_ImageTexture( graph ); + edgeIntensityTexture = new RG_ImageTexture( graph ); + + generateViewZ = new RG_GenerateViewZ( graph ); + + zOutlines = new RG_ZOutlines( graph ); + + + graph.InitializeNodes(); + + generateViewZ.SetTextureSlotInputs( screenDepthTexture, bufferTexture ); + generateViewZ.input.UseLinearSamplerEdgeClamped(); + + zOutlines.SetTextureSlotInputs( screenColorTexture, screenColorTexture ); + zOutlines.input.UseLinearSampler(); + + zOutlines.AddTextureSlotInput( bufferTexture ).UseLinearSamplerEdgeClamped(); + zOutlines.AddTextureSlotInput( zTresholdTexture ).UseLinearSamplerEdgeClamped(); + zOutlines.AddTextureSlotInput( edgeIntensityTexture ).UseLinearSamplerEdgeClamped(); + zOutlines.AddTextureSlotInput( screenNormalRoughnessTexture ).UseLinearSamplerEdgeClamped(); + + + + + graph.SetProcessOrder( + screenColorTexture, + screenDepthTexture, + screenNormalRoughnessTexture, + + bufferTexture, + zTresholdTexture, + edgeIntensityTexture, + + generateViewZ, + zOutlines + ); + + } + + + protected override void ForAllViews() + { + zTresholdTexture.SetImageTexture( zTresholdCurve ); + edgeIntensityTexture.SetImageTexture( edgeIntensityCurve ); + + var projection = context.GetCameraProjection().Inverse(); + + + generateViewZ.constants.Set( + projection.X, + projection.Y, + projection.Z, + projection.W, + + zInput.X, + zInput.Y, + zOutput.X, + zOutput.Y + ); + + zOutlines.constants.Set( + amount * edgeColor.A, + edgeColor.R, + edgeColor.G, + edgeColor.B, + + zInput.X, + zInput.Y, + zTreshold, + edgeIntensity, + + adaptiveScaleAmount, + adaptiveScaleNormalizer, + zEdgeAmount, + normalEdgeAmount, + + normalEdgeAmountMin, + normalEdgeAmountMax, + rimOffset.X, + rimOffset.Y, + + fillColor, + + rimContrast, + rimStrength, + 0f, + 0f + ); + + + } + + + } +} \ No newline at end of file diff --git a/Runtime/Rendering/Compositor/CompositorEffects/Outlines/DepthOutlines/DepthOutlinesEffect.cs.uid b/Runtime/Rendering/Compositor/CompositorEffects/Outlines/DepthOutlines/DepthOutlinesEffect.cs.uid new file mode 100644 index 0000000..64e1325 --- /dev/null +++ b/Runtime/Rendering/Compositor/CompositorEffects/Outlines/DepthOutlines/DepthOutlinesEffect.cs.uid @@ -0,0 +1 @@ +uid://bx4j8ic80vl7f diff --git a/Runtime/Rendering/Compositor/CompositorVFXPresets/Glow/Rainbow Star Glow.tres b/Runtime/Rendering/Compositor/CompositorVFXPresets/Glow/Rainbow Star Glow.tres index 344270e..e500f4b 100644 --- a/Runtime/Rendering/Compositor/CompositorVFXPresets/Glow/Rainbow Star Glow.tres +++ b/Runtime/Rendering/Compositor/CompositorVFXPresets/Glow/Rainbow Star Glow.tres @@ -1,4 +1,4 @@ -[gd_resource type="Resource" script_class="CompositorVFXPreset" load_steps=35 format=3 uid="uid://cxxb8xq3xpa6d"] +[gd_resource type="Resource" script_class="CompositorVFXPreset" load_steps=39 format=3 uid="uid://cxxb8xq3xpa6d"] [ext_resource type="Script" uid="uid://dvvfvlutisecy" path="res://addons/rokojori_action_library/Runtime/Rendering/Compositor/AnimationTargets/CompFXMemberCurveTarget.cs" id="1_e74ec"] [ext_resource type="Script" uid="uid://cx5qcow1mmd11" path="res://addons/rokojori_action_library/Runtime/Rendering/Compositor/CompositorEffectReferences/CompositorEffectOwner.cs" id="2_bfksq"] @@ -10,6 +10,14 @@ [ext_resource type="Script" uid="uid://pevgspwywsxi" path="res://addons/rokojori_action_library/Runtime/Rendering/Compositor/CompositorEffects/HSLAdjustment/HSLAdjustmentEffect.cs" id="8_bfeok"] [ext_resource type="Script" uid="uid://ckixweetchlo0" path="res://addons/rokojori_action_library/Runtime/Rendering/Compositor/CompositorEffectReferences/CompositorVFXPreset.cs" id="9_fgrt2"] +[sub_resource type="Curve" id="Curve_e74ec"] +_data = [Vector2(0, 0), 0.0, 0.0, 0, 0, Vector2(1, 1), 0.0, 0.0, 0, 0] +point_count = 2 + +[sub_resource type="CurveTexture" id="CurveTexture_bfksq"] +texture_mode = 1 +curve = SubResource("Curve_e74ec") + [sub_resource type="Curve" id="Curve_xhmdb"] _data = [Vector2(0, 0), 0.0, 0.24930753, 0, 0, Vector2(1, 0.5578947), 0.5578947, 0.0, 1, 0] point_count = 2 @@ -54,10 +62,19 @@ overlayTint = Color(1, 1, 1, 0.050980393) tiling = Vector2(9, 5.0625) scrolling = Vector2(0.22, 0.012) maskTexture = SubResource("GradientTexture2D_cqn6v") +alphaMapping = SubResource("CurveTexture_bfksq") animationTargets = [SubResource("Resource_jdtjt")] compositorEffectID = SubResource("Resource_5jnfl") metadata/_custom_type_script = "uid://t5g1g1uv5yrj" +[sub_resource type="Curve" id="Curve_eyvih"] +_data = [Vector2(0, 0), 0.0, 0.0, 0, 0, Vector2(1, 1), 0.0, 0.0, 0, 0] +point_count = 2 + +[sub_resource type="CurveTexture" id="CurveTexture_chktd"] +texture_mode = 1 +curve = SubResource("Curve_eyvih") + [sub_resource type="Resource" id="Resource_86qek"] script = ExtResource("1_e74ec") member = "opacity" @@ -92,6 +109,7 @@ overlayTint = Color(1, 1, 1, 0.21568628) tiling = Vector2(1, 0.5625) scrolling = Vector2(-0.1, -0.01) maskTexture = SubResource("GradientTexture2D_su8gi") +alphaMapping = SubResource("CurveTexture_chktd") animationTargets = [SubResource("Resource_86qek")] compositorEffectID = SubResource("Resource_qf8q3") metadata/_custom_type_script = "uid://t5g1g1uv5yrj" diff --git a/Runtime/Rendering/Compositor/CompositorVFXPresets/Physical/Frozen Ice.tres b/Runtime/Rendering/Compositor/CompositorVFXPresets/Physical/Frozen Ice.tres index 1a50615..489b4bb 100644 --- a/Runtime/Rendering/Compositor/CompositorVFXPresets/Physical/Frozen Ice.tres +++ b/Runtime/Rendering/Compositor/CompositorVFXPresets/Physical/Frozen Ice.tres @@ -1,4 +1,4 @@ -[gd_resource type="Resource" script_class="CompositorVFXPreset" load_steps=39 format=3 uid="uid://c5qouanne0mar"] +[gd_resource type="Resource" script_class="CompositorVFXPreset" load_steps=43 format=3 uid="uid://c5qouanne0mar"] [ext_resource type="Script" uid="uid://dvvfvlutisecy" path="res://addons/rokojori_action_library/Runtime/Rendering/Compositor/AnimationTargets/CompFXMemberCurveTarget.cs" id="1_dw6h6"] [ext_resource type="Script" uid="uid://cx5qcow1mmd11" path="res://addons/rokojori_action_library/Runtime/Rendering/Compositor/CompositorEffectReferences/CompositorEffectOwner.cs" id="2_dsqqr"] @@ -8,6 +8,14 @@ [ext_resource type="Script" uid="uid://pevgspwywsxi" path="res://addons/rokojori_action_library/Runtime/Rendering/Compositor/CompositorEffects/HSLAdjustment/HSLAdjustmentEffect.cs" id="6_vhp5e"] [ext_resource type="Script" uid="uid://ckixweetchlo0" path="res://addons/rokojori_action_library/Runtime/Rendering/Compositor/CompositorEffectReferences/CompositorVFXPreset.cs" id="7_ibrjq"] +[sub_resource type="Curve" id="Curve_q52cp"] +_data = [Vector2(0, 0), 0.0, 0.0, 0, 0, Vector2(1, 1), 0.0, 0.0, 0, 0] +point_count = 2 + +[sub_resource type="CurveTexture" id="CurveTexture_ba71q"] +texture_mode = 1 +curve = SubResource("Curve_q52cp") + [sub_resource type="Curve" id="Curve_uhxun"] _limits = [0.0, 0.5, 0.0, 1.0] _data = [Vector2(0, 0), 0.0, 0.79, 0, 0, Vector2(1, 0.5), 0.5, -0.9409129, 0, 0] @@ -68,6 +76,7 @@ tiling = Vector2(2.4045, 2.349) offset = Vector2(-0.1725, 0) scrolling = Vector2(0, 0.03) maskTexture = SubResource("GradientTexture2D_ls5mq") +alphaMapping = SubResource("CurveTexture_ba71q") maskOverlayConversion = 0 screenConversion = 1 outputConversion = 2 @@ -130,6 +139,14 @@ animationTargets = [SubResource("Resource_f0pyq")] compositorEffectID = SubResource("Resource_msay1") metadata/_custom_type_script = "uid://balixgskgouhm" +[sub_resource type="Curve" id="Curve_fumfa"] +_data = [Vector2(0, 0), 0.0, 0.0, 0, 0, Vector2(1, 1), 0.0, 0.0, 0, 0] +point_count = 2 + +[sub_resource type="CurveTexture" id="CurveTexture_e3oac"] +texture_mode = 1 +curve = SubResource("Curve_fumfa") + [sub_resource type="Curve" id="Curve_cqn6v"] _data = [Vector2(0, 0), 0.0, 0.09, 0, 0, Vector2(0.507177, 0), 0.0, 0.0, 0, 0, Vector2(0.76076555, 0.19999993), 0.95000005, 0.95000005, 0, 0, Vector2(1, 1), 3.1777756, 0.0, 0, 0] point_count = 4 @@ -185,6 +202,7 @@ overlayConversion = 0 tiling = Vector2(2.4045, 2.349) offset = Vector2(-0.1725, 0) maskTexture = SubResource("GradientTexture2D_n0rnh") +alphaMapping = SubResource("CurveTexture_e3oac") maskOverlayConversion = 0 screenConversion = 1 outputConversion = 2 diff --git a/Runtime/Rendering/Compositor/CompositorVFXPresets/Screen/Analog Tube TV .tres b/Runtime/Rendering/Compositor/CompositorVFXPresets/Screen/Analog Tube TV .tres index 4f6fb43..6938de7 100644 --- a/Runtime/Rendering/Compositor/CompositorVFXPresets/Screen/Analog Tube TV .tres +++ b/Runtime/Rendering/Compositor/CompositorVFXPresets/Screen/Analog Tube TV .tres @@ -27,7 +27,7 @@ script = ExtResource("2_uexx8") script = ExtResource("3_qf8os") owner = SubResource("Resource_4n83u") -[sub_resource type="CompositorEffect" id="CompositorEffect_btbfg"] +[sub_resource type="CompositorEffect" id="CompositorEffect_075h3"] resource_local_to_scene = false resource_name = "" enabled = true @@ -64,7 +64,7 @@ curve = SubResource("Curve_pl7u1") script = ExtResource("3_qf8os") owner = SubResource("Resource_4n83u") -[sub_resource type="CompositorEffect" id="CompositorEffect_ixqtu"] +[sub_resource type="CompositorEffect" id="CompositorEffect_cf0ae"] resource_local_to_scene = false resource_name = "" enabled = true @@ -116,7 +116,7 @@ gradient = SubResource("Gradient_gwku0") fill = 1 fill_from = Vector2(0.36796537, 0.47619048) -[sub_resource type="CompositorEffect" id="CompositorEffect_m7r8b"] +[sub_resource type="CompositorEffect" id="CompositorEffect_jspws"] resource_local_to_scene = false resource_name = "" enabled = true @@ -167,7 +167,7 @@ gradient = SubResource("Gradient_jyu1d") fill = 1 fill_from = Vector2(0.36796537, 0.47619048) -[sub_resource type="CompositorEffect" id="CompositorEffect_ie6m2"] +[sub_resource type="CompositorEffect" id="CompositorEffect_g7lvo"] resource_local_to_scene = false resource_name = "" enabled = true @@ -218,7 +218,7 @@ curve_x = SubResource("Curve_r14qv") curve_y = SubResource("Curve_mcvtj") curve_z = SubResource("Curve_ju6hd") -[sub_resource type="CompositorEffect" id="CompositorEffect_p64cs"] +[sub_resource type="CompositorEffect" id="CompositorEffect_pcye7"] resource_local_to_scene = false resource_name = "" enabled = true @@ -234,5 +234,5 @@ metadata/_custom_type_script = "uid://v8yddy4erbru" [resource] script = ExtResource("8_l3sri") -effects = [SubResource("CompositorEffect_btbfg"), SubResource("CompositorEffect_ixqtu"), SubResource("CompositorEffect_m7r8b"), SubResource("CompositorEffect_ie6m2"), SubResource("CompositorEffect_p64cs")] +effects = [SubResource("CompositorEffect_075h3"), SubResource("CompositorEffect_cf0ae"), SubResource("CompositorEffect_jspws"), SubResource("CompositorEffect_g7lvo"), SubResource("CompositorEffect_pcye7")] metadata/_custom_type_script = "uid://ckixweetchlo0" diff --git a/Runtime/Rendering/Compositor/CompositorVFXPresets/Screen/Sketch.tres b/Runtime/Rendering/Compositor/CompositorVFXPresets/Screen/Sketch.tres new file mode 100644 index 0000000..ca92a0d --- /dev/null +++ b/Runtime/Rendering/Compositor/CompositorVFXPresets/Screen/Sketch.tres @@ -0,0 +1,159 @@ +[gd_resource type="Resource" script_class="CompositorVFXPreset" load_steps=30 format=3 uid="uid://0blw3yhjw7y0"] + +[ext_resource type="Script" uid="uid://cx5qcow1mmd11" path="res://addons/rokojori_action_library/Runtime/Rendering/Compositor/CompositorEffectReferences/CompositorEffectOwner.cs" id="1_0ail8"] +[ext_resource type="Script" uid="uid://dvvfvlutisecy" path="res://addons/rokojori_action_library/Runtime/Rendering/Compositor/AnimationTargets/CompFXMemberCurveTarget.cs" id="1_4xviq"] +[ext_resource type="Script" uid="uid://comuvej4dr22k" path="res://addons/rokojori_action_library/Runtime/Rendering/Compositor/CompositorEffectReferences/RokojoriCompositorEffectID.cs" id="2_tc21q"] +[ext_resource type="Script" uid="uid://bx4j8ic80vl7f" path="res://addons/rokojori_action_library/Runtime/Rendering/Compositor/CompositorEffects/Outlines/DepthOutlines/DepthOutlinesEffect.cs" id="3_dryyw"] +[ext_resource type="Texture2D" uid="uid://c30nul6romace" path="res://addons/rokojori_action_library/Runtime/Procedural/Noise/RGB 3D Noise.png" id="5_orb2s"] +[ext_resource type="Script" uid="uid://balixgskgouhm" path="res://addons/rokojori_action_library/Runtime/Rendering/Compositor/CompositorEffects/Distortion/TextureDistortion/TextureDistortionEffect.cs" id="6_hdnet"] +[ext_resource type="Script" uid="uid://ckixweetchlo0" path="res://addons/rokojori_action_library/Runtime/Rendering/Compositor/CompositorEffectReferences/CompositorVFXPreset.cs" id="6_orb2s"] + +[sub_resource type="Curve" id="Curve_btbfg"] +_data = [Vector2(0, 0), 0.0, 1.0, 0, 1, Vector2(1, 1), 1.0, 0.0, 1, 0] +point_count = 2 + +[sub_resource type="Resource" id="Resource_7axlu"] +script = ExtResource("1_4xviq") +member = "amount" +curve = SubResource("Curve_btbfg") +metadata/_custom_type_script = "uid://dvvfvlutisecy" + +[sub_resource type="Resource" id="Resource_ie6m2"] +script = ExtResource("1_0ail8") + +[sub_resource type="Resource" id="Resource_p64cs"] +script = ExtResource("2_tc21q") +owner = SubResource("Resource_ie6m2") + +[sub_resource type="Curve" id="Curve_7axlu"] +_data = [Vector2(0, 1), 0.0, -4.442954, 0, 0, Vector2(0.1704918, 0.36258066), -0.7034676, -0.7034676, 0, 0, Vector2(1, 0), -0.043128554, 0.0, 0, 0] +point_count = 3 + +[sub_resource type="CurveTexture" id="CurveTexture_i5utj"] +curve = SubResource("Curve_7axlu") + +[sub_resource type="Curve" id="Curve_22k1k"] +_data = [Vector2(0, 0), 0.0, 0.19326083, 0, 0, Vector2(1, 1), 0.26667082, 0.0, 0, 0] +point_count = 2 + +[sub_resource type="CurveTexture" id="CurveTexture_hpfyh"] +curve = SubResource("Curve_22k1k") + +[sub_resource type="CompositorEffect" id="CompositorEffect_ie6m2"] +resource_local_to_scene = false +resource_name = "" +enabled = true +effect_callback_type = 4 +needs_motion_vectors = false +needs_normal_roughness = false +script = ExtResource("3_dryyw") +edgeColor = Color(0.06552577, 0.040088717, 0.048853662, 0.9372549) +fillColor = Color(0.2, 0.2, 0.2, 0) +rimOffset = Vector2(0.001, -0.0051) +rimContrast = 0.0036 +normalEdgeAmountMin = 0.006 +normalEdgeAmountMax = 0.0215 +zTreshold = 0.3875 +zTresholdCurve = SubResource("CurveTexture_hpfyh") +edgeIntensity = 10.0 +edgeIntensityCurve = SubResource("CurveTexture_i5utj") +adaptiveScaleAmount = 0.1445 +adaptiveScaleNormalizer = 0.1 +zInput = Vector2(0.1, 500) +animationTargets = [SubResource("Resource_7axlu")] +compositorEffectID = SubResource("Resource_p64cs") +metadata/_custom_type_script = "uid://bx4j8ic80vl7f" + +[sub_resource type="Curve" id="Curve_sw5v3"] +_data = [Vector2(0, 0), 0.0, 0.0, 0, 0, Vector2(1, 1), 0.0, 0.0, 0, 0] +point_count = 2 + +[sub_resource type="Resource" id="Resource_63qv8"] +script = ExtResource("1_4xviq") +member = "blendAmount" +curve = SubResource("Curve_sw5v3") +metadata/_custom_type_script = "uid://dvvfvlutisecy" + +[sub_resource type="Resource" id="Resource_hpfyh"] +script = ExtResource("2_tc21q") +owner = SubResource("Resource_ie6m2") + +[sub_resource type="Gradient" id="Gradient_frwbc"] +offsets = PackedFloat32Array(1) +colors = PackedColorArray(1, 1, 1, 1) + +[sub_resource type="GradientTexture2D" id="GradientTexture2D_w6tyf"] +gradient = SubResource("Gradient_frwbc") + +[sub_resource type="CompositorEffect" id="CompositorEffect_i5utj"] +resource_local_to_scene = false +resource_name = "" +enabled = true +effect_callback_type = 4 +needs_motion_vectors = false +needs_normal_roughness = false +script = ExtResource("6_hdnet") +distortionAmount = 0.0049 +smearingSteps = 1 +smearing = 1.0 +redShift = 0.0 +distortionTexture = ExtResource("5_orb2s") +distortionTiling = Vector2(0.01, 0.01) +distortionOffset = Vector2(0.573, 0) +distortionScroll = Vector2(0.32, 1.107) +distortionScrollFPS = 3.0 +maskTexture = SubResource("GradientTexture2D_w6tyf") +animationTargets = [SubResource("Resource_63qv8")] +compositorEffectID = SubResource("Resource_hpfyh") +metadata/_custom_type_script = "uid://balixgskgouhm" + +[sub_resource type="Curve" id="Curve_4n83u"] +_data = [Vector2(0, 0), 0.0, 0.0, 0, 0, Vector2(1, 1), 0.0, 0.0, 0, 0] +point_count = 2 + +[sub_resource type="Resource" id="Resource_ixn1d"] +script = ExtResource("1_4xviq") +member = "blendAmount" +curve = SubResource("Curve_4n83u") +metadata/_custom_type_script = "uid://dvvfvlutisecy" + +[sub_resource type="Resource" id="Resource_gxlxg"] +script = ExtResource("2_tc21q") +owner = SubResource("Resource_ie6m2") + +[sub_resource type="CompressedTexture2D" id="CompressedTexture2D_4n83u"] +load_path = "res://.godot/imported/RGB 3D Noise.png-daebfe00d2f3fcd5d3bc528f8a3972e1.ctex" + +[sub_resource type="Gradient" id="Gradient_72jau"] +offsets = PackedFloat32Array(1) +colors = PackedColorArray(1, 1, 1, 1) + +[sub_resource type="GradientTexture2D" id="GradientTexture2D_ixn1d"] +gradient = SubResource("Gradient_72jau") + +[sub_resource type="CompositorEffect" id="CompositorEffect_22k1k"] +resource_local_to_scene = false +resource_name = "" +enabled = true +effect_callback_type = 4 +needs_motion_vectors = false +needs_normal_roughness = false +script = ExtResource("6_hdnet") +distortionAmount = 0.0026 +smearingSteps = 1 +smearing = 1.0 +redShift = 0.0 +distortionTexture = SubResource("CompressedTexture2D_4n83u") +distortionTiling = Vector2(0.1, 0.1) +distortionOffset = Vector2(0.573, 0) +distortionScroll = Vector2(0.123, 1.107) +distortionScrollFPS = 6.0 +maskTexture = SubResource("GradientTexture2D_ixn1d") +animationTargets = [SubResource("Resource_ixn1d")] +compositorEffectID = SubResource("Resource_gxlxg") +metadata/_custom_type_script = "uid://balixgskgouhm" + +[resource] +script = ExtResource("6_orb2s") +effects = [SubResource("CompositorEffect_ie6m2"), SubResource("CompositorEffect_i5utj"), SubResource("CompositorEffect_22k1k")] +metadata/_custom_type_script = "uid://ckixweetchlo0" diff --git a/Runtime/Rendering/Compositor/RokojoriCompositorEffect.cs b/Runtime/Rendering/Compositor/RokojoriCompositorEffect.cs index 5de73d5..cf42479 100644 --- a/Runtime/Rendering/Compositor/RokojoriCompositorEffect.cs +++ b/Runtime/Rendering/Compositor/RokojoriCompositorEffect.cs @@ -1,5 +1,6 @@ using Godot; +using Rokojori.Tools; using System.Collections.Generic; namespace Rokojori @@ -7,7 +8,7 @@ namespace Rokojori [Tool] [GlobalClass] public abstract partial class RokojoriCompositorEffect:CompositorEffect - { + { [ExportGroup("Animation Targets")] [Export] public RokojoriCompositorEffectAnimationTarget[] animationTargets = []; @@ -19,6 +20,19 @@ namespace Rokojori [ExportToolButton( "Clear Caches" )] public Callable clearCachesButton => Callable.From( ()=> ClearCaches() ); + [ExportToolButton( "Analyse Object" )] + public Callable analyseObject => Callable.From( + ()=> + { + #if TOOLS + var stats = ObjectGraphInspector.Inspect( this ); + + this.LogInfo( stats ); + + #endif + } + ); + public static readonly string effectsPath = "res://addons/rokojori_action_library/Runtime/Rendering/Compositor/CompositorEffects"; public static string Path( string path ) { diff --git a/Runtime/Rendering/Context/RDContext.CleanUp.cs b/Runtime/Rendering/Context/RDContext.CleanUp.cs index c19f347..690ee41 100644 --- a/Runtime/Rendering/Context/RDContext.CleanUp.cs +++ b/Runtime/Rendering/Context/RDContext.CleanUp.cs @@ -9,6 +9,8 @@ namespace Rokojori { protected List _cleanUps = new List(); protected List _cleanUpInfo = new List(); + protected HashSet _idMap = new HashSet(); + protected bool cleanAll = false; @@ -39,6 +41,8 @@ namespace Rokojori } Verbose( "Cleaning up: ", info, ro.rid ); + + _idMap.Remove( ro.GetHashID() ); ro.Free( this ); } @@ -101,15 +105,19 @@ namespace Rokojori Free(); } + + + public void AddToCleanUp( RDObject ro, string info = null ) { - if ( _cleanUps.Contains( ro ) ) + if ( _idMap.Contains( ro.GetHashID() ) ) { return; } _cleanUps.Add( ro ); _cleanUpInfo.Add( info ); + _idMap.Add( ro.GetHashID() ); } public void AddToCleanUp( List ro, string info = null ) diff --git a/Runtime/Rendering/Context/RDContext.cs b/Runtime/Rendering/Context/RDContext.cs index f370506..fa2dbb7 100644 --- a/Runtime/Rendering/Context/RDContext.cs +++ b/Runtime/Rendering/Context/RDContext.cs @@ -162,12 +162,12 @@ namespace Rokojori if ( sampler == null ) { - // effect.Verbose( "Adding Image" ); + // RJLog.Log( "Adding Image" ); AddUniformSet( RDUniformSet.Image( this, texture, setIndex ) ); } else { - // effect.Verbose( "Adding Sampler" ); + // RJLog.Log( "Adding Sampler" ); AddUniformSet( RDUniformSet.Sampler( this, sampler,texture, setIndex ) ); } } @@ -197,6 +197,7 @@ namespace Rokojori } else { + RJLog.Log( "Creating uncached uniform", array ); return renderingDevice.UniformSetCreate( array, shader.rid, (uint) index ); } @@ -306,6 +307,7 @@ namespace Rokojori _uniformSets.ForEach( ( u )=> { + // RJLog.Log( "Binding Uniform Set:", u.rid ); computeList.BindUniformSet( u, u.setIndex ); } ); diff --git a/Runtime/Rendering/Objects/RDObject.cs b/Runtime/Rendering/Objects/RDObject.cs index d8d6ac1..e0d928d 100644 --- a/Runtime/Rendering/Objects/RDObject.cs +++ b/Runtime/Rendering/Objects/RDObject.cs @@ -14,6 +14,11 @@ namespace Rokojori protected bool _isDestroyed = false; public bool valid => ! _isDestroyed && _context != null && _rid.IsValid; + public string GetHashID() + { + return GetType().Name + "_" + rid.Id; + } + public RDObject( RDContext context, Rid rid ) { _context = context; diff --git a/Runtime/Rendering/RenderGraph/Nodes/Processors/Depth/GenerateViewZ/GenerateViewZ.glsl b/Runtime/Rendering/RenderGraph/Nodes/Processors/Depth/GenerateViewZ/GenerateViewZ.glsl new file mode 100644 index 0000000..213d6da --- /dev/null +++ b/Runtime/Rendering/RenderGraph/Nodes/Processors/Depth/GenerateViewZ/GenerateViewZ.glsl @@ -0,0 +1,288 @@ +#[compute] +#version 450 + +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 ) ); +} + +vec3 applyMatrix( vec3 v, mat4 m ) +{ + return ( m * vec4( v, 1.0 ) ).xyz; +} + +vec3 applyMatrixWithoutTranslation( vec3 v, mat4 m ) +{ + return ( m * vec4( v, 0.0 ) ).xyz; +} + +vec3 applyMatrix( vec3 v, mat3 m ) +{ + return ( m * v ).xyz; +} + + +vec3 localToWorld( vec3 local, mat4 _MODEL_MATRIX ) +{ + return applyMatrix( local, _MODEL_MATRIX ); +} + +vec3 localToWorldDirection( vec3 local, mat4 _MODEL_MATRIX ) +{ + return applyMatrixWithoutTranslation( local, _MODEL_MATRIX ); +} + +vec3 localToView( vec3 local, mat4 _MODELVIEW_MATRIX ) +{ + return applyMatrix( local, _MODELVIEW_MATRIX ); +} + +vec3 localToViewDirection( vec3 local, mat4 _MODELVIEW_MATRIX ) +{ + return applyMatrixWithoutTranslation( local, _MODELVIEW_MATRIX ); +} + +vec3 localToViewDirection( vec3 local, mat3 _MODELVIEW_NORMAL_MATRIX ) +{ + return applyMatrix( local, _MODELVIEW_NORMAL_MATRIX ); +} + +vec3 worldToLocal( vec3 world, mat4 _MODEL_MATRIX ) +{ + mat4 inversedMatrix = inverse( _MODEL_MATRIX ); + return applyMatrix( world, inversedMatrix ); +} + +vec3 worldToLocalDirection( vec3 world, mat4 _MODEL_MATRIX ) +{ + mat4 inversedMatrix = inverse( _MODEL_MATRIX ); + return applyMatrixWithoutTranslation( world, inversedMatrix ); +} + + +vec3 worldToView( vec3 world, mat4 _VIEW_MATRIX ) +{ + return applyMatrix( world, _VIEW_MATRIX ); +} + +vec3 worldToViewDirection( vec3 worldDirection, mat4 _VIEW_MATRIX ) +{ + return applyMatrixWithoutTranslation( worldDirection, _VIEW_MATRIX ); +} + +vec3 viewToWorld( vec3 view, mat4 _INV_VIEW_MATRIX ) +{ + return applyMatrix( view, _INV_VIEW_MATRIX ); +} + +vec3 viewToWorldDirection( vec3 viewDirection, mat4 _INV_VIEW_MATRIX ) +{ + return applyMatrixWithoutTranslation( viewDirection, _INV_VIEW_MATRIX ); +} + +vec3 viewToLocal( vec3 view, mat4 _INV_VIEW_MATRIX, mat4 _MODEL_MATRIX ) +{ + vec3 world = viewToWorld( view, _INV_VIEW_MATRIX ); + return worldToLocal( world, _MODEL_MATRIX ); +} + +vec3 viewToLocal( vec3 view, mat4 _MODELVIEW_MATRIX ) +{ + mat4 inversedMatrix = inverse( _MODELVIEW_MATRIX ); + return applyMatrix( view, inversedMatrix ); +} + +vec3 viewToLocalDirection( vec3 viewDirection, mat4 _MODELVIEW_MATRIX ) +{ + mat4 inversedMatrix = inverse( _MODELVIEW_MATRIX ); + return applyMatrixWithoutTranslation( viewDirection, inversedMatrix ); +} + +vec3 viewToLocalDirection( vec3 view, mat4 _INV_VIEW_MATRIX, mat4 _MODEL_MATRIX ) +{ + vec3 world = viewToWorldDirection( view, _INV_VIEW_MATRIX ); + return worldToLocalDirection( world, _MODEL_MATRIX ); +} + +vec4 viewToClip( vec3 view, mat4 _PROJECTION_MATRIX ) +{ + vec4 clip = _PROJECTION_MATRIX * vec4( view, 1.0 ); + clip /= clip.w; + return clip; +} + +vec2 clipToScreen( vec4 clip ) +{ + return ( clip.xy / clip.w ) * 0.5 + vec2( 0.5 ); +} + +vec4 screenToClip( vec2 screen, float z ) +{ + return vec4( screen * 2.0 - 1.0, z, 1.0 ); +} + +vec4 clipToView( vec4 clip, mat4 _INV_PROJECTION_MATRIX ) +{ + vec4 view = _INV_PROJECTION_MATRIX * clip; + view /= view.w; + return view; +} + +vec4 screenToView( vec2 screen, float z, mat4 _INV_PROJECTION_MATRIX ) +{ + vec4 clip = screenToClip( screen, z ); + vec4 view = clipToView( clip, _INV_PROJECTION_MATRIX ); + + return view; +} + +vec3 screenToWorld( vec2 screen, float z, mat4 _INV_PROJECTION_MATRIX, mat4 _INV_VIEW_MATRIX ) +{ + vec4 view = screenToView( screen, z, _INV_PROJECTION_MATRIX ); + + return viewToWorld( view.xyz, _INV_VIEW_MATRIX ); +} + +vec3 screenToLocal( vec2 screen_point, float z, mat4 _PROJECTION_MATRIX, mat4 _VIEW_MATRIX, mat4 _MODEL_MATRIX ) +{ + vec4 clip = vec4( screen_point * 2.0 - 1.0, z, 1.0 ); + vec4 view4 = inverse( _PROJECTION_MATRIX ) * clip; + view4 /= view4.w; + vec3 view = view4.xyz; + mat4 m = inverse( _VIEW_MATRIX * _MODEL_MATRIX ); + return ( m * vec4( view, 1.0 ) ).xyz; +} + +vec2 viewToScreen( vec3 view, mat4 _PROJECTION_MATRIX ) +{ + vec4 clip = viewToClip( view, _PROJECTION_MATRIX ); + + return clipToScreen( clip ); +} + +vec2 localToScreen( vec3 local, mat4 _MODELVIEW_MATRIX, mat4 _PROJECTION_MATRIX ) +{ + vec3 view = localToView( local, _MODELVIEW_MATRIX ); + return viewToScreen( view, _PROJECTION_MATRIX ); +} + +vec2 worldToScreen( vec3 world, mat4 _VIEW_MATRIX, mat4 _PROJECTION_MATRIX ) +{ + vec3 view = worldToView( world, _VIEW_MATRIX ); + vec4 clip = viewToClip( view, _PROJECTION_MATRIX ); + vec2 screen = clipToScreen( clip ); + + return screen; +} + + +vec3 extractTranslation( mat4 matrix ) +{ + return vec3( matrix[ 3 ][ 0 ], matrix[ 3 ][ 1 ], matrix[ 3 ][ 2 ] ); +} + +vec3 extractScale( mat3 matrix ) +{ + mat3 m = matrix; + + float x = length( vec3( m[ 0 ][ 0 ], m[ 1 ][ 0 ], m[ 2 ][ 0 ] ) ); + float y = length( vec3( m[ 0 ][ 1 ], m[ 1 ][ 1 ], m[ 2 ][ 1 ] ) ); + float z = length( vec3( m[ 0 ][ 2 ], m[ 1 ][ 2 ], m[ 2 ][ 2 ] ) ); + + return vec3( x, y, z ); +} + +vec3 extractScale( mat4 matrix ) +{ + mat4 m = matrix; + + float x = length( vec3( m[ 0 ][ 0 ], m[ 1 ][ 0 ], m[ 2 ][ 0 ] ) ); + float y = length( vec3( m[ 0 ][ 1 ], m[ 1 ][ 1 ], m[ 2 ][ 1 ] ) ); + float z = length( vec3( m[ 0 ][ 2 ], m[ 1 ][ 2 ], m[ 2 ][ 2 ] ) ); + + return vec3( x, y, z ); +} + +mat3 extractRotationMatrix( mat4 m ) +{ + vec3 x = normalize( m[ 0 ].xyz ); + vec3 y = normalize( m[ 1 ].xyz ); + vec3 z = normalize( m[ 2 ].xyz ); + + return mat3( x, y, z ); +} + + +layout( local_size_x = 8, local_size_y = 8, local_size_z = 1 ) in; + +layout( set = 0, binding = 0 ) +uniform sampler2D depthSampler; + +layout( rgba16, set = 1, binding = 0 ) +uniform restrict writeonly image2D outputImage; + + +layout( push_constant, std430 ) +uniform Parameters +{ + vec4 m0; + vec4 m1; + vec4 m2; + vec4 m3; + + float inputZMin; + float inputZMax; + float outputZMin; + float outputZMax; + +} parameters; + +float getZ( vec2 uv, float depth, mat4 INV_PROJ ) +{ + vec4 position = screenToView( uv, depth, INV_PROJ ); + return max( 0.0, -position.z ); +} + +void main() +{ + ivec2 size = imageSize( outputImage ); + ivec2 xy = ivec2( gl_GlobalInvocationID.xy ); + + if ( any( greaterThanEqual( xy, size ) ) ) + { + return; + } + + vec2 uv = ( vec2( xy ) + vec2( 0.5 ) ) / vec2( size ); + + mat4 INV_PROJ = mat4( parameters.m0, parameters.m1, parameters.m2, parameters.m3 ); + + float depth = texture( depthSampler, uv ).r; + float z = getZ( uv, depth, INV_PROJ ); + + float mappedZ = mapClamped( z, parameters.inputZMin, parameters.inputZMax, parameters.outputZMin, parameters.outputZMax ); + + vec4 color = vec4( mappedZ, mappedZ, mappedZ, 1.0 ); + + imageStore( outputImage, xy, color ); +} diff --git a/Runtime/Rendering/RenderGraph/Nodes/Processors/Depth/GenerateViewZ/GenerateViewZ.glsl.import b/Runtime/Rendering/RenderGraph/Nodes/Processors/Depth/GenerateViewZ/GenerateViewZ.glsl.import new file mode 100644 index 0000000..798a6e7 --- /dev/null +++ b/Runtime/Rendering/RenderGraph/Nodes/Processors/Depth/GenerateViewZ/GenerateViewZ.glsl.import @@ -0,0 +1,14 @@ +[remap] + +importer="glsl" +type="RDShaderFile" +uid="uid://b0xhtwfgbns80" +path="res://.godot/imported/GenerateViewZ.glsl-d8251609930fa7083fc7c876024fa644.res" + +[deps] + +source_file="res://addons/rokojori_action_library/Runtime/Rendering/RenderGraph/Nodes/Processors/Depth/GenerateViewZ/GenerateViewZ.glsl" +dest_files=["res://.godot/imported/GenerateViewZ.glsl-d8251609930fa7083fc7c876024fa644.res"] + +[params] + diff --git a/Runtime/Rendering/RenderGraph/Nodes/Processors/Depth/GenerateViewZ/RG_GenerateViewZ.cs b/Runtime/Rendering/RenderGraph/Nodes/Processors/Depth/GenerateViewZ/RG_GenerateViewZ.cs new file mode 100644 index 0000000..6901579 --- /dev/null +++ b/Runtime/Rendering/RenderGraph/Nodes/Processors/Depth/GenerateViewZ/RG_GenerateViewZ.cs @@ -0,0 +1,17 @@ + +using Godot; +using System.Collections.Generic; + +namespace Rokojori +{ + public class RG_GenerateViewZ:CEG_ImageProcessor + { + public static readonly string shaderPath = + RDGraph.Path( "Nodes/Processors/Depth/GenerateViewZ/GenerateViewZ.glsl" ); + + public RG_GenerateViewZ( RDGraph graph ):base( graph, shaderPath ) + {} + + + } +} \ No newline at end of file diff --git a/Runtime/Rendering/RenderGraph/Nodes/Processors/Depth/GenerateViewZ/RG_GenerateViewZ.cs.uid b/Runtime/Rendering/RenderGraph/Nodes/Processors/Depth/GenerateViewZ/RG_GenerateViewZ.cs.uid new file mode 100644 index 0000000..3bb5c8f --- /dev/null +++ b/Runtime/Rendering/RenderGraph/Nodes/Processors/Depth/GenerateViewZ/RG_GenerateViewZ.cs.uid @@ -0,0 +1 @@ +uid://bri4ks4qa50oc diff --git a/Runtime/Rendering/RenderGraph/Nodes/Processors/Generic/CEG_ImageProcessor.cs b/Runtime/Rendering/RenderGraph/Nodes/Processors/Generic/CEG_ImageProcessor.cs index d60ae94..0796ab5 100644 --- a/Runtime/Rendering/RenderGraph/Nodes/Processors/Generic/CEG_ImageProcessor.cs +++ b/Runtime/Rendering/RenderGraph/Nodes/Processors/Generic/CEG_ImageProcessor.cs @@ -30,12 +30,14 @@ namespace Rokojori imageProcessorBefore.output.ConnectTo( output ); } - public void AddTextureSlotInput( RDGraphTextureSlotInput inputSlot, CompositorEffectGraphTextureSlot slot = null ) + public CompositorEffectGraphTextureSlot AddTextureSlotInput( RDGraphTextureSlotInput inputSlot, CompositorEffectGraphTextureSlot slot = null ) { slot = slot != null ? slot : new CompositorEffectGraphTextureSlot( this ); _textureSlots.Add( slot ); inputSlot.ConnectTo( slot ); + + return slot; } public void AddSampledTextureSlotInput( RDGraphTextureSlotInput inputSlot, RenderingDevice.SamplerFilter filter = RenderingDevice.SamplerFilter.Linear, RenderingDevice.SamplerRepeatMode repeatMode = RenderingDevice.SamplerRepeatMode.Repeat ) @@ -46,6 +48,7 @@ namespace Rokojori inputSlot.ConnectTo( slot ); } + } } \ No newline at end of file diff --git a/Runtime/Rendering/RenderGraph/Nodes/Processors/Generic/RG_ScreenNormalRoughnessTexture.cs b/Runtime/Rendering/RenderGraph/Nodes/Processors/Generic/RG_ScreenNormalRoughnessTexture.cs new file mode 100644 index 0000000..9906dce --- /dev/null +++ b/Runtime/Rendering/RenderGraph/Nodes/Processors/Generic/RG_ScreenNormalRoughnessTexture.cs @@ -0,0 +1,52 @@ + +using Godot; +using System.Collections.Generic; + +namespace Rokojori +{ + public class RG_ScreenNormalRoughnessTexture: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 void SetDisconnected( CompositorEffectGraphTextureSlot slot ) + { + _connectedSlots.Remove( slot ); + } + + public RG_ScreenNormalRoughnessTexture( RDGraph graph ):base( graph ) + {} + + public override void Process() + { + _texture = graph.context.GetScreenNormalRoughnessTexture(); + } + + public void ConnectTo( CompositorEffectGraphTextureSlot slot ) + { + slot.SetInput( this ); + } + + public void Disconnect( CompositorEffectGraphTextureSlot slot ) + { + slot.RemoveInput( this ); + } + + } +} \ No newline at end of file diff --git a/Runtime/Rendering/RenderGraph/Nodes/Processors/Generic/RG_ScreenNormalRoughnessTexture.cs.uid b/Runtime/Rendering/RenderGraph/Nodes/Processors/Generic/RG_ScreenNormalRoughnessTexture.cs.uid new file mode 100644 index 0000000..67a13d1 --- /dev/null +++ b/Runtime/Rendering/RenderGraph/Nodes/Processors/Generic/RG_ScreenNormalRoughnessTexture.cs.uid @@ -0,0 +1 @@ +uid://1maktrub2jap diff --git a/Runtime/Rendering/RenderGraph/Nodes/Processors/Noise/ChannelPixelation/ChannelPixelation.glsl b/Runtime/Rendering/RenderGraph/Nodes/Processors/Noise/ChannelPixelation/ChannelPixelation.glsl index 19434d3..77a92dc 100644 --- a/Runtime/Rendering/RenderGraph/Nodes/Processors/Noise/ChannelPixelation/ChannelPixelation.glsl +++ b/Runtime/Rendering/RenderGraph/Nodes/Processors/Noise/ChannelPixelation/ChannelPixelation.glsl @@ -138,6 +138,7 @@ void main() } vec4 originalColor = imageLoad( inputImage, xy ); + vec4 originalUnmodified = originalColor; vec2 uv = ( vec2( xy ) + 0.5 ) / vec2( size ); @@ -169,7 +170,7 @@ void main() int editingChanngel = colorChannel; - if ( colorChannel != 7 && colorChannel >= 3 ) + if ( colorChannel != 6 && colorChannel >= 3 ) { editingChanngel -= 3; @@ -180,13 +181,13 @@ void main() originalColor = RGBtoHSL( originalColor, colorScale2 ); } - if ( colorChannel != 7 ) + if ( colorChannel != 6 ) { float value = getRGBByIndex( color.rgb, editingChanngel ); color.rgb = setRGBByIndex( originalColor.rgb, editingChanngel, value ); } - if ( colorChannel != 7 && colorChannel >= 3 ) + if ( colorChannel != 6 && colorChannel >= 3 ) { color = HSLtoRGB( color, colorScale ); originalColor = HSLtoRGB( originalColor, colorScale2 ); @@ -194,7 +195,7 @@ void main() - color = mix( originalColor, color, parameters.amount ); + color = mix( originalUnmodified, color, parameters.amount ); imageStore( outputImage, xy, color); diff --git a/Runtime/Rendering/RenderGraph/Nodes/Processors/Outlines/ZOutlines/RG_ZOutlines.cs b/Runtime/Rendering/RenderGraph/Nodes/Processors/Outlines/ZOutlines/RG_ZOutlines.cs new file mode 100644 index 0000000..e624805 --- /dev/null +++ b/Runtime/Rendering/RenderGraph/Nodes/Processors/Outlines/ZOutlines/RG_ZOutlines.cs @@ -0,0 +1,18 @@ + +using Godot; +using System.Collections.Generic; + +namespace Rokojori +{ + + public class RG_ZOutlines:CEG_ImageProcessor + { + public static readonly string shaderPath = + RDGraph.Path( "Nodes/Processors/Outlines/ZOutlines/ZOutlines.glsl" ); + + public RG_ZOutlines( RDGraph graph ):base( graph, shaderPath ) + {} + + + } +} \ No newline at end of file diff --git a/Runtime/Rendering/RenderGraph/Nodes/Processors/Outlines/ZOutlines/RG_ZOutlines.cs.uid b/Runtime/Rendering/RenderGraph/Nodes/Processors/Outlines/ZOutlines/RG_ZOutlines.cs.uid new file mode 100644 index 0000000..927e233 --- /dev/null +++ b/Runtime/Rendering/RenderGraph/Nodes/Processors/Outlines/ZOutlines/RG_ZOutlines.cs.uid @@ -0,0 +1 @@ +uid://bkmw2pym4ugsq diff --git a/Runtime/Rendering/RenderGraph/Nodes/Processors/Outlines/ZOutlines/ZOutlines.glsl b/Runtime/Rendering/RenderGraph/Nodes/Processors/Outlines/ZOutlines/ZOutlines.glsl new file mode 100644 index 0000000..41decb6 --- /dev/null +++ b/Runtime/Rendering/RenderGraph/Nodes/Processors/Outlines/ZOutlines/ZOutlines.glsl @@ -0,0 +1,233 @@ +#[compute] +#version 450 + +layout( local_size_x = 8, local_size_y = 8, local_size_z = 1 ) in; + +layout( set = 0, binding = 0 ) +uniform sampler2D inputImage; + +layout( rgba16f, set = 1, binding = 0 ) +uniform image2D outputImage; + +layout( set = 2, binding = 0 ) +uniform sampler2D zSampler; + +layout( set = 3, binding = 0 ) +uniform sampler2D zTresholdSampler; + +layout( set = 4, binding = 0 ) +uniform sampler2D edgeIntensitySampler; + +layout( set = 5, binding = 0 ) +uniform sampler2D normalRoughnessSampler; + +// layout( set = 6, binding = 0 ) +// uniform sampler2D shadowSampler; + +layout( push_constant, std430 ) +uniform Parameters +{ + float amount; + float edgeR; + float edgeG; + float edgeB; + + float zMin; + float zMax; + float edgeThreshold; + float edgeIntensity; + + float adaptiveScaleAmount; + float adaptiveScaleNormalizer; + float zEdgeAmount; + float normalEdgeAmount; + + float normalEdgeZMin; + float normalEdgeZMax; + float rimOffsetX; + float rimOffsetY; + + float fillR; + float fillG; + float fillB; + float fillA; + + float rimContrast; + float rimStrength; + float p0; + float p1; + + +} parameters; + +vec3 SRGBtoLINEAR( vec3 sRGB ) +{ + return mix( pow( (sRGB + vec3( 0.055 )) * ( 1.0 / ( 1.0 + 0.055 )),vec3( 2.4 )),sRGB * ( 1.0 / 12.92 ),lessThan( sRGB,vec3( 0.04045 )) ); +} + +vec4 SRGBtoLINEAR( vec4 sRGB ) +{ + return vec4( SRGBtoLINEAR( sRGB.rgb ), sRGB.a ); +} + +vec3 LINEARtoSRGB( vec3 linear ) +{ + vec3 color = linear; + const vec3 a = vec3(0.055f); + return mix((vec3(1.0f) + a) * pow(color.rgb, vec3(1.0f / 2.4f)) - a, 12.92f * color.rgb, lessThan(color.rgb, vec3(0.0031308f))); +} + +vec4 LINEARtoSRGB( vec4 linear ) +{ + return vec4( LINEARtoSRGB( linear.rgb ), linear.a ); +} + +float randomFloat( vec2 uv ) +{ + return fract( sin( dot( uv.xy, vec2( 12.9898,78.233 ) ) ) * 43758.5453123 ); +} + +vec2 random( vec2 uv ) +{ + float x = randomFloat( uv ); + float y = randomFloat( uv + vec2( 10002, -23589 ) ); + + return vec2( x, y ) * 2.0 - vec2( 1.0, 1.0 ); +} + +float computeGaussianWeight( float x, float y, float sigma ) +{ + return exp( - ( x * x + y * y ) / ( 2.0 * sigma * sigma )); +} + +float sampleNormalizedZ( vec2 uv, int x, int y, vec2 stepSize ) +{ + return textureLod( zSampler, uv + vec2( float( x ), float( y ) ) * stepSize, 0 ).r; +} + +float sampleZ( vec2 uv, int x, int y, vec2 stepSize ) +{ + float z = sampleNormalizedZ( uv, x, y, stepSize ); + + return z * ( parameters.zMax - parameters.zMin ) + parameters.zMin; +} + +vec3 sampleNormal( vec2 uv, int x, int y, vec2 stepSize ) +{ + vec3 normalRGB = textureLod( normalRoughnessSampler, uv + vec2( float( x ), float( y ) ) * stepSize, 0 ).rgb; + vec3 normalXYZ = normalRGB * 2.0 - vec3( 1.0 ); + return normalize( normalXYZ ); +} + +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 ) ); +} + +void main( ) +{ + ivec2 size = imageSize( outputImage ); + ivec2 xy = ivec2( gl_GlobalInvocationID.xy ); + + if ( any( greaterThanEqual( xy, size ) ) ) + { + return; + } + + + + vec2 stepSize = vec2( 1.0 ) / vec2( size ); + + vec2 uv = ( vec2( xy ) + vec2( 0.5 ) ) * stepSize; + + + float z00 = sampleZ( uv, -1, -1, stepSize ); + float z10 = sampleZ( uv, 0, -1, stepSize ); + float z20 = sampleZ( uv, 1, -1, stepSize ); + + float z01 = sampleZ( uv, -1, 0, stepSize ); + float z11 = sampleNormalizedZ( uv, 0, 0, stepSize ); + float zCenter = z11 * ( parameters.zMax * parameters.zMin ) + parameters.zMin; + float z21 = sampleZ( uv, 1, 0, stepSize ); + + float z02 = sampleZ( uv, -1, 1, stepSize ); + float z12 = sampleZ( uv, 0, 1, stepSize ); + float z22 = sampleZ( uv, 1, 1, stepSize ); + + float gx = -z00 - 2.0 * z01 - z02 + z20 + 2.0 * z21 + z22; + float gy = -z00 - 2.0 * z10 - z20 + z02 + 2.0 * z12 + z22; + + vec2 rimOffset = vec2( parameters.rimOffsetX, parameters.rimOffsetY ); + float rimZ = sampleZ( uv + rimOffset, 0, 0, stepSize ); + + float rimStrength = min( 1.0, max( 0.0, abs( zCenter - rimZ ) ) * parameters.rimContrast / zCenter ); + rimStrength *= parameters.rimStrength; + + + vec2 zUV = vec2( z11, 0.0 ); + + float zThresholdCurve = textureLod( zTresholdSampler, zUV, 0 ).r; + float edgeIntensityCurve = textureLod( edgeIntensitySampler, zUV, 0 ).r; + + float adaptiveScale = zCenter / parameters.adaptiveScaleNormalizer; + adaptiveScale = mix( 1.0, adaptiveScale, parameters.adaptiveScaleAmount ); + + float zEdge = length( vec2( gx, gy ) ); + zEdge = ( zEdge - adaptiveScale * parameters.edgeThreshold * zThresholdCurve ) * parameters.edgeIntensity * edgeIntensityCurve; + zEdge = clamp( zEdge, 0.0, 1.0 ); + + + vec3 n10 = sampleNormal( uv, 0, -1, stepSize ); + vec3 n01 = sampleNormal( uv, -1, 0, stepSize ); + vec3 n11 = sampleNormal( uv, 0, 0, stepSize ); + vec3 n21 = sampleNormal( uv, 1, 0, stepSize ); + vec3 n12 = sampleNormal( uv, 0, 1, stepSize ); + + vec3 centerNormal = normalize( 0.5 * n11 + 0.5 * ( n10 + n01 + n21 + n12 ) / 4.0 ); + + // vec3 shadowDirection = vec3( parameters.normalX, parameters.normalY, 0 ); + + // float shadowAmount = max( 0, dot( centerNormal, normalize( shadowDirection ) ) ); + + float normalEdge = 0.0; + + normalEdge = max( normalEdge, 1.0 - dot( n11, n01 ) ); + normalEdge = max( normalEdge, 1.0 - dot( n11, n21 ) ); + normalEdge = max( normalEdge, 1.0 - dot( n11, n10 ) ); + normalEdge = max( normalEdge, 1.0 - dot( n11, n12 ) ); + + float edgeWeight = smoothstep( parameters.normalEdgeZMin, parameters.normalEdgeZMax, normalEdge ); + + float edge = max( normalEdge * parameters.normalEdgeAmount, zEdge * parameters.zEdgeAmount * edgeWeight ); + + vec4 originalColor = textureLod( inputImage, uv, 0 ); + originalColor = mix( originalColor, vec4( parameters.fillR, parameters.fillG, parameters.fillB, 1.0 ), parameters.fillA * parameters.amount ); + originalColor = mix( originalColor, vec4( 1.0 ), rimStrength * parameters.amount ); + + vec4 edgeColor = vec4( parameters.edgeR, parameters.edgeG, parameters.edgeB, 1.0 ); + // originalColor.rgb = mix( originalColor.rgb, vec3( 0.0, 0.0, 0.0 ), shadowAmount ); + vec4 mixedColor = mix( originalColor, edgeColor, parameters.amount * edge ); + + + imageStore( outputImage, xy, mixedColor ); +} \ No newline at end of file diff --git a/Runtime/Rendering/RenderGraph/Nodes/Processors/Outlines/ZOutlines/ZOutlines.glsl.import b/Runtime/Rendering/RenderGraph/Nodes/Processors/Outlines/ZOutlines/ZOutlines.glsl.import new file mode 100644 index 0000000..54d8b80 --- /dev/null +++ b/Runtime/Rendering/RenderGraph/Nodes/Processors/Outlines/ZOutlines/ZOutlines.glsl.import @@ -0,0 +1,14 @@ +[remap] + +importer="glsl" +type="RDShaderFile" +uid="uid://cx88t4pwjyqf2" +path="res://.godot/imported/ZOutlines.glsl-0d7c656d8531f93d834b951434d4132c.res" + +[deps] + +source_file="res://addons/rokojori_action_library/Runtime/Rendering/RenderGraph/Nodes/Processors/Outlines/ZOutlines/ZOutlines.glsl" +dest_files=["res://.godot/imported/ZOutlines.glsl-0d7c656d8531f93d834b951434d4132c.res"] + +[params] + diff --git a/Tools/object-inspector/ObjectGraphInspector.cs b/Tools/object-inspector/ObjectGraphInspector.cs new file mode 100644 index 0000000..e323030 --- /dev/null +++ b/Tools/object-inspector/ObjectGraphInspector.cs @@ -0,0 +1,122 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Reflection; +using Godot; + +namespace Rokojori.Tools; + +public static class ObjectGraphInspector +{ + public class Stats + { + public int totalObjects; + public int maxDepth; + public Dictionary typeCounts = new(); + public Dictionary memberInfos = new(); + + public override string ToString() + { + var info = + "Total Objects:" + totalObjects + " MaxDepth: " + maxDepth; + + foreach ( var t in typeCounts ) + { + info += "\n"; + info += t.Key + ": " + t.Value; + } + + foreach ( var t in memberInfos ) + { + info += "\n"; + info += t.Key + ": " + t.Value; + } + + return info; + } + } + + public static Stats Inspect( object root, int maxDepth = 64 ) + { + var visited = new HashSet(ReferenceEqualityComparer.Instance); + var stats = new Stats(); + + Walk( root, 0, maxDepth, visited, stats, "" ); + stats.totalObjects = visited.Count; + + return stats; + } + + static void Walk( object obj, int depth, int maxDepth, HashSet visited, Stats stats, string memberInfo ) + { + if ( obj == null ) + { + return; + } + + var type = obj.GetType(); + + if ( type.IsValueType || obj is string ) + { + return; + } + + if ( ! visited.Add(obj) ) + { + return; + } + + stats.maxDepth = Math.Max( stats.maxDepth, depth ); + + stats.typeCounts.TryGetValue( type, out int count ); + stats.typeCounts[ type ] = count + 1; + + var combinedInfo = memberInfo + "(" + type.Name + ")"; + + stats.memberInfos.TryGetValue( combinedInfo, out int memberCount ); + stats.memberInfos[ combinedInfo ] = memberCount + 1; + + if ( depth >= maxDepth ) + { + return; + } + + if ( obj is IEnumerable enumerable ) + { + foreach ( var item in enumerable ) + { + Walk( item, depth + 1, maxDepth, visited, stats, type.Name + "." + item ); + } + } + + var flags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; + + foreach ( var field in type.GetFields( flags ) ) + { + if ( field.FieldType.IsValueType || field.FieldType == typeof(string)) + { + continue; + } + + try + { + var value = field.GetValue( obj ); + Walk( value, depth + 1, maxDepth, visited, stats, type.Name + "." + field.Name ); + } + catch + { + // Ignore reflection failures + } + } + } + + class ReferenceEqualityComparer : IEqualityComparer + { + public static readonly ReferenceEqualityComparer Instance = new(); + + public new bool Equals(object x, object y) => ReferenceEquals(x, y); + + public int GetHashCode(object obj) => + System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(obj); + } +} \ No newline at end of file diff --git a/Tools/object-inspector/ObjectGraphInspector.cs.uid b/Tools/object-inspector/ObjectGraphInspector.cs.uid new file mode 100644 index 0000000..f072388 --- /dev/null +++ b/Tools/object-inspector/ObjectGraphInspector.cs.uid @@ -0,0 +1 @@ +uid://3s2yk5oqh5g6 diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..0274701 --- /dev/null +++ b/readme.md @@ -0,0 +1,12 @@ +# ROKOJORI ACTION LIBRARY + +This is the repository for the **Rokojori Action Library** - a framework for creating games in **Godot**. It focuses on **fast, maintainable, and efficient workflows** for game creators. + +Read more on the official [website](http://rokojori.com/en/labs/rokojori-action-library) + + +## License + +The library is licensed under the Rokojori [PIL](https://rokojori.com/en/labs/rokojori-action-library/license) (Public Indie License). +There are also [other licenses](https://rokojori.com/en/labs/rokojori-action-library/license) available. +