+1 vote

is possible to make a shader on a texture button state (hover, pressed, etc, ) ?
Thanks in advance.

in Engine by (1,469 points)
edited by

1 Answer

+2 votes
Best answer
  • Create a custom theme
  • Add the class items you need, e.g. a button
  • set a certain background color for each state (maybe light green = hover, pink = focus, etc.)
  • add a shader to the button, that only affects the pixels that have the proper color, for example a whirl-shader like this:
uniform float frequency=60;
uniform float depth = 0.005;

vec2 uv = SCREEN_UV;
uv.x += sin(uv.y*frequency+TIME*1.4)*depth;
uv.x = clamp(uv.x,0,1);
vec3 c = texscreen(uv);

if (COLOR.rgb == vec3(1, 0, 1)) 
  COLOR.rgb = c;

you will get something like this: I used pink for the focus state (vec3(1, 0, 1)).

button shader

by (196 points)
selected by
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 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 webmaster@godotengine.org with your username.