@@ -309,6 +309,30 @@ vec3 getColorFromTexture(float scalar, int component, float height) {
309309 return texture2D (colorTexture, vec2 (scaledScalar, height)).rgb;
310310}
311311
312+ float getRadonOpacity(vec4 tValue) {
313+ #ifdef EnabledIndependentComponents
314+ return getOpacityFromTexture(tValue.r, 0 , 0.5 );
315+ #else
316+ #if vtkNumberOfComponents == 1
317+ return getOpacityFromTexture(tValue.r, 0 , 0.5 );
318+ #endif
319+ #if vtkNumberOfComponents == 2
320+ return getOpacityFromTexture(tValue.a, 1 , 0.5 );
321+ #endif
322+ #if vtkNumberOfComponents == 3
323+ return getOpacityFromTexture(tValue.a, 0 , 0.5 );
324+ #endif
325+ #if vtkNumberOfComponents == 4
326+ return getOpacityFromTexture(tValue.a, 3 , 0.5 );
327+ #endif
328+ #endif
329+ }
330+
331+ vec3 getRadonColor(float normalizedRayIntensity) {
332+ float colorCoord = clamp (normalizedRayIntensity, 0.0 , 1.0 );
333+ return texture2D (colorTexture, vec2 (colorCoord, 0.5 )).rgb;
334+ }
335+
312336// =======================================================================
313337// transformation between VC and IS space
314338
@@ -1554,20 +1578,26 @@ void applyBlend(vec3 rayOriginVC, vec3 rayDirVC, float minDistance,
15541578
15551579 #if vtkBlendMode == RADON_TRANSFORM_BLEND
15561580 float normalizedRayIntensity = 1.0 ;
1557- vec3 posVC = rayOriginVC + minDistance * rayDirVC;
1581+ vec3 firstPosVC = rayOriginVC + minDistance * rayDirVC;
1582+ vec3 posVC = firstPosVC;
15581583 float stepsTraveled = 0.0 ;
15591584
15601585 // handle very thin volumes
15611586 if (raySteps <= 1.0 ) {
15621587 vec3 posIS = posVCtoIS(posVC);
15631588 vec4 tValue = getTextureValue(posIS);
15641589 normalizedRayIntensity -= raySteps * sampleDistance *
1565- getOpacityFromTexture (tValue.r, 0 , 0.5 );
1590+ getRadonOpacity (tValue);
15661591 gl_FragData [0 ] =
1567- vec4 (getColorFromTexture (normalizedRayIntensity, 0 , 0.5 ), 1.0 );
1592+ vec4 (getRadonColor (normalizedRayIntensity), 1.0 );
15681593 return ;
15691594 }
15701595
1596+ vec3 firstPosIS = posVCtoIS(firstPosVC);
1597+ vec4 firstValue = getTextureValue(firstPosIS);
1598+ normalizedRayIntensity -=
1599+ jitter * sampleDistance * getRadonOpacity(firstValue);
1600+
15711601 posVC += jitter * stepVC;
15721602 stepsTraveled += jitter;
15731603
@@ -1581,15 +1611,24 @@ void applyBlend(vec3 rayOriginVC, vec3 rayDirVC, float minDistance,
15811611 // Convert scalar value to normalizedRayIntensity coefficient and
15821612 // accumulate normalizedRayIntensity
15831613 normalizedRayIntensity -=
1584- sampleDistance * getOpacityFromTexture (value.r, 0 , 0.5 );
1614+ sampleDistance * getRadonOpacity (value);
15851615
15861616 posVC += stepVC;
15871617 stepsTraveled++ ;
15881618 }
15891619
1620+ if ((raySteps - stepsTraveled) > 0.0 ) {
1621+ vec3 endPosIS = clamp (
1622+ posVCtoIS(rayOriginVC + maxDistance * rayDirVC),
1623+ vec3 (0.0 ), vec3 (1.0 ));
1624+ vec4 endValue = getTextureValue(endPosIS);
1625+ normalizedRayIntensity -=
1626+ (raySteps - stepsTraveled) * sampleDistance * getRadonOpacity(endValue);
1627+ }
1628+
15901629 // map normalizedRayIntensity to color
15911630 gl_FragData [0 ] =
1592- vec4 (getColorFromTexture (normalizedRayIntensity, 0 , 0.5 ), 1.0 );
1631+ vec4 (getRadonColor (normalizedRayIntensity), 1.0 );
15931632 #endif
15941633
15951634 #if vtkBlendMode == LABELMAP_EDGE_PROJECTION_BLEND
0 commit comments