                 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[];
+    //}
 }
 
 

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

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

    if (imageX >= width || imageY >= height)
        return;

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

    int offset = 4 * (imageY * width + imageX);

    //new things
    //imgDataBlock[linearThreadIndex] = *(float4*)(&cuConstRendererParams.imageData[offset]);
    //float4* imgPtr = (float4*)(&imgDataBlock[linearThreadIndex]);
    float4 imgPtr = *(float4*)(&cuConstRendererParams.imageData[offset]);

    float invWidth = 1.f / width;
    float invHeight = 1.f / height;
