Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Ron0Studios |
I have a warp shader, it looks like this:
shader_type canvas_item;
uniform vec2 center;
uniform float force : hint_range(0,1, 0.01);
uniform float size : hint_range(0,1,0.01);
uniform float thick : hint_range(0,1,0.01);
uniform float range : hint_range(0,1.0,0.01);
void fragment(){
vec2 scaledUV = UV;
float mask = (1.0 - smoothstep(size,size+0.1, length(scaledUV - center)))
* smoothstep(size-thick-0.01, size-thick+0.4, length(scaledUV-center));
vec2 disp = normalize(scaledUV - center) * force * mask;// * clamp(range-size,0.0,100.0);
if(disp == vec2(0.0,0.0)){
COLOR = texture(SCREEN_TEXTURE, SCREEN_UV);
}
else
COLOR = texture(SCREEN_TEXTURE, SCREEN_UV-disp);
//COLOR.rgb = vec3(disp,0.0);
//COLOR.rgb = vec3(mask * clamp(range-size,0.0,100.0));
}
Basically all it does is warp the SCREEN_UV to create a shockwave effect. I’ve modified it from tutorials on youtube so that it can work as a standalone sfx at any position in the world (by using a regular UV and SCREEN_UV in conjunction)
However, I have been finding it difficult to layer two of these together, such as when two instances of the wave are created close to each other. As you can see, I have tried to solve this with an if-else statement, but it doesn’t really blend the two waves, but rather overrides certain parts to make the effect less jarring.
Is there a way to blend this?