                 float3 p = *(float3*)(&cuConstRendererParams.position[index3]);
                 float2 pixelCenterNorm = make_float2(invWidth * (static_cast<float>(imageX) + 0.5f),
                                                      invHeight * (static_cast<float>(imageY) + 0.5f));
-                shadePixel(circleInBlock[i]+thread_iter,pixelCenterNorm, p, imgPtr);
+                shadePixel(circleInBlock[i]+thread_iter,pixelCenterNorm, p, &imgPtr);
         }
-        __syncthreads();
-    }
+    }
+    *(float4*)(&cuConstRendererParams.imageData[offset]) = imgPtr;
+    //if (!threadIdx.x and !threadIdx.y){
+    //    image[];
+    //}
 }
 
 

    float boxB = (float)(blockIdx.y * blockDim.y)/height;
    float boxT = (float)((blockIdx.y+1) * blockDim.y)/height;

    int linearThreadIndex = threadIdx.y * blockDim.x+threadIdx.x;

    //The loop guard ensures all threads will enter the for loop, no matter whether it corresponds to a circle
    //Example of possible thread_iter value: 0, 256, 512,...

    __shared__ uint scanOutput[THREADS_PER_BLK];
    __shared__ uint scanScratch[2 * THREADS_PER_BLK];
    __shared__ int circleInBlock[THREADS_PER_BLK];
    //__shared__ float4 imgDataBlock[THREADS_PER_BLK];

    int imageX = blockIdx.x * blockDim.x + threadIdx.x;
    int imageY = blockIdx.y * blockDim.y + threadIdx.y;
