This commit is contained in:
Matias Lavik 2022-03-22 21:58:42 +01:00
Родитель 1fecae6908
Коммит 6ef93e1a49
1 изменённых файлов: 7 добавлений и 3 удалений

Просмотреть файл

@ -261,6 +261,7 @@
float stepSize = 1.0 / NUM_STEPS; float stepSize = 1.0 / NUM_STEPS;
float maxDensity = 0.0f; float maxDensity = 0.0f;
float3 maxDensityPos = rayStartPos;
for (uint iStep = 0; iStep < NUM_STEPS; iStep++) for (uint iStep = 0; iStep < NUM_STEPS; iStep++)
{ {
const float t = iStep * stepSize; const float t = iStep * stepSize;
@ -272,15 +273,18 @@
#endif #endif
const float density = getDensity(currPos); const float density = getDensity(currPos);
if (density > _MinVal && density < _MaxVal) if (density > maxDensity && density > _MinVal && density < _MaxVal)
maxDensity = max(density, maxDensity); {
maxDensity = density;
maxDensityPos = currPos;
}
} }
// Write fragment output // Write fragment output
frag_out output; frag_out output;
output.colour = float4(1.0f, 1.0f, 1.0f, maxDensity); // maximum intensity output.colour = float4(1.0f, 1.0f, 1.0f, maxDensity); // maximum intensity
#if DEPTHWRITE_ON #if DEPTHWRITE_ON
output.depth = localToDepth(i.vertexLocal); output.depth = localToDepth(maxDensityPos - float3(0.5f, 0.5f, 0.5f));
#endif #endif
return output; return output;
} }