RD Compositor/Context/Graph Rewrite

This commit is contained in:
Josef 2025-04-26 22:04:11 +02:00
parent 748ea8ac84
commit f2a0901146
125 changed files with 867 additions and 907 deletions

View File

@ -10,10 +10,7 @@ namespace Rokojori
[GlobalClass] [GlobalClass]
public partial class AlphaGrabTestEffect:SingleShaderCompositorEffect public partial class AlphaGrabTestEffect:SingleShaderCompositorEffect
{ {
public static readonly string shaderPath = public static readonly string shaderPath = Path( "AlphaGrabTest/AlphaGrabTestShader.glsl" );
RokojoriPlugin.Path( "Runtime/Rendering/CompositorEffects/AlphaGrabTest/AlphaGrabTestShader.glsl" );
protected override void OnConfigure() protected override void OnConfigure()
{ {
@ -29,12 +26,13 @@ namespace Rokojori
byte[] _data; byte[] _data;
bool _ready = false; bool _ready = false;
bool _canDraw = true; bool _canDraw = true;
public async Task<Texture2D> GetImageTexture( System.Func<Task> waiter ) public async Task<Texture2D> GetImageTexture( System.Func<Task> waiter )
{ {
var fmt = _bufferTexture.format; var fmt = _bufferTexture.format;
var imgF = Image.Format.Rgbah; var imgF = Image.Format.Rgbah;
var data = _rd.TextureGetData( _bufferTexture.rid, 0 ); var data = context.renderingDevice.TextureGetData( _bufferTexture.rid, 0 );
var image = Image.CreateFromData( (int) fmt.Width, (int)fmt.Height, false, imgF, data ); var image = Image.CreateFromData( (int) fmt.Width, (int)fmt.Height, false, imgF, data );
return ImageTexture.CreateFromImage( image ); return ImageTexture.CreateFromImage( image );
@ -54,8 +52,8 @@ namespace Rokojori
protected override void RenderView() protected override void RenderView()
{ {
_bufferTexture = RDTexture.EnsureScreenSizeTexture( _bufferTexture, this ); _bufferTexture = RDTexture.EnsureScreenSizeTexture( _bufferTexture, context );
_copyTexture = RDTexture.EnsureScreenSizeTexture( _copyTexture, this ); _copyTexture = RDTexture.EnsureScreenSizeTexture( _copyTexture, context );
context.AssignScreenColorTexture(); context.AssignScreenColorTexture();
context.AssignTexture( _bufferTexture ); context.AssignTexture( _bufferTexture );
@ -63,7 +61,7 @@ namespace Rokojori
// context.pushConstants = constants; // context.pushConstants = constants;
context.Render(); context.ProcessComputeProgram();
} }
} }

View File

@ -0,0 +1,14 @@
[remap]
importer="glsl"
type="RDShaderFile"
uid="uid://b0sbxsqka4svp"
path="res://.godot/imported/AlphaGrabTestShader.glsl-5702cdc3b0621155b6f7f01fc32fd0e7.res"
[deps]
source_file="res://addons/rokojori_action_library/Runtime/Rendering/Compositor/CompositorEffects/AlphaGrabTest/AlphaGrabTestShader.glsl"
dest_files=["res://.godot/imported/AlphaGrabTestShader.glsl-5702cdc3b0621155b6f7f01fc32fd0e7.res"]
[params]

View File

@ -64,7 +64,7 @@ namespace Rokojori
RJLog.Log( "Initializing succeed, loading shader" ); RJLog.Log( "Initializing succeed, loading shader" );
//Make sure this is correctly pointing to the GLSL file //Make sure this is correctly pointing to the GLSL file
RDShaderFile glslFile = ( RDShaderFile ) GD.Load( "res://addons/rokojori_action_library/Runtime/Rendering/CompositorEffects/Blur/BlurEffect.glsl" ); RDShaderFile glslFile = ( RDShaderFile ) GD.Load( RokojoriCompositorEffect.Path( "Blur/BlurEffect.glsl" ) );
shader = rd.ShaderCreateFromSpirV( glslFile.GetSpirV() ); shader = rd.ShaderCreateFromSpirV( glslFile.GetSpirV() );
pipeline = rd.ComputePipelineCreate( shader ); pipeline = rd.ComputePipelineCreate( shader );

View File

@ -0,0 +1,14 @@
[remap]
importer="glsl"
type="RDShaderFile"
uid="uid://b7s44e3k68axi"
path="res://.godot/imported/BlurEffect.glsl-2976c2aaa6ede28da3481e2bef2cf488.res"
[deps]
source_file="res://addons/rokojori_action_library/Runtime/Rendering/Compositor/CompositorEffects/Blur/BlurEffect.glsl"
dest_files=["res://.godot/imported/BlurEffect.glsl-2976c2aaa6ede28da3481e2bef2cf488.res"]
[params]

View File

@ -9,9 +9,7 @@ namespace Rokojori
[GlobalClass] [GlobalClass]
public partial class DepthAntiAliasingEffect:SingleShaderCompositorEffect public partial class DepthAntiAliasingEffect:SingleShaderCompositorEffect
{ {
public static readonly string shaderPath = public static readonly string shaderPath = Path( "DepthAntiAliasing/DepthAntiAliasingShader.glsl" );
RokojoriPlugin.Path( "Runtime/Rendering/CompositorEffects/DepthAntiAliasing/DepthAntiAliasingShader.glsl" );
RDSampler sampler; RDSampler sampler;
@ -50,7 +48,7 @@ namespace Rokojori
{ {
base.OnInitialize(); base.OnInitialize();
sampler = Sampler( RenderingDevice.SamplerFilter.Nearest, RenderingDevice.SamplerRepeatMode.ClampToEdge ); sampler = context.Sampler( RenderingDevice.SamplerFilter.Nearest, RenderingDevice.SamplerRepeatMode.ClampToEdge );
} }
@ -76,7 +74,7 @@ namespace Rokojori
context.pushConstants = constants; context.pushConstants = constants;
context.Render(); context.ProcessComputeProgram();
} }
} }

View File

@ -3,12 +3,12 @@
importer="glsl" importer="glsl"
type="RDShaderFile" type="RDShaderFile"
uid="uid://us4n0un8oo2v" uid="uid://us4n0un8oo2v"
path="res://.godot/imported/DepthAntiAliasingShader.glsl-ea5a9a21bccd9baeec39a54eb65d5afd.res" path="res://.godot/imported/DepthAntiAliasingShader.glsl-51ad5443a76812922ed37cac7bc9291d.res"
[deps] [deps]
source_file="res://addons/rokojori_action_library/Runtime/Rendering/CompositorEffects/DepthAntiAliasing/DepthAntiAliasingShader.glsl" source_file="res://addons/rokojori_action_library/Runtime/Rendering/Compositor/CompositorEffects/DepthAntiAliasing/DepthAntiAliasingShader.glsl"
dest_files=["res://.godot/imported/DepthAntiAliasingShader.glsl-ea5a9a21bccd9baeec39a54eb65d5afd.res"] dest_files=["res://.godot/imported/DepthAntiAliasingShader.glsl-51ad5443a76812922ed37cac7bc9291d.res"]
[params] [params]

View File

@ -9,11 +9,8 @@ namespace Rokojori
[GlobalClass] [GlobalClass]
public partial class DepthViewEffect:SingleShaderCompositorEffect public partial class DepthViewEffect:SingleShaderCompositorEffect
{ {
public static readonly string shaderPath = public static readonly string shaderPath = Path( "DepthView/DepthViewShader.glsl" );
RokojoriPlugin.Path( "Runtime/Rendering/CompositorEffects/DepthView/DepthViewShader.glsl" );
RDPushConstants constants = new RDPushConstants();
RDSampler sampler; RDSampler sampler;
[Export( PropertyHint.Range, "0,1") ] [Export( PropertyHint.Range, "0,1") ]
@ -36,7 +33,7 @@ namespace Rokojori
{ {
base.OnInitialize(); base.OnInitialize();
sampler = Sampler( RenderingDevice.SamplerFilter.Nearest, RenderingDevice.SamplerRepeatMode.ClampToEdge ); sampler = context.Sampler( RenderingDevice.SamplerFilter.Nearest, RenderingDevice.SamplerRepeatMode.ClampToEdge );
} }
protected override void SetConstants() protected override void SetConstants()
@ -55,7 +52,7 @@ namespace Rokojori
context.pushConstants = constants; context.pushConstants = constants;
context.Render(); context.ProcessComputeProgram();
} }
} }

View File

@ -0,0 +1,14 @@
[remap]
importer="glsl"
type="RDShaderFile"
uid="uid://ccufacegh2n8s"
path="res://.godot/imported/DepthViewShader.glsl-d09858ccee0b4cebdfc21e9d288c8d06.res"
[deps]
source_file="res://addons/rokojori_action_library/Runtime/Rendering/Compositor/CompositorEffects/DepthView/DepthViewShader.glsl"
dest_files=["res://.godot/imported/DepthViewShader.glsl-d09858ccee0b4cebdfc21e9d288c8d06.res"]
[params]

