VTK
vtkVolumeShaderComposer.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkVolumeShaderComposer.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
15 
16 #ifndef vtkVolumeShaderComposer_h
17 #define vtkVolumeShaderComposer_h
18 
19 #include "vtkVolumeMask.h"
20 
21 #include <vtkCamera.h>
22 #include <vtkRenderer.h>
23 #include <vtkVolume.h>
24 #include <vtkVolumeMapper.h>
25 #include <vtkVolumeProperty.h>
26 
27 #include <map>
28 #include <sstream>
29 #include <string>
30 
31 namespace vtkvolume
32 {
33  //--------------------------------------------------------------------------
35  const std::string replace, bool all)
36  {
37  if (replace.empty())
38  {
39  return source;
40  }
41 
42  std::string::size_type pos = 0;
43  bool first = true;
44  while ((pos = source.find(search, 0)) != std::string::npos)
45  {
46  source.replace(pos, search.length(), replace);
47  pos += search.length();
48  if (first)
49  {
50  first = false;
51  if (!all)
52  {
53  return source;
54  }
55  }
56  }
57  return source;
58  }
59 
60  //--------------------------------------------------------------------------
62  vtkVolumeMapper* vtkNotUsed(mapper),
63  vtkVolume* vtkNotUsed(vol))
64  {
65  return std::string("\
66  \n vec4 pos = in_projectionMatrix * in_modelViewMatrix *\
67  \n in_volumeMatrix * vec4(in_vertexPos.xyz, 1.0);\
68  \n gl_Position = pos;"
69  );
70  }
71 
72  //--------------------------------------------------------------------------
74  vtkVolumeMapper* vtkNotUsed(mapper),
75  vtkVolume* vtkNotUsed(vol))
76  {
77  return std::string(
78  "\n // For point dataset, we offset the texture coordinate\
79  \n // to account for OpenGL treating voxel at the center of the cell.\
80  \n vec3 spacingSign = vec3(1.0);\
81  \n if (in_cellSpacing.x < 0.0)\
82  \n {\
83  \n spacingSign.x = -1.0;\
84  \n }\
85  \n if (in_cellSpacing.y < 0.0)\
86  \n {\
87  \n spacingSign.y = -1.0;\
88  \n }\
89  \n if (in_cellSpacing.z < 0.0)\
90  \n {\
91  \n spacingSign.z = -1.0;\
92  \n }\
93  \n vec3 uvx = spacingSign * (in_vertexPos - in_volumeExtentsMin) /\
94  \n (in_volumeExtentsMax - in_volumeExtentsMin);\
95  \n if (in_cellFlag)\
96  \n {\
97  \n ip_textureCoords = uvx;\
98  \n }\
99  \n else\
100  \n {\
101  \n vec3 delta = in_textureExtentsMax - in_textureExtentsMin;\
102  \n ip_textureCoords = (uvx * (delta - vec3(1.0)) + vec3(0.5)) / delta;\
103  \n }"
104  );
105  }
106 
107  //--------------------------------------------------------------------------
109  vtkVolumeMapper* vtkNotUsed(mapper),
110  vtkVolume* vtkNotUsed(vol))
111  {
112  return std::string("\
113  \n uniform bool in_cellFlag;\
114  \n uniform vec3 in_cellSpacing;\
115  \n uniform mat4 in_modelViewMatrix;\
116  \n uniform mat4 in_projectionMatrix;\
117  \n uniform mat4 in_volumeMatrix;\
118  \n\
119  \n uniform vec3 in_volumeExtentsMin;\
120  \n uniform vec3 in_volumeExtentsMax;\
121  \n\
122  \n uniform vec3 in_textureExtentsMax;\
123  \n uniform vec3 in_textureExtentsMin;"
124  );
125  }
126 
127  //--------------------------------------------------------------------------
129  vtkVolumeMapper* vtkNotUsed(mapper),
130  vtkVolume* vtkNotUsed(vol),
131  int vtkNotUsed(numberOfLights),
132  int lightingComplexity,
133  int noOfComponents,
134  int independentComponents)
135  {
136  std::string shaderStr = std::string("\
137  \n// Volume dataset\
138  \nuniform sampler3D in_volume;\
139  \nuniform int in_noOfComponents;\
140  \nuniform int in_independentComponents;\
141  \n\
142  \nuniform sampler2D in_noiseSampler;\
143  \n#ifndef GL_ES\
144  \nuniform sampler2D in_depthSampler;\
145  \n#endif\
146  \n\
147  \n// Camera position\
148  \nuniform vec3 in_cameraPos;\
149  \n\
150  \n// view and model matrices\
151  \nuniform mat4 in_volumeMatrix;\
152  \nuniform mat4 in_inverseVolumeMatrix;\
153  \nuniform mat4 in_projectionMatrix;\
154  \nuniform mat4 in_inverseProjectionMatrix;\
155  \nuniform mat4 in_modelViewMatrix;\
156  \nuniform mat4 in_inverseModelViewMatrix;\
157  \nuniform mat4 in_textureDatasetMatrix;\
158  \nuniform mat4 in_inverseTextureDatasetMatrix;\
159  \nuniform mat4 in_texureToEyeIt;\
160  \n\
161  \n// Ray step size\
162  \nuniform vec3 in_cellStep;\
163  \nuniform vec2 in_scalarsRange;\
164  \nuniform vec3 in_cellSpacing;\
165  \n\
166  \n// Sample distance\
167  \nuniform float in_sampleDistance;\
168  \n\
169  \n// Scales\
170  \nuniform vec3 in_cellScale;\
171  \nuniform vec2 in_windowLowerLeftCorner;\
172  \nuniform vec2 in_inverseOriginalWindowSize;\
173  \nuniform vec2 in_inverseWindowSize;\
174  \nuniform vec3 in_textureExtentsMax;\
175  \nuniform vec3 in_textureExtentsMin;\
176  \n\
177  \n// Material and lighting\
178  \nuniform vec3 in_diffuse;\
179  \nuniform vec3 in_ambient;\
180  \nuniform vec3 in_specular;\
181  \nuniform float in_shininess;\
182  \nuniform bool in_cellFlag;\
183  ");
184 
185  if (lightingComplexity > 0)
186  {
187  shaderStr += std::string("\
188  \nuniform bool in_twoSidedLighting;\
189  \nvec3 g_xvec;\
190  \nvec3 g_yvec;\
191  \nvec3 g_zvec;\
192  \nvec3 g_cellSpacing;\
193  \nfloat g_avgSpacing;"
194  );
195  }
196 
197  if (lightingComplexity == 3)
198  {
199  shaderStr += std::string("\
200  \nvec4 g_fragWorldPos;\
201  \nuniform int in_numberOfLights;\
202  \nuniform vec3 in_lightAmbientColor[6];\
203  \nuniform vec3 in_lightDiffuseColor[6];\
204  \nuniform vec3 in_lightSpecularColor[6];\
205  \nuniform vec3 in_lightDirection[6];\
206  \nuniform vec3 in_lightPosition[6];\
207  \nuniform vec3 in_lightAttenuation[6];\
208  \nuniform float in_lightConeAngle[6];\
209  \nuniform float in_lightExponent[6];\
210  \nuniform int in_lightPositional[6];\
211  ");
212  }
213  else if (lightingComplexity == 2)
214  {
215  shaderStr += std::string("\
216  \nvec4 g_fragWorldPos;\
217  \nuniform int in_numberOfLights;\
218  \nuniform vec3 in_lightAmbientColor[6];\
219  \nuniform vec3 in_lightDiffuseColor[6];\
220  \nuniform vec3 in_lightSpecularColor[6];\
221  \nuniform vec3 in_lightDirection[6];\
222  ");
223  }
224  else
225  {
226  shaderStr += std::string("\
227  \nuniform vec3 in_lightAmbientColor[1];\
228  \nuniform vec3 in_lightDiffuseColor[1];\
229  \nuniform vec3 in_lightSpecularColor[1];\
230  \nvec4 g_lightPosObj;\
231  \nvec3 g_ldir;\
232  \nvec3 g_vdir;\
233  \nvec3 g_h;\
234  \nvec3 g_aspect;"
235  );
236  }
237 
238  if (noOfComponents > 1 && independentComponents)
239  {
240  shaderStr += std::string("\
241  \nuniform vec4 in_componentWeight;");
242  }
243 
244  return shaderStr;
245  }
246 
247  //--------------------------------------------------------------------------
248  std::string BaseInit(vtkRenderer* vtkNotUsed(ren),
249  vtkVolumeMapper* vtkNotUsed(mapper),
250  vtkVolume* vol,
251  int lightingComplexity)
252  {
253  std::string shaderStr = std::string("\
254  \n // Get the 3D texture coordinates for lookup into the in_volume dataset\
255  \n g_dataPos = ip_textureCoords.xyz;\
256  \n\
257  \n // Eye position in object space\
258  \n g_eyePosObj = (in_inverseVolumeMatrix * vec4(in_cameraPos, 1.0));\
259  \n if (g_eyePosObj.w != 0.0)\
260  \n {\
261  \n g_eyePosObj.x /= g_eyePosObj.w;\
262  \n g_eyePosObj.y /= g_eyePosObj.w;\
263  \n g_eyePosObj.z /= g_eyePosObj.w;\
264  \n g_eyePosObj.w = 1.0;\
265  \n }\
266  \n\
267  \n // Getting the ray marching direction (in object space);\
268  \n vec3 rayDir = computeRayDirection();\
269  \n\
270  \n // Multiply the raymarching direction with the step size to get the\
271  \n // sub-step size we need to take at each raymarching step\
272  \n g_dirStep = (in_inverseTextureDatasetMatrix *\
273  \n vec4(rayDir, 0.0)).xyz * in_sampleDistance;\
274  \n\
275  \n g_dataPos += g_dirStep * (texture2D(in_noiseSampler, g_dataPos.xy).x);\
276  \n\
277  \n // Flag to deternmine if voxel should be considered for the rendering\
278  \n bool l_skip = false;");
279 
280  if (vol->GetProperty()->GetShade() && lightingComplexity == 1)
281  {
282  shaderStr += std::string("\
283  \n // Light position in object space\
284  \n g_lightPosObj = (in_inverseVolumeMatrix *\
285  \n vec4(in_cameraPos, 1.0));\
286  \n if (g_lightPosObj.w != 0.0)\
287  \n {\
288  \n g_lightPosObj.x /= g_lightPosObj.w;\
289  \n g_lightPosObj.y /= g_lightPosObj.w;\
290  \n g_lightPosObj.z /= g_lightPosObj.w;\
291  \n g_lightPosObj.w = 1.0;\
292  \n }\
293  \n g_ldir = normalize(g_lightPosObj.xyz - ip_vertexPos);\
294  \n g_vdir = normalize(g_eyePosObj.xyz - ip_vertexPos);\
295  \n g_h = normalize(g_ldir + g_vdir);\
296  \n g_cellSpacing = vec3(in_cellSpacing[0],\
297  \n in_cellSpacing[1],\
298  \n in_cellSpacing[2]);\
299  \n g_avgSpacing = (g_cellSpacing[0] +\
300  \n g_cellSpacing[1] +\
301  \n g_cellSpacing[2])/3.0;\
302  \n // Adjust the aspect\
303  \n g_aspect.x = g_cellSpacing[0] * 2.0 / g_avgSpacing;\
304  \n g_aspect.y = g_cellSpacing[1] * 2.0 / g_avgSpacing;\
305  \n g_aspect.z = g_cellSpacing[2] * 2.0 / g_avgSpacing;"
306  );
307  }
308  if (vol->GetProperty()->GetShade())
309  {
310  shaderStr += std::string("\
311  \n g_xvec = vec3(in_cellStep[0], 0.0, 0.0);\
312  \n g_yvec = vec3(0.0, in_cellStep[1], 0.0);\
313  \n g_zvec = vec3(0.0, 0.0, in_cellStep[2]);"
314  );
315  }
316  return shaderStr;
317  }
318 
319  //--------------------------------------------------------------------------
321  vtkVolumeMapper* vtkNotUsed(mapper),
322  vtkVolume* vtkNotUsed(vol))
323  {
324  return std::string("\
325  \n l_skip = false;"
326  );
327  }
328 
329  //--------------------------------------------------------------------------
330  std::string BaseExit(vtkRenderer* vtkNotUsed(ren),
331  vtkVolumeMapper* vtkNotUsed(mapper),
332  vtkVolume* vtkNotUsed(vol))
333  {
334  return std::string();
335  }
336 
337  //--------------------------------------------------------------------------
339  vtkVolumeMapper* vtkNotUsed(mapper),
340  vtkVolume* vol,
341  int noOfComponents,
342  int independentComponents,
343  std::map<int, std::string> gradientTableMap)
344  {
345  std::string shaderStr;
346  if (noOfComponents == 1 && vol->GetProperty()->HasGradientOpacity())
347  {
348  shaderStr += std::string("\
349  \nuniform sampler2D in_gradientTransferFunc;\
350  \nfloat computeGradientOpacity(vec4 grad)\
351  \n {\
352  \n return texture2D(in_gradientTransferFunc, vec2(grad.w,0.0)).r;\
353  \n }"
354  );
355  }
356  else if (noOfComponents > 1 && independentComponents &&
358  {
359  for (int i = 0; i < noOfComponents; ++i)
360  {
361  shaderStr += std::string("\n uniform sampler2D ") +
362  gradientTableMap[i] + std::string(";");
363  }
364 
365  shaderStr += std::string("\
366  \nfloat computeGradientOpacity(vec4 grad, int component)\
367  \n {\
368  \n if (component == 0)\
369  \n {\
370  \n return texture2D(in_gradientTransferFunc, vec2(grad.w,0.0)).r;\
371  \n }\
372  \n if (component == 1)\
373  \n {\
374  \n return texture2D(in_gradientTransferFunc1, vec2(grad.w,0.0)).r;\
375  \n }\
376  \n if (component == 2)\
377  \n {\
378  \n return texture2D(in_gradientTransferFunc2, vec2(grad.w,0.0)).r;\
379  \n }\
380  \n if (component == 3)\
381  \n {\
382  \n return texture2D(in_gradientTransferFunc3, vec2(grad.w,0.0)).r;\
383  \n }\
384  \n }"
385  );
386  }
387 
388  if (vol->GetProperty()->GetShade() &&
389  !vol->GetProperty()->HasGradientOpacity())
390  {
391  shaderStr += std::string("\
392  \nvec4 computeGradient()\
393  \n {\
394  \n vec3 g1;\
395  \n vec3 g2;\
396  \n g1.x = texture3D(in_volume, vec3(g_dataPos + g_xvec)).x;\
397  \n g1.y = texture3D(in_volume, vec3(g_dataPos + g_yvec)).x;\
398  \n g1.z = texture3D(in_volume, vec3(g_dataPos + g_zvec)).x;\
399  \n g2.x = texture3D(in_volume, vec3(g_dataPos - g_xvec)).x;\
400  \n g2.y = texture3D(in_volume, vec3(g_dataPos - g_yvec)).x;\
401  \n g2.z = texture3D(in_volume, vec3(g_dataPos - g_zvec)).x;\
402  \n g1 = g1 * in_volume_scale.r + in_volume_bias.r;\
403  \n g2 = g2 * in_volume_scale.r + in_volume_bias.r;\
404  \n return vec4((g1 - g2), -1.0);\
405  \n }"
406  );
407  }
408  else if (vol->GetProperty()->GetShade() &&
410  {
411  shaderStr += std::string("\
412  \nvec4 computeGradient()\
413  \n {\
414  \n vec3 g1;\
415  \n vec4 g2;\
416  \n g1.x = texture3D(in_volume, vec3(g_dataPos + g_xvec)).x;\
417  \n g1.y = texture3D(in_volume, vec3(g_dataPos + g_yvec)).x;\
418  \n g1.z = texture3D(in_volume, vec3(g_dataPos + g_zvec)).x;\
419  \n g2.x = texture3D(in_volume, vec3(g_dataPos - g_xvec)).x;\
420  \n g2.y = texture3D(in_volume, vec3(g_dataPos - g_yvec)).x;\
421  \n g2.z = texture3D(in_volume, vec3(g_dataPos - g_zvec)).x;\
422  \n g1 = g1*in_volume_scale.r + in_volume_bias.r;\
423  \n g2 = g2*in_volume_scale.r + in_volume_bias.r;\
424  \n g1.x = in_scalarsRange[0] + (\
425  \n in_scalarsRange[1] - in_scalarsRange[0]) * g1.x;\
426  \n g1.y = in_scalarsRange[0] + (\
427  \n in_scalarsRange[1] - in_scalarsRange[0]) * g1.y;\
428  \n g1.z = in_scalarsRange[0] + (\
429  \n in_scalarsRange[1] - in_scalarsRange[0]) * g1.z;\
430  \n g2.x = in_scalarsRange[0] + (\
431  \n in_scalarsRange[1] - in_scalarsRange[0]) * g2.x;\
432  \n g2.y = in_scalarsRange[0] + (\
433  \n in_scalarsRange[1] - in_scalarsRange[0]) * g2.y;\
434  \n g2.z = in_scalarsRange[0] + (\
435  \n in_scalarsRange[1] - in_scalarsRange[0]) * g2.z;\
436  \n g2.xyz = g1 - g2.xyz;\
437  \n g2.x /= g_aspect.x;\
438  \n g2.y /= g_aspect.y;\
439  \n g2.z /= g_aspect.z;\
440  \n float grad_mag = sqrt(g2.x * g2.x +\
441  \n g2.y * g2.y +\
442  \n g2.z * g2.z);\
443  \n if (grad_mag > 0.0)\
444  \n {\
445  \n g2.x /= grad_mag;\
446  \n g2.y /= grad_mag;\
447  \n g2.z /= grad_mag;\
448  \n }\
449  \n else\
450  \n {\
451  \n g2.xyz = vec3(0.0, 0.0, 0.0);\
452  \n }\
453  \n grad_mag = grad_mag * 1.0 / (0.25 * (in_scalarsRange[1] -\
454  \n (in_scalarsRange[0])));\
455  \n grad_mag = clamp(grad_mag, 0.0, 1.0);\
456  \n g2.w = grad_mag;\
457  \n return g2;\
458  \n }"
459  );
460  }
461  else
462  {
463  shaderStr += std::string("\
464  \nvec4 computeGradient()\
465  \n {\
466  \n return vec4(0.0);\
467  \n }");
468  }
469 
470  return shaderStr;
471  }
472 
473  //--------------------------------------------------------------------------
475  vtkVolumeMapper* vtkNotUsed(mapper),
476  vtkVolume* vol,
477  int noOfComponents,
478  int independentComponents,
479  int vtkNotUsed(numberOfLights),
480  int lightingComplexity)
481  {
482  vtkVolumeProperty* volProperty = vol->GetProperty();
483  std::string shaderStr = std::string("\
484  \nvec4 computeLighting(vec4 color)\
485  \n {\
486  \n vec4 finalColor = vec4(0.0);"
487  );
488 
489  if (volProperty->GetShade() || volProperty->HasGradientOpacity())
490  {
491  shaderStr += std::string("\
492  \n // Compute gradient function only once\
493  \n vec4 gradient = computeGradient();"
494  );
495  }
496 
497  if (volProperty->GetShade())
498  {
499  if (lightingComplexity == 1)
500  {
501  shaderStr += std::string("\
502  \n vec3 diffuse = vec3(0.0);\
503  \n vec3 specular = vec3(0.0);\
504  \n vec3 normal = gradient.xyz / in_cellSpacing;\
505  \n float normalLength = length(normal);\
506  \n if (normalLength > 0.0)\
507  \n {\
508  \n normal = normalize(normal);\
509  \n }\
510  \n else\
511  \n {\
512  \n normal = vec3(0.0, 0.0, 0.0);\
513  \n }\
514  \n float nDotL = dot(normal, g_ldir);\
515  \n float nDotH = dot(normal, g_h);\
516  \n if (nDotL < 0.0 && in_twoSidedLighting)\
517  \n {\
518  \n nDotL = -nDotL;\
519  \n }\
520  \n if (nDotH < 0.0 && in_twoSidedLighting)\
521  \n {\
522  \n nDotH = -nDotH;\
523  \n }\
524  \n if (nDotL > 0.0)\
525  \n {\
526  \n diffuse = nDotL * in_diffuse * in_lightDiffuseColor[0]\
527  \n * color.rgb;\
528  \n }\
529  \n specular = pow(nDotH, in_shininess) * in_specular *\
530  \n in_lightSpecularColor[0];\
531  \n // For the headlight, ignore the light's ambient color\
532  \n // for now as it is causing the old mapper tests to fail\
533  \n finalColor.xyz = in_ambient * color.rgb + diffuse + specular;"
534  );
535  }
536  else if (lightingComplexity == 2)
537  {
538  shaderStr += std::string("\
539  \n g_fragWorldPos = in_modelViewMatrix * in_volumeMatrix *\
540  \n in_textureDatasetMatrix * vec4(-g_dataPos, 1.0);\
541  \n if (g_fragWorldPos.w != 0.0)\
542  \n {\
543  \n g_fragWorldPos /= g_fragWorldPos.w;\
544  \n }\
545  \n vec3 vdir = normalize(g_fragWorldPos.xyz);\
546  \n vec3 normal = gradient.xyz;\
547  \n vec3 ambient = vec3(0.0);\
548  \n vec3 diffuse = vec3(0.0);\
549  \n vec3 specular = vec3(0.0);\
550  \n float normalLength = length(normal);\
551  \n if (normalLength > 0.0)\
552  \n {\
553  \n normal = normalize((in_texureToEyeIt * vec4(normal, 0.0)).xyz);\
554  \n }\
555  \n else\
556  \n {\
557  \n normal = vec3(0.0, 0.0, 0.0);\
558  \n }\
559  \n for (int lightNum = 0; lightNum < in_numberOfLights; lightNum++)\
560  \n {\
561  \n vec3 ldir = in_lightDirection[lightNum].xyz;\
562  \n vec3 h = normalize(ldir + vdir);\
563  \n float nDotH = dot(normal, h);\
564  \n if (nDotH < 0.0 && in_twoSidedLighting)\
565  \n {\
566  \n nDotH = -nDotH;\
567  \n }\
568  \n float nDotL = dot(normal, ldir);\
569  \n if (nDotL < 0.0 && in_twoSidedLighting)\
570  \n {\
571  \n nDotL = -nDotL;\
572  \n }\
573  \n if (nDotL > 0.0)\
574  \n {\
575  \n diffuse += in_lightDiffuseColor[lightNum] * nDotL;\
576  \n }\
577  \n if (nDotH > 0.0)\
578  \n {\
579  \n specular = in_lightSpecularColor[lightNum] * pow(nDotH, in_shininess);\
580  \n }\
581  \n ambient += in_lightAmbientColor[lightNum];\
582  \n }\
583  \n finalColor.xyz = in_ambient * ambient +\
584  \n in_diffuse * diffuse * color.rgb +\
585  \n in_specular * specular;"
586  );
587  }
588  else if (lightingComplexity == 3)
589  {
590  shaderStr += std::string("\
591  \n g_fragWorldPos = in_modelViewMatrix * in_volumeMatrix *\
592  \n in_textureDatasetMatrix * vec4(g_dataPos, 1.0);\
593  \n if (g_fragWorldPos.w != 0.0)\
594  \n {\
595  \n g_fragWorldPos /= g_fragWorldPos.w;\
596  \n }\
597  \n vec3 viewDirection = normalize(-g_fragWorldPos.xyz);\
598  \n vec3 ambient = vec3(0,0,0);\
599  \n vec3 diffuse = vec3(0,0,0);\
600  \n vec3 specular = vec3(0,0,0);\
601  \n vec3 vertLightDirection;\
602  \n vec3 normal = normalize((in_texureToEyeIt * vec4(gradient.xyz, 0.0)).xyz);\
603  \n vec3 lightDir;\
604  \n for (int lightNum = 0; lightNum < in_numberOfLights; lightNum++)\
605  \n {\
606  \n float attenuation = 1.0;\
607  \n // directional\
608  \n lightDir = in_lightDirection[lightNum];\
609  \n if (in_lightPositional[lightNum] == 0)\
610  \n {\
611  \n vertLightDirection = lightDir;\
612  \n }\
613  \n else\
614  \n {\
615  \n vertLightDirection = (g_fragWorldPos.xyz - in_lightPosition[lightNum]);\
616  \n float distance = length(vertLightDirection);\
617  \n vertLightDirection = normalize(vertLightDirection);\
618  \n attenuation = 1.0 /\
619  \n (in_lightAttenuation[lightNum].x\
620  \n + in_lightAttenuation[lightNum].y * distance\
621  \n + in_lightAttenuation[lightNum].z * distance * distance);\
622  \n // per OpenGL standard cone angle is 90 or less for a spot light\
623  \n if (in_lightConeAngle[lightNum] <= 90.0)\
624  \n {\
625  \n float coneDot = dot(vertLightDirection, lightDir);\
626  \n // if inside the cone\
627  \n if (coneDot >= cos(radians(in_lightConeAngle[lightNum])))\
628  \n {\
629  \n attenuation = attenuation * pow(coneDot, in_lightExponent[lightNum]);\
630  \n }\
631  \n else\
632  \n {\
633  \n attenuation = 0.0;\
634  \n }\
635  \n }\
636  \n }\
637  \n // diffuse and specular lighting\
638  \n float nDotL = dot(normal, vertLightDirection);\
639  \n if (nDotL < 0.0 && in_twoSidedLighting)\
640  \n {\
641  \n nDotL = -nDotL;\
642  \n }\
643  \n if (nDotL > 0.0)\
644  \n {\
645  \n float df = max(0.0, attenuation * nDotL);\
646  \n diffuse += (df * in_lightDiffuseColor[lightNum]);\
647  \n }\
648  \n vec3 h = normalize(vertLightDirection + viewDirection);\
649  \n float nDotH = dot(normal, h);\
650  \n if (nDotH < 0.0 && in_twoSidedLighting)\
651  \n {\
652  \n nDotH = -nDotH;\
653  \n }\
654  \n if (nDotH > 0.0)\
655  \n {\
656  \n float sf = attenuation * pow(nDotH, in_shininess);\
657  \n specular += (sf * in_lightSpecularColor[lightNum]);\
658  \n }\
659  \n ambient += in_lightAmbientColor[lightNum];\
660  \n }\
661  \n finalColor.xyz = in_ambient * ambient + in_diffuse *\
662  \n diffuse * color.rgb + in_specular * specular;\
663  ");
664  }
665  }
666  else
667  {
668  shaderStr += std::string(
669  "\n finalColor = vec4(color.rgb, 0.0);"
670  );
671  }
672 
673  if (noOfComponents == 1 && volProperty->HasGradientOpacity())
674  {
675  shaderStr += std::string("\
676  \n if (gradient.w >= 0.0)\
677  \n {\
678  \n color.a = color.a *\
679  \n computeGradientOpacity(gradient);\
680  \n }"
681  );
682  }
683  else if (noOfComponents > 1 && independentComponents &&
684  volProperty->HasGradientOpacity())
685  {
686  shaderStr += std::string("\
687  \n if (gradient.w >= 0.0)\
688  \n {\
689  \n for (int i = 0; i < in_noOfComponents; ++i)\
690  \n {\
691  \n color.a = color.a *\
692  \n computeGradientOpacity(gradient, i) * in_componentWeight[i];\
693  \n }"
694  );
695  }
696 
697  shaderStr += std::string("\
698  \n finalColor.a = color.a;\
699  \n return finalColor;\
700  \n }"
701  );
702 
703  return shaderStr;
704  }
705 
706  //--------------------------------------------------------------------------
708  vtkVolumeMapper* vtkNotUsed(mapper),
709  vtkVolume* vtkNotUsed(vol),
710  int vtkNotUsed(noOfComponents))
711  {
712  if (!ren->GetActiveCamera()->GetParallelProjection())
713  {
714  return std::string("\
715  \nvec3 computeRayDirection()\
716  \n {\
717  \n return normalize(ip_vertexPos.xyz - g_eyePosObj.xyz);\
718  \n }");
719  }
720  else
721  {
722  return std::string("\
723  \nuniform vec3 in_projectionDirection;\
724  \nvec3 computeRayDirection()\
725  \n {\
726  \n return normalize((in_inverseVolumeMatrix *\
727  \n vec4(in_projectionDirection, 0.0)).xyz);\
728  \n }");
729  }
730  }
731 
732  //--------------------------------------------------------------------------
734  vtkVolumeMapper* vtkNotUsed(mapper),
735  vtkVolume* vtkNotUsed(vol),
736  int noOfComponents,
737  int independentComponents,
738  std::map<int, std::string> colorTableMap)
739  {
740  if (noOfComponents == 1)
741  {
742  return std::string("\
743  \nuniform sampler2D in_colorTransferFunc;\
744  \nvec4 computeColor(vec4 scalar, float opacity)\
745  \n {\
746  \n return computeLighting(vec4(texture2D(in_colorTransferFunc,\
747  \n vec2(scalar.w, 0.0)).xyz, opacity));\
748  \n }");
749  }
750  else if (noOfComponents > 1 && independentComponents)
751  {
752  std::string shaderStr;
753  std::ostringstream toString;
754  for (int i = 0; i < noOfComponents; ++i)
755  {
756  shaderStr += std::string("\n uniform sampler2D ") +
757  colorTableMap[i] + std::string(";");
758  }
759 
760  shaderStr += std::string("\
761  \nvec4 computeColor(vec4 scalar, float opacity, int component)\
762  \n {");
763 
764  for (int i = 0; i < noOfComponents; ++i)
765  {
766  toString << i;
767  shaderStr += std::string("\
768  \n if (component == " + toString.str() + ")");
769 
770  shaderStr += std::string("\
771  \n {\
772  \n return computeLighting(vec4(texture2D(\
773  \n in_colorTransferFunc");
774  shaderStr += (i == 0 ? "" : toString.str());
775  shaderStr += std::string(", vec2(\
776  \n scalar[" + toString.str() + "],0.0)).xyz,\
777  \n opacity));\
778  \n }");
779 
780  // Reset
781  toString.str("");
782  toString.clear();
783  }
784 
785  shaderStr += std::string("\n }");
786  return shaderStr;
787  }
788  else if (noOfComponents == 2&& !independentComponents)
789  {
790  return std::string("\
791  \nuniform sampler2D in_colorTransferFunc;\
792  \nvec4 computeColor(vec4 scalar, float opacity)\
793  \n {\
794  \n return computeLighting(vec4(texture2D(in_colorTransferFunc,\
795  \n vec2(scalar.x, 0.0)).xyz,\
796  \n opacity));\
797  \n }");
798  }
799  else
800  {
801  return std::string("\
802  \nvec4 computeColor(vec4 scalar, float opacity)\
803  \n {\
804  \n return computeLighting(vec4(scalar.xyz, opacity));\
805  \n }");
806  }
807  }
808 
809  //--------------------------------------------------------------------------
811  vtkVolumeMapper* vtkNotUsed(mapper),
812  vtkVolume* vtkNotUsed(vol),
813  int noOfComponents,
814  int independentComponents,
815  std::map<int, std::string> opacityTableMap)
816  {
817  if (noOfComponents > 1 && independentComponents)
818  {
819  std::string shaderStr;
820  std::ostringstream toString;
821 
822  for (int i = 0; i < noOfComponents; ++i)
823  {
824  shaderStr += std::string("\n uniform sampler2D ") +
825  opacityTableMap[i] + std::string(";");
826 
827  }
828 
829  shaderStr += std::string("\
830  \nfloat computeOpacity(vec4 scalar, int component)\
831  \n {");
832 
833  for (int i = 0; i < noOfComponents; ++i)
834  {
835  toString << i;
836  shaderStr += std::string("\
837  \n if (component == " + toString.str() + ")");
838 
839  shaderStr += std::string("\
840  \n {\
841  \n return texture2D(in_opacityTransferFunc");
842  shaderStr += (i == 0 ? "" : toString.str());
843  shaderStr += std::string(",vec2(scalar[" + toString.str() + "],0)).r;\
844  \n }");
845 
846  // Reset
847  toString.str("");
848  toString.clear();
849  }
850 
851  shaderStr += std::string("\n }");
852  return shaderStr;
853  }
854  else if (noOfComponents == 2 && !independentComponents)
855  {
856  return std::string("\
857  \nuniform sampler2D in_opacityTransferFunc;\
858  \nfloat computeOpacity(vec4 scalar)\
859  \n {\
860  \n return texture2D(in_opacityTransferFunc, vec2(scalar.y, 0)).r;\
861  \n }");
862  }
863  else
864  {
865  return std::string("\
866  \nuniform sampler2D in_opacityTransferFunc;\
867  \nfloat computeOpacity(vec4 scalar)\
868  \n {\
869  \n return texture2D(in_opacityTransferFunc, vec2(scalar.w, 0)).r;\
870  \n }");
871  }
872  }
873 
874  //--------------------------------------------------------------------------
876  vtkVolumeMapper* vtkNotUsed(mapper),
877  vtkVolume* vtkNotUsed(vol))
878  {
879  return std::string();
880  }
881 
882  //--------------------------------------------------------------------------
884  vtkVolumeMapper* vtkNotUsed(mapper),
885  vtkVolume* vtkNotUsed(vol))
886  {
887  return std::string();
888  }
889 
890  //--------------------------------------------------------------------------
892  vtkVolumeMapper* mapper,
893  vtkVolume* vtkNotUsed(vol))
894  {
896  {
897  return std::string("\
898  \n // We get data between 0.0 - 1.0 range\
899  \n bool l_firstValue = true;\
900  \n vec4 l_maxValue = vec4(0.0);"
901  );
902  }
904  {
905  return std::string("\
906  \n //We get data between 0.0 - 1.0 range\
907  \n bool l_firstValue = true;\
908  \n vec4 l_minValue = vec4(1.0);"
909  );
910  }
911  else if (mapper->GetBlendMode() == vtkVolumeMapper::ADDITIVE_BLEND)
912  {
913  return std::string("\
914  \n //We get data between 0.0 - 1.0 range\
915  \n float l_sumValue = 0.0;"
916  );
917  }
918  else
919  {
920  return std::string();
921  }
922  }
923 
924  //--------------------------------------------------------------------------
926  vtkVolumeMapper* mapper,
927  vtkVolume* vtkNotUsed(vol),
928  vtkImageData* maskInput,
929  vtkVolumeMask* mask, int maskType,
930  int noOfComponents,
931  int independentComponents = 0)
932  {
933  std::string shaderStr = std::string("\
934  \n if (!l_skip)\
935  \n {\
936  \n vec4 scalar = texture3D(in_volume, g_dataPos);"
937  );
938 
939  // simulate old intensity textures
940  if (noOfComponents == 1)
941  {
942  shaderStr += std::string("\
943  \n scalar.r = scalar.r*in_volume_scale.r + in_volume_bias.r;\
944  \n scalar = vec4(scalar.r,scalar.r,scalar.r,scalar.r);"
945  );
946  }
947  else
948  {
949  // handle bias and scale
950  shaderStr += std::string("\
951  \n scalar = scalar*in_volume_scale + in_volume_bias;"
952  );
953  }
954 
956  {
957  if (noOfComponents > 1)
958  {
959  if (!independentComponents)
960  {
961  shaderStr += std::string("\
962  \n if (l_maxValue.w < scalar.w || l_firstValue)\
963  \n {\
964  \n l_maxValue = scalar;\
965  \n }\
966  \n\
967  \n if (l_firstValue)\
968  \n {\
969  \n l_firstValue = false;\
970  \n }"
971  );
972  }
973  else
974  {
975  shaderStr += std::string("\
976  \n for (int i = 0; i < in_noOfComponents; ++i)\
977  \n {\
978  \n if (l_maxValue[i] < scalar[i] || l_firstValue)\
979  \n {\
980  \n l_maxValue[i] = scalar[i];\
981  \n }\
982  \n }\
983  \n if (l_firstValue)\
984  \n {\
985  \n l_firstValue = false;\
986  \n }"
987  );
988  }
989  }
990  else
991  {
992  shaderStr += std::string("\
993  \n if (l_maxValue.w < scalar.x || l_firstValue)\
994  \n {\
995  \n l_maxValue.w = scalar.x;\
996  \n }\
997  \n\
998  \n if (l_firstValue)\
999  \n {\
1000  \n l_firstValue = false;\
1001  \n }"
1002  );
1003  }
1004  }
1006  {
1007  if (noOfComponents > 1)
1008  {
1009  if (!independentComponents)
1010  {
1011  shaderStr += std::string("\
1012  \n if (l_minValue.w > scalar.w || l_firstValue)\
1013  \n {\
1014  \n l_minValue = scalar;\
1015  \n }\
1016  \n\
1017  \n if (l_firstValue)\
1018  \n {\
1019  \n l_firstValue = false;\
1020  \n }"
1021  );
1022  }
1023  else
1024  {
1025  shaderStr += std::string("\
1026  \n for (int i = 0; i < in_noOfComponents; ++i)\
1027  \n {\
1028  \n if (l_minValue[i] < scalar[i] || l_firstValue)\
1029  \n {\
1030  \n l_minValue[i] = scalar[i];\
1031  \n }\
1032  \n }\
1033  \n if (l_firstValue)\
1034  \n {\
1035  \n l_firstValue = false;\
1036  \n }"
1037  );
1038  }
1039  }
1040  else
1041  {
1042  shaderStr += std::string("\
1043  \n if (l_minValue.w > scalar.x || l_firstValue)\
1044  \n {\
1045  \n l_minValue.w = scalar.x;\
1046  \n }\
1047  \n\
1048  \n if (l_firstValue)\
1049  \n {\
1050  \n l_firstValue = false;\
1051  \n }"
1052  );
1053  }
1054  }
1055  else if (mapper->GetBlendMode() == vtkVolumeMapper::ADDITIVE_BLEND)
1056  {
1057  if (noOfComponents > 1)
1058  {
1059  if (!independentComponents)
1060  {
1061  shaderStr += std::string("\
1062  \n float opacity = computeOpacity(scalar);\
1063  \n l_sumValue = l_sumValue + opacity * scalar.x;"
1064  );
1065  }
1066  else
1067  {
1068  shaderStr += std::string("\
1069  \n for (int i = 0; i < in_noOfComponents; ++i)\
1070  \n {\
1071  \n float opacity = computeOpacity(scalar, i);\
1072  \n l_sumValue[i] = l_sumValue[i] + opacity * scalar[i];\
1073  \n }"
1074  );
1075  }
1076  }
1077  else
1078  {
1079  shaderStr += std::string("\
1080  \n float opacity = computeOpacity(scalar);\
1081  \n l_sumValue = l_sumValue + opacity * scalar.x;"
1082  );
1083  }
1084  }
1085  else if (mapper->GetBlendMode() == vtkVolumeMapper::COMPOSITE_BLEND)
1086  {
1087  if (noOfComponents > 1 && independentComponents)
1088  {
1089  shaderStr += std::string("\
1090  \n vec4 color[4]; vec4 tmp = vec4(0.0);\
1091  \n float totalAlpha = 0.0;\
1092  \n for (int i = 0; i < in_noOfComponents; ++i)\
1093  \n {\
1094  ");
1095  if (!mask || !maskInput ||
1097  {
1098  shaderStr += std::string("\
1099  \n // Data fetching from the red channel of volume texture\
1100  \n color[i][3] = computeOpacity(scalar, i);\
1101  \n color[i] = computeColor(scalar, color[i][3], i);\
1102  \n totalAlpha += color[i][3] * in_componentWeight[i];\
1103  \n }\
1104  \n if (totalAlpha > 0.0)\
1105  \n {\
1106  \n for (int i = 0; i < in_noOfComponents; ++i)\
1107  \n {\
1108  \n tmp.x += color[i].x * color[i].w * in_componentWeight[i];\
1109  \n tmp.y += color[i].y * color[i].w * in_componentWeight[i];\
1110  \n tmp.z += color[i].z * color[i].w * in_componentWeight[i];\
1111  \n tmp.w += ((color[i].w * color[i].w)/totalAlpha);\
1112  \n }\
1113  \n }\
1114  \n g_fragColor = (1.0f - g_fragColor.a) * tmp + g_fragColor;"
1115  );
1116  }
1117  }
1118  else
1119  {
1120  if (!mask || !maskInput ||
1122  {
1123  shaderStr += std::string("\
1124  \n g_srcColor = vec4(0.0);\
1125  \n g_srcColor.a = computeOpacity(scalar);\
1126  \n if (g_srcColor.a > 0.0)\
1127  \n {\
1128  \n g_srcColor = computeColor(scalar, g_srcColor.a);"
1129  );
1130  }
1131 
1132  shaderStr += std::string("\
1133  \n // Opacity calculation using compositing:\
1134  \n // Here we use front to back compositing scheme whereby\
1135  \n // the current sample value is multiplied to the\
1136  \n // currently accumulated alpha and then this product\
1137  \n // is subtracted from the sample value to get the\
1138  \n // alpha from the previous steps. Next, this alpha is\
1139  \n // multiplied with the current sample colour\
1140  \n // and accumulated to the composited colour. The alpha\
1141  \n // value from the previous steps is then accumulated\
1142  \n // to the composited colour alpha.\
1143  \n g_srcColor.rgb *= g_srcColor.a;\
1144  \n g_fragColor = (1.0f - g_fragColor.a) * g_srcColor + g_fragColor;"
1145  );
1146 
1147  if (!mask || !maskInput ||
1149  {
1150  shaderStr += std::string("\
1151  \n }"
1152  );
1153  }
1154  }
1155  }
1156  else
1157  {
1158  shaderStr += std::string();
1159  }
1160 
1161  shaderStr += std::string("\
1162  \n }"
1163  );
1164  return shaderStr;
1165  }
1166 
1167  //--------------------------------------------------------------------------
1169  vtkVolumeMapper* mapper,
1170  vtkVolume* vtkNotUsed(vol),
1171  int noOfComponents,
1172  int independentComponents = 0)
1173  {
1175  {
1176  if (noOfComponents > 1 && independentComponents)
1177  {
1178  return std::string("\
1179  \n g_srcColor = vec4(0);\
1180  \n for (int i = 0; i < in_noOfComponents; ++i)\
1181  \n {\
1182  \n vec4 tmp = computeColor(l_maxValue, computeOpacity(l_maxValue, i), i);\
1183  \n g_srcColor[0] += tmp[0] * tmp[3] * in_componentWeight[i];\
1184  \n g_srcColor[1] += tmp[1] * tmp[3] * in_componentWeight[i];\
1185  \n g_srcColor[2] += tmp[2] * tmp[3] * in_componentWeight[i];\
1186  \n g_srcColor[3] += tmp[3] * in_componentWeight[i];\
1187  \n }\
1188  \n g_fragColor = g_srcColor;"
1189  );
1190  }
1191  else
1192  {
1193  return std::string("\
1194  \n g_srcColor = computeColor(l_maxValue,\
1195  computeOpacity(l_maxValue));\
1196  \n g_fragColor.rgb = g_srcColor.rgb * g_srcColor.a;\
1197  \n g_fragColor.a = g_srcColor.a;"
1198  );
1199  }
1200  }
1202  {
1203  if (noOfComponents > 1 && independentComponents)
1204  {
1205  return std::string("\
1206  \n g_srcColor = vec4(0);\
1207  \n for (int i = 0; i < in_noOfComponents; ++i)\
1208  \n {\
1209  \n vec4 tmp = computeColor(l_minValue, computeOpacity(l_minValue, i), i);\
1210  \n g_srcColor[0] += tmp[0] * tmp[3] * in_componentWeight[i];\
1211  \n g_srcColor[1] += tmp[1] * tmp[3] * in_componentWeight[i];\
1212  \n g_srcColor[2] += tmp[2] * tmp[3] * in_componentWeight[i];\
1213  \n g_srcColor[2] += tmp[3] * tmp[3] * in_componentWeight[i];\
1214  \n }\
1215  \n g_fragColor = g_srcColor;"
1216  );
1217  }
1218  else
1219  {
1220  return std::string("\
1221  \n g_srcColor = computeColor(l_minValue,\
1222  \n computeOpacity(l_minValue));\
1223  \n g_fragColor.rgb = g_srcColor.rgb * g_srcColor.a;\
1224  \n g_fragColor.a = g_srcColor.a;"
1225  );
1226  }
1227  }
1228  else if (mapper->GetBlendMode() == vtkVolumeMapper::ADDITIVE_BLEND)
1229  {
1230  if (noOfComponents > 1 && independentComponents)
1231  {
1232  return std::string("\
1233  \n l_sumValue = clamp(l_sumValue, 0.0, 1.0);\
1234  \n g_fragColor = vec4(l_sumValue);"
1235  );
1236  }
1237  else
1238  {
1239  return std::string("\
1240  \n l_sumValue = clamp(l_sumValue, 0.0, 1.0);\
1241  \n g_fragColor = vec4(vec3(l_sumValue), 1.0);"
1242  );
1243  }
1244  }
1245  else
1246  {
1247  return std::string();
1248  }
1249  }
1250 
1251  //--------------------------------------------------------------------------
1253  vtkVolumeMapper* vtkNotUsed(mapper),
1254  vtkVolume* vtkNotUsed(vol))
1255  {
1256  return std::string();
1257  }
1258 
1259  //--------------------------------------------------------------------------
1261  vtkVolumeMapper* vtkNotUsed(mapper),
1262  vtkVolume* vtkNotUsed(vol))
1263  {
1264  return std::string();
1265  }
1266 
1267  //--------------------------------------------------------------------------
1269  vtkVolumeMapper* vtkNotUsed(mapper),
1270  vtkVolume* vtkNotUsed(vol))
1271  {
1272  return std::string("\
1273  \n // Minimum texture access coordinate\
1274  \n vec3 l_tex_min = vec3(0.0);\
1275  \n vec3 l_tex_max = vec3(1.0);\
1276  \n if (!in_cellFlag)\
1277  \n {\
1278  \n vec3 delta = in_textureExtentsMax - in_textureExtentsMin;\
1279  \n l_tex_min = vec3(0.5) / delta;\
1280  \n l_tex_max = (delta - vec3(0.5)) / delta;\
1281  \n }\
1282  \n\
1283  \n // Flag to indicate if the raymarch loop should terminate \
1284  \n bool stop = false;\
1285  \n\
1286  \n // 2D Texture fragment coordinates [0,1] from fragment coordinates \
1287  \n // the frame buffer texture has the size of the plain buffer but \
1288  \n // we use a fraction of it. The texture coordinates is less than 1 if \
1289  \n // the reduction factor is less than 1. \
1290  \n // Device coordinates are between -1 and 1. We need texture \
1291  \n // coordinates between 0 and 1 the in_depthSampler buffer has the \
1292  \n // original size buffer. \
1293  \n vec2 fragTexCoord = (gl_FragCoord.xy - in_windowLowerLeftCorner) *\
1294  \n in_inverseWindowSize;\
1295  \n float l_terminatePointMax = 0.0;\
1296  \n\
1297  \n#ifdef GL_ES\
1298  \n vec4 l_depthValue = vec4(1.0,1.0,1.0,1.0);\
1299  \n#else\
1300  \n vec4 l_depthValue = texture2D(in_depthSampler, fragTexCoord);\
1301  \n#endif\
1302  \n // Depth test\
1303  \n if(gl_FragCoord.z >= l_depthValue.x)\
1304  \n {\
1305  \n discard;\
1306  \n }\
1307  \n\
1308  \n // color buffer or max scalar buffer have a reduced size.\
1309  \n fragTexCoord = (gl_FragCoord.xy - in_windowLowerLeftCorner) *\
1310  \n in_inverseOriginalWindowSize;\
1311  \n\
1312  \n // Compute max number of iterations it will take before we hit\
1313  \n // the termination point\
1314  \n\
1315  \n // Abscissa of the point on the depth buffer along the ray.\
1316  \n // point in texture coordinates\
1317  \n vec4 terminatePoint;\
1318  \n terminatePoint.x = (gl_FragCoord.x - in_windowLowerLeftCorner.x) * 2.0 *\
1319  \n in_inverseWindowSize.x - 1.0;\
1320  \n terminatePoint.y = (gl_FragCoord.y - in_windowLowerLeftCorner.y) * 2.0 *\
1321  \n in_inverseWindowSize.y - 1.0;\
1322  \n terminatePoint.z = (2.0 * l_depthValue.x - (gl_DepthRange.near +\
1323  \n gl_DepthRange.far)) / gl_DepthRange.diff;\
1324  \n terminatePoint.w = 1.0;\
1325  \n\
1326  \n // From normalized device coordinates to eye coordinates.\
1327  \n // in_projectionMatrix is inversed because of way VT\
1328  \n // From eye coordinates to texture coordinates\
1329  \n terminatePoint = in_inverseTextureDatasetMatrix *\
1330  \n in_inverseVolumeMatrix *\
1331  \n in_inverseModelViewMatrix *\
1332  \n in_inverseProjectionMatrix *\
1333  \n terminatePoint;\
1334  \n terminatePoint /= terminatePoint.w;\
1335  \n\
1336  \n l_terminatePointMax = length(terminatePoint.xyz - g_dataPos.xyz) /\
1337  \n length(g_dirStep);\
1338  \n float l_currentT = 0.0;");
1339  }
1340 
1341  //--------------------------------------------------------------------------
1343  vtkVolumeMapper* vtkNotUsed(mapper),
1344  vtkVolume* vtkNotUsed(vol))
1345  {
1346  return std::string("\
1347  \n // sign function performs component wise operation and returns -1\
1348  \n // if the difference is less than 0, 0 if equal to 0, and 1 if\
1349  \n // above 0. So if the ray is inside the volume, dot product will\
1350  \n // always be 3.\
1351  \n stop = dot(sign(g_dataPos - l_tex_min), sign(l_tex_max - g_dataPos))\
1352  \n < 3.0;\
1353  \n\
1354  \n // If the stopping condition is true we brek out of the ray marching\
1355  \n // loop\
1356  \n if (stop)\
1357  \n {\
1358  \n break;\
1359  \n }\
1360  \n // Early ray termination\
1361  \n // if the currently composited colour alpha is already fully saturated\
1362  \n // we terminated the loop or if we have hit an obstacle in the\
1363  \n // direction of they ray (using depth buffer) we terminate as well.\
1364  \n if((g_fragColor.a > (1.0 - 1.0/255.0)) || \
1365  \n l_currentT >= l_terminatePointMax)\
1366  \n {\
1367  \n break;\
1368  \n }\
1369  \n ++l_currentT;"
1370  );
1371  }
1372 
1373  //--------------------------------------------------------------------------
1375  vtkVolumeMapper* vtkNotUsed(mapper),
1376  vtkVolume* vtkNotUsed(vol))
1377  {
1378  return std::string();
1379  }
1380 
1381  //--------------------------------------------------------------------------
1383  vtkVolumeMapper* vtkNotUsed(mapper),
1384  vtkVolume* vtkNotUsed(vol))
1385  {
1386  return std::string();
1387  }
1388 
1389  //--------------------------------------------------------------------------
1391  vtkVolumeMapper* mapper,
1392  vtkVolume* vtkNotUsed(vol))
1393  {
1394  if (!mapper->GetCropping()) {
1395  return std::string();
1396  }
1397 
1398  return std::string("\
1399  \nuniform float cropping_planes[6];\
1400  \nuniform int cropping_flags [32];\
1401  \n// X: axis = 0, Y: axis = 1, Z: axis = 2\
1402  \n// cp Cropping plane bounds (minX, maxX, minY, maxY, minZ, maxZ)\
1403  \nint computeRegionCoord(float cp[6], vec3 pos, int axis)\
1404  \n {\
1405  \n int cpmin = axis * 2;\
1406  \n int cpmax = cpmin + 1;\
1407  \n\
1408  \n if (pos[axis] < cp[cpmin])\
1409  \n {\
1410  \n return 1;\
1411  \n }\
1412  \n else if (pos[axis] >= cp[cpmin] &&\
1413  \n pos[axis] < cp[cpmax])\
1414  \n {\
1415  \n return 2;\
1416  \n }\
1417  \n else if (pos[axis] >= cp[cpmax])\
1418  \n {\
1419  \n return 3;\
1420  \n }\
1421  \n return 0;\
1422  \n }\
1423  \n\
1424  \nint computeRegion(float cp[6], vec3 pos)\
1425  \n {\
1426  \n return (computeRegionCoord(cp, pos, 0) +\
1427  \n (computeRegionCoord(cp, pos, 1) - 1) * 3 +\
1428  \n (computeRegionCoord(cp, pos, 2) - 1) * 9);\
1429  \n }"
1430  );
1431  }
1432 
1433  //--------------------------------------------------------------------------
1435  vtkVolumeMapper* mapper,
1436  vtkVolume* vtkNotUsed(vol))
1437  {
1438  if (!mapper->GetCropping()) {
1439  return std::string();
1440  }
1441 
1442  return std::string("\
1443  \n // Convert cropping region to texture space\
1444  \n float cropping_planes_ts[6];\
1445  \n mat4 datasetToTextureMat = in_inverseTextureDatasetMatrix;\
1446  \n\
1447  \n vec4 temp = vec4(cropping_planes[0], 0.0, 0.0, 1.0);\
1448  \n temp = datasetToTextureMat * temp;\
1449  \n if (temp[3] != 0.0)\
1450  \n {\
1451  \n temp[0] /= temp[3];\
1452  \n }\
1453  \n cropping_planes_ts[0] = temp[0];\
1454  \n\
1455  \n temp = vec4(cropping_planes[1], 0.0, 0.0, 1.0);\
1456  \n temp = datasetToTextureMat * temp;\
1457  \n if (temp[3] != 0.0)\
1458  \n {\
1459  \n temp[0] /= temp[3];\
1460  \n }\
1461  \n cropping_planes_ts[1] = temp[0];\
1462  \n\
1463  \n temp = vec4(0.0, cropping_planes[2], 0.0, 1.0);\
1464  \n temp = datasetToTextureMat * temp;\
1465  \n if (temp[3] != 0.0)\
1466  \n {\
1467  \n temp[1] /= temp[3];\
1468  \n }\
1469  \n cropping_planes_ts[2] = temp[1];\
1470  \n\
1471  \n temp = vec4(0.0, cropping_planes[3], 0.0, 1.0);\
1472  \n temp = datasetToTextureMat * temp;\
1473  \n if (temp[3] != 0.0)\
1474  \n {\
1475  \n temp[1] /= temp[3];\
1476  \n }\
1477  \n cropping_planes_ts[3] = temp[1];\
1478  \n\
1479  \n temp = vec4(0.0, 0.0, cropping_planes[4], 1.0);\
1480  \n temp = datasetToTextureMat * temp;\
1481  \n if (temp[3] != 0.0)\
1482  \n {\
1483  \n temp[2] /= temp[3];\
1484  \n }\
1485  \n cropping_planes_ts[4] = temp[2];\
1486  \n\
1487  \n temp = vec4(0.0, 0.0, cropping_planes[5], 1.0);\
1488  \n temp = datasetToTextureMat * temp;\
1489  \n if (temp[3] != 0.0)\
1490  \n {\
1491  \n temp[2] /= temp[3];\
1492  \n }\
1493  \n cropping_planes_ts[5] = temp[2];"
1494  );
1495  }
1496 
1497  //--------------------------------------------------------------------------
1499  vtkVolumeMapper* mapper,
1500  vtkVolume* vtkNotUsed(vol))
1501  {
1502  if (!mapper->GetCropping()) {
1503  return std::string();
1504  }
1505 
1506  return std::string("\
1507  \n // Determine region\
1508  \n int regionNo = computeRegion(cropping_planes_ts, g_dataPos);\
1509  \n\
1510  \n // Do & operation with cropping flags\
1511  \n // Pass the flag that its Ok to sample or not to sample\
1512  \n if (cropping_flags[regionNo] == 0)\
1513  \n {\
1514  \n // Skip this voxel\
1515  \n l_skip = true;\
1516  \n }"
1517  );
1518  }
1519 
1520  //--------------------------------------------------------------------------
1522  vtkVolumeMapper* vtkNotUsed(mapper),
1523  vtkVolume* vtkNotUsed(vol))
1524  {
1525  return std::string();
1526  }
1527 
1528  //--------------------------------------------------------------------------
1530  vtkVolumeMapper* vtkNotUsed(mapper),
1531  vtkVolume* vtkNotUsed(vol))
1532  {
1533  return std::string();
1534  }
1535 
1536  //--------------------------------------------------------------------------
1538  vtkVolumeMapper* vtkNotUsed(mapper),
1539  vtkVolume* vtkNotUsed(vol))
1540  {
1541  return std::string();
1542  }
1543 
1544  //--------------------------------------------------------------------------
1546  vtkVolumeMapper* mapper,
1547  vtkVolume* vtkNotUsed(vol))
1548  {
1549  if (!mapper->GetClippingPlanes())
1550  {
1551  return std::string();
1552  }
1553  else
1554  {
1555  return std::string("\
1556  \nfloat clippingPlanesTexture[48];\
1557  \nint clippingPlanesSize = int(in_clippingPlanes[0]);\
1558  \n\
1559  \nmat4 world_to_texture_mat = in_inverseTextureDatasetMatrix *\
1560  \n in_inverseVolumeMatrix;\
1561  \nfor (int i = 0; i < clippingPlanesSize; i = i + 6)\
1562  \n {\
1563  \n vec4 origin = vec4(in_clippingPlanes[i + 1],\
1564  \n in_clippingPlanes[i + 2],\
1565  \n in_clippingPlanes[i + 3], 1.0);\
1566  \n vec4 normal = vec4(in_clippingPlanes[i + 4],\
1567  \n in_clippingPlanes[i + 5],\
1568  \n in_clippingPlanes[i + 6], 0.0);\
1569  \n\
1570  \n origin = world_to_texture_mat * origin;\
1571  \n normal = world_to_texture_mat * normal;\
1572  \n\
1573  \n if (origin[3] != 0.0)\
1574  \n {\
1575  \n origin[0] = origin[0] / origin[3];\
1576  \n origin[1] = origin[1] / origin[3];\
1577  \n origin[2] = origin[2] / origin[3];\
1578  \n }\
1579  \n if (normal[3] != 0.0)\
1580  \n {\
1581  \n normal[0] = normal[0] / normal[3];\
1582  \n normal[1] = normal[1] / normal[3];\
1583  \n normal[2] = normal[2] / normal[3];\
1584  \n }\
1585  \n\
1586  \n clippingPlanesTexture[i] = origin[0];\
1587  \n clippingPlanesTexture[i + 1] = origin[1];\
1588  \n clippingPlanesTexture[i + 2] = origin[2];\
1589  \n\
1590  \n clippingPlanesTexture[i + 3] = normal[0];\
1591  \n clippingPlanesTexture[i + 4] = normal[1];\
1592  \n clippingPlanesTexture[i + 5] = normal[2];\
1593  \n }"
1594  );
1595  }
1596  }
1597 
1598  //--------------------------------------------------------------------------
1600  vtkVolumeMapper* mapper,
1601  vtkVolume* vtkNotUsed(vol))
1602  {
1603  if (!mapper->GetClippingPlanes())
1604  {
1605  return std::string();
1606  }
1607  else
1608  {
1609  return std::string("\
1610  \n for (int i = 0; i < (clippingPlanesSize) && !l_skip; i = i + 6)\
1611  \n {\
1612  \n if (dot(vec3(g_dataPos - vec3(clippingPlanesTexture[i],\
1613  \n clippingPlanesTexture[i + 1],\
1614  \n clippingPlanesTexture[i + 2])),\
1615  \n vec3(clippingPlanesTexture[i + 3],\
1616  \n clippingPlanesTexture[i + 4],\
1617  \n clippingPlanesTexture[i + 5])) < 0)\
1618  \n {\
1619  \n l_skip = true;\
1620  \n break;\
1621  \n }\
1622  \n }"
1623  );
1624  }
1625  }
1626 
1627  //--------------------------------------------------------------------------
1629  vtkVolumeMapper* vtkNotUsed(mapper),
1630  vtkVolume* vtkNotUsed(vol))
1631  {
1632  return std::string();
1633  }
1634 
1635  //--------------------------------------------------------------------------
1637  vtkVolumeMapper* vtkNotUsed(mapper),
1638  vtkVolume* vtkNotUsed(vol),
1639  vtkImageData* maskInput,
1640  vtkVolumeMask* mask,
1641  int vtkNotUsed(maskType))
1642  {
1643  if (!mask || !maskInput)
1644  {
1645  return std::string();
1646  }
1647  else
1648  {
1649  return std::string("uniform sampler3D in_mask;");
1650  }
1651  }
1652 
1653  //--------------------------------------------------------------------------
1655  vtkVolumeMapper* vtkNotUsed(mapper),
1656  vtkVolume* vtkNotUsed(vol),
1657  vtkImageData* maskInput,
1658  vtkVolumeMask* mask,
1659  int maskType)
1660  {
1661  if (!mask || !maskInput ||
1663  {
1664  return std::string();
1665  }
1666  else
1667  {
1668  return std::string("\
1669  \nvec4 maskValue = texture3D(in_mask, g_dataPos);\
1670  \nif(maskValue.r <= 0.0)\
1671  \n {\
1672  \n l_skip = true;\
1673  \n }"
1674  );
1675  }
1676  }
1677 
1678  //--------------------------------------------------------------------------
1680  vtkVolumeMapper* vtkNotUsed(mapper),
1681  vtkVolume* vtkNotUsed(vol),
1682  vtkImageData* maskInput,
1683  vtkVolumeMask* mask,
1684  int maskType)
1685  {
1686  if (!mask || !maskInput ||
1688  {
1689  return std::string();
1690  }
1691  else
1692  {
1693  return std::string("\
1694  \nuniform float in_maskBlendFactor;\
1695  \nuniform sampler2D in_mask1;\
1696  \nuniform sampler2D in_mask2;"
1697  );
1698  }
1699  }
1700 
1701  //--------------------------------------------------------------------------
1703  vtkVolumeMapper* vtkNotUsed(mapper),
1704  vtkVolume* vtkNotUsed(vol),
1705  vtkImageData* maskInput,
1706  vtkVolumeMask* mask,
1707  int maskType,
1708  int noOfComponents)
1709  {
1710  if (!mask || !maskInput ||
1712  {
1713  return std::string();
1714  }
1715  else
1716  {
1717  std::string shaderStr = std::string("\
1718  \nvec4 scalar = texture3D(in_volume, g_dataPos);");
1719 
1720  // simulate old intensity textures
1721  if (noOfComponents == 1)
1722  {
1723  shaderStr += std::string("\
1724  \n scalar.r = scalar.r*in_volume_scale.r + in_volume_bias.r;\
1725  \n scalar = vec4(scalar.r,scalar.r,scalar.r,scalar.r);"
1726  );
1727  }
1728  else
1729  {
1730  // handle bias and scale
1731  shaderStr += std::string("\
1732  \n scalar = scalar*in_volume_scale + in_volume_bias;"
1733  );
1734  }
1735 
1736  return shaderStr + std::string("\
1737  \nif (in_maskBlendFactor == 0.0)\
1738  \n {\
1739  \n g_srcColor = computeColor(scalar, computeOpacity(scalar));\
1740  \n }\
1741  \nelse\
1742  \n {\
1743  \n float opacity = computeOpacity(scalar);\
1744  \n // Get the mask value at this same location\
1745  \n vec4 maskValue = texture3D(in_mask, g_dataPos);\
1746  \n if(maskValue.r == 0.0)\
1747  \n {\
1748  \n g_srcColor = computeColor(scalar, opacity);\
1749  \n }\
1750  \n else\
1751  \n {\
1752  \n if (maskValue.r == 1.0/255.0)\
1753  \n {\
1754  \n g_srcColor = texture2D(in_mask1, vec2(scalar.w,0.0));\
1755  \n }\
1756  \n else\
1757  \n {\
1758  \n // maskValue.r == 2.0/255.0\
1759  \n g_srcColor = texture2D(in_mask2, vec2(scalar.w,0.0));\
1760  \n }\
1761  \n g_srcColor.a = 1.0;\
1762  \n if(in_maskBlendFactor < 1.0)\
1763  \n {\
1764  \n g_srcColor = (1.0 - in_maskBlendFactor) *\
1765  \n computeColor(scalar, opacity) +\
1766  \n in_maskBlendFactor * g_srcColor;\
1767  \n }\
1768  \n }\
1769  \n g_srcColor.a = opacity;\
1770  \n }"
1771  );
1772  }
1773  }
1774 
1775  //--------------------------------------------------------------------------
1777  vtkVolumeMapper* vtkNotUsed(mapper),
1778  vtkVolume* vtkNotUsed(vol))
1779  {
1780  return std::string("\
1781  \n vec3 l_opaqueFragPos = g_dataPos;\
1782  \n bool l_updateDepth = true;"
1783  );
1784  }
1785 
1786  //--------------------------------------------------------------------------
1788  vtkRenderer* vtkNotUsed(ren), vtkVolumeMapper* vtkNotUsed(mapper),
1789  vtkVolume* vtkNotUsed(vol))
1790  {
1791  return std::string("\
1792  \n if(!l_skip && g_srcColor.a > 0.0 && l_updateDepth)\
1793  \n {\
1794  \n l_opaqueFragPos = g_dataPos;\
1795  \n l_updateDepth = false;\
1796  \n }"
1797  );
1798  }
1799 
1800  //--------------------------------------------------------------------------
1802  vtkVolumeMapper* vtkNotUsed(mapper),
1803  vtkVolume* vtkNotUsed(vol))
1804  {
1805  return std::string("\
1806  \n vec4 depthValue = in_projectionMatrix * in_modelViewMatrix *\
1807  \n in_volumeMatrix * in_textureDatasetMatrix *\
1808  \n vec4(l_opaqueFragPos, 1.0);\
1809  \n gl_FragData[1] = vec4(vec3((depthValue.z/depthValue.w) * 0.5 + 0.5),\
1810  \n 1.0);"
1811  );
1812  }
1813 }
1814 
1815 #endif // vtkVolumeShaderComposer_h
1816 // VTK-HeaderTest-Exclude: vtkVolumeShaderComposer.h
std::string ShadingExit(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *mapper, vtkVolume *vtkNotUsed(vol), int noOfComponents, int independentComponents=0)
std::string BaseImplementation(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol))
represents a volume (data & properties) in a rendered scene
Definition: vtkVolume.h:49
std::string CroppingDeclarationVertex(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol))
std::string CompositeMaskImplementation(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol), vtkImageData *maskInput, vtkVolumeMask *mask, int maskType, int noOfComponents)
Abstract class for a volume mapper.
std::string BinaryMaskDeclaration(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol), vtkImageData *maskInput, vtkVolumeMask *mask, int vtkNotUsed(maskType))
virtual int GetBlendMode()
std::string BaseInit(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vol, int lightingComplexity)
abstract specification for renderers
Definition: vtkRenderer.h:62
std::string CroppingDeclarationFragment(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *mapper, vtkVolume *vtkNotUsed(vol))
std::string ShadingDeclarationFragment(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol))
std::string TerminationExit(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol))
std::string ShadingDeclarationVertex(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol))
std::string BinaryMaskImplementation(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol), vtkImageData *maskInput, vtkVolumeMask *mask, int maskType)
std::string ComputeLightingDeclaration(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vol, int noOfComponents, int independentComponents, int vtkNotUsed(numberOfLights), int lightingComplexity)
virtual vtkPlaneCollection * GetClippingPlanes()
vtkCamera * GetActiveCamera()
int GetShade(int index)
std::string ClippingImplementation(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *mapper, vtkVolume *vtkNotUsed(vol))
std::string RenderToImageDepthInit(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol))
std::string TerminationInit(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol))
std::string CroppingImplementation(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *mapper, vtkVolume *vtkNotUsed(vol))
std::string TerminationImplementation(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol))
std::string ClippingDeclarationVertex(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol))
std::string ClippingExit(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol))
std::string CompositeMaskDeclarationFragment(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol), vtkImageData *maskInput, vtkVolumeMask *mask, int maskType)
topologically and geometrically regular array of data
Definition: vtkImageData.h:44
bool HasGradientOpacity(int index=0)
std::string RenderToImageDepthExit(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol))
std::string RenderToImageDepthImplementation(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol))
std::string ShadingImplementation(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *mapper, vtkVolume *vtkNotUsed(vol), vtkImageData *maskInput, vtkVolumeMask *mask, int maskType, int noOfComponents, int independentComponents=0)
virtual int GetParallelProjection()
std::string ComputeClipPositionImplementation(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol))
std::string ComputeRayDirectionDeclaration(vtkRenderer *ren, vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol), int vtkNotUsed(noOfComponents))
std::string BaseDeclarationFragment(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol), int vtkNotUsed(numberOfLights), int lightingComplexity, int noOfComponents, int independentComponents)
std::string ShadingInit(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *mapper, vtkVolume *vtkNotUsed(vol))
represents the common properties for rendering a volume.
std::string CroppingExit(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol))
std::string ClippingDeclarationFragment(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol))
std::string ComputeTextureCoordinates(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol))
std::string ClippingInit(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *mapper, vtkVolume *vtkNotUsed(vol))
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
std::string ComputeGradientDeclaration(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vol, int noOfComponents, int independentComponents, std::map< int, std::string > gradientTableMap)
std::string CroppingInit(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *mapper, vtkVolume *vtkNotUsed(vol))
vtkVolumeProperty * GetProperty()
virtual int GetCropping()
std::string replace(std::string source, const std::string &search, const std::string replace, bool all)
std::string TerminationDeclarationVertex(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol))
std::string BaseDeclarationVertex(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol))
std::string BaseExit(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol))
std::string TerminationDeclarationFragment(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol))
std::string ComputeOpacityDeclaration(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol), int noOfComponents, int independentComponents, std::map< int, std::string > opacityTableMap)
std::string ComputeColorDeclaration(vtkRenderer *vtkNotUsed(ren), vtkVolumeMapper *vtkNotUsed(mapper), vtkVolume *vtkNotUsed(vol), int noOfComponents, int independentComponents, std::map< int, std::string > colorTableMap)