Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 41 additions & 5 deletions Sources/Rendering/OpenGL/glsl/vtkVolumeFS.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,29 @@ vec3 getColorFromTexture(float scalar, int component, float height) {
return texture2D(colorTexture, vec2(scaledScalar, height)).rgb;
}

float getRadonOpacity(vec4 tValue) {
#ifdef EnabledIndependentComponents
return getOpacityFromTexture(tValue.r, 0, 0.5);
#else
#if vtkNumberOfComponents == 1
return getOpacityFromTexture(tValue.r, 0, 0.5);
#endif
#if vtkNumberOfComponents == 2
return getOpacityFromTexture(tValue.a, 1, 0.5);
#endif
#if vtkNumberOfComponents == 3
return getOpacityFromTexture(tValue.a, 0, 0.5);
Comment thread
finetjul marked this conversation as resolved.
#endif
#if vtkNumberOfComponents == 4
return getOpacityFromTexture(tValue.a, 3, 0.5);
#endif
#endif
}

vec3 getRadonColor(float normalizedRayIntensity) {
return texture2D(colorTexture, vec2(normalizedRayIntensity, 0.5)).rgb;
}

//=======================================================================
// transformation between VC and IS space

Expand Down Expand Up @@ -1554,20 +1577,26 @@ void applyBlend(vec3 rayOriginVC, vec3 rayDirVC, float minDistance,

#if vtkBlendMode == RADON_TRANSFORM_BLEND
float normalizedRayIntensity = 1.0;
vec3 posVC = rayOriginVC + minDistance * rayDirVC;
vec3 firstPosVC = rayOriginVC + minDistance * rayDirVC;
vec3 posVC = firstPosVC;
float stepsTraveled = 0.0;

// handle very thin volumes
if (raySteps <= 1.0) {
vec3 posIS = posVCtoIS(posVC);
vec4 tValue = getTextureValue(posIS);
normalizedRayIntensity -= raySteps * sampleDistance *
getOpacityFromTexture(tValue.r, 0, 0.5);
getRadonOpacity(tValue);
gl_FragData[0] =
vec4(getColorFromTexture(normalizedRayIntensity, 0, 0.5), 1.0);
vec4(getRadonColor(normalizedRayIntensity), 1.0);
return;
}

vec3 firstPosIS = posVCtoIS(firstPosVC);
vec4 firstValue = getTextureValue(firstPosIS);
normalizedRayIntensity -=
jitter * sampleDistance * getRadonOpacity(firstValue);

posVC += jitter * stepVC;
stepsTraveled += jitter;

Expand All @@ -1581,15 +1610,22 @@ void applyBlend(vec3 rayOriginVC, vec3 rayDirVC, float minDistance,
// Convert scalar value to normalizedRayIntensity coefficient and
// accumulate normalizedRayIntensity
normalizedRayIntensity -=
sampleDistance * getOpacityFromTexture(value.r, 0, 0.5);
sampleDistance * getRadonOpacity(value);

posVC += stepVC;
stepsTraveled++;
}

if ((raySteps - stepsTraveled) > 0.0) {
vec3 endPosIS = posVCtoIS(rayOriginVC + maxDistance * rayDirVC);
vec4 endValue = getTextureValue(endPosIS);
normalizedRayIntensity -=
(raySteps - stepsTraveled) * sampleDistance * getRadonOpacity(endValue);
}

// map normalizedRayIntensity to color
gl_FragData[0] =
vec4(getColorFromTexture(normalizedRayIntensity, 0, 0.5), 1.0);
vec4(getRadonColor(normalizedRayIntensity), 1.0);
#endif

#if vtkBlendMode == LABELMAP_EDGE_PROJECTION_BLEND
Expand Down
Loading