 
   gl_FragDepth = 0.0;
 
-
   uint maxage = u_Counts[Saddr(ij)];
 
   if (maxage == 0)

    discard;  // no fragment, early exit
  }

  vec4 clr = vec4(0, 0, 0, 0);
  for (uint a = 1; a <= maxage; a++)  // all fragments
  {
    uvec2 l = (ij + u_Offsets[a]);
    uint64_t h = Haddr(l % uvec2(u_HashSz));

    uint64_t rec = u_Records[h];

    uint32_t key = uint32_t(rec >> uint64_t(32));
    if (HA_AGE(key) == a)
    {
      // clr = blend(clr,RGBA(uint32_t(rec)));
      const FragmentData fragment = u_FragmentData[uint32_t(rec)];
      clr = blend(clr, fragment.color);
      // break; // just the first fragment
    }
  }

  o_PixColor = blend(clr, vec4(BkgColor, 1.0));

layout(depth_any) out float gl_FragDepth;

uniform vec3 BkgColor = vec3(1.0, 1.0, 1.0);
uniform mat4 projectionMatrix;

// Blending equation for in-order traversal
vec4 blend(vec4 clr, vec4 srf)
{
  return clr + (1.0 - clr.w) * vec4(srf.xyz * srf.w, srf.w);
}

bool fetchFragment(in uvec2 ij, in uint age, out FragmentData fragment)
{
  uvec2 l = (ij + u_Offsets[age]);
  uint64_t h = Haddr(l % uvec2(u_HashSz));

  uint64_t rec = u_Records[h];

  uint32_t key = uint32_t(rec >> uint64_t(32));

  if (HA_AGE(key) == age)
  {
    // clr = blend(clr,RGBA(uint32_t(rec)));
    fragment = u_FragmentData[uint32_t(rec)];
    return true;
  }
  else
  {
    return false;
  }
}


