16 #ifndef vtkVolumeShaderComposer_h 17 #define vtkVolumeShaderComposer_h 49 std::string::size_type pos = 0;
51 while ((pos =
source.find(search, 0)) != std::string::npos)
54 pos += search.length();
73 \n vec4 pos = in_projectionMatrix * in_modelViewMatrix *\ 74 \n in_volumeMatrix * vec4(in_vertexPos.xyz, 1.0);\ 75 \n gl_Position = pos;" 85 "\n // For point dataset, we offset the texture coordinate\ 86 \n // to account for OpenGL treating voxel at the center of the cell.\ 87 \n vec3 uvx = sign(in_cellSpacing) * (in_vertexPos - in_volumeExtentsMin) /\ 88 \n (in_volumeExtentsMax - in_volumeExtentsMin);\ 92 \n ip_textureCoords = uvx;\ 93 \n ip_inverseTextureDataAdjusted = in_inverseTextureDatasetMatrix;\ 97 \n // Transform cell tex-coordinates to point tex-coordinates\ 98 \n ip_textureCoords = (in_cellToPoint * vec4(uvx, 1.0)).xyz;\ 99 \n ip_inverseTextureDataAdjusted = in_cellToPoint * in_inverseTextureDatasetMatrix;\ 109 \n uniform bool in_cellFlag;\ 110 \n uniform vec3 in_cellSpacing;\ 111 \n uniform mat4 in_modelViewMatrix;\ 112 \n uniform mat4 in_projectionMatrix;\ 113 \n uniform mat4 in_volumeMatrix;\ 115 \n uniform vec3 in_volumeExtentsMin;\ 116 \n uniform vec3 in_volumeExtentsMax;\ 118 \n uniform mat4 in_inverseTextureDatasetMatrix;\ 119 \n uniform mat4 in_cellToPoint;\ 120 \n uniform vec3 in_textureExtentsMax;\ 121 \n uniform vec3 in_textureExtentsMin;\ 123 \n //This variable could be 'invariant varying' but it is declared\ 124 \n //as 'varying' to avoid compiler compatibility issues.\ 125 \n varying mat4 ip_inverseTextureDataAdjusted;");
132 int vtkNotUsed(numberOfLights),
133 int lightingComplexity,
134 bool hasGradientOpacity,
136 int independentComponents)
140 \nuniform sampler3D in_volume;\ 141 \nuniform int in_noOfComponents;\ 142 \nuniform int in_independentComponents;\ 144 \nuniform sampler2D in_noiseSampler;\ 146 \nuniform sampler2D in_depthSampler;\ 149 \n// Camera position\ 150 \nuniform vec3 in_cameraPos;\ 152 \n// view and model matrices\ 153 \nuniform mat4 in_volumeMatrix;\ 154 \nuniform mat4 in_inverseVolumeMatrix;\ 155 \nuniform mat4 in_projectionMatrix;\ 156 \nuniform mat4 in_inverseProjectionMatrix;\ 157 \nuniform mat4 in_modelViewMatrix;\ 158 \nuniform mat4 in_inverseModelViewMatrix;\ 159 \nuniform mat4 in_textureDatasetMatrix;\ 160 \nuniform mat4 in_inverseTextureDatasetMatrix;\ 161 \nvarying mat4 ip_inverseTextureDataAdjusted;\ 162 \nuniform vec3 in_texMin;\ 163 \nuniform vec3 in_texMax;\ 164 \nuniform mat4 in_textureToEye;\ 167 \nuniform vec3 in_cellStep;\ 168 \nuniform vec2 in_scalarsRange[4];\ 169 \nuniform vec3 in_cellSpacing;\ 171 \n// Sample distance\ 172 \nuniform float in_sampleDistance;\ 175 \nuniform vec3 in_cellScale;\ 176 \nuniform vec2 in_windowLowerLeftCorner;\ 177 \nuniform vec2 in_inverseOriginalWindowSize;\ 178 \nuniform vec2 in_inverseWindowSize;\ 179 \nuniform vec3 in_textureExtentsMax;\ 180 \nuniform vec3 in_textureExtentsMin;\ 182 \n// Material and lighting\ 183 \nuniform vec3 in_diffuse[4];\ 184 \nuniform vec3 in_ambient[4];\ 185 \nuniform vec3 in_specular[4];\ 186 \nuniform float in_shininess[4];\ 189 \nuniform bool in_cellFlag;\ 190 \nuniform bool in_useJittering;\ 191 \nvec3 g_rayJitter = vec3(0.0);\ 192 \nuniform bool in_clampDepthToBackface;\ 194 \nuniform vec2 in_averageIPRange;" 197 if (lightingComplexity > 0 || hasGradientOpacity)
200 \nuniform bool in_twoSidedLighting;\ 206 if (hasGradientOpacity)
210 \nvec3 g_cellSpacing;\ 211 \nfloat g_avgSpacing;");
214 if (lightingComplexity == 3)
217 \nvec4 g_fragWorldPos;\ 218 \nuniform int in_numberOfLights;\ 219 \nuniform vec3 in_lightAmbientColor[6];\ 220 \nuniform vec3 in_lightDiffuseColor[6];\ 221 \nuniform vec3 in_lightSpecularColor[6];\ 222 \nuniform vec3 in_lightDirection[6];\ 223 \nuniform vec3 in_lightPosition[6];\ 224 \nuniform vec3 in_lightAttenuation[6];\ 225 \nuniform float in_lightConeAngle[6];\ 226 \nuniform float in_lightExponent[6];\ 227 \nuniform int in_lightPositional[6];\ 230 else if (lightingComplexity == 2)
233 \nvec4 g_fragWorldPos;\ 234 \nuniform int in_numberOfLights;\ 235 \nuniform vec3 in_lightAmbientColor[6];\ 236 \nuniform vec3 in_lightDiffuseColor[6];\ 237 \nuniform vec3 in_lightSpecularColor[6];\ 238 \nuniform vec3 in_lightDirection[6];\ 244 \nuniform vec3 in_lightAmbientColor[1];\ 245 \nuniform vec3 in_lightDiffuseColor[1];\ 246 \nuniform vec3 in_lightSpecularColor[1];\ 247 \nvec4 g_lightPosObj;\ 253 if (noOfComponents > 1 && independentComponents)
256 \nuniform vec4 in_componentWeight;");
265 \nuniform sampler2D in_depthPassSampler;");
275 int lightingComplexity)
281 \n bool l_adjustTextureExtents = !in_cellFlag;" 290 \n vec2 fragTexCoord2 = (gl_FragCoord.xy - in_windowLowerLeftCorner) *\ 291 \n in_inverseWindowSize;\ 292 \n vec4 depthValue = texture2D(in_depthPassSampler, fragTexCoord2);\ 293 \n vec4 dataPos = WindowToNDC(gl_FragCoord.x, gl_FragCoord.y, depthValue.x);\ 295 \n // From normalized device coordinates to eye coordinates.\ 296 \n // in_projectionMatrix is inversed because of way VT\ 297 \n // From eye coordinates to texture coordinates\ 298 \n dataPos = in_inverseTextureDatasetMatrix *\ 299 \n in_inverseVolumeMatrix *\ 300 \n in_inverseModelViewMatrix *\ 301 \n in_inverseProjectionMatrix *\ 303 \n dataPos /= dataPos.w;\ 304 \n g_dataPos = dataPos.xyz;\ 305 \n l_adjustTextureExtents = true;" 311 \n // Get the 3D texture coordinates for lookup into the in_volume dataset\ 312 \n g_dataPos = ip_textureCoords.xyz;" 318 \n // Eye position in dataset space\ 319 \n g_eyePosObj = (in_inverseVolumeMatrix * vec4(in_cameraPos, 1.0));\ 320 \n if (g_eyePosObj.w != 0.0)\ 322 \n g_eyePosObj.x /= g_eyePosObj.w;\ 323 \n g_eyePosObj.y /= g_eyePosObj.w;\ 324 \n g_eyePosObj.z /= g_eyePosObj.w;\ 325 \n g_eyePosObj.w = 1.0;\ 328 \n // Getting the ray marching direction (in dataset space);\ 329 \n vec3 rayDir = computeRayDirection();\ 331 \n // Multiply the raymarching direction with the step size to get the\ 332 \n // sub-step size we need to take at each raymarching step\ 333 \n g_dirStep = (ip_inverseTextureDataAdjusted *\ 334 \n vec4(rayDir, 0.0)).xyz * in_sampleDistance;\ 336 \n // 2D Texture fragment coordinates [0,1] from fragment coordinates.\ 337 \n // The frame buffer texture has the size of the plain buffer but \ 338 \n // we use a fraction of it. The texture coordinate is less than 1 if\ 339 \n // the reduction factor is less than 1.\ 340 \n // Device coordinates are between -1 and 1. We need texture\ 341 \n // coordinates between 0 and 1. The in_noiseSampler and in_depthSampler\ 342 \n // buffers have the original size buffer.\ 343 \n vec2 fragTexCoord = (gl_FragCoord.xy - in_windowLowerLeftCorner) *\ 344 \n in_inverseWindowSize;\ 346 \n if (in_useJittering)\ 348 \n float jitterValue = texture2D(in_noiseSampler, fragTexCoord).x;\ 349 \n g_rayJitter = g_dirStep * jitterValue;\ 350 \n g_dataPos += g_rayJitter;\ 354 \n g_dataPos += g_dirStep;\ 357 \n // Flag to deternmine if voxel should be considered for the rendering\ 358 \n g_skip = false;");
363 \n // Light position in dataset space\ 364 \n g_lightPosObj = (in_inverseVolumeMatrix *\ 365 \n vec4(in_cameraPos, 1.0));\ 366 \n if (g_lightPosObj.w != 0.0)\ 368 \n g_lightPosObj.x /= g_lightPosObj.w;\ 369 \n g_lightPosObj.y /= g_lightPosObj.w;\ 370 \n g_lightPosObj.z /= g_lightPosObj.w;\ 371 \n g_lightPosObj.w = 1.0;\ 373 \n g_ldir = normalize(g_lightPosObj.xyz - ip_vertexPos);\ 374 \n g_vdir = normalize(g_eyePosObj.xyz - ip_vertexPos);\ 375 \n g_h = normalize(g_ldir + g_vdir);" 383 \n g_xvec = vec3(in_cellStep[0], 0.0, 0.0);\ 384 \n g_yvec = vec3(0.0, in_cellStep[1], 0.0);\ 385 \n g_zvec = vec3(0.0, 0.0, in_cellStep[2]);" 392 \n g_cellSpacing = vec3(in_cellSpacing[0],\ 393 \n in_cellSpacing[1],\ 394 \n in_cellSpacing[2]);\ 395 \n g_avgSpacing = (g_cellSpacing[0] +\ 396 \n g_cellSpacing[1] +\ 397 \n g_cellSpacing[2])/3.0;\ 398 \n // Adjust the aspect\ 399 \n g_aspect.x = g_cellSpacing[0] * 2.0 / g_avgSpacing;\ 400 \n g_aspect.y = g_cellSpacing[1] * 2.0 / g_avgSpacing;\ 401 \n g_aspect.z = g_cellSpacing[2] * 2.0 / g_avgSpacing;" 431 int independentComponents,
432 std::map<int, std::string>
437 (noOfComponents == 1 || !independentComponents))
440 \nuniform sampler2D in_gradientTransferFunc;\ 441 \nfloat computeGradientOpacity(vec4 grad)\ 443 \n return texture2D("+gradientTableMap[0]+
", vec2(grad.w, 0.0)).r;\ 447 else if (noOfComponents > 1 && independentComponents &&
450 std::ostringstream toString;
451 for (
int i = 0; i < noOfComponents; ++i)
453 shaderStr +=
std::string(
"\n uniform sampler2D ") +
458 \nfloat computeGradientOpacity(vec4 grad, int component)\ 461 for (
int i = 0; i < noOfComponents; ++i)
465 \n if (component == " + toString.str() +
")");
469 \n return texture2D("+ gradientTableMap[i] +
", vec2(grad.w, 0.0)).r;\ 486 \n// c is short for component\ 487 \nvec4 computeGradient(int c)\ 489 \n // Approximate Nabla(F) derivatives with central differences.\ 490 \n vec3 g1; // F_front\ 491 \n vec3 g2; // F_back\ 492 \n g1.x = texture3D(in_volume, vec3(g_dataPos + g_xvec))[c];\ 493 \n g1.y = texture3D(in_volume, vec3(g_dataPos + g_yvec))[c];\ 494 \n g1.z = texture3D(in_volume, vec3(g_dataPos + g_zvec))[c];\ 495 \n g2.x = texture3D(in_volume, vec3(g_dataPos - g_xvec))[c];\ 496 \n g2.y = texture3D(in_volume, vec3(g_dataPos - g_yvec))[c];\ 497 \n g2.z = texture3D(in_volume, vec3(g_dataPos - g_zvec))[c];\ 499 \n // Apply scale and bias to the fetched values.\ 500 \n g1 = g1 * in_volume_scale[c] + in_volume_bias[c];\ 501 \n g2 = g2 * in_volume_scale[c] + in_volume_bias[c];\ 503 \n // Central differences: (F_front - F_back) / 2h\ 504 \n // This version of computeGradient() is only used for lighting\ 505 \n // calculations (only direction matters), hence the difference is\ 506 \n // not scaled by 2h and a dummy gradient mag is returned (-1.).\ 507 \n return vec4((g1 - g2), -1.0);\ 514 \n// c is short for component\ 515 \nvec4 computeGradient(int c)\ 517 \n // Approximate Nabla(F) derivatives with central differences.\ 518 \n vec3 g1; // F_front\ 519 \n vec3 g2; // F_back\ 520 \n g1.x = texture3D(in_volume, vec3(g_dataPos + g_xvec))[c];\ 521 \n g1.y = texture3D(in_volume, vec3(g_dataPos + g_yvec))[c];\ 522 \n g1.z = texture3D(in_volume, vec3(g_dataPos + g_zvec))[c];\ 523 \n g2.x = texture3D(in_volume, vec3(g_dataPos - g_xvec))[c];\ 524 \n g2.y = texture3D(in_volume, vec3(g_dataPos - g_yvec))[c];\ 525 \n g2.z = texture3D(in_volume, vec3(g_dataPos - g_zvec))[c];\ 527 \n // Apply scale and bias to the fetched values.\ 528 \n g1 = g1 * in_volume_scale[c] + in_volume_bias[c];\ 529 \n g2 = g2 * in_volume_scale[c] + in_volume_bias[c];\ 531 \n // Scale values the actual scalar range.\ 532 \n float range = in_scalarsRange[c][1] - in_scalarsRange[c][0];\ 533 \n g1 = in_scalarsRange[c][0] + range * g1;\ 534 \n g2 = in_scalarsRange[c][0] + range * g2;\ 536 \n // Central differences: (F_front - F_back) / 2h\ 539 \n float grad_mag = length(g2);\ 541 \n // Handle normalizing with grad_mag == 0.0\ 542 \n g2 = grad_mag > 0.0 ? normalize(g2) : vec3(0.0);\ 544 \n // Since the actual range of the gradient magnitude is unknown,\ 545 \n // assume it is in the range [0, 0.25 * dataRange].\ 546 \n range = range != 0 ? range : 1.0;\ 547 \n grad_mag = grad_mag / (0.25 * range);\ 548 \n grad_mag = clamp(grad_mag, 0.0, 1.0);\ 550 \n return vec4(g2.xyz, grad_mag);\ 556 \nvec4 computeGradient(int component)\ 558 \n return vec4(0.0);\ 570 int independentComponents,
571 int vtkNotUsed(numberOfLights),
572 int lightingComplexity)
576 \nvec4 computeLighting(vec4 color, int component)\ 578 \n vec4 finalColor = vec4(0.0);" 582 int shadeReqd = volProperty->
GetShade() &&
589 \n // Compute gradient function only once\ 590 \n vec4 gradient = computeGradient(component);" 596 if (lightingComplexity == 1)
599 \n vec3 diffuse = vec3(0.0);\ 600 \n vec3 specular = vec3(0.0);\ 601 \n vec3 normal = gradient.xyz / in_cellSpacing;\ 602 \n float normalLength = length(normal);\ 603 \n if (normalLength > 0.0)\ 605 \n normal = normalize(normal);\ 609 \n normal = vec3(0.0, 0.0, 0.0);\ 611 \n float nDotL = dot(normal, g_ldir);\ 612 \n float nDotH = dot(normal, g_h);\ 613 \n if (nDotL < 0.0 && in_twoSidedLighting)\ 617 \n if (nDotH < 0.0 && in_twoSidedLighting)\ 623 \n diffuse = nDotL * in_diffuse[component] *\ 624 \n in_lightDiffuseColor[0] * color.rgb;\ 626 \n specular = pow(nDotH, in_shininess[component]) *\ 627 \n in_specular[component] *\ 628 \n in_lightSpecularColor[0];\ 629 \n // For the headlight, ignore the light's ambient color\ 630 \n // for now as it is causing the old mapper tests to fail\ 631 \n finalColor.xyz = in_ambient[component] * color.rgb +\ 632 \n diffuse + specular;" 635 else if (lightingComplexity == 2)
638 \n g_fragWorldPos = in_modelViewMatrix * in_volumeMatrix *\ 639 \n in_textureDatasetMatrix * vec4(-g_dataPos, 1.0);\ 640 \n if (g_fragWorldPos.w != 0.0)\ 642 \n g_fragWorldPos /= g_fragWorldPos.w;\ 644 \n vec3 vdir = normalize(g_fragWorldPos.xyz);\ 645 \n vec3 normal = gradient.xyz;\ 646 \n vec3 ambient = vec3(0.0);\ 647 \n vec3 diffuse = vec3(0.0);\ 648 \n vec3 specular = vec3(0.0);\ 649 \n float normalLength = length(normal);\ 650 \n if (normalLength > 0.0)\ 652 \n normal = normalize((in_textureToEye * vec4(normal, 0.0)).xyz);\ 656 \n normal = vec3(0.0, 0.0, 0.0);\ 658 \n for (int lightNum = 0; lightNum < in_numberOfLights; lightNum++)\ 660 \n vec3 ldir = in_lightDirection[lightNum].xyz;\ 661 \n vec3 h = normalize(ldir + vdir);\ 662 \n float nDotH = dot(normal, h);\ 663 \n if (nDotH < 0.0 && in_twoSidedLighting)\ 667 \n float nDotL = dot(normal, ldir);\ 668 \n if (nDotL < 0.0 && in_twoSidedLighting)\ 674 \n diffuse += in_lightDiffuseColor[lightNum] * nDotL;\ 678 \n specular = in_lightSpecularColor[lightNum] *\ 679 \n pow(nDotH, in_shininess[component]);\ 681 \n ambient += in_lightAmbientColor[lightNum];\ 683 \n finalColor.xyz = in_ambient[component] * ambient +\ 684 \n in_diffuse[component] * diffuse * color.rgb +\ 685 \n in_specular[component] * specular;" 688 else if (lightingComplexity == 3)
691 \n g_fragWorldPos = in_modelViewMatrix * in_volumeMatrix *\ 692 \n in_textureDatasetMatrix * vec4(g_dataPos, 1.0);\ 693 \n if (g_fragWorldPos.w != 0.0)\ 695 \n g_fragWorldPos /= g_fragWorldPos.w;\ 697 \n vec3 viewDirection = normalize(-g_fragWorldPos.xyz);\ 698 \n vec3 ambient = vec3(0,0,0);\ 699 \n vec3 diffuse = vec3(0,0,0);\ 700 \n vec3 specular = vec3(0,0,0);\ 701 \n vec3 vertLightDirection;\ 702 \n vec3 normal = normalize((in_textureToEye * vec4(gradient.xyz, 0.0)).xyz);\ 704 \n for (int lightNum = 0; lightNum < in_numberOfLights; lightNum++)\ 706 \n float attenuation = 1.0;\ 708 \n lightDir = in_lightDirection[lightNum];\ 709 \n if (in_lightPositional[lightNum] == 0)\ 711 \n vertLightDirection = lightDir;\ 715 \n vertLightDirection = (g_fragWorldPos.xyz - in_lightPosition[lightNum]);\ 716 \n float distance = length(vertLightDirection);\ 717 \n vertLightDirection = normalize(vertLightDirection);\ 718 \n attenuation = 1.0 /\ 719 \n (in_lightAttenuation[lightNum].x\ 720 \n + in_lightAttenuation[lightNum].y * distance\ 721 \n + in_lightAttenuation[lightNum].z * distance * distance);\ 722 \n // per OpenGL standard cone angle is 90 or less for a spot light\ 723 \n if (in_lightConeAngle[lightNum] <= 90.0)\ 725 \n float coneDot = dot(vertLightDirection, lightDir);\ 726 \n // if inside the cone\ 727 \n if (coneDot >= cos(radians(in_lightConeAngle[lightNum])))\ 729 \n attenuation = attenuation * pow(coneDot, in_lightExponent[lightNum]);\ 733 \n attenuation = 0.0;\ 737 \n // diffuse and specular lighting\ 738 \n float nDotL = dot(normal, vertLightDirection);\ 739 \n if (nDotL < 0.0 && in_twoSidedLighting)\ 745 \n float df = max(0.0, attenuation * nDotL);\ 746 \n diffuse += (df * in_lightDiffuseColor[lightNum]);\ 748 \n vec3 h = normalize(vertLightDirection + viewDirection);\ 749 \n float nDotH = dot(normal, h);\ 750 \n if (nDotH < 0.0 && in_twoSidedLighting)\ 756 \n float sf = attenuation * pow(nDotH, in_shininess[component]);\ 757 \n specular += (sf * in_lightSpecularColor[lightNum]);\ 759 \n ambient += in_lightAmbientColor[lightNum];\ 761 \n finalColor.xyz = in_ambient[component] * ambient +\ 762 \n in_diffuse[component] * diffuse * color.rgb +\ 763 \n in_specular[component] * specular;\ 770 "\n finalColor = vec4(color.rgb, 0.0);" 775 (noOfComponents == 1 || !independentComponents))
778 \n if (gradient.w >= 0.0)\ 780 \n color.a = color.a *\ 781 \n computeGradientOpacity(gradient);\ 785 else if (noOfComponents > 1 && independentComponents &&
789 \n if (gradient.w >= 0.0)\ 791 \n for (int i = 0; i < in_noOfComponents; ++i)\ 793 \n color.a = color.a *\ 794 \n computeGradientOpacity(gradient, i) * in_componentWeight[i];\ 801 \n finalColor.a = color.a;\ 802 \n return finalColor;\ 813 int vtkNotUsed(noOfComponents))
818 \nvec3 computeRayDirection()\ 820 \n return normalize(ip_vertexPos.xyz - g_eyePosObj.xyz);\ 826 \nuniform vec3 in_projectionDirection;\ 827 \nvec3 computeRayDirection()\ 829 \n return normalize((in_inverseVolumeMatrix *\ 830 \n vec4(in_projectionDirection, 0.0)).xyz);\ 840 int independentComponents,
841 std::map<int, std::string> colorTableMap)
843 if (noOfComponents == 1)
846 \nuniform sampler2D in_colorTransferFunc;\ 847 \nvec4 computeColor(vec4 scalar, float opacity)\ 849 \n return computeLighting(vec4(texture2D(in_colorTransferFunc,\ 850 \n vec2(scalar.w, 0.0)).xyz, opacity), 0);\ 853 else if (noOfComponents > 1 && independentComponents)
856 std::ostringstream toString;
857 for (
int i = 0; i < noOfComponents; ++i)
859 shaderStr +=
std::string(
"\n uniform sampler2D ") +
864 \nvec4 computeColor(vec4 scalar, float opacity, int component)\ 867 for (
int i = 0; i < noOfComponents; ++i)
871 \n if (component == " + toString.str() +
")");
875 \n return computeLighting(vec4(texture2D(\ 876 \n "+colorTableMap[i]);
878 \n scalar[" + toString.str() +
"],0.0)).xyz,\ 879 \n opacity),"+toString.str()+
");\ 890 else if (noOfComponents == 2 && !independentComponents)
893 \nuniform sampler2D in_colorTransferFunc;\ 894 \nvec4 computeColor(vec4 scalar, float opacity)\ 896 \n return computeLighting(vec4(texture2D(in_colorTransferFunc,\ 897 \n vec2(scalar.x, 0.0)).xyz,\ 904 \nvec4 computeColor(vec4 scalar, float opacity)\ 906 \n return computeLighting(vec4(scalar.xyz, opacity), 0);\ 916 int independentComponents,
917 std::map<int, std::string> opacityTableMap)
919 if (noOfComponents > 1 && independentComponents)
922 std::ostringstream toString;
924 for (
int i = 0; i < noOfComponents; ++i)
926 shaderStr +=
std::string(
"\n uniform sampler2D ") +
932 \nfloat computeOpacity(vec4 scalar, int component)\ 935 for (
int i = 0; i < noOfComponents; ++i)
939 \n if (component == " + toString.str() +
")");
943 \n return texture2D(in_opacityTransferFunc");
944 shaderStr += (i == 0 ?
"" : toString.str());
945 shaderStr +=
std::string(
",vec2(scalar[" + toString.str() +
"],0)).r;\ 956 else if (noOfComponents == 2 && !independentComponents)
959 \nuniform sampler2D in_opacityTransferFunc;\ 960 \nfloat computeOpacity(vec4 scalar)\ 962 \n return texture2D(in_opacityTransferFunc, vec2(scalar.y, 0)).r;\ 968 \nuniform sampler2D in_opacityTransferFunc;\ 969 \nfloat computeOpacity(vec4 scalar)\ 971 \n return texture2D(in_opacityTransferFunc, vec2(scalar.w, 0)).r;\ 992 \n bool l_firstValue;\ 993 \n vec4 l_maxValue;");
999 \n bool l_firstValue;\ 1000 \n vec4 l_minValue;");
1005 \n uvec4 l_numSamples;\ 1006 \n vec4 l_avgValue;");
1011 \n vec4 l_sumValue;");
1027 \n // We get data between 0.0 - 1.0 range\ 1028 \n l_firstValue = true;\ 1029 \n l_maxValue = vec4(0.0);" 1036 \n //We get data between 0.0 - 1.0 range\ 1037 \n l_firstValue = true;\ 1038 \n l_minValue = vec4(1.0);" 1044 \n //We get data between 0.0 - 1.0 range\ 1045 \n l_avgValue = vec4(0.0);\ 1046 \n // Keep track of number of samples\ 1047 \n l_numSamples = uvec4(0);" 1053 \n //We get data between 0.0 - 1.0 range\ 1054 \n l_sumValue = vec4(0.0);" 1070 int independentComponents = 0)
1077 \n vec4 scalar = texture3D(in_volume, g_dataPos);" 1081 if (noOfComponents == 1)
1084 \n scalar.r = scalar.r*in_volume_scale.r + in_volume_bias.r;\ 1085 \n scalar = vec4(scalar.r,scalar.r,scalar.r,scalar.r);" 1092 \n scalar = scalar*in_volume_scale + in_volume_bias;" 1098 if (noOfComponents > 1)
1100 if (!independentComponents)
1103 \n if (l_maxValue.w < scalar.w || l_firstValue)\ 1105 \n l_maxValue = scalar;\ 1108 \n if (l_firstValue)\ 1110 \n l_firstValue = false;\ 1117 \n for (int i = 0; i < in_noOfComponents; ++i)\ 1119 \n if (l_maxValue[i] < scalar[i] || l_firstValue)\ 1121 \n l_maxValue[i] = scalar[i];\ 1124 \n if (l_firstValue)\ 1126 \n l_firstValue = false;\ 1134 \n if (l_maxValue.w < scalar.x || l_firstValue)\ 1136 \n l_maxValue.w = scalar.x;\ 1139 \n if (l_firstValue)\ 1141 \n l_firstValue = false;\ 1148 if (noOfComponents > 1)
1150 if (!independentComponents)
1153 \n if (l_minValue.w > scalar.w || l_firstValue)\ 1155 \n l_minValue = scalar;\ 1158 \n if (l_firstValue)\ 1160 \n l_firstValue = false;\ 1167 \n for (int i = 0; i < in_noOfComponents; ++i)\ 1169 \n if (l_minValue[i] < scalar[i] || l_firstValue)\ 1171 \n l_minValue[i] = scalar[i];\ 1174 \n if (l_firstValue)\ 1176 \n l_firstValue = false;\ 1184 \n if (l_minValue.w > scalar.x || l_firstValue)\ 1186 \n l_minValue.w = scalar.x;\ 1189 \n if (l_firstValue)\ 1191 \n l_firstValue = false;\ 1198 if (noOfComponents > 1 && independentComponents)
1201 \n for (int i = 0; i < in_noOfComponents; ++i)\ 1203 \n // Get the intensity in volume scalar range\ 1204 \n float intensity = in_scalarsRange[i][0] +\ 1205 \n (in_scalarsRange[i][1] -\ 1206 \n in_scalarsRange[i][0]) * scalar[i];\ 1207 \n if (in_averageIPRange.x <= intensity &&\ 1208 \n intensity <= in_averageIPRange.y)\ 1210 \n l_avgValue[i] += computeOpacity(scalar, i) * scalar[i];\ 1211 \n ++l_numSamples[i];\ 1219 \n // Get the intensity in volume scalar range\ 1220 \n float intensity = in_scalarsRange[0][0] +\ 1221 \n (in_scalarsRange[0][1] -\ 1222 \n in_scalarsRange[0][0]) * scalar.x;\ 1223 \n if (in_averageIPRange.x <= intensity &&\ 1224 \n intensity <= in_averageIPRange.y)\ 1226 \n l_avgValue.x += computeOpacity(scalar) * scalar.x;\ 1227 \n ++l_numSamples.x;\ 1234 if (noOfComponents > 1 && independentComponents)
1237 \n for (int i = 0; i < in_noOfComponents; ++i)\ 1239 \n float opacity = computeOpacity(scalar, i);\ 1240 \n l_sumValue[i] = l_sumValue[i] + opacity * scalar[i];\ 1247 \n float opacity = computeOpacity(scalar);\ 1248 \n l_sumValue.x = l_sumValue.x + opacity * scalar.x;" 1254 if (noOfComponents > 1 && independentComponents)
1257 \n vec4 color[4]; vec4 tmp = vec4(0.0);\ 1258 \n float totalAlpha = 0.0;\ 1259 \n for (int i = 0; i < in_noOfComponents; ++i)\ 1266 \n // Data fetching from the red channel of volume texture\ 1267 \n float opacity = computeOpacity(scalar, i);\ 1268 \n if (opacity > 0.0)\ 1270 \n g_srcColor.a = opacity;\ 1275 else if (!mask || !maskInput ||
1279 \n // Data fetching from the red channel of volume texture\ 1280 \n color[i][3] = computeOpacity(scalar, i);\ 1281 \n color[i] = computeColor(scalar, color[i][3], i);\ 1282 \n totalAlpha += color[i][3] * in_componentWeight[i];\ 1284 \n if (totalAlpha > 0.0)\ 1286 \n for (int i = 0; i < in_noOfComponents; ++i)\ 1288 \n // Only let visible components contribute to the final color\ 1289 \n if (in_componentWeight[i] <= 0) continue;\ 1291 \n tmp.x += color[i].x * color[i].w * in_componentWeight[i];\ 1292 \n tmp.y += color[i].y * color[i].w * in_componentWeight[i];\ 1293 \n tmp.z += color[i].z * color[i].w * in_componentWeight[i];\ 1294 \n tmp.w += ((color[i].w * color[i].w)/totalAlpha);\ 1297 \n g_fragColor = (1.0f - g_fragColor.a) * tmp + g_fragColor;" 1305 \n g_srcColor = vec4(0.0);\ 1306 \n g_srcColor.a = computeOpacity(scalar);" 1311 if (!mask || !maskInput ||
1315 \n g_srcColor = vec4(0.0);\ 1316 \n g_srcColor.a = computeOpacity(scalar);\ 1317 \n if (g_srcColor.a > 0.0)\ 1319 \n g_srcColor = computeColor(scalar, g_srcColor.a);" 1324 \n // Opacity calculation using compositing:\ 1325 \n // Here we use front to back compositing scheme whereby\ 1326 \n // the current sample value is multiplied to the\ 1327 \n // currently accumulated alpha and then this product\ 1328 \n // is subtracted from the sample value to get the\ 1329 \n // alpha from the previous steps. Next, this alpha is\ 1330 \n // multiplied with the current sample colour\ 1331 \n // and accumulated to the composited colour. The alpha\ 1332 \n // value from the previous steps is then accumulated\ 1333 \n // to the composited colour alpha.\ 1334 \n g_srcColor.rgb *= g_srcColor.a;\ 1335 \n g_fragColor = (1.0f - g_fragColor.a) * g_srcColor + g_fragColor;" 1338 if (!mask || !maskInput ||
1363 \n // Special coloring mode which renders the Prop Id in fragments that\ 1364 \n // have accumulated certain level of opacity. Used during the selection\ 1365 \n // pass vtkHardwareSelection::ACTOR_PASS.\ 1366 \n if (g_fragColor.a > 3.0/ 255.0)\ 1368 \n gl_FragData[0] = vec4(in_propId, 1.0);\ 1372 \n gl_FragData[0] = vec4(0.0);\ 1382 \n // Special coloring mode which renders the voxel index in fragments that\ 1383 \n // have accumulated certain level of opacity. Used during the selection\ 1384 \n // pass vtkHardwareSelection::ID_LOW24.\ 1385 \n if (g_fragColor.a > 3.0/ 255.0)\ 1387 \n uvec3 volumeDim = uvec3(in_textureExtentsMax - in_textureExtentsMin);\ 1388 \n uvec3 voxelCoords = uvec3(volumeDim * g_dataPos);\ 1389 \n // vtkHardwareSelector assumes index 0 to be empty space, so add uint(1).\ 1390 \n uint idx = volumeDim.x * volumeDim.y * voxelCoords.z +\ 1391 \n volumeDim.x * voxelCoords.y + voxelCoords.x + uint(1);\ 1392 \n gl_FragData[0] = vec4(float(idx % uint(256)) / 255.0,\ 1393 \n float((idx / uint(256)) % uint(256)) / 255.0,\ 1394 \n float((idx / uint(65536)) % uint(256)) / 255.0, 1.0);\ 1398 \n gl_FragData[0] = vec4(0.0);\ 1408 \n // Special coloring mode which renders the voxel index in fragments that\ 1409 \n // have accumulated certain level of opacity. Used during the selection\ 1410 \n // pass vtkHardwareSelection::ID_MID24.\ 1411 \n if (g_fragColor.a > 3.0/ 255.0)\ 1413 \n uvec3 volumeDim = uvec3(in_textureExtentsMax - in_textureExtentsMin);\ 1414 \n uvec3 voxelCoords = uvec3(volumeDim * g_dataPos);\ 1415 \n // vtkHardwareSelector assumes index 0 to be empty space, so add uint(1).\ 1416 \n uint idx = volumeDim.x * volumeDim.y * voxelCoords.z +\ 1417 \n volumeDim.x * voxelCoords.y + voxelCoords.x + uint(1);\ 1418 \n idx = ((idx & 0xff000000) >> 24);\ 1419 \n gl_FragData[0] = vec4(float(idx % uint(256)) / 255.0,\ 1420 \n float((idx / uint(256)) % uint(256)) / 255.0,\ 1421 \n float(idx / uint(65536)) / 255.0, 1.0);\ 1425 \n gl_FragData[0] = vec4(0.0);\ 1435 int independentComponents = 0)
1448 if (noOfComponents > 1 && independentComponents)
1451 \n g_srcColor = vec4(0);\ 1452 \n for (int i = 0; i < in_noOfComponents; ++i)\ 1454 \n vec4 tmp = computeColor(l_maxValue, computeOpacity(l_maxValue, i), i);\ 1455 \n g_srcColor[0] += tmp[0] * tmp[3] * in_componentWeight[i];\ 1456 \n g_srcColor[1] += tmp[1] * tmp[3] * in_componentWeight[i];\ 1457 \n g_srcColor[2] += tmp[2] * tmp[3] * in_componentWeight[i];\ 1458 \n g_srcColor[3] += tmp[3] * in_componentWeight[i];\ 1460 \n g_fragColor = g_srcColor;" 1466 \n g_srcColor = computeColor(l_maxValue,\ 1467 \n computeOpacity(l_maxValue));\ 1468 \n g_fragColor.rgb = g_srcColor.rgb * g_srcColor.a;\ 1469 \n g_fragColor.a = g_srcColor.a;" 1475 if (noOfComponents > 1 && independentComponents)
1478 \n g_srcColor = vec4(0);\ 1479 \n for (int i = 0; i < in_noOfComponents; ++i)\ 1481 \n vec4 tmp = computeColor(l_minValue, computeOpacity(l_minValue, i), i);\ 1482 \n g_srcColor[0] += tmp[0] * tmp[3] * in_componentWeight[i];\ 1483 \n g_srcColor[1] += tmp[1] * tmp[3] * in_componentWeight[i];\ 1484 \n g_srcColor[2] += tmp[2] * tmp[3] * in_componentWeight[i];\ 1485 \n g_srcColor[2] += tmp[3] * tmp[3] * in_componentWeight[i];\ 1487 \n g_fragColor = g_srcColor;" 1493 \n g_srcColor = computeColor(l_minValue,\ 1494 \n computeOpacity(l_minValue));\ 1495 \n g_fragColor.rgb = g_srcColor.rgb * g_srcColor.a;\ 1496 \n g_fragColor.a = g_srcColor.a;" 1502 if (noOfComponents > 1 && independentComponents)
1505 \n for (int i = 0; i < in_noOfComponents; ++i)\ 1507 \n if (l_numSamples[i] == uint(0))\ 1511 \n l_avgValue[i] = l_avgValue[i] * in_componentWeight[i] /\ 1512 \n l_numSamples[i];\ 1515 \n l_avgValue[0] += l_avgValue[i];\ 1518 \n l_avgValue[0] = clamp(l_avgValue[0], 0.0, 1.0);\ 1519 \n g_fragColor = vec4(vec3(l_avgValue[0]), 1.0);" 1525 \n if (l_numSamples.x == uint(0))\ 1531 \n l_avgValue.x /= l_numSamples.x;\ 1532 \n l_avgValue.x = clamp(l_avgValue.x, 0.0, 1.0);\ 1533 \n g_fragColor = vec4(vec3(l_avgValue.x), 1.0);\ 1540 if (noOfComponents > 1 && independentComponents)
1544 \n l_sumValue.x *= in_componentWeight.x;\ 1545 \n for (int i = 1; i < in_noOfComponents; ++i)\ 1547 \n l_sumValue.x += l_sumValue[i] * in_componentWeight[i];\ 1549 \n l_sumValue.x = clamp(l_sumValue.x, 0.0, 1.0);\ 1550 \n g_fragColor = vec4(vec3(l_sumValue.x), 1.0);" 1556 \n l_sumValue.x = clamp(l_sumValue.x, 0.0, 1.0);\ 1557 \n g_fragColor = vec4(vec3(l_sumValue.x), 1.0);" 1581 \n const float g_opacityThreshold = 1.0 - 1.0 / 255.0;");
1589 \n uniform vec3 in_propId;");
1598 \n // Flag to indicate if the raymarch loop should terminate \ 1599 \n bool stop = false;\ 1601 \n g_terminatePointMax = 0.0;\ 1604 \n vec4 l_depthValue = vec4(1.0,1.0,1.0,1.0);\ 1606 \n vec4 l_depthValue = texture2D(in_depthSampler, fragTexCoord);\ 1609 \n if(gl_FragCoord.z >= l_depthValue.x)\ 1614 \n // color buffer or max scalar buffer have a reduced size.\ 1615 \n fragTexCoord = (gl_FragCoord.xy - in_windowLowerLeftCorner) *\ 1616 \n in_inverseOriginalWindowSize;\ 1618 \n // Compute max number of iterations it will take before we hit\ 1619 \n // the termination point\ 1621 \n // Abscissa of the point on the depth buffer along the ray.\ 1622 \n // point in texture coordinates\ 1623 \n vec4 terminatePoint = WindowToNDC(gl_FragCoord.x, gl_FragCoord.y, l_depthValue.x);\ 1625 \n // From normalized device coordinates to eye coordinates.\ 1626 \n // in_projectionMatrix is inversed because of way VT\ 1627 \n // From eye coordinates to texture coordinates\ 1628 \n terminatePoint = ip_inverseTextureDataAdjusted *\ 1629 \n in_inverseVolumeMatrix *\ 1630 \n in_inverseModelViewMatrix *\ 1631 \n in_inverseProjectionMatrix *\ 1633 \n terminatePoint /= terminatePoint.w;\ 1635 \n g_terminatePointMax = length(terminatePoint.xyz - g_dataPos.xyz) /\ 1636 \n length(g_dirStep);\ 1637 \n g_currentT = 0.0;");
1646 \n if(any(greaterThan(g_dataPos, in_texMax)) ||\ 1647 \n any(lessThan(g_dataPos, in_texMin)))\ 1652 \n // Early ray termination\ 1653 \n // if the currently composited colour alpha is already fully saturated\ 1654 \n // we terminated the loop or if we have hit an obstacle in the\ 1655 \n // direction of they ray (using depth buffer) we terminate as well.\ 1656 \n if((g_fragColor.a > g_opacityThreshold) || \ 1657 \n g_currentT >= g_terminatePointMax)\ 1691 \nuniform float in_croppingPlanes[6];\ 1692 \nuniform int in_croppingFlags [32];\ 1693 \nfloat croppingPlanesTexture[6];\ 1695 \n// X: axis = 0, Y: axis = 1, Z: axis = 2\ 1696 \n// cp Cropping plane bounds (minX, maxX, minY, maxY, minZ, maxZ)\ 1697 \nint computeRegionCoord(float cp[6], vec3 pos, int axis)\ 1699 \n int cpmin = axis * 2;\ 1700 \n int cpmax = cpmin + 1;\ 1702 \n if (pos[axis] < cp[cpmin])\ 1706 \n else if (pos[axis] >= cp[cpmin] &&\ 1707 \n pos[axis] < cp[cpmax])\ 1711 \n else if (pos[axis] >= cp[cpmax])\ 1718 \nint computeRegion(float cp[6], vec3 pos)\ 1720 \n return (computeRegionCoord(cp, pos, 0) +\ 1721 \n (computeRegionCoord(cp, pos, 1) - 1) * 3 +\ 1722 \n (computeRegionCoord(cp, pos, 2) - 1) * 9);\ 1737 \n // Convert cropping region to texture space\ 1738 \n mat4 datasetToTextureMat = in_inverseTextureDatasetMatrix;\ 1740 \n vec4 tempCrop = vec4(in_croppingPlanes[0], 0.0, 0.0, 1.0);\ 1741 \n tempCrop = datasetToTextureMat * tempCrop;\ 1742 \n if (tempCrop[3] != 0.0)\ 1744 \n tempCrop[0] /= tempCrop[3];\ 1746 \n croppingPlanesTexture[0] = tempCrop[0];\ 1748 \n tempCrop = vec4(in_croppingPlanes[1], 0.0, 0.0, 1.0);\ 1749 \n tempCrop = datasetToTextureMat * tempCrop;\ 1750 \n if (tempCrop[3] != 0.0)\ 1752 \n tempCrop[0] /= tempCrop[3];\ 1754 \n croppingPlanesTexture[1] = tempCrop[0];\ 1756 \n tempCrop = vec4(0.0, in_croppingPlanes[2], 0.0, 1.0);\ 1757 \n tempCrop = datasetToTextureMat * tempCrop;\ 1758 \n if (tempCrop[3] != 0.0)\ 1760 \n tempCrop[1] /= tempCrop[3];\ 1762 \n croppingPlanesTexture[2] = tempCrop[1];\ 1764 \n tempCrop = vec4(0.0, in_croppingPlanes[3], 0.0, 1.0);\ 1765 \n tempCrop = datasetToTextureMat * tempCrop;\ 1766 \n if (tempCrop[3] != 0.0)\ 1768 \n tempCrop[1] /= tempCrop[3];\ 1770 \n croppingPlanesTexture[3] = tempCrop[1];\ 1772 \n tempCrop = vec4(0.0, 0.0, in_croppingPlanes[4], 1.0);\ 1773 \n tempCrop = datasetToTextureMat * tempCrop;\ 1774 \n if (tempCrop[3] != 0.0)\ 1776 \n tempCrop[2] /= tempCrop[3];\ 1778 \n croppingPlanesTexture[4] = tempCrop[2];\ 1780 \n tempCrop = vec4(0.0, 0.0, in_croppingPlanes[5], 1.0);\ 1781 \n tempCrop = datasetToTextureMat * tempCrop;\ 1782 \n if (tempCrop[3] != 0.0)\ 1784 \n tempCrop[2] /= tempCrop[3];\ 1786 \n croppingPlanesTexture[5] = tempCrop[2];" 1800 \n // Determine region\ 1801 \n int regionNo = computeRegion(croppingPlanesTexture, g_dataPos);\ 1803 \n // Do & operation with cropping flags\ 1804 \n // Pass the flag that its Ok to sample or not to sample\ 1805 \n if (in_croppingFlags[regionNo] == 0)\ 1807 \n // Skip this voxel\ 1835 \n int clippingPlanesSize;\ 1837 \n mat4 textureToObjMat;");
1854 vec4 tempClip = in_volumeMatrix * vec4(rayDir, 0.0);\ 1855 \n if (tempClip.w != 0.0)\ 1857 \n tempClip = tempClip/tempClip.w;\ 1858 \n tempClip.w = 1.0;\ 1860 \n objRayDir = tempClip.xyz;");
1865 objRayDir = normalize(in_projectionDirection);");
1869 \n clippingPlanesSize = int(in_clippingPlanes[0]);\ 1870 \n vec4 objDataPos = vec4(0.0);\ 1871 \n textureToObjMat = in_volumeMatrix * in_textureDatasetMatrix;\ 1873 \n vec4 terminatePointObj = textureToObjMat * terminatePoint;\ 1874 \n if (terminatePointObj.w != 0.0)\ 1876 \n terminatePointObj = terminatePointObj/ terminatePointObj.w ;\ 1877 \n terminatePointObj.w = 1.0;\ 1880 \n for (int i = 0; i < clippingPlanesSize; i = i + 6)\ 1882 \n if (in_useJittering)\ 1884 \n objDataPos = textureToObjMat * vec4(g_dataPos - g_rayJitter,\ 1889 \n objDataPos = textureToObjMat * vec4(g_dataPos - g_dirStep, 1.0);\ 1891 \n if (objDataPos.w != 0.0)\ 1893 \n objDataPos = objDataPos/objDataPos.w; objDataPos.w = 1.0;\ 1895 \n vec3 planeOrigin = vec3(in_clippingPlanes[i + 1],\ 1896 \n in_clippingPlanes[i + 2],\ 1897 \n in_clippingPlanes[i + 3]);\ 1898 \n vec3 planeNormal = vec3(in_clippingPlanes[i + 4],\ 1899 \n in_clippingPlanes[i + 5],\ 1900 \n in_clippingPlanes[i + 6]);\ 1901 \n vec3 normalizedPlaneNormal = normalize(planeNormal);\ 1903 \n float rayDotNormal = dot(objRayDir, normalizedPlaneNormal);\ 1904 \n bool frontFace = rayDotNormal > 0;\ 1905 \n float distance = dot(normalizedPlaneNormal, planeOrigin - objDataPos.xyz);\ 1907 \n if (frontFace && // Observing from the clipped side (plane's front face)\ 1908 \n distance > 0.0) // Ray-entry lies on the clipped side.\ 1910 \n // Scale the point-plane distance to the ray direction and update the\ 1912 \n float rayScaledDist = distance / rayDotNormal;\ 1913 \n vec4 newObjDataPos = vec4(objDataPos.xyz + rayScaledDist * objRayDir, 1.0);\ 1914 \n newObjDataPos = in_inverseTextureDatasetMatrix\ 1915 \n * in_inverseVolumeMatrix * vec4(newObjDataPos.xyz, 1.0);\ 1916 \n if (newObjDataPos.w != 0.0)\ 1918 \n newObjDataPos /= newObjDataPos.w;\ 1920 \n if (in_useJittering)\ 1922 \n g_dataPos = newObjDataPos.xyz + g_rayJitter;\ 1926 \n g_dataPos = newObjDataPos.xyz + g_dirStep;\ 1929 \n bool stop = any(greaterThan(g_dataPos, in_texMax)) ||\ 1930 \n any(lessThan(g_dataPos, in_texMin));\ 1933 \n // The ray exits the bounding box before ever intersecting the plane (only\ 1934 \n // the clipped space is hit).\ 1938 \n bool behindGeometry = dot(terminatePointObj.xyz - planeOrigin.xyz, normalizedPlaneNormal) < 0.0;\ 1939 \n if (behindGeometry)\ 1941 \n // Geometry appears in front of the plane.\ 1945 \n // Update the number of ray marching steps to account for the clipped entry point (\ 1946 \n // this is necessary in case the ray hits geometry after marching behind the plane,\ 1947 \n // given that the number of steps was assumed to be from the not-clipped entry).\ 1948 \n g_terminatePointMax = length(terminatePoint.xyz - g_dataPos.xyz) /\ 1949 \n length(g_dirStep);\ 1968 \n for (int i = 0; i < clippingPlanesSize && !g_skip; i = i + 6)\ 1970 \n vec4 objDataPos = textureToObjMat * vec4(g_dataPos, 1.0);\ 1971 \n if (objDataPos.w != 0.0)\ 1973 \n objDataPos /= objDataPos.w;\ 1975 \n vec3 planeOrigin = vec3(in_clippingPlanes[i + 1],\ 1976 \n in_clippingPlanes[i + 2],\ 1977 \n in_clippingPlanes[i + 3]);\ 1978 \n vec3 planeNormal = vec3(in_clippingPlanes[i + 4],\ 1979 \n in_clippingPlanes[i + 5],\ 1980 \n in_clippingPlanes[i + 6]);\ 1981 \n if (dot(vec3(objDataPos.xyz - planeOrigin), planeNormal) < 0 && dot(objRayDir, planeNormal) < 0)\ 2005 int vtkNotUsed(maskType))
2007 if (!mask || !maskInput)
2025 if (!mask || !maskInput ||
2033 \nvec4 maskValue = texture3D(in_mask, g_dataPos);\ 2034 \nif(maskValue.r <= 0.0)\ 2050 if (!mask || !maskInput ||
2058 \nuniform float in_maskBlendFactor;\ 2059 \nuniform sampler2D in_mask1;\ 2060 \nuniform sampler2D in_mask2;" 2074 if (!mask || !maskInput ||
2082 \nvec4 scalar = texture3D(in_volume, g_dataPos);");
2085 if (noOfComponents == 1)
2088 \n scalar.r = scalar.r*in_volume_scale.r + in_volume_bias.r;\ 2089 \n scalar = vec4(scalar.r,scalar.r,scalar.r,scalar.r);" 2096 \n scalar = scalar*in_volume_scale + in_volume_bias;" 2101 \nif (in_maskBlendFactor == 0.0)\ 2103 \n g_srcColor = computeColor(scalar, computeOpacity(scalar));\ 2107 \n float opacity = computeOpacity(scalar);\ 2108 \n // Get the mask value at this same location\ 2109 \n vec4 maskValue = texture3D(in_mask, g_dataPos);\ 2110 \n if(maskValue.r == 0.0)\ 2112 \n g_srcColor = computeColor(scalar, opacity);\ 2116 \n if (maskValue.r == 1.0/255.0)\ 2118 \n g_srcColor = texture2D(in_mask1, vec2(scalar.w,0.0));\ 2122 \n // maskValue.r == 2.0/255.0\ 2123 \n g_srcColor = texture2D(in_mask2, vec2(scalar.w,0.0));\ 2125 \n g_srcColor.a = 1.0;\ 2126 \n if(in_maskBlendFactor < 1.0)\ 2128 \n g_srcColor = (1.0 - in_maskBlendFactor) *\ 2129 \n computeColor(scalar, opacity) +\ 2130 \n in_maskBlendFactor * g_srcColor;\ 2133 \n g_srcColor.a = opacity;\ 2145 \n vec3 l_opaqueFragPos;\ 2146 \n bool l_updateDepth;");
2155 \n l_opaqueFragPos = vec3(-1.0);\ 2156 \n if(in_clampDepthToBackface)\ 2158 \n l_opaqueFragPos = g_dataPos;\ 2160 \n l_updateDepth = true;" 2170 \n if(!g_skip && g_srcColor.a > 0.0 && l_updateDepth)\ 2172 \n l_opaqueFragPos = g_dataPos;\ 2173 \n l_updateDepth = false;\ 2184 \n if (l_opaqueFragPos == vec3(-1.0))\ 2186 \n gl_FragData[1] = vec4(1.0);\ 2190 \n vec4 depthValue = in_projectionMatrix * in_modelViewMatrix *\ 2191 \n in_volumeMatrix * in_textureDatasetMatrix *\ 2192 \n vec4(l_opaqueFragPos, 1.0);\ 2193 \n depthValue /= depthValue.w;\ 2194 \n gl_FragData[1] = vec4(vec3(0.5 * (gl_DepthRange.far -\ 2195 \n gl_DepthRange.near) * depthValue.z + 0.5 *\ 2196 \n (gl_DepthRange.far + gl_DepthRange.near)), 1.0);\ 2207 \n vec3 l_isoPos = g_dataPos;" 2217 \n if(!g_skip && g_srcColor.a > 0.0)\ 2219 \n l_isoPos = g_dataPos;\ 2220 \n g_exit = true; g_skip = true;\ 2231 \n vec4 depthValue = in_projectionMatrix * in_modelViewMatrix *\ 2232 \n in_volumeMatrix * in_textureDatasetMatrix *\ 2233 \n vec4(l_isoPos, 1.0);\ 2234 \n gl_FragData[0] = vec4(l_isoPos, 1.0);\ 2235 \n gl_FragData[1] = vec4(vec3((depthValue.z/depthValue.w) * 0.5 + 0.5),\ 2246 \n initializeRayCast();\ 2247 \n castRay(-1.0, -1.0);\ 2248 \n finalizeRayCast();");
2252 #endif // vtkVolumeShaderComposer_h std::string ShadingExit(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *mapper, vtkVolume *vtkNotUsed(vol), int noOfComponents, int independentComponents=0)
std::string RenderToImageImplementation(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol))
std::string BaseImplementation(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol))
represents a volume (data & properties) in a rendered scene
std::string CroppingDeclarationVertex(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol))
std::string CompositeMaskImplementation(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol), vtkImageData *maskInput, vtkVolumeMask *mask, int maskType, int noOfComponents)
Abstract class for a volume mapper.
std::string BinaryMaskDeclaration(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol), vtkImageData *maskInput, vtkVolumeMask *mask, int vtkNotUsed(maskType))
virtual int GetUseDepthPass()
If UseDepthPass is on, the mapper will use two passes.
std::string DepthPassInit(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol))
virtual int GetBlendMode()
Set/Get the blend mode.
std::string PickingActorPassDeclaration(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol))
std::string RenderToImageDeclarationFragment(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol))
std::string RenderToImageExit(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol))
abstract specification for renderers
std::string CroppingDeclarationFragment(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *mapper, vtkVolume *vtkNotUsed(vol))
std::string TerminationExit(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol))
std::string ShadingDeclarationVertex(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol))
std::string BinaryMaskImplementation(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol), vtkImageData *maskInput, vtkVolumeMask *mask, int maskType)
std::string replace(std::string source, const std::string &search, const std::string &replace, bool all)
virtual vtkPlaneCollection * GetClippingPlanes()
Get/Set the vtkPlaneCollection which specifies the clipping planes.
vtkCamera * GetActiveCamera()
Get the current camera.
int GetShade(int index)
Set/Get the shading of a volume.
std::string PickingActorPassExit(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol))
std::string ClippingImplementation(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *mapper, vtkVolume *vtkNotUsed(vol))
std::string ComputeLightingDeclaration(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *mapper, vtkVolume *vol, int noOfComponents, int independentComponents, int vtkNotUsed(numberOfLights), int lightingComplexity)
OpenGL subclass that draws the image to the screen.
static vtkOpenGLGPUVolumeRayCastMapper * SafeDownCast(vtkObjectBase *o)
std::string TerminationInit(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol))
std::string CroppingImplementation(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *mapper, vtkVolume *vtkNotUsed(vol))
std::string TerminationImplementation(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol))
std::string ClippingDeclarationVertex(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol))
std::string ClippingExit(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol))
std::string CompositeMaskDeclarationFragment(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol), vtkImageData *maskInput, vtkVolumeMask *mask, int maskType)
topologically and geometrically regular array of data
bool HasGradientOpacity(int index=0)
Check whether or not we have the gradient opacity.
std::string ShadingImplementation(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *mapper, vtkVolume *vtkNotUsed(vol), vtkImageData *maskInput, vtkVolumeMask *mask, int maskType, int noOfComponents, int independentComponents=0)
std::string WorkerImplementation(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol))
virtual int GetParallelProjection()
Set/Get the value of the ParallelProjection instance variable.
std::string ComputeClipPositionImplementation(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol))
std::string ComputeRayDirectionDeclaration(vtkRenderer *ren, vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol), int vtkNotUsed(noOfComponents))
std::string ShadingInit(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *mapper, vtkVolume *vtkNotUsed(vol))
represents the common properties for rendering a volume.
std::string ShadingDeclarationFragment(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *mapper, vtkVolume *vtkNotUsed(vol))
std::string CroppingExit(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol))
std::string ClippingInit(vtkRenderer *ren, vtkVolumeMapper *mapper, vtkVolume *vtkNotUsed(vol))
std::string ClippingDeclarationFragment(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol))
std::string ComputeTextureCoordinates(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol))
boost::graph_traits< vtkGraph *>::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
std::string ComputeGradientDeclaration(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vol, int noOfComponents, int independentComponents, std::map< int, std::string > gradientTableMap)
std::string PickingIdLow24PassExit(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol))
std::string CroppingInit(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *mapper, vtkVolume *vtkNotUsed(vol))
vtkVolumeProperty * GetProperty()
Set/Get the volume property.
virtual int GetCurrentPass()
virtual int GetCropping()
Turn On/Off orthogonal cropping.
std::string TerminationDeclarationVertex(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol))
std::string BaseDeclarationVertex(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol))
std::string DepthPassExit(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol))
std::string DepthPassImplementation(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol))
std::string BaseExit(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol))
std::string BaseInit(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *mapper, vtkVolume *vol, int lightingComplexity)
std::string BaseDeclarationFragment(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *mapper, vtkVolume *vtkNotUsed(vol), int vtkNotUsed(numberOfLights), int lightingComplexity, bool hasGradientOpacity, int noOfComponents, int independentComponents)
std::string TerminationDeclarationFragment(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol))
std::string ComputeOpacityDeclaration(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol), int noOfComponents, int independentComponents, std::map< int, std::string > opacityTableMap)
std::string ComputeColorDeclaration(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol), int noOfComponents, int independentComponents, std::map< int, std::string > colorTableMap)
std::string RenderToImageInit(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol))
std::string PickingIdMid24PassExit(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol))