How do I add two effects together? (Shockwave and Chromatic Aberration)

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Amti

I want to add the Chromatic Aberration to the shockwave. Much like in the tutorial.
I have no idea how to do this and have been stuck for a while.

shader_type canvas_item;

uniform vec2 center;
uniform float force;
uniform float size;
uniform float thickness;
uniform float offset;

void fragment(){

float ratio = SCREEN_PIXEL_SIZE.x / SCREEN_PIXEL_SIZE.y;
vec2 scaledUV = (SCREEN_UV - vec2(0.5, 0.0) ) / vec2(ratio, 1.0) + vec2(0.5, 0.0);
float mask = (1.0 - smoothstep(size-0.1, size, length(scaledUV - center))) *
	smoothstep(size-thickness-0.1, size-thickness, length(scaledUV - center));
vec2 disp = normalize(scaledUV - center) * force * mask;
COLOR = texture(SCREEN_TEXTURE, SCREEN_UV - disp);
//COLOR.rgb = vec3(mask);

//Chromatic Aberration (I want to apply chromatic Aberation to the shockwave.I'm nt sure how to combine the effects')(The code below is something used in shadertoy)
vec4 rc = texture(SCREEN_TEXTURE, vec2(scaledUV.x - offset, scaledUV.y));
vec4 gc = texture(SCREEN_TEXTURE, vec2(scaledUV.x + offset, scaledUV.y));
vec4 bc = texture(SCREEN_TEXTURE, vec2(scaledUV.x, scaledUV.y));

vec3 distortion = vec3(rc.r, gc.g, bc.b);

}
//This is the code I’m trying to replicate from for the chromatic abberation.
//void mainImage( out vec4 fragColor, in vec2 fragCoord ) {

//vec2 scaledUV = fragCoord/iResolution.xy;
//vec4 rc = texture(iChannel0, vec2(scaledUV.x - offset, scaledUV.y));
//vec4 gc = texture(iChannel0, vec2(scaledUV.x + offset, scaledUV.y));
//vec4 bc = texture(iChannel0, vec2(scaledUV.x, scaledUV.y));

//fragColor = vec4(rc.r, gc.g, bc.b, 1.0);

//}

:bust_in_silhouette: Reply From: rakkarage

https://forum.godotengine.org/40236/how-to-stack-shaders

i think each shader has a nextPass var in inspector that you can set to another shader or something

// MAYBE A LITTLE LATE, BUT HERE YOU GO.

shader_type canvas_item;
render_mode blend_mix;
uniform float size:hint_range (0.0,2.0);
uniform vec2 center = vec2(0.5,0.5);
uniform float thickness:hint_range (0.0,0.50);
uniform float force =0.123;
// uniform used to move the texture by pixels
uniform float pixel_move:hint_range(-0.003,0.003);
void fragment()
{


float ratio = (SCREEN_PIXEL_SIZE.x/SCREEN_PIXEL_SIZE.y );
vec2 scaledUV = (SCREEN_UV-vec2(0.5,0.0)) / vec2(ratio,1.0) +vec2 (0.5,0.0);
float mask    = (1.0-smoothstep(size-0.1,size,length(scaledUV-center))) 
					*smoothstep(size-thickness-0.1,size-thickness,length(scaledUV-center));
vec2 displacement = normalize(scaledUV-center) *force;
vec4 tex =  texture(SCREEN_TEXTURE,(SCREEN_UV)-displacement *mask);
///offset used to Move the Textures 
vec2 offset = (SCREEN_PIXEL_SIZE.xy+vec2(pixel_move) )* mask;

vec4 rc = texture(SCREEN_TEXTURE,(SCREEN_UV-vec2(offset.x,0.0))-displacement *mask);
vec4 gc = texture(SCREEN_TEXTURE,(SCREEN_UV+vec2(offset.x,0.0))-displacement *mask);
vec4 bc = texture(SCREEN_TEXTURE,(SCREEN_UV-vec2(0.0,offset.y))-displacement *mask);

COLOR =  vec4(rc.r, gc.g, bc.b, 1.0);

}

0nepixel | 2020-11-06 16:26