This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
+1 vote

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.

enter image description here

shadertype canvasitem;

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

void fragment(){

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.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);


in Engine by (13 points)

1 Answer

0 votes

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

by (1,945 points)


shadertype canvasitem;
rendermode blendmix;
uniform float size:hintrange (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 pixelmove:hintrange(-0.003,0.003);
void fragment()

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))) 
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);


Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.