


layout(binding = 1)
  uniform sampler1D transferFunctionData;

uniform float rOffset;
uniform float rScale;
uniform bool isNoValueColorVisible;

/////////////////////////////////////////////////////////////////////////////
// IsInvisible
//

bool
IsInvisible(ivec3 iMin, ivec3 iMax)
{

  for (int z_in = iMin.z; z_in < iMax.z; z_in++)
  {
    for (int y_in = iMin.y; y_in < iMax.y; y_in++)
    {
      for (int x_in = iMin.x; x_in < iMax.x ; x_in++)
      {
        bool
          isNoValue;

        float
          red = GetVoxelFloat(x_in, y_in, z_in, isNoValue);

        if (isNoValue)
        {
          if (nIsNoValueColorVisible != 0)
          {
            return false;
          }
        }

        float
          rTextureLookupPosition = (red + rOffset) * rScale;
        
        rTextureLookupPosition = clamp (rTextureLookupPosition, 0, 1);
        
        vec4
          vARGB = texture (transferFunctionData, rTextureLookupPosition);

        float
          rAlpha = vARGB.w;

        bool
          isVisible = rAlpha != 0;

        if (isVisible)
        {
          return false;
        }
      }
    }
  }

  return true;             
}