View File

@ -0,0 +1,14 @@
[remap]
importer="glsl"
type="RDShaderFile"
uid="uid://biw2n3t4ci7t"
path="res://.godot/imported/GrayScaleShader.glsl-0a4b79670c58543930a6cf627ff753f4.res"
[deps]
source_file="res://addons/rokojori_action_library/Runtime/Rendering/Compositor/CompositorEffects/GreyScale/GrayScaleShader.glsl"
dest_files=["res://.godot/imported/GrayScaleShader.glsl-0a4b79670c58543930a6cf627ff753f4.res"]
[params]

View File

@ -9,8 +9,7 @@ namespace Rokojori
[GlobalClass] [GlobalClass]
public partial class GreyScaleEffect:SingleShaderCompositorEffect public partial class GreyScaleEffect:SingleShaderCompositorEffect
{ {
public static readonly string shaderPath = public static readonly string shaderPath = Path( "GreyScale/GrayScaleShader.glsl" );
RokojoriPlugin.Path( "Runtime/Rendering/CompositorEffects/GreyScale/GrayScaleShader.glsl" );
protected override void OnConfigure() protected override void OnConfigure()
@ -34,7 +33,7 @@ namespace Rokojori
context.pushConstants = constants; context.pushConstants = constants;
context.Render(); context.ProcessComputeProgram();
} }
} }

View File

@ -9,8 +9,7 @@ namespace Rokojori
[GlobalClass] [GlobalClass]
public partial class PixelationEffect:SingleShaderCompositorEffect public partial class PixelationEffect:SingleShaderCompositorEffect
{ {
public static readonly string shaderPath = public static readonly string shaderPath = Path( "Pixelation/PixelationShader.glsl" );
RokojoriPlugin.Path( "Runtime/Rendering/CompositorEffects/Pixelation/PixelationShader.glsl" );
[Export] [Export]
public float pixelSize = 1f; public float pixelSize = 1f;
@ -39,7 +38,7 @@ namespace Rokojori
context.pushConstants = constants; context.pushConstants = constants;
context.Render(); context.ProcessComputeProgram();
} }
} }

View File

@ -0,0 +1,14 @@
[remap]
importer="glsl"
type="RDShaderFile"
uid="uid://ghbawysn1d3c"
path="res://.godot/imported/PixelationShader.glsl-927856b0a13769ea6d6a031cc7878cd6.res"
[deps]
source_file="res://addons/rokojori_action_library/Runtime/Rendering/Compositor/CompositorEffects/Pixelation/PixelationShader.glsl"
dest_files=["res://.godot/imported/PixelationShader.glsl-927856b0a13769ea6d6a031cc7878cd6.res"]
[params]

View File

@ -9,8 +9,7 @@ namespace Rokojori
[GlobalClass] [GlobalClass]
public partial class RadialBlurEffect:SingleShaderCompositorEffect public partial class RadialBlurEffect:SingleShaderCompositorEffect
{ {
public static readonly string shaderPath = public static readonly string shaderPath = Path( "RadialBlur/RadialBlurShader.glsl" );
RokojoriPlugin.Path( "Runtime/Rendering/CompositorEffects/RadialBlur/RadialBlurShader.glsl" );
[Export] [Export]
public Vector2 center = new Vector2( 0.5f, 0.5f ); public Vector2 center = new Vector2( 0.5f, 0.5f );
@ -49,7 +48,7 @@ namespace Rokojori
context.pushConstants = constants; context.pushConstants = constants;
context.Render(); context.ProcessComputeProgram();
} }
} }

View File

@ -0,0 +1,14 @@
[remap]
importer="glsl"
type="RDShaderFile"
uid="uid://yioccj34hlex"
path="res://.godot/imported/RadialBlurShader.glsl-2f269c12bf2dd3e246c931195b015d45.res"
[deps]
source_file="res://addons/rokojori_action_library/Runtime/Rendering/Compositor/CompositorEffects/RadialBlur/RadialBlurShader.glsl"
dest_files=["res://.godot/imported/RadialBlurShader.glsl-2f269c12bf2dd3e246c931195b015d45.res"]
[params]

View File

@ -7,9 +7,9 @@ namespace Rokojori
{ {
[Tool] [Tool]
[GlobalClass] [GlobalClass]
public partial class RadialBlur2:_XX_CompositorEffectGraph public partial class RadialBlur2:RDGraphCompositorEffect
{ {
public RadialBlur2() public RadialBlur2():base()
{ {
Initialize(); Initialize();
} }
@ -31,41 +31,33 @@ namespace Rokojori
CEG_BufferTexture bufferTexture; CEG_BufferTexture bufferTexture;
CEG_Copy copy; CEG_Copy copy;
CEG_RadialBlur radialBlur; CEG_RadialBlur radialBlur;
void Initialize() void Initialize()
{ {
CreateGraphNodes(); screenColorTexture = new CEG_ScreenColorTexure( graph );
ConnectGraph(); bufferTexture = CEG_BufferTexture.ScreenSize( graph );
AssignData();
}
void CreateGraphNodes() copy = new CEG_Copy( graph );
{ radialBlur = new CEG_RadialBlur( graph );
screenColorTexture = new CEG_ScreenColorTexure( this );
bufferTexture = CEG_BufferTexture.ScreenSize( this );
copy = new CEG_Copy( this );
radialBlur = new CEG_RadialBlur( this );
_processors = new List<CompositorEffectGraphProcessor>{ screenColorTexture, bufferTexture, copy, radialBlur }; graph.InitializeNodes();
_processors.ForEach( p => p.Initialize() );
}
void ConnectGraph()
{
copy.SetTextureSlotInputs( screenColorTexture, bufferTexture ); copy.SetTextureSlotInputs( screenColorTexture, bufferTexture );
radialBlur.SetTextureSlotInputs( copy.output, copy.input ); radialBlur.SetTextureSlotInputs( copy.output, copy.input );
SetProcessOrder( graph.SetProcessOrder(
screenColorTexture, bufferTexture, screenColorTexture, bufferTexture,
copy, radialBlur copy, radialBlur
); );
} }
void AssignData()
protected override void ForAllViews()
{ {
radialBlur.constants.Set( radialBlur.constants.Set(
center, center,
@ -76,10 +68,6 @@ namespace Rokojori
); );
} }
protected override void OnPreProcess()
{
AssignData();
}
} }
} }

View File

@ -0,0 +1,14 @@
[remap]
importer="glsl"
type="RDShaderFile"
uid="uid://cd1ysd752pjrn"
path="res://.godot/imported/TemporalSmear.glsl-9560df032a34c0eac9345bfb92a4fe20.res"
[deps]
source_file="res://addons/rokojori_action_library/Runtime/Rendering/Compositor/CompositorEffects/TemporalSmear/TemporalSmear.glsl"
dest_files=["res://.godot/imported/TemporalSmear.glsl-9560df032a34c0eac9345bfb92a4fe20.res"]
[params]

View File

@ -9,8 +9,7 @@ namespace Rokojori
[GlobalClass] [GlobalClass]
public partial class TemporalSmearEffect:SingleShaderCompositorEffect public partial class TemporalSmearEffect:SingleShaderCompositorEffect
{ {
public static readonly string shaderPath = public static readonly string shaderPath = Path( "TemporalSmear/TemporalSmear.glsl" );
RokojoriPlugin.Path( "Runtime/Rendering/CompositorEffects/TemporalSmear/TemporalSmear.glsl" );
[Export( PropertyHint.Range, "0,1")] [Export( PropertyHint.Range, "0,1")]
public float amount = 1f; public float amount = 1f;
@ -58,7 +57,7 @@ namespace Rokojori
protected override void RenderView() protected override void RenderView()
{ {
_bufferTexture = RDTexture.EnsureScreenSizeTexture( _bufferTexture, this ); _bufferTexture = RDTexture.EnsureScreenSizeTexture( _bufferTexture, context );
context.AssignTexture( _bufferTexture ); context.AssignTexture( _bufferTexture );
context.AssignScreenColorTexture(); context.AssignScreenColorTexture();
@ -66,7 +65,7 @@ namespace Rokojori
context.pushConstants = constants; context.pushConstants = constants;
context.Render(); context.ProcessComputeProgram();
} }
} }

View File

@ -0,0 +1,14 @@
[remap]
importer="glsl"
type="RDShaderFile"
uid="uid://b281d2ovcc1wm"
path="res://.godot/imported/Copy.glsl-691649f2edc1532cdaf82fe24cf0a825.res"
[deps]
source_file="res://addons/rokojori_action_library/Runtime/Rendering/Compositor/CompositorEffects/TextureDilation/Copy.glsl"
dest_files=["res://.godot/imported/Copy.glsl-691649f2edc1532cdaf82fe24cf0a825.res"]
[params]

View File

