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)
53 source.replace(pos, search.length(),
replace);
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_texureToEyeIt;\
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 \n uniform bool in_useJittering;\
191 \n uniform bool in_clampDepthToBackface;\
193 \nuniform vec2 in_averageIPRange;"
196 if (lightingComplexity > 0 || hasGradientOpacity)
199 \nuniform bool in_twoSidedLighting;\
205 if (hasGradientOpacity)
209 \nvec3 g_cellSpacing;\
210 \nfloat g_avgSpacing;");
213 if (lightingComplexity == 3)
216 \nvec4 g_fragWorldPos;\
217 \nuniform int in_numberOfLights;\
218 \nuniform vec3 in_lightAmbientColor[6];\
219 \nuniform vec3 in_lightDiffuseColor[6];\
220 \nuniform vec3 in_lightSpecularColor[6];\
221 \nuniform vec3 in_lightDirection[6];\
222 \nuniform vec3 in_lightPosition[6];\
223 \nuniform vec3 in_lightAttenuation[6];\
224 \nuniform float in_lightConeAngle[6];\
225 \nuniform float in_lightExponent[6];\
226 \nuniform int in_lightPositional[6];\
229 else if (lightingComplexity == 2)
232 \nvec4 g_fragWorldPos;\
233 \nuniform int in_numberOfLights;\
234 \nuniform vec3 in_lightAmbientColor[6];\
235 \nuniform vec3 in_lightDiffuseColor[6];\
236 \nuniform vec3 in_lightSpecularColor[6];\
237 \nuniform vec3 in_lightDirection[6];\
243 \nuniform vec3 in_lightAmbientColor[1];\
244 \nuniform vec3 in_lightDiffuseColor[1];\
245 \nuniform vec3 in_lightSpecularColor[1];\
246 \nvec4 g_lightPosObj;\
252 if (noOfComponents > 1 && independentComponents)
255 \nuniform vec4 in_componentWeight;");
264 \nuniform sampler2D in_depthPassSampler;");
274 int lightingComplexity)
280 \n bool l_adjustTextureExtents = !in_cellFlag;"
289 \n vec2 fragTexCoord2 = (gl_FragCoord.xy - in_windowLowerLeftCorner) *\
290 \n in_inverseWindowSize;\
291 \n vec4 depthValue = texture2D(in_depthPassSampler, fragTexCoord2);\
293 \n dataPos.x = (gl_FragCoord.x - in_windowLowerLeftCorner.x) * 2.0 *\
294 \n in_inverseWindowSize.x - 1.0;\
295 \n dataPos.y = (gl_FragCoord.y - in_windowLowerLeftCorner.y) * 2.0 *\
296 \n in_inverseWindowSize.y - 1.0;\
297 \n dataPos.z = (2.0 * depthValue.x - (gl_DepthRange.near +\
298 \n gl_DepthRange.far)) / gl_DepthRange.diff;\
301 \n // From normalized device coordinates to eye coordinates.\
302 \n // in_projectionMatrix is inversed because of way VT\
303 \n // From eye coordinates to texture coordinates\
304 \n dataPos = in_inverseTextureDatasetMatrix *\
305 \n in_inverseVolumeMatrix *\
306 \n in_inverseModelViewMatrix *\
307 \n in_inverseProjectionMatrix *\
309 \n dataPos /= dataPos.w;\
310 \n g_dataPos = dataPos.xyz;\
311 \n l_adjustTextureExtents = true;"
317 \n // Get the 3D texture coordinates for lookup into the in_volume dataset\
318 \n g_dataPos = ip_textureCoords.xyz;"
324 \n // Eye position in dataset space\
325 \n g_eyePosObj = (in_inverseVolumeMatrix * vec4(in_cameraPos, 1.0));\
326 \n if (g_eyePosObj.w != 0.0)\
328 \n g_eyePosObj.x /= g_eyePosObj.w;\
329 \n g_eyePosObj.y /= g_eyePosObj.w;\
330 \n g_eyePosObj.z /= g_eyePosObj.w;\
331 \n g_eyePosObj.w = 1.0;\
334 \n // Getting the ray marching direction (in dataset space);\
335 \n vec3 rayDir = computeRayDirection();\
337 \n // Multiply the raymarching direction with the step size to get the\
338 \n // sub-step size we need to take at each raymarching step\
339 \n g_dirStep = (ip_inverseTextureDataAdjusted *\
340 \n vec4(rayDir, 0.0)).xyz * in_sampleDistance;\
342 \n // 2D Texture fragment coordinates [0,1] from fragment coordinates.\
343 \n // The frame buffer texture has the size of the plain buffer but \
344 \n // we use a fraction of it. The texture coordinate is less than 1 if\
345 \n // the reduction factor is less than 1.\
346 \n // Device coordinates are between -1 and 1. We need texture\
347 \n // coordinates between 0 and 1. The in_noiseSampler and in_depthSampler\
348 \n // buffers have the original size buffer.\
349 \n vec2 fragTexCoord = (gl_FragCoord.xy - in_windowLowerLeftCorner) *\
350 \n in_inverseWindowSize;\
352 \n float jitterValue = 0;\
353 \n if (in_useJittering)\
355 \n jitterValue = texture2D(in_noiseSampler, fragTexCoord).x;\
356 \n g_dataPos += g_dirStep * jitterValue;\
360 \n g_dataPos += g_dirStep;\
363 \n // Flag to deternmine if voxel should be considered for the rendering\
364 \n bool l_skip = false;");
369 \n // Light position in dataset space\
370 \n g_lightPosObj = (in_inverseVolumeMatrix *\
371 \n vec4(in_cameraPos, 1.0));\
372 \n if (g_lightPosObj.w != 0.0)\
374 \n g_lightPosObj.x /= g_lightPosObj.w;\
375 \n g_lightPosObj.y /= g_lightPosObj.w;\
376 \n g_lightPosObj.z /= g_lightPosObj.w;\
377 \n g_lightPosObj.w = 1.0;\
379 \n g_ldir = normalize(g_lightPosObj.xyz - ip_vertexPos);\
380 \n g_vdir = normalize(g_eyePosObj.xyz - ip_vertexPos);\
381 \n g_h = normalize(g_ldir + g_vdir);"
389 \n g_xvec = vec3(in_cellStep[0], 0.0, 0.0);\
390 \n g_yvec = vec3(0.0, in_cellStep[1], 0.0);\
391 \n g_zvec = vec3(0.0, 0.0, in_cellStep[2]);"
398 \n g_cellSpacing = vec3(in_cellSpacing[0],\
399 \n in_cellSpacing[1],\
400 \n in_cellSpacing[2]);\
401 \n g_avgSpacing = (g_cellSpacing[0] +\
402 \n g_cellSpacing[1] +\
403 \n g_cellSpacing[2])/3.0;\
404 \n // Adjust the aspect\
405 \n g_aspect.x = g_cellSpacing[0] * 2.0 / g_avgSpacing;\
406 \n g_aspect.y = g_cellSpacing[1] * 2.0 / g_avgSpacing;\
407 \n g_aspect.z = g_cellSpacing[2] * 2.0 / g_avgSpacing;"
437 int independentComponents,
438 std::map<int, std::string>
443 (noOfComponents == 1 || !independentComponents))
446 \nuniform sampler2D in_gradientTransferFunc;\
447 \nfloat computeGradientOpacity(vec4 grad)\
449 \n return texture2D("+gradientTableMap[0]+
", vec2(grad.w, 0.0)).r;\
453 else if (noOfComponents > 1 && independentComponents &&
456 std::ostringstream toString;
457 for (
int i = 0; i < noOfComponents; ++i)
459 shaderStr +=
std::string(
"\n uniform sampler2D ") +
464 \nfloat computeGradientOpacity(vec4 grad, int component)\
467 for (
int i = 0; i < noOfComponents; ++i)
471 \n if (component == " + toString.str() +
")");
475 \n return texture2D("+ gradientTableMap[i] +
", vec2(grad.w, 0.0)).r;\
492 \n// c is short for component\
493 \nvec4 computeGradient(int c)\
497 \n g1.x = texture3D(in_volume, vec3(g_dataPos + g_xvec)).x;\
498 \n g1.y = texture3D(in_volume, vec3(g_dataPos + g_yvec)).x;\
499 \n g1.z = texture3D(in_volume, vec3(g_dataPos + g_zvec)).x;\
500 \n g2.x = texture3D(in_volume, vec3(g_dataPos - g_xvec)).x;\
501 \n g2.y = texture3D(in_volume, vec3(g_dataPos - g_yvec)).x;\
502 \n g2.z = texture3D(in_volume, vec3(g_dataPos - g_zvec)).x;\
503 \n g1 = g1 * in_volume_scale.r + in_volume_bias.r;\
504 \n g2 = g2 * in_volume_scale.r + in_volume_bias.r;\
505 \n return vec4((g1 - g2), -1.0);\
512 \n// c is short for component\
513 \nvec4 computeGradient(int c)\
517 \n g1.x = texture3D(in_volume, vec3(g_dataPos + g_xvec)).x;\
518 \n g1.y = texture3D(in_volume, vec3(g_dataPos + g_yvec)).x;\
519 \n g1.z = texture3D(in_volume, vec3(g_dataPos + g_zvec)).x;\
520 \n g2.x = texture3D(in_volume, vec3(g_dataPos - g_xvec)).x;\
521 \n g2.y = texture3D(in_volume, vec3(g_dataPos - g_yvec)).x;\
522 \n g2.z = texture3D(in_volume, vec3(g_dataPos - g_zvec)).x;\
523 \n g1 = g1 * in_volume_scale.r + in_volume_bias.r;\
524 \n g2 = g2 * in_volume_scale.r + in_volume_bias.r;\
525 \n g1.x = in_scalarsRange[c][0] + (\
526 \n in_scalarsRange[c][1] - in_scalarsRange[c][0]) * g1.x;\
527 \n g1.y = in_scalarsRange[c][0] + (\
528 \n in_scalarsRange[c][1] - in_scalarsRange[c][0]) * g1.y;\
529 \n g1.z = in_scalarsRange[c][0] + (\
530 \n in_scalarsRange[c][1] - in_scalarsRange[c][0]) * g1.z;\
531 \n g2.x = in_scalarsRange[c][0] + (\
532 \n in_scalarsRange[c][1] - in_scalarsRange[c][0]) * g2.x;\
533 \n g2.y = in_scalarsRange[c][0] + (\
534 \n in_scalarsRange[c][1] - in_scalarsRange[c][0]) * g2.y;\
535 \n g2.z = in_scalarsRange[c][0] + (\
536 \n in_scalarsRange[c][1] - in_scalarsRange[c][0]) * g2.z;\
537 \n g2.xyz = g1 - g2.xyz;\
538 \n g2.x /= g_aspect.x;\
539 \n g2.y /= g_aspect.y;\
540 \n g2.z /= g_aspect.z;\
542 \n float grad_mag = length(g2);\
543 \n if (grad_mag > 0.0)\
545 \n g2.x /= grad_mag;\
546 \n g2.y /= grad_mag;\
547 \n g2.z /= grad_mag;\
551 \n g2.xyz = vec3(0.0, 0.0, 0.0);\
553 \n grad_mag = grad_mag * 1.0 / (0.25 * (in_scalarsRange[c][1] -\
554 \n (in_scalarsRange[c][0])));\
555 \n grad_mag = clamp(grad_mag, 0.0, 1.0);\
564 \nvec4 computeGradient(int component)\
566 \n return vec4(0.0);\
578 int independentComponents,
579 int vtkNotUsed(numberOfLights),
580 int lightingComplexity)
584 \nvec4 computeLighting(vec4 color, int component)\
586 \n vec4 finalColor = vec4(0.0);"
590 int shadeReqd = volProperty->
GetShade() &&
597 \n // Compute gradient function only once\
598 \n vec4 gradient = computeGradient(component);"
604 if (lightingComplexity == 1)
607 \n vec3 diffuse = vec3(0.0);\
608 \n vec3 specular = vec3(0.0);\
609 \n vec3 normal = gradient.xyz / in_cellSpacing;\
610 \n float normalLength = length(normal);\
611 \n if (normalLength > 0.0)\
613 \n normal = normalize(normal);\
617 \n normal = vec3(0.0, 0.0, 0.0);\
619 \n float nDotL = dot(normal, g_ldir);\
620 \n float nDotH = dot(normal, g_h);\
621 \n if (nDotL < 0.0 && in_twoSidedLighting)\
625 \n if (nDotH < 0.0 && in_twoSidedLighting)\
631 \n diffuse = nDotL * in_diffuse[component] *\
632 \n in_lightDiffuseColor[0] * color.rgb;\
634 \n specular = pow(nDotH, in_shininess[component]) *\
635 \n in_specular[component] *\
636 \n in_lightSpecularColor[0];\
637 \n // For the headlight, ignore the light's ambient color\
638 \n // for now as it is causing the old mapper tests to fail\
639 \n finalColor.xyz = in_ambient[component] * color.rgb +\
640 \n diffuse + specular;"
643 else if (lightingComplexity == 2)
646 \n g_fragWorldPos = in_modelViewMatrix * in_volumeMatrix *\
647 \n in_textureDatasetMatrix * vec4(-g_dataPos, 1.0);\
648 \n if (g_fragWorldPos.w != 0.0)\
650 \n g_fragWorldPos /= g_fragWorldPos.w;\
652 \n vec3 vdir = normalize(g_fragWorldPos.xyz);\
653 \n vec3 normal = gradient.xyz;\
654 \n vec3 ambient = vec3(0.0);\
655 \n vec3 diffuse = vec3(0.0);\
656 \n vec3 specular = vec3(0.0);\
657 \n float normalLength = length(normal);\
658 \n if (normalLength > 0.0)\
660 \n normal = normalize((in_texureToEyeIt * vec4(normal, 0.0)).xyz);\
664 \n normal = vec3(0.0, 0.0, 0.0);\
666 \n for (int lightNum = 0; lightNum < in_numberOfLights; lightNum++)\
668 \n vec3 ldir = in_lightDirection[lightNum].xyz;\
669 \n vec3 h = normalize(ldir + vdir);\
670 \n float nDotH = dot(normal, h);\
671 \n if (nDotH < 0.0 && in_twoSidedLighting)\
675 \n float nDotL = dot(normal, ldir);\
676 \n if (nDotL < 0.0 && in_twoSidedLighting)\
682 \n diffuse += in_lightDiffuseColor[lightNum] * nDotL;\
686 \n specular = in_lightSpecularColor[lightNum] *\
687 \n pow(nDotH, in_shininess[component]);\
689 \n ambient += in_lightAmbientColor[lightNum];\
691 \n finalColor.xyz = in_ambient[component] * ambient +\
692 \n in_diffuse[component] * diffuse * color.rgb +\
693 \n in_specular[component] * specular;"
696 else if (lightingComplexity == 3)
699 \n g_fragWorldPos = in_modelViewMatrix * in_volumeMatrix *\
700 \n in_textureDatasetMatrix * vec4(g_dataPos, 1.0);\
701 \n if (g_fragWorldPos.w != 0.0)\
703 \n g_fragWorldPos /= g_fragWorldPos.w;\
705 \n vec3 viewDirection = normalize(-g_fragWorldPos.xyz);\
706 \n vec3 ambient = vec3(0,0,0);\
707 \n vec3 diffuse = vec3(0,0,0);\
708 \n vec3 specular = vec3(0,0,0);\
709 \n vec3 vertLightDirection;\
710 \n vec3 normal = normalize((in_texureToEyeIt * vec4(gradient.xyz, 0.0)).xyz);\
712 \n for (int lightNum = 0; lightNum < in_numberOfLights; lightNum++)\
714 \n float attenuation = 1.0;\
716 \n lightDir = in_lightDirection[lightNum];\
717 \n if (in_lightPositional[lightNum] == 0)\
719 \n vertLightDirection = lightDir;\
723 \n vertLightDirection = (g_fragWorldPos.xyz - in_lightPosition[lightNum]);\
724 \n float distance = length(vertLightDirection);\
725 \n vertLightDirection = normalize(vertLightDirection);\
726 \n attenuation = 1.0 /\
727 \n (in_lightAttenuation[lightNum].x\
728 \n + in_lightAttenuation[lightNum].y * distance\
729 \n + in_lightAttenuation[lightNum].z * distance * distance);\
730 \n // per OpenGL standard cone angle is 90 or less for a spot light\
731 \n if (in_lightConeAngle[lightNum] <= 90.0)\
733 \n float coneDot = dot(vertLightDirection, lightDir);\
734 \n // if inside the cone\
735 \n if (coneDot >= cos(radians(in_lightConeAngle[lightNum])))\
737 \n attenuation = attenuation * pow(coneDot, in_lightExponent[lightNum]);\
741 \n attenuation = 0.0;\
745 \n // diffuse and specular lighting\
746 \n float nDotL = dot(normal, vertLightDirection);\
747 \n if (nDotL < 0.0 && in_twoSidedLighting)\
753 \n float df = max(0.0, attenuation * nDotL);\
754 \n diffuse += (df * in_lightDiffuseColor[lightNum]);\
756 \n vec3 h = normalize(vertLightDirection + viewDirection);\
757 \n float nDotH = dot(normal, h);\
758 \n if (nDotH < 0.0 && in_twoSidedLighting)\
764 \n float sf = attenuation * pow(nDotH, in_shininess[component]);\
765 \n specular += (sf * in_lightSpecularColor[lightNum]);\
767 \n ambient += in_lightAmbientColor[lightNum];\
769 \n finalColor.xyz = in_ambient[component] * ambient +\
770 \n in_diffuse[component] * diffuse * color.rgb +\
771 \n in_specular[component] * specular;\
778 "\n finalColor = vec4(color.rgb, 0.0);"
783 (noOfComponents == 1 || !independentComponents))
786 \n if (gradient.w >= 0.0)\
788 \n color.a = color.a *\
789 \n computeGradientOpacity(gradient);\
793 else if (noOfComponents > 1 && independentComponents &&
797 \n if (gradient.w >= 0.0)\
799 \n for (int i = 0; i < in_noOfComponents; ++i)\
801 \n color.a = color.a *\
802 \n computeGradientOpacity(gradient, i) * in_componentWeight[i];\
809 \n finalColor.a = color.a;\
810 \n return finalColor;\
821 int vtkNotUsed(noOfComponents))
826 \nvec3 computeRayDirection()\
828 \n return normalize(ip_vertexPos.xyz - g_eyePosObj.xyz);\
834 \nuniform vec3 in_projectionDirection;\
835 \nvec3 computeRayDirection()\
837 \n return normalize((in_inverseVolumeMatrix *\
838 \n vec4(in_projectionDirection, 0.0)).xyz);\
848 int independentComponents,
849 std::map<int, std::string> colorTableMap)
851 if (noOfComponents == 1)
854 \nuniform sampler2D in_colorTransferFunc;\
855 \nvec4 computeColor(vec4 scalar, float opacity)\
857 \n return computeLighting(vec4(texture2D(in_colorTransferFunc,\
858 \n vec2(scalar.w, 0.0)).xyz, opacity), 0);\
861 else if (noOfComponents > 1 && independentComponents)
864 std::ostringstream toString;
865 for (
int i = 0; i < noOfComponents; ++i)
867 shaderStr +=
std::string(
"\n uniform sampler2D ") +
872 \nvec4 computeColor(vec4 scalar, float opacity, int component)\
875 for (
int i = 0; i < noOfComponents; ++i)
879 \n if (component == " + toString.str() +
")");
883 \n return computeLighting(vec4(texture2D(\
884 \n "+colorTableMap[i]);
886 \n scalar[" + toString.str() +
"],0.0)).xyz,\
887 \n opacity),"+toString.str()+
");\
898 else if (noOfComponents == 2 && !independentComponents)
901 \nuniform sampler2D in_colorTransferFunc;\
902 \nvec4 computeColor(vec4 scalar, float opacity)\
904 \n return computeLighting(vec4(texture2D(in_colorTransferFunc,\
905 \n vec2(scalar.x, 0.0)).xyz,\
912 \nvec4 computeColor(vec4 scalar, float opacity)\
914 \n return computeLighting(vec4(scalar.xyz, opacity), 0);\
924 int independentComponents,
925 std::map<int, std::string> opacityTableMap)
927 if (noOfComponents > 1 && independentComponents)
930 std::ostringstream toString;
932 for (
int i = 0; i < noOfComponents; ++i)
934 shaderStr +=
std::string(
"\n uniform sampler2D ") +
940 \nfloat computeOpacity(vec4 scalar, int component)\
943 for (
int i = 0; i < noOfComponents; ++i)
947 \n if (component == " + toString.str() +
")");
951 \n return texture2D(in_opacityTransferFunc");
952 shaderStr += (i == 0 ?
"" : toString.str());
953 shaderStr +=
std::string(
",vec2(scalar[" + toString.str() +
"],0)).r;\
964 else if (noOfComponents == 2 && !independentComponents)
967 \nuniform sampler2D in_opacityTransferFunc;\
968 \nfloat computeOpacity(vec4 scalar)\
970 \n return texture2D(in_opacityTransferFunc, vec2(scalar.y, 0)).r;\
976 \nuniform sampler2D in_opacityTransferFunc;\
977 \nfloat computeOpacity(vec4 scalar)\
979 \n return texture2D(in_opacityTransferFunc, vec2(scalar.w, 0)).r;\
1008 \n // We get data between 0.0 - 1.0 range\
1009 \n bool l_firstValue = true;\
1010 \n vec4 l_maxValue = vec4(0.0);"
1017 \n //We get data between 0.0 - 1.0 range\
1018 \n bool l_firstValue = true;\
1019 \n vec4 l_minValue = vec4(1.0);"
1025 \n //We get data between 0.0 - 1.0 range\
1026 \n vec4 l_avgValue = vec4(0.0);\
1027 \n // Keep track of number of samples\
1028 \n uvec4 l_numSamples = uvec4(0);"
1034 \n //We get data between 0.0 - 1.0 range\
1035 \n vec4 l_sumValue = vec4(0.0);"
1051 int independentComponents = 0)
1058 \n vec4 scalar = texture3D(in_volume, g_dataPos);"
1062 if (noOfComponents == 1)
1065 \n scalar.r = scalar.r*in_volume_scale.r + in_volume_bias.r;\
1066 \n scalar = vec4(scalar.r,scalar.r,scalar.r,scalar.r);"
1073 \n scalar = scalar*in_volume_scale + in_volume_bias;"
1079 if (noOfComponents > 1)
1081 if (!independentComponents)
1084 \n if (l_maxValue.w < scalar.w || l_firstValue)\
1086 \n l_maxValue = scalar;\
1089 \n if (l_firstValue)\
1091 \n l_firstValue = false;\
1098 \n for (int i = 0; i < in_noOfComponents; ++i)\
1100 \n if (l_maxValue[i] < scalar[i] || l_firstValue)\
1102 \n l_maxValue[i] = scalar[i];\
1105 \n if (l_firstValue)\
1107 \n l_firstValue = false;\
1115 \n if (l_maxValue.w < scalar.x || l_firstValue)\
1117 \n l_maxValue.w = scalar.x;\
1120 \n if (l_firstValue)\
1122 \n l_firstValue = false;\
1129 if (noOfComponents > 1)
1131 if (!independentComponents)
1134 \n if (l_minValue.w > scalar.w || l_firstValue)\
1136 \n l_minValue = scalar;\
1139 \n if (l_firstValue)\
1141 \n l_firstValue = false;\
1148 \n for (int i = 0; i < in_noOfComponents; ++i)\
1150 \n if (l_minValue[i] < scalar[i] || l_firstValue)\
1152 \n l_minValue[i] = scalar[i];\
1155 \n if (l_firstValue)\
1157 \n l_firstValue = false;\
1165 \n if (l_minValue.w > scalar.x || l_firstValue)\
1167 \n l_minValue.w = scalar.x;\
1170 \n if (l_firstValue)\
1172 \n l_firstValue = false;\
1179 if (noOfComponents > 1 && independentComponents)
1182 \n for (int i = 0; i < in_noOfComponents; ++i)\
1184 \n // Get the intensity in volume scalar range\
1185 \n float intensity = in_scalarsRange[i][0] +\
1186 \n (in_scalarsRange[i][1] -\
1187 \n in_scalarsRange[i][0]) * scalar[i];\
1188 \n if (in_averageIPRange.x <= intensity &&\
1189 \n intensity <= in_averageIPRange.y)\
1191 \n l_avgValue[i] += computeOpacity(scalar, i) * scalar[i];\
1192 \n ++l_numSamples[i];\
1200 \n // Get the intensity in volume scalar range\
1201 \n float intensity = in_scalarsRange[0][0] +\
1202 \n (in_scalarsRange[0][1] -\
1203 \n in_scalarsRange[0][0]) * scalar.x;\
1204 \n if (in_averageIPRange.x <= intensity &&\
1205 \n intensity <= in_averageIPRange.y)\
1207 \n l_avgValue.x += computeOpacity(scalar) * scalar.x;\
1208 \n ++l_numSamples.x;\
1215 if (noOfComponents > 1 && independentComponents)
1218 \n for (int i = 0; i < in_noOfComponents; ++i)\
1220 \n float opacity = computeOpacity(scalar, i);\
1221 \n l_sumValue[i] = l_sumValue[i] + opacity * scalar[i];\
1228 \n float opacity = computeOpacity(scalar);\
1229 \n l_sumValue.x = l_sumValue.x + opacity * scalar.x;"
1235 if (noOfComponents > 1 && independentComponents)
1238 \n vec4 color[4]; vec4 tmp = vec4(0.0);\
1239 \n float totalAlpha = 0.0;\
1240 \n for (int i = 0; i < in_noOfComponents; ++i)\
1247 \n // Data fetching from the red channel of volume texture\
1248 \n float opacity = computeOpacity(scalar, i);\
1249 \n if (opacity > 0.0)\
1251 \n g_srcColor.a = opacity;\
1256 else if (!mask || !maskInput ||
1260 \n // Data fetching from the red channel of volume texture\
1261 \n color[i][3] = computeOpacity(scalar, i);\
1262 \n color[i] = computeColor(scalar, color[i][3], i);\
1263 \n totalAlpha += color[i][3] * in_componentWeight[i];\
1265 \n if (totalAlpha > 0.0)\
1267 \n for (int i = 0; i < in_noOfComponents; ++i)\
1269 \n // Only let visible components contribute to the final color\
1270 \n if (in_componentWeight[i] <= 0) continue;\
1272 \n tmp.x += color[i].x * color[i].w * in_componentWeight[i];\
1273 \n tmp.y += color[i].y * color[i].w * in_componentWeight[i];\
1274 \n tmp.z += color[i].z * color[i].w * in_componentWeight[i];\
1275 \n tmp.w += ((color[i].w * color[i].w)/totalAlpha);\
1278 \n g_fragColor = (1.0f - g_fragColor.a) * tmp + g_fragColor;"
1286 \n g_srcColor = vec4(0.0);\
1287 \n g_srcColor.a = computeOpacity(scalar);"
1292 if (!mask || !maskInput ||
1296 \n g_srcColor = vec4(0.0);\
1297 \n g_srcColor.a = computeOpacity(scalar);\
1298 \n if (g_srcColor.a > 0.0)\
1300 \n g_srcColor = computeColor(scalar, g_srcColor.a);"
1305 \n // Opacity calculation using compositing:\
1306 \n // Here we use front to back compositing scheme whereby\
1307 \n // the current sample value is multiplied to the\
1308 \n // currently accumulated alpha and then this product\
1309 \n // is subtracted from the sample value to get the\
1310 \n // alpha from the previous steps. Next, this alpha is\
1311 \n // multiplied with the current sample colour\
1312 \n // and accumulated to the composited colour. The alpha\
1313 \n // value from the previous steps is then accumulated\
1314 \n // to the composited colour alpha.\
1315 \n g_srcColor.rgb *= g_srcColor.a;\
1316 \n g_fragColor = (1.0f - g_fragColor.a) * g_srcColor + g_fragColor;"
1319 if (!mask || !maskInput ||
1344 \n // Special coloring mode which renders the Prop Id in fragments that\
1345 \n // have accumulated certain level of opacity. Used during the selection\
1346 \n // pass vtkHardwareSelection::ACTOR_PASS.\
1347 \n if (g_fragColor.a > 3.0/ 255.0)\
1349 \n gl_FragData[0] = vec4(in_propId, 1.0);\
1353 \n gl_FragData[0] = vec4(0.0);\
1363 \n // Special coloring mode which renders the voxel index in fragments that\
1364 \n // have accumulated certain level of opacity. Used during the selection\
1365 \n // pass vtkHardwareSelection::ID_LOW24.\
1366 \n if (g_fragColor.a > 3.0/ 255.0)\
1368 \n uvec3 volumeDim = uvec3(in_textureExtentsMax - in_textureExtentsMin);\
1369 \n uvec3 voxelCoords = uvec3(volumeDim * g_dataPos);\
1370 \n // vtkHardwareSelector assumes index 0 to be empty space, so add uint(1).\
1371 \n uint idx = volumeDim.x * volumeDim.y * voxelCoords.z +\
1372 \n volumeDim.x * voxelCoords.y + voxelCoords.x + uint(1);\
1373 \n gl_FragData[0] = vec4(float(idx % uint(256)) / 255.0,\
1374 \n float((idx / uint(256)) % uint(256)) / 255.0,\
1375 \n float((idx / uint(65536)) % uint(256)) / 255.0, 1.0);\
1379 \n gl_FragData[0] = vec4(0.0);\
1389 \n // Special coloring mode which renders the voxel index in fragments that\
1390 \n // have accumulated certain level of opacity. Used during the selection\
1391 \n // pass vtkHardwareSelection::ID_MID24.\
1392 \n if (g_fragColor.a > 3.0/ 255.0)\
1394 \n uvec3 volumeDim = uvec3(in_textureExtentsMax - in_textureExtentsMin);\
1395 \n uvec3 voxelCoords = uvec3(volumeDim * g_dataPos);\
1396 \n // vtkHardwareSelector assumes index 0 to be empty space, so add uint(1).\
1397 \n uint idx = volumeDim.x * volumeDim.y * voxelCoords.z +\
1398 \n volumeDim.x * voxelCoords.y + voxelCoords.x + uint(1);\
1399 \n idx = ((idx & 0xff000000) >> 24);\
1400 \n gl_FragData[0] = vec4(float(idx % uint(256)) / 255.0,\
1401 \n float((idx / uint(256)) % uint(256)) / 255.0,\
1402 \n float(idx / uint(65536)) / 255.0, 1.0);\
1406 \n gl_FragData[0] = vec4(0.0);\
1416 int independentComponents = 0)
1429 if (noOfComponents > 1 && independentComponents)
1432 \n g_srcColor = vec4(0);\
1433 \n for (int i = 0; i < in_noOfComponents; ++i)\
1435 \n vec4 tmp = computeColor(l_maxValue, computeOpacity(l_maxValue, i), i);\
1436 \n g_srcColor[0] += tmp[0] * tmp[3] * in_componentWeight[i];\
1437 \n g_srcColor[1] += tmp[1] * tmp[3] * in_componentWeight[i];\
1438 \n g_srcColor[2] += tmp[2] * tmp[3] * in_componentWeight[i];\
1439 \n g_srcColor[3] += tmp[3] * in_componentWeight[i];\
1441 \n g_fragColor = g_srcColor;"
1447 \n g_srcColor = computeColor(l_maxValue,\
1448 \n computeOpacity(l_maxValue));\
1449 \n g_fragColor.rgb = g_srcColor.rgb * g_srcColor.a;\
1450 \n g_fragColor.a = g_srcColor.a;"
1456 if (noOfComponents > 1 && independentComponents)
1459 \n g_srcColor = vec4(0);\
1460 \n for (int i = 0; i < in_noOfComponents; ++i)\
1462 \n vec4 tmp = computeColor(l_minValue, computeOpacity(l_minValue, i), i);\
1463 \n g_srcColor[0] += tmp[0] * tmp[3] * in_componentWeight[i];\
1464 \n g_srcColor[1] += tmp[1] * tmp[3] * in_componentWeight[i];\
1465 \n g_srcColor[2] += tmp[2] * tmp[3] * in_componentWeight[i];\
1466 \n g_srcColor[2] += tmp[3] * tmp[3] * in_componentWeight[i];\
1468 \n g_fragColor = g_srcColor;"
1474 \n g_srcColor = computeColor(l_minValue,\
1475 \n computeOpacity(l_minValue));\
1476 \n g_fragColor.rgb = g_srcColor.rgb * g_srcColor.a;\
1477 \n g_fragColor.a = g_srcColor.a;"
1483 if (noOfComponents > 1 && independentComponents)
1486 \n for (int i = 0; i < in_noOfComponents; ++i)\
1488 \n if (l_numSamples[i] == uint(0))\
1492 \n l_avgValue[i] = l_avgValue[i] * in_componentWeight[i] /\
1493 \n l_numSamples[i];\
1496 \n l_avgValue[0] += l_avgValue[i];\
1499 \n l_avgValue[0] = clamp(l_avgValue[0], 0.0, 1.0);\
1500 \n g_fragColor = vec4(vec3(l_avgValue[0]), 1.0);"
1506 \n if (l_numSamples.x == uint(0))\
1512 \n l_avgValue.x /= l_numSamples.x;\
1513 \n l_avgValue.x = clamp(l_avgValue.x, 0.0, 1.0);\
1514 \n g_fragColor = vec4(vec3(l_avgValue.x), 1.0);\
1521 if (noOfComponents > 1 && independentComponents)
1525 \n l_sumValue.x *= in_componentWeight.x;\
1526 \n for (int i = 1; i < in_noOfComponents; ++i)\
1528 \n l_sumValue.x += l_sumValue[i] * in_componentWeight[i];\
1530 \n l_sumValue.x = clamp(l_sumValue.x, 0.0, 1.0);\
1531 \n g_fragColor = vec4(vec3(l_sumValue.x), 1.0);"
1537 \n l_sumValue.x = clamp(l_sumValue.x, 0.0, 1.0);\
1538 \n g_fragColor = vec4(vec3(l_sumValue.x), 1.0);"
1569 \n uniform vec3 in_propId;");
1578 \n // Flag to indicate if the raymarch loop should terminate \
1579 \n bool stop = false;\
1581 \n float l_terminatePointMax = 0.0;\
1584 \n vec4 l_depthValue = vec4(1.0,1.0,1.0,1.0);\
1586 \n vec4 l_depthValue = texture2D(in_depthSampler, fragTexCoord);\
1589 \n if(gl_FragCoord.z >= l_depthValue.x)\
1594 \n // color buffer or max scalar buffer have a reduced size.\
1595 \n fragTexCoord = (gl_FragCoord.xy - in_windowLowerLeftCorner) *\
1596 \n in_inverseOriginalWindowSize;\
1598 \n // Compute max number of iterations it will take before we hit\
1599 \n // the termination point\
1601 \n // Abscissa of the point on the depth buffer along the ray.\
1602 \n // point in texture coordinates\
1603 \n vec4 terminatePoint;\
1604 \n terminatePoint.x = (gl_FragCoord.x - in_windowLowerLeftCorner.x) * 2.0 *\
1605 \n in_inverseWindowSize.x - 1.0;\
1606 \n terminatePoint.y = (gl_FragCoord.y - in_windowLowerLeftCorner.y) * 2.0 *\
1607 \n in_inverseWindowSize.y - 1.0;\
1608 \n terminatePoint.z = (2.0 * l_depthValue.x - (gl_DepthRange.near +\
1609 \n gl_DepthRange.far)) / gl_DepthRange.diff;\
1610 \n terminatePoint.w = 1.0;\
1612 \n // From normalized device coordinates to eye coordinates.\
1613 \n // in_projectionMatrix is inversed because of way VT\
1614 \n // From eye coordinates to texture coordinates\
1615 \n terminatePoint = ip_inverseTextureDataAdjusted *\
1616 \n in_inverseVolumeMatrix *\
1617 \n in_inverseModelViewMatrix *\
1618 \n in_inverseProjectionMatrix *\
1620 \n terminatePoint /= terminatePoint.w;\
1622 \n l_terminatePointMax = length(terminatePoint.xyz - g_dataPos.xyz) /\
1623 \n length(g_dirStep);\
1624 \n float l_currentT = 0.0;");
1633 \n if(any(greaterThan(g_dataPos, in_texMax)) ||\
1634 \n any(lessThan(g_dataPos, in_texMin)))\
1639 \n // Early ray termination\
1640 \n // if the currently composited colour alpha is already fully saturated\
1641 \n // we terminated the loop or if we have hit an obstacle in the\
1642 \n // direction of they ray (using depth buffer) we terminate as well.\
1643 \n if((g_fragColor.a > (1.0 - 1.0/255.0)) || \
1644 \n l_currentT >= l_terminatePointMax)\
1678 \nuniform float in_croppingPlanes[6];\
1679 \nuniform int in_croppingFlags [32];\
1680 \n// X: axis = 0, Y: axis = 1, Z: axis = 2\
1681 \n// cp Cropping plane bounds (minX, maxX, minY, maxY, minZ, maxZ)\
1682 \nint computeRegionCoord(float cp[6], vec3 pos, int axis)\
1684 \n int cpmin = axis * 2;\
1685 \n int cpmax = cpmin + 1;\
1687 \n if (pos[axis] < cp[cpmin])\
1691 \n else if (pos[axis] >= cp[cpmin] &&\
1692 \n pos[axis] < cp[cpmax])\
1696 \n else if (pos[axis] >= cp[cpmax])\
1703 \nint computeRegion(float cp[6], vec3 pos)\
1705 \n return (computeRegionCoord(cp, pos, 0) +\
1706 \n (computeRegionCoord(cp, pos, 1) - 1) * 3 +\
1707 \n (computeRegionCoord(cp, pos, 2) - 1) * 9);\
1722 \n // Convert cropping region to texture space\
1723 \n float croppingPlanesTexture[6];\
1724 \n mat4 datasetToTextureMat = in_inverseTextureDatasetMatrix;\
1726 \n vec4 temp = vec4(in_croppingPlanes[0], 0.0, 0.0, 1.0);\
1727 \n temp = datasetToTextureMat * temp;\
1728 \n if (temp[3] != 0.0)\
1730 \n temp[0] /= temp[3];\
1732 \n croppingPlanesTexture[0] = temp[0];\
1734 \n temp = vec4(in_croppingPlanes[1], 0.0, 0.0, 1.0);\
1735 \n temp = datasetToTextureMat * temp;\
1736 \n if (temp[3] != 0.0)\
1738 \n temp[0] /= temp[3];\
1740 \n croppingPlanesTexture[1] = temp[0];\
1742 \n temp = vec4(0.0, in_croppingPlanes[2], 0.0, 1.0);\
1743 \n temp = datasetToTextureMat * temp;\
1744 \n if (temp[3] != 0.0)\
1746 \n temp[1] /= temp[3];\
1748 \n croppingPlanesTexture[2] = temp[1];\
1750 \n temp = vec4(0.0, in_croppingPlanes[3], 0.0, 1.0);\
1751 \n temp = datasetToTextureMat * temp;\
1752 \n if (temp[3] != 0.0)\
1754 \n temp[1] /= temp[3];\
1756 \n croppingPlanesTexture[3] = temp[1];\
1758 \n temp = vec4(0.0, 0.0, in_croppingPlanes[4], 1.0);\
1759 \n temp = datasetToTextureMat * temp;\
1760 \n if (temp[3] != 0.0)\
1762 \n temp[2] /= temp[3];\
1764 \n croppingPlanesTexture[4] = temp[2];\
1766 \n temp = vec4(0.0, 0.0, in_croppingPlanes[5], 1.0);\
1767 \n temp = datasetToTextureMat * temp;\
1768 \n if (temp[3] != 0.0)\
1770 \n temp[2] /= temp[3];\
1772 \n croppingPlanesTexture[5] = temp[2];"
1786 \n // Determine region\
1787 \n int regionNo = computeRegion(croppingPlanesTexture, g_dataPos);\
1789 \n // Do & operation with cropping flags\
1790 \n // Pass the flag that its Ok to sample or not to sample\
1791 \n if (in_croppingFlags[regionNo] == 0)\
1793 \n // Skip this voxel\
1837 vec4 temp = in_volumeMatrix * vec4(rayDir, 0.0);\
1838 \n if (temp.w != 0.0)\
1840 \n temp = temp/temp.w;\
1843 vec3 objRayDir = temp.xyz;");
1848 vec3 objRayDir = normalize(in_projectionDirection);");
1852 \n int clippingPlanesSize = int(in_clippingPlanes[0]);\
1853 \n vec4 objDataPos = vec4(0.0);\
1854 \n mat4 textureToObjMat = in_volumeMatrix *\
1855 \n in_textureDatasetMatrix;\
1857 \n vec4 terminatePointObj = textureToObjMat * terminatePoint;\
1858 \n if (terminatePointObj.w != 0.0)\
1860 \n terminatePointObj = terminatePointObj/ terminatePointObj.w ;\
1861 \n terminatePointObj.w = 1.0;\
1864 \n for (int i = 0; i < clippingPlanesSize; i = i + 6)\
1866 \n if (in_useJittering)\
1868 \n objDataPos = textureToObjMat * vec4(g_dataPos - (g_dirStep\
1869 \n * jitterValue), 1.0);\
1873 \n objDataPos = textureToObjMat * vec4(g_dataPos - g_dirStep, 1.0);\
1875 \n if (objDataPos.w != 0.0)\
1877 \n objDataPos = objDataPos/objDataPos.w; objDataPos.w = 1.0;\
1879 \n vec3 planeOrigin = vec3(in_clippingPlanes[i + 1],\
1880 \n in_clippingPlanes[i + 2],\
1881 \n in_clippingPlanes[i + 3]);\
1882 \n vec3 planeNormal = vec3(in_clippingPlanes[i + 4],\
1883 \n in_clippingPlanes[i + 5],\
1884 \n in_clippingPlanes[i + 6]);\
1885 \n vec3 normalizedPlaneNormal = normalize(planeNormal);\
1887 \n float rayDotNormal = dot(objRayDir, normalizedPlaneNormal);\
1888 \n bool frontFace = rayDotNormal > 0;\
1889 \n float distance = dot(normalizedPlaneNormal, planeOrigin - objDataPos.xyz);\
1891 \n if (frontFace && // Observing from the clipped side (plane's front face)\
1892 \n distance > 0.0) // Ray-entry lies on the clipped side.\
1894 \n // Scale the point-plane distance to the ray direction and update the\
1896 \n float rayScaledDist = distance / rayDotNormal;\
1897 \n vec4 newObjDataPos = vec4(objDataPos.xyz + rayScaledDist * objRayDir, 1.0);\
1898 \n newObjDataPos = in_inverseTextureDatasetMatrix\
1899 \n * in_inverseVolumeMatrix * vec4(newObjDataPos.xyz, 1.0);\
1900 \n if (newObjDataPos.w != 0.0)\
1902 \n newObjDataPos /= newObjDataPos.w;\
1904 \n if (in_useJittering)\
1906 \n g_dataPos = newObjDataPos.xyz + g_dirStep * jitterValue;\
1910 \n g_dataPos = newObjDataPos.xyz + g_dirStep;\
1913 \n bool stop = any(greaterThan(g_dataPos, in_texMax)) ||\
1914 \n any(lessThan(g_dataPos, in_texMin));\
1917 \n // The ray exits the bounding box before ever intersecting the plane (only\
1918 \n // the clipped space is hit).\
1922 \n bool behindGeometry = dot(terminatePointObj.xyz - planeOrigin.xyz, normalizedPlaneNormal) < 0.0;\
1923 \n if (behindGeometry)\
1925 \n // Geometry appears in front of the plane.\
1929 \n // Update the number of ray marching steps to account for the clipped entry point (\
1930 \n // this is necessary in case the ray hits geometry after marching behind the plane,\
1931 \n // given that the number of steps was assumed to be from the not-clipped entry).\
1932 \n l_terminatePointMax = length(terminatePoint.xyz - g_dataPos.xyz) /\
1933 \n length(g_dirStep);\
1952 \n for (int i = 0; i < clippingPlanesSize && !l_skip; i = i + 6)\
1954 \n vec4 objDataPos = textureToObjMat * vec4(g_dataPos, 1.0);\
1955 \n if (objDataPos.w != 0.0)\
1957 \n objDataPos /= objDataPos.w;\
1959 \n vec3 planeOrigin = vec3(in_clippingPlanes[i + 1],\
1960 \n in_clippingPlanes[i + 2],\
1961 \n in_clippingPlanes[i + 3]);\
1962 \n vec3 planeNormal = vec3(in_clippingPlanes[i + 4],\
1963 \n in_clippingPlanes[i + 5],\
1964 \n in_clippingPlanes[i + 6]);\
1965 \n if (dot(vec3(objDataPos.xyz - planeOrigin), planeNormal) < 0 && dot(objRayDir, planeNormal) < 0)\
1989 int vtkNotUsed(maskType))
1991 if (!mask || !maskInput)
2009 if (!mask || !maskInput ||
2017 \nvec4 maskValue = texture3D(in_mask, g_dataPos);\
2018 \nif(maskValue.r <= 0.0)\
2034 if (!mask || !maskInput ||
2042 \nuniform float in_maskBlendFactor;\
2043 \nuniform sampler2D in_mask1;\
2044 \nuniform sampler2D in_mask2;"
2058 if (!mask || !maskInput ||
2066 \nvec4 scalar = texture3D(in_volume, g_dataPos);");
2069 if (noOfComponents == 1)
2072 \n scalar.r = scalar.r*in_volume_scale.r + in_volume_bias.r;\
2073 \n scalar = vec4(scalar.r,scalar.r,scalar.r,scalar.r);"
2080 \n scalar = scalar*in_volume_scale + in_volume_bias;"
2085 \nif (in_maskBlendFactor == 0.0)\
2087 \n g_srcColor = computeColor(scalar, computeOpacity(scalar));\
2091 \n float opacity = computeOpacity(scalar);\
2092 \n // Get the mask value at this same location\
2093 \n vec4 maskValue = texture3D(in_mask, g_dataPos);\
2094 \n if(maskValue.r == 0.0)\
2096 \n g_srcColor = computeColor(scalar, opacity);\
2100 \n if (maskValue.r == 1.0/255.0)\
2102 \n g_srcColor = texture2D(in_mask1, vec2(scalar.w,0.0));\
2106 \n // maskValue.r == 2.0/255.0\
2107 \n g_srcColor = texture2D(in_mask2, vec2(scalar.w,0.0));\
2109 \n g_srcColor.a = 1.0;\
2110 \n if(in_maskBlendFactor < 1.0)\
2112 \n g_srcColor = (1.0 - in_maskBlendFactor) *\
2113 \n computeColor(scalar, opacity) +\
2114 \n in_maskBlendFactor * g_srcColor;\
2117 \n g_srcColor.a = opacity;\
2129 \n vec3 l_opaqueFragPos = vec3(-1.0);\
2130 \n if(in_clampDepthToBackface)\
2132 \n l_opaqueFragPos = g_dataPos;\
2134 \n bool l_updateDepth = true;"
2144 \n if(!l_skip && g_srcColor.a > 0.0 && l_updateDepth)\
2146 \n l_opaqueFragPos = g_dataPos;\
2147 \n l_updateDepth = false;\
2158 \n if (l_opaqueFragPos == vec3(-1.0))\
2160 \n gl_FragData[1] = vec4(1.0);\
2164 \n vec4 depthValue = in_projectionMatrix * in_modelViewMatrix *\
2165 \n in_volumeMatrix * in_textureDatasetMatrix *\
2166 \n vec4(l_opaqueFragPos, 1.0);\
2167 \n depthValue /= depthValue.w;\
2168 \n gl_FragData[1] = vec4(vec3(0.5 * (gl_DepthRange.far -\
2169 \n gl_DepthRange.near) * depthValue.z + 0.5 *\
2170 \n (gl_DepthRange.far + gl_DepthRange.near)), 1.0);\
2181 \n vec3 l_isoPos = g_dataPos;"
2191 \n if(!l_skip && g_srcColor.a > 0.0)\
2193 \n l_isoPos = g_dataPos;\
2194 \n g_exit = true; l_skip = true;\
2205 \n vec4 depthValue = in_projectionMatrix * in_modelViewMatrix *\
2206 \n in_volumeMatrix * in_textureDatasetMatrix *\
2207 \n vec4(l_isoPos, 1.0);\
2208 \n gl_FragData[0] = vec4(l_isoPos, 1.0);\
2209 \n gl_FragData[1] = vec4(vec3((depthValue.z/depthValue.w) * 0.5 + 0.5),\
2215 #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 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 ShadingDeclarationFragment(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(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)
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 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))