I think this is the best I can do for a hover vs. click shader effect. Just do it in a shader based on a uniform setting.

This commit is contained in:
Zed A. Shaw 2025-04-15 01:01:44 -04:00
parent 84a5f06dac
commit 7186c2ecb0
16 changed files with 54 additions and 38 deletions

View file

@ -5,18 +5,25 @@ uniform float u_time;
uniform float u_time_end;
uniform sampler2D texture;
uniform bool is_shape;
uniform bool hover;
void main() {
if(is_shape) {
float tick = (u_time_end - u_time) / u_duration;
float blink = mix(0.5, 1.0, tick);
vec4 color = vec4(blink, blink, blink, 1.0);
gl_FragColor = gl_Color * color;
vec4 blink() {
if(hover) {
return vec4(0.95, 0.95, 1.0, 1.0);
} else {
vec4 pixel = texture2D(texture, gl_TexCoord[0].xy);
float tick = (u_time_end - u_time) / u_duration;
float blink = mix(0.5, 1.0, tick);
vec4 color = vec4(blink, blink, blink, 1.0);
gl_FragColor = gl_Color * color * pixel;
return vec4(blink, blink, blink, 1.0);
}
}
void main() {
vec4 color = blink();
if(!is_shape) {
vec4 pixel = texture2D(texture, gl_TexCoord[0].xy);
color *= pixel;
}
gl_FragColor = gl_Color * color;
}