 
    // do the computation on the device
 #define compositeNearest(sliceStep, principal) \
-   compositeSlicesNearest<1, sliceStep, principal> <<<to-from, 128, intImg->width*vvSoftImg::PIXEL_SIZE>>>( \
+   compositeSlicesNearest<1, sliceStep, principal> <<<to-from, 128, intImg->width*vvSoftImg::PIXEL_SIZE+vd->vox[principal]*vd->getBPV()>>>( \
          d_img, intImg->width, intImg->height, \
          d_voxels+vd->getBPV()*principal*(vd->vox[0]*vd->vox[1]*vd->vox[2]), \
          firstSlice, lastSlice, \

        // the voxel row of the current slice corresponding to this image line
        const uchar *voxLine = voxels +BPV * (MUL24(slice+1,MUL24(c_vox[principal+1],c_vox[principal+0]))
                + MUL24((iPosY-line-1),c_vox[principal+0]));

        // Traverse intermediate image pixels which correspond to the current slice.
        // 1 is subtracted from each loop counter to remain inside of the volume boundaries:

        return;

    // initialise intermediate image line
    __shared__ extern uchar smem[];
    uchar4 *imgLine = (uchar4 *)smem;
    uchar *voxel = smem+width*4;
    for (int ix=threadIdx.x; ix<width; ix+=blockDim.x)
    {
        imgLine[ix] = make_uchar4(0,0,0,0);
