From 1aa33e8e144a80894470a6da046be2ed8947188a Mon Sep 17 00:00:00 2001 From: Martin Opat Date: Sat, 11 Jan 2025 14:59:27 +0100 Subject: [PATCH] Fixed rays not interacting with missing volume incorrectly when number of samples > 1 --- src/consts.h | 4 ++-- src/illumination/Raycaster.cu | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/consts.h b/src/consts.h index d53abff..2686450 100644 --- a/src/consts.h +++ b/src/consts.h @@ -26,9 +26,9 @@ const float MAX_SPEED = 14.0f; // --------------------------- Raycasting Constants --------------------------- -const int SAMPLES_PER_PIXEL = 1; +const int SAMPLES_PER_PIXEL = 4; -const float alphaAcumLimit = 1.0f; // TODO: Atm, this does not work very intuitively, other parameters control transparency +const float alphaAcumLimit = 0.4f; // TODO: Atm, this only works with sigmoid const float minAllowedDensity = 0.001f; const float stepSize = 0.02f; diff --git a/src/illumination/Raycaster.cu b/src/illumination/Raycaster.cu index c9015cf..b2d1939 100644 --- a/src/illumination/Raycaster.cu +++ b/src/illumination/Raycaster.cu @@ -21,7 +21,7 @@ __global__ void raycastKernel(float* volumeData, FrameBuffer framebuffer) { float accumR = 0.0f; float accumG = 0.0f; float accumB = 0.0f; - float accumA = 1.0f; + float accumA = 1.0f * (float)SAMPLES_PER_PIXEL; // Initialize random state for ray scattering curandState randState; @@ -77,6 +77,7 @@ __global__ void raycastKernel(float* volumeData, FrameBuffer framebuffer) { accumG = d_backgroundColor.y * (float)SAMPLES_PER_PIXEL; accumB = d_backgroundColor.z * (float)SAMPLES_PER_PIXEL; accumA = 1.0f * (float)SAMPLES_PER_PIXEL; + } else { if (tNear < 0.0f) tNear = 0.0f;