@ -0,0 +1,14 @@
[remap]
importer="glsl"
type="RDShaderFile"
uid="uid://fjarrr31htov"
path="res://.godot/imported/JFA_Assign.glsl-60af4dba5fb8c409e694413cad0c1fc1.res"
[deps]
source_file="res://addons/rokojori_action_library/Runtime/Rendering/Compositor/CompositorEffects/TextureDilation/JFA_Assign.glsl"
dest_files=["res://.godot/imported/JFA_Assign.glsl-60af4dba5fb8c409e694413cad0c1fc1.res"]
[params]

View File

@ -0,0 +1,14 @@
[remap]
importer="glsl"
type="RDShaderFile"
uid="uid://eqgl8l1lmgrl"
path="res://.godot/imported/JFA_Initialize.glsl-eaec1fd1e6da355b3a37aafdebae382c.res"
[deps]
source_file="res://addons/rokojori_action_library/Runtime/Rendering/Compositor/CompositorEffects/TextureDilation/JFA_Initialize.glsl"
dest_files=["res://.godot/imported/JFA_Initialize.glsl-eaec1fd1e6da355b3a37aafdebae382c.res"]
[params]

View File

@ -0,0 +1,14 @@
[remap]
importer="glsl"
type="RDShaderFile"
uid="uid://b263k73iy5pbl"
path="res://.godot/imported/JFA_Step.glsl-f98466c4d4be76f4e3f5470b1ad291a6.res"
[deps]
source_file="res://addons/rokojori_action_library/Runtime/Rendering/Compositor/CompositorEffects/TextureDilation/JFA_Step.glsl"
dest_files=["res://.godot/imported/JFA_Step.glsl-f98466c4d4be76f4e3f5470b1ad291a6.res"]
[params]

View File

@ -0,0 +1,19 @@
using System.Diagnostics;
using System.Collections;
using System.Collections.Generic;
using System;
using Godot;
namespace Rokojori
{
[Tool]
[GlobalClass]
public partial class TextureDilationCompositerEffect:RDGraphCompositorEffect
{
}
}

View File

@ -0,0 +1,26 @@
using Godot;
using System.Collections.Generic;
namespace Rokojori
{
[Tool]
[GlobalClass]
public partial class RDGraphCompositorEffect:RokojoriCompositorEffect
{
protected RDGraph _graph;
public RDGraph graph => _graph;
protected override void OnInitialize()
{
_graph = new RDGraph( context );
}
protected override void RenderView()
{
_graph.ProcessForView();
}
}
}

View File

@ -0,0 +1 @@
uid://c14vrtrstrhi8

View File

@ -0,0 +1,130 @@
using Godot;
using System.Collections.Generic;
namespace Rokojori
{
[Tool]
[GlobalClass]
public partial class RokojoriCompositorEffect:CompositorEffect
{
public static readonly string effectsPath = "res://addons/rokojori_action_library/Runtime/Rendering/Compositor/CompositorEffects";
public static string Path( string path )
{
return effectsPath + "/" + path;
}
RDContext _context;
public RDContext context => _context;
protected virtual void OnConfigure(){}
protected virtual void OnInitialize(){}
protected virtual void ForAllViews(){}
protected virtual void RenderView(){}
public RokojoriCompositorEffect():base()
{
RenderingServer.CallOnRenderThread( Callable.From( _InitializeCompositorEffect ) );
}
protected void _InitializeCompositorEffect()
{
OnConfigure();
_context = new RDContext();
_context.Initialize();
OnInitialize();
}
bool _hasError = false;
public override void _RenderCallback( int effectCallbackType, RenderData renderData )
{
if ( _hasError || context.HasError() )
{
this.LogInfo( context.messages );
return;
}
context.messages.Clear();
try
{
if ( context.renderingDevice == null )
{
context.Error( "No render device" );
return;
}
var sceneBuffers = ( RenderSceneBuffersRD ) renderData.GetRenderSceneBuffers();
var sceneData = ( RenderSceneDataRD ) renderData.GetRenderSceneData();
if ( sceneBuffers == null && sceneData == null )
{
context.Error( "sceneBuffers == null && sceneData == null" );
return;
}
var size = sceneBuffers.GetInternalSize();
if ( size.X == 0 || size.Y == 0 )
{
context.Warning( "InternalSize.X == 0 || InternalSize.Y == 0" );
return;
}
_context.SetRenderData( renderData, sceneBuffers, sceneData );
_context.SetView( -1 );
ForAllViews();
int viewCount = ( int ) sceneBuffers.GetViewCount();
for ( int i = 0; i < viewCount; i++ )
{
_context.SetView( i );
RenderView();
}
}
catch( System.Exception e )
{
this.LogError( e );
_hasError = true;
}
if ( context.HasError() )
{
_hasError = true;
}
}
public override void _Notification( int what )
{
var _shader = context.shader;
context.Verbose( "Got notification: ", what );
if ( what != NotificationPredelete || ( _shader == null || !_shader.valid ) || context.renderingDevice == null )
{
context.Verbose(
"what != NotificationPredelete", what != NotificationPredelete,
"( _shader == null || !_shader.valid )", ( _shader == null || !_shader.valid ),
"rd == null", context.renderingDevice == null
);
return;
}
context.Free( _shader, "Shader" );
context.CleanUp();
}
}
}

View File

@ -16,11 +16,11 @@ namespace Rokojori
protected override void OnInitialize() protected override void OnInitialize()
{ {
Verbose( "Trying to load shader: ", _shaderPath ); context.Verbose( "Trying to load shader: ", _shaderPath );
if ( _shaderPath == null ) if ( _shaderPath == null )
{ {
Error( "_shaderPath == null" ); context.Error( "_shaderPath == null" );
return; return;
} }
@ -28,27 +28,27 @@ namespace Rokojori
if ( glslFile == null ) if ( glslFile == null )
{ {
Error( "Couldn't load shader at path:", _shaderPath ); context.Error( "Couldn't load shader at path:", _shaderPath );
return; return;
} }
_shader = RDShader.CreateFromSpirV( this, glslFile.GetSpirV() ); _shader = RDShader.CreateFromSpirV( context, glslFile.GetSpirV() );
if ( _shader == null ) if ( _shader == null )
{ {
Error( "Couldn't create shader from code, path:", _shaderPath ); context.Error( "Couldn't create shader from code, path:", _shaderPath );
return; return;
} }
_pipeline = RDPipeline.Create( this, _shader ); _pipeline = RDPipeline.Create( context, _shader );
if ( _shader == null ) if ( _shader == null )
{ {
Error( "Couldn't create pipeline from compiled shader, path:", _shaderPath ); context.Error( "Couldn't create pipeline from compiled shader, path:", _shaderPath );
return; return;
} }
Verbose( "Created shader at path: ", _shaderPath ); context.Verbose( "Created shader at path: ", _shaderPath );
context.SetShaderAndPipeline( _shader, _pipeline ); context.SetShaderAndPipeline( _shader, _pipeline );
} }
@ -58,7 +58,7 @@ namespace Rokojori
protected override void ForAllViews() protected override void ForAllViews()
{ {
context.ComputeGroups( _groupSize ); context.CalculateComputeGroups( _groupSize );
SetConstants(); SetConstants();
} }

View File

@ -1,14 +0,0 @@
[remap]
importer="glsl"
type="RDShaderFile"
uid="uid://b0sbxsqka4svp"
path="res://.godot/imported/AlphaGrabTestShader.glsl-6c0893a67e5a07d0f4ca62efdf6123e9.res"
[deps]
source_file="res://addons/rokojori_action_library/Runtime/Rendering/CompositorEffects/AlphaGrabTest/AlphaGrabTestShader.glsl"
dest_files=["res://.godot/imported/AlphaGrabTestShader.glsl-6c0893a67e5a07d0f4ca62efdf6123e9.res"]
[params]

View File

@ -1,14 +0,0 @@
[remap]
importer="glsl"
type="RDShaderFile"
uid="uid://b7s44e3k68axi"
path="res://.godot/imported/BlurEffect.glsl-adc1ff46efeaf20c40c851da38f62fae.res"
[deps]
source_file="res://addons/rokojori_action_library/Runtime/Rendering/CompositorEffects/Blur/BlurEffect.glsl"
dest_files=["res://.godot/imported/BlurEffect.glsl-adc1ff46efeaf20c40c851da38f62fae.res"]
[params]

View File

@ -1,14 +0,0 @@
[remap]
importer="glsl"
type="RDShaderFile"
uid="uid://ccufacegh2n8s"
path="res://.godot/imported/DepthViewShader.glsl-c19eff884d9bff6ff641a138482426b5.res"
[deps]
source_file="res://addons/rokojori_action_library/Runtime/Rendering/CompositorEffects/DepthView/DepthViewShader.glsl"
dest_files=["res://.godot/imported/DepthViewShader.glsl-c19eff884d9bff6ff641a138482426b5.res"]
[params]

View File

@ -1,14 +0,0 @@
[remap]
importer="glsl"
type="RDShaderFile"
uid="uid://biw2n3t4ci7t"
path="res://.godot/imported/GrayScaleShader.glsl-89be3b50af0d77c6515222d93b33ffb3.res"
[deps]
source_file="res://addons/rokojori_action_library/Runtime/Rendering/CompositorEffects/GreyScale/GrayScaleShader.glsl"
dest_files=["res://.godot/imported/GrayScaleShader.glsl-89be3b50af0d77c6515222d93b33ffb3.res"]
[params]

