0 votes

I'm following Nolkaloid's shockwave shader tutorial and using the Kenney Simplified Platformer player spritesheet. I've set the Hframe and Vframe properties on the spritesheet to 4 and 2, respectively. My shader code looks like this:

shader_type canvas_item;

uniform vec2 center;
uniform float force;

void fragment() {
    vec2 disp = normalize(UV - center) * force;
    COLOR = texture(TEXTURE, UV - disp);

When setting the center to 0.5 and the force to anything above 0, the other sprites in the spritesheet end up coming into the image. How do I fix this?

Godot version 4.0 beta 7
in Engine by (12 points)
retagged by

1 Answer

0 votes

That is happening because the UV's are going beyond the range of 0 - 1.
The easy fix is dividing the (UV - disp) by a number. How big this number is depends on the force.

by (2,017 points)
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.