56 lines
1.2 KiB
C#
56 lines
1.2 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 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 );
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}
|