crabs-game/images/goo/goo.shader

35 lines
1.1 KiB
Plaintext
Raw Permalink Normal View History

2020-08-18 15:13:54 +02:00
shader_type canvas_item;
render_mode blend_mix;
uniform int particles_anim_h_frames;
uniform int particles_anim_v_frames;
uniform bool particles_anim_loop;
uniform int frame;
2020-08-18 15:13:54 +02:00
void vertex() {
float h_frames = float(particles_anim_h_frames);
float v_frames = float(particles_anim_v_frames);
VERTEX.xy /= vec2(h_frames, v_frames);
float particle_total_frames = float(particles_anim_h_frames * particles_anim_v_frames);
// float particle_frame = floor(INSTANCE_CUSTOM.z * float(particle_total_frames));
// if (!particles_anim_loop) {
// particle_frame = clamp(particle_frame, 0.0, particle_total_frames - 1.0);
// } else {
// particle_frame = mod(particle_frame, particle_total_frames);
// }
float particle_frame = float(frame);
UV /= vec2(h_frames, v_frames);
2020-08-18 15:13:54 +02:00
UV += vec2(mod(particle_frame, h_frames) / h_frames, floor(particle_frame / h_frames) / v_frames);
}
void fragment() {
float b = texture(TEXTURE, UV).w;
float n = texture(NORMAL_TEXTURE, UV).w;
if(b == 0f && n >= 1f) {
//COLOR.xyz = vec3(1, 1, 1) - texture(SCREEN_TEXTURE, SCREEN_UV).xyz;
COLOR = vec4(0, 0, 0, 0.9f);
} else {
COLOR = texture(TEXTURE, UV);
}
}