View File

@ -1,14 +0,0 @@
[remap]
importer="glsl"
type="RDShaderFile"
uid="uid://ghbawysn1d3c"
path="res://.godot/imported/PixelationShader.glsl-7bf34134c1434ce83105711f1252021f.res"
[deps]
source_file="res://addons/rokojori_action_library/Runtime/Rendering/CompositorEffects/Pixelation/PixelationShader.glsl"
dest_files=["res://.godot/imported/PixelationShader.glsl-7bf34134c1434ce83105711f1252021f.res"]
[params]

View File

@ -1,14 +0,0 @@
[remap]
importer="glsl"
type="RDShaderFile"
uid="uid://yioccj34hlex"
path="res://.godot/imported/RadialBlurShader.glsl-495ace3264af9b141d13d88646f4d37b.res"
[deps]
source_file="res://addons/rokojori_action_library/Runtime/Rendering/CompositorEffects/RadialBlur/RadialBlurShader.glsl"
dest_files=["res://.godot/imported/RadialBlurShader.glsl-495ace3264af9b141d13d88646f4d37b.res"]
[params]

View File

@ -1,14 +0,0 @@
[remap]
importer="glsl"
type="RDShaderFile"
uid="uid://cd1ysd752pjrn"
path="res://.godot/imported/TemporalSmear.glsl-b228c3fd9c0b0985d61f64e14d6b8842.res"
[deps]
source_file="res://addons/rokojori_action_library/Runtime/Rendering/CompositorEffects/TemporalSmear/TemporalSmear.glsl"
dest_files=["res://.godot/imported/TemporalSmear.glsl-b228c3fd9c0b0985d61f64e14d6b8842.res"]
[params]

View File

@ -1,14 +0,0 @@
[remap]
importer="glsl"
type="RDShaderFile"
uid="uid://b281d2ovcc1wm"
path="res://.godot/imported/Copy.glsl-440875809e1224bd8f12ab4747b61bfc.res"
[deps]
source_file="res://addons/rokojori_action_library/Runtime/Rendering/CompositorEffects/TextureDilation/Copy.glsl"
dest_files=["res://.godot/imported/Copy.glsl-440875809e1224bd8f12ab4747b61bfc.res"]
[params]

View File

@ -1,14 +0,0 @@
[remap]
importer="glsl"
type="RDShaderFile"
uid="uid://fjarrr31htov"
path="res://.godot/imported/JFA_Assign.glsl-d64da3d1862c7dbd2f410c2e5f98e270.res"
[deps]
source_file="res://addons/rokojori_action_library/Runtime/Rendering/CompositorEffects/TextureDilation/JFA_Assign.glsl"
dest_files=["res://.godot/imported/JFA_Assign.glsl-d64da3d1862c7dbd2f410c2e5f98e270.res"]
[params]

View File

@ -1,14 +0,0 @@
[remap]
importer="glsl"
type="RDShaderFile"
uid="uid://eqgl8l1lmgrl"
path="res://.godot/imported/JFA_Initialize.glsl-8eec6889b219c52896e1b7597ec3dbbd.res"
[deps]
source_file="res://addons/rokojori_action_library/Runtime/Rendering/CompositorEffects/TextureDilation/JFA_Initialize.glsl"
dest_files=["res://.godot/imported/JFA_Initialize.glsl-8eec6889b219c52896e1b7597ec3dbbd.res"]
[params]

View File

@ -1,14 +0,0 @@
[remap]
importer="glsl"
type="RDShaderFile"
uid="uid://b263k73iy5pbl"
path="res://.godot/imported/JFA_Step.glsl-89a0d568e1c875744d558d5c62c00f0b.res"
[deps]
source_file="res://addons/rokojori_action_library/Runtime/Rendering/CompositorEffects/TextureDilation/JFA_Step.glsl"
dest_files=["res://.godot/imported/JFA_Step.glsl-89a0d568e1c875744d558d5c62c00f0b.res"]
[params]

View File

@ -1,32 +0,0 @@
using System.Diagnostics;
using System.Collections;
using System.Collections.Generic;
using System;
using Godot;
namespace Rokojori
{
[Tool]
[GlobalClass]
public partial class TextureDilationCompositerEffect:_XX_CompositorEffectGraph
{
public TextureDilationCompositerEffect()
{
CreateGraph();
}
void CreateGraph()
{
}
void AssignData()
{
}
}
}

View File

@ -0,0 +1,65 @@
using Godot;
using System.Collections.Generic;
namespace Rokojori
{
public partial class RDContext
{
protected List<RenderingObject> _cleanUps = new List<RenderingObject>();
protected List<string> _cleanUpInfo = new List<string>();
public void Free( RenderingObject ro, string info = null )
{
if ( ro == null )
{
Warning( "ro == null, couldn't clean up: ", info );
return;
}
Verbose( "Cleaning up: ", info, ro.rid );
renderingDevice.FreeRid( ro.rid );
}
public void CleanUp()
{
var index = 0;
_cleanUps.ForEach(
c =>
{
Free( c, "_cleanUps[" + index + "]");
index ++;
}
);
_cleanUps.Clear();
}
public void AddToCleanUp( RenderingObject ro, string info = null )
{
if ( _cleanUps.Contains( ro ) )
{
return;
}
_cleanUps.Add( ro );
_cleanUpInfo.Add( info );
}
public void AddToCleanUp( List<RenderingObject> ro, string info = null )
{
var index = 0;
info = info == null ? "" : info;
ro.ForEach(
r =>
{
AddToCleanUp( r, info + "["+ index + "]" );
index ++;
}
);
}
}
}

View File

@ -0,0 +1 @@
uid://tvdeo52a18qd

View File

@ -0,0 +1,38 @@
using Godot;
using System.Collections.Generic;
namespace Rokojori
{
public partial class RDContext
{
public RDSampler Sampler( RDSamplerState state = null)
{
if ( state == null )
{
state = new RDSamplerState();
state.MinFilter = RenderingDevice.SamplerFilter.Linear;
state.MagFilter = RenderingDevice.SamplerFilter.Linear;
state.RepeatU = RenderingDevice.SamplerRepeatMode.Repeat;
state.RepeatV = RenderingDevice.SamplerRepeatMode.Repeat;
}
var sampler = RDSampler.Create( this, state );
return sampler;
}
public RDSampler Sampler( RenderingDevice.SamplerFilter filter, RenderingDevice.SamplerRepeatMode repeatMode)
{
var state = new RDSamplerState();
state.MinFilter = filter;
state.MagFilter = filter;
state.RepeatU = repeatMode;
state.RepeatV = repeatMode;
return Sampler( state );
}
}
}

View File

@ -0,0 +1 @@
uid://dkjlvi7ir3qur

View File

@ -0,0 +1,69 @@
using Godot;
using System.Collections.Generic;
namespace Rokojori
{
public partial class RDContext
{
protected List<Message> _messages = new List<Message>();
public List<Message> messages => _messages;
public bool logMessages = true;
public int messageLogLevel = Messages.GetLevel( MessageType.Info );
public bool HasError()
{
return Messages.HasError( _messages );
}
public void Error( params object[] messages )
{
var message = RJLog.GetLogString( messages );
Messages.Error( _messages, message );
if ( logMessages )
{
RJLog.Log( message );
}
}
public void Warning( params object[] messages )
{
var message = RJLog.GetLogString( messages );
Messages.Warning( _messages, message );
if ( logMessages && Messages.GetLevel( MessageType.Warning ) >= messageLogLevel )
{
RJLog.Log( message );
}
}
public void Info( params object[] messages )
{
var message = RJLog.GetLogString( messages );
Messages.Info( _messages, message );
if ( logMessages && Messages.GetLevel( MessageType.Info ) >= messageLogLevel )
{
RJLog.Log( message );
}
}
public void Verbose( params object[] messages )
{
var message = RJLog.GetLogString( messages );
Messages.Verbose( _messages, message );
if ( logMessages && Messages.GetLevel( MessageType.Verbose ) >= messageLogLevel )
{
RJLog.Log( message );
}
}
}
}

View File

@ -0,0 +1 @@
uid://bq4mu4ti38oj8

View File

