   #endif
   #if vtkBlendMode == 1 || vtkBlendMode == 2
     // MAXIMUM_INTENSITY_BLEND || MINIMUM_INTENSITY_BLEND
-    // Find maximum/minimum intensity along the ray before
-    // mapping to a color
-    float value = getTextureValue(posIS).r;
+    // Find maximum/minimum intensity along the ray.
+    vec4 value = getTextureValue(posIS);
 
     // TODO: Might be a cleaner way to write this? Can we set
     // operator = min or operator = max instead of duplicating

    for (i = 0; i < //VTK::MaximumSamplesValue ; ++i)
    {
      // compute the scalar
      scalar = getTextureValue(posIS).r;

      // One can control the scalar range by setting the AverageIPScalarRange to disregard scalar values, not in the range of interest, from the average computation
      if (scalar < averageIPScalarRangeMin || scalar > averageIPScalarRangeMax) {
        continue;
      }

      // Average intensity blend mode works similar to the additive blend mode where the scalar values are multiplied by opacity calculated from the opacity transfer function and then added
      computed = texture2D(otexture, vec2(scalar * oscale0 + oshift0, 0.5)).r;

      // Sum the values across each step in the path
      value += computed;

      posIS += stepIS;
      if (i >= count) { break; }


  // local vars for the loop
  vec4 color = vec4(0.0, 0.0, 0.0, 0.0);
  vec4 tValue;
  vec4 tColor;

  int blendMode = //VTK::BlendMode;
  #if vtkBlendMode == 0 // COMPOSITE_BLEND
    for (int i = 0; i < //VTK::MaximumSamplesValue ; ++i)
      {
        // compute the scalar
        tValue = getTextureValue(posIS);

        // now map through opacity and color
        tColor = getColorForValue(tValue, posIS, tstep);

        float mix = (1.0 - color.a);

