Hi everyone,
I am new to shaders and I am having some problems to make my first attempt work. This first attempt is a port from shadertoys performing RGB separation and some blurr.
The scene setup is simple a Node2D -> Canvas Layer. Under the canvas layer a background sprite, the sprite where I apply the shader and the same sprite without shader.
The problem seems to be that the transparency (alpha) of the sprite is shown as black (even if the render mode is set-up to blend_mix).
Does anyone know what might be happening?
Regards,
Ricard
Result:

Shader code:
shader_type canvas_item;
render_mode blend_mix;
float hash( float n )
{
return fract(sin(n)*43758.5453);
}
float noise( in vec3 x )
{
vec3 p = floor(x);
vec3 f = fract(x);
f = f*f*(3.0-2.0*f);
float n = p.x + p.y*57.0 + 113.0*p.z;
float res = mix(mix(mix( hash(n+ 0.0), hash(n+ 1.0),f.x),
mix( hash(n+ 57.0), hash(n+ 58.0),f.x),f.y),
mix(mix( hash(n+113.0), hash(n+114.0),f.x),
mix( hash(n+170.0), hash(n+171.0),f.x),f.y),f.z);
return res;
}
void fragment () {
vec2 uv = UV;
float blurx = noise(vec3(TIME * 10.0, 0.0, 0.0)) * 2.0 - 1.0;
float offsetx = blurx * 0.025;
float blury = noise(vec3(TIME * 10.0, 1.0, 0.0)) * 2.0 - 1.0;
float offsety = blury * 0.01;
vec2 ruv = uv + vec2(offsetx, offsety);
vec2 guv = uv + vec2(-offsetx, -offsety);
vec2 buv = uv + vec2(0.00, 0.0);
float r = texture(TEXTURE, ruv).r;
float g = texture(TEXTURE, guv).g;
float b = texture(TEXTURE, buv).b;
COLOR = vec4(r, g, b, 1.0);
}