float3 computeWeights(in float hatchFactor, in float3 initialWeights) {
  float3 weights = max(float3(hatchFactor) - initialWeights, float3(0));
  // flag weights which are <= 2
  float3 flags = step(weights, float3(2.0));
  // multiply component-wise to zero weights > 2
  weights = weights * flags;
  // flag weights which are > 1
  flags = step(float3(1.0), weights);
  weights = flags*2.0 - weights;
  flags = step(weights, float3(0.0));
  flags = step(float3(0.0), weights) - flags;
  weights = weights * flags;
  return weights;
}
