Hi everyone,
following this tutorial (https://www.youtube.com/watch?v=SCHdglr35pk) I was able to instance that shader-scene on a button-release, so on release there's that nice "shockwave" happening right in the center of the screen.
shader_type canvas_item;
uniform vec2 center;
uniform float force;
uniform float size;
uniform float thickness;
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.04, size, length(scaledUV - center))) *
smoothstep(size-thickness-0.08, size-thickness, length(scaledUV - center));
vec2 disp = normalize(scaledUV - center) * force * mask;
COLOR = texture(SCREEN_TEXTURE, SCREEN_UV - disp);
}
I instanced other scenes in other situations and I usually can position them like this:
var shockwave = preload("res://shader/shockwave.tscn").instance()
add_child(shockwave)
shockwave.position = Vector2(80, 800)
In this case, however, positioning like that won't work.
It would be nice to have such a shockwave-scene independent from "the whole screen", but as its "own little object" instead, like some invisible sprite which could be instanced and positioned (and scaled etc.) anywhere... just so I could position it on top of my button.
Any ideas how that could be done?