       // residual distance
       posIS += (residual - 1.0) * stepIS;
 
-      // compute the scalar
-      scalar = getTextureValue(posIS).r;
+      // Obtain the value at this position (scalar or vector, depending on the number of components)
+      tValue = getTextureValue(posIS);
 
       // Update the minimum/maximum value if necessary
-      value = max(scalar, value);
+      value = max(tValue, value);
     } else {
       // Sample along the ray until MaximumSamplesValue,
       // ending slightly inside the total distance
       for (int i = 0; i < //VTK::MaximumSamplesValue ; ++i)
       {
         // compute the scalar
-        scalar = getTextureValue(posIS).r;
+        tValue = getTextureValue(posIS);
 
         // Update the minimum value if necessary
-        value = min(scalar, value);
+        value = min(tValue, value);
 
         posIS += stepIS;
         if (i >= count) { break; }

        posIS += (residual - 1.0)*stepIS;

        // compute the scalar
        vec4 tValue = getTextureValue(posIS);

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

        float mix = (1.0 - color.a);
        color = color + vec4(tColor.rgb*tColor.a, tColor.a)*mix;

    // handle lighting
    //VTK::Light::Impl

    gl_FragData[0] = tColor;
  #endif
}

