Chromatic Aberation
This commit is contained in:
parent
f2a0901146
commit
966cb7e28c
|
@ -0,0 +1,82 @@
|
|||
|
||||
using Godot;
|
||||
using Godot.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Rokojori
|
||||
{
|
||||
[Tool]
|
||||
[GlobalClass]
|
||||
public partial class ChromaticAberation:RDGraphCompositorEffect
|
||||
{
|
||||
public ChromaticAberation():base()
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
|
||||
|
||||
[Export]
|
||||
public float intensity = 0.5f;
|
||||
|
||||
[Export]
|
||||
public float shiftAll = 0.5f;
|
||||
|
||||
[Export]
|
||||
public float unshiftCenter = 16f;
|
||||
|
||||
[Export]
|
||||
public Vector2 rShift = new Vector2( -0.001f, 0.0f );
|
||||
|
||||
[Export]
|
||||
public Vector2 gShift = new Vector2( 0.0f, 0.0f );
|
||||
|
||||
[Export]
|
||||
public Vector2 bShift = new Vector2( 0.001f, 0.0f );
|
||||
|
||||
|
||||
|
||||
CEG_ScreenColorTexure screenColorTexture;
|
||||
CEG_BufferTexture bufferTexture;
|
||||
|
||||
CEG_Copy copy;
|
||||
CEG_ChromaticAberation chromaticAberation;
|
||||
|
||||
void Initialize()
|
||||
{
|
||||
screenColorTexture = new CEG_ScreenColorTexure( graph );
|
||||
bufferTexture = CEG_BufferTexture.ScreenSize( graph );
|
||||
|
||||
copy = new CEG_Copy( graph );
|
||||
chromaticAberation = new CEG_ChromaticAberation( graph );
|
||||
|
||||
|
||||
graph.InitializeNodes();
|
||||
|
||||
|
||||
|
||||
copy.SetTextureSlotInputs( screenColorTexture, bufferTexture );
|
||||
chromaticAberation.SetTextureSlotInputs( copy.output, copy.input );
|
||||
|
||||
|
||||
graph.SetProcessOrder(
|
||||
screenColorTexture, bufferTexture,
|
||||
copy, chromaticAberation
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
protected override void ForAllViews()
|
||||
{
|
||||
chromaticAberation.constants.Set(
|
||||
intensity,
|
||||
shiftAll,
|
||||
unshiftCenter,
|
||||
rShift,
|
||||
gShift,
|
||||
bShift
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
uid://cghyn18utdfl
|
|
@ -0,0 +1,17 @@
|
|||
|
||||
using Godot;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Rokojori
|
||||
{
|
||||
public class CEG_ChromaticAberation:CEG_ImageProcessor
|
||||
{
|
||||
public static readonly string shaderPath =
|
||||
RDGraph.Path( "Nodes/Processors/Color/ChromaticAberation/ChromaticAberation.glsl" );
|
||||
|
||||
public CEG_ChromaticAberation( RDGraph graph ):base( graph, shaderPath )
|
||||
{}
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
uid://cse0v4j8d7e1w
|
|
@ -0,0 +1,52 @@
|
|||
#[compute]
|
||||
#version 450
|
||||
|
||||
layout( local_size_x = 8, local_size_y = 8, local_size_z = 1 ) in;
|
||||
|
||||
layout( rgba16f, set = 0, binding = 0 )
|
||||
uniform image2D inputImage;
|
||||
layout( rgba16f, set = 1, binding = 0 )
|
||||
uniform image2D outputImage;
|
||||
|
||||
|
||||
layout( push_constant, std430 )
|
||||
uniform Params
|
||||
{
|
||||
float amount;
|
||||
float shiftAll;
|
||||
float unshiftCenter;
|
||||
vec2 rShift;
|
||||
vec2 gShift;
|
||||
vec2 bShift;
|
||||
|
||||
} params;
|
||||
|
||||
void main( )
|
||||
{
|
||||
ivec2 size = imageSize( inputImage );
|
||||
ivec2 texel_coord = ivec2( gl_GlobalInvocationID.xy );
|
||||
|
||||
if ( any( greaterThanEqual( texel_coord, size ) ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
vec2 uv = ( vec2( texel_coord ) + 0.5 ) / vec2( size );
|
||||
|
||||
|
||||
vec2 uvR = uv + params.rShift * params.shiftAll;
|
||||
vec2 uvG = uv + params.gShift * params.shiftAll;
|
||||
vec2 uvB = uv + params.bShift * params.shiftAll;
|
||||
|
||||
float r = imageLoad( inputImage, ivec2( uvR * size ) ).r;
|
||||
float g = imageLoad( inputImage, ivec2( uvG * size ) ).g;
|
||||
float b = imageLoad( inputImage, ivec2( uvB * size ) ).b;
|
||||
|
||||
vec4 chromaticColor = vec4( r, g, b, 1 );
|
||||
|
||||
vec4 color = imageLoad( inputImage, ivec2( uv * size ) );
|
||||
vec4 blended = mix( color, chromaticColor, params.amount );
|
||||
|
||||
|
||||
imageStore( outputImage, texel_coord, blended );
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
[remap]
|
||||
|
||||
importer="glsl"
|
||||
type="RDShaderFile"
|
||||
uid="uid://dnd8b80wfam5n"
|
||||
path="res://.godot/imported/ChromaticAberation.glsl-71eb2b3b033550490408285e80a1dcf1.res"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://addons/rokojori_action_library/Runtime/Rendering/RenderGraph/Nodes/Processors/Color/ChromaticAberation/ChromaticAberation.glsl"
|
||||
dest_files=["res://.godot/imported/ChromaticAberation.glsl-71eb2b3b033550490408285e80a1dcf1.res"]
|
||||
|
||||
[params]
|
||||
|
|
@ -13,7 +13,7 @@ namespace Rokojori
|
|||
|
||||
protected RDContext _context;
|
||||
public RDContext context => _context;
|
||||
public static readonly string path = "res://addons/rokojori_action_library/Runtime/Rendering/Compositor/CompositorEffectGraph";
|
||||
public static readonly string path = "res://addons/rokojori_action_library/Runtime/Rendering/RenderGraph";
|
||||
public static string Path( string subPath )
|
||||
{
|
||||
return path + "/" + subPath;
|
||||
|
|
Loading…
Reference in New Issue