 |
VTK
9.0.1
|
Go to the documentation of this file.
16 #ifndef vtkVolumeShaderComposer_h
17 #define vtkVolumeShaderComposer_h
36 for (
auto& item : inputs)
49 for (
auto& item : inputs)
52 const bool lighting = volProp->
GetShade() == 1;
61 for (
auto& item : inputs)
65 if (useClippedVoxelIntensity)
75 const std::string base = arrayName.substr(0, arrayName.length() - 3);
93 " //Transform vertex (data coordinates) to clip coordinates\n"
94 " // p_clip = T_ProjViewModel * T_dataToWorld * p_data\n"
95 " vec4 pos = in_projectionMatrix * in_modelViewMatrix * in_volumeMatrix[0] *\n"
96 " vec4(in_vertexPos.xyz, 1.0);\n"
97 " gl_Position = pos;\n");
105 " // Transform vertex (data coordinates) to texture coordinates.\n"
106 " // p_texture = T_dataToTex * p_data\n"
107 " vec3 uvx = sign(in_cellSpacing[0]) * (in_inverseTextureDatasetMatrix[0] *\n"
108 " vec4(in_vertexPos, 1.0)).xyz;\n"
110 " // For point dataset, we offset the texture coordinate\n"
111 " // to account for OpenGL treating voxel at the center of the cell.\n"
112 " // Transform cell tex-coordinates to point tex-coordinates (cellToPoint\n"
113 " // is an identity matrix in the case of cell data).\n"
114 " ip_textureCoords = (in_cellToPoint[0] * vec4(uvx, 1.0)).xyz;\n"
115 " ip_inverseTextureDataAdjusted = in_cellToPoint[0] * in_inverseTextureDatasetMatrix[0];\n");
120 vtkVolume* vtkNotUsed(vol),
bool multipleInputs)
123 const int numInputs = gpuMapper->GetInputCount();
125 std::ostringstream ss;
126 ss <<
"uniform vec3 in_cellSpacing[" << numInputs
128 "uniform mat4 in_modelViewMatrix;\n"
129 "uniform mat4 in_projectionMatrix;\n";
131 const int numTransf = multipleInputs ? numInputs + 1 : 1;
132 ss <<
"uniform mat4 in_volumeMatrix[" << numTransf
134 "uniform mat4 in_inverseTextureDatasetMatrix["
137 "uniform mat4 in_cellToPoint["
141 "//This variable could be 'invariant varying' but it is declared\n"
142 "//as 'varying' to avoid compiler compatibility issues.\n"
143 "out mat4 ip_inverseTextureDataAdjusted;\n";
151 int lightingComplexity,
int noOfComponents,
int independentComponents)
153 const int numInputs =
static_cast<int>(inputs.size());
155 std::ostringstream toShaderStr;
156 toShaderStr <<
"uniform sampler3D in_volume[" << numInputs <<
"];\n";
158 toShaderStr <<
"uniform vec4 in_volume_scale[" << numInputs
160 "uniform vec4 in_volume_bias["
161 << numInputs <<
"];\n";
163 toShaderStr <<
"uniform int in_noOfComponents;\n"
164 "uniform int in_independentComponents;\n"
166 "uniform sampler2D in_noiseSampler;\n"
168 "uniform sampler2D in_depthSampler;\n"
171 "// Camera position\n"
172 "uniform vec3 in_cameraPos;\n";
176 const int numTransf = (numInputs > 1) ? numInputs + 1 : 1;
177 toShaderStr <<
"uniform mat4 in_volumeMatrix[" << numTransf
179 "uniform mat4 in_inverseVolumeMatrix["
182 "uniform mat4 in_textureDatasetMatrix["
185 "uniform mat4 in_inverseTextureDatasetMatrix["
188 "uniform mat4 in_textureToEye["
191 "uniform vec3 in_texMin["
194 "uniform vec3 in_texMax["
197 "uniform mat4 in_cellToPoint["
198 << numTransf <<
"];\n";
200 toShaderStr <<
"// view and model matrices\n"
201 "uniform mat4 in_projectionMatrix;\n"
202 "uniform mat4 in_inverseProjectionMatrix;\n"
203 "uniform mat4 in_modelViewMatrix;\n"
204 "uniform mat4 in_inverseModelViewMatrix;\n"
205 "in mat4 ip_inverseTextureDataAdjusted;\n"
208 "uniform vec3 in_cellStep["
209 << numInputs <<
"];\n";
211 toShaderStr <<
"uniform vec2 in_scalarsRange[" << numInputs * 4
213 "uniform vec3 in_cellSpacing["
217 "// Sample distance\n"
218 "uniform float in_sampleDistance;\n"
221 "uniform vec2 in_windowLowerLeftCorner;\n"
222 "uniform vec2 in_inverseOriginalWindowSize;\n"
223 "uniform vec2 in_inverseWindowSize;\n"
224 "uniform vec3 in_textureExtentsMax;\n"
225 "uniform vec3 in_textureExtentsMin;\n"
227 "// Material and lighting\n"
228 "uniform vec3 in_diffuse[4];\n"
229 "uniform vec3 in_ambient[4];\n"
230 "uniform vec3 in_specular[4];\n"
231 "uniform float in_shininess[4];\n"
234 "uniform bool in_useJittering;\n"
235 "vec3 g_rayJitter = vec3(0.0);\n"
237 "uniform vec2 in_averageIPRange;\n";
239 const bool hasGradientOpacity = HasGradientOpacity(inputs);
240 if (lightingComplexity > 0 || hasGradientOpacity)
242 toShaderStr <<
"uniform bool in_twoSidedLighting;\n";
245 if (lightingComplexity == 3)
247 toShaderStr <<
"vec4 g_fragWorldPos;\n"
248 "uniform int in_numberOfLights;\n"
249 "uniform vec3 in_lightAmbientColor[6];\n"
250 "uniform vec3 in_lightDiffuseColor[6];\n"
251 "uniform vec3 in_lightSpecularColor[6];\n"
252 "uniform vec3 in_lightDirection[6];\n"
253 "uniform vec3 in_lightPosition[6];\n"
254 "uniform vec3 in_lightAttenuation[6];\n"
255 "uniform float in_lightConeAngle[6];\n"
256 "uniform float in_lightExponent[6];\n"
257 "uniform int in_lightPositional[6];\n";
259 else if (lightingComplexity == 2)
261 toShaderStr <<
"vec4 g_fragWorldPos;\n"
262 "uniform int in_numberOfLights;\n"
263 "uniform vec3 in_lightAmbientColor[6];\n"
264 "uniform vec3 in_lightDiffuseColor[6];\n"
265 "uniform vec3 in_lightSpecularColor[6];\n"
266 "uniform vec3 in_lightDirection[6];\n";
270 toShaderStr <<
"uniform vec3 in_lightAmbientColor[1];\n"
271 "uniform vec3 in_lightDiffuseColor[1];\n"
272 "uniform vec3 in_lightSpecularColor[1];\n"
273 "vec4 g_lightPosObj;\n"
279 if (noOfComponents > 1 && independentComponents)
281 toShaderStr <<
"uniform vec4 in_componentWeight;\n";
288 toShaderStr <<
"uniform sampler2D in_depthPassSampler;\n";
293 toShaderStr <<
"#if NUMBER_OF_CONTOURS\n"
294 "uniform float in_isosurfacesValues[NUMBER_OF_CONTOURS];\n"
296 "int findIsoSurfaceIndex(float scalar, float array[NUMBER_OF_CONTOURS+2])\n"
298 " int index = NUMBER_OF_CONTOURS >> 1;\n"
299 " while (scalar > array[index]) ++index;\n"
300 " while (scalar < array[index]) --index;\n"
307 vtkVolume* vol = inputs.begin()->second.Volume;
310 if (func && func->
IsA(
"vtkPlane"))
313 <<
"uniform vec3 in_slicePlaneOrigin;\n"
314 "uniform vec3 in_slicePlaneNormal;\n"
315 "vec3 g_intersection;\n"
317 "float intersectRayPlane(vec3 rayOrigin, vec3 rayDir)\n"
319 " vec4 planeNormal = in_inverseVolumeMatrix[0] * vec4(in_slicePlaneNormal, 0.0);\n"
320 " float denom = dot(planeNormal.xyz, rayDir);\n"
321 " if (abs(denom) > 1e-6)\n"
323 " vec4 planeOrigin = in_inverseVolumeMatrix[0] * vec4(in_slicePlaneOrigin, 1.0);\n"
324 " return dot(planeOrigin.xyz - rayOrigin, planeNormal.xyz) / denom;\n"
331 return toShaderStr.str();
339 vtkVolume* vol = inputs.begin()->second.Volume;
347 \n vec2 fragTexCoord2 = (gl_FragCoord.xy - in_windowLowerLeftCorner) *\
348 \n in_inverseWindowSize;\
349 \n vec4 depthValue = texture2D(in_depthPassSampler, fragTexCoord2);\
350 \n vec4 rayOrigin = WindowToNDC(gl_FragCoord.x, gl_FragCoord.y, depthValue.x);\
352 \n // From normalized device coordinates to eye coordinates.\
353 \n // in_projectionMatrix is inversed because of way VT\
354 \n // From eye coordinates to texture coordinates\
355 \n rayOrigin = in_inverseTextureDatasetMatrix[0] *\
356 \n in_inverseVolumeMatrix[0] *\
357 \n in_inverseModelViewMatrix *\
358 \n in_inverseProjectionMatrix *\
360 \n rayOrigin /= rayOrigin.w;\
361 \n g_rayOrigin = rayOrigin.xyz;");
366 \n // Get the 3D texture coordinates for lookup into the in_volume dataset\
367 \n g_rayOrigin = ip_textureCoords.xyz;");
372 \n // Eye position in dataset space\
373 \n g_eyePosObj = in_inverseVolumeMatrix[0] * vec4(in_cameraPos, 1.0);\
375 \n // Getting the ray marching direction (in dataset space)\
376 \n vec3 rayDir = computeRayDirection();\
378 \n // 2D Texture fragment coordinates [0,1] from fragment coordinates.\
379 \n // The frame buffer texture has the size of the plain buffer but \
380 \n // we use a fraction of it. The texture coordinate is less than 1 if\
381 \n // the reduction factor is less than 1.\
382 \n // Device coordinates are between -1 and 1. We need texture\
383 \n // coordinates between 0 and 1. The in_depthSampler\
384 \n // buffer has the original size buffer.\
385 \n vec2 fragTexCoord = (gl_FragCoord.xy - in_windowLowerLeftCorner) *\
386 \n in_inverseWindowSize;\
388 \n // Multiply the raymarching direction with the step size to get the\
389 \n // sub-step size we need to take at each raymarching step\
390 \n g_dirStep = (ip_inverseTextureDataAdjusted *\
391 \n vec4(rayDir, 0.0)).xyz * in_sampleDistance;\
398 \n if (in_useJittering)\
400 \n float jitterValue = texture2D(in_noiseSampler, gl_FragCoord.xy / textureSize(in_noiseSampler, 0)).x;\
401 \n g_rayJitter = g_dirStep * jitterValue;\
405 \n g_rayJitter = g_dirStep;\
407 \n g_rayOrigin += g_rayJitter;\
412 \n // Flag to determine if voxel should be considered for the rendering\
413 \n g_skip = false;");
418 \n // Light position in dataset space\
419 \n g_lightPosObj = (in_inverseVolumeMatrix[0] *\
420 \n vec4(in_cameraPos, 1.0));\
421 \n g_ldir = normalize(g_lightPosObj.xyz - ip_vertexPos);\
422 \n g_vdir = normalize(g_eyePosObj.xyz - ip_vertexPos);\
423 \n g_h = normalize(g_ldir + g_vdir);");
436 \n g_skip = false;");
441 \n g_dataPos = g_intersection;\
457 int independentComponents, std::map<int, std::string> gradientTableMap)
459 std::ostringstream ss;
460 ss <<
"uniform sampler2D " << ArrayBaseName(gradientTableMap[0]) <<
"[" << noOfComponents
462 ss <<
"uniform sampler2D in_labelMapGradientOpacity;\n";
468 \nfloat computeGradientOpacity(vec4 grad)\
470 \n return texture2D(" +
471 gradientTableMap[0] +
", vec2(grad.w, 0.0)).r;\
477 \nfloat computeGradientOpacity(vec4 grad, int component)\
480 for (
int i = 0; i < noOfComponents; ++i)
482 std::ostringstream toString;
485 \n if (component == " +
486 toString.str() +
")");
490 \n return texture2D(" +
491 gradientTableMap[i] +
", vec2(grad.w, 0.0)).r;\
500 (noOfComponents == 1 || !independentComponents))
503 \nfloat computeGradientOpacityForLabel(vec4 grad, float label)\
505 \n return texture2D(in_labelMapGradientOpacity, vec2(grad.w, label)).r;\
516 const bool hasLighting = HasLighting(inputs);
517 const bool hasGradientOp = HasGradientOpacity(inputs);
520 if (hasLighting || hasGradientOp)
523 "// c is short for component\n"
524 "vec4 computeGradient(in vec3 texPos, in int c, in sampler3D volume,in int index)\n"
526 " // Approximate Nabla(F) derivatives with central differences.\n"
527 " vec3 g1; // F_front\n"
528 " vec3 g2; // F_back\n"
529 " vec3 xvec = vec3(in_cellStep[index].x, 0.0, 0.0);\n"
530 " vec3 yvec = vec3(0.0, in_cellStep[index].y, 0.0);\n"
531 " vec3 zvec = vec3(0.0, 0.0, in_cellStep[index].z);\n"
532 " vec3 texPosPvec[3];\n"
533 " texPosPvec[0] = texPos + xvec;\n"
534 " texPosPvec[1] = texPos + yvec;\n"
535 " texPosPvec[2] = texPos + zvec;\n"
536 " vec3 texPosNvec[3];\n"
537 " texPosNvec[0] = texPos - xvec;\n"
538 " texPosNvec[1] = texPos - yvec;\n"
539 " texPosNvec[2] = texPos - zvec;\n"
540 " g1.x = texture3D(volume, vec3(texPosPvec[0]))[c];\n"
541 " g1.y = texture3D(volume, vec3(texPosPvec[1]))[c];\n"
542 " g1.z = texture3D(volume, vec3(texPosPvec[2]))[c];\n"
543 " g2.x = texture3D(volume, vec3(texPosNvec[0]))[c];\n"
544 " g2.y = texture3D(volume, vec3(texPosNvec[1]))[c];\n"
545 " g2.z = texture3D(volume, vec3(texPosNvec[2]))[c];\n"
550 std::string(
" vec4 g1ObjDataPos[3], g2ObjDataPos[3];\n"
551 " for (int i = 0; i < 3; ++i)\n"
553 " g1ObjDataPos[i] = clip_texToObjMat * vec4(texPosPvec[i], 1.0);\n"
554 " if (g1ObjDataPos[i].w != 0.0)\n"
556 " g1ObjDataPos[i] /= g1ObjDataPos[i].w;\n"
558 " g2ObjDataPos[i] = clip_texToObjMat * vec4(texPosNvec[i], 1.0);\n"
559 " if (g2ObjDataPos[i].w != 0.0)\n"
561 " g2ObjDataPos[i] /= g2ObjDataPos[i].w;\n"
565 " for (int i = 0; i < clip_numPlanes && !g_skip; i = i + 6)\n"
567 " vec3 planeOrigin = vec3(in_clippingPlanes[i + 1],\n"
568 " in_clippingPlanes[i + 2],\n"
569 " in_clippingPlanes[i + 3]);\n"
570 " vec3 planeNormal = normalize(vec3(in_clippingPlanes[i + 4],\n"
571 " in_clippingPlanes[i + 5],\n"
572 " in_clippingPlanes[i + 6]));\n"
573 " for (int j = 0; j < 3; ++j)\n"
575 " if (dot(vec3(planeOrigin - g1ObjDataPos[j].xyz), planeNormal) > 0)\n"
577 " g1[j] = in_clippedVoxelIntensity;\n"
579 " if (dot(vec3(planeOrigin - g2ObjDataPos[j].xyz), planeNormal) > 0)\n"
581 " g2[j] = in_clippedVoxelIntensity;\n"
587 shaderStr +=
std::string(
" // Apply scale and bias to the fetched values.\n"
588 " g1 = g1 * in_volume_scale[index][c] + in_volume_bias[index][c];\n"
589 " g2 = g2 * in_volume_scale[index][c] + in_volume_bias[index][c];\n"
594 std::string(
" // Central differences: (F_front - F_back) / 2h\n"
595 " // This version of computeGradient() is only used for lighting\n"
596 " // calculations (only direction matters), hence the difference is\n"
597 " // not scaled by 2h and a dummy gradient mag is returned (-1.).\n"
598 " return vec4((g1 - g2) / in_cellSpacing[index], -1.0);\n"
603 shaderStr +=
std::string(
" // Scale values the actual scalar range.\n"
604 " float range = in_scalarsRange[c][1] - in_scalarsRange[c][0];\n"
605 " g1 = in_scalarsRange[c][0] + range * g1;\n"
606 " g2 = in_scalarsRange[c][0] + range * g2;\n"
608 " // Central differences: (F_front - F_back) / 2h\n"
611 " float avgSpacing = (in_cellSpacing[index].x +\n"
612 " in_cellSpacing[index].y + in_cellSpacing[index].z) / 3.0;\n"
613 " vec3 aspect = in_cellSpacing[index] * 2.0 / avgSpacing;\n"
615 " float grad_mag = length(g2);\n"
617 " // Handle normalizing with grad_mag == 0.0\n"
618 " g2 = grad_mag > 0.0 ? normalize(g2) : vec3(0.0);\n"
620 " // Since the actual range of the gradient magnitude is unknown,\n"
621 " // assume it is in the range [0, 0.25 * dataRange].\n"
622 " range = range != 0 ? range : 1.0;\n"
623 " grad_mag = grad_mag / (0.25 * range);\n"
624 " grad_mag = clamp(grad_mag, 0.0, 1.0);\n"
626 " return vec4(g2.xyz, grad_mag);\n"
633 "vec4 computeGradient(in vec3 texPos, in int c, in sampler3D volume, in int index)\n"
635 " return vec4(0.0);\n"
644 vtkVolume* vol,
int noOfComponents,
int independentComponents,
int vtkNotUsed(numberOfLights),
645 int lightingComplexity)
649 \nvec4 computeLighting(vec4 color, int component, float label)\
651 \n vec4 finalColor = vec4(0.0);");
654 int const shadeReqd = volProperty->
GetShade() &&
663 switch (transferMode)
667 " // Compute gradient function only once\n"
668 " vec4 gradient = computeGradient(g_dataPos, component, in_volume[0], 0);\n");
671 shaderStr +=
std::string(
" // TransferFunction2D is enabled so the gradient for\n"
672 " // each component has already been cached\n"
673 " vec4 gradient = g_gradients_0[component];\n");
680 if (lightingComplexity == 1)
683 \n vec3 diffuse = vec3(0.0);\
684 \n vec3 specular = vec3(0.0);\
685 \n vec3 normal = gradient.xyz;\
686 \n float normalLength = length(normal);\
687 \n if (normalLength > 0.0)\
689 \n normal = normalize(normal);\
693 \n normal = vec3(0.0, 0.0, 0.0);\
695 \n float nDotL = dot(normal, g_ldir);\
696 \n float nDotH = dot(normal, g_h);\
697 \n if (nDotL < 0.0 && in_twoSidedLighting)\
701 \n if (nDotH < 0.0 && in_twoSidedLighting)\
707 \n diffuse = nDotL * in_diffuse[component] *\
708 \n in_lightDiffuseColor[0] * color.rgb;\
710 \n specular = pow(nDotH, in_shininess[component]) *\
711 \n in_specular[component] *\
712 \n in_lightSpecularColor[0];\
713 \n // For the headlight, ignore the light's ambient color\
714 \n // for now as it is causing the old mapper tests to fail\
715 \n finalColor.xyz = in_ambient[component] * color.rgb +\
716 \n diffuse + specular;\
719 else if (lightingComplexity == 2)
722 \n g_fragWorldPos = in_modelViewMatrix * in_volumeMatrix[0] *\
723 \n in_textureDatasetMatrix[0] * vec4(-g_dataPos, 1.0);\
724 \n if (g_fragWorldPos.w != 0.0)\
726 \n g_fragWorldPos /= g_fragWorldPos.w;\
728 \n vec3 vdir = normalize(g_fragWorldPos.xyz);\
729 \n vec3 normal = gradient.xyz;\
730 \n vec3 ambient = vec3(0.0);\
731 \n vec3 diffuse = vec3(0.0);\
732 \n vec3 specular = vec3(0.0);\
733 \n float normalLength = length(normal);\
734 \n if (normalLength > 0.0)\
736 \n normal = normalize((in_textureToEye[0] * vec4(normal, 0.0)).xyz);\
740 \n normal = vec3(0.0, 0.0, 0.0);\
742 \n for (int lightNum = 0; lightNum < in_numberOfLights; lightNum++)\
744 \n vec3 ldir = in_lightDirection[lightNum].xyz;\
745 \n vec3 h = normalize(ldir + vdir);\
746 \n float nDotH = dot(normal, h);\
747 \n if (nDotH < 0.0 && in_twoSidedLighting)\
751 \n float nDotL = dot(normal, ldir);\
752 \n if (nDotL < 0.0 && in_twoSidedLighting)\
758 \n diffuse += in_lightDiffuseColor[lightNum] * nDotL;\
762 \n specular = in_lightSpecularColor[lightNum] *\
763 \n pow(nDotH, in_shininess[component]);\
765 \n ambient += in_lightAmbientColor[lightNum];\
767 \n finalColor.xyz = in_ambient[component] * ambient +\
768 \n in_diffuse[component] * diffuse * color.rgb +\
769 \n in_specular[component] * specular;");
771 else if (lightingComplexity == 3)
774 \n g_fragWorldPos = in_modelViewMatrix * in_volumeMatrix[0] *\
775 \n in_textureDatasetMatrix[0] * vec4(g_dataPos, 1.0);\
776 \n if (g_fragWorldPos.w != 0.0)\
778 \n g_fragWorldPos /= g_fragWorldPos.w;\
780 \n vec3 viewDirection = normalize(-g_fragWorldPos.xyz);\
781 \n vec3 ambient = vec3(0,0,0);\
782 \n vec3 diffuse = vec3(0,0,0);\
783 \n vec3 specular = vec3(0,0,0);\
784 \n vec3 vertLightDirection;\
785 \n vec3 normal = normalize((in_textureToEye[0] * vec4(gradient.xyz, 0.0)).xyz);\
787 \n for (int lightNum = 0; lightNum < in_numberOfLights; lightNum++)\
789 \n float attenuation = 1.0;\
791 \n lightDir = in_lightDirection[lightNum];\
792 \n if (in_lightPositional[lightNum] == 0)\
794 \n vertLightDirection = lightDir;\
798 \n vertLightDirection = (g_fragWorldPos.xyz - in_lightPosition[lightNum]);\
799 \n float distance = length(vertLightDirection);\
800 \n vertLightDirection = normalize(vertLightDirection);\
801 \n attenuation = 1.0 /\
802 \n (in_lightAttenuation[lightNum].x\
803 \n + in_lightAttenuation[lightNum].y * distance\
804 \n + in_lightAttenuation[lightNum].z * distance * distance);\
805 \n // per OpenGL standard cone angle is 90 or less for a spot light\
806 \n if (in_lightConeAngle[lightNum] <= 90.0)\
808 \n float coneDot = dot(vertLightDirection, lightDir);\
809 \n // if inside the cone\
810 \n if (coneDot >= cos(radians(in_lightConeAngle[lightNum])))\
812 \n attenuation = attenuation * pow(coneDot, in_lightExponent[lightNum]);\
816 \n attenuation = 0.0;\
820 \n // diffuse and specular lighting\
821 \n float nDotL = dot(normal, vertLightDirection);\
822 \n if (nDotL < 0.0 && in_twoSidedLighting)\
828 \n float df = max(0.0, attenuation * nDotL);\
829 \n diffuse += (df * in_lightDiffuseColor[lightNum]);\
831 \n vec3 h = normalize(vertLightDirection + viewDirection);\
832 \n float nDotH = dot(normal, h);\
833 \n if (nDotH < 0.0 && in_twoSidedLighting)\
839 \n float sf = attenuation * pow(nDotH, in_shininess[component]);\
840 \n specular += (sf * in_lightSpecularColor[lightNum]);\
842 \n ambient += in_lightAmbientColor[lightNum];\
844 \n finalColor.xyz = in_ambient[component] * ambient +\
845 \n in_diffuse[component] * diffuse * color.rgb +\
846 \n in_specular[component] * specular;\
852 shaderStr +=
std::string(
"\n finalColor = vec4(color.rgb, 0.0);");
862 if (noOfComponents == 1 || !independentComponents)
867 \n if (gradient.w >= 0.0 && label == 0.0)\
869 \n color.a *= computeGradientOpacity(gradient);\
875 \n if (gradient.w >= 0.0 && label > 0.0)\
877 \n color.a *= computeGradientOpacityForLabel(gradient, label);\
881 else if (noOfComponents > 1 && independentComponents && volProperty->
HasGradientOpacity())
884 \n if (gradient.w >= 0.0)\
886 \n for (int i = 0; i < in_noOfComponents; ++i)\
888 \n color.a = color.a *\
889 \n computeGradientOpacity(gradient, i) * in_componentWeight[i];\
896 \n finalColor.a = color.a;\
897 \n return finalColor;\
905 vtkVolume* vtkNotUsed(vol),
int vtkNotUsed(noOfComponents))
910 \nvec3 computeRayDirection()\
912 \n return normalize(ip_vertexPos.xyz - g_eyePosObj.xyz);\
918 \nuniform vec3 in_projectionDirection;\
919 \nvec3 computeRayDirection()\
921 \n return normalize((in_inverseVolumeMatrix[0] *\
922 \n vec4(in_projectionDirection, 0.0)).xyz);\
930 int independentComponents, std::map<int, std::string> colorTableMap)
932 std::ostringstream ss;
933 ss <<
"uniform sampler2D " << ArrayBaseName(colorTableMap[0]) <<
"[" << noOfComponents <<
"];\n";
936 if (noOfComponents == 1)
939 \nvec4 computeColor(vec4 scalar, float opacity)\
941 \n return computeLighting(vec4(texture2D(" +
942 colorTableMap[0] +
",\
943 \n vec2(scalar.w, 0.0)).xyz, opacity), 0, 0);\
947 else if (noOfComponents > 1 && independentComponents)
949 std::ostringstream toString;
952 \nvec4 computeColor(vec4 scalar, float opacity, int component)\
955 for (
int i = 0; i < noOfComponents; ++i)
959 \n if (component == " +
960 toString.str() +
")");
964 \n return computeLighting(vec4(texture2D(\
969 toString.str() +
"],0.0)).xyz,\
971 toString.str() +
", 0);\
982 else if (noOfComponents == 2 && !independentComponents)
985 \nvec4 computeColor(vec4 scalar, float opacity)\
987 \n return computeLighting(vec4(texture2D(" +
988 colorTableMap[0] +
",\
989 \n vec2(scalar.x, 0.0)).xyz,\
997 \nvec4 computeColor(vec4 scalar, float opacity)\
999 \n return computeLighting(vec4(scalar.xyz, opacity), 0, 0);\
1008 std::ostringstream ss;
1010 for (
auto& item : inputs)
1012 auto prop = item.second.Volume->GetProperty();
1016 auto& map = item.second.RGBTablesMap;
1017 const auto numComp = map.size();
1018 ss <<
"uniform sampler2D " << ArrayBaseName(map[0]) <<
"[" << numComp <<
"];\n";
1022 ss <<
"vec3 computeColor(const in float scalar, const in sampler2D colorTF)\n"
1024 " return texture2D(colorTF, vec2(scalar, 0)).rgb;\n"
1032 std::ostringstream ss;
1034 for (
auto& item : inputs)
1036 auto prop = item.second.Volume->GetProperty();
1040 auto& map = item.second.OpacityTablesMap;
1041 const auto numComp = map.size();
1042 ss <<
"uniform sampler2D " << ArrayBaseName(map[0]) <<
"[" << numComp <<
"];\n";
1046 ss <<
"float computeOpacity(const in float scalar, const in sampler2D opacityTF)\n"
1048 " return texture2D(opacityTF, vec2(scalar, 0)).r;\n"
1057 std::ostringstream ss;
1060 for (
auto& item : inputs)
1062 auto prop = item.second.Volume->GetProperty();
1066 auto& map = item.second.GradientOpacityTablesMap;
1067 const auto numComp = map.size();
1068 ss <<
"uniform sampler2D " << ArrayBaseName(map[0]) <<
"[" << numComp <<
"];\n";
1072 ss <<
"float computeGradientOpacity(const in float scalar, const in sampler2D opacityTF)\n"
1074 " return texture2D(opacityTF, vec2(scalar, 0)).r;\n"
1082 int independentComponents, std::map<int, std::string> opacityTableMap)
1084 std::ostringstream ss;
1085 ss <<
"uniform sampler2D " << ArrayBaseName(opacityTableMap[0]) <<
"[" << noOfComponents
1089 if (noOfComponents > 1 && independentComponents)
1092 \nfloat computeOpacity(vec4 scalar, int component)\
1095 for (
int i = 0; i < noOfComponents; ++i)
1097 std::ostringstream toString;
1100 \n if (component == " +
1101 toString.str() +
")");
1105 \n return texture2D(" +
1106 opacityTableMap[i]);
1108 shaderStr +=
std::string(
",vec2(scalar[" + toString.str() +
"], 0)).r;\
1115 else if (noOfComponents == 2 && !independentComponents)
1118 \nfloat computeOpacity(vec4 scalar)\
1120 \n return texture2D(" +
1121 opacityTableMap[0] +
", vec2(scalar.y, 0)).r;\
1128 \nfloat computeOpacity(vec4 scalar)\
1130 \n return texture2D(" +
1131 opacityTableMap[0] +
", vec2(scalar.w, 0)).r;\
1140 int independentComponents, std::map<int, std::string> colorTableMap)
1142 if (noOfComponents == 1)
1145 return std::string(
"vec4 computeColor(vec4 scalar, float opacity)\n"
1147 " vec4 color = texture2D(" +
1150 " vec2(scalar.w, g_gradients_0[0].w));\n"
1151 " return computeLighting(color, 0, 0);\n"
1154 else if (noOfComponents > 1 && independentComponents)
1158 shaderStr +=
std::string(
"vec4 computeColor(vec4 scalar, float opacity, int component)\n"
1161 for (
int i = 0; i < noOfComponents; ++i)
1163 std::ostringstream toString;
1166 shaderStr +=
std::string(
" if (component == " + num +
1169 " vec4 color = texture2D(" +
1173 num +
"], g_gradients_0[" + num +
1175 " return computeLighting(color, " +
1184 else if (noOfComponents == 2 && !independentComponents)
1187 return std::string(
"vec4 computeColor(vec4 scalar, float opacity)\n"
1189 " vec4 color = texture2D(" +
1192 " vec2(scalar.x, g_gradients_0[0].w));\n"
1193 " return computeLighting(color, 0, 0);\n"
1198 return std::string(
"vec4 computeColor(vec4 scalar, float opacity)\n"
1200 " return computeLighting(vec4(scalar.xyz, opacity), 0, 0);\n"
1207 std::ostringstream ss;
1209 for (
auto& item : inputs)
1211 auto prop = item.second.Volume->GetProperty();
1215 auto& map = item.second.TransferFunctions2DMap;
1216 const auto numComp = map.size();
1217 ss <<
"uniform sampler2D " << ArrayBaseName(map[0]) <<
"[" << numComp <<
"];\n";
1227 int independentComponents, std::map<int, std::string> opacityTableMap)
1229 std::ostringstream toString;
1230 if (noOfComponents > 1 && independentComponents)
1233 toString <<
"float computeOpacity(vec4 scalar, int component)\n"
1236 for (
int i = 0; i < noOfComponents; ++i)
1238 toString <<
" if (component == " << i
1241 " return texture2D("
1242 << opacityTableMap[i]
1245 << i <<
"], g_gradients_0[" << i
1252 else if (noOfComponents == 2 && !independentComponents)
1255 toString <<
"float computeOpacity(vec4 scalar)\n"
1257 " return texture2D(" +
1258 opacityTableMap[0] +
1260 " vec2(scalar.y, g_gradients_0[0].w)).a;\n"
1266 toString <<
"float computeOpacity(vec4 scalar)\n"
1268 " return texture2D(" +
1269 opacityTableMap[0] +
1271 " vec2(scalar.a, g_gradients_0[0].w)).a;\n"
1274 return toString.str();
1291 \n bool l_firstValue;\
1292 \n vec4 l_maxValue;");
1297 \n bool l_firstValue;\
1298 \n vec4 l_minValue;");
1303 \n uvec4 l_numSamples;\
1304 \n vec4 l_avgValue;");
1309 \n vec4 l_sumValue;");
1314 \n int l_initialIndex = 0;\
1315 \n float l_normValues[NUMBER_OF_CONTOURS + 2];");
1330 \n // We get data between 0.0 - 1.0 range\
1331 \n l_firstValue = true;\
1332 \n l_maxValue = vec4(0.0);");
1337 \n //We get data between 0.0 - 1.0 range\
1338 \n l_firstValue = true;\
1339 \n l_minValue = vec4(1.0);");
1344 \n //We get data between 0.0 - 1.0 range\
1345 \n l_avgValue = vec4(0.0);\
1346 \n // Keep track of number of samples\
1347 \n l_numSamples = uvec4(0);");
1352 \n //We get data between 0.0 - 1.0 range\
1353 \n l_sumValue = vec4(0.0);");
1358 \n#if NUMBER_OF_CONTOURS\
1359 \n l_normValues[0] = -1e20; //-infinity\
1360 \n l_normValues[NUMBER_OF_CONTOURS+1] = +1e20; //+infinity\
1361 \n for (int i = 0; i < NUMBER_OF_CONTOURS; i++)\
1363 \n l_normValues[i+1] = (in_isosurfacesValues[i] - in_scalarsRange[0].x) / \
1364 \n (in_scalarsRange[0].y - in_scalarsRange[0].x);\
1379 const int numInputs =
static_cast<int>(inputs.size());
1380 const int comp = numInputs == 1 ?
1382 (!independentComponents ? 1 : numInputs)
1387 std::ostringstream toShader;
1388 for (
const auto& item : inputs)
1390 auto& input = item.second;
1391 if (input.Volume->GetProperty()->HasGradientOpacity())
1393 toShader <<
"vec4 " << input.GradientCacheName <<
"[" << comp <<
"];\n";
1397 return toShader.str();
1402 int noOfComponents = 1,
int independentComponents = 0)
1404 std::ostringstream shader;
1405 if (independentComponents)
1407 if (noOfComponents == 1)
1409 shader <<
"g_gradients_0[0] = computeGradient(g_dataPos, 0, in_volume[0], 0);\n";
1414 shader <<
"for (int comp = 0; comp < in_noOfComponents; comp++)\n"
1416 " g_gradients_0[comp] = computeGradient(g_dataPos, comp, in_volume[0], 0);\n"
1422 shader <<
"g_gradients_0[0] = computeGradient(g_dataPos, 0, in_volume[0], 0);\n";
1425 return shader.str();
1432 std::ostringstream toShaderStr;
1433 toShaderStr <<
" if (!g_skip)\n"
1443 for (
auto& item : inputs)
1445 auto& input = item.second;
1446 auto property = input.Volume->GetProperty();
1448 const auto idx = i + 1;
1453 " texPos = (in_cellToPoint[" << idx <<
"] * in_inverseTextureDatasetMatrix[" << idx
1454 <<
"] * in_inverseVolumeMatrix[" << idx
1456 " in_volumeMatrix[0] * in_textureDatasetMatrix[0] * "
1457 "vec4(g_dataPos.xyz, 1.0)).xyz;\n"
1458 " if ((all(lessThanEqual(texPos, vec3(1.0))) &&\n"
1459 " all(greaterThanEqual(texPos, vec3(0.0)))))\n"
1461 " vec4 scalar = texture3D(in_volume["
1464 " scalar = scalar * in_volume_scale["
1465 << i <<
"] + in_volume_bias[" << i
1467 " scalar = vec4(scalar.r);\n"
1468 " g_srcColor = vec4(0.0);\n";
1472 toShaderStr <<
" g_srcColor.a = computeOpacity(scalar.r,"
1473 << input.OpacityTablesMap[0]
1475 " if (g_srcColor.a > 0.0)\n"
1477 " g_srcColor.rgb = computeColor(scalar.r, "
1478 << input.RGBTablesMap[0] <<
");\n";
1480 if (property->HasGradientOpacity())
1482 const auto& grad = input.GradientCacheName;
1483 toShaderStr <<
" " << grad <<
"[0] = computeGradient(texPos, 0, "
1484 <<
"in_volume[" << i <<
"], " << i
1488 <<
"[0].w >= 0.0)\n"
1490 " g_srcColor.a *= computeGradientOpacity("
1491 << grad <<
"[0].w, " << input.GradientOpacityTablesMap[0]
1498 const auto& grad = input.GradientCacheName;
1501 " " << grad <<
"[0] = computeGradient(texPos, 0, "
1502 <<
"in_volume[" << i <<
"], " << i
1504 " g_srcColor = texture2D("
1505 << input.TransferFunctions2DMap[0] <<
", vec2(scalar.r, "
1506 << input.GradientCacheName
1508 " if (g_srcColor.a > 0.0)\n"
1513 <<
" g_srcColor.rgb *= g_srcColor.a;\n"
1514 " g_fragColor = (1.0f - g_fragColor.a) * g_srcColor + g_fragColor;\n"
1523 toShaderStr <<
" }\n";
1525 return toShaderStr.str();
1531 int noOfComponents,
int independentComponents = 0)
1540 \n vec4 scalar = texture3D(in_volume[0], g_dataPos);");
1543 if (noOfComponents == 1)
1546 \n scalar.r = scalar.r * in_volume_scale[0].r + in_volume_bias[0].r;\
1547 \n scalar = vec4(scalar.r);");
1553 \n scalar = scalar * in_volume_scale[0] + in_volume_bias[0];");
1558 if (noOfComponents > 1)
1560 if (!independentComponents)
1563 \n if (l_maxValue.w < scalar.w || l_firstValue)\
1565 \n l_maxValue = scalar;\
1568 \n if (l_firstValue)\
1570 \n l_firstValue = false;\
1576 \n for (int i = 0; i < in_noOfComponents; ++i)\
1578 \n if (l_maxValue[i] < scalar[i] || l_firstValue)\
1580 \n l_maxValue[i] = scalar[i];\
1583 \n if (l_firstValue)\
1585 \n l_firstValue = false;\
1592 \n if (l_maxValue.w < scalar.x || l_firstValue)\
1594 \n l_maxValue.w = scalar.x;\
1597 \n if (l_firstValue)\
1599 \n l_firstValue = false;\
1605 if (noOfComponents > 1)
1607 if (!independentComponents)
1610 \n if (l_minValue.w > scalar.w || l_firstValue)\
1612 \n l_minValue = scalar;\
1615 \n if (l_firstValue)\
1617 \n l_firstValue = false;\
1623 \n for (int i = 0; i < in_noOfComponents; ++i)\
1625 \n if (l_minValue[i] < scalar[i] || l_firstValue)\
1627 \n l_minValue[i] = scalar[i];\
1630 \n if (l_firstValue)\
1632 \n l_firstValue = false;\
1639 \n if (l_minValue.w > scalar.x || l_firstValue)\
1641 \n l_minValue.w = scalar.x;\
1644 \n if (l_firstValue)\
1646 \n l_firstValue = false;\
1652 if (noOfComponents > 1 && independentComponents)
1655 \n for (int i = 0; i < in_noOfComponents; ++i)\
1657 \n // Get the intensity in volume scalar range\
1658 \n float intensity = in_scalarsRange[i][0] +\
1659 \n (in_scalarsRange[i][1] -\
1660 \n in_scalarsRange[i][0]) * scalar[i];\
1661 \n if (in_averageIPRange.x <= intensity &&\
1662 \n intensity <= in_averageIPRange.y)\
1664 \n l_avgValue[i] += computeOpacity(scalar, i) * scalar[i];\
1665 \n ++l_numSamples[i];\
1672 \n // Get the intensity in volume scalar range\
1673 \n float intensity = in_scalarsRange[0][0] +\
1674 \n (in_scalarsRange[0][1] -\
1675 \n in_scalarsRange[0][0]) * scalar.x;\
1676 \n if (in_averageIPRange.x <= intensity &&\
1677 \n intensity <= in_averageIPRange.y)\
1679 \n l_avgValue.x += computeOpacity(scalar) * scalar.x;\
1680 \n ++l_numSamples.x;\
1686 if (noOfComponents > 1 && independentComponents)
1689 \n for (int i = 0; i < in_noOfComponents; ++i)\
1691 \n float opacity = computeOpacity(scalar, i);\
1692 \n l_sumValue[i] = l_sumValue[i] + opacity * scalar[i];\
1698 \n float opacity = computeOpacity(scalar);\
1699 \n l_sumValue.x = l_sumValue.x + opacity * scalar.x;");
1705 \n#if NUMBER_OF_CONTOURS\
1706 \n int maxComp = 0;");
1709 if (noOfComponents > 1 && independentComponents)
1712 \n for (int i = 1; i < in_noOfComponents; ++i)\
1714 \n if (in_componentWeight[i] > in_componentWeight[maxComp])\
1717 compParamStr =
", maxComp";
1720 \n if (g_currentT == 0)\
1722 \n l_initialIndex = findIsoSurfaceIndex(scalar[maxComp], l_normValues);\
1727 \n bool shade = false;\
1728 \n l_initialIndex = clamp(l_initialIndex, 0, NUMBER_OF_CONTOURS);\
1729 \n if (scalar[maxComp] < l_normValues[l_initialIndex])\
1731 \n s = l_normValues[l_initialIndex];\
1732 \n l_initialIndex--;\
1735 \n if (scalar[maxComp] > l_normValues[l_initialIndex+1])\
1737 \n s = l_normValues[l_initialIndex+1];\
1738 \n l_initialIndex++;\
1741 \n if (shade == true)\
1743 \n vec4 vs = vec4(s);\
1744 \n g_srcColor.a = computeOpacity(vs " +
1746 \n g_srcColor = computeColor(vs, g_srcColor.a " +
1748 \n g_srcColor.rgb *= g_srcColor.a;\
1749 \n g_fragColor = (1.0f - g_fragColor.a) * g_srcColor + g_fragColor;\
1757 \n // test if the intersection is inside the volume bounds\
1758 \n if (any(greaterThan(g_dataPos, vec3(1.0))) || any(lessThan(g_dataPos, vec3(0.0))))\
1762 \n float opacity = computeOpacity(scalar);\
1763 \n g_fragColor = computeColor(scalar, opacity);\
1764 \n g_fragColor.rgb *= opacity;\
1765 \n g_exit = true;");
1769 if (noOfComponents > 1 && independentComponents)
1772 \n vec4 color[4]; vec4 tmp = vec4(0.0);\
1773 \n float totalAlpha = 0.0;\
1774 \n for (int i = 0; i < in_noOfComponents; ++i)\
1777 if (glMapper->GetUseDepthPass() &&
1781 \n // Data fetching from the red channel of volume texture\
1782 \n float opacity = computeOpacity(scalar, i);\
1783 \n if (opacity > 0.0)\
1785 \n g_srcColor.a = opacity;\
1792 \n // Data fetching from the red channel of volume texture\
1793 \n color[i][3] = computeOpacity(scalar, i);\
1794 \n color[i] = computeColor(scalar, color[i][3], i);\
1795 \n totalAlpha += color[i][3] * in_componentWeight[i];\
1797 \n if (totalAlpha > 0.0)\
1799 \n for (int i = 0; i < in_noOfComponents; ++i)\
1801 \n // Only let visible components contribute to the final color\
1802 \n if (in_componentWeight[i] <= 0) continue;\
1804 \n tmp.x += color[i].x * color[i].w * in_componentWeight[i];\
1805 \n tmp.y += color[i].y * color[i].w * in_componentWeight[i];\
1806 \n tmp.z += color[i].z * color[i].w * in_componentWeight[i];\
1807 \n tmp.w += ((color[i].w * color[i].w)/totalAlpha);\
1810 \n g_fragColor = (1.0f - g_fragColor.a) * tmp + g_fragColor;");
1813 else if (glMapper->GetUseDepthPass() &&
1817 \n g_srcColor = vec4(0.0);\
1818 \n g_srcColor.a = computeOpacity(scalar);");
1825 \n g_srcColor = vec4(0.0);\
1826 \n g_srcColor.a = computeOpacity(scalar);\
1827 \n if (g_srcColor.a > 0.0)\
1829 \n g_srcColor = computeColor(scalar, g_srcColor.a);");
1833 \n // Opacity calculation using compositing:\
1834 \n // Here we use front to back compositing scheme whereby\
1835 \n // the current sample value is multiplied to the\
1836 \n // currently accumulated alpha and then this product\
1837 \n // is subtracted from the sample value to get the\
1838 \n // alpha from the previous steps. Next, this alpha is\
1839 \n // multiplied with the current sample colour\
1840 \n // and accumulated to the composited colour. The alpha\
1841 \n // value from the previous steps is then accumulated\
1842 \n // to the composited colour alpha.\
1843 \n g_srcColor.rgb *= g_srcColor.a;\
1844 \n g_fragColor = (1.0f - g_fragColor.a) * g_srcColor + g_fragColor;");
1868 \n // Special coloring mode which renders the Prop Id in fragments that\
1869 \n // have accumulated certain level of opacity. Used during the selection\
1870 \n // pass vtkHardwareSelection::ACTOR_PASS.\
1871 \n if (g_fragColor.a > 3.0/ 255.0)\
1873 \n gl_FragData[0] = vec4(in_propId, 1.0);\
1877 \n gl_FragData[0] = vec4(0.0);\
1887 \n // Special coloring mode which renders the voxel index in fragments that\
1888 \n // have accumulated certain level of opacity. Used during the selection\
1889 \n // pass vtkHardwareSelection::ID_LOW24.\
1890 \n if (g_fragColor.a > 3.0/ 255.0)\
1892 \n uvec3 volumeDim = uvec3(in_textureExtentsMax - in_textureExtentsMin);\
1893 \n uvec3 voxelCoords = uvec3(volumeDim * g_dataPos);\
1894 \n // vtkHardwareSelector assumes index 0 to be empty space, so add uint(1).\
1895 \n uint idx = volumeDim.x * volumeDim.y * voxelCoords.z +\
1896 \n volumeDim.x * voxelCoords.y + voxelCoords.x + uint(1);\
1897 \n gl_FragData[0] = vec4(float(idx % uint(256)) / 255.0,\
1898 \n float((idx / uint(256)) % uint(256)) / 255.0,\
1899 \n float((idx / uint(65536)) % uint(256)) / 255.0, 1.0);\
1903 \n gl_FragData[0] = vec4(0.0);\
1913 \n // Special coloring mode which renders the voxel index in fragments that\
1914 \n // have accumulated certain level of opacity. Used during the selection\
1915 \n // pass vtkHardwareSelection::ID_MID24.\
1916 \n if (g_fragColor.a > 3.0/ 255.0)\
1918 \n uvec3 volumeDim = uvec3(in_textureExtentsMax - in_textureExtentsMin);\
1919 \n uvec3 voxelCoords = uvec3(volumeDim * g_dataPos);\
1920 \n // vtkHardwareSelector assumes index 0 to be empty space, so add uint(1).\
1921 \n uint idx = volumeDim.x * volumeDim.y * voxelCoords.z +\
1922 \n volumeDim.x * voxelCoords.y + voxelCoords.x + uint(1);\
1923 \n idx = ((idx & 0xff000000) >> 24);\
1924 \n gl_FragData[0] = vec4(float(idx % uint(256)) / 255.0,\
1925 \n float((idx / uint(256)) % uint(256)) / 255.0,\
1926 \n float(idx / uint(65536)) / 255.0, 1.0);\
1930 \n gl_FragData[0] = vec4(0.0);\
1937 vtkVolume* vtkNotUsed(vol),
int noOfComponents,
int independentComponents = 0)
1949 if (noOfComponents > 1 && independentComponents)
1952 \n g_srcColor = vec4(0);\
1953 \n for (int i = 0; i < in_noOfComponents; ++i)\
1955 \n vec4 tmp = computeColor(l_maxValue, computeOpacity(l_maxValue, i), i);\
1956 \n g_srcColor[0] += tmp[0] * tmp[3] * in_componentWeight[i];\
1957 \n g_srcColor[1] += tmp[1] * tmp[3] * in_componentWeight[i];\
1958 \n g_srcColor[2] += tmp[2] * tmp[3] * in_componentWeight[i];\
1959 \n g_srcColor[3] += tmp[3] * in_componentWeight[i];\
1961 \n g_fragColor = g_srcColor;");
1966 \n g_srcColor = computeColor(l_maxValue,\
1967 \n computeOpacity(l_maxValue));\
1968 \n g_fragColor.rgb = g_srcColor.rgb * g_srcColor.a;\
1969 \n g_fragColor.a = g_srcColor.a;");
1974 if (noOfComponents > 1 && independentComponents)
1977 \n g_srcColor = vec4(0);\
1978 \n for (int i = 0; i < in_noOfComponents; ++i)\
1980 \n vec4 tmp = computeColor(l_minValue, computeOpacity(l_minValue, i), i);\
1981 \n g_srcColor[0] += tmp[0] * tmp[3] * in_componentWeight[i];\
1982 \n g_srcColor[1] += tmp[1] * tmp[3] * in_componentWeight[i];\
1983 \n g_srcColor[2] += tmp[2] * tmp[3] * in_componentWeight[i];\
1984 \n g_srcColor[2] += tmp[3] * tmp[3] * in_componentWeight[i];\
1986 \n g_fragColor = g_srcColor;");
1991 \n g_srcColor = computeColor(l_minValue,\
1992 \n computeOpacity(l_minValue));\
1993 \n g_fragColor.rgb = g_srcColor.rgb * g_srcColor.a;\
1994 \n g_fragColor.a = g_srcColor.a;");
1999 if (noOfComponents > 1 && independentComponents)
2002 \n for (int i = 0; i < in_noOfComponents; ++i)\
2004 \n if (l_numSamples[i] == uint(0))\
2008 \n l_avgValue[i] = l_avgValue[i] * in_componentWeight[i] /\
2009 \n l_numSamples[i];\
2012 \n l_avgValue[0] += l_avgValue[i];\
2015 \n l_avgValue[0] = clamp(l_avgValue[0], 0.0, 1.0);\
2016 \n g_fragColor = vec4(vec3(l_avgValue[0]), 1.0);");
2021 \n if (l_numSamples.x == uint(0))\
2027 \n l_avgValue.x /= l_numSamples.x;\
2028 \n l_avgValue.x = clamp(l_avgValue.x, 0.0, 1.0);\
2029 \n g_fragColor = vec4(vec3(l_avgValue.x), 1.0);\
2035 if (noOfComponents > 1 && independentComponents)
2039 \n l_sumValue.x *= in_componentWeight.x;\
2040 \n for (int i = 1; i < in_noOfComponents; ++i)\
2042 \n l_sumValue.x += l_sumValue[i] * in_componentWeight[i];\
2044 \n l_sumValue.x = clamp(l_sumValue.x, 0.0, 1.0);\
2045 \n g_fragColor = vec4(vec3(l_sumValue.x), 1.0);");
2050 \n l_sumValue.x = clamp(l_sumValue.x, 0.0, 1.0);\
2051 \n g_fragColor = vec4(vec3(l_sumValue.x), 1.0);");
2072 \n const float g_opacityThreshold = 1.0 - 1.0 / 255.0;");
2080 \n uniform vec3 in_propId;");
2088 \n // Flag to indicate if the raymarch loop should terminate \
2089 \n bool stop = false;\
2091 \n g_terminatePointMax = 0.0;\
2094 \n vec4 l_depthValue = vec4(1.0,1.0,1.0,1.0);\
2096 \n vec4 l_depthValue = texture2D(in_depthSampler, fragTexCoord);\
2099 \n if(gl_FragCoord.z >= l_depthValue.x)\
2104 \n // color buffer or max scalar buffer have a reduced size.\
2105 \n fragTexCoord = (gl_FragCoord.xy - in_windowLowerLeftCorner) *\
2106 \n in_inverseOriginalWindowSize;\
2114 if (sliceFunc->
IsA(
"vtkPlane"))
2118 \n // Intersection with plane\
2119 \n float t = intersectRayPlane(ip_vertexPos, rayDir);\
2120 \n vec4 intersection = vec4(ip_vertexPos + t * rayDir, 1.0);\
2121 \n g_intersection = (in_inverseTextureDatasetMatrix[0] * intersection).xyz;\
2122 \n vec4 intersDC = in_projectionMatrix * in_modelViewMatrix * in_volumeMatrix[0] * intersection;\
2123 \n intersDC.xyz /= intersDC.w;\
2124 \n vec4 intersWin = NDCToWindow(intersDC.x, intersDC.y, intersDC.z);\
2125 \n if(intersWin.z >= l_depthValue.x)\
2133 vtkErrorWithObjectMacro(
2134 sliceFunc,
"Implicit function type is not supported by this mapper.");
2140 \n // Compute max number of iterations it will take before we hit\
2141 \n // the termination point\
2143 \n // Abscissa of the point on the depth buffer along the ray.\
2144 \n // point in texture coordinates\
2145 \n vec4 rayTermination = WindowToNDC(gl_FragCoord.x, gl_FragCoord.y, l_depthValue.x);\
2147 \n // From normalized device coordinates to eye coordinates.\
2148 \n // in_projectionMatrix is inversed because of way VT\
2149 \n // From eye coordinates to texture coordinates\
2150 \n rayTermination = ip_inverseTextureDataAdjusted *\
2151 \n in_inverseVolumeMatrix[0] *\
2152 \n in_inverseModelViewMatrix *\
2153 \n in_inverseProjectionMatrix *\
2155 \n g_rayTermination = rayTermination.xyz / rayTermination.w;\
2157 \n // Setup the current segment:\
2158 \n g_dataPos = g_rayOrigin;\
2159 \n g_terminatePos = g_rayTermination;\
2161 \n g_terminatePointMax = length(g_terminatePos.xyz - g_dataPos.xyz) /\
2162 \n length(g_dirStep);\
2163 \n g_currentT = 0.0;");
2173 \n if(any(greaterThan(max(g_dirStep, vec3(0.0))*(g_dataPos - in_texMax[0]),vec3(0.0))) ||\
2174 \n any(greaterThan(min(g_dirStep, vec3(0.0))*(g_dataPos - in_texMin[0]),vec3(0.0))))\
2179 \n // Early ray termination\
2180 \n // if the currently composited colour alpha is already fully saturated\
2181 \n // we terminated the loop or if we have hit an obstacle in the\
2182 \n // direction of they ray (using depth buffer) we terminate as well.\
2183 \n if((g_fragColor.a > g_opacityThreshold) || \
2184 \n g_currentT >= g_terminatePointMax)\
2215 \nuniform float in_croppingPlanes[6];\
2216 \nuniform int in_croppingFlags [32];\
2217 \nfloat croppingPlanesTexture[6];\
2219 \n// X: axis = 0, Y: axis = 1, Z: axis = 2\
2220 \n// cp Cropping plane bounds (minX, maxX, minY, maxY, minZ, maxZ)\
2221 \nint computeRegionCoord(float cp[6], vec3 pos, int axis)\
2223 \n int cpmin = axis * 2;\
2224 \n int cpmax = cpmin + 1;\
2226 \n if (pos[axis] < cp[cpmin])\
2230 \n else if (pos[axis] >= cp[cpmin] &&\
2231 \n pos[axis] < cp[cpmax])\
2235 \n else if (pos[axis] >= cp[cpmax])\
2242 \nint computeRegion(float cp[6], vec3 pos)\
2244 \n return (computeRegionCoord(cp, pos, 0) +\
2245 \n (computeRegionCoord(cp, pos, 1) - 1) * 3 +\
2246 \n (computeRegionCoord(cp, pos, 2) - 1) * 9);\
2260 \n // Convert cropping region to texture space\
2261 \n mat4 datasetToTextureMat = in_inverseTextureDatasetMatrix[0];\
2263 \n vec4 tempCrop = vec4(in_croppingPlanes[0], 0.0, 0.0, 1.0);\
2264 \n tempCrop = datasetToTextureMat * tempCrop;\
2265 \n if (tempCrop[3] != 0.0)\
2267 \n tempCrop[0] /= tempCrop[3];\
2269 \n croppingPlanesTexture[0] = tempCrop[0];\
2271 \n tempCrop = vec4(in_croppingPlanes[1], 0.0, 0.0, 1.0);\
2272 \n tempCrop = datasetToTextureMat * tempCrop;\
2273 \n if (tempCrop[3] != 0.0)\
2275 \n tempCrop[0] /= tempCrop[3];\
2277 \n croppingPlanesTexture[1] = tempCrop[0];\
2279 \n tempCrop = vec4(0.0, in_croppingPlanes[2], 0.0, 1.0);\
2280 \n tempCrop = datasetToTextureMat * tempCrop;\
2281 \n if (tempCrop[3] != 0.0)\
2283 \n tempCrop[1] /= tempCrop[3];\
2285 \n croppingPlanesTexture[2] = tempCrop[1];\
2287 \n tempCrop = vec4(0.0, in_croppingPlanes[3], 0.0, 1.0);\
2288 \n tempCrop = datasetToTextureMat * tempCrop;\
2289 \n if (tempCrop[3] != 0.0)\
2291 \n tempCrop[1] /= tempCrop[3];\
2293 \n croppingPlanesTexture[3] = tempCrop[1];\
2295 \n tempCrop = vec4(0.0, 0.0, in_croppingPlanes[4], 1.0);\
2296 \n tempCrop = datasetToTextureMat * tempCrop;\
2297 \n if (tempCrop[3] != 0.0)\
2299 \n tempCrop[2] /= tempCrop[3];\
2301 \n croppingPlanesTexture[4] = tempCrop[2];\
2303 \n tempCrop = vec4(0.0, 0.0, in_croppingPlanes[5], 1.0);\
2304 \n tempCrop = datasetToTextureMat * tempCrop;\
2305 \n if (tempCrop[3] != 0.0)\
2307 \n tempCrop[2] /= tempCrop[3];\
2309 \n croppingPlanesTexture[5] = tempCrop[2];");
2322 \n // Determine region\
2323 \n int regionNo = computeRegion(croppingPlanesTexture, g_dataPos);\
2325 \n // Do & operation with cropping flags\
2326 \n // Pass the flag that its Ok to sample or not to sample\
2327 \n if (in_croppingFlags[regionNo] == 0)\
2329 \n // Skip this voxel\
2358 \n /// We support only 8 clipping planes for now\
2359 \n /// The first value is the size of the data array for clipping\
2360 \n /// planes (origin, normal)\
2361 \n uniform float in_clippingPlanes[49];\
2362 \n uniform float in_clippedVoxelIntensity;\
2364 \n int clip_numPlanes;\
2365 \n vec3 clip_rayDirObj;\
2366 \n mat4 clip_texToObjMat;\
2367 \n mat4 clip_objToTexMat;\
2369 \n// Tighten the sample range as needed to account for clip planes. \
2370 \n// Arguments are in texture coordinates. \
2371 \n// Returns true if the range is at all valid after clipping. If not, \
2372 \n// the fragment should be discarded. \
2373 \nbool AdjustSampleRangeForClipping(inout vec3 startPosTex, inout vec3 stopPosTex) \
2375 \n vec4 startPosObj = vec4(0.0);\
2377 \n startPosObj = clip_texToObjMat * vec4(startPosTex - g_rayJitter, 1.0);\
2378 \n startPosObj = startPosObj / startPosObj.w;\
2379 \n startPosObj.w = 1.0;\
2382 \n vec4 stopPosObj = vec4(0.0);\
2384 \n stopPosObj = clip_texToObjMat * vec4(stopPosTex, 1.0);\
2385 \n stopPosObj = stopPosObj / stopPosObj.w;\
2386 \n stopPosObj.w = 1.0;\
2389 \n for (int i = 0; i < clip_numPlanes; i = i + 6)\
2391 \n vec3 planeOrigin = vec3(in_clippingPlanes[i + 1],\
2392 \n in_clippingPlanes[i + 2],\
2393 \n in_clippingPlanes[i + 3]);\
2394 \n vec3 planeNormal = normalize(vec3(in_clippingPlanes[i + 4],\
2395 \n in_clippingPlanes[i + 5],\
2396 \n in_clippingPlanes[i + 6]));\
2398 \n // Abort if the entire segment is clipped:\
2399 \n // (We can do this before adjusting the term point, since it'll \
2400 \n // only move further into the clipped area)\
2401 \n float startDistance = dot(planeNormal, planeOrigin - startPosObj.xyz);\
2402 \n float stopDistance = dot(planeNormal, planeOrigin - stopPosObj.xyz);\
2403 \n bool startClipped = startDistance > 0.0;\
2404 \n bool stopClipped = stopDistance > 0.0;\
2405 \n if (startClipped && stopClipped)\
2410 \n float rayDotNormal = dot(clip_rayDirObj, planeNormal);\
2411 \n bool frontFace = rayDotNormal > 0;\
2413 \n // Move the start position further from the eye if needed:\
2414 \n if (frontFace && // Observing from the clipped side (plane's front face)\
2415 \n startDistance > 0.0) // Ray-entry lies on the clipped side.\
2417 \n // Scale the point-plane distance to the ray direction and update the\
2419 \n float rayScaledDist = startDistance / rayDotNormal;\
2420 \n startPosObj = vec4(startPosObj.xyz + rayScaledDist * clip_rayDirObj, 1.0);\
2421 \n vec4 newStartPosTex = clip_objToTexMat * vec4(startPosObj.xyz, 1.0);\
2422 \n newStartPosTex /= newStartPosTex.w;\
2423 \n startPosTex = newStartPosTex.xyz;\
2424 \n startPosTex += g_rayJitter;\
2427 \n // Move the end position closer to the eye if needed:\
2428 \n if (!frontFace && // Observing from the unclipped side (plane's back face)\
2429 \n stopDistance > 0.0) // Ray-entry lies on the unclipped side.\
2431 \n // Scale the point-plane distance to the ray direction and update the\
2432 \n // termination point.\
2433 \n float rayScaledDist = stopDistance / rayDotNormal;\
2434 \n stopPosObj = vec4(stopPosObj.xyz + rayScaledDist * clip_rayDirObj, 1.0);\
2435 \n vec4 newStopPosTex = clip_objToTexMat * vec4(stopPosObj.xyz, 1.0);\
2436 \n newStopPosTex /= newStopPosTex.w;\
2437 \n stopPosTex = newStopPosTex.xyz;\
2441 \n if (any(greaterThan(startPosTex, in_texMax[0])) ||\
2442 \n any(lessThan(startPosTex, in_texMin[0])))\
2464 \n vec4 tempClip = in_volumeMatrix[0] * vec4(rayDir, 0.0);\
2465 \n if (tempClip.w != 0.0)\
2467 \n tempClip = tempClip/tempClip.w;\
2468 \n tempClip.w = 1.0;\
2470 \n clip_rayDirObj = normalize(tempClip.xyz);");
2475 clip_rayDirObj = normalize(in_projectionDirection);");
2479 \n clip_numPlanes = int(in_clippingPlanes[0]);\
2480 \n clip_texToObjMat = in_volumeMatrix[0] * in_textureDatasetMatrix[0];\
2481 \n clip_objToTexMat = in_inverseTextureDatasetMatrix[0] * in_inverseVolumeMatrix[0];\
2483 \n // Adjust for clipping.\
2484 \n if (!AdjustSampleRangeForClipping(g_rayOrigin, g_rayTermination))\
2485 \n { // entire ray is clipped.\
2489 \n // Update the segment post-clip:\
2490 \n g_dataPos = g_rayOrigin;\
2491 \n g_terminatePos = g_rayTermination;\
2492 \n g_terminatePointMax = length(g_terminatePos.xyz - g_dataPos.xyz) /\
2493 \n length(g_dirStep);\
2516 int vtkNotUsed(maskType))
2518 if (!mask || !maskInput)
2540 \nvec4 maskValue = texture3D(in_mask, g_dataPos);\
2541 \nif(maskValue.r <= 0.0)\
2560 \nuniform float in_maskBlendFactor;\
2561 \nuniform sampler2D in_labelMapTransfer;\
2562 \nuniform float in_mask_scale;\
2563 \nuniform float in_mask_bias;\
2564 \nuniform int in_labelMapNumLabels;\
2581 \nvec4 scalar = texture3D(in_volume[0], g_dataPos);");
2584 if (noOfComponents == 1)
2587 \n scalar.r = scalar.r * in_volume_scale[0].r + in_volume_bias[0].r;\
2588 \n scalar = vec4(scalar.r);");
2594 \n scalar = scalar * in_volume_scale[0] + in_volume_bias[0];");
2601 \nif (in_maskBlendFactor == 0.0)\
2603 \n g_srcColor = computeColor(scalar, computeOpacity(scalar));\
2607 \n float opacity = computeOpacity(scalar);\
2608 \n // Get the mask value at this same location\
2609 \n vec4 maskValue = texture3D(in_mask, g_dataPos);\
2610 \n maskValue.r = maskValue.r * in_mask_scale + in_mask_bias;\
2611 \n // Quantize the height of the labelmap texture over number of labels\
2612 \n if (in_labelMapNumLabels > 0)\
2615 \n floor(maskValue.r * in_labelMapNumLabels) /\
2616 \n in_labelMapNumLabels;\
2620 \n maskValue.r = 0.0;\
2622 \n if(maskValue.r == 0.0)\
2624 \n g_srcColor = computeColor(scalar, opacity);\
2628 \n g_srcColor = texture2D(in_labelMapTransfer,\
2629 \n vec2(scalar.r, maskValue.r));\
2630 \n g_srcColor = computeLighting(g_srcColor, 0, maskValue.r);\
2631 \n if (in_maskBlendFactor < 1.0)\
2633 \n g_srcColor = (1.0 - in_maskBlendFactor) *\
2634 \n computeColor(scalar, opacity) +\
2635 \n in_maskBlendFactor * g_srcColor;\
2646 return std::string(
"uniform bool in_clampDepthToBackface;\n"
2647 "vec3 l_opaqueFragPos;\n"
2648 "bool l_updateDepth;\n");
2656 \n l_opaqueFragPos = vec3(-1.0);\
2657 \n if(in_clampDepthToBackface)\
2659 \n l_opaqueFragPos = g_dataPos;\
2661 \n l_updateDepth = true;");
2669 \n if(!g_skip && g_srcColor.a > 0.0 && l_updateDepth)\
2671 \n l_opaqueFragPos = g_dataPos;\
2672 \n l_updateDepth = false;\
2681 \n if (l_opaqueFragPos == vec3(-1.0))\
2683 \n gl_FragData[1] = vec4(1.0);\
2687 \n vec4 depthValue = in_projectionMatrix * in_modelViewMatrix *\
2688 \n in_volumeMatrix[0] * in_textureDatasetMatrix[0] *\
2689 \n vec4(l_opaqueFragPos, 1.0);\
2690 \n depthValue /= depthValue.w;\
2691 \n gl_FragData[1] = vec4(vec3(0.5 * (gl_DepthRange.far -\
2692 \n gl_DepthRange.near) * depthValue.z + 0.5 *\
2693 \n (gl_DepthRange.far + gl_DepthRange.near)), 1.0);\
2702 \n vec3 l_isoPos = g_dataPos;");
2710 \n if(!g_skip && g_srcColor.a > 0.0)\
2712 \n l_isoPos = g_dataPos;\
2713 \n g_exit = true; g_skip = true;\
2722 \n vec4 depthValue = in_projectionMatrix * in_modelViewMatrix *\
2723 \n in_volumeMatrix[0] * in_textureDatasetMatrix[0] *\
2724 \n vec4(l_isoPos, 1.0);\
2725 \n gl_FragData[0] = vec4(l_isoPos, 1.0);\
2726 \n gl_FragData[1] = vec4(vec3((depthValue.z/depthValue.w) * 0.5 + 0.5),\
2735 \n initializeRayCast();\
2736 \n castRay(-1.0, -1.0);\
2737 \n finalizeRayCast();");
2742 const std::vector<std::string>& varNames,
const size_t usedNames)
2745 for (
size_t i = 0; i < usedNames; i++)
2747 shader +=
"uniform sampler2D " + varNames[i] +
";\n";
2754 const std::vector<std::string>& varNames,
const size_t usedNames)
2757 for (
size_t i = 0; i < usedNames; i++)
2759 std::stringstream ss;
2761 shader +=
" gl_FragData[" + ss.str() +
"] = texture2D(" + varNames[i] +
", texCoord);\n";
2763 shader +=
" return;\n";
2768 #endif // vtkVolumeShaderComposer_h
static vtkGPUVolumeRayCastMapper * SafeDownCast(vtkObjectBase *o)
std::string RenderToImageDeclarationFragment(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol))
std::string PreComputeGradientsImpl(vtkRenderer *vtkNotUsed(ren), vtkVolume *vtkNotUsed(vol), int noOfComponents=1, int independentComponents=0)
Abstract class for a volume mapper.
std::string BaseDeclarationFragment(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *mapper, vtkOpenGLGPUVolumeRayCastMapper::VolumeInputMap &inputs, int vtkNotUsed(numberOfLights), int lightingComplexity, int noOfComponents, int independentComponents)
std::string ShadingMultipleInputs(vtkVolumeMapper *mapper, vtkOpenGLGPUVolumeRayCastMapper::VolumeInputMap &inputs)
std::string DepthPassInit(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol))
virtual vtkTypeBool GetCropping()
@ MAXIMUM_INTENSITY_BLEND
represents a volume (data & properties) in a rendered scene
std::string PickingActorPassExit(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol))
std::string BaseImplementation(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *mapper, vtkVolume *vtkNotUsed(vol))
std::string ComputeColorMultiDeclaration(vtkOpenGLGPUVolumeRayCastMapper::VolumeInputMap &inputs)
virtual int GetCurrentPass()
std::string ShadingDeclarationFragment(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *mapper, vtkVolume *vtkNotUsed(vol))
std::string ShadingInit(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *mapper, vtkVolume *vtkNotUsed(vol))
std::string TerminationImplementation(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol))
std::string DepthPassExit(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol))
std::string BinaryMaskImplementation(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol), vtkImageData *maskInput, vtkVolumeTexture *mask, int maskType)
virtual int GetBlendMode()
std::string ShadingSingleInput(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *mapper, vtkVolume *vtkNotUsed(vol), vtkImageData *maskInput, vtkVolumeTexture *mask, int maskType, int noOfComponents, int independentComponents=0)
std::string ClippingExit(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol))
std::string BaseInit(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *mapper, vtkOpenGLGPUVolumeRayCastMapper::VolumeInputMap &inputs, int lightingComplexity)
virtual vtkTypeBool IsA(const char *type)
Return 1 if this class is the same type of (or a subclass of) the named class.
std::string ClippingDeclarationVertex(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol))
std::string WorkerImplementation(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol))
std::string CroppingInit(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *mapper, vtkVolume *vtkNotUsed(vol))
std::string ClippingImplementation(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol))
std::string CroppingDeclarationFragment(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *mapper, vtkVolume *vtkNotUsed(vol))
std::string ShadingExit(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *mapper, vtkVolume *vtkNotUsed(vol), int noOfComponents, int independentComponents=0)
virtual vtkVolumeProperty * GetProperty()
virtual vtkTypeBool GetParallelProjection()
bool HasLabelGradientOpacity()
std::string CroppingDeclarationVertex(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol))
abstract interface for implicit functions
std::string TerminationDeclarationFragment(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol))
virtual int GetTransferFunctionMode()
@ AVERAGE_INTENSITY_BLEND
vtkCamera * GetActiveCamera()
Get the current camera.
std::string ComputeColor2DDeclaration(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol), int noOfComponents, int independentComponents, std::map< int, std::string > colorTableMap)
std::string CroppingImplementation(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *mapper, vtkVolume *vtkNotUsed(vol))
bool HasGradientOpacity(int index=0)
Check whether or not we have the gradient opacity.
std::string ComputeClipPositionImplementation(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol))
std::string BinaryMaskDeclaration(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol), vtkImageData *maskInput, vtkVolumeTexture *mask, int vtkNotUsed(maskType))
std::string GradientCacheDec(vtkRenderer *vtkNotUsed(ren), vtkVolume *vtkNotUsed(vol), vtkOpenGLGPUVolumeRayCastMapper::VolumeInputMap &inputs, int independentComponents=0)
virtual vtkPlaneCollection * GetClippingPlanes()
static vtkOpenGLGPUVolumeRayCastMapper * SafeDownCast(vtkObjectBase *o)
topologically and geometrically regular array of data
std::string Transfer2DDeclaration(vtkOpenGLGPUVolumeRayCastMapper::VolumeInputMap &inputs)
std::string ComputeGradientOpacity1DDecl(vtkVolume *vol, int noOfComponents, int independentComponents, std::map< int, std::string > gradientTableMap)
std::string BaseExit(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol))
std::string ClippingDeclarationFragment(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *mapper, vtkVolume *vtkNotUsed(vol))
virtual int GetDisableGradientOpacity(int index)
std::string BaseDeclarationVertex(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *mapper, vtkVolume *vtkNotUsed(vol), bool multipleInputs)
std::string ComputeColorDeclaration(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol), int noOfComponents, int independentComponents, std::map< int, std::string > colorTableMap)
std::string DepthPassImplementation(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol))
std::string CompositeMaskDeclarationFragment(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol), vtkImageData *maskInput, vtkVolumeTexture *mask, int maskType)
std::string TerminationInit(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *mapper, vtkVolume *vol)
std::string RenderToImageInit(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol))
std::string PickingActorPassDeclaration(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol))
std::string ComputeOpacity2DDeclaration(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol), int noOfComponents, int independentComponents, std::map< int, std::string > opacityTableMap)
std::string ComputeRayDirectionDeclaration(vtkRenderer *ren, vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol), int vtkNotUsed(noOfComponents))
std::string CroppingExit(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol))
Creates and manages the volume texture rendered by vtkOpenGLGPUVolumeRayCastMapper.
OpenGL implementation of volume rendering through ray-casting.
std::string ClippingInit(vtkRenderer *ren, vtkVolumeMapper *mapper, vtkVolume *vtkNotUsed(vol))
std::string RenderToImageImplementation(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol))
std::string ComputeLightingDeclaration(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *mapper, vtkVolume *vol, int noOfComponents, int independentComponents, int vtkNotUsed(numberOfLights), int lightingComplexity)
std::string ImageSampleDeclarationFrag(const std::vector< std::string > &varNames, const size_t usedNames)
std::string RenderToImageExit(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol))
std::string PickingIdLow24PassExit(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol))
@ MINIMUM_INTENSITY_BLEND
abstract specification for renderers
std::string TerminationDeclarationVertex(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 TerminationExit(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol))
std::map< int, vtkVolumeInputHelper > VolumeInputMap
std::string ComputeTextureCoordinates(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol))
std::string PickingIdHigh24PassExit(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol))
std::string ComputeOpacityMultiDeclaration(vtkOpenGLGPUVolumeRayCastMapper::VolumeInputMap &inputs)
std::string CompositeMaskImplementation(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol), vtkImageData *maskInput, vtkVolumeTexture *mask, int maskType, int noOfComponents)
std::string ComputeGradientOpacityMulti1DDecl(vtkOpenGLGPUVolumeRayCastMapper::VolumeInputMap &inputs)
std::string ImageSampleImplementationFrag(const std::vector< std::string > &varNames, const size_t usedNames)
virtual int GetUseClippedVoxelIntensity()
virtual vtkTypeBool GetUseDepthPass()
std::string ComputeGradientDeclaration(vtkOpenGLGPUVolumeRayCastMapper *mapper, vtkOpenGLGPUVolumeRayCastMapper::VolumeInputMap &inputs)
represents the common properties for rendering a volume.
std::string ShadingDeclarationVertex(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol))