From fad61c7e9b38e69e0b27457ccb6dd5c8fd242b47 Mon Sep 17 00:00:00 2001 From: Josef Date: Mon, 5 Jan 2026 22:14:39 +0100 Subject: [PATCH] Compositor Effects Update --- Runtime/Actions/Visual/TweenFloat.cs | 25 +- Runtime/Animation/Driver/FloatDriver.cs | 53 ++++ Runtime/Animation/Driver/FloatDriver.cs.uid | 1 + .../Animation/Driver/FloatDriverNodeTarget.cs | 30 +++ .../Driver/FloatDriverNodeTarget.cs.uid | 1 + .../Driver/FloatDriverResourceTarget.cs | 30 +++ .../Driver/FloatDriverResourceTarget.cs.uid | 1 + Runtime/Animation/Driver/FloatDriverTarget.cs | 28 ++ .../Animation/Driver/FloatDriverTarget.cs.uid | 1 + Runtime/Procedural/Baking/GrabTexture2.cs | 2 +- Runtime/Procedural/Baking/GrabTextureRD.cs | 2 +- .../BoxBlur/BoxBlurEffect.cs | 26 +- .../ChromaticAberation/ChromaticAberation.cs | 13 +- .../ColorQuantizer/ColorQuantizerEffect.cs | 187 +++++++++++++ .../ColorQuantizerEffect.cs.uid | 1 + .../EllipseDistortionEffect.cs | 123 +++++++++ .../EllipseDistortionEffect.cs.uid | 1 + .../NoiseDistortion/NoiseDistortionEffect.cs | 105 ++++++++ .../NoiseDistortionEffect.cs.uid | 1 + .../Distortion/ScanLines/ScanLinesEffect.cs | 117 ++++++++ .../ScanLines/ScanLinesEffect.cs.uid | 1 + .../HSLAdjustment/HSLAdjustmentEffect.cs | 96 +++++++ .../HSLAdjustment/HSLAdjustmentEffect.cs.uid | 1 + .../CompositorEffects/Invert/InvertEffect.cs | 64 +++++ .../Invert/InvertEffect.cs.uid | 1 + .../Kernel3/Kernel3Effect.cs | 102 +++++++ .../Kernel3/Kernel3Effect.cs.uid | 1 + .../LightnessBasedAdjustmentEffect.cs | 93 +++++++ .../LightnessBasedAdjustmentEffect.cs.uid | 1 + .../NormalView/NormalViewEffect.cs | 4 +- .../Posterization/PosterizationEffect.cs | 67 +++++ .../Posterization/PosterizationEffect.cs.uid | 1 + .../RadialBlur2/RadialBlur2.cs | 4 +- .../ReplaceColor/ReplaceColorEffect.cs | 69 +++++ .../ReplaceColor/ReplaceColorEffect.cs.uid | 1 + .../CompositorEffects/Sepia/SepiaEffect.cs | 63 +++++ .../Sepia/SepiaEffect.cs.uid | 1 + .../TemporalSmearSimpleEffect.cs | 2 +- .../UnsharpMasking/UnsharpMaskingEffect.cs | 70 +++++ .../UnsharpMaskingEffect.cs.uid | 1 + .../Processors/Blurs/BoxBlur/BoxBlur.glsl | 27 +- .../Processors/Blurs/BoxBlur/RG_BoxBlur.cs | 4 +- .../{CEG_RadialBlur.cs => RG_RadialBlur.cs} | 4 +- ...RadialBlur.cs.uid => RG_RadialBlur.cs.uid} | 0 ...orDilation.cs => RG_AlphaColorDilation.cs} | 4 +- ...on.cs.uid => RG_AlphaColorDilation.cs.uid} | 0 .../ChromaticAberation.glsl | 32 ++- .../Color/ColorQuantizer/ColorQuantizer.glsl | 182 +++++++++++++ .../ColorQuantizer/ColorQuantizer.glsl.import | 14 + .../Color/ColorQuantizer/RG_ColorQuantizer.cs | 17 ++ .../ColorQuantizer/RG_ColorQuantizer.cs.uid | 1 + .../Color/HSLAdjustment/HSLAdjustment.glsl | 208 ++++++++++++++ .../HSLAdjustment/HSLAdjustment.glsl.import | 14 + .../Color/HSLAdjustment/RG_HSLAdjustment.cs | 17 ++ .../HSLAdjustment/RG_HSLAdjustment.cs.uid | 1 + .../Nodes/Processors/Color/Invert/Invert.glsl | 156 +++++++++++ .../Color/Invert/Invert.glsl.import | 14 + .../Processors/Color/Invert/RG_Invert.cs | 17 ++ .../Processors/Color/Invert/RG_Invert.cs.uid | 1 + .../LightnessBasedAdjustment.glsl | 158 +++++++++++ .../LightnessBasedAdjustment.glsl.import | 14 + .../RG_LightnessBasedAdjustment.cs | 17 ++ .../RG_LightnessBasedAdjustment.cs.uid | 1 + .../Color/Posterization/Posterization.glsl | 138 ++++++++++ .../Posterization/Posterization.glsl.import | 14 + .../Color/Posterization/RG_Posterization.cs | 17 ++ .../Posterization/RG_Posterization.cs.uid | 1 + .../Color/ReplaceColor/RG_ReplaceColor.cs | 17 ++ .../Color/ReplaceColor/RG_ReplaceColor.cs.uid | 1 + .../Color/ReplaceColor/ReplaceColor.glsl | 74 +++++ .../ReplaceColor/ReplaceColor.glsl.import | 14 + .../Nodes/Processors/Color/Sepia/RG_Sepia.cs | 17 ++ .../Processors/Color/Sepia/RG_Sepia.cs.uid | 1 + .../Nodes/Processors/Color/Sepia/Sepia.glsl | 122 +++++++++ .../Processors/Color/Sepia/Sepia.glsl.import | 14 + .../Distortion/Distortion.gdshaderinc | 0 .../Distortion/Distortion.gdshaderinc.uid | 1 + .../EllipseDistortion/EllipseDistortion.glsl | 253 ++++++++++++++++++ .../EllipseDistortion.glsl.import | 14 + .../EllipseDistortion/RG_EllipseDistortion.cs | 17 ++ .../RG_EllipseDistortion.cs.uid | 1 + .../NoiseDistortion/NoiseDistortion.glsl | 196 ++++++++++++++ .../NoiseDistortion.glsl.import | 14 + .../NoiseDistortion/RG_NoiseDistortion.cs | 17 ++ .../NoiseDistortion/RG_NoiseDistortion.cs.uid | 1 + .../Distortion/ScanLines/RG_ScanLines.cs | 17 ++ .../Distortion/ScanLines/RG_ScanLines.cs.uid | 1 + .../Distortion/ScanLines/ScanLines.glsl | 225 ++++++++++++++++ .../ScanLines/ScanLines.glsl.import | 14 + .../Processors/Kernels/Kernel3/Kernel3.glsl | 83 ++++++ .../Kernels/Kernel3/Kernel3.glsl.import | 14 + .../Processors/Kernels/Kernel3/RG_Kernel3.cs | 17 ++ .../Kernels/Kernel3/RG_Kernel3.cs.uid | 1 + Runtime/Shading/Library/SDF.gdshaderinc | 42 +++ 94 files changed, 3612 insertions(+), 40 deletions(-) create mode 100644 Runtime/Animation/Driver/FloatDriver.cs create mode 100644 Runtime/Animation/Driver/FloatDriver.cs.uid create mode 100644 Runtime/Animation/Driver/FloatDriverNodeTarget.cs create mode 100644 Runtime/Animation/Driver/FloatDriverNodeTarget.cs.uid create mode 100644 Runtime/Animation/Driver/FloatDriverResourceTarget.cs create mode 100644 Runtime/Animation/Driver/FloatDriverResourceTarget.cs.uid create mode 100644 Runtime/Animation/Driver/FloatDriverTarget.cs create mode 100644 Runtime/Animation/Driver/FloatDriverTarget.cs.uid create mode 100644 Runtime/Rendering/Compositor/CompositorEffects/ColorQuantizer/ColorQuantizerEffect.cs create mode 100644 Runtime/Rendering/Compositor/CompositorEffects/ColorQuantizer/ColorQuantizerEffect.cs.uid create mode 100644 Runtime/Rendering/Compositor/CompositorEffects/Distortion/EllispeDistortion/EllipseDistortionEffect.cs create mode 100644 Runtime/Rendering/Compositor/CompositorEffects/Distortion/EllispeDistortion/EllipseDistortionEffect.cs.uid create mode 100644 Runtime/Rendering/Compositor/CompositorEffects/Distortion/NoiseDistortion/NoiseDistortionEffect.cs create mode 100644 Runtime/Rendering/Compositor/CompositorEffects/Distortion/NoiseDistortion/NoiseDistortionEffect.cs.uid create mode 100644 Runtime/Rendering/Compositor/CompositorEffects/Distortion/ScanLines/ScanLinesEffect.cs create mode 100644 Runtime/Rendering/Compositor/CompositorEffects/Distortion/ScanLines/ScanLinesEffect.cs.uid create mode 100644 Runtime/Rendering/Compositor/CompositorEffects/HSLAdjustment/HSLAdjustmentEffect.cs create mode 100644 Runtime/Rendering/Compositor/CompositorEffects/HSLAdjustment/HSLAdjustmentEffect.cs.uid create mode 100644 Runtime/Rendering/Compositor/CompositorEffects/Invert/InvertEffect.cs create mode 100644 Runtime/Rendering/Compositor/CompositorEffects/Invert/InvertEffect.cs.uid create mode 100644 Runtime/Rendering/Compositor/CompositorEffects/Kernel3/Kernel3Effect.cs create mode 100644 Runtime/Rendering/Compositor/CompositorEffects/Kernel3/Kernel3Effect.cs.uid create mode 100644 Runtime/Rendering/Compositor/CompositorEffects/LightnessBasedAdjustment/LightnessBasedAdjustmentEffect.cs create mode 100644 Runtime/Rendering/Compositor/CompositorEffects/LightnessBasedAdjustment/LightnessBasedAdjustmentEffect.cs.uid create mode 100644 Runtime/Rendering/Compositor/CompositorEffects/Posterization/PosterizationEffect.cs create mode 100644 Runtime/Rendering/Compositor/CompositorEffects/Posterization/PosterizationEffect.cs.uid create mode 100644 Runtime/Rendering/Compositor/CompositorEffects/ReplaceColor/ReplaceColorEffect.cs create mode 100644 Runtime/Rendering/Compositor/CompositorEffects/ReplaceColor/ReplaceColorEffect.cs.uid create mode 100644 Runtime/Rendering/Compositor/CompositorEffects/Sepia/SepiaEffect.cs create mode 100644 Runtime/Rendering/Compositor/CompositorEffects/Sepia/SepiaEffect.cs.uid create mode 100644 Runtime/Rendering/Compositor/CompositorEffects/UnsharpMasking/UnsharpMaskingEffect.cs create mode 100644 Runtime/Rendering/Compositor/CompositorEffects/UnsharpMasking/UnsharpMaskingEffect.cs.uid rename Runtime/Rendering/RenderGraph/Nodes/Processors/Blurs/RadialBlur/{CEG_RadialBlur.cs => RG_RadialBlur.cs} (64%) rename Runtime/Rendering/RenderGraph/Nodes/Processors/Blurs/RadialBlur/{CEG_RadialBlur.cs.uid => RG_RadialBlur.cs.uid} (100%) rename Runtime/Rendering/RenderGraph/Nodes/Processors/Color/AlphaColorDilation/{CEG_AlphaColorDilation.cs => RG_AlphaColorDilation.cs} (63%) rename Runtime/Rendering/RenderGraph/Nodes/Processors/Color/AlphaColorDilation/{CEG_AlphaColorDilation.cs.uid => RG_AlphaColorDilation.cs.uid} (100%) create mode 100644 Runtime/Rendering/RenderGraph/Nodes/Processors/Color/ColorQuantizer/ColorQuantizer.glsl create mode 100644 Runtime/Rendering/RenderGraph/Nodes/Processors/Color/ColorQuantizer/ColorQuantizer.glsl.import create mode 100644 Runtime/Rendering/RenderGraph/Nodes/Processors/Color/ColorQuantizer/RG_ColorQuantizer.cs create mode 100644 Runtime/Rendering/RenderGraph/Nodes/Processors/Color/ColorQuantizer/RG_ColorQuantizer.cs.uid create mode 100644 Runtime/Rendering/RenderGraph/Nodes/Processors/Color/HSLAdjustment/HSLAdjustment.glsl create mode 100644 Runtime/Rendering/RenderGraph/Nodes/Processors/Color/HSLAdjustment/HSLAdjustment.glsl.import create mode 100644 Runtime/Rendering/RenderGraph/Nodes/Processors/Color/HSLAdjustment/RG_HSLAdjustment.cs create mode 100644 Runtime/Rendering/RenderGraph/Nodes/Processors/Color/HSLAdjustment/RG_HSLAdjustment.cs.uid create mode 100644 Runtime/Rendering/RenderGraph/Nodes/Processors/Color/Invert/Invert.glsl create mode 100644 Runtime/Rendering/RenderGraph/Nodes/Processors/Color/Invert/Invert.glsl.import create mode 100644 Runtime/Rendering/RenderGraph/Nodes/Processors/Color/Invert/RG_Invert.cs create mode 100644 Runtime/Rendering/RenderGraph/Nodes/Processors/Color/Invert/RG_Invert.cs.uid create mode 100644 Runtime/Rendering/RenderGraph/Nodes/Processors/Color/LightnessBasedAdjustment/LightnessBasedAdjustment.glsl create mode 100644 Runtime/Rendering/RenderGraph/Nodes/Processors/Color/LightnessBasedAdjustment/LightnessBasedAdjustment.glsl.import create mode 100644 Runtime/Rendering/RenderGraph/Nodes/Processors/Color/LightnessBasedAdjustment/RG_LightnessBasedAdjustment.cs create mode 100644 Runtime/Rendering/RenderGraph/Nodes/Processors/Color/LightnessBasedAdjustment/RG_LightnessBasedAdjustment.cs.uid create mode 100644 Runtime/Rendering/RenderGraph/Nodes/Processors/Color/Posterization/Posterization.glsl create mode 100644 Runtime/Rendering/RenderGraph/Nodes/Processors/Color/Posterization/Posterization.glsl.import create mode 100644 Runtime/Rendering/RenderGraph/Nodes/Processors/Color/Posterization/RG_Posterization.cs create mode 100644 Runtime/Rendering/RenderGraph/Nodes/Processors/Color/Posterization/RG_Posterization.cs.uid create mode 100644 Runtime/Rendering/RenderGraph/Nodes/Processors/Color/ReplaceColor/RG_ReplaceColor.cs create mode 100644 Runtime/Rendering/RenderGraph/Nodes/Processors/Color/ReplaceColor/RG_ReplaceColor.cs.uid create mode 100644 Runtime/Rendering/RenderGraph/Nodes/Processors/Color/ReplaceColor/ReplaceColor.glsl create mode 100644 Runtime/Rendering/RenderGraph/Nodes/Processors/Color/ReplaceColor/ReplaceColor.glsl.import create mode 100644 Runtime/Rendering/RenderGraph/Nodes/Processors/Color/Sepia/RG_Sepia.cs create mode 100644 Runtime/Rendering/RenderGraph/Nodes/Processors/Color/Sepia/RG_Sepia.cs.uid create mode 100644 Runtime/Rendering/RenderGraph/Nodes/Processors/Color/Sepia/Sepia.glsl create mode 100644 Runtime/Rendering/RenderGraph/Nodes/Processors/Color/Sepia/Sepia.glsl.import create mode 100644 Runtime/Rendering/RenderGraph/Nodes/Processors/Distortion/Distortion.gdshaderinc create mode 100644 Runtime/Rendering/RenderGraph/Nodes/Processors/Distortion/Distortion.gdshaderinc.uid create mode 100644 Runtime/Rendering/RenderGraph/Nodes/Processors/Distortion/EllipseDistortion/EllipseDistortion.glsl create mode 100644 Runtime/Rendering/RenderGraph/Nodes/Processors/Distortion/EllipseDistortion/EllipseDistortion.glsl.import create mode 100644 Runtime/Rendering/RenderGraph/Nodes/Processors/Distortion/EllipseDistortion/RG_EllipseDistortion.cs create mode 100644 Runtime/Rendering/RenderGraph/Nodes/Processors/Distortion/EllipseDistortion/RG_EllipseDistortion.cs.uid create mode 100644 Runtime/Rendering/RenderGraph/Nodes/Processors/Distortion/NoiseDistortion/NoiseDistortion.glsl create mode 100644 Runtime/Rendering/RenderGraph/Nodes/Processors/Distortion/NoiseDistortion/NoiseDistortion.glsl.import create mode 100644 Runtime/Rendering/RenderGraph/Nodes/Processors/Distortion/NoiseDistortion/RG_NoiseDistortion.cs create mode 100644 Runtime/Rendering/RenderGraph/Nodes/Processors/Distortion/NoiseDistortion/RG_NoiseDistortion.cs.uid create mode 100644 Runtime/Rendering/RenderGraph/Nodes/Processors/Distortion/ScanLines/RG_ScanLines.cs create mode 100644 Runtime/Rendering/RenderGraph/Nodes/Processors/Distortion/ScanLines/RG_ScanLines.cs.uid create mode 100644 Runtime/Rendering/RenderGraph/Nodes/Processors/Distortion/ScanLines/ScanLines.glsl create mode 100644 Runtime/Rendering/RenderGraph/Nodes/Processors/Distortion/ScanLines/ScanLines.glsl.import create mode 100644 Runtime/Rendering/RenderGraph/Nodes/Processors/Kernels/Kernel3/Kernel3.glsl create mode 100644 Runtime/Rendering/RenderGraph/Nodes/Processors/Kernels/Kernel3/Kernel3.glsl.import create mode 100644 Runtime/Rendering/RenderGraph/Nodes/Processors/Kernels/Kernel3/RG_Kernel3.cs create mode 100644 Runtime/Rendering/RenderGraph/Nodes/Processors/Kernels/Kernel3/RG_Kernel3.cs.uid diff --git a/Runtime/Actions/Visual/TweenFloat.cs b/Runtime/Actions/Visual/TweenFloat.cs index 00fd23c..5268366 100644 --- a/Runtime/Actions/Visual/TweenFloat.cs +++ b/Runtime/Actions/Visual/TweenFloat.cs @@ -12,6 +12,9 @@ namespace Rokojori [Export] public GodotObject target; + [Export] + public Node targetNode; + [Export] public string targetMemberPath; @@ -24,6 +27,13 @@ namespace Rokojori [Export] public Curve curve; + [ExportGroup( "Editor Testing")] + [Export] + public bool forceStartValue = false; + + [Export] + public float forcedStartValue = 0f; + public void OnAnimatorStart(){} public void OnAnimatorEnd(){} public void OnAnimatorCancel(){} @@ -33,7 +43,7 @@ namespace Rokojori - public float GetTargetValue( GodotObject go, string targetMember, float alternative = 0 ) + public static float GetTargetValue( GodotObject go, string targetMember, float alternative = 0 ) { var path = targetMember.Split( "/" ); var prop = path[ path.Length - 1 ]; @@ -44,7 +54,7 @@ namespace Rokojori } - public void SetTargetValue( GodotObject go, string targetMember, float value ) + public static void SetTargetValue( GodotObject go, string targetMember, float value ) { var path = targetMember.Split( "/" ); var prop = path[ path.Length - 1 ]; @@ -76,9 +86,20 @@ namespace Rokojori _actionID = DispatchStart(); + var target = this.target != null ? this.target : targetNode; + // var startValue = ReflectionHelper.GetValue( target, targetMember ); var startValue = GetTargetValue( target, targetMemberPath ); + + if ( forceStartValue && Engine.IsEditorHint() ) + { + startValue = forcedStartValue; + } + + + + AnimationManager.StartAnimation( this, target, targetMemberPath ); this.LogInfo( "Start Value Float Tween", HierarchyName.OfAny( target ), target.GetType().Name, targetMemberPath, ">>", startValue ); diff --git a/Runtime/Animation/Driver/FloatDriver.cs b/Runtime/Animation/Driver/FloatDriver.cs new file mode 100644 index 0000000..01c1bc8 --- /dev/null +++ b/Runtime/Animation/Driver/FloatDriver.cs @@ -0,0 +1,53 @@ +using System.Collections; +using System.Collections.Generic; +using System.Text.RegularExpressions; +using System.Text; +using Godot; + +namespace Rokojori +{ + [Tool] + [GlobalClass] + public partial class FloatDriver:Node + { + float _driverValue = 0f; + + [Export( PropertyHint.Range, "0,1" )] + public float value + { + get => _driverValue; + set + { + _driverValue = value; + UpdateValue(); + } + } + + [ExportToolButton( "Update Value")] + public Callable updateValueButton => Callable.From( ()=> UpdateValue() ) ; + + void UpdateValue() + { + if ( targets == null ) + { + return; + } + + for ( int i = 0; i < targets.Length; i++ ) + { + if ( targets[ i ] == null || targets[ i ].GetGodotObject( this ) == null ) + { + continue; + } + + targets[ i ].Update( this ); + } + } + + [Export] + public FloatDriverTarget[] targets = []; + + + + } +} \ No newline at end of file diff --git a/Runtime/Animation/Driver/FloatDriver.cs.uid b/Runtime/Animation/Driver/FloatDriver.cs.uid new file mode 100644 index 0000000..b0c7027 --- /dev/null +++ b/Runtime/Animation/Driver/FloatDriver.cs.uid @@ -0,0 +1 @@ +uid://bvmdtshoesn5v diff --git a/Runtime/Animation/Driver/FloatDriverNodeTarget.cs b/Runtime/Animation/Driver/FloatDriverNodeTarget.cs new file mode 100644 index 0000000..b8119e9 --- /dev/null +++ b/Runtime/Animation/Driver/FloatDriverNodeTarget.cs @@ -0,0 +1,30 @@ +using System.Collections; +using System.Collections.Generic; +using System.Text.RegularExpressions; +using System.Text; +using Godot; + +namespace Rokojori +{ + [Tool] + [GlobalClass] + public partial class FloatDriverNodeTarget:FloatDriverTarget + { + [Export] + public NodePath nodePath; + + [Export] + public string targetMemberPath; + + public override GodotObject GetGodotObject( FloatDriver driver ) + { + return driver.GetNode( nodePath ); + } + + public override string GetTargetMemberPath( FloatDriver driver ) + { + return targetMemberPath; + } + + } +} \ No newline at end of file diff --git a/Runtime/Animation/Driver/FloatDriverNodeTarget.cs.uid b/Runtime/Animation/Driver/FloatDriverNodeTarget.cs.uid new file mode 100644 index 0000000..4f732ba --- /dev/null +++ b/Runtime/Animation/Driver/FloatDriverNodeTarget.cs.uid @@ -0,0 +1 @@ +uid://cqgobpug8btt3 diff --git a/Runtime/Animation/Driver/FloatDriverResourceTarget.cs b/Runtime/Animation/Driver/FloatDriverResourceTarget.cs new file mode 100644 index 0000000..e2ceba9 --- /dev/null +++ b/Runtime/Animation/Driver/FloatDriverResourceTarget.cs @@ -0,0 +1,30 @@ +using System.Collections; +using System.Collections.Generic; +using System.Text.RegularExpressions; +using System.Text; +using Godot; + +namespace Rokojori +{ + [Tool] + [GlobalClass] + public partial class FloatDriverResourceTarget:FloatDriverTarget + { + [Export] + public Resource resource; + + [Export] + public string targetMemberPath; + + public override GodotObject GetGodotObject( FloatDriver driver ) + { + return resource; + } + + public override string GetTargetMemberPath( FloatDriver driver ) + { + return targetMemberPath; + } + + } +} \ No newline at end of file diff --git a/Runtime/Animation/Driver/FloatDriverResourceTarget.cs.uid b/Runtime/Animation/Driver/FloatDriverResourceTarget.cs.uid new file mode 100644 index 0000000..fd27ecd --- /dev/null +++ b/Runtime/Animation/Driver/FloatDriverResourceTarget.cs.uid @@ -0,0 +1 @@ +uid://dhuspbjmculan diff --git a/Runtime/Animation/Driver/FloatDriverTarget.cs b/Runtime/Animation/Driver/FloatDriverTarget.cs new file mode 100644 index 0000000..1fd0c62 --- /dev/null +++ b/Runtime/Animation/Driver/FloatDriverTarget.cs @@ -0,0 +1,28 @@ +using System.Collections; +using System.Collections.Generic; +using System.Text.RegularExpressions; +using System.Text; +using Godot; + +namespace Rokojori +{ + [Tool] + [GlobalClass] + public abstract partial class FloatDriverTarget:Resource + { + + [Export] + public Curve mappingCurve; + + public abstract string GetTargetMemberPath( FloatDriver driver ); + + public abstract GodotObject GetGodotObject( FloatDriver driver ); + + public void Update( FloatDriver driver ) + { + var mappedValue = mappingCurve.Sample( driver.value ); + var targetMemberPath = GetTargetMemberPath( driver ); + TweenFloat.SetTargetValue( GetGodotObject( driver ), targetMemberPath, mappedValue ); + } + } +} \ No newline at end of file diff --git a/Runtime/Animation/Driver/FloatDriverTarget.cs.uid b/Runtime/Animation/Driver/FloatDriverTarget.cs.uid new file mode 100644 index 0000000..034e024 --- /dev/null +++ b/Runtime/Animation/Driver/FloatDriverTarget.cs.uid @@ -0,0 +1 @@ +uid://bvx5mbwb86jca diff --git a/Runtime/Procedural/Baking/GrabTexture2.cs b/Runtime/Procedural/Baking/GrabTexture2.cs index 57830c6..cd71d6d 100644 --- a/Runtime/Procedural/Baking/GrabTexture2.cs +++ b/Runtime/Procedural/Baking/GrabTexture2.cs @@ -119,7 +119,7 @@ namespace Rokojori var bufferTexture = CEG_BufferTexture.From( graph, ot ); var copy = new CEG_Copy( graph ); - var blur = new RD_BoxBlur( graph ); + var blur = new RG_BoxBlur( graph ); graph.InitializeNodes(); diff --git a/Runtime/Procedural/Baking/GrabTextureRD.cs b/Runtime/Procedural/Baking/GrabTextureRD.cs index 56dae7c..04a1263 100644 --- a/Runtime/Procedural/Baking/GrabTextureRD.cs +++ b/Runtime/Procedural/Baking/GrabTextureRD.cs @@ -51,7 +51,7 @@ namespace Rokojori ctx.messageLogLevel = Messages.GetLevel( MessageType.Verbose ); this.LogInfo( "Creating program" ); - ctx.SetProgramFromPath( CEG_AlphaColorDilation.shaderPath ); + ctx.SetProgramFromPath( RG_AlphaColorDilation.shaderPath ); this.LogInfo( "Creating textures" ); diff --git a/Runtime/Rendering/Compositor/CompositorEffects/BoxBlur/BoxBlurEffect.cs b/Runtime/Rendering/Compositor/CompositorEffects/BoxBlur/BoxBlurEffect.cs index 6f94e71..d87fbac 100644 --- a/Runtime/Rendering/Compositor/CompositorEffects/BoxBlur/BoxBlurEffect.cs +++ b/Runtime/Rendering/Compositor/CompositorEffects/BoxBlur/BoxBlurEffect.cs @@ -18,16 +18,16 @@ namespace Rokojori public float intensity = 1f; [Export( PropertyHint.Range, "0,100")] - public float noise = 0f; + public float noise = 2f; [Export( PropertyHint.Range, "1,100")] - public int kernelOffset = 5; + public int kernelOffset = 2; [Export( PropertyHint.Range, "1,30")] public int kernelRadius = 2; [Export( PropertyHint.Range, "1,4")] - public int iterations = 1; + public int iterations = 2; CEG_ScreenColorTexure screenColorTexture; @@ -35,12 +35,12 @@ namespace Rokojori CEG_Copy copy; CEG_Copy copy2; - RD_BoxBlur boxBlur; - RD_BoxBlur boxBlur1; - RD_BoxBlur boxBlur2; - RD_BoxBlur boxBlur3; + RG_BoxBlur boxBlur; + RG_BoxBlur boxBlur1; + RG_BoxBlur boxBlur2; + RG_BoxBlur boxBlur3; - List _blurs; + List _blurs; void Initialize() { @@ -49,12 +49,12 @@ namespace Rokojori copy = new CEG_Copy( graph ); copy2 = new CEG_Copy( graph ); - boxBlur = new RD_BoxBlur( graph ); - boxBlur1 = new RD_BoxBlur( graph ); - boxBlur2 = new RD_BoxBlur( graph ); - boxBlur3 = new RD_BoxBlur( graph ); + boxBlur = new RG_BoxBlur( graph ); + boxBlur1 = new RG_BoxBlur( graph ); + boxBlur2 = new RG_BoxBlur( graph ); + boxBlur3 = new RG_BoxBlur( graph ); - _blurs = new List() + _blurs = new List() { boxBlur, boxBlur1, boxBlur2, boxBlur3 }; diff --git a/Runtime/Rendering/Compositor/CompositorEffects/ChromaticAberation/ChromaticAberation.cs b/Runtime/Rendering/Compositor/CompositorEffects/ChromaticAberation/ChromaticAberation.cs index af77d9d..937664b 100644 --- a/Runtime/Rendering/Compositor/CompositorEffects/ChromaticAberation/ChromaticAberation.cs +++ b/Runtime/Rendering/Compositor/CompositorEffects/ChromaticAberation/ChromaticAberation.cs @@ -7,7 +7,7 @@ namespace Rokojori { [Tool] [GlobalClass] - public abstract partial class ChromaticAberation:RDGraphCompositorEffect + public partial class ChromaticAberation:RDGraphCompositorEffect { public ChromaticAberation():base() { @@ -31,11 +31,10 @@ namespace Rokojori public float shiftAll = 0.5f; [Export] - public float unshiftCenter = 16f; + public float centerUnshiftPower = 1f; [Export] - public int constantsInternalSize; - + public float centerUnshiftMinRadius = 0.1f; CEG_ScreenColorTexure screenColorTexture; CEG_BufferTexture bufferTexture; @@ -75,12 +74,14 @@ namespace Rokojori rShift, gShift, bShift, + Vector2.Zero, // padding + intensity, shiftAll, - unshiftCenter + centerUnshiftPower, + centerUnshiftMinRadius // padding ); - constantsInternalSize = chromaticAberation.constants.internalSize; } diff --git a/Runtime/Rendering/Compositor/CompositorEffects/ColorQuantizer/ColorQuantizerEffect.cs b/Runtime/Rendering/Compositor/CompositorEffects/ColorQuantizer/ColorQuantizerEffect.cs new file mode 100644 index 0000000..fce67a1 --- /dev/null +++ b/Runtime/Rendering/Compositor/CompositorEffects/ColorQuantizer/ColorQuantizerEffect.cs @@ -0,0 +1,187 @@ + +using Godot; +using Godot.Collections; +using System.Collections.Generic; + +namespace Rokojori +{ + [Tool] + [GlobalClass] + public partial class ColorQuantizerEffect:RDGraphCompositorEffect + { + public ColorQuantizerEffect():base() + { + Initialize(); + } + + [ExportGroup("All")] + [Export( PropertyHint.Range, "0,1") ] + public float amount = 0.5f; + + public enum HSLConversionMode + { + Raw, + Scaled, + Clamped + } + + [Export] + public HSLConversionMode hslConversionMode = HSLConversionMode.Scaled; + + [ExportGroup("Red")] + [Export( PropertyHint.Range, "0,1") ] + public float redAmount = 0.5f; + + [Export( PropertyHint.Range, "1,100") ] + public float redSteps = 10; + + [Export( PropertyHint.Range, "1,10") ] + public float redStepsMultiplier = 1; + + [Export( PropertyHint.Range, "-1,1") ] + public float redGamma = 0; + + [Export( PropertyHint.Range, "-1,1") ] + public float redOffset = 0; + + [ExportGroup("Green")] + [Export( PropertyHint.Range, "0,1") ] + public float greenAmount = 0.5f; + + [Export( PropertyHint.Range, "1,100") ] + public float greenSteps = 10; + + [Export( PropertyHint.Range, "1,10") ] + public float greenStepsMultiplier = 1; + + [Export( PropertyHint.Range, "-1,1") ] + public float greenGamma = 0; + + [Export( PropertyHint.Range, "-1,1") ] + public float greenOffset = 0; + + [ExportGroup("Blue")] + [Export( PropertyHint.Range, "0,1") ] + public float blueAmount = 0.5f; + + [Export( PropertyHint.Range, "1,100") ] + public float blueSteps = 10; + + [Export( PropertyHint.Range, "1,10") ] + public float blueStepsMultiplier = 1; + + [Export( PropertyHint.Range, "-1,1") ] + public float blueGamma = 0; + + [Export( PropertyHint.Range, "-1,1") ] + public float blueOffset = 0; + + [ExportGroup("RGB")] + [Export( PropertyHint.Range, "0,1") ] + public float rgbAmount = 0.5f; + + [Export( PropertyHint.Range, "1,100") ] + public float rgbSteps = 10; + + [Export( PropertyHint.Range, "1,10") ] + public float rgbStepsMultiplier = 1; + + [Export( PropertyHint.Range, "-1,1") ] + public float rgbGamma = 0; + + [Export( PropertyHint.Range, "-1,1") ] + public float rgbOffset = 0; + + [ExportGroup("Hue")] + [Export( PropertyHint.Range, "0,1") ] + public float hueAmount = 0.5f; + + [Export( PropertyHint.Range, "1,100") ] + public float hueSteps = 10; + + [Export( PropertyHint.Range, "1,10") ] + public float hueStepsMultiplier = 1; + + [Export( PropertyHint.Range, "-1,1") ] + public float hueGamma = 0; + + [Export( PropertyHint.Range, "-1,1") ] + public float hueOffset = 0; + + [ExportGroup("Saturation")] + [Export( PropertyHint.Range, "0,1") ] + public float saturationAmount = 0.5f; + + [Export( PropertyHint.Range, "1,100") ] + public float saturationSteps = 10; + + [Export( PropertyHint.Range, "1,10") ] + public float saturationStepsMultiplier = 1; + + [Export( PropertyHint.Range, "-1,1") ] + public float saturationGamma = 0; + + [Export( PropertyHint.Range, "-1,1") ] + public float saturationOffset = 0; + + [ExportGroup("Luminance")] + [Export( PropertyHint.Range, "0,1") ] + public float luminanceAmount = 0.5f; + + [Export( PropertyHint.Range, "1,100") ] + public float luminanceSteps = 10; + + [Export( PropertyHint.Range, "1,10") ] + public float luminanceStepsMultiplier = 1; + + [Export( PropertyHint.Range, "-1,1") ] + public float luminanceGamma = 0; + + [Export( PropertyHint.Range, "-1,1") ] + public float luminanceOffset = 0; + + + + + CEG_ScreenColorTexure screenColorTexture; + RG_ColorQuantizer colorQuantizer; + + void Initialize() + { + screenColorTexture = new CEG_ScreenColorTexure( graph ); + colorQuantizer = new RG_ColorQuantizer( graph ); + + + graph.InitializeNodes(); + + + colorQuantizer.SetTextureSlotInputs( screenColorTexture, screenColorTexture ); + + + graph.SetProcessOrder( + screenColorTexture, + colorQuantizer + ); + } + + + protected override void ForAllViews() + { + colorQuantizer.constants.Set( + + new Vector4( redAmount, redSteps * redStepsMultiplier, Mathf.Pow( 5f,redGamma ), redOffset ), + new Vector4( greenAmount, greenSteps * greenStepsMultiplier, Mathf.Pow( 5f,greenGamma ), greenOffset ), + new Vector4( blueAmount, blueSteps * blueStepsMultiplier, Mathf.Pow( 5f,blueGamma ), blueOffset ), + new Vector4( rgbAmount, rgbSteps * rgbStepsMultiplier, Mathf.Pow( 5f,rgbGamma ), rgbOffset ), + + new Vector4( hueAmount, hueSteps * hueStepsMultiplier, Mathf.Pow( 5f,hueGamma), hueOffset ), + new Vector4( saturationAmount, saturationSteps * saturationStepsMultiplier, Mathf.Pow( 5f,saturationGamma), saturationOffset ), + new Vector4( luminanceAmount, luminanceSteps * luminanceStepsMultiplier, Mathf.Pow( 5f,luminanceGamma), luminanceOffset ), + + new Vector4( amount, (int) hslConversionMode, 0f, 0f ) + ); + } + + + } +} \ No newline at end of file diff --git a/Runtime/Rendering/Compositor/CompositorEffects/ColorQuantizer/ColorQuantizerEffect.cs.uid b/Runtime/Rendering/Compositor/CompositorEffects/ColorQuantizer/ColorQuantizerEffect.cs.uid new file mode 100644 index 0000000..e35b285 --- /dev/null +++ b/Runtime/Rendering/Compositor/CompositorEffects/ColorQuantizer/ColorQuantizerEffect.cs.uid @@ -0,0 +1 @@ +uid://b2oxy6ln560ys diff --git a/Runtime/Rendering/Compositor/CompositorEffects/Distortion/EllispeDistortion/EllipseDistortionEffect.cs b/Runtime/Rendering/Compositor/CompositorEffects/Distortion/EllispeDistortion/EllipseDistortionEffect.cs new file mode 100644 index 0000000..957f506 --- /dev/null +++ b/Runtime/Rendering/Compositor/CompositorEffects/Distortion/EllispeDistortion/EllipseDistortionEffect.cs @@ -0,0 +1,123 @@ + +using Godot; +using Godot.Collections; +using System.Collections.Generic; + +namespace Rokojori +{ + [Tool] + [GlobalClass] + public partial class EllipseDistortionEffect:RDGraphCompositorEffect + { + public EllipseDistortionEffect():base() + { + Initialize(); + } + + [Export( PropertyHint.Range, "0,1") ] + public float distortionAmount = 0.5f; + + [Export( PropertyHint.Range, "0,1") ] + public float blendAmount = 1f; + + [Export] + public Vector2 ellipseCenter = new Vector2( 0.5f, 0.5f ); + + [Export] + public Vector2 ellipseSize = new Vector2( 0.5f, 0.5f ); + + [Export] + public float ellipseScale = 1.0f; + + [Export] + public bool keepRatio = true; + + [Export] + public float minDistance = 0.1f; + + [Export( PropertyHint.Range, "1,20") ] + public float rings = 1f; + + [Export( PropertyHint.Range, "-1,1") ] + public float ringsIntensity = 0.5f; + + [Export( PropertyHint.Range, "-2,2") ] + public float ringsType = 0.5f; + + + [Export( PropertyHint.Range, "-1,1") ] + public float ringsDistribution = 1f; + + + [Export( PropertyHint.Range, "1,10") ] + public int smearingSteps = 5; + + [Export( PropertyHint.Range, "1,1.5") ] + public float smearing = 1.1f; + + [Export( PropertyHint.Range, "-1,1") ] + public float redShift = 0.1f; + + [Export( PropertyHint.Range, "-1,1") ] + public float greenShift = 0f; + + [Export( PropertyHint.Range, "-1,1") ] + public float blueShift = 0f; + + + CEG_ScreenColorTexure screenColorTexture; + CEG_BufferTexture bufferTexture; + + CEG_Copy copy; + RG_EllipseDistortion distortion; + + void Initialize() + { + screenColorTexture = new CEG_ScreenColorTexure( graph ); + bufferTexture = CEG_BufferTexture.ScreenSize( graph ); + + copy = new CEG_Copy( graph ); + distortion = new RG_EllipseDistortion( graph ); + graph.InitializeNodes(); + + copy.SetTextureSlotInputs( screenColorTexture, bufferTexture ); + distortion.SetTextureSlotInputs( copy.output, copy.input ); + + + + graph.SetProcessOrder( + screenColorTexture, + bufferTexture, + copy, + distortion + ); + + } + + + protected override void ForAllViews() + { + + distortion.constants.Set( + new Vector4( + ellipseCenter.X, ellipseCenter.Y, ellipseSize.X * ellipseScale, ellipseSize.Y * ellipseScale + ), + distortionAmount, + blendAmount, + minDistance, + 1.0f + redShift, + 1.0f + greenShift, + 1.0f + blueShift, + (float) smearingSteps, + smearing, + rings, + keepRatio ? 1.0f : 0.0f, + ringsIntensity, + Mathf.Pow( 10f, -ringsDistribution ), + ringsType + ); + } + + + } +} \ No newline at end of file diff --git a/Runtime/Rendering/Compositor/CompositorEffects/Distortion/EllispeDistortion/EllipseDistortionEffect.cs.uid b/Runtime/Rendering/Compositor/CompositorEffects/Distortion/EllispeDistortion/EllipseDistortionEffect.cs.uid new file mode 100644 index 0000000..9f78120 --- /dev/null +++ b/Runtime/Rendering/Compositor/CompositorEffects/Distortion/EllispeDistortion/EllipseDistortionEffect.cs.uid @@ -0,0 +1 @@ +uid://cqkrgyuerq50a diff --git a/Runtime/Rendering/Compositor/CompositorEffects/Distortion/NoiseDistortion/NoiseDistortionEffect.cs b/Runtime/Rendering/Compositor/CompositorEffects/Distortion/NoiseDistortion/NoiseDistortionEffect.cs new file mode 100644 index 0000000..cb3a1ae --- /dev/null +++ b/Runtime/Rendering/Compositor/CompositorEffects/Distortion/NoiseDistortion/NoiseDistortionEffect.cs @@ -0,0 +1,105 @@ + +using Godot; +using Godot.Collections; +using System.Collections.Generic; + +namespace Rokojori +{ + [Tool] + [GlobalClass] + public partial class NoiseDistortionEffect:RDGraphCompositorEffect + { + public NoiseDistortionEffect():base() + { + Initialize(); + } + + [Export( PropertyHint.Range, "0,1") ] + public float amount = 0.5f; + + [Export( PropertyHint.Range, "0.01,100") ] + public float scale = 1f; + + [Export( PropertyHint.Range, "1,5") ] + public int smearingSteps = 3; + + [Export( PropertyHint.Range, "1,1.5") ] + public float smearing = 1.1f; + + [Export] + public Vector3 xU = new Vector3( 0f, 0f, 0f ); + + [Export] + public Vector3 xV = new Vector3( 0f, 0f, 0f ); + + [Export] + public Vector3 yU = new Vector3( 0f, 0f, 0f ); + + [Export] + public Vector3 yV = new Vector3( 0f, 0f, 0f ); + + [Export( PropertyHint.Range, "-1,1") ] + public float redShift = 0.1f; + + [Export( PropertyHint.Range, "-1,1") ] + public float greenShift = 0f; + + [Export( PropertyHint.Range, "-1,1") ] + public float blueShift = 0f; + + + CEG_ScreenColorTexure screenColorTexture; + CEG_BufferTexture bufferTexture; + + CEG_Copy copy; + RG_NoiseDistortion distortion; + + void Initialize() + { + screenColorTexture = new CEG_ScreenColorTexure( graph ); + bufferTexture = CEG_BufferTexture.ScreenSize( graph ); + + copy = new CEG_Copy( graph ); + distortion = new RG_NoiseDistortion( graph ); + graph.InitializeNodes(); + + copy.SetTextureSlotInputs( screenColorTexture, bufferTexture ); + distortion.SetTextureSlotInputs( copy.output, copy.input ); + + + + graph.SetProcessOrder( + screenColorTexture, + bufferTexture, + copy, + distortion + ); + + } + + + protected override void ForAllViews() + { + var time = TimeLine.osTime; + + distortion.constants.Set( + new Vector4( + xU.X + Mathf.Sin( xU.Y * time ) * xU.Z, + xV.X + Mathf.Sin( xV.Y * time ) * xV.Z, + yU.X + Mathf.Sin( yU.Y * time ) * yU.Z, + yV.X + Mathf.Sin( yV.Y * time ) * yV.Z + ), + amount, + scale, + 1.0f + redShift, + 1.0f + greenShift, + 1.0f + blueShift, + (float) smearingSteps, + smearing + + ); + } + + + } +} \ No newline at end of file diff --git a/Runtime/Rendering/Compositor/CompositorEffects/Distortion/NoiseDistortion/NoiseDistortionEffect.cs.uid b/Runtime/Rendering/Compositor/CompositorEffects/Distortion/NoiseDistortion/NoiseDistortionEffect.cs.uid new file mode 100644 index 0000000..a6328d0 --- /dev/null +++ b/Runtime/Rendering/Compositor/CompositorEffects/Distortion/NoiseDistortion/NoiseDistortionEffect.cs.uid @@ -0,0 +1 @@ +uid://cidk0x7sb1pxl diff --git a/Runtime/Rendering/Compositor/CompositorEffects/Distortion/ScanLines/ScanLinesEffect.cs b/Runtime/Rendering/Compositor/CompositorEffects/Distortion/ScanLines/ScanLinesEffect.cs new file mode 100644 index 0000000..4e8064a --- /dev/null +++ b/Runtime/Rendering/Compositor/CompositorEffects/Distortion/ScanLines/ScanLinesEffect.cs @@ -0,0 +1,117 @@ + +using Godot; +using Godot.Collections; +using System.Collections.Generic; + +namespace Rokojori +{ + [Tool] + [GlobalClass] + public partial class ScanLinesEffect:RDGraphCompositorEffect + { + public ScanLinesEffect():base() + { + Initialize(); + } + + [Export( PropertyHint.Range, "0,1") ] + public float amount = 0.5f; + + [Export( PropertyHint.Range, "0,1") ] + public Color topColor = Colors.White; + + [Export( PropertyHint.Range, "0,1") ] + public Color bottomColor = new Color( 0.96f, 0.96f, 0.96f, 1.0f ); + + [Export( PropertyHint.Range, "0,500") ] + public int scanLineHeight = 2; + + [Export( PropertyHint.Range, "0,1") ] + public float rgbTintAmount = 0.1f; + + [Export( PropertyHint.Range, "1,100") ] + public int rgbSize = 2; + + [Export] + public bool useRGBOffset = false; + + [Export( PropertyHint.Range, "0,500") ] + public int rgbOffsetLineHeight = 2; + + [Export] + public float jitterStrength = 1f; + + [Export( PropertyHint.Range, "1,120") ] + public float jitterFPS = 60f; + + bool jitterFlag = false; + + + + + CEG_ScreenColorTexure screenColorTexture; + CEG_BufferTexture bufferTexture; + + CEG_Copy copy; + RG_ScanLines scanLines; + + void Initialize() + { + screenColorTexture = new CEG_ScreenColorTexure( graph ); + bufferTexture = CEG_BufferTexture.ScreenSize( graph ); + + copy = new CEG_Copy( graph ); + scanLines = new RG_ScanLines( graph ); + graph.InitializeNodes(); + + copy.SetTextureSlotInputs( screenColorTexture, bufferTexture ); + scanLines.SetTextureSlotInputs( copy.output, copy.input ); + + + + graph.SetProcessOrder( + screenColorTexture, + bufferTexture, + copy, + scanLines + ); + + } + + + protected override void ForAllViews() + { + float duration = 1f / jitterFPS; + float normalizedTime = ( TimeLine.osTime % duration ) / duration; + float jitter = Mathf.Sin( normalizedTime * Mathf.Pi * 2f ) * jitterStrength; + + // this.LogInfo( jitter ); + + + + + scanLines.constants.Set( + topColor, + bottomColor, + Vector4.Zero, + Vector4.Zero, + + amount, + (float) scanLineHeight, + rgbTintAmount, + (float) rgbOffsetLineHeight, + + (float) rgbSize, + useRGBOffset ? 1f : 0f, + jitter, + 0f + + + + + ); + } + + + } +} \ No newline at end of file diff --git a/Runtime/Rendering/Compositor/CompositorEffects/Distortion/ScanLines/ScanLinesEffect.cs.uid b/Runtime/Rendering/Compositor/CompositorEffects/Distortion/ScanLines/ScanLinesEffect.cs.uid new file mode 100644 index 0000000..b21c011 --- /dev/null +++ b/Runtime/Rendering/Compositor/CompositorEffects/Distortion/ScanLines/ScanLinesEffect.cs.uid @@ -0,0 +1 @@ +uid://dxnmlb5wobxtw diff --git a/Runtime/Rendering/Compositor/CompositorEffects/HSLAdjustment/HSLAdjustmentEffect.cs b/Runtime/Rendering/Compositor/CompositorEffects/HSLAdjustment/HSLAdjustmentEffect.cs new file mode 100644 index 0000000..09ca7c1 --- /dev/null +++ b/Runtime/Rendering/Compositor/CompositorEffects/HSLAdjustment/HSLAdjustmentEffect.cs @@ -0,0 +1,96 @@ + +using Godot; +using Godot.Collections; +using System.Collections.Generic; + +namespace Rokojori +{ + [Tool] + [GlobalClass] + public partial class HSLAdjustmentEffect:RDGraphCompositorEffect + { + public HSLAdjustmentEffect():base() + { + Initialize(); + } + + [Export( PropertyHint.Range, "0,1") ] + public float amount = 0.5f; + + [Export( PropertyHint.Range, "-360,360") ] + public float hueShift = 0; + + [Export( PropertyHint.Range, "-360,360") ] + public float temparatureShift = 0; + + [Export( PropertyHint.Range, "0,120") ] + public float temparatureBlendRadius = 15f; + + [Export( PropertyHint.Range, "-100,100") ] + public float saturationOffset = 0; + + [Export( PropertyHint.Range, "-100,100") ] + public float saturationGamma = 0; + + [Export( PropertyHint.Range, "-100,100") ] + public float lightnessOffset = 0; + + [Export( PropertyHint.Range, "-100,100") ] + public float lightnessGamma = 0; + + + public enum HSLConversionMode + { + Raw, + Scaled, + Clamped + } + + [Export] + public HSLConversionMode hslConversionMode = HSLConversionMode.Scaled; + + + + CEG_ScreenColorTexure screenColorTexture; + RG_HSLAdjustment hslAdjustment; + + void Initialize() + { + screenColorTexture = new CEG_ScreenColorTexure( graph ); + hslAdjustment = new RG_HSLAdjustment( graph ); + + + graph.InitializeNodes(); + + + hslAdjustment.SetTextureSlotInputs( screenColorTexture, screenColorTexture ); + + + graph.SetProcessOrder( + screenColorTexture, + hslAdjustment + ); + } + + + protected override void ForAllViews() + { + hslAdjustment.constants.Set( + amount, + MathX.Repeat( hueShift, 360 ) / 360f, temparatureShift, + + saturationOffset / 100f, Mathf.Pow( 5f, saturationGamma / 100f ), + lightnessOffset / 100f, Mathf.Pow( 5f, lightnessGamma / 100f ), + + (float)(int)hslConversionMode, + + temparatureBlendRadius, + 0f, + 0f, + 0f + ); + } + + + } +} \ No newline at end of file diff --git a/Runtime/Rendering/Compositor/CompositorEffects/HSLAdjustment/HSLAdjustmentEffect.cs.uid b/Runtime/Rendering/Compositor/CompositorEffects/HSLAdjustment/HSLAdjustmentEffect.cs.uid new file mode 100644 index 0000000..878f8a8 --- /dev/null +++ b/Runtime/Rendering/Compositor/CompositorEffects/HSLAdjustment/HSLAdjustmentEffect.cs.uid @@ -0,0 +1 @@ +uid://pevgspwywsxi diff --git a/Runtime/Rendering/Compositor/CompositorEffects/Invert/InvertEffect.cs b/Runtime/Rendering/Compositor/CompositorEffects/Invert/InvertEffect.cs new file mode 100644 index 0000000..f320df7 --- /dev/null +++ b/Runtime/Rendering/Compositor/CompositorEffects/Invert/InvertEffect.cs @@ -0,0 +1,64 @@ + +using Godot; +using Godot.Collections; +using System.Collections.Generic; + +namespace Rokojori +{ + [Tool] + [GlobalClass] + public partial class InvertEffect:RDGraphCompositorEffect + { + public InvertEffect():base() + { + Initialize(); + } + + [Export( PropertyHint.Range, "0,1") ] + public float amount = 0.5f; + + [Export] + public bool r = true; + + [Export] + public bool g = true; + + [Export] + public bool b = true; + + + CEG_ScreenColorTexure screenColorTexture; + RG_Invert invert; + + void Initialize() + { + screenColorTexture = new CEG_ScreenColorTexure( graph ); + invert = new RG_Invert( graph ); + + + graph.InitializeNodes(); + + + invert.SetTextureSlotInputs( screenColorTexture, screenColorTexture ); + + + graph.SetProcessOrder( + screenColorTexture, + invert + ); + } + + + protected override void ForAllViews() + { + invert.constants.Set( + amount, + r ? 1.0f : 0.0f, + g ? 1.0f : 0.0f, + b ? 1.0f : 0.0f + ); + } + + + } +} \ No newline at end of file diff --git a/Runtime/Rendering/Compositor/CompositorEffects/Invert/InvertEffect.cs.uid b/Runtime/Rendering/Compositor/CompositorEffects/Invert/InvertEffect.cs.uid new file mode 100644 index 0000000..42a0664 --- /dev/null +++ b/Runtime/Rendering/Compositor/CompositorEffects/Invert/InvertEffect.cs.uid @@ -0,0 +1 @@ +uid://m38dajaa0alm diff --git a/Runtime/Rendering/Compositor/CompositorEffects/Kernel3/Kernel3Effect.cs b/Runtime/Rendering/Compositor/CompositorEffects/Kernel3/Kernel3Effect.cs new file mode 100644 index 0000000..5263734 --- /dev/null +++ b/Runtime/Rendering/Compositor/CompositorEffects/Kernel3/Kernel3Effect.cs @@ -0,0 +1,102 @@ + +using Godot; +using Godot.Collections; +using System.Collections.Generic; + +namespace Rokojori +{ + [Tool] + [GlobalClass] + public partial class Kernel3Effect:RDGraphCompositorEffect + { + public Kernel3Effect():base() + { + Initialize(); + } + + [Export( PropertyHint.Range, "0,1")] + public float amount = 1f; + + [Export( PropertyHint.Range, "1,10")] + public int kernelOffset = 1; + + [Export] + public Vector3 rowTop = new Vector3( 0, 0, 0 ); + + [Export] + public Vector3 rowCenter = new Vector3( 0, 1, 0 ); + + [Export] + public Vector3 rowBottom = new Vector3( 0, 0, 0 ); + + [Export] + public bool normalize = false; + + [Export] + public bool clamp = false; + + CEG_ScreenColorTexure screenColorTexture; + CEG_BufferTexture bufferTexture; + + CEG_Copy copy; + RG_Kernel3 kernel; + + void Initialize() + { + screenColorTexture = new CEG_ScreenColorTexure( graph ); + bufferTexture = CEG_BufferTexture.ScreenSize( graph ); + + copy = new CEG_Copy( graph ); + kernel = new RG_Kernel3( graph ); + graph.InitializeNodes(); + + copy.SetTextureSlotInputs( screenColorTexture, bufferTexture ); + kernel.SetTextureSlotInputs( copy.output, copy.input ); + + + + graph.SetProcessOrder( + screenColorTexture, + bufferTexture, + copy, + kernel + ); + + } + + float v( Vector3 v ) + { + return v.X + v.Y + v.Z; + } + + protected override void ForAllViews() + { + var s = 1.0f; + + if ( normalize ) + { + var n = v( rowTop ) + v( rowCenter ) + v( rowBottom ); + + if ( n != 0 ) + { + s = 1f / n; + } + + } + + kernel.constants.Set( + [ + amount, + rowTop.X * s, rowTop.Y * s, rowTop.Z * s, + rowCenter.X * s, rowCenter.Y * s, rowCenter.Z * s, + rowBottom.X * s, rowBottom.Y * s, rowBottom.Z * s, + (float) kernelOffset, + clamp ? 1.0f : 0.0f + ] + ); + + } + + + } +} \ No newline at end of file diff --git a/Runtime/Rendering/Compositor/CompositorEffects/Kernel3/Kernel3Effect.cs.uid b/Runtime/Rendering/Compositor/CompositorEffects/Kernel3/Kernel3Effect.cs.uid new file mode 100644 index 0000000..62ec70a --- /dev/null +++ b/Runtime/Rendering/Compositor/CompositorEffects/Kernel3/Kernel3Effect.cs.uid @@ -0,0 +1 @@ +uid://b2pfl80ql156g diff --git a/Runtime/Rendering/Compositor/CompositorEffects/LightnessBasedAdjustment/LightnessBasedAdjustmentEffect.cs b/Runtime/Rendering/Compositor/CompositorEffects/LightnessBasedAdjustment/LightnessBasedAdjustmentEffect.cs new file mode 100644 index 0000000..915f4a5 --- /dev/null +++ b/Runtime/Rendering/Compositor/CompositorEffects/LightnessBasedAdjustment/LightnessBasedAdjustmentEffect.cs @@ -0,0 +1,93 @@ + +using Godot; +using Godot.Collections; +using System.Collections.Generic; + +namespace Rokojori +{ + [Tool] + [GlobalClass] + public partial class LightnessBasedAdjustmentEffect:RDGraphCompositorEffect + { + public LightnessBasedAdjustmentEffect():base() + { + Initialize(); + } + + [Export( PropertyHint.Range, "0,1") ] + public float amount = 0.5f; + + [Export] + public Vector3 hueShift = Vector3.Zero; + + [Export( PropertyHint.Range, "0,1") ] + public float hueAmount = 1.0f; + + [Export] + public Vector3 saturationShift = Vector3.Zero; + + [Export( PropertyHint.Range, "0,1") ] + public float saturationAmount = 1.0f; + + [Export ] + public Vector3 lightnessShift = Vector3.Zero; + + [Export( PropertyHint.Range, "0,1") ] + public float lightnessAmount = 1.0f; + + public enum HSLConversionMode + { + Raw, + Scaled, + Clamped + } + + [Export] + public HSLConversionMode hslConversionMode = HSLConversionMode.Scaled; + + + + CEG_ScreenColorTexure screenColorTexture; + RG_LightnessBasedAdjustment adjustment; + + void Initialize() + { + screenColorTexture = new CEG_ScreenColorTexure( graph ); + adjustment = new RG_LightnessBasedAdjustment( graph ); + + + graph.InitializeNodes(); + + + adjustment.SetTextureSlotInputs( screenColorTexture, screenColorTexture ); + + + graph.SetProcessOrder( + screenColorTexture, + adjustment + ); + } + + Vector4 ToVector4( Vector3 v, float w ) + { + return new Vector4( v.X, v.Y, v.Z, w ); + } + + protected override void ForAllViews() + { + adjustment.constants.Set( + ToVector4( hueShift, hueAmount ), + ToVector4( saturationShift, saturationAmount ), + ToVector4( lightnessShift, lightnessAmount ), + Vector4.Zero, + amount, + 0f, + 0f, + 0f + + ); + } + + + } +} \ No newline at end of file diff --git a/Runtime/Rendering/Compositor/CompositorEffects/LightnessBasedAdjustment/LightnessBasedAdjustmentEffect.cs.uid b/Runtime/Rendering/Compositor/CompositorEffects/LightnessBasedAdjustment/LightnessBasedAdjustmentEffect.cs.uid new file mode 100644 index 0000000..4f48a3d --- /dev/null +++ b/Runtime/Rendering/Compositor/CompositorEffects/LightnessBasedAdjustment/LightnessBasedAdjustmentEffect.cs.uid @@ -0,0 +1 @@ +uid://cjfxcl3cdhnku diff --git a/Runtime/Rendering/Compositor/CompositorEffects/NormalView/NormalViewEffect.cs b/Runtime/Rendering/Compositor/CompositorEffects/NormalView/NormalViewEffect.cs index 3948736..45b3b6f 100644 --- a/Runtime/Rendering/Compositor/CompositorEffects/NormalView/NormalViewEffect.cs +++ b/Runtime/Rendering/Compositor/CompositorEffects/NormalView/NormalViewEffect.cs @@ -7,9 +7,9 @@ namespace Rokojori { [Tool] [GlobalClass] - public partial class NormalViewEffect:SingleShaderCompositorEffect + public abstract partial class NormalViewEffect:SingleShaderCompositorEffect { - public static readonly string shaderPath = Path( "DepthView/NormalViewShader.glsl" ); + public static readonly string shaderPath = Path( "NormalView/NormalViewShader.glsl" ); RDSampler sampler; diff --git a/Runtime/Rendering/Compositor/CompositorEffects/Posterization/PosterizationEffect.cs b/Runtime/Rendering/Compositor/CompositorEffects/Posterization/PosterizationEffect.cs new file mode 100644 index 0000000..dfaa618 --- /dev/null +++ b/Runtime/Rendering/Compositor/CompositorEffects/Posterization/PosterizationEffect.cs @@ -0,0 +1,67 @@ + +using Godot; +using Godot.Collections; +using System.Collections.Generic; + +namespace Rokojori +{ + [Tool] + [GlobalClass] + public partial class PosterizationEffect:RDGraphCompositorEffect + { + public PosterizationEffect():base() + { + Initialize(); + } + + [Export( PropertyHint.Range, "0,1") ] + public float amount = 0.5f; + + [Export( PropertyHint.Range, "1,100") ] + public float steps = 10; + + [Export( PropertyHint.Range, "1,10") ] + public float stepsMultiplier = 1; + + [Export( PropertyHint.Range, "-1,1") ] + public float gamma = 0; + + [Export( PropertyHint.Range, "-1,1") ] + public float offset = 0; + + + CEG_ScreenColorTexure screenColorTexture; + RG_Posterization posterization; + + void Initialize() + { + screenColorTexture = new CEG_ScreenColorTexure( graph ); + posterization = new RG_Posterization( graph ); + + + graph.InitializeNodes(); + + + posterization.SetTextureSlotInputs( screenColorTexture, screenColorTexture ); + + + graph.SetProcessOrder( + screenColorTexture, + posterization + ); + } + + + protected override void ForAllViews() + { + posterization.constants.Set( + amount, + steps * stepsMultiplier, + Mathf.Pow( 5f, gamma ), + offset + ); + } + + + } +} \ No newline at end of file diff --git a/Runtime/Rendering/Compositor/CompositorEffects/Posterization/PosterizationEffect.cs.uid b/Runtime/Rendering/Compositor/CompositorEffects/Posterization/PosterizationEffect.cs.uid new file mode 100644 index 0000000..16545ab --- /dev/null +++ b/Runtime/Rendering/Compositor/CompositorEffects/Posterization/PosterizationEffect.cs.uid @@ -0,0 +1 @@ +uid://q6iw8nan6yiv diff --git a/Runtime/Rendering/Compositor/CompositorEffects/RadialBlur2/RadialBlur2.cs b/Runtime/Rendering/Compositor/CompositorEffects/RadialBlur2/RadialBlur2.cs index 9e1386c..6ab2650 100644 --- a/Runtime/Rendering/Compositor/CompositorEffects/RadialBlur2/RadialBlur2.cs +++ b/Runtime/Rendering/Compositor/CompositorEffects/RadialBlur2/RadialBlur2.cs @@ -31,7 +31,7 @@ namespace Rokojori CEG_BufferTexture bufferTexture; CEG_Copy copy; - CEG_RadialBlur radialBlur; + RG_RadialBlur radialBlur; void Initialize() { @@ -39,7 +39,7 @@ namespace Rokojori bufferTexture = CEG_BufferTexture.ScreenSize( graph ); copy = new CEG_Copy( graph ); - radialBlur = new CEG_RadialBlur( graph ); + radialBlur = new RG_RadialBlur( graph ); graph.InitializeNodes(); diff --git a/Runtime/Rendering/Compositor/CompositorEffects/ReplaceColor/ReplaceColorEffect.cs b/Runtime/Rendering/Compositor/CompositorEffects/ReplaceColor/ReplaceColorEffect.cs new file mode 100644 index 0000000..3c5714f --- /dev/null +++ b/Runtime/Rendering/Compositor/CompositorEffects/ReplaceColor/ReplaceColorEffect.cs @@ -0,0 +1,69 @@ + +using Godot; +using Godot.Collections; +using System.Collections.Generic; + +namespace Rokojori +{ + [Tool] + [GlobalClass] + public partial class ReplaceColorEffect:RDGraphCompositorEffect + { + public ReplaceColorEffect():base() + { + Initialize(); + } + + [Export( PropertyHint.Range, "0,1") ] + public float amount = 0.5f; + + [Export] + public Color searchColor; + + [Export] + public Color replacementColor; + + [Export( PropertyHint.Range, "0,3") ] + public float colorDistanceMax = 0.5f; + + [Export( PropertyHint.Range, "0,3") ] + public float colorDistanceMin = 0.1f; + + + CEG_ScreenColorTexure screenColorTexture; + RG_ReplaceColor replaceColor; + + void Initialize() + { + screenColorTexture = new CEG_ScreenColorTexure( graph ); + replaceColor = new RG_ReplaceColor( graph ); + + + graph.InitializeNodes(); + + + replaceColor.SetTextureSlotInputs( screenColorTexture, screenColorTexture ); + + + graph.SetProcessOrder( + screenColorTexture, + replaceColor + ); + } + + + protected override void ForAllViews() + { + replaceColor.constants.Set( + searchColor, + replacementColor, + amount, + colorDistanceMax, + colorDistanceMin, + 0f + ); + } + + + } +} \ No newline at end of file diff --git a/Runtime/Rendering/Compositor/CompositorEffects/ReplaceColor/ReplaceColorEffect.cs.uid b/Runtime/Rendering/Compositor/CompositorEffects/ReplaceColor/ReplaceColorEffect.cs.uid new file mode 100644 index 0000000..8c0728a --- /dev/null +++ b/Runtime/Rendering/Compositor/CompositorEffects/ReplaceColor/ReplaceColorEffect.cs.uid @@ -0,0 +1 @@ +uid://7pq3ojke8tvv diff --git a/Runtime/Rendering/Compositor/CompositorEffects/Sepia/SepiaEffect.cs b/Runtime/Rendering/Compositor/CompositorEffects/Sepia/SepiaEffect.cs new file mode 100644 index 0000000..f96a1cd --- /dev/null +++ b/Runtime/Rendering/Compositor/CompositorEffects/Sepia/SepiaEffect.cs @@ -0,0 +1,63 @@ + +using Godot; +using Godot.Collections; +using System.Collections.Generic; + +namespace Rokojori +{ + [Tool] + [GlobalClass] + public partial class SepiaEffect:RDGraphCompositorEffect + { + public SepiaEffect():base() + { + Initialize(); + } + + [ Export( PropertyHint.Range, "0,1") ] + public float amount = 1f; + + [ Export( PropertyHint.Range, "0,360") ] + public float hue = 35; + + [ Export( PropertyHint.Range, "0,1") ] + public float saturation = 0.5f; + + [ Export( PropertyHint.Range, "0,1") ] + public float saturationAmount = 0.5f; + + CEG_ScreenColorTexure screenColorTexture; + RG_Sepia sepia; + + void Initialize() + { + screenColorTexture = new CEG_ScreenColorTexure( graph ); + sepia = new RG_Sepia( graph ); + + + graph.InitializeNodes(); + + + sepia.SetTextureSlotInputs( screenColorTexture, screenColorTexture ); + + + graph.SetProcessOrder( + screenColorTexture, + sepia + ); + } + + + protected override void ForAllViews() + { + sepia.constants.Set( + amount, + hue / 360f, + saturation, + saturationAmount + ); + } + + + } +} \ No newline at end of file diff --git a/Runtime/Rendering/Compositor/CompositorEffects/Sepia/SepiaEffect.cs.uid b/Runtime/Rendering/Compositor/CompositorEffects/Sepia/SepiaEffect.cs.uid new file mode 100644 index 0000000..c665fed --- /dev/null +++ b/Runtime/Rendering/Compositor/CompositorEffects/Sepia/SepiaEffect.cs.uid @@ -0,0 +1 @@ +uid://cn2103slcr2vs diff --git a/Runtime/Rendering/Compositor/CompositorEffects/TemporalSmearSimple/TemporalSmearSimpleEffect.cs b/Runtime/Rendering/Compositor/CompositorEffects/TemporalSmearSimple/TemporalSmearSimpleEffect.cs index 796422a..de8fa1b 100644 --- a/Runtime/Rendering/Compositor/CompositorEffects/TemporalSmearSimple/TemporalSmearSimpleEffect.cs +++ b/Runtime/Rendering/Compositor/CompositorEffects/TemporalSmearSimple/TemporalSmearSimpleEffect.cs @@ -7,7 +7,7 @@ namespace Rokojori { [Tool] [GlobalClass] - public abstract partial class TemporalSmearSimpleEffect:SingleShaderCompositorEffect + public partial class TemporalSmearSimpleEffect:SingleShaderCompositorEffect { public static readonly string shaderPath = Path( "TemporalSmearSimple/TemporalSmearSimple.glsl" ); diff --git a/Runtime/Rendering/Compositor/CompositorEffects/UnsharpMasking/UnsharpMaskingEffect.cs b/Runtime/Rendering/Compositor/CompositorEffects/UnsharpMasking/UnsharpMaskingEffect.cs new file mode 100644 index 0000000..e79bda8 --- /dev/null +++ b/Runtime/Rendering/Compositor/CompositorEffects/UnsharpMasking/UnsharpMaskingEffect.cs @@ -0,0 +1,70 @@ + +using Godot; +using Godot.Collections; +using System.Collections.Generic; + +namespace Rokojori +{ + [Tool] + [GlobalClass] + public partial class UnsharpMaskingEffect:RDGraphCompositorEffect + { + public UnsharpMaskingEffect():base() + { + Initialize(); + } + + [Export( PropertyHint.Range, "0,1")] + public float amount = 1f; + + [Export( PropertyHint.Range, "1,10")] + public int kernelOffset = 1; + + CEG_ScreenColorTexure screenColorTexture; + CEG_BufferTexture bufferTexture; + + CEG_Copy copy; + RG_Kernel3 unsharpMaskingKernel; + + void Initialize() + { + screenColorTexture = new CEG_ScreenColorTexure( graph ); + bufferTexture = CEG_BufferTexture.ScreenSize( graph ); + + copy = new CEG_Copy( graph ); + unsharpMaskingKernel = new RG_Kernel3( graph ); + graph.InitializeNodes(); + + copy.SetTextureSlotInputs( screenColorTexture, bufferTexture ); + unsharpMaskingKernel.SetTextureSlotInputs( copy.output, copy.input ); + + + + graph.SetProcessOrder( + screenColorTexture, + bufferTexture, + copy, + unsharpMaskingKernel + ); + + } + + protected override void ForAllViews() + { + unsharpMaskingKernel.constants.Set( + [ + amount, + 0f, -1f, 0f, + -1f, 5f, -1f, + 0f, -1f,0f, + (float)kernelOffset, + 0f + + ] + ); + + } + + + } +} \ No newline at end of file diff --git a/Runtime/Rendering/Compositor/CompositorEffects/UnsharpMasking/UnsharpMaskingEffect.cs.uid b/Runtime/Rendering/Compositor/CompositorEffects/UnsharpMasking/UnsharpMaskingEffect.cs.uid new file mode 100644 index 0000000..3871129 --- /dev/null +++ b/Runtime/Rendering/Compositor/CompositorEffects/UnsharpMasking/UnsharpMaskingEffect.cs.uid @@ -0,0 +1 @@ +uid://wl1p78fs5sos diff --git a/Runtime/Rendering/RenderGraph/Nodes/Processors/Blurs/BoxBlur/BoxBlur.glsl b/Runtime/Rendering/RenderGraph/Nodes/Processors/Blurs/BoxBlur/BoxBlur.glsl index bbcb241..755a5fc 100644 --- a/Runtime/Rendering/RenderGraph/Nodes/Processors/Blurs/BoxBlur/BoxBlur.glsl +++ b/Runtime/Rendering/RenderGraph/Nodes/Processors/Blurs/BoxBlur/BoxBlur.glsl @@ -20,6 +20,27 @@ uniform Parameters } 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 ) { @@ -65,7 +86,7 @@ void main( ) kernelUV.x = clamp( kernelUV.x, 0, size.x - 1 ); kernelUV.y = clamp( kernelUV.y, 0, size.y - 1 ); - color += imageLoad( inputImage, kernelUV ); + color += ( imageLoad( inputImage, kernelUV ) ); } } } @@ -81,7 +102,7 @@ void main( ) kernelUV.x = clamp( kernelUV.x, 0, size.x - 1 ); kernelUV.y = clamp( kernelUV.y, 0, size.y - 1 ); - color += imageLoad( inputImage, kernelUV ); + color += ( imageLoad( inputImage, kernelUV ) ); } } } @@ -92,6 +113,8 @@ void main( ) color /= numPixels; + color = ( color ); + vec4 originalColor = imageLoad( inputImage, pixelUV ); vec4 mixedColor = mix( originalColor, color, parameters.intensity ); diff --git a/Runtime/Rendering/RenderGraph/Nodes/Processors/Blurs/BoxBlur/RG_BoxBlur.cs b/Runtime/Rendering/RenderGraph/Nodes/Processors/Blurs/BoxBlur/RG_BoxBlur.cs index 63deb06..cffa406 100644 --- a/Runtime/Rendering/RenderGraph/Nodes/Processors/Blurs/BoxBlur/RG_BoxBlur.cs +++ b/Runtime/Rendering/RenderGraph/Nodes/Processors/Blurs/BoxBlur/RG_BoxBlur.cs @@ -4,12 +4,12 @@ using System.Collections.Generic; namespace Rokojori { - public class RD_BoxBlur:CEG_ImageProcessor + public class RG_BoxBlur:CEG_ImageProcessor { public static readonly string shaderPath = RDGraph.Path( "Nodes/Processors/Blurs/BoxBlur/BoxBlur.glsl" ); - public RD_BoxBlur( RDGraph graph ):base( graph, shaderPath ) + public RG_BoxBlur( RDGraph graph ):base( graph, shaderPath ) {} diff --git a/Runtime/Rendering/RenderGraph/Nodes/Processors/Blurs/RadialBlur/CEG_RadialBlur.cs b/Runtime/Rendering/RenderGraph/Nodes/Processors/Blurs/RadialBlur/RG_RadialBlur.cs similarity index 64% rename from Runtime/Rendering/RenderGraph/Nodes/Processors/Blurs/RadialBlur/CEG_RadialBlur.cs rename to Runtime/Rendering/RenderGraph/Nodes/Processors/Blurs/RadialBlur/RG_RadialBlur.cs index be41ff8..816f782 100644 --- a/Runtime/Rendering/RenderGraph/Nodes/Processors/Blurs/RadialBlur/CEG_RadialBlur.cs +++ b/Runtime/Rendering/RenderGraph/Nodes/Processors/Blurs/RadialBlur/RG_RadialBlur.cs @@ -4,12 +4,12 @@ using System.Collections.Generic; namespace Rokojori { - public class CEG_RadialBlur:CEG_ImageProcessor + public class RG_RadialBlur:CEG_ImageProcessor { public static readonly string shaderPath = RDGraph.Path( "Nodes/Processors/Blurs/RadialBlur/RadialBlur.glsl" ); - public CEG_RadialBlur( RDGraph graph ):base( graph, shaderPath ) + public RG_RadialBlur( RDGraph graph ):base( graph, shaderPath ) {} diff --git a/Runtime/Rendering/RenderGraph/Nodes/Processors/Blurs/RadialBlur/CEG_RadialBlur.cs.uid b/Runtime/Rendering/RenderGraph/Nodes/Processors/Blurs/RadialBlur/RG_RadialBlur.cs.uid similarity index 100% rename from Runtime/Rendering/RenderGraph/Nodes/Processors/Blurs/RadialBlur/CEG_RadialBlur.cs.uid rename to Runtime/Rendering/RenderGraph/Nodes/Processors/Blurs/RadialBlur/RG_RadialBlur.cs.uid diff --git a/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/AlphaColorDilation/CEG_AlphaColorDilation.cs b/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/AlphaColorDilation/RG_AlphaColorDilation.cs similarity index 63% rename from Runtime/Rendering/RenderGraph/Nodes/Processors/Color/AlphaColorDilation/CEG_AlphaColorDilation.cs rename to Runtime/Rendering/RenderGraph/Nodes/Processors/Color/AlphaColorDilation/RG_AlphaColorDilation.cs index 4fc758f..9e18f1a 100644 --- a/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/AlphaColorDilation/CEG_AlphaColorDilation.cs +++ b/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/AlphaColorDilation/RG_AlphaColorDilation.cs @@ -4,12 +4,12 @@ using System.Collections.Generic; namespace Rokojori { - public class CEG_AlphaColorDilation:CEG_ImageProcessor + public class RG_AlphaColorDilation:CEG_ImageProcessor { public static readonly string shaderPath = RDGraph.Path( "Nodes/Processors/Color/AlphaColorDilation/AlphaColorDilation.glsl" ); - public CEG_AlphaColorDilation( RDGraph graph ):base( graph, shaderPath ) + public RG_AlphaColorDilation( RDGraph graph ):base( graph, shaderPath ) {} diff --git a/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/AlphaColorDilation/CEG_AlphaColorDilation.cs.uid b/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/AlphaColorDilation/RG_AlphaColorDilation.cs.uid similarity index 100% rename from Runtime/Rendering/RenderGraph/Nodes/Processors/Color/AlphaColorDilation/CEG_AlphaColorDilation.cs.uid rename to Runtime/Rendering/RenderGraph/Nodes/Processors/Color/AlphaColorDilation/RG_AlphaColorDilation.cs.uid diff --git a/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/ChromaticAberation/ChromaticAberation.glsl b/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/ChromaticAberation/ChromaticAberation.glsl index da662a2..7f0bd35 100644 --- a/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/ChromaticAberation/ChromaticAberation.glsl +++ b/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/ChromaticAberation/ChromaticAberation.glsl @@ -15,12 +15,28 @@ uniform Params vec2 rShift; vec2 gShift; vec2 bShift; + vec2 padding0; + float amount; float shiftAll; - float unshiftCenter; + float unshiftPower; + float unshiftOffset; } params; + +float mirrorValue( float x ) +{ + float t = mod( x, 2.0 ); + return ( t <= 1.0 ) ? t : 2.0 - t; +} + +vec2 mirrorUV( vec2 uv ) +{ + return vec2( mirrorValue( uv.x ), mirrorValue( uv.y ) ); +} + + void main( ) { ivec2 size = imageSize( inputImage ); @@ -32,11 +48,19 @@ void main( ) } vec2 uv = ( vec2( texel_coord ) + 0.5 ) / vec2( size ); + + float d = length( uv - vec2( 0.5 ) ) / 0.5; + d = pow( max( 0.0, d - params.unshiftOffset ), params.unshiftPower ); - vec2 uvR = uv + params.rShift * params.shiftAll; - vec2 uvG = uv + params.gShift * params.shiftAll; - vec2 uvB = uv + params.bShift * params.shiftAll; + vec2 uvR = uv + params.rShift * params.shiftAll * d; + vec2 uvG = uv + params.gShift * params.shiftAll * d; + vec2 uvB = uv + params.bShift * params.shiftAll * d; + + uvR = mirrorUV( uvR ); + uvG = mirrorUV( uvG ); + uvB = mirrorUV( uvB ); + float r = imageLoad( inputImage, ivec2( uvR * size ) ).r; float g = imageLoad( inputImage, ivec2( uvG * size ) ).g; diff --git a/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/ColorQuantizer/ColorQuantizer.glsl b/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/ColorQuantizer/ColorQuantizer.glsl new file mode 100644 index 0000000..f7f5a1e --- /dev/null +++ b/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/ColorQuantizer/ColorQuantizer.glsl @@ -0,0 +1,182 @@ +#[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 inputImage; +layout( rgba16f, set = 1, binding = 0 ) +uniform image2D outputImage; + + +layout( push_constant, std430 ) +uniform Parameters +{ + vec4 r; + vec4 g; + vec4 b; + vec4 rgb; + + vec4 h; + vec4 s; + vec4 l; + vec4 settings; + +} parameters; + + +vec3 RGBtoHSL( vec3 c ) +{ + float h = 0.0; + float s = 0.0; + float l = 0.0; + + float cmin = min( min( c.r, c.g ), c.b ); + float cmax = max( max( c.r, c.g ), c.b ); + + l = ( cmin + cmax ) / 2.0; + + if ( cmin == cmax ) + { + s = 0.0; + h = 0.0; + } + else + { + float delta = cmax - cmin; + float both = cmax + cmin; + + s = ( l <= 0.5 ) ? + ( both == 0.0 ? 0.0 : ( delta / both ) ) : + ( delta / ( 2.0 - both ) ); + + h = 0.0; + + if ( c.r == cmax ) + { + h = delta == 0.0 ? 0.0 : ( ( c.g - c.b ) / delta ); + } + else if ( c.g == cmax ) + { + h = delta == 0.0 ? 0.0 : ( 2.0 + ( c.b - c.r ) / delta ); + } + else if ( c.b == cmax ) + { + h = delta == 0.0 ? 0.0 : ( 4.0 + ( c.r - c.g ) / delta ) ; + } + + h = h / 6.0; + + if ( h > 1.0 ) + { + h -= 1.0; + } + + } + + return vec3( h, s, l ); +} + +vec3 hueToRGB( float hue ) +{ + float R = abs( hue * 6.0 - 3.0 ) - 1.0; + float G = 2.0 - abs( hue * 6.0 - 2.0 ); + float B = 2.0 - abs( hue * 6.0 - 4.0 ); + return clamp( vec3( R,G,B ), 0, 1 ); +} + +vec3 HSLtoRGB( vec3 hsl ) +{ + if ( hsl.y == 0.0 ) + { + return vec3( hsl.z, hsl.z, hsl.z ); + } + + vec3 rgb = hueToRGB( hsl.x ); + float C = ( 1.0 - abs( 2.0 * hsl.z - 1.0 )) * hsl.y; + return ( rgb - 0.5 ) * C + hsl.z; +} + +float applyGamma( float x, float power ) +{ + if ( x <= 0.0 ) + { + return 0.0; + } + + return pow( x, power ); +} + +float apply( float x, vec4 parameters ) +{ + float amount = parameters.x; + float steps = parameters.y; + float power = parameters.z; + float off = parameters.w; + + float y = applyGamma( x + off, power ); + y = round( y * steps ) / steps; + return mix( x, applyGamma( y, 1.0/ power ) - off, amount ); +} + +vec4 applyRGB( vec4 v, vec4 parameters ) +{ + v.x = apply( v.x, parameters ); + v.y = apply( v.y, parameters ); + v.z = apply( v.z, parameters ); + + return v; +} + + +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 ); + + vec4 color = imageLoad( inputImage, ivec2( uv * size ) ); + + vec4 rgb = color; + rgb.r = apply( rgb.r, parameters.r ); + rgb.g = apply( rgb.g, parameters.g ); + rgb.b = apply( rgb.b, parameters.b ); + + rgb = applyRGB( rgb, parameters.rgb ); + + int NONE = 0; + int SCALE = 1; + int CLAMP = 2; + + int hslMode = int( round( parameters.settings.y ) ); + float scaler = 1.0; + + if ( hslMode == SCALE ) + { + scaler = max( max( max( rgb.r, rgb.g ), rgb.b ), 1.0 ); + } + + if ( hslMode == CLAMP ) + { + rgb.rgb = clamp( rgb.rgb, 0.0, 1.0 ); + } + + vec3 hsl = RGBtoHSL( rgb.rgb / scaler ); + hsl.r = apply( hsl.r, parameters.h ); + hsl.g = apply( hsl.g, parameters.s ); + hsl.b = apply( hsl.b, parameters.l ); + + vec4 posterColor = vec4( HSLtoRGB( hsl ) * scaler, color.a ); + + + vec4 blended = mix( color, posterColor, parameters.settings.x ); + + + imageStore( outputImage, texel_coord, blended ); +} \ No newline at end of file diff --git a/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/ColorQuantizer/ColorQuantizer.glsl.import b/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/ColorQuantizer/ColorQuantizer.glsl.import new file mode 100644 index 0000000..dfda57f --- /dev/null +++ b/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/ColorQuantizer/ColorQuantizer.glsl.import @@ -0,0 +1,14 @@ +[remap] + +importer="glsl" +type="RDShaderFile" +uid="uid://pt5sgwsji4qe" +path="res://.godot/imported/ColorQuantizer.glsl-68db05911563e8ec1917ba51206dd6ab.res" + +[deps] + +source_file="res://addons/rokojori_action_library/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/ColorQuantizer/ColorQuantizer.glsl" +dest_files=["res://.godot/imported/ColorQuantizer.glsl-68db05911563e8ec1917ba51206dd6ab.res"] + +[params] + diff --git a/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/ColorQuantizer/RG_ColorQuantizer.cs b/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/ColorQuantizer/RG_ColorQuantizer.cs new file mode 100644 index 0000000..54d50b9 --- /dev/null +++ b/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/ColorQuantizer/RG_ColorQuantizer.cs @@ -0,0 +1,17 @@ + +using Godot; +using System.Collections.Generic; + +namespace Rokojori +{ + public class RG_ColorQuantizer:CEG_ImageProcessor + { + public static readonly string shaderPath = + RDGraph.Path( "Nodes/Processors/Color/ColorQuantizer/ColorQuantizer.glsl" ); + + public RG_ColorQuantizer( RDGraph graph ):base( graph, shaderPath ) + {} + + + } +} \ No newline at end of file diff --git a/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/ColorQuantizer/RG_ColorQuantizer.cs.uid b/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/ColorQuantizer/RG_ColorQuantizer.cs.uid new file mode 100644 index 0000000..a900d6d --- /dev/null +++ b/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/ColorQuantizer/RG_ColorQuantizer.cs.uid @@ -0,0 +1 @@ +uid://u4s8vs05cmto diff --git a/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/HSLAdjustment/HSLAdjustment.glsl b/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/HSLAdjustment/HSLAdjustment.glsl new file mode 100644 index 0000000..a3d1556 --- /dev/null +++ b/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/HSLAdjustment/HSLAdjustment.glsl @@ -0,0 +1,208 @@ +#[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 inputImage; +layout( rgba16f, set = 1, binding = 0 ) +uniform image2D outputImage; + + +layout( push_constant, std430 ) +uniform Parameters +{ + float amount; + float h; + float t; + float s; + + float sp; + float l; + float lp; + float hslMode; + + float tBlendRadius; + float p0; + float p1; + float p2; + +} parameters; + + +vec3 RGBtoHSL( vec3 c ) +{ + float h = 0.0; + float s = 0.0; + float l = 0.0; + + float cmin = min( min( c.r, c.g ), c.b ); + float cmax = max( max( c.r, c.g ), c.b ); + + l = ( cmin + cmax ) / 2.0; + + if ( cmin == cmax ) + { + s = 0.0; + h = 0.0; + } + else + { + float delta = cmax - cmin; + float both = cmax + cmin; + + s = ( l <= 0.5 ) ? + ( both == 0.0 ? 0.0 : ( delta / both ) ) : + ( delta / ( 2.0 - both ) ); + + h = 0.0; + + if ( c.r == cmax ) + { + h = delta == 0.0 ? 0.0 : ( ( c.g - c.b ) / delta ); + } + else if ( c.g == cmax ) + { + h = delta == 0.0 ? 0.0 : ( 2.0 + ( c.b - c.r ) / delta ); + } + else if ( c.b == cmax ) + { + h = delta == 0.0 ? 0.0 : ( 4.0 + ( c.r - c.g ) / delta ) ; + } + + h = h / 6.0; + + if ( h > 1.0 ) + { + h -= 1.0; + } + + } + + return vec3( h, s, l ); +} + +vec3 hueToRGB( float hue ) +{ + float R = abs( hue * 6.0 - 3.0 ) - 1.0; + float G = 2.0 - abs( hue * 6.0 - 2.0 ); + float B = 2.0 - abs( hue * 6.0 - 4.0 ); + return clamp( vec3( R,G,B ), 0, 1 ); +} + +vec3 HSLtoRGB( vec3 hsl ) +{ + if ( hsl.y == 0.0 ) + { + return vec3( hsl.z, hsl.z, hsl.z ); + } + + vec3 rgb = hueToRGB( hsl.x ); + float C = ( 1.0 - abs( 2.0 * hsl.z - 1.0 )) * hsl.y; + return ( rgb - 0.5 ) * C + hsl.z; +} + +float modPolarDegrees( float value ) +{ + return mod( value + 180.0, 360.0 ) - 180.0; +} + + +vec3 changeHueOfRGB( vec3 rgb, float hueChange ) +{ + vec3 hsl = RGBtoHSL( rgb ); + hsl.x = mod( hsl.x + hueChange, 1.0 ) ; + + return HSLtoRGB( hsl ); +} + +float hue360ToYB( float hue ) +{ + return modPolarDegrees( hue - 240.0 ); +} + +float ybToHue360( float yb ) +{ + return mod( yb + 240.0, 360.0 ); +} + +float changeHue360( float hue, float change ) +{ + float yb = hue360ToYB( hue ); + + float absYB = abs( yb ); + + absYB = clamp( absYB + change, 0.0, 180.0 ); + + float realYB = sign( yb ) * absYB; + + return ybToHue360( realYB ); +} + +float changeHue360Blended( float hue, float change, float blendRadius ) +{ + float distanceToYellow = min( 1.0, abs( hue - 60.0 ) / blendRadius ); + float distanceToBlue = min( 1.0, abs( hue - 240.0 ) / blendRadius ); + + return changeHue360( hue, change * distanceToYellow * distanceToBlue ); +} + +vec3 shiftHSL360( vec3 hslWithH360, vec3 offset, float blendRadius ) +{ + float distanceToYellow = min( 1.0, abs( hslWithH360.x - 60.0 ) / blendRadius ); + float distanceToBlue = min( 1.0, abs( hslWithH360.x - 240.0 ) / blendRadius ); + + hslWithH360.x = changeHue360( hslWithH360.x, offset.x * distanceToYellow * distanceToBlue ); + hslWithH360.y = clamp( hslWithH360.y + offset.y, 0, 1 ); + hslWithH360.z = clamp( hslWithH360.z + offset.z, 0, 1 ); + + return hslWithH360; +} + +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 ); + + vec4 color = imageLoad( inputImage, ivec2( uv * size ) ); + + vec4 rgb = color; + + int NONE = 0; + int SCALE = 1; + int CLAMP = 2; + + int hslMode = int( round( parameters.hslMode ) ); + float scaler = 1.0; + + if ( hslMode == SCALE ) + { + scaler = max( max( max( rgb.r, rgb.g ), rgb.b ), 1.0 ); + } + + if ( hslMode == CLAMP ) + { + rgb.rgb = clamp( rgb.rgb, 0.0, 1.0 ); + } + + vec3 hsl = RGBtoHSL( rgb.rgb / scaler ); + hsl.r = mod( hsl.r + parameters.h, 1.0 ); + hsl.r = changeHue360Blended( hsl.r * 360.0, parameters.t, parameters.tBlendRadius) / 360.0; + hsl.g = clamp( pow( hsl.g, parameters.sp ) + parameters.s, 0.0, 1.0 ); + hsl.b = clamp( pow( hsl.b, parameters.lp ) + parameters.l, 0.0, 1.0 ); + + vec4 processedColor = vec4( HSLtoRGB( hsl ) * scaler, color.a ); + + + vec4 blended = mix( color, processedColor, parameters.amount ); + + + imageStore( outputImage, texel_coord, blended ); +} \ No newline at end of file diff --git a/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/HSLAdjustment/HSLAdjustment.glsl.import b/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/HSLAdjustment/HSLAdjustment.glsl.import new file mode 100644 index 0000000..0b308ec --- /dev/null +++ b/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/HSLAdjustment/HSLAdjustment.glsl.import @@ -0,0 +1,14 @@ +[remap] + +importer="glsl" +type="RDShaderFile" +uid="uid://cvyxjo22y6g8a" +path="res://.godot/imported/HSLAdjustment.glsl-d01c2dde505d97a50e752af329ce3d54.res" + +[deps] + +source_file="res://addons/rokojori_action_library/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/HSLAdjustment/HSLAdjustment.glsl" +dest_files=["res://.godot/imported/HSLAdjustment.glsl-d01c2dde505d97a50e752af329ce3d54.res"] + +[params] + diff --git a/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/HSLAdjustment/RG_HSLAdjustment.cs b/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/HSLAdjustment/RG_HSLAdjustment.cs new file mode 100644 index 0000000..4cc86c6 --- /dev/null +++ b/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/HSLAdjustment/RG_HSLAdjustment.cs @@ -0,0 +1,17 @@ + +using Godot; +using System.Collections.Generic; + +namespace Rokojori +{ + public class RG_HSLAdjustment:CEG_ImageProcessor + { + public static readonly string shaderPath = + RDGraph.Path( "Nodes/Processors/Color/HSLAdjustment/HSLAdjustment.glsl" ); + + public RG_HSLAdjustment( RDGraph graph ):base( graph, shaderPath ) + {} + + + } +} \ No newline at end of file diff --git a/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/HSLAdjustment/RG_HSLAdjustment.cs.uid b/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/HSLAdjustment/RG_HSLAdjustment.cs.uid new file mode 100644 index 0000000..3f1b526 --- /dev/null +++ b/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/HSLAdjustment/RG_HSLAdjustment.cs.uid @@ -0,0 +1 @@ +uid://disjx4q2bdjbm diff --git a/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/Invert/Invert.glsl b/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/Invert/Invert.glsl new file mode 100644 index 0000000..03fe9a5 --- /dev/null +++ b/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/Invert/Invert.glsl @@ -0,0 +1,156 @@ +#[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 inputImage; +layout( rgba16f, set = 1, binding = 0 ) +uniform image2D outputImage; + + +layout( push_constant, std430 ) +uniform Parameters +{ + float amount; + float r; + float g; + float b; + +} 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 )) ); +} + +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))); +} + + +vec3 RGBtoHSL( vec3 c ) +{ + float h = 0.0; + float s = 0.0; + float l = 0.0; + + float cmin = min( min( c.r, c.g ), c.b ); + float cmax = max( max( c.r, c.g ), c.b ); + + l = ( cmin + cmax ) / 2.0; + + if ( cmin == cmax ) + { + s = 0.0; + h = 0.0; + } + else + { + float delta = cmax - cmin; + + s = ( l <= 0.5 ) ? ( delta / ( cmax + cmin ) ) : ( delta / ( 2.0 - ( cmax + cmin ) ) ); + + h = 0.0; + + if ( c.r == cmax ) + { + h = ( c.g - c.b ) / delta; + } + else if ( c.g == cmax ) + { + h = 2.0 + ( c.b - c.r ) / delta; + } + else if ( c.b == cmax ) + { + h = 4.0 + ( c.r - c.g ) / delta; + } + + h = h / 6.0; + + if ( h > 1.0 ) + { + h -= 1.0; + } + + } + + return vec3( h, s, l ); +} + +vec3 hueToRGB( float hue ) +{ + float R = abs( hue * 6.0 - 3.0 ) - 1.0; + float G = 2.0 - abs( hue * 6.0 - 2.0 ); + float B = 2.0 - abs( hue * 6.0 - 4.0 ); + return clamp( vec3( R,G,B ), 0, 1 ); +} + +vec3 HSLtoRGB( vec3 hsl ) +{ + if ( hsl.y == 0.0 ) + { + return vec3( hsl.z, hsl.z, hsl.z ); + } + + vec3 rgb = hueToRGB( hsl.x ); + float C = ( 1.0 - abs( 2.0 * hsl.z - 1.0 )) * hsl.y; + return ( rgb - 0.5 ) * C + hsl.z; +} + +float applyGamma( float x, float power ) +{ + if ( x <= 0.0 ) + { + return 0.0; + } + + return pow( x, power ); +} + +vec4 gammaColor( vec4 v, float power ) +{ + v.x = applyGamma( v.x, power ); + v.y = applyGamma( v.y, power ); + v.z = applyGamma( v.z, power ); + + return v; +} + +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 ); + + + + vec4 color = imageLoad( inputImage, ivec2( uv * size ) ); + + vec4 invertedColor = vec4( LINEARtoSRGB( color.rgb ), color.a ); + + float maxV = max( 1.0, max( invertedColor.r, max( invertedColor.g, invertedColor.b ) ) ); + invertedColor /= maxV; + + invertedColor.r = parameters.r < 0.5 ? invertedColor.r : ( 1.0 - invertedColor.r ); + invertedColor.g = parameters.g < 0.5 ? invertedColor.g : ( 1.0 - invertedColor.g ); + invertedColor.b = parameters.b < 0.5 ? invertedColor.b : ( 1.0 - invertedColor.b ); + + invertedColor *= maxV; + + invertedColor.rgb = SRGBtoLINEAR( invertedColor.rgb ); + + vec4 blended = mix( color, invertedColor, parameters.amount ); + + + imageStore( outputImage, texel_coord, blended ); +} \ No newline at end of file diff --git a/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/Invert/Invert.glsl.import b/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/Invert/Invert.glsl.import new file mode 100644 index 0000000..e0ec9bd --- /dev/null +++ b/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/Invert/Invert.glsl.import @@ -0,0 +1,14 @@ +[remap] + +importer="glsl" +type="RDShaderFile" +uid="uid://xlqgoulucny3" +path="res://.godot/imported/Invert.glsl-e536eda71df4cd1428c6b86e70585c9e.res" + +[deps] + +source_file="res://addons/rokojori_action_library/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/Invert/Invert.glsl" +dest_files=["res://.godot/imported/Invert.glsl-e536eda71df4cd1428c6b86e70585c9e.res"] + +[params] + diff --git a/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/Invert/RG_Invert.cs b/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/Invert/RG_Invert.cs new file mode 100644 index 0000000..a299f35 --- /dev/null +++ b/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/Invert/RG_Invert.cs @@ -0,0 +1,17 @@ + +using Godot; +using System.Collections.Generic; + +namespace Rokojori +{ + public class RG_Invert:CEG_ImageProcessor + { + public static readonly string shaderPath = + RDGraph.Path( "Nodes/Processors/Color/Invert/Invert.glsl" ); + + public RG_Invert( RDGraph graph ):base( graph, shaderPath ) + {} + + + } +} \ No newline at end of file diff --git a/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/Invert/RG_Invert.cs.uid b/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/Invert/RG_Invert.cs.uid new file mode 100644 index 0000000..3e66eab --- /dev/null +++ b/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/Invert/RG_Invert.cs.uid @@ -0,0 +1 @@ +uid://u4v7gvnxrx3y diff --git a/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/LightnessBasedAdjustment/LightnessBasedAdjustment.glsl b/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/LightnessBasedAdjustment/LightnessBasedAdjustment.glsl new file mode 100644 index 0000000..7f28ec0 --- /dev/null +++ b/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/LightnessBasedAdjustment/LightnessBasedAdjustment.glsl @@ -0,0 +1,158 @@ +#[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 inputImage; +layout( rgba16f, set = 1, binding = 0 ) +uniform image2D outputImage; + + +layout( push_constant, std430 ) +uniform Parameters +{ + vec4 h; + vec4 s; + vec4 l; + vec4 pad; + float amount; + float pad0; + float pad1; + float pad2; + + +} parameters; + + +vec3 RGBtoHSL( vec3 c ) +{ + float h = 0.0; + float s = 0.0; + float l = 0.0; + + float cmin = min( min( c.r, c.g ), c.b ); + float cmax = max( max( c.r, c.g ), c.b ); + + l = ( cmin + cmax ) / 2.0; + + if ( cmin == cmax ) + { + s = 0.0; + h = 0.0; + } + else + { + float delta = cmax - cmin; + + s = ( l <= 0.5 ) ? ( delta / ( cmax + cmin ) ) : ( delta / ( 2.0 - ( cmax + cmin ) ) ); + + h = 0.0; + + if ( c.r == cmax ) + { + h = ( c.g - c.b ) / delta; + } + else if ( c.g == cmax ) + { + h = 2.0 + ( c.b - c.r ) / delta; + } + else if ( c.b == cmax ) + { + h = 4.0 + ( c.r - c.g ) / delta; + } + + h = h / 6.0; + + if ( h > 1.0 ) + { + h -= 1.0; + } + + } + + return vec3( h, s, l ); +} + +vec3 hueToRGB( float hue ) +{ + float R = abs( hue * 6.0 - 3.0 ) - 1.0; + float G = 2.0 - abs( hue * 6.0 - 2.0 ); + float B = 2.0 - abs( hue * 6.0 - 4.0 ); + return clamp( vec3( R,G,B ), 0, 1 ); +} + +vec3 HSLtoRGB( vec3 hsl ) +{ + if ( hsl.y == 0.0 ) + { + return vec3( hsl.z, hsl.z, hsl.z ); + } + + vec3 rgb = hueToRGB( hsl.x ); + float C = ( 1.0 - abs( 2.0 * hsl.z - 1.0 )) * hsl.y; + return ( rgb - 0.5 ) * C + hsl.z; +} + +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 ); +} + +void main( ) +{ + ivec2 size = imageSize( inputImage ); + ivec2 texel_coord = ivec2( gl_GlobalInvocationID.xy ); + + if ( any( greaterThanEqual( texel_coord, size ) ) ) + { + return; + } + + + vec4 color = imageLoad( inputImage, texel_coord ); + + vec4 sRGB = LINEARtoSRGB( color ); + float scale = max( 1.0, max( sRGB.r, max( sRGB.g, sRGB.b ) ) ); + vec4 scaledColor = sRGB / scale; + + vec3 hsl = RGBtoHSL( scaledColor.rgb ); + + vec3 offsetX = vec3( parameters.h.x * parameters.h.w, parameters.s.x * parameters.s.w, parameters.l.x * parameters.l.w ); + vec3 offsetY = vec3( parameters.h.y * parameters.h.w, parameters.s.y * parameters.s.w, parameters.l.y * parameters.l.w ); + vec3 offsetZ = vec3( parameters.h.z * parameters.h.w, parameters.s.z * parameters.s.w, parameters.l.z * parameters.l.w ); + + vec3 lerpedOffset = hsl.z < 0.5 ? mix( offsetX, offsetY, hsl.z * 2.0 ) : + mix( offsetY, offsetZ, ( hsl.z - 0.5 ) * 2.0 ); + + vec3 lerpedHSL = hsl; + lerpedHSL.x = mod( lerpedHSL.x + lerpedOffset.x, 1.0 ); + lerpedHSL.y = clamp( lerpedHSL.y + lerpedOffset.y, 0.0, 1.0 ); + lerpedHSL.z = clamp( lerpedHSL.z + lerpedOffset.z, 0.0, 1.0 ); + + vec4 processedColor = vec4( HSLtoRGB( lerpedHSL ) * scale, color.a ); + processedColor = SRGBtoLINEAR( processedColor ); + + + vec4 blended = mix( color, processedColor, parameters.amount ); + + + imageStore( outputImage, texel_coord, blended ); +} \ No newline at end of file diff --git a/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/LightnessBasedAdjustment/LightnessBasedAdjustment.glsl.import b/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/LightnessBasedAdjustment/LightnessBasedAdjustment.glsl.import new file mode 100644 index 0000000..abbbb02 --- /dev/null +++ b/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/LightnessBasedAdjustment/LightnessBasedAdjustment.glsl.import @@ -0,0 +1,14 @@ +[remap] + +importer="glsl" +type="RDShaderFile" +uid="uid://k2mgqrsy2q5g" +path="res://.godot/imported/LightnessBasedAdjustment.glsl-010561f97d3def7287134adc5db44cfe.res" + +[deps] + +source_file="res://addons/rokojori_action_library/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/LightnessBasedAdjustment/LightnessBasedAdjustment.glsl" +dest_files=["res://.godot/imported/LightnessBasedAdjustment.glsl-010561f97d3def7287134adc5db44cfe.res"] + +[params] + diff --git a/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/LightnessBasedAdjustment/RG_LightnessBasedAdjustment.cs b/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/LightnessBasedAdjustment/RG_LightnessBasedAdjustment.cs new file mode 100644 index 0000000..f7d857f --- /dev/null +++ b/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/LightnessBasedAdjustment/RG_LightnessBasedAdjustment.cs @@ -0,0 +1,17 @@ + +using Godot; +using System.Collections.Generic; + +namespace Rokojori +{ + public class RG_LightnessBasedAdjustment:CEG_ImageProcessor + { + public static readonly string shaderPath = + RDGraph.Path( "Nodes/Processors/Color/LightnessBasedAdjustment/LightnessBasedAdjustment.glsl" ); + + public RG_LightnessBasedAdjustment( RDGraph graph ):base( graph, shaderPath ) + {} + + + } +} \ No newline at end of file diff --git a/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/LightnessBasedAdjustment/RG_LightnessBasedAdjustment.cs.uid b/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/LightnessBasedAdjustment/RG_LightnessBasedAdjustment.cs.uid new file mode 100644 index 0000000..4d40c95 --- /dev/null +++ b/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/LightnessBasedAdjustment/RG_LightnessBasedAdjustment.cs.uid @@ -0,0 +1 @@ +uid://bl0nsj1m6ahc4 diff --git a/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/Posterization/Posterization.glsl b/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/Posterization/Posterization.glsl new file mode 100644 index 0000000..00c49e8 --- /dev/null +++ b/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/Posterization/Posterization.glsl @@ -0,0 +1,138 @@ +#[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 inputImage; +layout( rgba16f, set = 1, binding = 0 ) +uniform image2D outputImage; + + +layout( push_constant, std430 ) +uniform Parameters +{ + float amount; + float steps; + float gamma; + float off; + +} parameters; + + +vec3 RGBtoHSL( vec3 c ) +{ + float h = 0.0; + float s = 0.0; + float l = 0.0; + + float cmin = min( min( c.r, c.g ), c.b ); + float cmax = max( max( c.r, c.g ), c.b ); + + l = ( cmin + cmax ) / 2.0; + + if ( cmin == cmax ) + { + s = 0.0; + h = 0.0; + } + else + { + float delta = cmax - cmin; + + s = ( l <= 0.5 ) ? ( delta / ( cmax + cmin ) ) : ( delta / ( 2.0 - ( cmax + cmin ) ) ); + + h = 0.0; + + if ( c.r == cmax ) + { + h = ( c.g - c.b ) / delta; + } + else if ( c.g == cmax ) + { + h = 2.0 + ( c.b - c.r ) / delta; + } + else if ( c.b == cmax ) + { + h = 4.0 + ( c.r - c.g ) / delta; + } + + h = h / 6.0; + + if ( h > 1.0 ) + { + h -= 1.0; + } + + } + + return vec3( h, s, l ); +} + +vec3 hueToRGB( float hue ) +{ + float R = abs( hue * 6.0 - 3.0 ) - 1.0; + float G = 2.0 - abs( hue * 6.0 - 2.0 ); + float B = 2.0 - abs( hue * 6.0 - 4.0 ); + return clamp( vec3( R,G,B ), 0, 1 ); +} + +vec3 HSLtoRGB( vec3 hsl ) +{ + if ( hsl.y == 0.0 ) + { + return vec3( hsl.z, hsl.z, hsl.z ); + } + + vec3 rgb = hueToRGB( hsl.x ); + float C = ( 1.0 - abs( 2.0 * hsl.z - 1.0 )) * hsl.y; + return ( rgb - 0.5 ) * C + hsl.z; +} + +float applyGamma( float x, float power ) +{ + if ( x <= 0.0 ) + { + return 0.0; + } + + return pow( x, power ); +} + +vec4 gammaColor( vec4 v, float power ) +{ + v.x = applyGamma( v.x, power ); + v.y = applyGamma( v.y, power ); + v.z = applyGamma( v.z, power ); + + return v; +} + +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 ); + + vec4 color = imageLoad( inputImage, ivec2( uv * size ) ); + + float off = parameters.off; + vec4 offset = vec4( off, off, off, 0); + + vec4 gColor = color; + gColor = gammaColor( color + offset, parameters.gamma ); + vec4 posterColor = round( gColor * parameters.steps ) / parameters.steps; + posterColor = gammaColor( posterColor, parameters.gamma ) - offset; + + + vec4 blended = mix( color, posterColor, parameters.amount ); + + + imageStore( outputImage, texel_coord, blended ); +} \ No newline at end of file diff --git a/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/Posterization/Posterization.glsl.import b/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/Posterization/Posterization.glsl.import new file mode 100644 index 0000000..a89c5ba --- /dev/null +++ b/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/Posterization/Posterization.glsl.import @@ -0,0 +1,14 @@ +[remap] + +importer="glsl" +type="RDShaderFile" +uid="uid://clvkmeu1lxyj6" +path="res://.godot/imported/Posterization.glsl-ea3489149cb3e34a41a4e78e183669b0.res" + +[deps] + +source_file="res://addons/rokojori_action_library/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/Posterization/Posterization.glsl" +dest_files=["res://.godot/imported/Posterization.glsl-ea3489149cb3e34a41a4e78e183669b0.res"] + +[params] + diff --git a/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/Posterization/RG_Posterization.cs b/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/Posterization/RG_Posterization.cs new file mode 100644 index 0000000..74beac5 --- /dev/null +++ b/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/Posterization/RG_Posterization.cs @@ -0,0 +1,17 @@ + +using Godot; +using System.Collections.Generic; + +namespace Rokojori +{ + public class RG_Posterization:CEG_ImageProcessor + { + public static readonly string shaderPath = + RDGraph.Path( "Nodes/Processors/Color/Posterization/Posterization.glsl" ); + + public RG_Posterization( RDGraph graph ):base( graph, shaderPath ) + {} + + + } +} \ No newline at end of file diff --git a/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/Posterization/RG_Posterization.cs.uid b/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/Posterization/RG_Posterization.cs.uid new file mode 100644 index 0000000..1a21835 --- /dev/null +++ b/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/Posterization/RG_Posterization.cs.uid @@ -0,0 +1 @@ +uid://lk8i5eldaq1b diff --git a/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/ReplaceColor/RG_ReplaceColor.cs b/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/ReplaceColor/RG_ReplaceColor.cs new file mode 100644 index 0000000..68f3d4a --- /dev/null +++ b/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/ReplaceColor/RG_ReplaceColor.cs @@ -0,0 +1,17 @@ + +using Godot; +using System.Collections.Generic; + +namespace Rokojori +{ + public class RG_ReplaceColor:CEG_ImageProcessor + { + public static readonly string shaderPath = + RDGraph.Path( "Nodes/Processors/Color/ReplaceColor/ReplaceColor.glsl" ); + + public RG_ReplaceColor( RDGraph graph ):base( graph, shaderPath ) + {} + + + } +} \ No newline at end of file diff --git a/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/ReplaceColor/RG_ReplaceColor.cs.uid b/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/ReplaceColor/RG_ReplaceColor.cs.uid new file mode 100644 index 0000000..53231bd --- /dev/null +++ b/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/ReplaceColor/RG_ReplaceColor.cs.uid @@ -0,0 +1 @@ +uid://bfww66s0qml6d diff --git a/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/ReplaceColor/ReplaceColor.glsl b/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/ReplaceColor/ReplaceColor.glsl new file mode 100644 index 0000000..363cda0 --- /dev/null +++ b/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/ReplaceColor/ReplaceColor.glsl @@ -0,0 +1,74 @@ +#[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 inputImage; +layout( rgba16f, set = 1, binding = 0 ) +uniform image2D outputImage; + + +layout( push_constant, std430 ) +uniform Parameters +{ + vec4 searchColor; + vec4 replacementColor; + + float amount; + float colorDistanceMax; + float colorDistanceMin; + float colorSpace; + +} 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 ); +} + +void main( ) +{ + ivec2 size = imageSize( inputImage ); + ivec2 texel_coord = ivec2( gl_GlobalInvocationID.xy ); + + if ( any( greaterThanEqual( texel_coord, size ) ) ) + { + return; + } + + vec4 color = imageLoad( inputImage, texel_coord ); + + vec4 colorA = LINEARtoSRGB( color ) ; + vec4 colorB = parameters.searchColor; + + float dist = length( colorA.rgb - colorB.rgb ); + dist = max( 0.0, dist - parameters.colorDistanceMin ); + dist = min( 1.0, dist / parameters.colorDistanceMax ); + + float replaceAmount = 1.0 - dist; + + vec4 replacedColor = SRGBtoLINEAR( parameters.replacementColor ); + vec4 blended = mix( color, replacedColor, parameters.amount * replaceAmount ); + // blended = vec4( replaceAmount, replaceAmount, replaceAmount, 1.0 ); + + imageStore( outputImage, texel_coord, blended ); +} \ No newline at end of file diff --git a/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/ReplaceColor/ReplaceColor.glsl.import b/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/ReplaceColor/ReplaceColor.glsl.import new file mode 100644 index 0000000..0ab3023 --- /dev/null +++ b/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/ReplaceColor/ReplaceColor.glsl.import @@ -0,0 +1,14 @@ +[remap] + +importer="glsl" +type="RDShaderFile" +uid="uid://bkeu321cfhd1y" +path="res://.godot/imported/ReplaceColor.glsl-299dcd7071f443b0d26fe49c0c67fccc.res" + +[deps] + +source_file="res://addons/rokojori_action_library/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/ReplaceColor/ReplaceColor.glsl" +dest_files=["res://.godot/imported/ReplaceColor.glsl-299dcd7071f443b0d26fe49c0c67fccc.res"] + +[params] + diff --git a/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/Sepia/RG_Sepia.cs b/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/Sepia/RG_Sepia.cs new file mode 100644 index 0000000..b7d6855 --- /dev/null +++ b/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/Sepia/RG_Sepia.cs @@ -0,0 +1,17 @@ + +using Godot; +using System.Collections.Generic; + +namespace Rokojori +{ + public class RG_Sepia:CEG_ImageProcessor + { + public static readonly string shaderPath = + RDGraph.Path( "Nodes/Processors/Color/Sepia/Sepia.glsl" ); + + public RG_Sepia( RDGraph graph ):base( graph, shaderPath ) + {} + + + } +} \ No newline at end of file diff --git a/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/Sepia/RG_Sepia.cs.uid b/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/Sepia/RG_Sepia.cs.uid new file mode 100644 index 0000000..c60db7a --- /dev/null +++ b/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/Sepia/RG_Sepia.cs.uid @@ -0,0 +1 @@ +uid://cg18sqym0g4os diff --git a/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/Sepia/Sepia.glsl b/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/Sepia/Sepia.glsl new file mode 100644 index 0000000..472bc7a --- /dev/null +++ b/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/Sepia/Sepia.glsl @@ -0,0 +1,122 @@ +#[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 inputImage; +layout( rgba16f, set = 1, binding = 0 ) +uniform image2D outputImage; + + +layout( push_constant, std430 ) +uniform Parameters +{ + float amount; + float hue; + float saturationOverride; + float saturationAmount; + +} parameters; + + +vec3 RGBtoHSL( vec3 c ) +{ + float h = 0.0; + float s = 0.0; + float l = 0.0; + + float cmin = min( min( c.r, c.g ), c.b ); + float cmax = max( max( c.r, c.g ), c.b ); + + l = ( cmin + cmax ) / 2.0; + + if ( cmin == cmax ) + { + s = 0.0; + h = 0.0; + } + else + { + float delta = cmax - cmin; + + s = ( l <= 0.5 ) ? ( delta / ( cmax + cmin ) ) : ( delta / ( 2.0 - ( cmax + cmin ) ) ); + + h = 0.0; + + if ( c.r == cmax ) + { + h = ( c.g - c.b ) / delta; + } + else if ( c.g == cmax ) + { + h = 2.0 + ( c.b - c.r ) / delta; + } + else if ( c.b == cmax ) + { + h = 4.0 + ( c.r - c.g ) / delta; + } + + h = h / 6.0; + + if ( h > 1.0 ) + { + h -= 1.0; + } + + } + + return vec3( h, s, l ); +} + +vec3 hueToRGB( float hue ) +{ + float R = abs( hue * 6.0 - 3.0 ) - 1.0; + float G = 2.0 - abs( hue * 6.0 - 2.0 ); + float B = 2.0 - abs( hue * 6.0 - 4.0 ); + return clamp( vec3( R,G,B ), 0, 1 ); +} + +vec3 HSLtoRGB( vec3 hsl ) +{ + if ( hsl.y == 0.0 ) + { + return vec3( hsl.z, hsl.z, hsl.z ); + } + + vec3 rgb = hueToRGB( hsl.x ); + float C = ( 1.0 - abs( 2.0 * hsl.z - 1.0 )) * hsl.y; + return ( rgb - 0.5 ) * C + hsl.z; +} + +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 ); + + vec4 color = imageLoad( inputImage, ivec2( uv * size ) ); + + float scaler = max( max( max( color.r, color.g ), color.b ), 1.0 ); + + vec3 hsl = RGBtoHSL( color.rgb / scaler ); + + hsl.x = parameters.hue; + hsl.y = mix( hsl.y, parameters.saturationOverride, parameters.saturationAmount ); + + vec3 rgb = HSLtoRGB( hsl ) * scaler; + + vec4 sepiaColor = vec4( rgb, 1.0 ); + + + vec4 blended = mix( color, sepiaColor, parameters.amount ); + + + imageStore( outputImage, texel_coord, blended ); +} \ No newline at end of file diff --git a/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/Sepia/Sepia.glsl.import b/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/Sepia/Sepia.glsl.import new file mode 100644 index 0000000..bc7f454 --- /dev/null +++ b/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/Sepia/Sepia.glsl.import @@ -0,0 +1,14 @@ +[remap] + +importer="glsl" +type="RDShaderFile" +uid="uid://f108ocsg57wx" +path="res://.godot/imported/Sepia.glsl-f73d9003bf68ddf4b6920a6e59a092b0.res" + +[deps] + +source_file="res://addons/rokojori_action_library/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/Sepia/Sepia.glsl" +dest_files=["res://.godot/imported/Sepia.glsl-f73d9003bf68ddf4b6920a6e59a092b0.res"] + +[params] + diff --git a/Runtime/Rendering/RenderGraph/Nodes/Processors/Distortion/Distortion.gdshaderinc b/Runtime/Rendering/RenderGraph/Nodes/Processors/Distortion/Distortion.gdshaderinc new file mode 100644 index 0000000..e69de29 diff --git a/Runtime/Rendering/RenderGraph/Nodes/Processors/Distortion/Distortion.gdshaderinc.uid b/Runtime/Rendering/RenderGraph/Nodes/Processors/Distortion/Distortion.gdshaderinc.uid new file mode 100644 index 0000000..b76f567 --- /dev/null +++ b/Runtime/Rendering/RenderGraph/Nodes/Processors/Distortion/Distortion.gdshaderinc.uid @@ -0,0 +1 @@ +uid://b54gtivmiiprf diff --git a/Runtime/Rendering/RenderGraph/Nodes/Processors/Distortion/EllipseDistortion/EllipseDistortion.glsl b/Runtime/Rendering/RenderGraph/Nodes/Processors/Distortion/EllipseDistortion/EllipseDistortion.glsl new file mode 100644 index 0000000..b978705 --- /dev/null +++ b/Runtime/Rendering/RenderGraph/Nodes/Processors/Distortion/EllipseDistortion/EllipseDistortion.glsl @@ -0,0 +1,253 @@ +#[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 ) ); +} + +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 mirrorValue( float x ) +{ + float t = mod( x, 2.0 ); + return ( t <= 1.0 ) ? t : 2.0 - t; +} + +vec2 mirrorUV( vec2 uv ) +{ + return vec2( mirrorValue( uv.x ), mirrorValue( uv.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 +{ + vec4 ellipse; // x,y, sx,sy + + float distortionAmount; + float blendAmount; + float minDistance; + float redScale; + + float greenScale; + float blueScale; + float steps; + float smear; + + float rings; + float ratio; + float ringsIntensity; + float ringsDistribution; + + float ringsType; + float p0; + float p1; + float p2; + +} parameters; + + +vec4 sampleChromatic( vec2 uv, vec2 dir, ivec2 size, int steps, vec3 shifts, float smear ) +{ + vec4 combinedColor = vec4( 0.0 ); + + float weights = 0.0; + + for ( int i = -steps; i <= steps; i++ ) + { + float t = float( i ) / float( steps ); + float w = 1.0 - abs( t ); + vec2 stepDir = dir * pow( smear, t ); + + vec2 rUV = uv + stepDir * shifts.r; + rUV = mirrorUV( rUV ); + + vec2 gUV = uv + stepDir * shifts.g; + gUV = mirrorUV( gUV ); + + vec2 bUV = uv + stepDir * shifts.b; + bUV = mirrorUV( bUV ); + + vec4 colorR = imageLoad( inputImage, ivec2( rUV * size ) ); + vec4 colorG = imageLoad( inputImage, ivec2( gUV * size ) ); + vec4 colorB = imageLoad( inputImage, ivec2( bUV * size ) ); + + combinedColor.r += colorR.r * w; + combinedColor.g += colorG.g * w; + combinedColor.b += colorB.b * w; + combinedColor.a += colorG.a * w; + + weights += w; + } + + combinedColor /= weights; + + return combinedColor; +} + +float triangle( float value ) +{ + float inverted = 1.0 - value; + + return min( value, inverted ) * 2.0; +} + +float ringFunction( float value, float roundness ) +{ + float t = triangle( mod( value, 1.0 ) ); + float c = 0.5 - 0.5 * cos( 6.28318531 * value ); + + return clamp( mix( t, c, roundness ), 0.0, 1.0 ); +} + +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 ); + + // vec2 ratio = vec2( size ) / min( size.x, size.y ); + vec2 ellipseCenter = vec2( parameters.ellipse.x, parameters.ellipse.y ); + vec2 ellipseSize = vec2( parameters.ellipse.z, parameters.ellipse.w ); + + if ( parameters.ratio > 0.5 ) + { + float aspect = float( size.x ) / float( size.y ); + + ellipseSize.y *= aspect; + } + + vec2 dir = ellipseCenter - uv; + + vec2 scaledDir = dir; + scaledDir.x /= ellipseSize.x; + scaledDir.y /= ellipseSize.y; + + float dist = length( scaledDir ); + float amount = 1.0 - clamp( dist - parameters.minDistance, 0.0, 1.0 ); + + float simpleAmount = amount; + amount = ringFunction( pow( amount, parameters.ringsDistribution ) * parameters.rings, parameters.ringsType ); + + if ( parameters.ringsIntensity < 0.0 ) + { + amount = mix( amount * ( 1.0 - simpleAmount ), amount, 1.0 + parameters.ringsIntensity ); + } + else + { + amount = mix( amount, amount * simpleAmount, parameters.ringsIntensity ); + } + + + vec2 uvOffset = normalize( dir ) * amount; + vec3 distortion = vec3( parameters.redScale, parameters.greenScale, parameters.blueScale ) * parameters.distortionAmount; + + int stepsI = min( 10, int( parameters.steps ) ); + + vec4 originalColor = imageLoad( inputImage, texel_coord ); + vec4 color = originalColor; + + if ( stepsI <= 1 ) + { + vec2 rUV = uv + uvOffset * distortion.r; + rUV = mirrorUV( rUV ); + + vec2 gUV = uv + uvOffset * distortion.g; + gUV = mirrorUV( gUV ); + + vec2 bUV = uv + uvOffset * distortion.b; + bUV = mirrorUV( bUV ); + + vec4 colorR = imageLoad( inputImage, ivec2( rUV * size ) ); + vec4 colorG = imageLoad( inputImage, ivec2( gUV * size ) ); + vec4 colorB = imageLoad( inputImage, ivec2( bUV * size ) ); + + color = vec4( colorR.r, colorG.g, colorB.b, colorG.a ); + + } + else + { + color = sampleChromatic( uv, uvOffset, size, stepsI, distortion, parameters.smear ); + } + + color = mix( originalColor, color, parameters.blendAmount ); + imageStore( outputImage, texel_coord, color ); +} \ No newline at end of file diff --git a/Runtime/Rendering/RenderGraph/Nodes/Processors/Distortion/EllipseDistortion/EllipseDistortion.glsl.import b/Runtime/Rendering/RenderGraph/Nodes/Processors/Distortion/EllipseDistortion/EllipseDistortion.glsl.import new file mode 100644 index 0000000..374b35f --- /dev/null +++ b/Runtime/Rendering/RenderGraph/Nodes/Processors/Distortion/EllipseDistortion/EllipseDistortion.glsl.import @@ -0,0 +1,14 @@ +[remap] + +importer="glsl" +type="RDShaderFile" +uid="uid://b1212vgxla2l5" +path="res://.godot/imported/EllipseDistortion.glsl-87ebf88b7bcd782ac275b8ebbbf1f32d.res" + +[deps] + +source_file="res://addons/rokojori_action_library/Runtime/Rendering/RenderGraph/Nodes/Processors/Distortion/EllipseDistortion/EllipseDistortion.glsl" +dest_files=["res://.godot/imported/EllipseDistortion.glsl-87ebf88b7bcd782ac275b8ebbbf1f32d.res"] + +[params] + diff --git a/Runtime/Rendering/RenderGraph/Nodes/Processors/Distortion/EllipseDistortion/RG_EllipseDistortion.cs b/Runtime/Rendering/RenderGraph/Nodes/Processors/Distortion/EllipseDistortion/RG_EllipseDistortion.cs new file mode 100644 index 0000000..510d332 --- /dev/null +++ b/Runtime/Rendering/RenderGraph/Nodes/Processors/Distortion/EllipseDistortion/RG_EllipseDistortion.cs @@ -0,0 +1,17 @@ + +using Godot; +using System.Collections.Generic; + +namespace Rokojori +{ + public class RG_EllipseDistortion:CEG_ImageProcessor + { + public static readonly string shaderPath = + RDGraph.Path( "Nodes/Processors/Distortion/EllipseDistortion/EllipseDistortion.glsl" ); + + public RG_EllipseDistortion( RDGraph graph ):base( graph, shaderPath ) + {} + + + } +} \ No newline at end of file diff --git a/Runtime/Rendering/RenderGraph/Nodes/Processors/Distortion/EllipseDistortion/RG_EllipseDistortion.cs.uid b/Runtime/Rendering/RenderGraph/Nodes/Processors/Distortion/EllipseDistortion/RG_EllipseDistortion.cs.uid new file mode 100644 index 0000000..79064ab --- /dev/null +++ b/Runtime/Rendering/RenderGraph/Nodes/Processors/Distortion/EllipseDistortion/RG_EllipseDistortion.cs.uid @@ -0,0 +1 @@ +uid://nt4qosqs3xmo diff --git a/Runtime/Rendering/RenderGraph/Nodes/Processors/Distortion/NoiseDistortion/NoiseDistortion.glsl b/Runtime/Rendering/RenderGraph/Nodes/Processors/Distortion/NoiseDistortion/NoiseDistortion.glsl new file mode 100644 index 0000000..9c1e879 --- /dev/null +++ b/Runtime/Rendering/RenderGraph/Nodes/Processors/Distortion/NoiseDistortion/NoiseDistortion.glsl @@ -0,0 +1,196 @@ +#[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 ) ); +} + +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 mirrorValue( float x ) +{ + float t = mod( x, 2.0 ); + return ( t <= 1.0 ) ? t : 2.0 - t; +} + +vec2 mirrorUV( vec2 uv ) +{ + return vec2( mirrorValue( uv.x ), mirrorValue( uv.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 +{ + vec4 noiseSeed; + float distortionAmount; + float noiseScale; + float redScale; + float greenScale; + float blueScale; + float steps; + float smear; + float p2; + +} parameters; + + +vec4 sampleChromatic( vec2 uv, vec2 dir, ivec2 size, int steps, vec3 shifts, float smear ) +{ + vec4 combinedColor = vec4( 0.0 ); + + float weights = 0.0; + + for ( int i = -steps; i <= steps; i++ ) + { + float t = float( i ) / float( steps ); + float w = 1.0 - abs( t ); + vec2 stepDir = dir * pow( smear, t ); + + vec2 rUV = uv + stepDir * shifts.r; + rUV = mirrorUV( rUV ); + + vec2 gUV = uv + stepDir * shifts.g; + gUV = mirrorUV( gUV ); + + vec2 bUV = uv + stepDir * shifts.b; + bUV = mirrorUV( bUV ); + + vec4 colorR = imageLoad( inputImage, ivec2( rUV * size ) ); + vec4 colorG = imageLoad( inputImage, ivec2( gUV * size ) ); + vec4 colorB = imageLoad( inputImage, ivec2( bUV * size ) ); + + combinedColor.r += colorR.r * w; + combinedColor.g += colorG.g * w; + combinedColor.b += colorB.b * w; + combinedColor.a += colorG.a * w; + + weights += w; + } + + combinedColor /= weights; + + return combinedColor; +} + + +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 ); + + vec2 ratio = vec2( size ) / min( size.x, size.y ); + + float noiseX = perlin( uv * parameters.noiseScale * ratio + vec2( parameters.noiseSeed.x, parameters.noiseSeed.y ) ); + float noiseY = perlin( uv * parameters.noiseScale * ratio + vec2( parameters.noiseSeed.z, parameters.noiseSeed.w ) ); + + vec2 uvNoise = vec2( noiseX, noiseY ) * 2.0 - vec2( 1.0 ); + + int stepsI = min( 5, int( parameters.steps ) ); + + vec3 distortion = vec3( parameters.redScale, parameters.greenScale, parameters.blueScale ) * parameters.distortionAmount; + + if ( stepsI <= 1 ) + { + vec2 rUV = uv + uvNoise * distortion.r; + rUV = mirrorUV( rUV ); + + vec2 gUV = uv + uvNoise * distortion.g; + gUV = mirrorUV( gUV ); + + vec2 bUV = uv + uvNoise * distortion.b; + bUV = mirrorUV( bUV ); + + vec4 colorR = imageLoad( inputImage, ivec2( rUV * size ) ); + vec4 colorG = imageLoad( inputImage, ivec2( gUV * size ) ); + vec4 colorB = imageLoad( inputImage, ivec2( bUV * size ) ); + + vec4 color = vec4( colorR.r, colorG.g, colorB.b, colorG.a ); + + imageStore( outputImage, texel_coord, color ); + } + else + { + vec4 chromatic = sampleChromatic( uv, uvNoise, size, stepsI, distortion, parameters.smear ); + imageStore( outputImage, texel_coord, chromatic ); + } +} \ No newline at end of file diff --git a/Runtime/Rendering/RenderGraph/Nodes/Processors/Distortion/NoiseDistortion/NoiseDistortion.glsl.import b/Runtime/Rendering/RenderGraph/Nodes/Processors/Distortion/NoiseDistortion/NoiseDistortion.glsl.import new file mode 100644 index 0000000..955166e --- /dev/null +++ b/Runtime/Rendering/RenderGraph/Nodes/Processors/Distortion/NoiseDistortion/NoiseDistortion.glsl.import @@ -0,0 +1,14 @@ +[remap] + +importer="glsl" +type="RDShaderFile" +uid="uid://bofphutm1n3lj" +path="res://.godot/imported/NoiseDistortion.glsl-d65b5f741f820cc23f4e7aa17b63beb1.res" + +[deps] + +source_file="res://addons/rokojori_action_library/Runtime/Rendering/RenderGraph/Nodes/Processors/Distortion/NoiseDistortion/NoiseDistortion.glsl" +dest_files=["res://.godot/imported/NoiseDistortion.glsl-d65b5f741f820cc23f4e7aa17b63beb1.res"] + +[params] + diff --git a/Runtime/Rendering/RenderGraph/Nodes/Processors/Distortion/NoiseDistortion/RG_NoiseDistortion.cs b/Runtime/Rendering/RenderGraph/Nodes/Processors/Distortion/NoiseDistortion/RG_NoiseDistortion.cs new file mode 100644 index 0000000..92c5259 --- /dev/null +++ b/Runtime/Rendering/RenderGraph/Nodes/Processors/Distortion/NoiseDistortion/RG_NoiseDistortion.cs @@ -0,0 +1,17 @@ + +using Godot; +using System.Collections.Generic; + +namespace Rokojori +{ + public class RG_NoiseDistortion:CEG_ImageProcessor + { + public static readonly string shaderPath = + RDGraph.Path( "Nodes/Processors/Distortion/NoiseDistortion/NoiseDistortion.glsl" ); + + public RG_NoiseDistortion( RDGraph graph ):base( graph, shaderPath ) + {} + + + } +} \ No newline at end of file diff --git a/Runtime/Rendering/RenderGraph/Nodes/Processors/Distortion/NoiseDistortion/RG_NoiseDistortion.cs.uid b/Runtime/Rendering/RenderGraph/Nodes/Processors/Distortion/NoiseDistortion/RG_NoiseDistortion.cs.uid new file mode 100644 index 0000000..fdb8c54 --- /dev/null +++ b/Runtime/Rendering/RenderGraph/Nodes/Processors/Distortion/NoiseDistortion/RG_NoiseDistortion.cs.uid @@ -0,0 +1 @@ +uid://edkh3455qjly diff --git a/Runtime/Rendering/RenderGraph/Nodes/Processors/Distortion/ScanLines/RG_ScanLines.cs b/Runtime/Rendering/RenderGraph/Nodes/Processors/Distortion/ScanLines/RG_ScanLines.cs new file mode 100644 index 0000000..267ae55 --- /dev/null +++ b/Runtime/Rendering/RenderGraph/Nodes/Processors/Distortion/ScanLines/RG_ScanLines.cs @@ -0,0 +1,17 @@ + +using Godot; +using System.Collections.Generic; + +namespace Rokojori +{ + public class RG_ScanLines:CEG_ImageProcessor + { + public static readonly string shaderPath = + RDGraph.Path( "Nodes/Processors/Distortion/ScanLines/ScanLines.glsl" ); + + public RG_ScanLines( RDGraph graph ):base( graph, shaderPath ) + {} + + + } +} \ No newline at end of file diff --git a/Runtime/Rendering/RenderGraph/Nodes/Processors/Distortion/ScanLines/RG_ScanLines.cs.uid b/Runtime/Rendering/RenderGraph/Nodes/Processors/Distortion/ScanLines/RG_ScanLines.cs.uid new file mode 100644 index 0000000..da985f2 --- /dev/null +++ b/Runtime/Rendering/RenderGraph/Nodes/Processors/Distortion/ScanLines/RG_ScanLines.cs.uid @@ -0,0 +1 @@ +uid://bpncud2w4lj3o diff --git a/Runtime/Rendering/RenderGraph/Nodes/Processors/Distortion/ScanLines/ScanLines.glsl b/Runtime/Rendering/RenderGraph/Nodes/Processors/Distortion/ScanLines/ScanLines.glsl new file mode 100644 index 0000000..138a032 --- /dev/null +++ b/Runtime/Rendering/RenderGraph/Nodes/Processors/Distortion/ScanLines/ScanLines.glsl @@ -0,0 +1,225 @@ +#[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 ) ); +} + +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 mirrorValue( float x ) +{ + float t = mod( x, 2.0 ); + return ( t <= 1.0 ) ? t : 2.0 - t; +} + +vec2 mirrorUV( vec2 uv ) +{ + return vec2( mirrorValue( uv.x ), mirrorValue( uv.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 +{ + vec4 scanlineTintTop; + vec4 scanlineTintBottom; + vec4 pad0; + vec4 pad1; + + float amount; + float scanlineHeight; + float rgbTintAmount; + float rgbOffsetLineHeight; + + float rgbSizeMultiplier; + float useRGBOffset; + float jitterOffset; + float p2; + + + + +} parameters; + + +vec4 sampleChromatic( vec2 uv, vec2 dir, ivec2 size, int steps, vec3 shifts, float smear ) +{ + vec4 combinedColor = vec4( 0.0 ); + + float weights = 0.0; + + for ( int i = -steps; i <= steps; i++ ) + { + float t = float( i ) / float( steps ); + float w = 1.0 - abs( t ); + vec2 stepDir = dir * pow( smear, t ); + + vec2 rUV = uv + stepDir * shifts.r; + rUV = mirrorUV( rUV ); + + vec2 gUV = uv + stepDir * shifts.g; + gUV = mirrorUV( gUV ); + + vec2 bUV = uv + stepDir * shifts.b; + bUV = mirrorUV( bUV ); + + vec4 colorR = imageLoad( inputImage, ivec2( rUV * size ) ); + vec4 colorG = imageLoad( inputImage, ivec2( gUV * size ) ); + vec4 colorB = imageLoad( inputImage, ivec2( bUV * size ) ); + + combinedColor.r += colorR.r * w; + combinedColor.g += colorG.g * w; + combinedColor.b += colorB.b * w; + combinedColor.a += colorG.a * w; + + weights += w; + } + + combinedColor /= weights; + + return combinedColor; +} + +float mirrorValue( float x, float base ) +{ + float t = mod( x, 2.0 * base ); + return ( t <= 1.0 * base ) ? t : 2.0 * base - t; +} + +vec2 mirrorUV( vec2 uv, vec2 size ) +{ + return vec2( mirrorValue( uv.x, size.x ), mirrorValue( uv.y, size.y ) ); +} + +void main( ) +{ + ivec2 size = imageSize( inputImage ); + ivec2 texel_coord = ivec2( gl_GlobalInvocationID.xy ); + + if ( any( greaterThanEqual( texel_coord, size ) ) ) + { + return; + } + + vec2 jitterTexel = gl_GlobalInvocationID.xy + vec2( 0.0, parameters.jitterOffset ); + jitterTexel = mirrorUV( jitterTexel, size ); + + vec2 uv = ( vec2( texel_coord ) + 0.5 + vec2( 0.0, parameters.jitterOffset ) ) / vec2( size ); + + + int scanLineHeight = int( parameters.scanlineHeight ); + // scanLineHeight = 20; + int scanLineIndex = texel_coord.y / scanLineHeight; + int lineType = scanLineIndex % 2; + float scanMix = float( lineType ); + + + int rgbSizeMultiplier = int( parameters.rgbSizeMultiplier ); + int rgbLineHeight = int( parameters.rgbOffsetLineHeight ); + int rgbLineIndex = texel_coord.y / rgbLineHeight; + int rgbLineType = rgbLineIndex % 2; + int useRGBLineOffsets = ( parameters.useRGBOffset > 0.5 ) ? 1 : 0; + int lineTypeOffset = ( ( rgbSizeMultiplier * 3 ) / 2 ) * rgbLineType * useRGBLineOffsets; + + int rgbIndex = ( ( texel_coord.x + lineTypeOffset ) % ( rgbSizeMultiplier * 3 ) ) / rgbSizeMultiplier; + + + + vec4 tintColor = mix( parameters.scanlineTintTop, parameters.scanlineTintBottom, scanMix ); + vec4 rTint = vec4( 1.0, 0.0, 0.0, 1.0 ); + vec4 gTint = vec4( 0.0, 1.0, 0.0, 1.0 ); + vec4 bTint = vec4( 0.0, 0.0, 1.0, 1.0 ); + vec4 noTint = vec4( 1.0, 1.0, 1.0, 1.0 ); + + vec4 rgbTint = rgbIndex == 0 ? rTint : rgbIndex == 1 ? gTint : bTint; + rgbTint = mix( noTint, rgbTint, parameters.rgbTintAmount ); + + tintColor *= rgbTint; + + + // vec2 uvOffset = normalize( dir ) * amount; + // vec3 distortion = vec3( parameters.redScale, parameters.greenScale, parameters.blueScale ) * parameters.distortionAmount; + + // int stepsI = min( 10, int( parameters.steps ) ); + + vec4 originalColor = imageLoad( inputImage, ivec2( texel_coord ) ); + vec4 color = imageLoad( inputImage, ivec2( jitterTexel ) ) * tintColor; + + // color = sampleChromatic( uv, uvOffset, size, stepsI, distortion, parameters.smear ); + + color = mix( originalColor, color, parameters.amount ); + imageStore( outputImage, texel_coord, color ); +} \ No newline at end of file diff --git a/Runtime/Rendering/RenderGraph/Nodes/Processors/Distortion/ScanLines/ScanLines.glsl.import b/Runtime/Rendering/RenderGraph/Nodes/Processors/Distortion/ScanLines/ScanLines.glsl.import new file mode 100644 index 0000000..120542b --- /dev/null +++ b/Runtime/Rendering/RenderGraph/Nodes/Processors/Distortion/ScanLines/ScanLines.glsl.import @@ -0,0 +1,14 @@ +[remap] + +importer="glsl" +type="RDShaderFile" +uid="uid://d4jddifyjhrtj" +path="res://.godot/imported/ScanLines.glsl-d4442328b795066fd693e1241ef6b0f8.res" + +[deps] + +source_file="res://addons/rokojori_action_library/Runtime/Rendering/RenderGraph/Nodes/Processors/Distortion/ScanLines/ScanLines.glsl" +dest_files=["res://.godot/imported/ScanLines.glsl-d4442328b795066fd693e1241ef6b0f8.res"] + +[params] + diff --git a/Runtime/Rendering/RenderGraph/Nodes/Processors/Kernels/Kernel3/Kernel3.glsl b/Runtime/Rendering/RenderGraph/Nodes/Processors/Kernels/Kernel3/Kernel3.glsl new file mode 100644 index 0000000..09140fd --- /dev/null +++ b/Runtime/Rendering/RenderGraph/Nodes/Processors/Kernels/Kernel3/Kernel3.glsl @@ -0,0 +1,83 @@ +#[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 inputImage; + +layout( rgba16f, set = 1, binding = 0 ) +uniform image2D outputImage; + + +layout( push_constant, std430 ) +uniform Parameters +{ + float amount; + + float k00; + float k01; + float k02; + + float k10; + float k11; + float k12; + + float k20; + float k21; + float k22; + + float kernelOffset; + + float clampValues; + +} parameters; + +vec4 getPixel( ivec2 pixelUV, int x, int y, int kernelOffset, ivec2 size ) +{ + ivec2 xy = ivec2( x, y ) * kernelOffset; + ivec2 kernelUV = pixelUV + xy; + + kernelUV.x = clamp( kernelUV.x, 0, size.x - 1 ); + kernelUV.y = clamp( kernelUV.y, 0, size.y - 1 ); + + return imageLoad( inputImage, kernelUV ); +} + +void main( ) +{ + ivec2 size = imageSize( inputImage ); + ivec2 pixelUV = ivec2( gl_GlobalInvocationID.xy ); + + if ( any( greaterThanEqual( pixelUV, size ) ) ) + { + return; + } + + vec4 color = vec4( 0.0 ); + + int kernelOffsetInt = int( parameters.kernelOffset ); + + color += parameters.k00 * getPixel( pixelUV, -1, -1, kernelOffsetInt, size ); + color += parameters.k01 * getPixel( pixelUV, -1, 0, kernelOffsetInt, size ); + color += parameters.k02 * getPixel( pixelUV, -1, 1, kernelOffsetInt, size ); + + color += parameters.k10 * getPixel( pixelUV, 0, -1, kernelOffsetInt, size ); + color += parameters.k11 * getPixel( pixelUV, 0, 0, kernelOffsetInt, size ); + color += parameters.k12 * getPixel( pixelUV, 0, 1, kernelOffsetInt, size ); + + color += parameters.k20 * getPixel( pixelUV, 1, -1, kernelOffsetInt, size ); + color += parameters.k21 * getPixel( pixelUV, 1, 0, kernelOffsetInt, size ); + color += parameters.k22 * getPixel( pixelUV, 1, 1, kernelOffsetInt, size ); + + if ( parameters.clampValues > 0.5 ) + { + color = clamp( color, 0.0, 1.0 ); + } + + vec4 originalColor = imageLoad( inputImage, pixelUV ); + + vec4 mixedColor = mix( originalColor, color, parameters.amount ); + + imageStore( outputImage, pixelUV, mixedColor ); +} \ No newline at end of file diff --git a/Runtime/Rendering/RenderGraph/Nodes/Processors/Kernels/Kernel3/Kernel3.glsl.import b/Runtime/Rendering/RenderGraph/Nodes/Processors/Kernels/Kernel3/Kernel3.glsl.import new file mode 100644 index 0000000..31ad09b --- /dev/null +++ b/Runtime/Rendering/RenderGraph/Nodes/Processors/Kernels/Kernel3/Kernel3.glsl.import @@ -0,0 +1,14 @@ +[remap] + +importer="glsl" +type="RDShaderFile" +uid="uid://of7kmaig5kx8" +path="res://.godot/imported/Kernel3.glsl-af00fc9c65ae98562facfc2cc048d423.res" + +[deps] + +source_file="res://addons/rokojori_action_library/Runtime/Rendering/RenderGraph/Nodes/Processors/Kernels/Kernel3/Kernel3.glsl" +dest_files=["res://.godot/imported/Kernel3.glsl-af00fc9c65ae98562facfc2cc048d423.res"] + +[params] + diff --git a/Runtime/Rendering/RenderGraph/Nodes/Processors/Kernels/Kernel3/RG_Kernel3.cs b/Runtime/Rendering/RenderGraph/Nodes/Processors/Kernels/Kernel3/RG_Kernel3.cs new file mode 100644 index 0000000..eae39e6 --- /dev/null +++ b/Runtime/Rendering/RenderGraph/Nodes/Processors/Kernels/Kernel3/RG_Kernel3.cs @@ -0,0 +1,17 @@ + +using Godot; +using System.Collections.Generic; + +namespace Rokojori +{ + public class RG_Kernel3:CEG_ImageProcessor + { + public static readonly string shaderPath = + RDGraph.Path( "Nodes/Processors/Kernels/Kernel3/Kernel3.glsl" ); + + public RG_Kernel3( RDGraph graph ):base( graph, shaderPath ) + {} + + + } +} \ No newline at end of file diff --git a/Runtime/Rendering/RenderGraph/Nodes/Processors/Kernels/Kernel3/RG_Kernel3.cs.uid b/Runtime/Rendering/RenderGraph/Nodes/Processors/Kernels/Kernel3/RG_Kernel3.cs.uid new file mode 100644 index 0000000..dccb4ed --- /dev/null +++ b/Runtime/Rendering/RenderGraph/Nodes/Processors/Kernels/Kernel3/RG_Kernel3.cs.uid @@ -0,0 +1 @@ +uid://b38a30q5as67r diff --git a/Runtime/Shading/Library/SDF.gdshaderinc b/Runtime/Shading/Library/SDF.gdshaderinc index 4d68ad0..86536de 100644 --- a/Runtime/Shading/Library/SDF.gdshaderinc +++ b/Runtime/Shading/Library/SDF.gdshaderinc @@ -122,6 +122,48 @@ float sdSegment( in vec2 p, in vec2 a, in vec2 b ) return length( pa - ba*h ); } +float sdEllipse( in vec2 p, in vec2 ab ) +{ + p = abs(p); + + if( p.x > p.y ) + { + p=p.yx;ab=ab.yx; + } + + float l = ab.y*ab.y - ab.x*ab.x; + float m = ab.x*p.x/l; float m2 = m*m; + float n = ab.y*p.y/l; float n2 = n*n; + float c = (m2+n2-1.0)/3.0; float c3 = c*c*c; + float q = c3 + m2*n2*2.0; + float d = c3 + m2*n2; + float g = m + m*n2; + float co; + + if( d < 0.0 ) + { + float h = acos(q/c3)/3.0; + float s = cos(h); + float t = sin(h)*sqrt(3.0); + float rx = sqrt( -c*(s + t + 2.0) + m2 ); + float ry = sqrt( -c*(s - t + 2.0) + m2 ); + co = (ry+sign(l)*rx+abs(g)/(rx*ry)- m)/2.0; + } + else + { + float h = 2.0*m*n*sqrt( d ); + float s = sign(q+h)*pow(abs(q+h), 1.0/3.0); + float u = sign(q-h)*pow(abs(q-h), 1.0/3.0); + float rx = -s - u - c*4.0 + 2.0*m2; + float ry = (s - u)*sqrt(3.0); + float rm = sqrt( rx*rx + ry*ry ); + co = (ry/sqrt(rm-rx)+2.0*g/rm-m)/2.0; + } + + vec2 r = ab * vec2(co, sqrt(1.0-co*co)); + return length(r-p) * sign(p.y-r.y); +} + /* TAKEN FROM