@ -4,33 +4,24 @@ using System.Collections.Generic;
namespace Rokojori namespace Rokojori
{ {
public class RokojoriCompositorContext public partial class RDContext
{ {
protected RokojoriCompositorEffect _effect; protected RenderingDevice _renderingDevice;
public RokojoriCompositorEffect effect => _effect; public RenderingDevice renderingDevice => _renderingDevice;
protected RDShader _shader; protected RDShader _shader;
public RDShader shader => _shader; public RDShader shader => _shader;
protected RDPipeline _pipeline; protected RDPipeline _pipeline;
public RDPipeline pipeline => _pipeline; public RDPipeline pipeline => _pipeline;
public void SetShaderAndPipeline( RDShader shader, RDPipeline pipeline ) public void Initialize( bool local = false)
{ {
if ( shader == null || pipeline == null ) _renderingDevice = local ? RenderingServer.Singleton.CreateLocalRenderingDevice():
{ RenderingServer.Singleton.GetRenderingDevice();
_shader = null;
_pipeline = null;
effect.Error( "Shader Pipeline is null", shader, pipeline );
return;
}
effect.Verbose( "Set Shader Pipeline", shader, pipeline );
_shader = shader;
_pipeline = pipeline;
} }
protected int _view = -1; protected int _view = -1;
public int view => _view; public int view => _view;
@ -40,7 +31,6 @@ namespace Rokojori
protected RenderData _renderData; protected RenderData _renderData;
public RenderData renderData => _renderData; public RenderData renderData => _renderData;
protected RenderSceneBuffersRD _sceneBuffers; protected RenderSceneBuffersRD _sceneBuffers;
public RenderSceneBuffersRD sceneBuffers => _sceneBuffers; public RenderSceneBuffersRD sceneBuffers => _sceneBuffers;
@ -62,6 +52,23 @@ namespace Rokojori
return RDTexture.Depth( this ); return RDTexture.Depth( this );
} }
public void SetShaderAndPipeline( RDShader shader, RDPipeline pipeline )
{
if ( shader == null || pipeline == null )
{
_shader = null;
_pipeline = null;
Error( "Shader Pipeline is null", shader, pipeline );
return;
}
Verbose( "Set Shader Pipeline", shader, pipeline );
_shader = shader;
_pipeline = pipeline;
}
public void AssignScreenColorTexture( RDSampler sampler = null, int setIndex = -1 ) public void AssignScreenColorTexture( RDSampler sampler = null, int setIndex = -1 )
{ {
AssignTexture( GetScreenColorTexture(), sampler, setIndex ); AssignTexture( GetScreenColorTexture(), sampler, setIndex );
@ -86,12 +93,12 @@ namespace Rokojori
if ( sampler == null ) if ( sampler == null )
{ {
// effect.Verbose( "Adding Image" ); // effect.Verbose( "Adding Image" );
AddUniformSet( RDUniformSet.Image( _effect, texture, setIndex ) ); AddUniformSet( RDUniformSet.Image( this, texture, setIndex ) );
} }
else else
{ {
// effect.Verbose( "Adding Sampler" ); // effect.Verbose( "Adding Sampler" );
AddUniformSet( RDUniformSet.Sampler( _effect, sampler,texture, setIndex ) ); AddUniformSet( RDUniformSet.Sampler( this, sampler,texture, setIndex ) );
} }
} }
@ -109,17 +116,17 @@ namespace Rokojori
pushConstants = null; pushConstants = null;
} }
public void SetGroups( Vector3I groups ) public void SetComputeGroups( Vector3I groups )
{ {
this._groups = groups; this._groups = groups;
} }
public void ComputeGroups( int groupSize ) public void CalculateComputeGroups( int groupSize )
{ {
ComputeGroups( new Vector3I( groupSize, groupSize, 0 ) ); CalculateComputeGroups( new Vector3I( groupSize, groupSize, 0 ) );
} }
public void ComputeGroups( Vector3I groupSize ) public void CalculateComputeGroups( Vector3I groupSize )
{ {
var size = sceneBuffers.GetInternalSize(); var size = sceneBuffers.GetInternalSize();
@ -127,15 +134,15 @@ namespace Rokojori
var yGroups = groupSize.Y == 0 ? 1 : Mathf.CeilToInt( size.Y / (float) groupSize.Y ); var yGroups = groupSize.Y == 0 ? 1 : Mathf.CeilToInt( size.Y / (float) groupSize.Y );
var zGroups = groupSize.Z == 0 ? 1 : Mathf.CeilToInt( size.Y / (float) groupSize.Y ); var zGroups = groupSize.Z == 0 ? 1 : Mathf.CeilToInt( size.Y / (float) groupSize.Y );
SetGroups( new Vector3I( xGroups, yGroups, zGroups ) ); SetComputeGroups( new Vector3I( xGroups, yGroups, zGroups ) );
} }
public void Render() public void ProcessComputeProgram()
{ {
try try
{ {
var computeList = RDComputeList.Begin( _effect.rd ); var computeList = RDComputeList.Begin( _renderingDevice );
computeList.BindPipeline( pipeline ); computeList.BindPipeline( pipeline );
@ -161,21 +168,12 @@ namespace Rokojori
} }
catch( System.Exception e ) catch( System.Exception e )
{ {
effect.Error( e ); Error( e );
} }
Clear(); Clear();
} }
}
public class EditableRokojoriCompositorContext:RokojoriCompositorContext
{
public void SetEffect( RokojoriCompositorEffect effect )
{
this._effect = effect;
}
public void SetRenderData( RenderData renderData, RenderSceneBuffersRD buffers, RenderSceneDataRD sceneData ) public void SetRenderData( RenderData renderData, RenderSceneBuffersRD buffers, RenderSceneDataRD sceneData )
{ {
this._renderData = renderData; this._renderData = renderData;
@ -188,6 +186,5 @@ namespace Rokojori
this._view = view; this._view = view;
} }
} }
} }

View File

@ -1,16 +0,0 @@
using Godot;
namespace Rokojori
{
public class CompositorEffectGraphConnection:CompositorEffectGraphNode
{
protected CompositorEffectGraphProcessor _processor;
public CompositorEffectGraphConnection( CompositorEffectGraphProcessor processor ):base( processor.graph )
{
_processor = processor;
}
}
}

View File

@ -1,16 +0,0 @@
using Godot;
namespace Rokojori
{
public class CompositorEffectGraphNode
{
_XX_CompositorEffectGraph _graph;
public _XX_CompositorEffectGraph graph => _graph;
public CompositorEffectGraphNode( _XX_CompositorEffectGraph graph )
{
_graph = graph;
}
}
}

View File

@ -1,14 +0,0 @@
[remap]
importer="glsl"
type="RDShaderFile"
uid="uid://bqsb2a6poa7b0"
path="res://.godot/imported/RadialBlur.glsl-2a7bbca9e049b45a9edfab7b714dd886.res"
[deps]
source_file="res://addons/rokojori_action_library/Runtime/Rendering/Objects/CompositorEffectGraph/Nodes/Processors/Blurs/RadialBlur/RadialBlur.glsl"
dest_files=["res://.godot/imported/RadialBlur.glsl-2a7bbca9e049b45a9edfab7b714dd886.res"]
[params]

View File

@ -1,14 +0,0 @@
[remap]
importer="glsl"
type="RDShaderFile"
uid="uid://dkmulxqa0tvis"
path="res://.godot/imported/Copy.glsl-04e877248c733e7d624480658e605c4c.res"
[deps]
source_file="res://addons/rokojori_action_library/Runtime/Rendering/Objects/CompositorEffectGraph/Nodes/Processors/Copy/Copy.glsl"
dest_files=["res://.godot/imported/Copy.glsl-04e877248c733e7d624480658e605c4c.res"]
[params]

View File

@ -1,14 +0,0 @@
[remap]
importer="glsl"
type="RDShaderFile"
uid="uid://diia0hlqqkna"
path="res://.godot/imported/JFA_Initialize.glsl-805a62d8bfe18f03d3fff707518fb98e.res"
[deps]
source_file="res://addons/rokojori_action_library/Runtime/Rendering/Objects/CompositorEffectGraph/Nodes/Processors/JFA/JFA_Initialize.glsl"
dest_files=["res://.godot/imported/JFA_Initialize.glsl-805a62d8bfe18f03d3fff707518fb98e.res"]
[params]

View File

@ -1,14 +0,0 @@
[remap]
importer="glsl"
type="RDShaderFile"
uid="uid://dntu82sa6clb4"
path="res://.godot/imported/JFA_Iterate.glsl-7375b6aced2100cd0023eb6c61803e61.res"
[deps]
source_file="res://addons/rokojori_action_library/Runtime/Rendering/Objects/CompositorEffectGraph/Nodes/Processors/JFA/JFA_Iterate.glsl"
dest_files=["res://.godot/imported/JFA_Iterate.glsl-7375b6aced2100cd0023eb6c61803e61.res"]
[params]

View File

@ -1,58 +0,0 @@
using Godot;
using System.Collections.Generic;
namespace Rokojori
{
[Tool]
[GlobalClass]
public partial class _XX_CompositorEffectGraph:RokojoriCompositorEffect
{
public static readonly string path = "res://addons/rokojori_action_library/Runtime/Rendering/Objects/CompositorEffectGraph";
public static string Path( string subPath )
{
return path + "/" + subPath;
}
protected List<CompositorEffectGraphNode> _nodes = new List<CompositorEffectGraphNode>();
protected List<CompositorEffectGraphProcessor> _processors = new List<CompositorEffectGraphProcessor>();
protected List<CompositorEffectGraphProcessor> _processOrder = new List<CompositorEffectGraphProcessor>();
protected void SetProcessOrder( List<CompositorEffectGraphProcessor> order )
{
_processOrder.Clear();
_processOrder.AddRange( order );
}
protected void SetProcessOrder( params CompositorEffectGraphProcessor[] order )
{
_processOrder.Clear();
_processOrder.AddRange( order );
}
protected override void RenderView()
{
OnPreProcess();
_processOrder.ForEach(
p =>
{
Verbose( p.GetType() );
p.Process();
}
);
OnPostProcess();
}
protected virtual void OnPreProcess()
{
}
protected virtual void OnPostProcess()
{
}
}
}

View File

@ -5,12 +5,12 @@ namespace Rokojori
{ {
public class RDPipeline: RenderingObject public class RDPipeline: RenderingObject
{ {
public RDPipeline( RokojoriCompositorEffect effect, Rid rid ):base( effect, rid ) public RDPipeline( RDContext context, Rid rid ):base( context, rid )
{} {}
public static RDPipeline Create( RokojoriCompositorEffect effect, RDShader shader ) public static RDPipeline Create( RDContext context, RDShader shader )
{ {
return new RDPipeline( effect, effect.rd.ComputePipelineCreate( shader.rid ) ); return new RDPipeline( context, context.renderingDevice.ComputePipelineCreate( shader.rid ) );
} }
} }
} }

View File

@ -0,0 +1,25 @@
using Godot;
using Godot.Collections;
namespace Rokojori
{
public class RDProgram
{
public enum Type
{
VertexFragment,
Compute
}
protected Type _type;
public Type type => _type;
protected RDShader _shader;
public RDShader shader;
protected RDPipeline _pipeline;
public RDPipeline pipeline;
}
}

View File

@ -0,0 +1 @@
uid://c1s1t05wskad0

View File

@ -5,12 +5,12 @@ namespace Rokojori
{ {
public class RDSampler: RenderingObject public class RDSampler: RenderingObject
{ {
public RDSampler( RokojoriCompositorEffect effect, Rid rid ):base( effect, rid ) public RDSampler( RDContext effect, Rid rid ):base( effect, rid )
{} {}
public static RDSampler Create( RokojoriCompositorEffect effect, RDSamplerState samplerState ) public static RDSampler Create( RDContext context, RDSamplerState samplerState )
{ {
return new RDSampler( effect, effect.rd.SamplerCreate( samplerState ) ); return new RDSampler( context, context.renderingDevice.SamplerCreate( samplerState ) );
} }
} }
} }

View File

@ -5,13 +5,13 @@ namespace Rokojori
{ {
public class RDShader: RenderingObject public class RDShader: RenderingObject
{ {
public RDShader( RokojoriCompositorEffect effect, Rid rid ):base( effect, rid ) public RDShader( RDContext context, Rid rid ):base( context, rid )
{} {}
public static RDShader CreateFromSpirV( RokojoriCompositorEffect effect, RDShaderSpirV rDShaderSpirV ) public static RDShader CreateFromSpirV( RDContext context, RDShaderSpirV rDShaderSpirV )
{ {
var shaderID = effect.rd.ShaderCreateFromSpirV( rDShaderSpirV ); var shaderID = context.renderingDevice.ShaderCreateFromSpirV( rDShaderSpirV );
return new RDShader( effect, shaderID ); return new RDShader( context, shaderID );
} }
} }
} }

View File

@ -5,32 +5,32 @@ namespace Rokojori
{ {
public class RDTexture: RenderingObject public class RDTexture: RenderingObject
{ {
public RDTexture( RokojoriCompositorEffect effect, Rid rid ):base( effect, rid ){} public RDTexture( RDContext context, Rid rid ):base( context, rid ){}
public static RDTexture Create( RokojoriCompositorEffect effect, RDTextureFormat format, RDTextureView view ) public static RDTexture Create( RDContext effect, RDTextureFormat format, RDTextureView view )
{ {
return new RDTexture( effect, effect.rd.TextureCreate( format, view ) ); return new RDTexture( effect, effect.renderingDevice.TextureCreate( format, view ) );
} }
public static RDTexture Color( RokojoriCompositorContext context ) public static RDTexture Color( RDContext context )
{ {
var rid = context.sceneBuffers.GetColorLayer( (uint) context.view ); var rid = context.sceneBuffers.GetColorLayer( (uint) context.view );
return new RDTexture( context.effect, rid ); return new RDTexture( context, rid );
} }
public static RDTexture Depth( RokojoriCompositorContext context ) public static RDTexture Depth( RDContext context )
{ {
var rid = context.sceneBuffers.GetDepthLayer( (uint) context.view ); var rid = context.sceneBuffers.GetDepthLayer( (uint) context.view );
return new RDTexture( context.effect, rid ); return new RDTexture( context, rid );
} }
public RDTextureFormat format public RDTextureFormat format
{ {
get get
{ {
return effect.rd.TextureGetFormat( rid ); return context.renderingDevice.TextureGetFormat( rid );
} }
} }
@ -43,28 +43,28 @@ namespace Rokojori
} }
} }
public static RDTexture EnsureScreenSizeTexture( RDTexture texture, RokojoriCompositorEffect effect, bool cleanUp = true ) public static RDTexture EnsureScreenSizeTexture( RDTexture texture, RDContext context, bool cleanUp = true )
{ {
var size = effect.context.internalSize; var size = context.internalSize;
if ( texture == null || texture.size != size ) if ( texture == null || texture.size != size )
{ {
if ( cleanUp && texture != null ) if ( cleanUp && texture != null )
{ {
effect.rd.FreeRid( texture.rid ); context.Free( texture, "Old Screen Size Texture" );
} }
texture = Create( effect, size ); texture = Create( context, size );
} }
return texture; return texture;
} }
public static RDTexture Create( RokojoriCompositorEffect effect, RDTextureFormat format ) public static RDTexture Create( RDContext context, RDTextureFormat format )
{ {
var view = new RDTextureView(); var view = new RDTextureView();
var rid = effect.rd.TextureCreate( format, view ); var rid = context.renderingDevice.TextureCreate( format, view );
return new RDTexture( effect, rid ); return new RDTexture( context, rid );
} }
public static RDTextureFormat DefaultFormat( int w, int h, RenderingDevice.DataFormat dataFormat = RenderingDevice.DataFormat.R16G16B16A16Unorm ) public static RDTextureFormat DefaultFormat( int w, int h, RenderingDevice.DataFormat dataFormat = RenderingDevice.DataFormat.R16G16B16A16Unorm )
@ -118,19 +118,19 @@ namespace Rokojori
} }
public static RDTexture Create( RokojoriCompositorEffect effect, Vector2I size, RenderingDevice.DataFormat dataFormat = RenderingDevice.DataFormat.R16G16B16A16Unorm ) public static RDTexture Create( RDContext context, Vector2I size, RenderingDevice.DataFormat dataFormat = RenderingDevice.DataFormat.R16G16B16A16Unorm )
{ {
return Create( effect, size.X, size.Y, dataFormat ); return Create( context, size.X, size.Y, dataFormat );
} }
public static RDTexture Create( RokojoriCompositorEffect effect, int width, int height, public static RDTexture Create( RDContext context, int width, int height,
RenderingDevice.DataFormat dataFormat = RenderingDevice.DataFormat.R16G16B16A16Unorm ) RenderingDevice.DataFormat dataFormat = RenderingDevice.DataFormat.R16G16B16A16Unorm )
{ {
var view = new RDTextureView(); var view = new RDTextureView();
var format = DefaultFormat( width, height, dataFormat ); var format = DefaultFormat( width, height, dataFormat );
var rid = effect.rd.TextureCreate( format, view ); var rid = context.renderingDevice.TextureCreate( format, view );
return new RDTexture( effect, rid ); return new RDTexture( context, rid );
} }
} }
} }

View File

@ -9,26 +9,26 @@ namespace Rokojori
protected int _setIndex = -1; protected int _setIndex = -1;
public int setIndex => _setIndex; public int setIndex => _setIndex;
public RDUniformSet( RokojoriCompositorEffect effect, int setIndex, Rid rid ):base( effect, rid ) public RDUniformSet( RDContext effect, int setIndex, Rid rid ):base( effect, rid )
{ {
_setIndex =setIndex; _setIndex =setIndex;
} }
public static RDUniformSet Image( RokojoriCompositorEffect effect, RDTexture texture, int setIndex ) public static RDUniformSet Image( RDContext context, RDTexture texture, int setIndex )
{ {
var uniform = new RDUniform(); var uniform = new RDUniform();
uniform.UniformType = RenderingDevice.UniformType.Image; uniform.UniformType = RenderingDevice.UniformType.Image;
uniform.Binding = 0; uniform.Binding = 0;
uniform.AddId( texture.rid ); uniform.AddId( texture.rid );
var rd = effect.rd; var rd = context.renderingDevice;
var rid = UniformSetCacheRD.GetCache( effect.context.shader.rid, (uint) setIndex, new Array<RDUniform>{ uniform } ); var rid = UniformSetCacheRD.GetCache( context.shader.rid, (uint) setIndex, new Array<RDUniform> { uniform } );
// var rid = rd.UniformSetCreate( new Array<RDUniform>{ uniform }, effect.context.shader.rid, (uint) setIndex ); // var rid = rd.UniformSetCreate( new Array<RDUniform>{ uniform }, effect.context.shader.rid, (uint) setIndex );
return new RDUniformSet( effect, setIndex, rid ); return new RDUniformSet( context, setIndex, rid );
} }
public static RDUniformSet Sampler( RokojoriCompositorEffect effect, RDSampler sampler, RDTexture texture, int setIndex ) public static RDUniformSet Sampler( RDContext context, RDSampler sampler, RDTexture texture, int setIndex )
{ {
var uniform = new RDUniform(); var uniform = new RDUniform();
uniform.UniformType = RenderingDevice.UniformType.SamplerWithTexture; uniform.UniformType = RenderingDevice.UniformType.SamplerWithTexture;
@ -36,12 +36,12 @@ namespace Rokojori
uniform.AddId( sampler.rid ); uniform.AddId( sampler.rid );
uniform.AddId( texture.rid ) ; uniform.AddId( texture.rid ) ;
var rd = effect.rd; var rd = context.renderingDevice;
var rid = UniformSetCacheRD.GetCache( effect.context.shader.rid, (uint) setIndex, new Array<RDUniform>{ uniform } ); var rid = UniformSetCacheRD.GetCache( context.shader.rid, (uint) setIndex, new Array<RDUniform>{ uniform } );
// var rid = rd.UniformSetCreate( new Array<RDUniform>{ uniform }, effect.context.shader.rid, (uint) setIndex ); // var rid = rd.UniformSetCreate( new Array<RDUniform>{ uniform }, effect.context.shader.rid, (uint) setIndex );
return new RDUniformSet( effect, setIndex, rid ); return new RDUniformSet( context, setIndex, rid );
} }
} }
} }

View File

@ -5,17 +5,17 @@ namespace Rokojori
{ {
public class RenderingObject public class RenderingObject
{ {
protected RokojoriCompositorEffect _effect; protected RDContext _context;
public RokojoriCompositorEffect effect => _effect; public RDContext context => _context;
protected Rid _rid; protected Rid _rid;
public Rid rid => _rid; public Rid rid => _rid;
public bool valid => _rid.IsValid; public bool valid => _rid.IsValid;
public RenderingObject( RokojoriCompositorEffect effect, Rid rid ) public RenderingObject( RDContext context, Rid rid )
{ {
this._effect = effect; this._context = context;
this._rid = rid; this._rid = rid;
} }

View File

@ -1,308 +0,0 @@
using Godot;
using System.Collections.Generic;
namespace Rokojori
{
[Tool]
[GlobalClass]
public partial class RokojoriCompositorEffect:CompositorEffect
{
protected RenderingDevice _rd;
public RenderingDevice rd => _rd;
protected List<RenderingObject> _cleanUps = new List<RenderingObject>();
protected List<string> _cleanUpInfo = new List<string>();
EditableRokojoriCompositorContext _context;
protected bool _hasContext = false;
public RokojoriCompositorContext context => _hasContext ? _context : null;
protected List<Message> _messages = new List<Message>();
public List<Message> messages => _messages;
public bool logMessages = true;
public int messageLogLevel = Messages.GetLevel( MessageType.Info );
protected virtual void OnConfigure(){}
protected virtual void OnInitialize(){}
protected virtual void ForAllViews(){}
protected virtual void RenderView(){}
public RokojoriCompositorEffect():base()
{
RenderingServer.CallOnRenderThread( Callable.From( _InitializeCompositorEffect ) );
}
protected void _InitializeCompositorEffect()
{
OnConfigure();
_rd = RenderingServer.Singleton.GetRenderingDevice();
if ( _rd == null )
{
Error( "Found no rendering device" );
return;
}
_context = new EditableRokojoriCompositorContext();
_context.SetEffect( this );
_hasContext = true;
OnInitialize();
_hasContext = false;
}
bool _hasError = false;
protected bool HasError()
{
return Messages.HasError( _messages );
}
public override void _RenderCallback( int effectCallbackType, RenderData renderData )
{
if ( _hasError || HasError() )
{
this.LogInfo( _messages );
return;
}
_messages.Clear();
_hasContext = false;
try
{
if ( rd == null )
{
Error( "No render device" );
return;
}
var sceneBuffers = ( RenderSceneBuffersRD ) renderData.GetRenderSceneBuffers();
var sceneData = ( RenderSceneDataRD ) renderData.GetRenderSceneData();
if ( sceneBuffers == null && sceneData == null )
{
Error( "sceneBuffers == null && sceneData == null" );
return;
}
var size = sceneBuffers.GetInternalSize();
if ( size.X == 0 || size.Y == 0 )
{
Warning( "InternalSize.X == 0 || InternalSize.Y == 0" );
return;
}
_context.SetRenderData( renderData, sceneBuffers, sceneData );
_context.SetView( -1 );
_hasContext = true;
ForAllViews();
int viewCount = ( int ) sceneBuffers.GetViewCount();
for ( int i = 0; i < viewCount; i++ )
{
_context.SetView( i );
RenderView();
}
}
catch( System.Exception e )
{
this.LogError( e );
_hasError = true;
}
if ( HasError() )
{
_hasError = true;
}
_hasContext = false;
}
public override void _Notification( int what )
{
var _shader = context.shader;
Verbose( "Got notification: ", what );
if ( what != NotificationPredelete || ( _shader == null || !_shader.valid ) || rd == null )
{
Verbose(
"what != NotificationPredelete", what != NotificationPredelete,
"( _shader == null || !_shader.valid )", ( _shader == null || !_shader.valid ),
"rd == null", rd == null
);
return;
}
CleanUp( _shader, "Shader" );
var index = 0;
_cleanUps.ForEach(
c =>
{
CleanUp( c, "_cleanUps[" + index + "]");
index ++;
}
);
_cleanUps.Clear();
}
public void AddToCleanUp( RenderingObject ro, string info = null )
{
var _shader = context.shader;
if ( _cleanUps.Contains( ro ) || _shader == ro )
{
return;
}
_cleanUps.Add( ro );
_cleanUpInfo.Add( info );
}
public void AddToCleanUp( List<RenderingObject> ro, string info = null )
{
var index = 0;
info = info == null ? "" : info;
ro.ForEach(
r =>
{
AddToCleanUp( r, info + "["+ index + "]" );
index ++;
}
);
}
void CleanUp( RenderingObject ro, string info )
{
if ( ro == null )
{
Warning( "ro == null, couldn't clean up: ", info );
return;
}
Verbose( "Cleaning up: ", info, ro.rid );
rd.FreeRid( ro.rid );
}
// ---------------------------------------------
// ---------------------------------------------
// CONVINIENCE
// ---------------------------------------------
// ---------------------------------------------
public RDSampler Sampler( RDSamplerState state = null)
{
if ( state == null )
{
state = new RDSamplerState();
state.MinFilter = RenderingDevice.SamplerFilter.Linear;
state.MagFilter = RenderingDevice.SamplerFilter.Linear;
state.RepeatU = RenderingDevice.SamplerRepeatMode.Repeat;
state.RepeatV = RenderingDevice.SamplerRepeatMode.Repeat;
}
var sampler = RDSampler.Create( this, state );
return sampler;
}
public RDSampler Sampler( RenderingDevice.SamplerFilter filter, RenderingDevice.SamplerRepeatMode repeatMode)
{
var state = new RDSamplerState();
state.MinFilter = filter;
state.MagFilter = filter;
state.RepeatU = repeatMode;
state.RepeatV = repeatMode;
return Sampler( state );
}
// ---------------------------------------------
// ---------------------------------------------
// MESSAGES
// ---------------------------------------------
// ---------------------------------------------
public void Error( params object[] messages )
{
var message = RJLog.GetLogString( messages );
Messages.Error( _messages, message );
if ( logMessages )
{
this.LogError( message );
}
}
public void Warning( params object[] messages )
{
var message = RJLog.GetLogString( messages );
Messages.Warning( _messages, message );
if ( logMessages && Messages.GetLevel( MessageType.Warning ) >= messageLogLevel )
{
this.LogInfo( message );
}
}
public void Info( params object[] messages )
{
var message = RJLog.GetLogString( messages );
Messages.Info( _messages, message );
if ( logMessages && Messages.GetLevel( MessageType.Info ) >= messageLogLevel )
{
this.LogInfo( message );
}
}
public void Verbose( params object[] messages )
{
var message = RJLog.GetLogString( messages );
Messages.Verbose( _messages, message );
if ( logMessages && Messages.GetLevel( MessageType.Verbose ) >= messageLogLevel )
{
this.LogInfo( message );
}
}
}
}

View File

@ -7,9 +7,9 @@ namespace Rokojori
public class CEG_RadialBlur:CEG_ImageProcessor public class CEG_RadialBlur:CEG_ImageProcessor
{ {
public static readonly string shaderPath = public static readonly string shaderPath =
_XX_CompositorEffectGraph.Path( "Nodes/Processors/Blurs/RadialBlur/RadialBlur.glsl" ); RDGraph.Path( "Nodes/Processors/Blurs/RadialBlur/RadialBlur.glsl" );
public CEG_RadialBlur( _XX_CompositorEffectGraph graph ):base( graph, shaderPath ) public CEG_RadialBlur( RDGraph graph ):base( graph, shaderPath )
{} {}

View File

@ -0,0 +1,14 @@
[remap]
importer="glsl"
type="RDShaderFile"
uid="uid://bqsb2a6poa7b0"
path="res://.godot/imported/RadialBlur.glsl-35b5275b6d1793a0225f9e56654817ba.res"
[deps]
source_file="res://addons/rokojori_action_library/Runtime/Rendering/RenderGraph/Nodes/Processors/Blurs/RadialBlur/RadialBlur.glsl"
dest_files=["res://.godot/imported/RadialBlur.glsl-35b5275b6d1793a0225f9e56654817ba.res"]
[params]

View File

@ -7,9 +7,9 @@ namespace Rokojori
public class CEG_Copy:CEG_ImageProcessor public class CEG_Copy:CEG_ImageProcessor
{ {
public static readonly string shaderPath = public static readonly string shaderPath =
_XX_CompositorEffectGraph.Path( "Nodes/Processors/Copy/Copy.glsl" ); RDGraph.Path( "Nodes/Processors/Copy/Copy.glsl" );
public CEG_Copy( _XX_CompositorEffectGraph graph ):base( graph, shaderPath ) public CEG_Copy( RDGraph graph ):base( graph, shaderPath )
{} {}

View File

@ -0,0 +1,14 @@
[remap]
importer="glsl"
type="RDShaderFile"
uid="uid://dkmulxqa0tvis"
path="res://.godot/imported/Copy.glsl-a0f0f39536a9da8f32ba3e28463a2f50.res"
[deps]
source_file="res://addons/rokojori_action_library/Runtime/Rendering/RenderGraph/Nodes/Processors/Copy/Copy.glsl"
dest_files=["res://.godot/imported/Copy.glsl-a0f0f39536a9da8f32ba3e28463a2f50.res"]
[params]

View File

@ -19,7 +19,7 @@ namespace Rokojori
} }
public virtual RDTexture Create( RDTexture texture, _XX_CompositorEffectGraph graph ) public virtual RDTexture Create( RDTexture texture, RDGraph graph )
{ {
return texture; return texture;
} }
@ -30,15 +30,15 @@ namespace Rokojori
public RDTextureFormat format = RDTexture.DefaultFormat( -1, -1 ); public RDTextureFormat format = RDTexture.DefaultFormat( -1, -1 );
public Vector2 scale = Vector2.One; public Vector2 scale = Vector2.One;
public override RDTexture Create( RDTexture texture, _XX_CompositorEffectGraph graph ) public override RDTexture Create( RDTexture texture, RDGraph graph )
{ {
Vector2I scaledSize = (Vector2I) ( graph.context.internalSize * scale ); Vector2I scaledSize = (Vector2I) ( graph.context.internalSize * scale );
if ( texture == null || scaledSize != texture.size ) if ( texture == null || scaledSize != texture.size )
{ {
AutoClean( texture, graph.rd ); AutoClean( texture, graph.context.renderingDevice );
format = RDTexture.FormatChangeSize( format, scaledSize ); format = RDTexture.FormatChangeSize( format, scaledSize );
texture = RDTexture.Create( graph, format ); texture = RDTexture.Create( graph.context, format );
} }
return texture; return texture;
@ -49,14 +49,14 @@ namespace Rokojori
{ {
public RDTextureFormat format = RDTexture.DefaultFormat( -1, -1 ); public RDTextureFormat format = RDTexture.DefaultFormat( -1, -1 );
public override RDTexture Create( RDTexture texture, _XX_CompositorEffectGraph graph ) public override RDTexture Create( RDTexture texture, RDGraph graph )
{ {
var formatSize = new Vector2I( (int) format.Width, (int) format.Height ); var formatSize = new Vector2I( (int) format.Width, (int) format.Height );
if ( texture == null || texture.size != formatSize ) if ( texture == null || texture.size != formatSize )
{ {
AutoClean( texture, graph.rd ); AutoClean( texture, graph.context.renderingDevice );
texture = RDTexture.Create( graph, format ); texture = RDTexture.Create( graph.context, format );
} }
return texture; return texture;
@ -65,7 +65,7 @@ namespace Rokojori
public class CEG_BufferTexture:CompositorEffectGraphProcessor, CompositorEffectGraphTextureSlotInput public class CEG_BufferTexture:RGGraphProcessor, RDGraphTextureSlotInput
{ {
RDTexture _texture; RDTexture _texture;
@ -77,7 +77,7 @@ namespace Rokojori
return _texture; return _texture;
} }
public CompositorEffectGraphProcessor GetProcessor() public RGGraphProcessor GetProcessor()
{ {
return this; return this;
} }
@ -89,19 +89,19 @@ namespace Rokojori
_connectedSlots.Add( slot ); _connectedSlots.Add( slot );
} }
public CEG_BufferTexture( _XX_CompositorEffectGraph graph, CEG_TextureCreator creator ):base( graph ) public CEG_BufferTexture( RDGraph graph, CEG_TextureCreator creator ):base( graph )
{ {
_creator = creator; _creator = creator;
} }
public static CEG_BufferTexture ScreenSize( _XX_CompositorEffectGraph graph, Vector2? scale = null ) public static CEG_BufferTexture ScreenSize( RDGraph graph, Vector2? scale = null )
{ {
var screenSize = new CEG_TextureCreator_ScreenSize(); var screenSize = new CEG_TextureCreator_ScreenSize();
screenSize.scale = scale == null ? Vector2.One : (Vector2) scale; screenSize.scale = scale == null ? Vector2.One : (Vector2) scale;
return new CEG_BufferTexture( graph, screenSize ); return new CEG_BufferTexture( graph, screenSize );
} }
public static CEG_BufferTexture FixedSize( _XX_CompositorEffectGraph graph ) public static CEG_BufferTexture FixedSize( RDGraph graph )
{ {
return new CEG_BufferTexture( graph, new CEG_TextureCreator_FixedSize() ); return new CEG_BufferTexture( graph, new CEG_TextureCreator_FixedSize() );
} }

View File

@ -4,12 +4,12 @@ using System.Collections.Generic;
namespace Rokojori namespace Rokojori
{ {
public class CEG_ImageProcessor:CompositorEffectShaderProcessor public class CEG_ImageProcessor:RDShaderProcessor
{ {
public readonly CompositorEffectGraphTextureSlot input; public readonly CompositorEffectGraphTextureSlot input;
public readonly CompositorEffectGraphTextureSlot output; public readonly CompositorEffectGraphTextureSlot output;
public CEG_ImageProcessor( _XX_CompositorEffectGraph graph, string shaderPath ):base( graph, shaderPath ) public CEG_ImageProcessor( RDGraph graph, string shaderPath ):base( graph, shaderPath )
{ {
input = new CompositorEffectGraphTextureSlot( this ); input = new CompositorEffectGraphTextureSlot( this );
output = new CompositorEffectGraphTextureSlot( this ); output = new CompositorEffectGraphTextureSlot( this );
@ -17,7 +17,7 @@ namespace Rokojori
_textureSlots.AddRange( new List<CompositorEffectGraphTextureSlot>{ input, output } ); _textureSlots.AddRange( new List<CompositorEffectGraphTextureSlot>{ input, output } );
} }
public void SetTextureSlotInputs( CompositorEffectGraphTextureSlotInput inputSlot, CompositorEffectGraphTextureSlotInput outputSlot ) public void SetTextureSlotInputs( RDGraphTextureSlotInput inputSlot, RDGraphTextureSlotInput outputSlot )
{ {
inputSlot.ConnectTo( input ); inputSlot.ConnectTo( input );
outputSlot.ConnectTo( output ); outputSlot.ConnectTo( output );

View File

@ -4,7 +4,7 @@ using System.Collections.Generic;
namespace Rokojori namespace Rokojori
{ {
public class CEG_ScreenColorTexure:CompositorEffectGraphProcessor, CompositorEffectGraphTextureSlotInput public class CEG_ScreenColorTexure:RGGraphProcessor, RDGraphTextureSlotInput
{ {
RDTexture _texture; RDTexture _texture;
@ -13,7 +13,7 @@ namespace Rokojori
return _texture; return _texture;
} }
public CompositorEffectGraphProcessor GetProcessor() public RGGraphProcessor GetProcessor()
{ {
return this; return this;
} }
@ -25,7 +25,7 @@ namespace Rokojori
_connectedSlots.Add( slot ); _connectedSlots.Add( slot );
} }
public CEG_ScreenColorTexure( _XX_CompositorEffectGraph graph ):base( graph ) public CEG_ScreenColorTexure( RDGraph graph ):base( graph )
{} {}
public override void Process() public override void Process()

Some files were not shown because too many files have changed in this diff Show More