 }
 
 template<bool frontToBack>
-__global__ void render(uint *d_output, const uint width, const uint height, const float dist)
+__global__ void render(uint *d_output, const uint width, const uint height, const float dist,
+                       const float3 volSize)
 {
   const int maxSteps = 10000;
   const float tstep = dist;
   const float opacityThreshold = 0.95f;
-  const float3 boxMin = make_float3(-1.0f, -1.0f, -1.0f);
-  const float3 boxMax = make_float3(1.0f, 1.0f, 1.0f);
+  const float3 boxMin = make_float3(-volSize.x, -volSize.y, -volSize.z);
+  const float3 boxMax = make_float3(volSize.x, volSize.y, volSize.z);
 
   const uint x = blockIdx.x * blockDim.x + threadIdx.x;
   const uint y = blockIdx.y * blockDim.y + threadIdx.y;


  float4 dst = make_float4(0.0f);
  float t = tnear;
  float3 pos = eyeRay.o + eyeRay.d*tnear;
  float3 step = eyeRay.d * tstep;

  for (int i=0; i<maxSteps; ++i)
  {
    const float sample = tex3D(volTexture,
                               pos.x * 0.5f + 0.5f,
                               pos.y * 0.5f + 0.5f,
                               pos.z * 0.5f + 0.5f);

    // Post-classification transfer-function lookup.
    float4 src = tex1D(tfTexture, sample);

    return ((tmax >= tmin) && (tmax >= 0.0f));
}

__device__ float4 mul(const matrix4x4& M, const float4& v)
{
    float4 r;
    r.x = dot(v, M.m[0]);
