xxxxxxxxxx
20
precision mediump float;
varying vec2 pos;
void main() {
float strength = pos.x;
float durability = pos.y;
// if strength is greater than durability, do full strength damage
float strengthGreaterMask = step(durability, strength);
float maxDurability = step(1.0, durability); // if durability is max => no damage
float damage = strengthGreaterMask + ((1.-strengthGreaterMask) * (strength/durability));
damage *= (1. - maxDurability);
gl_FragColor = vec4(damage, damage, damage, 1.0);
}