     const float sample = volume<t_bpc>(texCoord);
 
     // Post-classification transfer-function lookup.
-    float4 src;
-
-    if (t_mipMode == 0)
-    {
-      src = tex1D(tfTexture, sample);
-    }
-    else if ((t_mipMode == 1) && (sample > maxIntensity))
-    {
-      dst = tex1D(tfTexture, sample);
-      maxIntensity = sample;
-    }
-    else if ((t_mipMode == 2) && (sample  < minIntensity))
-    {
-      dst = tex1D(tfTexture, sample);
-      minIntensity = sample;
+    float4 src = tex1D(tfTexture, sample);
+
+    if (t_mipMode == 1)
+    {
+      dst.x = fmaxf(src.x, dst.x);
+      dst.y = fmaxf(src.y, dst.y);
+      dst.z = fmaxf(src.z, dst.z);
+      dst.w = 1;
+    }
+    else if (t_mipMode == 2)
+    {
+      dst.x = fminf(src.x, dst.x);
+      dst.y = fminf(src.y, dst.y);
+      dst.z = fminf(src.z, dst.z);
+      dst.w = 1;
     }
 
     // Local illumination.

         bool t_clipSphere,
         bool t_useSphereAsProbe
        >
renderKernel getKernelWithSphereAsProbe(vvRayRend*)
{
  return &render<t_earlyRayTermination, // Early ray termination.
                 true, // Space skipping.
                 true, // Front to back.
                 t_bpc, // Bytes per channel.
                 0, // Mip mode.
                 t_illumination, // Local illumination.
                 t_opacityCorrection, // Opacity correction.
                 false, // Jittering.
                 t_clipPlane, // Clip plane.
                 t_clipSphere, // Clip sphere.
                 t_useSphereAsProbe // Show what's inside the clip sphere.
                >;
}

template<

typedef void(*renderKernel)(uchar4*, const uint, const uint, const uint, const float, const float3, const float3,
                            const float3, const float3, const float3, const float3, const float3,
                            const float, const float3, const float);

template<
         int t_bpc,
         bool t_illumination,
         bool t_opacityCorrection,
         bool t_earlyRayTermination,
         bool t_clipPlane,
         bool t_clipSphere,
         bool t_useSphereAsProbe,
         int t_mipMode
        >
renderKernel getKernelWithMip(vvRayRend*)
{
  return &render<t_earlyRayTermination, // Early ray termination.
                 true, // Space skipping.
                 true, // Front to back.
                 t_bpc, // Bytes per channel.
                 t_mipMode, // Mip mode.
                 t_illumination, // Local illumination.
                 t_opacityCorrection, // Opacity correction.
                 false, // Jittering.
                 t_clipPlane, // Clip plane.
                 t_clipSphere, // Clip sphere.
                 t_useSphereAsProbe // Show what's inside the clip sphere.
                >;
}

template<
         int t_bpc,
