Shaders Update
This commit is contained in:
parent
fad61c7e9b
commit
02aee8bbf4
|
|
@ -66,7 +66,23 @@ namespace Rokojori
|
|||
return;
|
||||
}
|
||||
|
||||
ReflectionHelper.SetValue( target, prop, value );
|
||||
try
|
||||
{
|
||||
ReflectionHelper.SetValue( target, prop, value );
|
||||
}
|
||||
catch ( Exception e )
|
||||
{
|
||||
try
|
||||
{
|
||||
ReflectionHelper.SetValue( target, prop, (int)value );
|
||||
}
|
||||
catch ( Exception ex )
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected override void _OnTrigger()
|
||||
|
|
|
|||
|
|
@ -6,9 +6,14 @@ using Godot;
|
|||
|
||||
namespace Rokojori
|
||||
{
|
||||
public interface IFloatDriver
|
||||
{
|
||||
public float GetDriverFloatValue();
|
||||
}
|
||||
|
||||
[Tool]
|
||||
[GlobalClass]
|
||||
public partial class FloatDriver:Node
|
||||
public partial class FloatDriver:Node, IFloatDriver
|
||||
{
|
||||
float _driverValue = 0f;
|
||||
|
||||
|
|
@ -23,17 +28,15 @@ namespace Rokojori
|
|||
}
|
||||
}
|
||||
|
||||
public float GetDriverFloatValue()
|
||||
{ return _driverValue; }
|
||||
|
||||
[ExportToolButton( "Update Value")]
|
||||
public Callable updateValueButton => Callable.From( ()=> UpdateValue() ) ;
|
||||
|
||||
void UpdateValue()
|
||||
{
|
||||
if ( targets == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for ( int i = 0; i < targets.Length; i++ )
|
||||
{
|
||||
for ( int i = 0; targets != null && i < targets.Length; i++ )
|
||||
{
|
||||
if ( targets[ i ] == null || targets[ i ].GetGodotObject( this ) == null )
|
||||
{
|
||||
|
|
@ -42,11 +45,40 @@ namespace Rokojori
|
|||
|
||||
targets[ i ].Update( this );
|
||||
}
|
||||
|
||||
onChange?.Trigger();
|
||||
|
||||
if ( value == 0 )
|
||||
{
|
||||
onZero?.Trigger();
|
||||
}
|
||||
else if ( value == 1 )
|
||||
{
|
||||
onOne?.Trigger();
|
||||
}
|
||||
else
|
||||
{
|
||||
onIntermediate?.Trigger();
|
||||
}
|
||||
}
|
||||
|
||||
[Export]
|
||||
public FloatDriverTarget[] targets = [];
|
||||
|
||||
[Export]
|
||||
public Action onChange;
|
||||
|
||||
[Export]
|
||||
public Action onZero;
|
||||
|
||||
[Export]
|
||||
public Action onOne;
|
||||
|
||||
[Export]
|
||||
public Action onIntermediate;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 FloatDriverCompositorEffectTarget:FloatDriverTarget
|
||||
{
|
||||
[Export]
|
||||
public CompositorEffectReference compositorEffectReference;
|
||||
|
||||
[Export]
|
||||
public string targetMemberPath;
|
||||
|
||||
public override GodotObject GetGodotObject( IFloatDriver driver )
|
||||
{
|
||||
return compositorEffectReference.GetCompositorEffect( driver as Node );
|
||||
}
|
||||
|
||||
public override string GetTargetMemberPath( IFloatDriver driver )
|
||||
{
|
||||
return targetMemberPath;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://bc72e1jvuv48g
|
||||
|
|
@ -16,12 +16,12 @@ namespace Rokojori
|
|||
[Export]
|
||||
public string targetMemberPath;
|
||||
|
||||
public override GodotObject GetGodotObject( FloatDriver driver )
|
||||
public override GodotObject GetGodotObject( IFloatDriver driver )
|
||||
{
|
||||
return driver.GetNode( nodePath );
|
||||
return ( driver as Node ).GetNode( nodePath );
|
||||
}
|
||||
|
||||
public override string GetTargetMemberPath( FloatDriver driver )
|
||||
public override string GetTargetMemberPath( IFloatDriver driver )
|
||||
{
|
||||
return targetMemberPath;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,12 +16,12 @@ namespace Rokojori
|
|||
[Export]
|
||||
public string targetMemberPath;
|
||||
|
||||
public override GodotObject GetGodotObject( FloatDriver driver )
|
||||
public override GodotObject GetGodotObject( IFloatDriver driver )
|
||||
{
|
||||
return resource;
|
||||
}
|
||||
|
||||
public override string GetTargetMemberPath( FloatDriver driver )
|
||||
public override string GetTargetMemberPath( IFloatDriver driver )
|
||||
{
|
||||
return targetMemberPath;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,13 +14,13 @@ namespace Rokojori
|
|||
[Export]
|
||||
public Curve mappingCurve;
|
||||
|
||||
public abstract string GetTargetMemberPath( FloatDriver driver );
|
||||
public abstract string GetTargetMemberPath( IFloatDriver driver );
|
||||
|
||||
public abstract GodotObject GetGodotObject( FloatDriver driver );
|
||||
public abstract GodotObject GetGodotObject( IFloatDriver driver );
|
||||
|
||||
public void Update( FloatDriver driver )
|
||||
public void Update( IFloatDriver driver )
|
||||
{
|
||||
var mappedValue = mappingCurve.Sample( driver.value );
|
||||
var mappedValue = mappingCurve.Sample( driver.GetDriverFloatValue() );
|
||||
var targetMemberPath = GetTargetMemberPath( driver );
|
||||
TweenFloat.SetTargetValue( GetGodotObject( driver ), targetMemberPath, mappedValue );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,6 +37,9 @@ namespace Rokojori
|
|||
[Export]
|
||||
public bool postProcess = true;
|
||||
|
||||
[Export]
|
||||
public CompositorEffectLayout compositorLayout = new CompositorEffectLayout();
|
||||
|
||||
[Export]
|
||||
public PostProcessVolume[] postProcessVolumes = [];
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,100 @@
|
|||
using Godot;
|
||||
using System.Text;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
|
||||
namespace Rokojori
|
||||
{
|
||||
public class UndoGDMarker
|
||||
{
|
||||
public string name = "";
|
||||
}
|
||||
|
||||
public class UndoGD
|
||||
{
|
||||
static UndoGDMarker undoActionMarker = null;
|
||||
|
||||
#if TOOLS
|
||||
|
||||
static EditorUndoRedoManager UndoManager()
|
||||
{
|
||||
return EditorInterface.Singleton.GetEditorUndoRedo();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
public static UndoGDMarker Start( string actionName )
|
||||
{
|
||||
#if TOOLS
|
||||
|
||||
if ( undoActionMarker != null )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
undoActionMarker = new UndoGDMarker();
|
||||
undoActionMarker.name = actionName;
|
||||
|
||||
// UndoManager().CreateAction( actionName );
|
||||
|
||||
return undoActionMarker;
|
||||
|
||||
#else
|
||||
|
||||
return null;
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
public static void End( UndoGDMarker marker )
|
||||
{
|
||||
#if TOOLS
|
||||
|
||||
if ( undoActionMarker != marker )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// UndoManager().CommitAction();
|
||||
undoActionMarker = null;
|
||||
|
||||
#else
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
public static void Set<T>( GodotObject obj, string member, T value )
|
||||
{
|
||||
#if TOOLS
|
||||
|
||||
try
|
||||
{
|
||||
if ( undoActionMarker == null )
|
||||
{
|
||||
RJLog.ErrorGD( obj, "No undo marker! ", member, ">>", value );
|
||||
return;
|
||||
}
|
||||
|
||||
var currentValue = ReflectionHelper.GetValue<T>( obj, member );
|
||||
// UndoManager().AddUndoProperty( obj, member, (GodotObject)(object)currentValue );
|
||||
// UndoManager().AddDoProperty( obj, member, (GodotObject)(object)value );
|
||||
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
ReflectionHelper.SetValue( obj, member, value );
|
||||
|
||||
#else
|
||||
|
||||
ReflectionHelper.SetValue( obj, member, value );
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://b3t2srtl1tli0
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
using Godot;
|
||||
using System.Text;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Rokojori
|
||||
{
|
||||
public static class ArrayExtensions
|
||||
{
|
||||
public static void ForEach<[MustBeVariant] T>( this Godot.Collections.Array<T> array, System.Action<T> action )
|
||||
{
|
||||
for (int i = 0; i < array.Count; i++)
|
||||
{
|
||||
action( array[i] );
|
||||
}
|
||||
}
|
||||
|
||||
public static T Find<[MustBeVariant] T>( this Godot.Collections.Array<T> array, System.Func<T,bool> evaluater )
|
||||
{
|
||||
for ( int i = 0; i < array.Count; i++ )
|
||||
{
|
||||
if ( evaluater( array[ i ] ) )
|
||||
{
|
||||
return array[ i ];
|
||||
}
|
||||
}
|
||||
|
||||
return default(T);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://clusd1thvxjac
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
using Godot;
|
||||
using System.Text;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Rokojori
|
||||
{
|
||||
public static class Vector2Extensions
|
||||
{
|
||||
public static Vector4 ToVector4( this Vector2 xy, Vector2 zw )
|
||||
{
|
||||
return new Vector4( xy.X, xy.Y, zw.X, zw.Y );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://c0d8bml6nct6w
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
using Godot;
|
||||
using System.Text;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Rokojori
|
||||
{
|
||||
public static class Vector4Extensions
|
||||
{
|
||||
public static Vector4 Create( Vector2 xy, Vector2 zw )
|
||||
{
|
||||
return new Vector4( xy.X, xy.Y, zw.X, zw.Y );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://bh02vu5qnklci
|
||||
|
|
@ -262,6 +262,22 @@ namespace Rokojori
|
|||
LogErrorMessage( "" + HierarchyName.Of( resource ) + "\n" + GetLogString( objects ), 4 );
|
||||
}
|
||||
|
||||
public static void ErrorGD( GodotObject obj, params object[] objects)
|
||||
{
|
||||
if ( obj is Node n )
|
||||
{
|
||||
Error( n, objects );
|
||||
}
|
||||
else if ( obj is Resource r )
|
||||
{
|
||||
Error( r, objects );
|
||||
}
|
||||
else
|
||||
{
|
||||
LogErrorMessage( "" + obj + "\n" + GetLogString( objects ), 4 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static string GetLogString( object[] objects )
|
||||
|
|
|
|||
|
|
@ -0,0 +1,24 @@
|
|||
|
||||
using System.Diagnostics;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using Godot;
|
||||
|
||||
|
||||
namespace Rokojori
|
||||
{
|
||||
public enum ColorSpace
|
||||
{
|
||||
Unknown,
|
||||
sRGB,
|
||||
Linear
|
||||
}
|
||||
|
||||
public enum ColorSpaceConversion
|
||||
{
|
||||
No_Conversion,
|
||||
Linear_to_sRGB,
|
||||
sRGB_to_Linear
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://cyvo4y3oorxf6
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
|
||||
using Godot;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Rokojori
|
||||
{
|
||||
[Tool]
|
||||
[GlobalClass]
|
||||
public abstract partial class CompositorEffectDriverTarget:Resource
|
||||
{
|
||||
public abstract void OnDriverChange( RokojoriCompositorEffect re, float value );
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://dt61u7tn1hrws
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
|
||||
using Godot;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Rokojori
|
||||
{
|
||||
[Tool]
|
||||
[GlobalClass]
|
||||
public partial class CompositorEffectLayer:Resource
|
||||
{
|
||||
[Export]
|
||||
public string layerName;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://b2ik21q1iwjvo
|
||||
|
|
@ -0,0 +1,112 @@
|
|||
|
||||
using Godot;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Rokojori
|
||||
{
|
||||
[Tool]
|
||||
[GlobalClass]
|
||||
public partial class CompositorEffectLayout:Resource
|
||||
{
|
||||
[Export]
|
||||
public CompositorEffectLayer[] layers;
|
||||
|
||||
[Export]
|
||||
public Compositor compositor;
|
||||
|
||||
public void Ensure( RokojoriCompositorEffect[] effects, bool inside )
|
||||
{
|
||||
|
||||
// this.LogInfo( "Ensure effects:", inside );
|
||||
|
||||
var list = new List<System.Tuple<RokojoriCompositorEffect,RokojoriCompositorEffect>>();
|
||||
var replacements = new List<System.Tuple<RokojoriCompositorEffect,RokojoriCompositorEffect>>();
|
||||
|
||||
effects.ForEach(
|
||||
( e )=>
|
||||
{
|
||||
var el = compositor.CompositorEffects.Find( ce => ce is RokojoriCompositorEffect re && re.compositorEffectID == e.compositorEffectID );
|
||||
|
||||
var isInside = el != null;
|
||||
|
||||
if ( isInside == inside )
|
||||
{
|
||||
if ( el != e )
|
||||
{
|
||||
// var fx = compositor.CompositorEffects;
|
||||
// var index = fx.IndexOf( el );
|
||||
|
||||
// fx[ index ] = e;
|
||||
|
||||
// compositor.CompositorEffects = fx;
|
||||
|
||||
replacements.Add( new System.Tuple<RokojoriCompositorEffect, RokojoriCompositorEffect>( e, el as RokojoriCompositorEffect ) ) ;
|
||||
}
|
||||
|
||||
// this.LogInfo( "Already " + ( inside ? "inside" : "removed" ), e );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( inside )
|
||||
{
|
||||
// this.LogInfo( "Adding:", e );
|
||||
// compositor.CompositorEffects.Add( e );
|
||||
}
|
||||
else
|
||||
{
|
||||
// this.LogInfo( "Removing:", el );
|
||||
|
||||
// compositor.CompositorEffects.Remove( e );
|
||||
}
|
||||
|
||||
list.Add( new System.Tuple<RokojoriCompositorEffect, RokojoriCompositorEffect>( e, el as RokojoriCompositorEffect ) );
|
||||
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
replacements.ForEach(
|
||||
( t )=>
|
||||
{
|
||||
var ef = t.Item1;
|
||||
var indexE = effects.IndexOf( ef );
|
||||
var ce = t.Item2;
|
||||
var indexC = compositor.CompositorEffects.IndexOf( ce );
|
||||
|
||||
effects[ indexE ] = (RokojoriCompositorEffect) ef.Duplicate();
|
||||
|
||||
var fx = compositor.CompositorEffects;
|
||||
fx[ indexC ] = effects[ indexE ];
|
||||
compositor.CompositorEffects = fx;
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
if ( list.Count > 0 )
|
||||
{
|
||||
var newEffects = compositor.CompositorEffects;
|
||||
|
||||
if ( inside )
|
||||
{
|
||||
list.ForEach(
|
||||
( l )=>
|
||||
{
|
||||
var index = effects.IndexOf( l.Item1 );
|
||||
effects[ index ] = (RokojoriCompositorEffect) effects[ index ].Duplicate();
|
||||
newEffects.Add( effects[ index ] );
|
||||
}
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
list.ForEach( e => newEffects.Remove( e.Item2 ) );
|
||||
}
|
||||
|
||||
compositor.CompositorEffects = newEffects;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://dn7xg8cqdnolq
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
|
||||
using Godot;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Rokojori
|
||||
{
|
||||
[Tool]
|
||||
[GlobalClass]
|
||||
public partial class CompositorEffectMemberCurveTarget:CompositorEffectDriverTarget
|
||||
{
|
||||
[Export]
|
||||
public string member;
|
||||
|
||||
[Export]
|
||||
public Curve curve;
|
||||
|
||||
public enum TargetType
|
||||
{
|
||||
Float,
|
||||
Int,
|
||||
Bool
|
||||
}
|
||||
|
||||
[Export]
|
||||
public TargetType targetType = TargetType.Float;
|
||||
|
||||
public override void OnDriverChange( RokojoriCompositorEffect re, float value )
|
||||
{
|
||||
var curveValue = curve == null ? value : curve.Sample( value );
|
||||
|
||||
if ( TargetType.Float == targetType )
|
||||
{
|
||||
ReflectionHelper.SetValue( re, member, curveValue );
|
||||
}
|
||||
else if ( TargetType.Int == targetType )
|
||||
{
|
||||
ReflectionHelper.SetValue( re, member, (int)curveValue );
|
||||
}
|
||||
else if ( TargetType.Bool == targetType )
|
||||
{
|
||||
ReflectionHelper.SetValue( re, member, curveValue > 0 );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://bwspscpb222by
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
|
||||
using Godot;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Rokojori
|
||||
{
|
||||
[Tool]
|
||||
[GlobalClass]
|
||||
public partial class CompositorEffectOwner:Resource
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://cx5qcow1mmd11
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
|
||||
using Godot;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Rokojori
|
||||
{
|
||||
[Tool]
|
||||
[GlobalClass]
|
||||
public abstract partial class CompositorEffectReference:Resource
|
||||
{
|
||||
public abstract CompositorEffect GetCompositorEffect( Node context );
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://cg5h1p6c6m1n6
|
||||
|
|
@ -0,0 +1,160 @@
|
|||
|
||||
using Godot;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Rokojori
|
||||
{
|
||||
[Tool]
|
||||
[GlobalClass]
|
||||
public partial class CompositorVFX:Node, IFloatDriver
|
||||
{
|
||||
[Export]
|
||||
public CompositorVFXPreset preset;
|
||||
|
||||
// [Export]
|
||||
// public RokojoriCompositorEffect[] effects = [];
|
||||
|
||||
float _driverValue = 0f;
|
||||
|
||||
[Export( PropertyHint.Range, "0,1" ) ]
|
||||
public float driverValue
|
||||
{
|
||||
get => _driverValue;
|
||||
|
||||
set
|
||||
{
|
||||
_driverValue = value;
|
||||
UpdateValue();
|
||||
}
|
||||
}
|
||||
|
||||
public float GetDriverFloatValue()
|
||||
{
|
||||
return _driverValue;
|
||||
}
|
||||
|
||||
public enum ManagingMode
|
||||
{
|
||||
None,
|
||||
Remove_On_Zero_Insert_At_InterMediate,
|
||||
Remove_On_NonIntermediate_Insert_Else
|
||||
}
|
||||
|
||||
[ExportGroup( "Actions")]
|
||||
[Export]
|
||||
public Action onChange;
|
||||
|
||||
[Export]
|
||||
public Action onZero;
|
||||
|
||||
[Export]
|
||||
public Action onOne;
|
||||
|
||||
[Export]
|
||||
public Action onIntermediate;
|
||||
|
||||
[ExportGroup("Setup")]
|
||||
[Export]
|
||||
public ManagingMode managingMode = ManagingMode.Remove_On_Zero_Insert_At_InterMediate;
|
||||
|
||||
[Export]
|
||||
public CompositorEffectLayout layout;
|
||||
|
||||
[Export]
|
||||
public CompositorEffectOwner ownerReference;
|
||||
|
||||
|
||||
void EnsureOwnerShip()
|
||||
{
|
||||
this.LogInfo( "EnsureOwnerShip", ownerReference );
|
||||
var undoMarker = UndoGD.Start( "Set Ownership for " + HierarchyName.Of( this ) );
|
||||
|
||||
if ( ownerReference == null )
|
||||
{
|
||||
ownerReference = new CompositorEffectOwner();
|
||||
this.LogInfo( "Created ownership", ownerReference );
|
||||
UndoGD.Set( this, nameof( ownerReference ), ownerReference );
|
||||
}
|
||||
|
||||
preset.effectPresets.ForEach( ep => SetOwnerShip( ep.effect ) );
|
||||
|
||||
UndoGD.End( undoMarker );
|
||||
}
|
||||
|
||||
void SetOwnerShip( RokojoriCompositorEffect effect )
|
||||
{
|
||||
var id = effect.compositorEffectID;
|
||||
|
||||
if ( id == null )
|
||||
{
|
||||
id = new RokojoriCompositorEffectID();
|
||||
UndoGD.Set( effect, nameof( effect.compositorEffectID ), id );
|
||||
}
|
||||
|
||||
if ( id.owner != ownerReference )
|
||||
{
|
||||
UndoGD.Set( id, nameof( id.owner ), ownerReference );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void UpdateValue()
|
||||
{
|
||||
this.LogInfo( "Updating value", _driverValue );
|
||||
|
||||
UpdateEffects();
|
||||
|
||||
onChange?.Trigger();
|
||||
|
||||
if ( _driverValue == 0 )
|
||||
{
|
||||
onZero?.Trigger();
|
||||
}
|
||||
else if ( _driverValue == 1 )
|
||||
{
|
||||
onOne?.Trigger();
|
||||
}
|
||||
else
|
||||
{
|
||||
onIntermediate?.Trigger();
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateEffects()
|
||||
{
|
||||
if ( preset == null || preset.effectPresets == null || preset.effectPresets.Length == 0 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
preset.effectPresets.ForEach( ep => ep.UpdateTargets( _driverValue ) );
|
||||
|
||||
if ( managingMode != ManagingMode.None )
|
||||
{
|
||||
EnsureOwnerShip();
|
||||
|
||||
var effects = preset.effectPresets.Map( ep => ep.effect ).ToArray();
|
||||
|
||||
var currentLayout = layout != null ? layout : Unique<CameraManager>.Get().compositorLayout;
|
||||
|
||||
if ( _driverValue == 0 || ( _driverValue == 1 && managingMode == ManagingMode.Remove_On_NonIntermediate_Insert_Else ) )
|
||||
{
|
||||
currentLayout.Ensure( effects, false );
|
||||
}
|
||||
else
|
||||
{
|
||||
currentLayout.Ensure( effects, true );
|
||||
|
||||
for ( int i = 0; i < effects.Length; i++ )
|
||||
{
|
||||
preset.effectPresets[ i ].effect = effects[ i ];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://cebnf3dtch0oh
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
|
||||
using Godot;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Rokojori
|
||||
{
|
||||
[Tool]
|
||||
[GlobalClass]
|
||||
public partial class CompositorVFXEffectPreset:Resource
|
||||
{
|
||||
[Export]
|
||||
public RokojoriCompositorEffect effect;
|
||||
|
||||
[Export]
|
||||
public CompositorEffectDriverTarget[] targets;
|
||||
|
||||
public void UpdateTargets( float value )
|
||||
{
|
||||
targets.ForEach( t => t.OnDriverChange( effect, value ) );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://cs4onr5s6171q
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
|
||||
using Godot;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Rokojori
|
||||
{
|
||||
[Tool]
|
||||
[GlobalClass]
|
||||
public partial class CompositorVFXPreset:Resource
|
||||
{
|
||||
[Export]
|
||||
public CompositorVFXEffectPreset[] effectPresets = [];
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://ckixweetchlo0
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
|
||||
using Godot;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Rokojori
|
||||
{
|
||||
[Tool]
|
||||
[GlobalClass]
|
||||
public partial class RokojoriCompositorEffectID:Resource
|
||||
{
|
||||
[Export]
|
||||
public CompositorEffectOwner owner;
|
||||
|
||||
[Export]
|
||||
public CompositorEffectLayer layer;
|
||||
|
||||
[Export]
|
||||
public int priority = 0;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://comuvej4dr22k
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
|
||||
using Godot;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Rokojori
|
||||
{
|
||||
[Tool]
|
||||
[GlobalClass]
|
||||
public partial class RokojoriCompositorEffectIDReference:CompositorEffectReference
|
||||
{
|
||||
[Export]
|
||||
public NodePath worldEnvironmentPath;
|
||||
|
||||
[Export]
|
||||
public RokojoriCompositorEffectID compositorEffectID;
|
||||
|
||||
public override CompositorEffect GetCompositorEffect( Node context )
|
||||
{
|
||||
var we = context.GetNode<WorldEnvironment>( worldEnvironmentPath );
|
||||
|
||||
if ( we == null || we.Compositor == null )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var fxs = we.Compositor.CompositorEffects;
|
||||
return fxs.Find( c => c is RokojoriCompositorEffect rce && rce.compositorEffectID == compositorEffectID );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://c5sw7q34a6m7f
|
||||
|
|
@ -0,0 +1,130 @@
|
|||
|
||||
using Godot;
|
||||
using Godot.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Rokojori
|
||||
{
|
||||
[Tool]
|
||||
[GlobalClass]
|
||||
public partial class DAAEffect:RDGraphCompositorEffect
|
||||
{
|
||||
public DAAEffect():base()
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
|
||||
|
||||
[Export( PropertyHint.Range, "0,4")]
|
||||
public float amount = 1;
|
||||
|
||||
[Export( PropertyHint.Range, "0,1")]
|
||||
public float edgeTreshold = 0.2f;
|
||||
|
||||
[Export( PropertyHint.Range, "1,4")]
|
||||
public float edgeTresholdPower = 1f;
|
||||
|
||||
[Export( PropertyHint.Range, "0,4")]
|
||||
public float edgeIntensity = 2f;
|
||||
|
||||
[Export( PropertyHint.Range, "0,1")]
|
||||
public float blurMix = 0.25f;
|
||||
|
||||
public enum BlurMode
|
||||
{
|
||||
UniDirectional,
|
||||
BiDirectional
|
||||
}
|
||||
|
||||
[Export]
|
||||
public BlurMode blurMode = BlurMode.UniDirectional;
|
||||
|
||||
[Export( PropertyHint.Range, "1,10" )]
|
||||
public int blurSpread = 1;
|
||||
|
||||
CEG_ScreenColorTexure screenColorTexture;
|
||||
|
||||
RG_DAA _daa0;
|
||||
RG_DAA _daa1;
|
||||
RG_DAA _daa2;
|
||||
RG_DAA _daa3;
|
||||
|
||||
List<RG_DAA> _daa = [];
|
||||
|
||||
|
||||
void Initialize()
|
||||
{
|
||||
EffectCallbackType = EffectCallbackTypeEnum.PostOpaque;
|
||||
|
||||
screenColorTexture = new CEG_ScreenColorTexure( graph );
|
||||
_daa0 = new RG_DAA( graph );
|
||||
_daa1 = new RG_DAA( graph );
|
||||
_daa2 = new RG_DAA( graph );
|
||||
_daa3 = new RG_DAA( graph );
|
||||
|
||||
graph.InitializeNodes();
|
||||
|
||||
_daa = [ _daa0, _daa1, _daa2, _daa3 ];
|
||||
|
||||
_daa.ForEach( fx =>
|
||||
{
|
||||
fx.input.sampler = context.Sampler( RenderingDevice.SamplerFilter.Linear, RenderingDevice.SamplerRepeatMode.ClampToEdge );
|
||||
fx.SetTextureSlotInputs( screenColorTexture, screenColorTexture );
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
graph.SetProcessOrder(
|
||||
screenColorTexture,
|
||||
_daa0,
|
||||
_daa1,
|
||||
_daa2,
|
||||
_daa3
|
||||
);
|
||||
}
|
||||
|
||||
int lastIterations = -1;
|
||||
|
||||
protected override void ForAllViews()
|
||||
{
|
||||
var clampedAmount = Mathf.Min( 3.99999999f, amount );
|
||||
int numIterations = Mathf.CeilToInt( clampedAmount );
|
||||
var partialAmount = amount - ( numIterations - 1 );
|
||||
|
||||
|
||||
if ( lastIterations != numIterations )
|
||||
{
|
||||
lastIterations = numIterations;
|
||||
var list = new List<RGGraphProcessor>();
|
||||
|
||||
list.Add( screenColorTexture );
|
||||
|
||||
for ( int i = 0; i < numIterations; i++ )
|
||||
{
|
||||
list.Add( _daa[ i ] );
|
||||
}
|
||||
|
||||
graph.SetProcessOrder( list.ToArray() );
|
||||
}
|
||||
|
||||
for ( int i = 0; i < numIterations; i++ )
|
||||
{
|
||||
float fxAmount = i == ( numIterations - 1 ) ? partialAmount : 1f;
|
||||
|
||||
_daa[ i ].constants.Set(
|
||||
fxAmount,
|
||||
Mathf.Pow( edgeTreshold, edgeTresholdPower ),
|
||||
edgeIntensity,
|
||||
blurMix,
|
||||
|
||||
(float)blurMode,
|
||||
(float)blurSpread,
|
||||
0f,
|
||||
0f
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://c88y1hc8yya48
|
||||
|
|
@ -7,9 +7,9 @@ namespace Rokojori
|
|||
{
|
||||
[Tool]
|
||||
[GlobalClass]
|
||||
public abstract partial class DepthAntiAliasingEffect:SingleShaderCompositorEffect
|
||||
public abstract partial class DepthAntiAliasingEffect:SingleShaderCompositorEffect
|
||||
{
|
||||
public static readonly string shaderPath = Path( "DepthAntiAliasing/DepthAntiAliasingShader.glsl" );
|
||||
public static readonly string shaderPath = Path( "AntiAliasing/DepthAntiAliasing/DepthAntiAliasingShader.glsl" );
|
||||
|
||||
RDSampler sampler;
|
||||
|
||||
|
|
@ -48,7 +48,7 @@ namespace Rokojori
|
|||
{
|
||||
base.OnInitialize();
|
||||
|
||||
sampler = context.Sampler( RenderingDevice.SamplerFilter.Nearest, RenderingDevice.SamplerRepeatMode.ClampToEdge );
|
||||
sampler = context.Sampler( RenderingDevice.SamplerFilter.Linear, RenderingDevice.SamplerRepeatMode.ClampToEdge );
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -58,12 +58,16 @@ namespace Rokojori
|
|||
constants.Set(
|
||||
(Vector2)context.internalSize,
|
||||
new Vector2( greyAmount, depthAmount ),
|
||||
Vector2.Zero,
|
||||
Vector2.Zero,
|
||||
effectStrength,
|
||||
depthEdgeTreshold / 100f,
|
||||
depthEdgeIntensity * 20f,
|
||||
colorContrastTreshold / 100f,
|
||||
colorContrastIntensity * 20f,
|
||||
debugView
|
||||
debugView,
|
||||
0f,
|
||||
0f
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -15,12 +15,18 @@ uniform Params
|
|||
{
|
||||
vec2 rasterSize;
|
||||
vec2 amounts;
|
||||
vec2 pad0;
|
||||
vec2 pad1;
|
||||
|
||||
float effectStrength;
|
||||
float edgeThreshold;
|
||||
float edgeIntensity;
|
||||
float contrastThreshold;
|
||||
|
||||
float contrastIntensity;
|
||||
float debugView;
|
||||
float pad2;
|
||||
float pad3;
|
||||
|
||||
} params;
|
||||
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
[remap]
|
||||
|
||||
importer="glsl"
|
||||
type="RDShaderFile"
|
||||
uid="uid://us4n0un8oo2v"
|
||||
path="res://.godot/imported/DepthAntiAliasingShader.glsl-62b6b5b853b384dd1246151bf3fa7d65.res"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://addons/rokojori_action_library/Runtime/Rendering/Compositor/CompositorEffects/AntiAliasing/DepthAntiAliasing/DepthAntiAliasingShader.glsl"
|
||||
dest_files=["res://.godot/imported/DepthAntiAliasingShader.glsl-62b6b5b853b384dd1246151bf3fa7d65.res"]
|
||||
|
||||
[params]
|
||||
|
||||
|
|
@ -0,0 +1,124 @@
|
|||
|
||||
using Godot;
|
||||
using Godot.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Rokojori
|
||||
{
|
||||
[Tool]
|
||||
[GlobalClass]
|
||||
public partial class FXAAEffect:RDGraphCompositorEffect
|
||||
{
|
||||
public FXAAEffect():base()
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
|
||||
|
||||
[Export( PropertyHint.Range, "0,4")]
|
||||
public float amount = 1;
|
||||
|
||||
public enum ExecutionMode
|
||||
{
|
||||
Ints_FullAmount_Fraction_PartialAmount,
|
||||
Four_With_PartialAmount
|
||||
}
|
||||
|
||||
[Export]
|
||||
public ExecutionMode executionMode = ExecutionMode.Ints_FullAmount_Fraction_PartialAmount;
|
||||
|
||||
// [Export( PropertyHint.Range, "0,2")]
|
||||
// public float exposure = 1f;
|
||||
|
||||
// [Export( PropertyHint.Range, "0,2")]
|
||||
// public float luminance_multiplier = 1f;
|
||||
|
||||
|
||||
CEG_ScreenColorTexure screenColorTexture;
|
||||
|
||||
RG_FXAA _fxaa0;
|
||||
RG_FXAA _fxaa1;
|
||||
RG_FXAA _fxaa2;
|
||||
RG_FXAA _fxaa3;
|
||||
|
||||
List<RG_FXAA> _fxaa = [];
|
||||
|
||||
|
||||
void Initialize()
|
||||
{
|
||||
screenColorTexture = new CEG_ScreenColorTexure( graph );
|
||||
_fxaa0 = new RG_FXAA( graph );
|
||||
_fxaa1 = new RG_FXAA( graph );
|
||||
_fxaa2 = new RG_FXAA( graph );
|
||||
_fxaa3 = new RG_FXAA( graph );
|
||||
|
||||
graph.InitializeNodes();
|
||||
|
||||
_fxaa = [ _fxaa0, _fxaa1, _fxaa2, _fxaa3 ];
|
||||
|
||||
_fxaa.ForEach( fx =>
|
||||
{
|
||||
fx.input.sampler = context.Sampler( RenderingDevice.SamplerFilter.Linear, RenderingDevice.SamplerRepeatMode.ClampToEdge );
|
||||
fx.SetTextureSlotInputs( screenColorTexture, screenColorTexture );
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
graph.SetProcessOrder(
|
||||
screenColorTexture,
|
||||
_fxaa0,
|
||||
_fxaa1,
|
||||
_fxaa2,
|
||||
_fxaa3
|
||||
);
|
||||
}
|
||||
|
||||
int lastIterations = -1;
|
||||
|
||||
protected override void ForAllViews()
|
||||
{
|
||||
var clampedAmount = Mathf.Min( 3.99999999f, amount );
|
||||
int numIterations = Mathf.CeilToInt( clampedAmount );
|
||||
var partialAmount = amount - ( numIterations - 1 );
|
||||
|
||||
if ( ExecutionMode.Four_With_PartialAmount == executionMode )
|
||||
{
|
||||
numIterations = 4;
|
||||
}
|
||||
|
||||
|
||||
if ( lastIterations != numIterations )
|
||||
{
|
||||
lastIterations = numIterations;
|
||||
var list = new List<RGGraphProcessor>();
|
||||
|
||||
list.Add( screenColorTexture );
|
||||
|
||||
for ( int i = 0; i < numIterations; i++ )
|
||||
{
|
||||
list.Add( _fxaa[ i ] );
|
||||
}
|
||||
|
||||
graph.SetProcessOrder( list.ToArray() );
|
||||
}
|
||||
|
||||
for ( int i = 0; i < numIterations; i++ )
|
||||
{
|
||||
float fxAmount = i == ( numIterations - 1 ) ? partialAmount : 1f;
|
||||
|
||||
if ( ExecutionMode.Four_With_PartialAmount == executionMode )
|
||||
{
|
||||
fxAmount = amount / 4.0f;
|
||||
}
|
||||
|
||||
_fxaa[ i ].constants.Set(
|
||||
1f,
|
||||
1f,
|
||||
fxAmount
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://bgw3wuqxbwrb0
|
||||
|
|
@ -0,0 +1,96 @@
|
|||
|
||||
using Godot;
|
||||
using Godot.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Rokojori
|
||||
{
|
||||
[Tool]
|
||||
[GlobalClass]
|
||||
public partial class CrossChannelCurvesEffect:RDGraphCompositorEffect
|
||||
{
|
||||
public CrossChannelCurvesEffect():base()
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
|
||||
public enum CrossChannelDriver
|
||||
{
|
||||
Red,
|
||||
Green,
|
||||
Blue,
|
||||
Hue,
|
||||
Saturation,
|
||||
Lightness
|
||||
}
|
||||
|
||||
public enum CrossChannelTarget
|
||||
{
|
||||
Red,
|
||||
Green,
|
||||
Blue,
|
||||
Hue,
|
||||
Saturation,
|
||||
Lightness,
|
||||
Temparature
|
||||
}
|
||||
|
||||
[Export( PropertyHint.Range, "0,1") ]
|
||||
public float amount = 0.5f;
|
||||
|
||||
[Export]
|
||||
public CrossChannelDriver driver = CrossChannelDriver.Lightness;
|
||||
|
||||
[Export]
|
||||
public CrossChannelTarget target = CrossChannelTarget.Saturation;
|
||||
|
||||
[Export]
|
||||
public CurveTexture curve = new CurveTexture();
|
||||
|
||||
CEG_ScreenColorTexure screenColorTexture;
|
||||
RG_ImageTexture _curvesTexture;
|
||||
RG_CrossChannelCurves _curves;
|
||||
|
||||
void Initialize()
|
||||
{
|
||||
screenColorTexture = new CEG_ScreenColorTexure( graph );
|
||||
_curvesTexture = new RG_ImageTexture( graph );
|
||||
_curves = new RG_CrossChannelCurves( graph );
|
||||
|
||||
|
||||
graph.InitializeNodes();
|
||||
|
||||
|
||||
_curves.SetTextureSlotInputs( screenColorTexture, screenColorTexture );
|
||||
_curves.SetCurvesTextureSlotInputs( _curvesTexture );
|
||||
|
||||
_curvesTexture.SetImageTexture( curve );
|
||||
|
||||
_curves.curves.sampler = context.Sampler( RenderingDevice.SamplerFilter.Linear, RenderingDevice.SamplerRepeatMode.ClampToEdge );
|
||||
|
||||
graph.SetProcessOrder(
|
||||
screenColorTexture,
|
||||
_curves
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
protected override void ForAllViews()
|
||||
{
|
||||
_curvesTexture.SetImageTexture( curve );
|
||||
|
||||
_curves.constants.Set(
|
||||
amount,
|
||||
(float)(int)driver,
|
||||
(float)(int)target,
|
||||
0f,
|
||||
0f,
|
||||
0f,
|
||||
0f,
|
||||
0f
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://7dbnbfv4pdw
|
||||
|
|
@ -0,0 +1,86 @@
|
|||
|
||||
using Godot;
|
||||
using Godot.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Rokojori
|
||||
{
|
||||
[Tool]
|
||||
[GlobalClass]
|
||||
public partial class HDRMappingEffect:RDGraphCompositorEffect
|
||||
{
|
||||
public HDRMappingEffect():base()
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
|
||||
[Export( PropertyHint.Range, "0,1") ]
|
||||
public float amount = 0.5f;
|
||||
|
||||
[Export]
|
||||
public CurveTexture mapping = new CurveTexture();
|
||||
|
||||
[Export]
|
||||
public float inputMaxmimum = 10;
|
||||
|
||||
[Export]
|
||||
public float outputMaximum = 10;
|
||||
|
||||
[ExportGroup( "Luma Settings")]
|
||||
[Export]
|
||||
public Vector3 lumaWeights = new Vector3( 0.3f, 0.5f, 0.2f );
|
||||
|
||||
[Export]
|
||||
public float lumaPower = 1;
|
||||
|
||||
[Export]
|
||||
public float lumaScale = 1;
|
||||
|
||||
CEG_ScreenColorTexure screenColorTexture;
|
||||
RG_ImageTexture _curvesTexture;
|
||||
RG_HDRMapping _mapping;
|
||||
|
||||
void Initialize()
|
||||
{
|
||||
screenColorTexture = new CEG_ScreenColorTexure( graph );
|
||||
_curvesTexture = new RG_ImageTexture( graph );
|
||||
_mapping = new RG_HDRMapping( graph );
|
||||
|
||||
|
||||
graph.InitializeNodes();
|
||||
|
||||
|
||||
_mapping.SetTextureSlotInputs( _curvesTexture, screenColorTexture );
|
||||
|
||||
_curvesTexture.SetImageTexture( mapping );
|
||||
|
||||
_mapping.input.sampler = context.Sampler( RenderingDevice.SamplerFilter.Linear, RenderingDevice.SamplerRepeatMode.ClampToEdge );
|
||||
|
||||
graph.SetProcessOrder(
|
||||
screenColorTexture,
|
||||
_curvesTexture,
|
||||
_mapping
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
protected override void ForAllViews()
|
||||
{
|
||||
_curvesTexture.SetImageTexture( mapping );
|
||||
|
||||
_mapping.constants.Set(
|
||||
inputMaxmimum,
|
||||
lumaWeights.X,
|
||||
lumaWeights.Y,
|
||||
lumaWeights.Z,
|
||||
|
||||
lumaPower,
|
||||
lumaScale,
|
||||
outputMaximum,
|
||||
0f
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://uwj67glvbmk4
|
||||
|
|
@ -0,0 +1,63 @@
|
|||
|
||||
using Godot;
|
||||
using Godot.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Rokojori
|
||||
{
|
||||
[Tool]
|
||||
[GlobalClass]
|
||||
public partial class HSLCurvesEffect:RDGraphCompositorEffect
|
||||
{
|
||||
public HSLCurvesEffect():base()
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
|
||||
[Export( PropertyHint.Range, "0,1") ]
|
||||
public float amount = 0.5f;
|
||||
|
||||
[Export]
|
||||
public CurveXyzTexture curves = new CurveXyzTexture();
|
||||
|
||||
CEG_ScreenColorTexure screenColorTexture;
|
||||
RG_ImageTexture _curvesTexture;
|
||||
RG_HSLCurves _curves;
|
||||
|
||||
void Initialize()
|
||||
{
|
||||
screenColorTexture = new CEG_ScreenColorTexure( graph );
|
||||
_curvesTexture = new RG_ImageTexture( graph );
|
||||
_curves = new RG_HSLCurves( graph );
|
||||
|
||||
|
||||
graph.InitializeNodes();
|
||||
|
||||
|
||||
_curves.SetTextureSlotInputs( screenColorTexture, screenColorTexture );
|
||||
_curves.SetCurvesTextureSlotInputs( _curvesTexture );
|
||||
|
||||
_curvesTexture.SetImageTexture( curves );
|
||||
|
||||
_curves.curves.sampler = context.Sampler( RenderingDevice.SamplerFilter.Linear, RenderingDevice.SamplerRepeatMode.ClampToEdge );
|
||||
|
||||
graph.SetProcessOrder(
|
||||
screenColorTexture,
|
||||
_curves
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
protected override void ForAllViews()
|
||||
{
|
||||
_curvesTexture.SetImageTexture( curves );
|
||||
|
||||
_curves.constants.Set(
|
||||
|
||||
amount
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://v8yddy4erbru
|
||||
|
|
@ -0,0 +1,63 @@
|
|||
|
||||
using Godot;
|
||||
using Godot.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Rokojori
|
||||
{
|
||||
[Tool]
|
||||
[GlobalClass]
|
||||
public partial class RGBCurvesEffect:RDGraphCompositorEffect
|
||||
{
|
||||
public RGBCurvesEffect():base()
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
|
||||
[Export( PropertyHint.Range, "0,1") ]
|
||||
public float amount = 0.5f;
|
||||
|
||||
[Export]
|
||||
public CurveXyzTexture curves = new CurveXyzTexture();
|
||||
|
||||
CEG_ScreenColorTexure screenColorTexture;
|
||||
RG_ImageTexture _curvesTexture;
|
||||
RG_RGBCurves _curves;
|
||||
|
||||
void Initialize()
|
||||
{
|
||||
screenColorTexture = new CEG_ScreenColorTexure( graph );
|
||||
_curvesTexture = new RG_ImageTexture( graph );
|
||||
_curves = new RG_RGBCurves( graph );
|
||||
|
||||
|
||||
graph.InitializeNodes();
|
||||
|
||||
|
||||
_curves.SetTextureSlotInputs( screenColorTexture, screenColorTexture );
|
||||
_curves.SetCurvesTextureSlotInputs( _curvesTexture );
|
||||
|
||||
_curvesTexture.SetImageTexture( curves );
|
||||
|
||||
_curves.curves.sampler = context.Sampler( RenderingDevice.SamplerFilter.Linear, RenderingDevice.SamplerRepeatMode.ClampToEdge );
|
||||
|
||||
graph.SetProcessOrder(
|
||||
screenColorTexture,
|
||||
_curves
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
protected override void ForAllViews()
|
||||
{
|
||||
_curvesTexture.SetImageTexture( curves );
|
||||
|
||||
_curves.constants.Set(
|
||||
|
||||
amount
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://bwobnip0unil2
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
[remap]
|
||||
|
||||
importer="glsl"
|
||||
type="RDShaderFile"
|
||||
uid="uid://us4n0un8oo2v"
|
||||
path="res://.godot/imported/DepthAntiAliasingShader.glsl-51ad5443a76812922ed37cac7bc9291d.res"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://addons/rokojori_action_library/Runtime/Rendering/Compositor/CompositorEffects/DepthAntiAliasing/DepthAntiAliasingShader.glsl"
|
||||
dest_files=["res://.godot/imported/DepthAntiAliasingShader.glsl-51ad5443a76812922ed37cac7bc9291d.res"]
|
||||
|
||||
[params]
|
||||
|
||||
|
|
@ -0,0 +1,113 @@
|
|||
|
||||
using Godot;
|
||||
using Godot.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Rokojori
|
||||
{
|
||||
[Tool]
|
||||
[GlobalClass]
|
||||
public partial class EdgeDistortionEffect:RDGraphCompositorEffect
|
||||
{
|
||||
public EdgeDistortionEffect():base()
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
|
||||
[Export( PropertyHint.Range, "0,0.5") ]
|
||||
public float distortionAmount = 0.1f;
|
||||
|
||||
[Export( PropertyHint.Range, "0,1") ]
|
||||
public float blendAmount = 1f;
|
||||
|
||||
[Export( PropertyHint.Range, "0,1") ]
|
||||
public float horizontalAmount = 1f;
|
||||
|
||||
[Export( PropertyHint.Range, "0,0.5") ]
|
||||
public float horizontalEdge = 0.5f;
|
||||
|
||||
[Export( PropertyHint.Range, "0,1") ]
|
||||
public float horizontalEdgePower = 0.25f;
|
||||
|
||||
[Export( PropertyHint.Range, "0,1") ]
|
||||
public float verticalAmount = 1f;
|
||||
|
||||
[Export( PropertyHint.Range, "0,0.5") ]
|
||||
public float verticalEdge = 0.5f;
|
||||
|
||||
[Export( PropertyHint.Range, "0,1") ]
|
||||
public float verticalEdgePower = 0.25f;
|
||||
|
||||
|
||||
[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_EdgeDistortion distortion;
|
||||
|
||||
void Initialize()
|
||||
{
|
||||
screenColorTexture = new CEG_ScreenColorTexure( graph );
|
||||
bufferTexture = CEG_BufferTexture.ScreenSize( graph );
|
||||
|
||||
copy = new CEG_Copy( graph );
|
||||
distortion = new RG_EdgeDistortion( 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(
|
||||
distortionAmount,
|
||||
blendAmount,
|
||||
horizontalEdge,
|
||||
verticalEdge,
|
||||
1.0f + redShift,
|
||||
1.0f + greenShift,
|
||||
1.0f + blueShift,
|
||||
(float) smearingSteps,
|
||||
smearing,
|
||||
Mathf.Pow( 10f, horizontalEdgePower ),
|
||||
Mathf.Pow( 10f, verticalEdgePower ),
|
||||
horizontalAmount,
|
||||
verticalAmount,
|
||||
0f,
|
||||
0f,
|
||||
0f
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://be2v7ns5irml5
|
||||
|
|
@ -0,0 +1,204 @@
|
|||
|
||||
using Godot;
|
||||
using Godot.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Rokojori
|
||||
{
|
||||
[Tool]
|
||||
[GlobalClass]
|
||||
public partial class TextureDistortionEffect:RDGraphCompositorEffect
|
||||
{
|
||||
public TextureDistortionEffect():base()
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
|
||||
|
||||
[ExportGroup("Main")]
|
||||
[Export( PropertyHint.Range, "0,1") ]
|
||||
public float distortionAmount = 0.1f;
|
||||
|
||||
[Export( PropertyHint.Range, "0,1") ]
|
||||
public float blendAmount = 1f;
|
||||
|
||||
[Export( PropertyHint.Range, "1,5") ]
|
||||
public int smearingSteps = 3;
|
||||
|
||||
[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;
|
||||
|
||||
[ExportGroup("Distortion Texture", "distortion")]
|
||||
[Export]
|
||||
public Texture2D distortionTexture;
|
||||
|
||||
[Export]
|
||||
public Vector2 distortionTiling = Vector2.One;
|
||||
|
||||
[Export]
|
||||
public Vector2 distortionOffset = Vector2.Zero;
|
||||
|
||||
[Export]
|
||||
public Vector2 distortionScroll = Vector2.Zero;
|
||||
|
||||
[Export]
|
||||
public TimeLine distortionScrollTimeLine;
|
||||
|
||||
|
||||
[Export]
|
||||
public RenderingDevice.SamplerFilter distortionFilter = RenderingDevice.SamplerFilter.Linear;
|
||||
|
||||
[Export]
|
||||
public RenderingDevice.SamplerRepeatMode distortionRepeatMode = RenderingDevice.SamplerRepeatMode.Repeat;
|
||||
|
||||
[Export]
|
||||
public ColorSpaceConversion distortionTextureConversion = ColorSpaceConversion.No_Conversion;
|
||||
|
||||
[ExportGroup("Mask Texture", "mask")]
|
||||
[Export]
|
||||
public Texture2D maskTexture;
|
||||
|
||||
[Export ]
|
||||
public Vector2 maskTiling = Vector2.One;
|
||||
|
||||
[Export ]
|
||||
public Vector2 maskOffset = Vector2.Zero;
|
||||
|
||||
[Export ]
|
||||
public Vector2 maskScroll = Vector2.Zero;
|
||||
|
||||
[Export]
|
||||
public TimeLine maskScrollTimeLine;
|
||||
|
||||
[Export]
|
||||
public RenderingDevice.SamplerFilter maskFilter = RenderingDevice.SamplerFilter.Linear;
|
||||
|
||||
[Export]
|
||||
public RenderingDevice.SamplerRepeatMode maskRepeatMode = RenderingDevice.SamplerRepeatMode.Repeat;
|
||||
|
||||
[Export]
|
||||
public ColorSpaceConversion maskTextureConversion = ColorSpaceConversion.No_Conversion;
|
||||
|
||||
CEG_ScreenColorTexure screenColorTexture;
|
||||
CEG_BufferTexture bufferTexture;
|
||||
RG_ImageTexture distortionTextureInput;
|
||||
RG_ImageTexture maskTextureInput;
|
||||
|
||||
CEG_Copy copy;
|
||||
RD_TextureDistortion distortion;
|
||||
|
||||
void Initialize()
|
||||
{
|
||||
screenColorTexture = new CEG_ScreenColorTexure( graph );
|
||||
bufferTexture = CEG_BufferTexture.ScreenSize( graph );
|
||||
distortionTextureInput = new RG_ImageTexture( graph );
|
||||
maskTextureInput = new RG_ImageTexture( graph );
|
||||
|
||||
copy = new CEG_Copy( graph );
|
||||
distortion = new RD_TextureDistortion( graph );
|
||||
|
||||
graph.InitializeNodes();
|
||||
|
||||
copy.SetTextureSlotInputs( screenColorTexture, bufferTexture );
|
||||
|
||||
distortion.SetTextureSlotInputs( copy.output, copy.input );
|
||||
distortion.SetDistortionTextureSlotInputs( distortionTextureInput, maskTextureInput );
|
||||
|
||||
distortion.distortion.sampler = context.Sampler( distortionFilter, distortionRepeatMode );
|
||||
distortion.mask.sampler = context.Sampler( maskFilter, maskRepeatMode );
|
||||
|
||||
distortionTextureInput.SetImageTexture( distortionTexture );
|
||||
maskTextureInput.SetImageTexture( maskTexture );
|
||||
|
||||
graph.SetProcessOrder(
|
||||
screenColorTexture,
|
||||
bufferTexture,
|
||||
distortionTextureInput,
|
||||
maskTextureInput,
|
||||
|
||||
copy,
|
||||
distortion
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
RenderingDevice.SamplerFilter assignedfilterTop = RenderingDevice.SamplerFilter.Linear;
|
||||
RenderingDevice.SamplerRepeatMode assignedRepeatModeTop = RenderingDevice.SamplerRepeatMode.Repeat;
|
||||
|
||||
RenderingDevice.SamplerFilter assignedfilterMask = RenderingDevice.SamplerFilter.Linear;
|
||||
RenderingDevice.SamplerRepeatMode assignedRepeatModeMask = RenderingDevice.SamplerRepeatMode.Repeat;
|
||||
|
||||
|
||||
protected override void ForAllViews()
|
||||
{
|
||||
// RJLog.Log( "FOR ALL:", distortionTexture, maskTexture );
|
||||
|
||||
if ( assignedfilterTop != distortionFilter || assignedRepeatModeTop != distortionRepeatMode )
|
||||
{
|
||||
assignedfilterTop = distortionFilter;
|
||||
assignedRepeatModeTop = distortionRepeatMode;
|
||||
|
||||
distortion.distortion.sampler = context.Sampler( assignedfilterTop, assignedRepeatModeTop );
|
||||
}
|
||||
|
||||
if ( assignedfilterMask != maskFilter || assignedRepeatModeMask != maskRepeatMode )
|
||||
{
|
||||
assignedfilterMask = maskFilter;
|
||||
assignedRepeatModeMask = maskRepeatMode;
|
||||
|
||||
distortion.mask.sampler = context.Sampler( assignedfilterMask, assignedRepeatModeMask );
|
||||
}
|
||||
|
||||
distortionTextureInput.SetImageTexture( distortionTexture );
|
||||
maskTextureInput.SetImageTexture( maskTexture );
|
||||
|
||||
// RJLog.Log(
|
||||
// distortionTextureInput.GetTexture(), distortionTexture,
|
||||
// maskTextureInput.GetTexture(), maskTexture
|
||||
// );
|
||||
|
||||
var timeLine = TimeLineManager.Ensure( distortionScrollTimeLine );
|
||||
var scrollPosition = timeLine.position * distortionScroll;
|
||||
scrollPosition.X = MathX.Repeat( scrollPosition.X, 1.0f );
|
||||
scrollPosition.Y = MathX.Repeat( scrollPosition.Y, 1.0f );
|
||||
|
||||
var timeLineMask = TimeLineManager.Ensure( maskScrollTimeLine );
|
||||
var scrollPositionMask = timeLineMask.position * maskScroll;
|
||||
scrollPositionMask.X = MathX.Repeat( scrollPositionMask.X, 1.0f );
|
||||
scrollPositionMask.Y = MathX.Repeat( scrollPositionMask.Y, 1.0f );
|
||||
|
||||
distortion.constants.Set(
|
||||
distortionTiling.ToVector4( distortionOffset + scrollPosition ),
|
||||
maskTiling.ToVector4( maskOffset + scrollPositionMask ),
|
||||
Vector4.Zero,
|
||||
Vector4.Zero,
|
||||
|
||||
distortionAmount,
|
||||
blendAmount,
|
||||
1.0f + redShift,
|
||||
1.0f + greenShift,
|
||||
|
||||
1.0f + blueShift,
|
||||
(float) smearingSteps,
|
||||
smearing,
|
||||
(float)(int)distortionTextureConversion,
|
||||
(float)(int)maskTextureConversion,
|
||||
0f,
|
||||
0f,
|
||||
0f
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://balixgskgouhm
|
||||
|
|
@ -0,0 +1,245 @@
|
|||
|
||||
using Godot;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Rokojori
|
||||
{
|
||||
[Tool]
|
||||
[GlobalClass]
|
||||
public partial class ChromaticBloomEffect:RDGraphCompositorEffect
|
||||
{
|
||||
public ChromaticBloomEffect():base()
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
|
||||
[ExportGroup( "Main")]
|
||||
[Export( PropertyHint.Range, "0,1") ]
|
||||
public float amount = 0.5f;
|
||||
|
||||
[Export( PropertyHint.Range, "1,10") ]
|
||||
public int num = 2;
|
||||
|
||||
[ExportGroup( "Distortion")]
|
||||
|
||||
[Export( PropertyHint.Range, "0,1") ]
|
||||
public float distortionAmount = 0.5f;
|
||||
|
||||
[Export( PropertyHint.Range, "0,360") ]
|
||||
public float distortionAngle = 0.5f;
|
||||
|
||||
[Export( PropertyHint.Range, "0,360") ]
|
||||
public float distortionAngleSpeed = 0.5f;
|
||||
|
||||
[Export]
|
||||
public TimeLine distortionAngleTimeLine;
|
||||
|
||||
[Export( PropertyHint.Range, "-1,1") ]
|
||||
public Vector2 distortionOffset = Vector2.Zero;
|
||||
|
||||
[ExportGroup( "Smearing")]
|
||||
[Export( PropertyHint.Range, "1,32") ]
|
||||
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;
|
||||
|
||||
[ExportGroup( "Luma")]
|
||||
[Export]
|
||||
public Color lumaTint = Colors.White;
|
||||
|
||||
[Export]
|
||||
public Vector3 lumaWeights = new Vector3( 0.3f, 0.5f, 0.2f );
|
||||
|
||||
[Export]
|
||||
public float lumaWeightPower =1f;
|
||||
|
||||
[Export]
|
||||
public Vector2 lumaInputRange = new Vector2( 0.5f, 1.5f );
|
||||
|
||||
[Export]
|
||||
public float lumaNormalizationPower = 1f;
|
||||
|
||||
[Export]
|
||||
public Vector2 lumaOutputRange = new Vector2( 0f, 1.5f );
|
||||
|
||||
[Export]
|
||||
public float desaturation = 1f;
|
||||
|
||||
|
||||
int _downSampling = 16;
|
||||
|
||||
public enum DownSampling
|
||||
{
|
||||
_1x_,
|
||||
_2x_,
|
||||
_4x_,
|
||||
_8x_,
|
||||
_16x_,
|
||||
_32x_
|
||||
}
|
||||
|
||||
public int downSamplingRate => Mathf.RoundToInt( Mathf.Pow( 2, (int) downSampling ) );
|
||||
|
||||
[Export]
|
||||
public DownSampling downSampling = DownSampling._4x_;
|
||||
|
||||
|
||||
CEG_ScreenColorTexure screenColorTexture;
|
||||
CEG_BufferTexture bufferTexture;
|
||||
|
||||
RG_Resize downScale;
|
||||
|
||||
RG_ExtractGlow extractGlow;
|
||||
|
||||
int maxBlooms = 10;
|
||||
|
||||
|
||||
List<RG_ChromaticBloom> _blooms = [];
|
||||
|
||||
|
||||
void Initialize()
|
||||
{
|
||||
screenColorTexture = new CEG_ScreenColorTexure( graph );
|
||||
bufferTexture = CEG_BufferTexture.ScreenSize( graph, Vector2.One / (float) _downSampling );
|
||||
|
||||
downScale = new RG_Resize( graph );
|
||||
extractGlow = new RG_ExtractGlow( graph );
|
||||
|
||||
// bloom = new RG_ChromaticBloom( graph );
|
||||
// bloom2 = new RG_ChromaticBloom( graph );
|
||||
// bloom3 = new RG_ChromaticBloom( graph );
|
||||
// bloom4 = new RG_ChromaticBloom( graph );
|
||||
|
||||
// _blooms = [ bloom, bloom2, bloom3, bloom4 ];
|
||||
|
||||
_blooms = new List<RG_ChromaticBloom>();
|
||||
|
||||
for ( int i = 0; i < maxBlooms; i++ )
|
||||
{
|
||||
var b = new RG_ChromaticBloom( graph );
|
||||
_blooms.Add( b );
|
||||
}
|
||||
|
||||
graph.InitializeNodes();
|
||||
|
||||
downScale.SetTextureSlotInputs( screenColorTexture, bufferTexture );
|
||||
downScale.input.UseSampler();
|
||||
|
||||
extractGlow.SetTextureSlotInputs( screenColorTexture, bufferTexture );
|
||||
extractGlow.input.UseSampler();
|
||||
|
||||
_blooms.ForEach(
|
||||
( b )=>
|
||||
{
|
||||
b.SetTextureSlotInputs( bufferTexture, screenColorTexture );
|
||||
b.input.UseSampler();
|
||||
}
|
||||
);
|
||||
|
||||
graph.SetProcessOrder(
|
||||
screenColorTexture,
|
||||
bufferTexture,
|
||||
extractGlow
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
int _lastNum = -1;
|
||||
|
||||
protected override void ForAllViews()
|
||||
{
|
||||
if ( downSamplingRate != _downSampling )
|
||||
{
|
||||
_downSampling = downSamplingRate;
|
||||
( bufferTexture.GetCreator() as CEG_TextureCreator_ScreenSize ).scale = Vector2.One / (float) _downSampling;
|
||||
}
|
||||
|
||||
downScale.SetCustomComputeSize( context.internalSize / _downSampling );
|
||||
|
||||
extractGlow.SetCustomComputeSize( context.internalSize / _downSampling );
|
||||
|
||||
extractGlow.constants.Set(
|
||||
lumaWeights.X,
|
||||
lumaWeights.Y,
|
||||
lumaWeights.Z,
|
||||
lumaWeightPower,
|
||||
|
||||
lumaInputRange.X,
|
||||
lumaInputRange.Y,
|
||||
lumaNormalizationPower,
|
||||
lumaOutputRange.X,
|
||||
|
||||
lumaOutputRange.Y,
|
||||
desaturation,
|
||||
lumaTint.R,
|
||||
lumaTint.G,
|
||||
|
||||
lumaTint.B,
|
||||
0f,
|
||||
0f,
|
||||
0f
|
||||
);
|
||||
|
||||
if ( _lastNum != num )
|
||||
{
|
||||
_lastNum = num;
|
||||
|
||||
var list = new List<RGGraphProcessor>(){
|
||||
screenColorTexture,
|
||||
bufferTexture,
|
||||
extractGlow
|
||||
};
|
||||
|
||||
for ( int i = 0; i < num; i++ )
|
||||
{
|
||||
list.Add( _blooms[ i ] );
|
||||
}
|
||||
|
||||
graph.SetProcessOrder( list.ToArray() );
|
||||
}
|
||||
|
||||
var combinedRotation = distortionAngle;
|
||||
|
||||
var tl = TimeLineManager.Ensure( distortionAngleTimeLine );
|
||||
var animationRotation = MathX.Repeat( tl.position * distortionAngleSpeed / 360, 1f ) * 360f;
|
||||
combinedRotation = MathX.Repeat( animationRotation + combinedRotation, 360f );
|
||||
|
||||
|
||||
for ( int i = 0; i < num; i++ )
|
||||
{
|
||||
float angleOffset = 180f / (float) num;
|
||||
|
||||
_blooms[ i ].constants.Set(
|
||||
amount,
|
||||
1.0f + redShift,
|
||||
1.0f + greenShift,
|
||||
1.0f + blueShift,
|
||||
|
||||
(float) smearingSteps,
|
||||
smearing,
|
||||
distortionAmount,
|
||||
( combinedRotation + i * angleOffset ) / 180f * Mathf.Pi,
|
||||
|
||||
distortionOffset.X,
|
||||
distortionOffset.Y,
|
||||
0f,
|
||||
0f
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://6jkixa201wux
|
||||
|
|
@ -0,0 +1,213 @@
|
|||
|
||||
using Godot;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Rokojori
|
||||
{
|
||||
[Tool]
|
||||
[GlobalClass]
|
||||
public partial class StreaksEffect:RDGraphCompositorEffect
|
||||
{
|
||||
public StreaksEffect():base()
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
|
||||
[Export( PropertyHint.Range, "0,1") ]
|
||||
public float intensity = 0.5f;
|
||||
|
||||
[Export( PropertyHint.Range, "0,1") ]
|
||||
public float intensityScale = 0.1f;
|
||||
|
||||
[Export( PropertyHint.Range, "0,1") ]
|
||||
public float amount = 0.1f;
|
||||
|
||||
[Export ]
|
||||
public Vector2 direction = new Vector2( 1f, 0f );
|
||||
|
||||
[Export( PropertyHint.Range, "-360,360") ]
|
||||
public float rotationOffset = 0;
|
||||
|
||||
[Export( PropertyHint.Range, "-360,360") ]
|
||||
public float rotationSpeed = 0;
|
||||
|
||||
[Export]
|
||||
public TimeLine rotationSpeedTimeLine;
|
||||
|
||||
[Export( PropertyHint.Range, "1,8") ]
|
||||
public int numStreaks = 3;
|
||||
|
||||
[Export( PropertyHint.Range, "0,1") ]
|
||||
public float attenuation = 0.5f;
|
||||
|
||||
[Export( PropertyHint.Range, "0,5") ]
|
||||
public float lumaTreshold = 1.0f;
|
||||
|
||||
[Export( PropertyHint.Range, "-1,1") ]
|
||||
public float lumaScale5 = 0f;
|
||||
|
||||
[Export( PropertyHint.Range, "1,12") ]
|
||||
public int samples = 2;
|
||||
|
||||
[Export( PropertyHint.Range, "0,1") ]
|
||||
public float desaturation = 0.5f;
|
||||
|
||||
[Export( PropertyHint.Range, "1,5") ]
|
||||
public int blurRadius = 1;
|
||||
|
||||
[Export( PropertyHint.Range, "1,10") ]
|
||||
public int blurSpread = 1;
|
||||
|
||||
[Export( PropertyHint.Range, "0,10") ]
|
||||
public float blurNoise = 1;
|
||||
|
||||
public enum DownSampling
|
||||
{
|
||||
_1x_,
|
||||
_2x_,
|
||||
_4x_,
|
||||
_8x_,
|
||||
_16x_,
|
||||
_32x_
|
||||
}
|
||||
|
||||
public int downSamplingRate => Mathf.RoundToInt( Mathf.Pow( 2, (int) downSampling ) );
|
||||
|
||||
[Export]
|
||||
public DownSampling downSampling = DownSampling._4x_;
|
||||
|
||||
CEG_ScreenColorTexure screenColorTexture;
|
||||
CEG_BufferTexture bufferTexture;
|
||||
CEG_BufferTexture bufferTexture2;
|
||||
|
||||
RG_Resize downScale;
|
||||
CEG_Copy copy;
|
||||
|
||||
RG_GlowAdd upScale;
|
||||
|
||||
RG_Streaks streaks1;
|
||||
RG_Streaks streaks2;
|
||||
RG_Streaks streaks3;
|
||||
|
||||
List<RG_Streaks> _streaks;
|
||||
|
||||
int _downSampling = 16;
|
||||
|
||||
void Initialize()
|
||||
{
|
||||
screenColorTexture = new CEG_ScreenColorTexure( graph );
|
||||
bufferTexture = CEG_BufferTexture.ScreenSize( graph, Vector2.One / (float) _downSampling );
|
||||
bufferTexture2 = CEG_BufferTexture.ScreenSize( graph, Vector2.One / (float) _downSampling );
|
||||
|
||||
downScale = new RG_Resize( graph );
|
||||
upScale = new RG_GlowAdd( graph );
|
||||
|
||||
copy = new CEG_Copy( graph );
|
||||
|
||||
streaks1 = new RG_Streaks( graph );
|
||||
streaks2 = new RG_Streaks( graph );
|
||||
streaks3 = new RG_Streaks( graph );
|
||||
|
||||
_streaks =
|
||||
[
|
||||
streaks1,
|
||||
streaks2,
|
||||
streaks3
|
||||
];
|
||||
|
||||
graph.InitializeNodes();
|
||||
|
||||
downScale.SetTextureSlotInputs( screenColorTexture, bufferTexture );
|
||||
downScale.input.UseSampler();
|
||||
|
||||
copy.SetTextureSlotInputs( bufferTexture, bufferTexture2 );
|
||||
|
||||
streaks1.SetTextureSlotInputs( bufferTexture, bufferTexture2 );
|
||||
streaks1.input.UseSampler();
|
||||
|
||||
streaks2.SetTextureSlotInputs( bufferTexture2, bufferTexture );
|
||||
streaks2.input.UseSampler();
|
||||
|
||||
streaks3.SetTextureSlotInputs( bufferTexture, bufferTexture2 );
|
||||
streaks3.input.UseSampler();
|
||||
|
||||
upScale.SetTextureSlotInputs( bufferTexture2, screenColorTexture );
|
||||
upScale.input.UseSampler();
|
||||
|
||||
|
||||
graph.SetProcessOrder(
|
||||
screenColorTexture,
|
||||
bufferTexture,
|
||||
bufferTexture2,
|
||||
|
||||
downScale,
|
||||
|
||||
copy,
|
||||
|
||||
streaks1,
|
||||
streaks2,
|
||||
streaks3,
|
||||
|
||||
upScale
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected override void ForAllViews()
|
||||
{
|
||||
if ( downSamplingRate != _downSampling )
|
||||
{
|
||||
_downSampling = downSamplingRate;
|
||||
( bufferTexture.GetCreator() as CEG_TextureCreator_ScreenSize ).scale = Vector2.One / (float) _downSampling;
|
||||
( bufferTexture2.GetCreator() as CEG_TextureCreator_ScreenSize ).scale = Vector2.One / (float) _downSampling;
|
||||
}
|
||||
|
||||
downScale.SetCustomComputeSize( context.internalSize / _downSampling );
|
||||
copy.SetCustomComputeSize( context.internalSize / _downSampling );
|
||||
|
||||
var iteration = 0;
|
||||
var lumaScale = Mathf.Pow( 5f, lumaScale5 );
|
||||
|
||||
var combinedRotation = rotationOffset;
|
||||
|
||||
var tl = TimeLineManager.Ensure( rotationSpeedTimeLine );
|
||||
var animationRotation = MathX.Repeat( tl.position * rotationSpeed / 360, 1f ) * 360f;
|
||||
combinedRotation = MathX.Repeat( animationRotation + combinedRotation, 360f );
|
||||
|
||||
_streaks.ForEach(
|
||||
( s )=>
|
||||
{
|
||||
s.SetCustomComputeSize( context.internalSize / _downSampling );
|
||||
|
||||
s.constants.Set(
|
||||
direction,
|
||||
new Vector2( attenuation, amount ),
|
||||
new Vector2( samples, iteration ),
|
||||
new Vector2( lumaTreshold, lumaScale ),
|
||||
new Vector2( numStreaks, blurRadius ),
|
||||
new Vector2( combinedRotation / 180 * Mathf.Pi, desaturation )
|
||||
);
|
||||
|
||||
iteration++;
|
||||
}
|
||||
);
|
||||
|
||||
upScale.constants.Set(
|
||||
intensity * intensityScale,
|
||||
blurNoise,
|
||||
(float)blurSpread,
|
||||
(float)blurRadius,
|
||||
|
||||
lumaTreshold,
|
||||
lumaScale,
|
||||
0f,
|
||||
0f
|
||||
);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://duvytqqnfwvf6
|
||||
|
|
@ -79,8 +79,8 @@ namespace Rokojori
|
|||
amount,
|
||||
MathX.Repeat( hueShift, 360 ) / 360f, temparatureShift,
|
||||
|
||||
saturationOffset / 100f, Mathf.Pow( 5f, saturationGamma / 100f ),
|
||||
lightnessOffset / 100f, Mathf.Pow( 5f, lightnessGamma / 100f ),
|
||||
( saturationOffset ) / 100f, Mathf.Pow( 5f, saturationGamma / 100f ),
|
||||
( lightnessOffset) / 100f, Mathf.Pow( 5f, lightnessGamma / 100f ),
|
||||
|
||||
(float)(int)hslConversionMode,
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,122 @@
|
|||
|
||||
using Godot;
|
||||
using Godot.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Rokojori
|
||||
{
|
||||
[Tool]
|
||||
[GlobalClass]
|
||||
public partial class ChannelPixelationEffect:RDGraphCompositorEffect
|
||||
{
|
||||
public ChannelPixelationEffect():base()
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
|
||||
[Export( PropertyHint.Range, "0,1") ]
|
||||
public float amount = 0.1f;
|
||||
|
||||
[Export( PropertyHint.Range, "1,2000") ]
|
||||
public int pixelSizeX = 3;
|
||||
|
||||
[Export( PropertyHint.Range, "1,2000") ]
|
||||
public int pixelSizeY = 3;
|
||||
|
||||
[Export( PropertyHint.Range, "0,1") ]
|
||||
public float pixelOffsetX = 0.5f;
|
||||
|
||||
[Export( PropertyHint.Range, "0,1") ]
|
||||
public float pixelOffsetY = 0.5f;
|
||||
|
||||
public enum Channel
|
||||
{
|
||||
Red,
|
||||
Green,
|
||||
Blue,
|
||||
Hue,
|
||||
Saturation,
|
||||
Lightness,
|
||||
RGB
|
||||
}
|
||||
|
||||
[Export]
|
||||
public Channel targetChannel;
|
||||
|
||||
[Export( PropertyHint.Range, "0,1") ]
|
||||
public float noiseAmount = 0.1f;
|
||||
|
||||
[Export( PropertyHint.Range, "0.01,100") ]
|
||||
public float noiseScale = 3;
|
||||
|
||||
[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 );
|
||||
|
||||
|
||||
|
||||
CEG_ScreenColorTexure screenColorTexture;
|
||||
CEG_BufferTexture bufferTexture;
|
||||
|
||||
CEG_Copy copy;
|
||||
RG_ChannelPixelation pixelation;
|
||||
|
||||
void Initialize()
|
||||
{
|
||||
screenColorTexture = new CEG_ScreenColorTexure( graph );
|
||||
bufferTexture = CEG_BufferTexture.ScreenSize( graph );
|
||||
|
||||
copy = new CEG_Copy( graph );
|
||||
pixelation = new RG_ChannelPixelation( graph );
|
||||
graph.InitializeNodes();
|
||||
|
||||
copy.SetTextureSlotInputs( screenColorTexture, bufferTexture );
|
||||
pixelation.SetTextureSlotInputs( copy.output, copy.input );
|
||||
|
||||
|
||||
|
||||
graph.SetProcessOrder(
|
||||
screenColorTexture,
|
||||
bufferTexture,
|
||||
copy,
|
||||
pixelation
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected override void ForAllViews()
|
||||
{
|
||||
var time = TimeLine.osTime;
|
||||
|
||||
pixelation.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
|
||||
),
|
||||
|
||||
(float)pixelSizeX,
|
||||
(float)pixelSizeY,
|
||||
amount,
|
||||
(float)(int)targetChannel,
|
||||
|
||||
noiseAmount,
|
||||
noiseScale,
|
||||
pixelOffsetX,
|
||||
pixelOffsetY
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://lytit04mgc2d
|
||||
|
|
@ -11,7 +11,7 @@ namespace Rokojori
|
|||
{
|
||||
[Tool]
|
||||
[GlobalClass]
|
||||
public partial class TextureDilationCompositerEffect:RDGraphCompositorEffect
|
||||
public abstract partial class TextureDilationCompositerEffect:RDGraphCompositorEffect
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,208 @@
|
|||
|
||||
using Godot;
|
||||
using Godot.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Rokojori
|
||||
{
|
||||
[Tool]
|
||||
[GlobalClass]
|
||||
public partial class TextureOverlayEffect:RDGraphCompositorEffect
|
||||
{
|
||||
public TextureOverlayEffect():base()
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
|
||||
[ExportGroup("All")]
|
||||
[Export( PropertyHint.Range, "0,1")]
|
||||
public float opacity = 1f;
|
||||
|
||||
[Export]
|
||||
public RG_BlendModeType blendMode = RG_BlendModeType.Alpha;
|
||||
|
||||
[ExportGroup("Overlay")]
|
||||
|
||||
[Export]
|
||||
public Texture2D overlayTexture;
|
||||
|
||||
[Export]
|
||||
public Color overlayTint = Colors.White;
|
||||
|
||||
[Export]
|
||||
public ColorSpaceConversion overlayConversion = ColorSpaceConversion.sRGB_to_Linear;
|
||||
|
||||
[Export]
|
||||
public Vector2 tiling = Vector2.One;
|
||||
|
||||
[Export]
|
||||
public Vector2 offset = Vector2.Zero;
|
||||
|
||||
[Export]
|
||||
public Vector2 scrolling = Vector2.Zero;
|
||||
|
||||
[Export]
|
||||
public TimeLine scrollTimeline;
|
||||
|
||||
[Export]
|
||||
public RenderingDevice.SamplerFilter filter = RenderingDevice.SamplerFilter.Linear;
|
||||
|
||||
[Export]
|
||||
public RenderingDevice.SamplerRepeatMode repeatMode = RenderingDevice.SamplerRepeatMode.Repeat;
|
||||
|
||||
[ExportGroup("Mask")]
|
||||
[Export]
|
||||
public Texture2D maskTexture;
|
||||
|
||||
[Export]
|
||||
public ColorSpaceConversion maskOverlayConversion = ColorSpaceConversion.sRGB_to_Linear;
|
||||
|
||||
|
||||
[Export]
|
||||
public Vector2 maskTiling = Vector2.One;
|
||||
|
||||
[Export]
|
||||
public Vector2 maskOffset = Vector2.Zero;
|
||||
|
||||
[Export]
|
||||
public Vector2 maskScrolling = Vector2.Zero;
|
||||
|
||||
[Export]
|
||||
public TimeLine maskScrollTimeline;
|
||||
|
||||
[Export]
|
||||
public RenderingDevice.SamplerFilter maskFilter = RenderingDevice.SamplerFilter.Linear;
|
||||
|
||||
[Export]
|
||||
public RenderingDevice.SamplerRepeatMode maskRepeatMode = RenderingDevice.SamplerRepeatMode.Repeat;
|
||||
|
||||
[ExportGroup("Advanced")]
|
||||
[Export]
|
||||
public ColorSpaceConversion screenConversion = ColorSpaceConversion.No_Conversion;
|
||||
|
||||
[Export]
|
||||
public ColorSpaceConversion outputConversion = ColorSpaceConversion.No_Conversion;
|
||||
|
||||
RG_ImageTexture _topTexture;
|
||||
RG_ImageTexture _maskTexture;
|
||||
CEG_ScreenColorTexure _bottomTexture;
|
||||
CEG_ScreenColorTexure _outputTexture;
|
||||
|
||||
|
||||
List<RG_BlendModeBase> _blendModes;
|
||||
|
||||
RenderingDevice.SamplerFilter assignedfilterTop = RenderingDevice.SamplerFilter.Linear;
|
||||
RenderingDevice.SamplerRepeatMode assignedRepeatModeTop = RenderingDevice.SamplerRepeatMode.Repeat;
|
||||
|
||||
RenderingDevice.SamplerFilter assignedfilterMask = RenderingDevice.SamplerFilter.Linear;
|
||||
RenderingDevice.SamplerRepeatMode assignedRepeatModeMask = RenderingDevice.SamplerRepeatMode.Repeat;
|
||||
|
||||
RG_BlendModeType _assignBlendMode = RG_BlendModeType.Alpha;
|
||||
|
||||
void Initialize()
|
||||
{
|
||||
_topTexture = new RG_ImageTexture( graph );
|
||||
_maskTexture = new RG_ImageTexture( graph );
|
||||
_bottomTexture = new CEG_ScreenColorTexure( graph );
|
||||
_outputTexture = new CEG_ScreenColorTexure( graph );
|
||||
|
||||
_blendModes = RG_BlendModesTool.CreateAll( graph );
|
||||
|
||||
graph.InitializeNodes();
|
||||
|
||||
_blendModes.ForEach(
|
||||
( bm )=>
|
||||
{
|
||||
bm.SetTextureSlotInputs( _topTexture, _maskTexture, _bottomTexture, _outputTexture );
|
||||
|
||||
bm.top.sampler = context.Sampler( assignedfilterTop, assignedRepeatModeTop );
|
||||
bm.mask.sampler = context.Sampler( assignedfilterMask, assignedRepeatModeMask );
|
||||
bm.bottom.sampler = context.Sampler( RenderingDevice.SamplerFilter.Nearest, RenderingDevice.SamplerRepeatMode.ClampToEdge );
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
_assignBlendMode = blendMode;
|
||||
|
||||
graph.SetProcessOrder(
|
||||
_topTexture,
|
||||
_maskTexture,
|
||||
_bottomTexture,
|
||||
_outputTexture,
|
||||
RG_BlendModesTool.GetCurrentBlendMode( _blendModes, _assignBlendMode )
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected override void ForAllViews()
|
||||
{
|
||||
if ( _assignBlendMode != blendMode )
|
||||
{
|
||||
_assignBlendMode = blendMode;
|
||||
|
||||
var nextBlendMode = RG_BlendModesTool.GetCurrentBlendMode( _blendModes, _assignBlendMode );
|
||||
graph.SetProcessOrder(
|
||||
_topTexture,
|
||||
_maskTexture,
|
||||
_bottomTexture,
|
||||
_outputTexture,
|
||||
RG_BlendModesTool.GetCurrentBlendMode( _blendModes, _assignBlendMode )
|
||||
);
|
||||
|
||||
nextBlendMode.top.sampler = context.Sampler( assignedfilterTop, assignedRepeatModeTop );
|
||||
nextBlendMode.mask.sampler = context.Sampler( assignedfilterMask, assignedRepeatModeMask );
|
||||
}
|
||||
|
||||
var currentBlendMode = RG_BlendModesTool.GetCurrentBlendMode( _blendModes, blendMode );
|
||||
|
||||
if ( assignedfilterTop != filter || assignedRepeatModeTop != repeatMode )
|
||||
{
|
||||
assignedfilterTop = filter;
|
||||
assignedRepeatModeTop = repeatMode;
|
||||
|
||||
currentBlendMode.top.sampler = context.Sampler( assignedfilterTop, assignedRepeatModeTop );
|
||||
}
|
||||
|
||||
if ( assignedfilterMask != maskFilter || assignedRepeatModeMask != maskRepeatMode )
|
||||
{
|
||||
assignedfilterMask = maskFilter;
|
||||
assignedRepeatModeMask = maskRepeatMode;
|
||||
|
||||
currentBlendMode.mask.sampler = context.Sampler( assignedfilterMask, assignedRepeatModeMask );
|
||||
}
|
||||
|
||||
_topTexture.SetImageTexture( overlayTexture );
|
||||
_maskTexture.SetImageTexture( maskTexture );
|
||||
|
||||
var timeLine = TimeLineManager.Ensure( scrollTimeline );
|
||||
var scrollPosition = timeLine.position * scrolling;
|
||||
scrollPosition.X = MathX.Repeat( scrollPosition.X, 1.0f );
|
||||
scrollPosition.Y = MathX.Repeat( scrollPosition.Y, 1.0f );
|
||||
|
||||
var timeLineMask = TimeLineManager.Ensure( maskScrollTimeline );
|
||||
var scrollPositionMask = timeLineMask.position * maskScrolling;
|
||||
scrollPositionMask.X = MathX.Repeat( scrollPositionMask.X, 1.0f );
|
||||
scrollPositionMask.Y = MathX.Repeat( scrollPositionMask.Y, 1.0f );
|
||||
|
||||
currentBlendMode.constants.Set(
|
||||
[
|
||||
new Vector4( tiling.X, tiling.Y, offset.X + scrollPosition.X, offset.Y + scrollPosition.Y ),
|
||||
new Vector4( maskTiling.X, maskTiling.Y, maskOffset.X + scrollPositionMask.X, maskOffset.Y + scrollPositionMask.Y ),
|
||||
new Vector4( 1f, 1f, 0f, 0f ),
|
||||
overlayTint,
|
||||
opacity,
|
||||
(float)(int)overlayConversion,
|
||||
(float)(int)maskOverlayConversion,
|
||||
(float)(int)screenConversion,
|
||||
(float)(int)outputConversion,
|
||||
1f
|
||||
]
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://t5g1g1uv5yrj
|
||||
|
|
@ -8,6 +8,10 @@ namespace Rokojori
|
|||
[GlobalClass]
|
||||
public abstract partial class RokojoriCompositorEffect:CompositorEffect
|
||||
{
|
||||
[ExportGroup("Debug")]
|
||||
[Export]
|
||||
public RokojoriCompositorEffectID compositorEffectID;
|
||||
|
||||
[ExportToolButton( "Clear Caches" )]
|
||||
public Callable clearCachesButton => Callable.From( ()=> ClearCaches() );
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,47 @@
|
|||
|
||||
using Godot;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Rokojori
|
||||
{
|
||||
[Tool]
|
||||
[GlobalClass]
|
||||
public partial class SetCompositorEffectsStates:Action
|
||||
{
|
||||
[Export]
|
||||
public CompositorEffectReference[] compositorEffectReferences = [];
|
||||
|
||||
public enum ChangeMode
|
||||
{
|
||||
Set_Enabled,
|
||||
Set_Disabled,
|
||||
Toggle
|
||||
}
|
||||
|
||||
[Export]
|
||||
public ChangeMode mode = ChangeMode.Set_Disabled;
|
||||
|
||||
protected override void _OnTrigger()
|
||||
{
|
||||
if ( compositorEffectReferences == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
compositorEffectReferences.ForEach(
|
||||
( cr )=>
|
||||
{
|
||||
if ( cr == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var c = cr.GetCompositorEffect( this );
|
||||
|
||||
var settingMode = mode == ChangeMode.Toggle ? ! c.Enabled : ( ChangeMode.Set_Enabled == mode );
|
||||
c.Enabled = settingMode;
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://ndhbl08jwmg1
|
||||
|
|
@ -6,7 +6,7 @@ namespace Rokojori
|
|||
{
|
||||
public partial class RDContext
|
||||
{
|
||||
public RDSampler Sampler( RDSamplerState state = null)
|
||||
public RDSampler Sampler( RDSamplerState state )
|
||||
{
|
||||
if ( state == null )
|
||||
{
|
||||
|
|
@ -21,7 +21,7 @@ namespace Rokojori
|
|||
return sampler;
|
||||
}
|
||||
|
||||
public RDSampler Sampler( RenderingDevice.SamplerFilter filter, RenderingDevice.SamplerRepeatMode repeatMode)
|
||||
public RDSampler Sampler( RenderingDevice.SamplerFilter filter = RenderingDevice.SamplerFilter.Linear, RenderingDevice.SamplerRepeatMode repeatMode = RenderingDevice.SamplerRepeatMode.Repeat )
|
||||
{
|
||||
var state = new RDSamplerState();
|
||||
|
||||
|
|
@ -34,5 +34,6 @@ namespace Rokojori
|
|||
return Sampler( state );
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -200,8 +200,17 @@ namespace Rokojori
|
|||
|
||||
public Vector2I computeSize = new Vector2I( 512, 512 );
|
||||
|
||||
public bool useFixedComputeSize = false;
|
||||
|
||||
|
||||
|
||||
public Vector2I GetComputeSize()
|
||||
{
|
||||
if ( useFixedComputeSize )
|
||||
{
|
||||
return computeSize;
|
||||
}
|
||||
|
||||
if ( _sceneBuffers != null )
|
||||
{
|
||||
return _sceneBuffers.GetInternalSize();
|
||||
|
|
|
|||
|
|
@ -11,14 +11,14 @@ namespace Rokojori
|
|||
|
||||
public RDUniformSet( RDContext effect, int setIndex, Rid rid ):base( effect, rid )
|
||||
{
|
||||
_setIndex =setIndex;
|
||||
_setIndex = setIndex;
|
||||
}
|
||||
|
||||
public static RDUniformSet Image( RDContext context, RDTexture texture, int setIndex )
|
||||
public static RDUniformSet Image( RDContext context, RDTexture texture, int setIndex, int binding = 0 )
|
||||
{
|
||||
var uniform = new RDUniform();
|
||||
uniform.UniformType = RenderingDevice.UniformType.Image;
|
||||
uniform.Binding = 0;
|
||||
uniform.Binding = binding;
|
||||
uniform.AddId( texture.rid );
|
||||
|
||||
|
||||
|
|
@ -29,11 +29,11 @@ namespace Rokojori
|
|||
return new RDUniformSet( context, setIndex, rid );
|
||||
}
|
||||
|
||||
public static RDUniformSet Sampler( RDContext context, RDSampler sampler, RDTexture texture, int setIndex )
|
||||
public static RDUniformSet Sampler( RDContext context, RDSampler sampler, RDTexture texture, int setIndex, int binding = 0 )
|
||||
{
|
||||
var uniform = new RDUniform();
|
||||
uniform.UniformType = RenderingDevice.UniformType.SamplerWithTexture;
|
||||
uniform.Binding = 0;
|
||||
uniform.Binding = binding;
|
||||
uniform.AddId( sampler.rid );
|
||||
uniform.AddId( texture.rid ) ;
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,87 @@
|
|||
#[compute]
|
||||
#version 450
|
||||
|
||||
layout( local_size_x = 8, local_size_y = 8, local_size_z = 1 ) in;
|
||||
|
||||
layout( set = 0, binding = 0 )
|
||||
uniform sampler2D depthSampler;
|
||||
|
||||
layout( rgba16f, set = 1, binding = 0 )
|
||||
uniform image2D outputImage;
|
||||
|
||||
|
||||
layout( push_constant, std430 )
|
||||
uniform Parameters
|
||||
{
|
||||
float amount;
|
||||
float edgeThreshold;
|
||||
float edgeIntensity;
|
||||
float blurMix;
|
||||
|
||||
float blurType;
|
||||
float spread;
|
||||
int pad;
|
||||
int pad2;
|
||||
|
||||
} parameters;
|
||||
|
||||
float sampleDepth( ivec2 xy, vec2 pixelSize )
|
||||
{
|
||||
vec2 uv = ( vec2( xy ) + 0.5 ) * pixelSize;
|
||||
return texture( depthSampler, uv ).r;
|
||||
}
|
||||
|
||||
void main( )
|
||||
{
|
||||
ivec2 xy = ivec2( gl_GlobalInvocationID.xy );
|
||||
ivec2 size = imageSize( outputImage );
|
||||
|
||||
if ( xy.x >= size.x || xy.y >= size.y )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
vec2 pixelSize = vec2( 1.0 ) / vec2( size );
|
||||
|
||||
float centerDepth = sampleDepth( xy, pixelSize );
|
||||
|
||||
float topLeft = sampleDepth( xy + ivec2( -1, -1 ), pixelSize );
|
||||
float top = sampleDepth( xy + ivec2( 0, -1 ), pixelSize );
|
||||
float topRight = sampleDepth( xy + ivec2( 1, -1 ), pixelSize );
|
||||
|
||||
float left = sampleDepth( xy + ivec2( -1, 0 ), pixelSize );
|
||||
float right = sampleDepth( xy + ivec2( 1, 0 ), pixelSize );
|
||||
|
||||
float bottomLeft = sampleDepth( xy + ivec2( -1, 1 ), pixelSize );
|
||||
float bottom = sampleDepth( xy + ivec2( 0, 1 ), pixelSize );
|
||||
float bottomRight = sampleDepth( xy + ivec2( 1, 1 ), pixelSize );
|
||||
|
||||
|
||||
float gx = -topLeft - 2.0 * left - bottomLeft + topRight + 2.0 * right + bottomRight;
|
||||
float gy = -topLeft - 2.0 * top - topRight + bottomLeft + 2.0 * bottom + bottomRight;
|
||||
|
||||
|
||||
float edge = length( vec2( gx, gy ) );
|
||||
edge = ( edge - parameters.edgeThreshold ) * parameters.edgeIntensity;
|
||||
edge = clamp( edge, 0.0, 1.0 );
|
||||
|
||||
|
||||
vec4 color = imageLoad( outputImage, xy );
|
||||
|
||||
int spread = int( parameters.spread );
|
||||
vec4 color0 = imageLoad( outputImage, xy + ivec2( -1, 0 ) * spread );
|
||||
vec4 color1 = imageLoad( outputImage, xy + ivec2( 1, 0 ) * spread );
|
||||
|
||||
ivec2 dir2 = int( parameters.blurType ) == 0 ? ivec2( 2, 0 ) : ivec2( 0, 1 );
|
||||
|
||||
vec4 color2 = imageLoad( outputImage, xy - dir2 * spread );
|
||||
vec4 color3 = imageLoad( outputImage, xy + dir2 * spread );
|
||||
|
||||
vec4 blurColor = 0.35 * ( color0 + color1 ) + ( color2 + color3 ) * 0.15;
|
||||
|
||||
vec4 smoothedColor = mix( color, blurColor, parameters.blurMix );
|
||||
|
||||
color.rgb = mix( color.rgb, smoothedColor.rgb, edge * parameters.amount );
|
||||
|
||||
imageStore( outputImage, xy, color );
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
[remap]
|
||||
|
||||
importer="glsl"
|
||||
type="RDShaderFile"
|
||||
uid="uid://d1k1ht3v6vifm"
|
||||
path="res://.godot/imported/DAA.glsl-751e497645ace7b9b9009529d035728d.res"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://addons/rokojori_action_library/Runtime/Rendering/RenderGraph/Nodes/Processors/AntiAliasing/DAA/DAA.glsl"
|
||||
dest_files=["res://.godot/imported/DAA.glsl-751e497645ace7b9b9009529d035728d.res"]
|
||||
|
||||
[params]
|
||||
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
|
||||
using Godot;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Rokojori
|
||||
{
|
||||
public class RG_DAA:CEG_ImageProcessor
|
||||
{
|
||||
|
||||
public static readonly string shaderPath =
|
||||
RDGraph.Path( "Nodes/Processors/AntiAliasing/DAA/DAA.glsl" );
|
||||
|
||||
public RG_DAA( RDGraph graph ):base( graph, shaderPath ){}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://cbfamydf7cioe
|
||||
|
|
@ -0,0 +1,213 @@
|
|||
#[compute]
|
||||
#version 450
|
||||
|
||||
layout( local_size_x = 8, local_size_y = 8, local_size_z = 1 ) in;
|
||||
|
||||
|
||||
layout( set = 0, binding = 0 )
|
||||
uniform sampler2D sourceColor;
|
||||
|
||||
layout( rgba16f, set = 1, binding = 0 )
|
||||
uniform image2D outputImage;
|
||||
|
||||
layout( push_constant, std430 )
|
||||
uniform Parameters
|
||||
{
|
||||
float luminance_multiplier;
|
||||
float exposure;
|
||||
float amount;
|
||||
float pad1;
|
||||
|
||||
} parameters;
|
||||
|
||||
|
||||
float QUALITY( float q )
|
||||
{
|
||||
return ( q < 5 ? 1.0 : ( q > 5 ? ( q < 10 ? 2.0 : ( q < 11 ? 4.0 : 8.0 ) ) : 1.5 ) );
|
||||
}
|
||||
|
||||
float rgb2luma( vec3 rgb )
|
||||
{
|
||||
return sqrt( dot( rgb, vec3( 0.299, 0.587, 0.114 ) ) );
|
||||
}
|
||||
|
||||
vec3 applyFXAA( vec3 color, float exposure, vec2 uv_interp, vec2 pixel_size )
|
||||
{
|
||||
const float EDGE_THRESHOLD_MIN = 0.0312;
|
||||
const float EDGE_THRESHOLD_MAX = 0.125;
|
||||
const int ITERATIONS = 12;
|
||||
const float SUBPIXEL_QUALITY = 0.75;
|
||||
|
||||
float lumaUp = rgb2luma( textureLodOffset( sourceColor, uv_interp, 0.0, ivec2( 0, 1 ) ).xyz * exposure * parameters.luminance_multiplier );
|
||||
float lumaDown = rgb2luma( textureLodOffset( sourceColor, uv_interp, 0.0, ivec2( 0, -1 ) ).xyz * exposure * parameters.luminance_multiplier );
|
||||
float lumaLeft = rgb2luma( textureLodOffset( sourceColor, uv_interp, 0.0, ivec2( -1, 0 ) ).xyz * exposure * parameters.luminance_multiplier );
|
||||
float lumaRight = rgb2luma( textureLodOffset( sourceColor, uv_interp, 0.0, ivec2( 1, 0 ) ).xyz * exposure * parameters.luminance_multiplier );
|
||||
|
||||
float lumaCenter = rgb2luma( color );
|
||||
|
||||
float lumaMin = min( lumaCenter, min( min( lumaUp, lumaDown ), min( lumaLeft, lumaRight ) ) );
|
||||
float lumaMax = max( lumaCenter, max( max( lumaUp, lumaDown ), max( lumaLeft, lumaRight ) ) );
|
||||
|
||||
float lumaRange = lumaMax - lumaMin;
|
||||
|
||||
if ( lumaRange < max( EDGE_THRESHOLD_MIN, lumaMax * EDGE_THRESHOLD_MAX ) )
|
||||
{
|
||||
return color;
|
||||
}
|
||||
|
||||
float lumaDownLeft = rgb2luma( textureLodOffset( sourceColor, uv_interp, 0.0, ivec2( -1, -1 ) ).xyz * exposure * parameters.luminance_multiplier );
|
||||
float lumaUpRight = rgb2luma( textureLodOffset( sourceColor, uv_interp, 0.0, ivec2( 1, 1 ) ).xyz * exposure * parameters.luminance_multiplier );
|
||||
float lumaUpLeft = rgb2luma( textureLodOffset( sourceColor, uv_interp, 0.0, ivec2( -1, 1 ) ).xyz * exposure * parameters.luminance_multiplier );
|
||||
float lumaDownRight = rgb2luma( textureLodOffset( sourceColor, uv_interp, 0.0, ivec2( 1, -1 ) ).xyz * exposure * parameters.luminance_multiplier );
|
||||
|
||||
float lumaDownUp = lumaDown + lumaUp;
|
||||
float lumaLeftRight = lumaLeft + lumaRight;
|
||||
|
||||
float lumaLeftCorners = lumaDownLeft + lumaUpLeft;
|
||||
float lumaDownCorners = lumaDownLeft + lumaDownRight;
|
||||
float lumaRightCorners = lumaDownRight + lumaUpRight;
|
||||
float lumaUpCorners = lumaUpRight + lumaUpLeft;
|
||||
|
||||
float edgeHorizontal = abs( -2.0 * lumaLeft + lumaLeftCorners ) + abs( -2.0 * lumaCenter + lumaDownUp ) * 2.0 + abs( -2.0 * lumaRight + lumaRightCorners );
|
||||
float edgeVertical = abs( -2.0 * lumaUp + lumaUpCorners ) + abs( -2.0 * lumaCenter + lumaLeftRight ) * 2.0 + abs( -2.0 * lumaDown + lumaDownCorners );
|
||||
|
||||
bool isHorizontal = ( edgeHorizontal >= edgeVertical );
|
||||
|
||||
float stepLength = isHorizontal ? pixel_size.y : pixel_size.x;
|
||||
|
||||
float luma1 = isHorizontal ? lumaDown : lumaLeft;
|
||||
float luma2 = isHorizontal ? lumaUp : lumaRight;
|
||||
float gradient1 = luma1 - lumaCenter;
|
||||
float gradient2 = luma2 - lumaCenter;
|
||||
|
||||
bool is1Steepest = abs( gradient1 ) >= abs( gradient2 );
|
||||
|
||||
float gradientScaled = 0.25 * max( abs( gradient1 ), abs( gradient2 ) );
|
||||
|
||||
float lumaLocalAverage = 0.0;
|
||||
if ( is1Steepest ) {
|
||||
stepLength = -stepLength;
|
||||
lumaLocalAverage = 0.5 * ( luma1 + lumaCenter );
|
||||
} else {
|
||||
lumaLocalAverage = 0.5 * ( luma2 + lumaCenter );
|
||||
}
|
||||
|
||||
vec2 currentUv = uv_interp;
|
||||
if ( isHorizontal ) {
|
||||
currentUv.y += stepLength * 0.5;
|
||||
} else {
|
||||
currentUv.x += stepLength * 0.5;
|
||||
}
|
||||
|
||||
vec2 offset = isHorizontal ? vec2( pixel_size.x, 0.0 ) : vec2( 0.0, pixel_size.y );
|
||||
vec2 uv1 = currentUv - offset * QUALITY( 0 );
|
||||
vec2 uv2 = currentUv + offset * QUALITY( 0 );
|
||||
|
||||
float lumaEnd1 = rgb2luma( textureLod( sourceColor, uv1, 0.0 ).xyz * exposure * parameters.luminance_multiplier );
|
||||
float lumaEnd2 = rgb2luma( textureLod( sourceColor, uv2, 0.0 ).xyz * exposure * parameters.luminance_multiplier );
|
||||
lumaEnd1 -= lumaLocalAverage;
|
||||
lumaEnd2 -= lumaLocalAverage;
|
||||
|
||||
bool reached1 = abs( lumaEnd1 ) >= gradientScaled;
|
||||
bool reached2 = abs( lumaEnd2 ) >= gradientScaled;
|
||||
bool reachedBoth = reached1 && reached2;
|
||||
|
||||
if ( !reached1 ) {
|
||||
uv1 -= offset * QUALITY( 1 );
|
||||
}
|
||||
if ( !reached2 ) {
|
||||
uv2 += offset * QUALITY( 1 );
|
||||
}
|
||||
|
||||
if ( !reachedBoth ) {
|
||||
for ( int i = 2; i < ITERATIONS; i++ ) {
|
||||
if ( !reached1 ) {
|
||||
lumaEnd1 = rgb2luma( textureLod( sourceColor, uv1, 0.0 ).xyz * exposure * parameters.luminance_multiplier );
|
||||
lumaEnd1 = lumaEnd1 - lumaLocalAverage;
|
||||
}
|
||||
if ( !reached2 ) {
|
||||
lumaEnd2 = rgb2luma( textureLod( sourceColor, uv2, 0.0 ).xyz * exposure * parameters.luminance_multiplier );
|
||||
lumaEnd2 = lumaEnd2 - lumaLocalAverage;
|
||||
}
|
||||
reached1 = abs( lumaEnd1 ) >= gradientScaled;
|
||||
reached2 = abs( lumaEnd2 ) >= gradientScaled;
|
||||
reachedBoth = reached1 && reached2;
|
||||
if ( !reached1 ) {
|
||||
uv1 -= offset * QUALITY( i );
|
||||
}
|
||||
if ( !reached2 ) {
|
||||
uv2 += offset * QUALITY( i );
|
||||
}
|
||||
if ( reachedBoth ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
float distance1 = isHorizontal ? ( uv_interp.x - uv1.x ) : ( uv_interp.y - uv1.y );
|
||||
float distance2 = isHorizontal ? ( uv2.x - uv_interp.x ) : ( uv2.y - uv_interp.y );
|
||||
|
||||
bool isDirection1 = distance1 < distance2;
|
||||
float distanceFinal = min( distance1, distance2 );
|
||||
|
||||
float edgeThickness = ( distance1 + distance2 );
|
||||
|
||||
bool isLumaCenterSmaller = lumaCenter < lumaLocalAverage;
|
||||
|
||||
bool correctVariation1 = ( lumaEnd1 < 0.0 ) != isLumaCenterSmaller;
|
||||
bool correctVariation2 = ( lumaEnd2 < 0.0 ) != isLumaCenterSmaller;
|
||||
|
||||
bool correctVariation = isDirection1 ? correctVariation1 : correctVariation2;
|
||||
|
||||
float pixelOffset = -distanceFinal / edgeThickness + 0.5;
|
||||
|
||||
float finalOffset = correctVariation ? pixelOffset : 0.0;
|
||||
|
||||
float lumaAverage = ( 1.0 / 12.0 ) * ( 2.0 * ( lumaDownUp + lumaLeftRight ) + lumaLeftCorners + lumaRightCorners );
|
||||
|
||||
float subPixelOffset1 = clamp( abs( lumaAverage - lumaCenter ) / lumaRange, 0.0, 1.0 );
|
||||
float subPixelOffset2 = ( -2.0 * subPixelOffset1 + 3.0 ) * subPixelOffset1 * subPixelOffset1;
|
||||
|
||||
float subPixelOffsetFinal = subPixelOffset2 * subPixelOffset2 * SUBPIXEL_QUALITY;
|
||||
|
||||
finalOffset = max( finalOffset, subPixelOffsetFinal );
|
||||
|
||||
vec2 finalUv = uv_interp;
|
||||
if ( isHorizontal )
|
||||
{
|
||||
finalUv.y += finalOffset * stepLength;
|
||||
}
|
||||
else
|
||||
{
|
||||
finalUv.x += finalOffset * stepLength;
|
||||
}
|
||||
|
||||
vec3 finalColor = textureLod( sourceColor, finalUv, 0.0 ).xyz * exposure * parameters.luminance_multiplier;
|
||||
return finalColor;
|
||||
|
||||
}
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
ivec2 size = imageSize( outputImage );
|
||||
ivec2 xy = ivec2( gl_GlobalInvocationID.xy );
|
||||
|
||||
if ( any( greaterThanEqual( xy, size ) ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
vec2 uv = ( vec2( xy ) + vec2( 0.5 ) ) / vec2( size );
|
||||
|
||||
float exposure = parameters.exposure;
|
||||
|
||||
vec4 color = textureLod( sourceColor, uv, 0 );
|
||||
vec4 original = color;
|
||||
|
||||
color.rgb = applyFXAA( color.rgb, exposure, uv, 1.0 / size );
|
||||
|
||||
color = mix( original, color, parameters.amount );
|
||||
|
||||
imageStore( outputImage, xy, color );
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
[remap]
|
||||
|
||||
importer="glsl"
|
||||
type="RDShaderFile"
|
||||
uid="uid://dl2u3wsehqitk"
|
||||
path="res://.godot/imported/FXAA.glsl-407f27be9c671cc34cba7e9e09b95f3b.res"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://addons/rokojori_action_library/Runtime/Rendering/RenderGraph/Nodes/Processors/AntiAliasing/FXAA/FXAA.glsl"
|
||||
dest_files=["res://.godot/imported/FXAA.glsl-407f27be9c671cc34cba7e9e09b95f3b.res"]
|
||||
|
||||
[params]
|
||||
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
|
||||
using Godot;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Rokojori
|
||||
{
|
||||
public class RG_FXAA:CEG_ImageProcessor
|
||||
{
|
||||
|
||||
public static readonly string shaderPath =
|
||||
RDGraph.Path( "Nodes/Processors/AntiAliasing/FXAA/FXAA.glsl" );
|
||||
|
||||
public RG_FXAA( RDGraph graph ):base( graph, shaderPath )
|
||||
{}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://rhe0n5g2d2ee
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
#[compute]
|
||||
#version 450
|
||||
|
||||
#include "res://addons/rokojori_action_library/Runtime/Shading/Library/Colors.gdshaderinc"
|
||||
|
||||
layout( local_size_x = 8, local_size_y = 8, local_size_z = 1 ) in;
|
||||
|
||||
layout( set = 0, binding = 0 )
|
||||
uniform sampler2D topImage;
|
||||
|
||||
layout( set = 1, binding = 0 )
|
||||
uniform sampler2D maskImage;
|
||||
|
||||
layout( set = 2, binding = 0 )
|
||||
uniform sampler2D bottomImage;
|
||||
|
||||
layout( rgba16f, set = 3, binding = 0 )
|
||||
uniform image2D outputImage;
|
||||
|
||||
|
||||
layout( push_constant, std430 )
|
||||
uniform Parameters
|
||||
{
|
||||
vec4 topTilingOffset;
|
||||
vec4 maskTilingOffset;
|
||||
vec4 bottomTilingOffset;
|
||||
vec4 topTint;
|
||||
|
||||
float opacity;
|
||||
float topColorConversion;
|
||||
float maskColorConversion;
|
||||
float bottomColorConversion;
|
||||
|
||||
float outputColorConversion;
|
||||
float forceOpaqueBottom;
|
||||
float p2;
|
||||
float p3;
|
||||
|
||||
} parameters;
|
||||
|
||||
|
||||
void main( )
|
||||
{
|
||||
ivec2 size = imageSize( outputImage );
|
||||
ivec2 xy = ivec2( gl_GlobalInvocationID.xy );
|
||||
|
||||
if ( any( greaterThanEqual( xy, size ) ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
vec2 uv = ( vec2( xy ) + vec2( 0.5 ) ) / vec2( size );
|
||||
|
||||
vec4 topColor = texture( topImage, uv * parameters.topTilingOffset.xy + parameters.topTilingOffset.zw );
|
||||
vec4 maskColor = texture( maskImage, uv * parameters.maskTilingOffset.xy + parameters.maskTilingOffset.zw );
|
||||
vec4 bottomColor = texture( bottomImage, uv * parameters.bottomTilingOffset.xy + parameters.bottomTilingOffset.zw );
|
||||
|
||||
topColor *= parameters.topTint;
|
||||
|
||||
topColor = colorSpaceConversion( topColor, int( parameters.topColorConversion ) );
|
||||
maskColor = colorSpaceConversion( maskColor, int( parameters.maskColorConversion ) );
|
||||
bottomColor = colorSpaceConversion( bottomColor, int( parameters.bottomColorConversion ) );
|
||||
|
||||
topColor.a *= parameters.opacity * maskColor.r ;
|
||||
|
||||
if ( parameters.forceOpaqueBottom > 0.5 )
|
||||
{
|
||||
bottomColor.a = 1.;
|
||||
}
|
||||
|
||||
vec4 blended = blendMode_alpha( bottomColor, topColor );
|
||||
|
||||
blended = colorSpaceConversion( blended, int( parameters.outputColorConversion ) );
|
||||
|
||||
|
||||
imageStore( outputImage, xy, blended );
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
[remap]
|
||||
|
||||
importer="glsl"
|
||||
type="RDShaderFile"
|
||||
uid="uid://cqrsk43lxoh5l"
|
||||
path="res://.godot/imported/BlendMode_Alpha.glsl-5e1f8702121b27a17fef05a79b94fcf2.res"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://addons/rokojori_action_library/Runtime/Rendering/RenderGraph/Nodes/Processors/Blend/BlendMode_Alpha/BlendMode_Alpha.glsl"
|
||||
dest_files=["res://.godot/imported/BlendMode_Alpha.glsl-5e1f8702121b27a17fef05a79b94fcf2.res"]
|
||||
|
||||
[params]
|
||||
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
|
||||
using Godot;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Rokojori
|
||||
{
|
||||
public class RG_BlendMode_Alpha:RG_BlendModeBase
|
||||
{
|
||||
public static readonly string shaderPath =
|
||||
RDGraph.Path( "Nodes/Processors/Blend/BlendMode_Alpha/BlendMode_Alpha.glsl" );
|
||||
|
||||
public RG_BlendMode_Alpha( RDGraph graph ):base( graph, shaderPath )
|
||||
{}
|
||||
|
||||
public override RG_BlendModeType GetBlendModeType()
|
||||
{
|
||||
return RG_BlendModeType.Alpha;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://b0k8rl3w6f3ad
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
#[compute]
|
||||
#version 450
|
||||
|
||||
#include "res://addons/rokojori_action_library/Runtime/Shading/Library/Colors.gdshaderinc"
|
||||
|
||||
layout( local_size_x = 8, local_size_y = 8, local_size_z = 1 ) in;
|
||||
|
||||
layout( set = 0, binding = 0 )
|
||||
uniform sampler2D topImage;
|
||||
|
||||
layout( set = 1, binding = 0 )
|
||||
uniform sampler2D maskImage;
|
||||
|
||||
layout( set = 2, binding = 0 )
|
||||
uniform sampler2D bottomImage;
|
||||
|
||||
layout( rgba16f, set = 3, binding = 0 )
|
||||
uniform image2D outputImage;
|
||||
|
||||
|
||||
layout( push_constant, std430 )
|
||||
uniform Parameters
|
||||
{
|
||||
vec4 topTilingOffset;
|
||||
vec4 maskTilingOffset;
|
||||
vec4 bottomTilingOffset;
|
||||
vec4 topTint;
|
||||
|
||||
float opacity;
|
||||
float topColorConversion;
|
||||
float maskColorConversion;
|
||||
float bottomColorConversion;
|
||||
|
||||
float outputColorConversion;
|
||||
float forceOpaqueBottom;
|
||||
float p2;
|
||||
float p3;
|
||||
|
||||
} parameters;
|
||||
|
||||
|
||||
void main( )
|
||||
{
|
||||
ivec2 size = imageSize( outputImage );
|
||||
ivec2 xy = ivec2( gl_GlobalInvocationID.xy );
|
||||
|
||||
if ( any( greaterThanEqual( xy, size ) ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
vec2 uv = ( vec2( xy ) + vec2( 0.5 ) ) / vec2( size );
|
||||
|
||||
vec4 topColor = texture( topImage, uv * parameters.topTilingOffset.xy + parameters.topTilingOffset.zw );
|
||||
vec4 maskColor = texture( maskImage, uv * parameters.maskTilingOffset.xy + parameters.maskTilingOffset.zw );
|
||||
vec4 bottomColor = texture( bottomImage, uv * parameters.bottomTilingOffset.xy + parameters.bottomTilingOffset.zw );
|
||||
|
||||
topColor *= parameters.topTint;
|
||||
|
||||
topColor = colorSpaceConversion( topColor, int( parameters.topColorConversion ) );
|
||||
maskColor = colorSpaceConversion( maskColor, int( parameters.maskColorConversion ) );
|
||||
bottomColor = colorSpaceConversion( bottomColor, int( parameters.bottomColorConversion ) );
|
||||
|
||||
topColor.a *= parameters.opacity * maskColor.r ;
|
||||
|
||||
if ( parameters.forceOpaqueBottom > 0.5 )
|
||||
{
|
||||
bottomColor.a = 1.;
|
||||
}
|
||||
|
||||
vec4 blended = blendMode_screen( bottomColor, topColor );
|
||||
|
||||
blended = colorSpaceConversion( blended, int( parameters.outputColorConversion ) );
|
||||
|
||||
|
||||
imageStore( outputImage, xy, blended );
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
[remap]
|
||||
|
||||
importer="glsl"
|
||||
type="RDShaderFile"
|
||||
uid="uid://147wufofqg3a"
|
||||
path="res://.godot/imported/BlendMode_Screen.glsl-9e7cd0e6e54b5625a5f1441c8838248e.res"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://addons/rokojori_action_library/Runtime/Rendering/RenderGraph/Nodes/Processors/Blend/BlendMode_Screen/BlendMode_Screen.glsl"
|
||||
dest_files=["res://.godot/imported/BlendMode_Screen.glsl-9e7cd0e6e54b5625a5f1441c8838248e.res"]
|
||||
|
||||
[params]
|
||||
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
|
||||
using Godot;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Rokojori
|
||||
{
|
||||
public class RG_BlendMode_Screen:RG_BlendModeBase
|
||||
{
|
||||
public static readonly string shaderPath =
|
||||
RDGraph.Path( "Nodes/Processors/Blend/BlendMode_Screen/BlendMode_Screen.glsl" );
|
||||
|
||||
public RG_BlendMode_Screen( RDGraph graph ):base( graph, shaderPath )
|
||||
{}
|
||||
|
||||
public override RG_BlendModeType GetBlendModeType()
|
||||
{
|
||||
return RG_BlendModeType.Screen;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://pdyp5ufyjlsb
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
|
||||
using Godot;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Rokojori
|
||||
{
|
||||
public enum RG_BlendModeType
|
||||
{
|
||||
Alpha,
|
||||
Screen
|
||||
}
|
||||
|
||||
public class RG_BlendModesTool
|
||||
{
|
||||
public static List<RG_BlendModeBase> CreateAll( RDGraph graph )
|
||||
{
|
||||
List<RG_BlendModeBase> blendModes = [
|
||||
new RG_BlendMode_Alpha( graph ),
|
||||
new RG_BlendMode_Screen( graph )
|
||||
];
|
||||
|
||||
|
||||
return blendModes;
|
||||
}
|
||||
|
||||
public static RG_BlendModeBase ByType( RDGraph graph, RG_BlendModeType type )
|
||||
{
|
||||
if ( RG_BlendModeType.Alpha == type )
|
||||
{
|
||||
return new RG_BlendMode_Alpha( graph );
|
||||
}
|
||||
else if ( RG_BlendModeType.Screen == type )
|
||||
{
|
||||
return new RG_BlendMode_Screen( graph );
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static RG_BlendModeBase[] Create( RDGraph graph, params RG_BlendModeType[] types )
|
||||
{
|
||||
return types.Map( t => ByType( graph, t ) );
|
||||
}
|
||||
|
||||
public static RG_BlendModeBase GetCurrentBlendMode( IEnumerable<RG_BlendModeBase> blendModes, RG_BlendModeType type )
|
||||
{
|
||||
foreach ( var bm in blendModes )
|
||||
{
|
||||
if ( bm.GetBlendModeType() == type )
|
||||
{
|
||||
return bm;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://b56rouvuui3o1
|
||||
|
|
@ -0,0 +1,92 @@
|
|||
#[compute]
|
||||
#version 450
|
||||
|
||||
#include "res://addons/rokojori_action_library/Runtime/Shading/Library/Colors.gdshaderinc"
|
||||
|
||||
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( set = 2, binding = 0 )
|
||||
uniform sampler2D curves;
|
||||
|
||||
|
||||
layout( push_constant, std430 )
|
||||
uniform Parameters
|
||||
{
|
||||
float amount;
|
||||
float driverChannel;
|
||||
float targetChannel;
|
||||
float pad;
|
||||
|
||||
float p0;
|
||||
float p1;
|
||||
float p2;
|
||||
float p3;
|
||||
|
||||
} parameters;
|
||||
|
||||
|
||||
void main( )
|
||||
{
|
||||
ivec2 size = imageSize( inputImage );
|
||||
ivec2 xy = ivec2( gl_GlobalInvocationID.xy );
|
||||
|
||||
if ( any( greaterThanEqual( xy, size ) ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
vec2 uv = ( vec2( xy ) + 0.5 ) / vec2( size );
|
||||
|
||||
vec4 color = imageLoad( inputImage, ivec2( uv * size ) );
|
||||
|
||||
vec4 processedColor = color;
|
||||
float scale = getRGBScale( color );
|
||||
|
||||
int driver = int( round( parameters.driverChannel ) );
|
||||
int target = int( round( parameters.targetChannel ) );
|
||||
|
||||
bool driverIsHSL = false;
|
||||
|
||||
vec4 driverColor = color;
|
||||
|
||||
if ( driver >= 3 )
|
||||
{
|
||||
driver -= 3;
|
||||
driverColor = RGBtoHSL( color, scale );
|
||||
driverIsHSL = true;
|
||||
}
|
||||
|
||||
float driverValue = getRGBByIndex( driverColor.rgb, driver );
|
||||
|
||||
float offset = texture( curves, vec2( driverValue, 0 ) ).r * 2.0 - 1.0;
|
||||
|
||||
if ( target >= 3 )
|
||||
{
|
||||
processedColor = RGBtoHSL( color, scale );
|
||||
|
||||
if ( target == 6 )
|
||||
{
|
||||
processedColor.r = changeTemparature( processedColor.r, offset, 30 );
|
||||
}
|
||||
else
|
||||
{
|
||||
processedColor.rgb = changeRGBByIndex( processedColor.rgb, target - 3, offset );
|
||||
}
|
||||
|
||||
processedColor = HSLtoRGB( processedColor, scale );
|
||||
}
|
||||
else
|
||||
{
|
||||
processedColor.rgb = changeRGBByIndex( processedColor.rgb, target, offset );
|
||||
}
|
||||
|
||||
|
||||
vec4 blended = mix( color, processedColor, parameters.amount );
|
||||
|
||||
imageStore( outputImage, xy, blended );
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
[remap]
|
||||
|
||||
importer="glsl"
|
||||
type="RDShaderFile"
|
||||
uid="uid://qvwo2mkhower"
|
||||
path="res://.godot/imported/CrossChannelCurves.glsl-7e2d0ae8aca9253afb53652696608856.res"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://addons/rokojori_action_library/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/CrossChannelCurves/CrossChannelCurves.glsl"
|
||||
dest_files=["res://.godot/imported/CrossChannelCurves.glsl-7e2d0ae8aca9253afb53652696608856.res"]
|
||||
|
||||
[params]
|
||||
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
|
||||
using Godot;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Rokojori
|
||||
{
|
||||
public class RG_CrossChannelCurves:CEG_ImageProcessor
|
||||
{
|
||||
public readonly CompositorEffectGraphTextureSlot curves;
|
||||
|
||||
public static readonly string shaderPath =
|
||||
RDGraph.Path( "Nodes/Processors/Color/CrossChannelCurves/CrossChannelCurves.glsl" );
|
||||
|
||||
public RG_CrossChannelCurves( RDGraph graph ):base( graph, shaderPath )
|
||||
{
|
||||
curves = new CompositorEffectGraphTextureSlot( this );
|
||||
|
||||
_textureSlots.Add( curves );
|
||||
}
|
||||
|
||||
public void SetCurvesTextureSlotInputs( RDGraphTextureSlotInput curvesSlotInput )
|
||||
{
|
||||
curvesSlotInput.ConnectTo( curves );
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://bltsv5s6r2rm6
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue