rj-action-library/Runtime/Rendering/Objects/SingleShaderCompositorEffec...

72 lines
1.5 KiB
C#

using Godot;
using System.Collections.Generic;
namespace Rokojori
{
[Tool]
[GlobalClass]
public partial class SingleShaderCompositorEffect:RokojoriCompositorEffect
{
protected string _shaderPath;
protected RDShader _shader;
protected RDPipeline _pipeline;
protected int _groupSize = 16;
protected override void OnInitialize()
{
Verbose( "Trying to load shader: ", _shaderPath );
if ( _shaderPath == null )
{
Error( "_shaderPath == null" );
return;
}
var glslFile = GD.Load<RDShaderFile>( _shaderPath );
if ( glslFile == null )
{
Error( "Couldn't load shader at path:", _shaderPath );
return;
}
_shader = RDShader.CreateFromSpirV( this, glslFile.GetSpirV() );
if ( _shader == null )
{
Error( "Couldn't create shader from code, path:", _shaderPath );
return;
}
_pipeline = RDPipeline.Create( this, _shader );
if ( _shader == null )
{
Error( "Couldn't create pipeline from compiled shader, path:", _shaderPath );
return;
}
Verbose( "Created shader at path: ", _shaderPath );
context.SetShaderAndPipeline( _shader, _pipeline );
}
protected RDPushConstants _constants = new RDPushConstants();
public RDPushConstants constants => _constants;
protected override void ForAllViews()
{
context.ComputeGroups( _groupSize );
SetConstants();
}
protected virtual void SetConstants()
{
}
}
}