34 template<
typename VolumeType,
typename IsVoxelTransparentCallback>
42 POLYVOX_ASSERT(volInput->getWidth() % arrayResult->
getDimension(0) == 0,
"Volume width must be an exact multiple of array width.");
43 POLYVOX_ASSERT(volInput->getHeight() % arrayResult->
getDimension(1) == 0,
"Volume height must be an exact multiple of array height.");
44 POLYVOX_ASSERT(volInput->getDepth() % arrayResult->
getDimension(2) == 0,
"Volume depth must be an exact multiple of array depth.");
55 const int iRatioX = volInput->getWidth() / arrayResult->
getDimension(0);
56 const int iRatioY = volInput->getHeight() / arrayResult->
getDimension(1);
57 const int iRatioZ = volInput->getDepth() / arrayResult->
getDimension(2);
59 const float fRatioX = iRatioX;
60 const float fRatioY = iRatioY;
61 const float fRatioZ = iRatioZ;
64 const float fHalfRatioX = fRatioX * 0.5f;
65 const float fHalfRatioY = fRatioY * 0.5f;
66 const float fHalfRatioZ = fRatioZ * 0.5f;
67 const Vector3DFloat v3dHalfRatio(fHalfRatioX, fHalfRatioY, fHalfRatioZ);
81 v3dStart -= v3dOffset;
82 v3dStart += v3dHalfRatio;
87 for(
int ct = 0; ct < uNoOfSamplesPerOutputElement; ct++)
92 v3dJitter *= v3dHalfRatio;
96 v3dRayDirection *= fRayLength;
105 ++uVisibleDirections;
110 if(uNoOfSamplesPerOutputElement == 0)
118 fVisibility =
static_cast<float>(uVisibleDirections) / static_cast<float>(uNoOfSamplesPerOutputElement);
119 POLYVOX_ASSERT((fVisibility >= 0.0f) && (fVisibility <= 1.0f),
"Visibility value out of range.");
122 (*arrayResult)[z / iRatioZ][y / iRatioY][x / iRatioX] =
static_cast<uint8_t>(255.0f * fVisibility);