   float3 sample1;
   float3 sample2;
   const float DELTA = 0.01f;
-  sample1.x = volume(pos - make_float3(DELTA, 0.0f, 0.0f));
-  sample2.x = volume(pos + make_float3(DELTA, 0.0f, 0.0f));
-  sample1.y = volume(pos - make_float3(0.0f, DELTA, 0.0f));
-  sample2.y = volume(pos + make_float3(0.0f, DELTA, 0.0f));
-  sample1.z = volume(pos - make_float3(0.0f, 0.0f, DELTA));
-  sample2.z = volume(pos + make_float3(0.0f, 0.0f, DELTA));
+  sample1.x = volume<bpc>(pos - make_float3(DELTA, 0.0f, 0.0f));
+  sample2.x = volume<bpc>(pos + make_float3(DELTA, 0.0f, 0.0f));
+  sample1.y = volume<bpc>(pos - make_float3(0.0f, DELTA, 0.0f));
+  sample2.y = volume<bpc>(pos + make_float3(0.0f, DELTA, 0.0f));
+  sample1.z = volume<bpc>(pos - make_float3(0.0f, 0.0f, DELTA));
+  sample2.z = volume<bpc>(pos + make_float3(0.0f, 0.0f, DELTA));
 
   N = normalize(sample2 - sample1);
 


    float3 texCoord = calcTexCoord(pos, volSizeHalf);

    const float sample = volume(texCoord/* + randOffset*/);

    // Post-classification transfer-function lookup.
    float4 src;

  const float3 H = normalize(L + V);

  // Clip sphere.
  const float3 center = make_float3(_renderState._roiPos[0],
                                    _renderState._roiPos[1],
                                    _renderState._roiPos[2]);//make_float3(0.0f, 128.0f, 128.0f);
  const float radius = _renderState._roiSize[0] * vd->getSize()[0];//150;

  // Clip plane.
  const float3 pnormal = normalize(make_float3(0.0f, 0.71f, 0.63f));
  const float pdist = 0.0f;

  if (vd->bpc == 1)
  {
      render<
             true, // Front to back.
             1, // Bytes per channel.
             0, // Mip mode.
             true, // Local illumination.
             true, // Opacity correction.
             false, // Jittering.
             false, // Clip sphere.
             false // Clip plane.
            ><<<gridSize, blockSize>>>(d_output, width, height,
                                       diagonalVoxels / (float)numSlices,
                                       volSize * 0.5f,
                                       L, H,
                                       center, radius * radius,
                                       pnormal, pdist);
  }
  else if (vd->bpc == 2)
  {
      render<
             true, // Front to back.
             2, // Bytes per channel.
             0, // Mip mode.
             true, // Local illumination.
             true, // Opacity correction.
             false, // Jittering.
             false, // Clip sphere.
             false // Clip plane.
            ><<<gridSize, blockSize>>>(d_output, width, height,
                                       diagonalVoxels / (float)numSlices,
                                       volSize * 0.5f,
                                       L, H,
                                       center, radius * radius,
                                       pnormal, pdist);
  }
  cudaGLUnmapBufferObject(_pbo);

  glBindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB, _pbo);
  glBindTexture(GL_TEXTURE_2D, _gltex);
