Go to the documentation of this file.
16 #ifndef vtkVolumeShaderComposer_h
17 #define vtkVolumeShaderComposer_h
34 for (
auto& item : inputs)
46 for (
auto& item : inputs)
49 const bool lighting = volProp->
GetShade() == 1;
58 const std::string base = arrayName.substr(0, arrayName.length() - 3);
77 " //Transform vertex (data coordinates) to clip coordinates\n"
78 " // p_clip = T_ProjViewModel * T_dataToWorld * p_data\n"
79 " vec4 pos = in_projectionMatrix * in_modelViewMatrix * in_volumeMatrix[0] *\n"
80 " vec4(in_vertexPos.xyz, 1.0);\n"
81 " gl_Position = pos;\n");
90 " // Transform vertex (data coordinates) to texture coordinates.\n"
91 " // p_texture = T_dataToTex * p_data\n"
92 " vec3 uvx = sign(in_cellSpacing[0]) * (in_inverseTextureDatasetMatrix[0] *\n"
93 " vec4(in_vertexPos, 1.0)).xyz;\n"
95 " // For point dataset, we offset the texture coordinate\n"
96 " // to account for OpenGL treating voxel at the center of the cell.\n"
97 " // Transform cell tex-coordinates to point tex-coordinates (cellToPoint\n"
98 " // is an identity matrix in the case of cell data).\n"
99 " ip_textureCoords = (in_cellToPoint[0] * vec4(uvx, 1.0)).xyz;\n"
100 " ip_inverseTextureDataAdjusted = in_cellToPoint[0] * in_inverseTextureDatasetMatrix[0];\n");
110 const int numInputs = gpuMapper->GetInputCount();
112 std::ostringstream ss;
114 "uniform vec3 in_cellSpacing["<< numInputs <<
"];\n"
115 "uniform mat4 in_modelViewMatrix;\n"
116 "uniform mat4 in_projectionMatrix;\n";
118 const int numTransf = multipleInputs ? numInputs + 1 : 1;
120 "uniform mat4 in_volumeMatrix[" << numTransf <<
"];\n"
121 "uniform mat4 in_inverseTextureDatasetMatrix[" << numTransf <<
"];\n"
122 "uniform mat4 in_cellToPoint[" << numTransf <<
"];\n"
124 "//This variable could be 'invariant varying' but it is declared\n"
125 "//as 'varying' to avoid compiler compatibility issues.\n"
126 "out mat4 ip_inverseTextureDataAdjusted;\n";
135 int vtkNotUsed(numberOfLights),
136 int lightingComplexity,
138 int independentComponents)
140 const int numInputs = static_cast<int>(inputs.size());
142 std::ostringstream toShaderStr;
144 "uniform sampler3D in_volume[" << numInputs <<
"];\n";
147 "uniform vec4 in_volume_scale[" << numInputs <<
"];\n"
148 "uniform vec4 in_volume_bias[" << numInputs <<
"];\n";
151 "uniform int in_noOfComponents;\n"
152 "uniform int in_independentComponents;\n"
154 "uniform sampler2D in_noiseSampler;\n"
156 "uniform sampler2D in_depthSampler;\n"
159 "// Camera position\n"
160 "uniform vec3 in_cameraPos;\n";
164 const int numTransf = (numInputs > 1) ? numInputs + 1 :
167 "uniform mat4 in_volumeMatrix[" << numTransf <<
"];\n"
168 "uniform mat4 in_inverseVolumeMatrix[" << numTransf <<
"];\n"
169 "uniform mat4 in_textureDatasetMatrix[" << numTransf <<
"];\n"
170 "uniform mat4 in_inverseTextureDatasetMatrix[" << numTransf <<
"];\n"
171 "uniform mat4 in_textureToEye[" << numTransf <<
"];\n"
172 "uniform vec3 in_texMin[" << numTransf <<
"];\n"
173 "uniform vec3 in_texMax[" << numTransf <<
"];\n"
174 "uniform mat4 in_cellToPoint[" << numTransf <<
"];\n";
177 "// view and model matrices\n"
178 "uniform mat4 in_projectionMatrix;\n"
179 "uniform mat4 in_inverseProjectionMatrix;\n"
180 "uniform mat4 in_modelViewMatrix;\n"
181 "uniform mat4 in_inverseModelViewMatrix;\n"
182 "in mat4 ip_inverseTextureDataAdjusted;\n"
185 "uniform vec3 in_cellStep[" << numInputs <<
"];\n";
188 "uniform vec2 in_scalarsRange[" << numInputs * 4 <<
"];\n"
189 "uniform vec3 in_cellSpacing[" << numInputs <<
"];\n"
191 "// Sample distance\n"
192 "uniform float in_sampleDistance;\n"
195 "uniform vec2 in_windowLowerLeftCorner;\n"
196 "uniform vec2 in_inverseOriginalWindowSize;\n"
197 "uniform vec2 in_inverseWindowSize;\n"
198 "uniform vec3 in_textureExtentsMax;\n"
199 "uniform vec3 in_textureExtentsMin;\n"
201 "// Material and lighting\n"
202 "uniform vec3 in_diffuse[4];\n"
203 "uniform vec3 in_ambient[4];\n"
204 "uniform vec3 in_specular[4];\n"
205 "uniform float in_shininess[4];\n"
208 "uniform bool in_useJittering;\n"
209 "vec3 g_rayJitter = vec3(0.0);\n"
211 "uniform vec2 in_averageIPRange;\n";
213 const bool hasGradientOpacity = HasGradientOpacity(inputs);
214 if (lightingComplexity > 0 || hasGradientOpacity)
217 "uniform bool in_twoSidedLighting;\n";
220 if (lightingComplexity == 3)
223 "vec4 g_fragWorldPos;\n"
224 "uniform int in_numberOfLights;\n"
225 "uniform vec3 in_lightAmbientColor[6];\n"
226 "uniform vec3 in_lightDiffuseColor[6];\n"
227 "uniform vec3 in_lightSpecularColor[6];\n"
228 "uniform vec3 in_lightDirection[6];\n"
229 "uniform vec3 in_lightPosition[6];\n"
230 "uniform vec3 in_lightAttenuation[6];\n"
231 "uniform float in_lightConeAngle[6];\n"
232 "uniform float in_lightExponent[6];\n"
233 "uniform int in_lightPositional[6];\n";
235 else if (lightingComplexity == 2)
238 "vec4 g_fragWorldPos;\n"
239 "uniform int in_numberOfLights;\n"
240 "uniform vec3 in_lightAmbientColor[6];\n"
241 "uniform vec3 in_lightDiffuseColor[6];\n"
242 "uniform vec3 in_lightSpecularColor[6];\n"
243 "uniform vec3 in_lightDirection[6];\n";
248 "uniform vec3 in_lightAmbientColor[1];\n"
249 "uniform vec3 in_lightDiffuseColor[1];\n"
250 "uniform vec3 in_lightSpecularColor[1];\n"
251 "vec4 g_lightPosObj;\n"
257 if (noOfComponents > 1 && independentComponents)
260 "uniform vec4 in_componentWeight;\n";
269 "uniform sampler2D in_depthPassSampler;\n";
275 "#if NUMBER_OF_CONTOURS\n"
276 "uniform float in_isosurfacesValues[NUMBER_OF_CONTOURS];\n"
278 "int findIsoSurfaceIndex(float scalar, float array[NUMBER_OF_CONTOURS+2])\n"
280 " int index = NUMBER_OF_CONTOURS >> 1;\n"
281 " while (scalar > array[index]) ++index;\n"
282 " while (scalar < array[index]) --index;\n"
288 return toShaderStr.str();
295 int lightingComplexity)
299 vtkVolume* vol = inputs.begin()->second.Volume;
308 \n vec2 fragTexCoord2 = (gl_FragCoord.xy - in_windowLowerLeftCorner) *\
309 \n in_inverseWindowSize;\
310 \n vec4 depthValue = texture2D(in_depthPassSampler, fragTexCoord2);\
311 \n vec4 dataPos = WindowToNDC(gl_FragCoord.x, gl_FragCoord.y, depthValue.x);\
313 \n // From normalized device coordinates to eye coordinates.\
314 \n // in_projectionMatrix is inversed because of way VT\
315 \n // From eye coordinates to texture coordinates\
316 \n dataPos = in_inverseTextureDatasetMatrix[0] *\
317 \n in_inverseVolumeMatrix[0] *\
318 \n in_inverseModelViewMatrix *\
319 \n in_inverseProjectionMatrix *\
321 \n dataPos /= dataPos.w;\
322 \n g_dataPos = dataPos.xyz;"
328 \n // Get the 3D texture coordinates for lookup into the in_volume dataset\
329 \n g_dataPos = ip_textureCoords.xyz;"
335 \n // Eye position in dataset space\
336 \n g_eyePosObj = in_inverseVolumeMatrix[0] * vec4(in_cameraPos, 1.0);\
338 \n // Getting the ray marching direction (in dataset space);\
339 \n vec3 rayDir = computeRayDirection();\
341 \n // Multiply the raymarching direction with the step size to get the\
342 \n // sub-step size we need to take at each raymarching step\
343 \n g_dirStep = (ip_inverseTextureDataAdjusted *\
344 \n vec4(rayDir, 0.0)).xyz * in_sampleDistance;\
346 \n // 2D Texture fragment coordinates [0,1] from fragment coordinates.\
347 \n // The frame buffer texture has the size of the plain buffer but \
348 \n // we use a fraction of it. The texture coordinate is less than 1 if\
349 \n // the reduction factor is less than 1.\
350 \n // Device coordinates are between -1 and 1. We need texture\
351 \n // coordinates between 0 and 1. The in_depthSampler\
352 \n // buffer has the original size buffer.\
353 \n vec2 fragTexCoord = (gl_FragCoord.xy - in_windowLowerLeftCorner) *\
354 \n in_inverseWindowSize;\
356 \n if (in_useJittering)\
358 \n float jitterValue = texture2D(in_noiseSampler, gl_FragCoord.xy / textureSize(in_noiseSampler, 0)).x;\
359 \n g_rayJitter = g_dirStep * jitterValue;\
363 \n g_rayJitter = g_dirStep;\
365 \n g_dataPos += g_rayJitter;\
367 \n // Flag to deternmine if voxel should be considered for the rendering\
368 \n g_skip = false;");
373 \n // Light position in dataset space\
374 \n g_lightPosObj = (in_inverseVolumeMatrix[0] *\
375 \n vec4(in_cameraPos, 1.0));\
376 \n g_ldir = normalize(g_lightPosObj.xyz - ip_vertexPos);\
377 \n g_vdir = normalize(g_eyePosObj.xyz - ip_vertexPos);\
378 \n g_h = normalize(g_ldir + g_vdir);"
405 int noOfComponents,
int independentComponents,
406 std::map<int, std::string> gradientTableMap)
408 std::ostringstream ss;
409 ss <<
"uniform sampler2D " << ArrayBaseName(gradientTableMap[0])
410 <<
"[" << noOfComponents <<
"];\n";
414 (noOfComponents == 1 || !independentComponents))
417 \nfloat computeGradientOpacity(vec4 grad)\
419 \n return texture2D("+gradientTableMap[0]+
", vec2(grad.w, 0.0)).r;\
423 else if (noOfComponents > 1 && independentComponents &&
427 \nfloat computeGradientOpacity(vec4 grad, int component)\
430 for (
int i = 0; i < noOfComponents; ++i)
432 std::ostringstream toString;
435 \n if (component == " + toString.str() +
")");
439 \n return texture2D("+ gradientTableMap[i] +
", vec2(grad.w, 0.0)).r;\
455 const bool hasLighting = HasLighting(inputs);
456 const bool hasGradientOp = HasGradientOpacity(inputs);
459 if (hasLighting && !hasGradientOp)
462 "// c is short for component\n"
463 "vec4 computeGradient(in vec3 texPos, in int c, in sampler3D volume,in int index)\n"
465 " // Approximate Nabla(F) derivatives with central differences.\n"
466 " vec3 g1; // F_front\n"
467 " vec3 g2; // F_back\n"
468 " vec3 xvec = vec3(in_cellStep[index].x, 0.0, 0.0);\n"
469 " vec3 yvec = vec3(0.0, in_cellStep[index].y, 0.0);\n"
470 " vec3 zvec = vec3(0.0, 0.0, in_cellStep[index].z);\n"
471 " g1.x = texture3D(volume, vec3(texPos + xvec))[c];\n"
472 " g1.y = texture3D(volume, vec3(texPos + yvec))[c];\n"
473 " g1.z = texture3D(volume, vec3(texPos + zvec))[c];\n"
474 " g2.x = texture3D(volume, vec3(texPos - xvec))[c];\n"
475 " g2.y = texture3D(volume, vec3(texPos - yvec))[c];\n"
476 " g2.z = texture3D(volume, vec3(texPos - zvec))[c];\n"
478 " // Apply scale and bias to the fetched values.\n"
479 " g1 = g1 * in_volume_scale[index][c] + in_volume_bias[index][c];\n"
480 " g2 = g2 * in_volume_scale[index][c] + in_volume_bias[index][c];\n"
482 " // Central differences: (F_front - F_back) / 2h\n"
483 " // This version of computeGradient() is only used for lighting\n"
484 " // calculations (only direction matters), hence the difference is\n"
485 " // not scaled by 2h and a dummy gradient mag is returned (-1.).\n"
486 " return vec4((g1 - g2) / in_cellSpacing[index], -1.0);\n"
489 else if (hasGradientOp)
492 "// c is short for component\n"
493 "vec4 computeGradient(in vec3 texPos, in int c, in sampler3D volume, in int index)\n"
495 " // Approximate Nabla(F) derivatives with central differences.\n"
496 " vec3 g1; // F_front\n"
497 " vec3 g2; // F_back\n"
498 " vec3 xvec = vec3(in_cellStep[index].x, 0.0, 0.0);\n"
499 " vec3 yvec = vec3(0.0, in_cellStep[index].y, 0.0);\n"
500 " vec3 zvec = vec3(0.0, 0.0, in_cellStep[index].z);\n"
501 " g1.x = texture3D(volume, vec3(texPos + xvec))[c];\n"
502 " g1.y = texture3D(volume, vec3(texPos + yvec))[c];\n"
503 " g1.z = texture3D(volume, vec3(texPos + zvec))[c];\n"
504 " g2.x = texture3D(volume, vec3(texPos - xvec))[c];\n"
505 " g2.y = texture3D(volume, vec3(texPos - yvec))[c];\n"
506 " g2.z = texture3D(volume, vec3(texPos - zvec))[c];\n"
508 " // Apply scale and bias to the fetched values.\n"
509 " g1 = g1 * in_volume_scale[index][c] + in_volume_bias[index][c];\n"
510 " g2 = g2 * in_volume_scale[index][c] + in_volume_bias[index][c];\n"
512 " // Scale values the actual scalar range.\n"
513 " float range = in_scalarsRange[c][1] - in_scalarsRange[c][0];\n"
514 " g1 = in_scalarsRange[c][0] + range * g1;\n"
515 " g2 = in_scalarsRange[c][0] + range * g2;\n"
517 " // Central differences: (F_front - F_back) / 2h\n"
520 " float avgSpacing = (in_cellSpacing[index].x +\n"
521 " in_cellSpacing[index].y + in_cellSpacing[index].z) / 3.0;\n"
522 " vec3 aspect = in_cellSpacing[index] * 2.0 / avgSpacing;\n"
524 " float grad_mag = length(g2);\n"
526 " // Handle normalizing with grad_mag == 0.0\n"
527 " g2 = grad_mag > 0.0 ? normalize(g2) : vec3(0.0);\n"
529 " // Since the actual range of the gradient magnitude is unknown,\n"
530 " // assume it is in the range [0, 0.25 * dataRange].\n"
531 " range = range != 0 ? range : 1.0;\n"
532 " grad_mag = grad_mag / (0.25 * range);\n"
533 " grad_mag = clamp(grad_mag, 0.0, 1.0);\n"
535 " return vec4(g2.xyz, grad_mag);\n"
541 "vec4 computeGradient(in vec3 texPos, in int c, in sampler3D volume, in int index)\n"
543 " return vec4(0.0);\n"
555 int independentComponents,
556 int vtkNotUsed(numberOfLights),
557 int lightingComplexity)
561 \nvec4 computeLighting(vec4 color, int component)\
563 \n vec4 finalColor = vec4(0.0);"
567 int const shadeReqd = volProperty->
GetShade() &&
575 switch (transferMode)
578 " // Compute gradient function only once\n"
579 " vec4 gradient = computeGradient(g_dataPos, component, in_volume[0], 0);\n");
583 " // TransferFunction2D is enabled so the gradient for\n"
584 " // each component has already been cached\n"
585 " vec4 gradient = g_gradients_0[component];\n");
592 if (lightingComplexity == 1)
595 \n vec3 diffuse = vec3(0.0);\
596 \n vec3 specular = vec3(0.0);\
597 \n vec3 normal = gradient.xyz;\
598 \n float normalLength = length(normal);\
599 \n if (normalLength > 0.0)\
601 \n normal = normalize(normal);\
605 \n normal = vec3(0.0, 0.0, 0.0);\
607 \n float nDotL = dot(normal, g_ldir);\
608 \n float nDotH = dot(normal, g_h);\
609 \n if (nDotL < 0.0 && in_twoSidedLighting)\
613 \n if (nDotH < 0.0 && in_twoSidedLighting)\
619 \n diffuse = nDotL * in_diffuse[component] *\
620 \n in_lightDiffuseColor[0] * color.rgb;\
622 \n specular = pow(nDotH, in_shininess[component]) *\
623 \n in_specular[component] *\
624 \n in_lightSpecularColor[0];\
625 \n // For the headlight, ignore the light's ambient color\
626 \n // for now as it is causing the old mapper tests to fail\
627 \n finalColor.xyz = in_ambient[component] * color.rgb +\
628 \n diffuse + specular;"
631 else if (lightingComplexity == 2)
634 \n g_fragWorldPos = in_modelViewMatrix * in_volumeMatrix[0] *\
635 \n in_textureDatasetMatrix[0] * vec4(-g_dataPos, 1.0);\
636 \n if (g_fragWorldPos.w != 0.0)\
638 \n g_fragWorldPos /= g_fragWorldPos.w;\
640 \n vec3 vdir = normalize(g_fragWorldPos.xyz);\
641 \n vec3 normal = gradient.xyz;\
642 \n vec3 ambient = vec3(0.0);\
643 \n vec3 diffuse = vec3(0.0);\
644 \n vec3 specular = vec3(0.0);\
645 \n float normalLength = length(normal);\
646 \n if (normalLength > 0.0)\
648 \n normal = normalize((in_textureToEye[0] * vec4(normal, 0.0)).xyz);\
652 \n normal = vec3(0.0, 0.0, 0.0);\
654 \n for (int lightNum = 0; lightNum < in_numberOfLights; lightNum++)\
656 \n vec3 ldir = in_lightDirection[lightNum].xyz;\
657 \n vec3 h = normalize(ldir + vdir);\
658 \n float nDotH = dot(normal, h);\
659 \n if (nDotH < 0.0 && in_twoSidedLighting)\
663 \n float nDotL = dot(normal, ldir);\
664 \n if (nDotL < 0.0 && in_twoSidedLighting)\
670 \n diffuse += in_lightDiffuseColor[lightNum] * nDotL;\
674 \n specular = in_lightSpecularColor[lightNum] *\
675 \n pow(nDotH, in_shininess[component]);\
677 \n ambient += in_lightAmbientColor[lightNum];\
679 \n finalColor.xyz = in_ambient[component] * ambient +\
680 \n in_diffuse[component] * diffuse * color.rgb +\
681 \n in_specular[component] * specular;"
684 else if (lightingComplexity == 3)
687 \n g_fragWorldPos = in_modelViewMatrix * in_volumeMatrix[0] *\
688 \n in_textureDatasetMatrix[0] * vec4(g_dataPos, 1.0);\
689 \n if (g_fragWorldPos.w != 0.0)\
691 \n g_fragWorldPos /= g_fragWorldPos.w;\
693 \n vec3 viewDirection = normalize(-g_fragWorldPos.xyz);\
694 \n vec3 ambient = vec3(0,0,0);\
695 \n vec3 diffuse = vec3(0,0,0);\
696 \n vec3 specular = vec3(0,0,0);\
697 \n vec3 vertLightDirection;\
698 \n vec3 normal = normalize((in_textureToEye[0] * vec4(gradient.xyz, 0.0)).xyz);\
700 \n for (int lightNum = 0; lightNum < in_numberOfLights; lightNum++)\
702 \n float attenuation = 1.0;\
704 \n lightDir = in_lightDirection[lightNum];\
705 \n if (in_lightPositional[lightNum] == 0)\
707 \n vertLightDirection = lightDir;\
711 \n vertLightDirection = (g_fragWorldPos.xyz - in_lightPosition[lightNum]);\
712 \n float distance = length(vertLightDirection);\
713 \n vertLightDirection = normalize(vertLightDirection);\
714 \n attenuation = 1.0 /\
715 \n (in_lightAttenuation[lightNum].x\
716 \n + in_lightAttenuation[lightNum].y * distance\
717 \n + in_lightAttenuation[lightNum].z * distance * distance);\
718 \n // per OpenGL standard cone angle is 90 or less for a spot light\
719 \n if (in_lightConeAngle[lightNum] <= 90.0)\
721 \n float coneDot = dot(vertLightDirection, lightDir);\
722 \n // if inside the cone\
723 \n if (coneDot >= cos(radians(in_lightConeAngle[lightNum])))\
725 \n attenuation = attenuation * pow(coneDot, in_lightExponent[lightNum]);\
729 \n attenuation = 0.0;\
733 \n // diffuse and specular lighting\
734 \n float nDotL = dot(normal, vertLightDirection);\
735 \n if (nDotL < 0.0 && in_twoSidedLighting)\
741 \n float df = max(0.0, attenuation * nDotL);\
742 \n diffuse += (df * in_lightDiffuseColor[lightNum]);\
744 \n vec3 h = normalize(vertLightDirection + viewDirection);\
745 \n float nDotH = dot(normal, h);\
746 \n if (nDotH < 0.0 && in_twoSidedLighting)\
752 \n float sf = attenuation * pow(nDotH, in_shininess[component]);\
753 \n specular += (sf * in_lightSpecularColor[lightNum]);\
755 \n ambient += in_lightAmbientColor[lightNum];\
757 \n finalColor.xyz = in_ambient[component] * ambient +\
758 \n in_diffuse[component] * diffuse * color.rgb +\
759 \n in_specular[component] * specular;\
766 "\n finalColor = vec4(color.rgb, 0.0);"
776 glMapper->GetInputCount() == 1)
779 (noOfComponents == 1 || !independentComponents))
782 \n if (gradient.w >= 0.0)\
784 \n color.a = color.a *\
785 \n computeGradientOpacity(gradient);\
789 else if (noOfComponents > 1 && independentComponents &&
793 \n if (gradient.w >= 0.0)\
795 \n for (int i = 0; i < in_noOfComponents; ++i)\
797 \n color.a = color.a *\
798 \n computeGradientOpacity(gradient, i) * in_componentWeight[i];\
806 \n finalColor.a = color.a;\
807 \n return finalColor;\
818 int vtkNotUsed(noOfComponents))
823 \nvec3 computeRayDirection()\
825 \n return normalize(ip_vertexPos.xyz - g_eyePosObj.xyz);\
831 \nuniform vec3 in_projectionDirection;\
832 \nvec3 computeRayDirection()\
834 \n return normalize((in_inverseVolumeMatrix[0] *\
835 \n vec4(in_projectionDirection, 0.0)).xyz);\
845 int independentComponents,
846 std::map<int, std::string> colorTableMap)
848 std::ostringstream ss;
849 ss <<
"uniform sampler2D " << ArrayBaseName(colorTableMap[0])
850 <<
"[" << noOfComponents <<
"];\n";
853 if (noOfComponents == 1)
856 \nvec4 computeColor(vec4 scalar, float opacity)\
858 \n return computeLighting(vec4(texture2D(" + colorTableMap[0] +
",\
859 \n vec2(scalar.w, 0.0)).xyz, opacity), 0);\
863 else if (noOfComponents > 1 && independentComponents)
865 std::ostringstream toString;
868 \nvec4 computeColor(vec4 scalar, float opacity, int component)\
871 for (
int i = 0; i < noOfComponents; ++i)
875 \n if (component == " + toString.str() +
")");
879 \n return computeLighting(vec4(texture2D(\
880 \n "+colorTableMap[i]);
882 \n scalar[" + toString.str() +
"],0.0)).xyz,\
883 \n opacity),"+toString.str()+
");\
894 else if (noOfComponents == 2 && !independentComponents)
897 \nvec4 computeColor(vec4 scalar, float opacity)\
899 \n return computeLighting(vec4(texture2D(" + colorTableMap[0] +
",\
900 \n vec2(scalar.x, 0.0)).xyz,\
908 \nvec4 computeColor(vec4 scalar, float opacity)\
910 \n return computeLighting(vec4(scalar.xyz, opacity), 0);\
920 std::ostringstream ss;
922 for (
auto& item : inputs)
924 auto prop = item.second.Volume->GetProperty();
928 auto& map = item.second.RGBTablesMap;
929 const auto numComp = map.size();
930 ss <<
"uniform sampler2D " << ArrayBaseName(map[0])
931 <<
"[" << numComp <<
"];\n";
936 "vec3 computeColor(const in float scalar, const in sampler2D colorTF)\n"
938 " return texture2D(colorTF, vec2(scalar, 0)).rgb;\n"
947 std::ostringstream ss;
949 for (
auto& item : inputs)
951 auto prop = item.second.Volume->GetProperty();
955 auto& map = item.second.OpacityTablesMap;
956 const auto numComp = map.size();
957 ss <<
"uniform sampler2D " << ArrayBaseName(map[0])
958 <<
"[" << numComp <<
"];\n";
963 "float computeOpacity(const in float scalar, const in sampler2D opacityTF)\n"
965 " return texture2D(opacityTF, vec2(scalar, 0)).r;\n"
974 std::ostringstream ss;
977 for (
auto& item : inputs)
979 auto prop = item.second.Volume->GetProperty();
981 !prop->HasGradientOpacity())
984 auto& map = item.second.GradientOpacityTablesMap;
985 const auto numComp = map.size();
986 ss <<
"uniform sampler2D " << ArrayBaseName(map[0])
987 <<
"[" << numComp <<
"];\n";
992 "float computeGradientOpacity(const in float scalar, const in sampler2D opacityTF)\n"
994 " return texture2D(opacityTF, vec2(scalar, 0)).r;\n"
1004 int independentComponents,
1005 std::map<int, std::string> opacityTableMap)
1007 std::ostringstream ss;
1008 ss <<
"uniform sampler2D " << ArrayBaseName(opacityTableMap[0])
1009 <<
"[" << noOfComponents <<
"];\n";
1012 if (noOfComponents > 1 && independentComponents)
1015 \nfloat computeOpacity(vec4 scalar, int component)\
1018 for (
int i = 0; i < noOfComponents; ++i)
1020 std::ostringstream toString;
1023 \n if (component == " + toString.str() +
")");
1027 \n return texture2D(" + opacityTableMap[i]);
1029 shaderStr +=
std::string(
",vec2(scalar[" + toString.str() +
"], 0)).r;\
1036 else if (noOfComponents == 2 && !independentComponents)
1039 \nfloat computeOpacity(vec4 scalar)\
1041 \n return texture2D(" + opacityTableMap[0] +
", vec2(scalar.y, 0)).r;\
1048 \nfloat computeOpacity(vec4 scalar)\
1050 \n return texture2D(" + opacityTableMap[0] +
", vec2(scalar.w, 0)).r;\
1061 int independentComponents,
1062 std::map<int, std::string> colorTableMap)
1064 if (noOfComponents == 1)
1068 "vec4 computeColor(vec4 scalar, float opacity)\n"
1070 " vec4 color = texture2D(" + colorTableMap[0] +
",\n"
1071 " vec2(scalar.w, g_gradients_0[0].w));\n"
1072 " return computeLighting(color, 0);\n"
1075 else if (noOfComponents > 1 && independentComponents)
1080 "vec4 computeColor(vec4 scalar, float opacity, int component)\n"
1083 for (
int i = 0; i < noOfComponents; ++i)
1085 std::ostringstream toString;
1089 " if (component == " + num +
")\n"
1091 " vec4 color = texture2D(" + colorTableMap[i] +
",\n"
1092 " vec2(scalar[" + num +
"], g_gradients_0[" + num +
"].w));\n"
1093 " return computeLighting(color, " + num +
");\n"
1100 else if (noOfComponents == 2 && !independentComponents)
1104 "vec4 computeColor(vec4 scalar, float opacity)\n"
1106 " vec4 color = texture2D(" + colorTableMap[0] +
",\n"
1107 " vec2(scalar.x, g_gradients_0[0].w));\n"
1108 " return computeLighting(color, 0);\n"
1114 "vec4 computeColor(vec4 scalar, float opacity)\n"
1116 " return computeLighting(vec4(scalar.xyz, opacity), 0);\n"
1124 std::ostringstream ss;
1126 for (
auto& item : inputs)
1128 auto prop = item.second.Volume->GetProperty();
1132 auto& map = item.second.TransferFunctions2DMap;
1133 const auto numComp = map.size();
1134 ss <<
"uniform sampler2D " << ArrayBaseName(map[0])
1135 <<
"[" << numComp <<
"];\n";
1147 int independentComponents,
1148 std::map<int, std::string> opacityTableMap)
1150 std::ostringstream toString;
1151 if (noOfComponents > 1 && independentComponents)
1155 "float computeOpacity(vec4 scalar, int component)\n"
1158 for (
int i = 0; i < noOfComponents; ++i)
1161 " if (component == " << i <<
")\n"
1163 " return texture2D(" << opacityTableMap[i] <<
",\n"
1164 " vec2(scalar[" << i <<
"], g_gradients_0[" << i <<
"].w)).a;\n"
1170 else if (noOfComponents == 2 && !independentComponents)
1174 "float computeOpacity(vec4 scalar)\n"
1176 " return texture2D(" + opacityTableMap[0] +
",\n"
1177 " vec2(scalar.y, g_gradients_0[0].w)).a;\n"
1184 "float computeOpacity(vec4 scalar)\n"
1186 " return texture2D(" + opacityTableMap[0] +
",\n"
1187 " vec2(scalar.a, g_gradients_0[0].w)).a;\n"
1190 return toString.str();
1209 \n bool l_firstValue;\
1210 \n vec4 l_maxValue;");
1216 \n bool l_firstValue;\
1217 \n vec4 l_minValue;");
1222 \n uvec4 l_numSamples;\
1223 \n vec4 l_avgValue;");
1228 \n vec4 l_sumValue;");
1233 \n int l_initialIndex = 0;\
1234 \n float l_normValues[NUMBER_OF_CONTOURS + 2];");
1250 \n // We get data between 0.0 - 1.0 range\
1251 \n l_firstValue = true;\
1252 \n l_maxValue = vec4(0.0);"
1259 \n //We get data between 0.0 - 1.0 range\
1260 \n l_firstValue = true;\
1261 \n l_minValue = vec4(1.0);"
1267 \n //We get data between 0.0 - 1.0 range\
1268 \n l_avgValue = vec4(0.0);\
1269 \n // Keep track of number of samples\
1270 \n l_numSamples = uvec4(0);"
1276 \n //We get data between 0.0 - 1.0 range\
1277 \n l_sumValue = vec4(0.0);"
1283 \n#if NUMBER_OF_CONTOURS\
1284 \n l_normValues[0] = -1e20; //-infinity\
1285 \n l_normValues[NUMBER_OF_CONTOURS+1] = +1e20; //+infinity\
1286 \n for (int i = 0; i < NUMBER_OF_CONTOURS; i++)\
1288 \n l_normValues[i+1] = (in_isosurfacesValues[i] - in_scalarsRange[0].x) / \
1289 \n (in_scalarsRange[0].y - in_scalarsRange[0].x);\
1304 int independentComponents = 0)
1306 const int numInputs = static_cast<int>(inputs.size());
1307 const int comp = numInputs == 1 ?
1309 (!independentComponents ? 1 : numInputs) :
1313 std::ostringstream toShader;
1314 for (
const auto& item : inputs)
1316 auto& input = item.second;
1317 if (input.Volume->GetProperty()->HasGradientOpacity())
1320 "vec4 " << input.GradientCacheName <<
"[" << comp <<
"];\n";
1324 return toShader.str();
1330 int noOfComponents = 1,
1331 int independentComponents = 0)
1333 std::ostringstream shader;
1334 if (independentComponents)
1336 if (noOfComponents == 1)
1339 "g_gradients_0[0] = computeGradient(g_dataPos, 0, in_volume[0], 0);\n";
1345 "for (int comp = 0; comp < in_noOfComponents; comp++)\n"
1347 " g_gradients_0[comp] = computeGradient(g_dataPos, comp, in_volume[0], 0);\n"
1354 "g_gradients_0[0] = computeGradient(g_dataPos, 0, in_volume[0], 0);\n";
1357 return shader.str();
1364 std::ostringstream toShaderStr;
1376 for (
auto& item : inputs)
1378 auto& input = item.second;
1379 auto property = input.Volume->GetProperty();
1381 const auto idx = i + 1;
1386 " texPos = (in_cellToPoint[" << idx <<
"] * in_inverseTextureDatasetMatrix[" << idx
1387 <<
"] * in_inverseVolumeMatrix[" << idx <<
"] *\n"
1388 " in_volumeMatrix[0] * in_textureDatasetMatrix[0] * vec4(g_dataPos.xyz, 1.0)).xyz;\n"
1389 " if ((all(lessThanEqual(texPos, vec3(1.0))) &&\n"
1390 " all(greaterThanEqual(texPos, vec3(0.0)))))\n"
1392 " vec4 scalar = texture3D(in_volume[" << i <<
"], texPos);\n"
1393 " scalar = scalar * in_volume_scale[" << i <<
"] + in_volume_bias[" << i <<
"];\n"
1394 " scalar = vec4(scalar.r);\n"
1395 " g_srcColor = vec4(0.0);\n";
1400 " g_srcColor.a = computeOpacity(scalar.r," << input.OpacityTablesMap[0] <<
");\n"
1401 " if (g_srcColor.a > 0.0)\n"
1403 " g_srcColor.rgb = computeColor(scalar.r, " << input.RGBTablesMap[0] <<
");\n";
1405 if (property->HasGradientOpacity())
1407 const auto& grad = input.GradientCacheName;
1409 " " << grad <<
"[0] = computeGradient(texPos, 0, " <<
"in_volume[" << i <<
"], " << i <<
");\n"
1410 " if ("<< grad <<
"[0].w >= 0.0)\n"
1412 " g_srcColor.a *= computeGradientOpacity(" << grad <<
"[0].w, "
1413 << input.GradientOpacityTablesMap[0] <<
");\n"
1419 const auto& grad = input.GradientCacheName;
1422 " " << grad <<
"[0] = computeGradient(texPos, 0, " <<
"in_volume[" << i <<
"], " << i <<
");\n"
1423 " g_srcColor = texture2D(" << input.TransferFunctions2DMap[0] <<
", vec2(scalar.r, " << input.GradientCacheName <<
"[0].w));\n"
1424 " if (g_srcColor.a > 0.0)\n"
1429 " g_srcColor.rgb *= g_srcColor.a;\n"
1430 " g_fragColor = (1.0f - g_fragColor.a) * g_srcColor + g_fragColor;\n"
1442 return toShaderStr.str();
1452 int independentComponents = 0)
1458 \n vec4 scalar = texture3D(in_volume[0], g_dataPos);"
1462 if (noOfComponents == 1)
1465 \n scalar.r = scalar.r * in_volume_scale[0].r + in_volume_bias[0].r;\
1466 \n scalar = vec4(scalar.r);"
1473 \n scalar = scalar * in_volume_scale[0] + in_volume_bias[0];"
1479 if (noOfComponents > 1)
1481 if (!independentComponents)
1484 \n if (l_maxValue.w < scalar.w || l_firstValue)\
1486 \n l_maxValue = scalar;\
1489 \n if (l_firstValue)\
1491 \n l_firstValue = false;\
1498 \n for (int i = 0; i < in_noOfComponents; ++i)\
1500 \n if (l_maxValue[i] < scalar[i] || l_firstValue)\
1502 \n l_maxValue[i] = scalar[i];\
1505 \n if (l_firstValue)\
1507 \n l_firstValue = false;\
1515 \n if (l_maxValue.w < scalar.x || l_firstValue)\
1517 \n l_maxValue.w = scalar.x;\
1520 \n if (l_firstValue)\
1522 \n l_firstValue = false;\
1529 if (noOfComponents > 1)
1531 if (!independentComponents)
1534 \n if (l_minValue.w > scalar.w || l_firstValue)\
1536 \n l_minValue = scalar;\
1539 \n if (l_firstValue)\
1541 \n l_firstValue = false;\
1548 \n for (int i = 0; i < in_noOfComponents; ++i)\
1550 \n if (l_minValue[i] < scalar[i] || l_firstValue)\
1552 \n l_minValue[i] = scalar[i];\
1555 \n if (l_firstValue)\
1557 \n l_firstValue = false;\
1565 \n if (l_minValue.w > scalar.x || l_firstValue)\
1567 \n l_minValue.w = scalar.x;\
1570 \n if (l_firstValue)\
1572 \n l_firstValue = false;\
1579 if (noOfComponents > 1 && independentComponents)
1582 \n for (int i = 0; i < in_noOfComponents; ++i)\
1584 \n // Get the intensity in volume scalar range\
1585 \n float intensity = in_scalarsRange[i][0] +\
1586 \n (in_scalarsRange[i][1] -\
1587 \n in_scalarsRange[i][0]) * scalar[i];\
1588 \n if (in_averageIPRange.x <= intensity &&\
1589 \n intensity <= in_averageIPRange.y)\
1591 \n l_avgValue[i] += computeOpacity(scalar, i) * scalar[i];\
1592 \n ++l_numSamples[i];\
1600 \n // Get the intensity in volume scalar range\
1601 \n float intensity = in_scalarsRange[0][0] +\
1602 \n (in_scalarsRange[0][1] -\
1603 \n in_scalarsRange[0][0]) * scalar.x;\
1604 \n if (in_averageIPRange.x <= intensity &&\
1605 \n intensity <= in_averageIPRange.y)\
1607 \n l_avgValue.x += computeOpacity(scalar) * scalar.x;\
1608 \n ++l_numSamples.x;\
1615 if (noOfComponents > 1 && independentComponents)
1618 \n for (int i = 0; i < in_noOfComponents; ++i)\
1620 \n float opacity = computeOpacity(scalar, i);\
1621 \n l_sumValue[i] = l_sumValue[i] + opacity * scalar[i];\
1628 \n float opacity = computeOpacity(scalar);\
1629 \n l_sumValue.x = l_sumValue.x + opacity * scalar.x;"
1636 \n#if NUMBER_OF_CONTOURS\
1637 \n int maxComp = 0;");
1640 if (noOfComponents > 1 && independentComponents)
1643 \n for (int i = 1; i < in_noOfComponents; ++i)\
1645 \n if (in_componentWeight[i] > in_componentWeight[maxComp])\
1648 compParamStr =
", maxComp";
1651 \n if (g_currentT == 0)\
1653 \n l_initialIndex = findIsoSurfaceIndex(scalar[maxComp], l_normValues);\
1658 \n bool shade = false;\
1659 \n l_initialIndex = clamp(l_initialIndex, 0, NUMBER_OF_CONTOURS);\
1660 \n if (scalar[maxComp] < l_normValues[l_initialIndex])\
1662 \n s = l_normValues[l_initialIndex];\
1663 \n l_initialIndex--;\
1666 \n if (scalar[maxComp] > l_normValues[l_initialIndex+1])\
1668 \n s = l_normValues[l_initialIndex+1];\
1669 \n l_initialIndex++;\
1672 \n if (shade == true)\
1674 \n vec4 vs = vec4(s);\
1675 \n g_srcColor.a = computeOpacity(vs "+compParamStr+
");\
1676 \n g_srcColor = computeColor(vs, g_srcColor.a "+compParamStr+
");\
1677 \n g_srcColor.rgb *= g_srcColor.a;\
1678 \n g_fragColor = (1.0f - g_fragColor.a) * g_srcColor + g_fragColor;\
1685 if (noOfComponents > 1 && independentComponents)
1688 \n vec4 color[4]; vec4 tmp = vec4(0.0);\
1689 \n float totalAlpha = 0.0;\
1690 \n for (int i = 0; i < in_noOfComponents; ++i)\
1693 if (glMapper->GetUseDepthPass() && glMapper->GetCurrentPass() ==
1697 \n // Data fetching from the red channel of volume texture\
1698 \n float opacity = computeOpacity(scalar, i);\
1699 \n if (opacity > 0.0)\
1701 \n g_srcColor.a = opacity;\
1706 else if (!mask || !maskInput ||
1710 \n // Data fetching from the red channel of volume texture\
1711 \n color[i][3] = computeOpacity(scalar, i);\
1712 \n color[i] = computeColor(scalar, color[i][3], i);\
1713 \n totalAlpha += color[i][3] * in_componentWeight[i];\
1715 \n if (totalAlpha > 0.0)\
1717 \n for (int i = 0; i < in_noOfComponents; ++i)\
1719 \n // Only let visible components contribute to the final color\
1720 \n if (in_componentWeight[i] <= 0) continue;\
1722 \n tmp.x += color[i].x * color[i].w * in_componentWeight[i];\
1723 \n tmp.y += color[i].y * color[i].w * in_componentWeight[i];\
1724 \n tmp.z += color[i].z * color[i].w * in_componentWeight[i];\
1725 \n tmp.w += ((color[i].w * color[i].w)/totalAlpha);\
1728 \n g_fragColor = (1.0f - g_fragColor.a) * tmp + g_fragColor;"
1732 else if (glMapper->GetUseDepthPass() && glMapper->GetCurrentPass() ==
1736 \n g_srcColor = vec4(0.0);\
1737 \n g_srcColor.a = computeOpacity(scalar);"
1742 if (!mask || !maskInput ||
1746 \n g_srcColor = vec4(0.0);\
1747 \n g_srcColor.a = computeOpacity(scalar);\
1748 \n if (g_srcColor.a > 0.0)\
1750 \n g_srcColor = computeColor(scalar, g_srcColor.a);"
1755 \n // Opacity calculation using compositing:\
1756 \n // Here we use front to back compositing scheme whereby\
1757 \n // the current sample value is multiplied to the\
1758 \n // currently accumulated alpha and then this product\
1759 \n // is subtracted from the sample value to get the\
1760 \n // alpha from the previous steps. Next, this alpha is\
1761 \n // multiplied with the current sample colour\
1762 \n // and accumulated to the composited colour. The alpha\
1763 \n // value from the previous steps is then accumulated\
1764 \n // to the composited colour alpha.\
1765 \n g_srcColor.rgb *= g_srcColor.a;\
1766 \n g_fragColor = (1.0f - g_fragColor.a) * g_srcColor + g_fragColor;"
1769 if (!mask || !maskInput ||
1794 \n // Special coloring mode which renders the Prop Id in fragments that\
1795 \n // have accumulated certain level of opacity. Used during the selection\
1796 \n // pass vtkHardwareSelection::ACTOR_PASS.\
1797 \n if (g_fragColor.a > 3.0/ 255.0)\
1799 \n gl_FragData[0] = vec4(in_propId, 1.0);\
1803 \n gl_FragData[0] = vec4(0.0);\
1813 \n // Special coloring mode which renders the voxel index in fragments that\
1814 \n // have accumulated certain level of opacity. Used during the selection\
1815 \n // pass vtkHardwareSelection::ID_LOW24.\
1816 \n if (g_fragColor.a > 3.0/ 255.0)\
1818 \n uvec3 volumeDim = uvec3(in_textureExtentsMax - in_textureExtentsMin);\
1819 \n uvec3 voxelCoords = uvec3(volumeDim * g_dataPos);\
1820 \n // vtkHardwareSelector assumes index 0 to be empty space, so add uint(1).\
1821 \n uint idx = volumeDim.x * volumeDim.y * voxelCoords.z +\
1822 \n volumeDim.x * voxelCoords.y + voxelCoords.x + uint(1);\
1823 \n gl_FragData[0] = vec4(float(idx % uint(256)) / 255.0,\
1824 \n float((idx / uint(256)) % uint(256)) / 255.0,\
1825 \n float((idx / uint(65536)) % uint(256)) / 255.0, 1.0);\
1829 \n gl_FragData[0] = vec4(0.0);\
1839 \n // Special coloring mode which renders the voxel index in fragments that\
1840 \n // have accumulated certain level of opacity. Used during the selection\
1841 \n // pass vtkHardwareSelection::ID_MID24.\
1842 \n if (g_fragColor.a > 3.0/ 255.0)\
1844 \n uvec3 volumeDim = uvec3(in_textureExtentsMax - in_textureExtentsMin);\
1845 \n uvec3 voxelCoords = uvec3(volumeDim * g_dataPos);\
1846 \n // vtkHardwareSelector assumes index 0 to be empty space, so add uint(1).\
1847 \n uint idx = volumeDim.x * volumeDim.y * voxelCoords.z +\
1848 \n volumeDim.x * voxelCoords.y + voxelCoords.x + uint(1);\
1849 \n idx = ((idx & 0xff000000) >> 24);\
1850 \n gl_FragData[0] = vec4(float(idx % uint(256)) / 255.0,\
1851 \n float((idx / uint(256)) % uint(256)) / 255.0,\
1852 \n float(idx / uint(65536)) / 255.0, 1.0);\
1856 \n gl_FragData[0] = vec4(0.0);\
1866 int independentComponents = 0)
1879 if (noOfComponents > 1 && independentComponents)
1882 \n g_srcColor = vec4(0);\
1883 \n for (int i = 0; i < in_noOfComponents; ++i)\
1885 \n vec4 tmp = computeColor(l_maxValue, computeOpacity(l_maxValue, i), i);\
1886 \n g_srcColor[0] += tmp[0] * tmp[3] * in_componentWeight[i];\
1887 \n g_srcColor[1] += tmp[1] * tmp[3] * in_componentWeight[i];\
1888 \n g_srcColor[2] += tmp[2] * tmp[3] * in_componentWeight[i];\
1889 \n g_srcColor[3] += tmp[3] * in_componentWeight[i];\
1891 \n g_fragColor = g_srcColor;"
1897 \n g_srcColor = computeColor(l_maxValue,\
1898 \n computeOpacity(l_maxValue));\
1899 \n g_fragColor.rgb = g_srcColor.rgb * g_srcColor.a;\
1900 \n g_fragColor.a = g_srcColor.a;"
1906 if (noOfComponents > 1 && independentComponents)
1909 \n g_srcColor = vec4(0);\
1910 \n for (int i = 0; i < in_noOfComponents; ++i)\
1912 \n vec4 tmp = computeColor(l_minValue, computeOpacity(l_minValue, i), i);\
1913 \n g_srcColor[0] += tmp[0] * tmp[3] * in_componentWeight[i];\
1914 \n g_srcColor[1] += tmp[1] * tmp[3] * in_componentWeight[i];\
1915 \n g_srcColor[2] += tmp[2] * tmp[3] * in_componentWeight[i];\
1916 \n g_srcColor[2] += tmp[3] * tmp[3] * in_componentWeight[i];\
1918 \n g_fragColor = g_srcColor;"
1924 \n g_srcColor = computeColor(l_minValue,\
1925 \n computeOpacity(l_minValue));\
1926 \n g_fragColor.rgb = g_srcColor.rgb * g_srcColor.a;\
1927 \n g_fragColor.a = g_srcColor.a;"
1933 if (noOfComponents > 1 && independentComponents)
1936 \n for (int i = 0; i < in_noOfComponents; ++i)\
1938 \n if (l_numSamples[i] == uint(0))\
1942 \n l_avgValue[i] = l_avgValue[i] * in_componentWeight[i] /\
1943 \n l_numSamples[i];\
1946 \n l_avgValue[0] += l_avgValue[i];\
1949 \n l_avgValue[0] = clamp(l_avgValue[0], 0.0, 1.0);\
1950 \n g_fragColor = vec4(vec3(l_avgValue[0]), 1.0);"
1956 \n if (l_numSamples.x == uint(0))\
1962 \n l_avgValue.x /= l_numSamples.x;\
1963 \n l_avgValue.x = clamp(l_avgValue.x, 0.0, 1.0);\
1964 \n g_fragColor = vec4(vec3(l_avgValue.x), 1.0);\
1971 if (noOfComponents > 1 && independentComponents)
1975 \n l_sumValue.x *= in_componentWeight.x;\
1976 \n for (int i = 1; i < in_noOfComponents; ++i)\
1978 \n l_sumValue.x += l_sumValue[i] * in_componentWeight[i];\
1980 \n l_sumValue.x = clamp(l_sumValue.x, 0.0, 1.0);\
1981 \n g_fragColor = vec4(vec3(l_sumValue.x), 1.0);"
1987 \n l_sumValue.x = clamp(l_sumValue.x, 0.0, 1.0);\
1988 \n g_fragColor = vec4(vec3(l_sumValue.x), 1.0);"
2012 \n const float g_opacityThreshold = 1.0 - 1.0 / 255.0;");
2020 \n uniform vec3 in_propId;");
2029 \n // Flag to indicate if the raymarch loop should terminate \
2030 \n bool stop = false;\
2032 \n g_terminatePointMax = 0.0;\
2035 \n vec4 l_depthValue = vec4(1.0,1.0,1.0,1.0);\
2037 \n vec4 l_depthValue = texture2D(in_depthSampler, fragTexCoord);\
2040 \n if(gl_FragCoord.z >= l_depthValue.x)\
2045 \n // color buffer or max scalar buffer have a reduced size.\
2046 \n fragTexCoord = (gl_FragCoord.xy - in_windowLowerLeftCorner) *\
2047 \n in_inverseOriginalWindowSize;\
2049 \n // Compute max number of iterations it will take before we hit\
2050 \n // the termination point\
2052 \n // Abscissa of the point on the depth buffer along the ray.\
2053 \n // point in texture coordinates\
2054 \n vec4 terminatePosTmp = WindowToNDC(gl_FragCoord.x, gl_FragCoord.y, l_depthValue.x);\
2056 \n // From normalized device coordinates to eye coordinates.\
2057 \n // in_projectionMatrix is inversed because of way VT\
2058 \n // From eye coordinates to texture coordinates\
2059 \n terminatePosTmp = ip_inverseTextureDataAdjusted *\
2060 \n in_inverseVolumeMatrix[0] *\
2061 \n in_inverseModelViewMatrix *\
2062 \n in_inverseProjectionMatrix *\
2063 \n terminatePosTmp;\
2064 \n g_terminatePos = terminatePosTmp.xyz / terminatePosTmp.w;\
2066 \n g_terminatePointMax = length(g_terminatePos.xyz - g_dataPos.xyz) /\
2067 \n length(g_dirStep);\
2068 \n g_currentT = 0.0;");
2077 \n if(any(greaterThan(g_dataPos, in_texMax[0])) ||\
2078 \n any(lessThan(g_dataPos, in_texMin[0])))\
2083 \n // Early ray termination\
2084 \n // if the currently composited colour alpha is already fully saturated\
2085 \n // we terminated the loop or if we have hit an obstacle in the\
2086 \n // direction of they ray (using depth buffer) we terminate as well.\
2087 \n if((g_fragColor.a > g_opacityThreshold) || \
2088 \n g_currentT >= g_terminatePointMax)\
2122 \nuniform float in_croppingPlanes[6];\
2123 \nuniform int in_croppingFlags [32];\
2124 \nfloat croppingPlanesTexture[6];\
2126 \n// X: axis = 0, Y: axis = 1, Z: axis = 2\
2127 \n// cp Cropping plane bounds (minX, maxX, minY, maxY, minZ, maxZ)\
2128 \nint computeRegionCoord(float cp[6], vec3 pos, int axis)\
2130 \n int cpmin = axis * 2;\
2131 \n int cpmax = cpmin + 1;\
2133 \n if (pos[axis] < cp[cpmin])\
2137 \n else if (pos[axis] >= cp[cpmin] &&\
2138 \n pos[axis] < cp[cpmax])\
2142 \n else if (pos[axis] >= cp[cpmax])\
2149 \nint computeRegion(float cp[6], vec3 pos)\
2151 \n return (computeRegionCoord(cp, pos, 0) +\
2152 \n (computeRegionCoord(cp, pos, 1) - 1) * 3 +\
2153 \n (computeRegionCoord(cp, pos, 2) - 1) * 9);\
2168 \n // Convert cropping region to texture space\
2169 \n mat4 datasetToTextureMat = in_inverseTextureDatasetMatrix[0];\
2171 \n vec4 tempCrop = vec4(in_croppingPlanes[0], 0.0, 0.0, 1.0);\
2172 \n tempCrop = datasetToTextureMat * tempCrop;\
2173 \n if (tempCrop[3] != 0.0)\
2175 \n tempCrop[0] /= tempCrop[3];\
2177 \n croppingPlanesTexture[0] = tempCrop[0];\
2179 \n tempCrop = vec4(in_croppingPlanes[1], 0.0, 0.0, 1.0);\
2180 \n tempCrop = datasetToTextureMat * tempCrop;\
2181 \n if (tempCrop[3] != 0.0)\
2183 \n tempCrop[0] /= tempCrop[3];\
2185 \n croppingPlanesTexture[1] = tempCrop[0];\
2187 \n tempCrop = vec4(0.0, in_croppingPlanes[2], 0.0, 1.0);\
2188 \n tempCrop = datasetToTextureMat * tempCrop;\
2189 \n if (tempCrop[3] != 0.0)\
2191 \n tempCrop[1] /= tempCrop[3];\
2193 \n croppingPlanesTexture[2] = tempCrop[1];\
2195 \n tempCrop = vec4(0.0, in_croppingPlanes[3], 0.0, 1.0);\
2196 \n tempCrop = datasetToTextureMat * tempCrop;\
2197 \n if (tempCrop[3] != 0.0)\
2199 \n tempCrop[1] /= tempCrop[3];\
2201 \n croppingPlanesTexture[3] = tempCrop[1];\
2203 \n tempCrop = vec4(0.0, 0.0, in_croppingPlanes[4], 1.0);\
2204 \n tempCrop = datasetToTextureMat * tempCrop;\
2205 \n if (tempCrop[3] != 0.0)\
2207 \n tempCrop[2] /= tempCrop[3];\
2209 \n croppingPlanesTexture[4] = tempCrop[2];\
2211 \n tempCrop = vec4(0.0, 0.0, in_croppingPlanes[5], 1.0);\
2212 \n tempCrop = datasetToTextureMat * tempCrop;\
2213 \n if (tempCrop[3] != 0.0)\
2215 \n tempCrop[2] /= tempCrop[3];\
2217 \n croppingPlanesTexture[5] = tempCrop[2];"
2231 \n // Determine region\
2232 \n int regionNo = computeRegion(croppingPlanesTexture, g_dataPos);\
2234 \n // Do & operation with cropping flags\
2235 \n // Pass the flag that its Ok to sample or not to sample\
2236 \n if (in_croppingFlags[regionNo] == 0)\
2238 \n // Skip this voxel\
2271 \n /// We support only 8 clipping planes for now\
2272 \n /// The first value is the size of the data array for clipping\
2273 \n /// planes (origin, normal)\
2274 \n uniform float in_clippingPlanes[49];\
2276 \n int clip_numPlanes;\
2277 \n vec3 clip_rayDirObj;\
2278 \n mat4 clip_texToObjMat;\
2279 \n mat4 clip_objToTexMat;\
2281 \n// Tighten the sample range as needed to account for clip planes. \
2282 \n// Arguments are in texture coordinates. \
2283 \n// Returns true if the range is at all valid after clipping. If not, \
2284 \n// the fragment should be discarded. \
2285 \nbool AdjustSampleRangeForClipping(inout vec3 startPosTex, inout vec3 stopPosTex) \
2287 \n vec4 startPosObj = vec4(0.0);\
2289 \n startPosObj = clip_texToObjMat * vec4(startPosTex - g_rayJitter, 1.0);\
2290 \n startPosObj = startPosObj / startPosObj.w;\
2291 \n startPosObj.w = 1.0;\
2294 \n vec4 stopPosObj = vec4(0.0);\
2296 \n stopPosObj = clip_texToObjMat * vec4(stopPosTex, 1.0);\
2297 \n stopPosObj = stopPosObj / stopPosObj.w;\
2298 \n stopPosObj.w = 1.0;\
2301 \n for (int i = 0; i < clip_numPlanes; i = i + 6)\
2303 \n vec3 planeOrigin = vec3(in_clippingPlanes[i + 1],\
2304 \n in_clippingPlanes[i + 2],\
2305 \n in_clippingPlanes[i + 3]);\
2306 \n vec3 planeNormal = normalize(vec3(in_clippingPlanes[i + 4],\
2307 \n in_clippingPlanes[i + 5],\
2308 \n in_clippingPlanes[i + 6]));\
2310 \n // Abort if the entire segment is clipped:\
2311 \n // (We can do this before adjusting the term point, since it'll \
2312 \n // only move further into the clipped area)\
2313 \n float startDistance = dot(planeNormal, planeOrigin - startPosObj.xyz);\
2314 \n float stopDistance = dot(planeNormal, planeOrigin - stopPosObj.xyz);\
2315 \n bool startClipped = startDistance > 0.0;\
2316 \n bool stopClipped = stopDistance > 0.0;\
2317 \n if (startClipped && stopClipped)\
2322 \n float rayDotNormal = dot(clip_rayDirObj, planeNormal);\
2323 \n bool frontFace = rayDotNormal > 0;\
2325 \n // Move the start position further from the eye if needed:\
2326 \n if (frontFace && // Observing from the clipped side (plane's front face)\
2327 \n startDistance > 0.0) // Ray-entry lies on the clipped side.\
2329 \n // Scale the point-plane distance to the ray direction and update the\
2331 \n float rayScaledDist = startDistance / rayDotNormal;\
2332 \n startPosObj = vec4(startPosObj.xyz + rayScaledDist * clip_rayDirObj, 1.0);\
2333 \n vec4 newStartPosTex = clip_objToTexMat * vec4(startPosObj.xyz, 1.0);\
2334 \n newStartPosTex /= newStartPosTex.w;\
2335 \n startPosTex = newStartPosTex.xyz;\
2336 \n startPosTex += g_rayJitter;\
2339 \n // Move the end position closer to the eye if needed:\
2340 \n if (!frontFace && // Observing from the unclipped side (plane's back face)\
2341 \n stopDistance > 0.0) // Ray-entry lies on the unclipped side.\
2343 \n // Scale the point-plane distance to the ray direction and update the\
2344 \n // termination point.\
2345 \n float rayScaledDist = stopDistance / rayDotNormal;\
2346 \n stopPosObj = vec4(stopPosObj.xyz + rayScaledDist * clip_rayDirObj, 1.0);\
2347 \n vec4 newStopPosTex = clip_objToTexMat * vec4(stopPosObj.xyz, 1.0);\
2348 \n newStopPosTex /= newStopPosTex.w;\
2349 \n stopPosTex = newStopPosTex.xyz;\
2353 \n if (any(greaterThan(startPosTex, in_texMax[0])) ||\
2354 \n any(lessThan(startPosTex, in_texMin[0])))\
2378 \n vec4 tempClip = in_volumeMatrix[0] * vec4(rayDir, 0.0);\
2379 \n if (tempClip.w != 0.0)\
2381 \n tempClip = tempClip/tempClip.w;\
2382 \n tempClip.w = 1.0;\
2384 \n clip_rayDirObj = normalize(tempClip.xyz);");
2389 clip_rayDirObj = normalize(in_projectionDirection);");
2393 \n clip_numPlanes = int(in_clippingPlanes[0]);\
2394 \n clip_texToObjMat = in_volumeMatrix[0] * in_textureDatasetMatrix[0];\
2395 \n clip_objToTexMat = in_inverseTextureDatasetMatrix[0] * in_inverseVolumeMatrix[0];");
2412 \n // Adjust the ray segment to account for clipping range:\
2413 \n if (!AdjustSampleRangeForClipping(g_dataPos.xyz, g_terminatePos.xyz))\
2415 \n return vec4(0.);\
2418 \n // Update the number of ray marching steps to account for the clipped entry point (\
2419 \n // this is necessary in case the ray hits geometry after marching behind the plane,\
2420 \n // given that the number of steps was assumed to be from the not-clipped entry).\
2421 \n g_terminatePointMax = length(g_terminatePos.xyz - g_dataPos.xyz) /\
2422 \n length(g_dirStep);\
2441 int vtkNotUsed(maskType))
2443 if (!mask || !maskInput)
2461 if (!mask || !maskInput ||
2469 \nvec4 maskValue = texture3D(in_mask, g_dataPos);\
2470 \nif(maskValue.r <= 0.0)\
2486 if (!mask || !maskInput ||
2494 \nuniform float in_maskBlendFactor;\
2495 \nuniform sampler2D in_mask1;\
2496 \nuniform sampler2D in_mask2;"
2510 if (!mask || !maskInput ||
2518 \nvec4 scalar = texture3D(in_volume[0], g_dataPos);");
2521 if (noOfComponents == 1)
2524 \n scalar.r = scalar.r * in_volume_scale[0].r + in_volume_bias[0].r;\
2525 \n scalar = vec4(scalar.r);"
2532 \n scalar = scalar * in_volume_scale[0] + in_volume_bias[0];"
2537 \nif (in_maskBlendFactor == 0.0)\
2539 \n g_srcColor = computeColor(scalar, computeOpacity(scalar));\
2543 \n float opacity = computeOpacity(scalar);\
2544 \n // Get the mask value at this same location\
2545 \n vec4 maskValue = texture3D(in_mask, g_dataPos);\
2546 \n if(maskValue.r == 0.0)\
2548 \n g_srcColor = computeColor(scalar, opacity);\
2552 \n if (maskValue.r == 1.0/255.0)\
2554 \n g_srcColor = texture2D(in_mask1, vec2(scalar.w,0.0));\
2558 \n // maskValue.r == 2.0/255.0\
2559 \n g_srcColor = texture2D(in_mask2, vec2(scalar.w,0.0));\
2561 \n g_srcColor.a = 1.0;\
2562 \n if(in_maskBlendFactor < 1.0)\
2564 \n g_srcColor = (1.0 - in_maskBlendFactor) *\
2565 \n computeColor(scalar, opacity) +\
2566 \n in_maskBlendFactor * g_srcColor;\
2569 \n g_srcColor.a = opacity;\
2581 "uniform bool in_clampDepthToBackface;\n"
2582 "vec3 l_opaqueFragPos;\n"
2583 "bool l_updateDepth;\n");
2592 \n l_opaqueFragPos = vec3(-1.0);\
2593 \n if(in_clampDepthToBackface)\
2595 \n l_opaqueFragPos = g_dataPos;\
2597 \n l_updateDepth = true;"
2607 \n if(!g_skip && g_srcColor.a > 0.0 && l_updateDepth)\
2609 \n l_opaqueFragPos = g_dataPos;\
2610 \n l_updateDepth = false;\
2621 \n if (l_opaqueFragPos == vec3(-1.0))\
2623 \n gl_FragData[1] = vec4(1.0);\
2627 \n vec4 depthValue = in_projectionMatrix * in_modelViewMatrix *\
2628 \n in_volumeMatrix[0] * in_textureDatasetMatrix[0] *\
2629 \n vec4(l_opaqueFragPos, 1.0);\
2630 \n depthValue /= depthValue.w;\
2631 \n gl_FragData[1] = vec4(vec3(0.5 * (gl_DepthRange.far -\
2632 \n gl_DepthRange.near) * depthValue.z + 0.5 *\
2633 \n (gl_DepthRange.far + gl_DepthRange.near)), 1.0);\
2644 \n vec3 l_isoPos = g_dataPos;"
2654 \n if(!g_skip && g_srcColor.a > 0.0)\
2656 \n l_isoPos = g_dataPos;\
2657 \n g_exit = true; g_skip = true;\
2668 \n vec4 depthValue = in_projectionMatrix * in_modelViewMatrix *\
2669 \n in_volumeMatrix[0] * in_textureDatasetMatrix[0] *\
2670 \n vec4(l_isoPos, 1.0);\
2671 \n gl_FragData[0] = vec4(l_isoPos, 1.0);\
2672 \n gl_FragData[1] = vec4(vec3((depthValue.z/depthValue.w) * 0.5 + 0.5),\
2683 \n initializeRayCast();\
2684 \n castRay(-1.0, -1.0);\
2685 \n finalizeRayCast();");
2690 const size_t usedNames)
2693 for (
size_t i = 0; i < usedNames; i++)
2695 shader +=
"uniform sampler2D " + varNames[i] +
";\n";
2702 const size_t usedNames)
2705 for (
size_t i = 0; i < usedNames; i++)
2707 std::stringstream ss; ss << i;
2708 shader +=
" gl_FragData[" + ss.str() +
"] = texture2D("+ varNames[i] +
2711 shader +=
" return;\n";
2716 #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()
represents a volume (data & properties) in a rendered scene
std::string PickingActorPassExit(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(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)
std::string TerminationInit(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol))
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 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()
std::string CroppingDeclarationVertex(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol))
std::string TerminationDeclarationFragment(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol))
virtual int GetTransferFunctionMode()
std::string ComputeGradientDeclaration(vtkOpenGLGPUVolumeRayCastMapper::VolumeInputMap &inputs)
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))
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 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 BaseImplementation(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol))
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))
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)
std::string ClippingImplementation(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *mapper, vtkVolume *vtkNotUsed(vol))
virtual vtkTypeBool GetUseDepthPass()
represents the common properties for rendering a volume.
std::string ShadingDeclarationVertex(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol))