@kitware/vtk.js 22.6.1 → 23.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (157) hide show
  1. package/Common/Core/CellArray.d.ts +2 -2
  2. package/Common/Core/DataArray.d.ts +2 -2
  3. package/Common/Core/Endian.d.ts +3 -1
  4. package/Common/Core/ImageHelper.d.ts +1 -1
  5. package/Common/Core/LookupTable.d.ts +2 -2
  6. package/Common/Core/Math.d.ts +1 -1
  7. package/Common/Core/MatrixBuilder.d.ts +1 -1
  8. package/Common/Core/Points.d.ts +2 -2
  9. package/Common/Core/PriorityQueue.d.ts +1 -1
  10. package/Common/Core/ProgressHandler.d.ts +1 -1
  11. package/Common/Core/ScalarsToColors.d.ts +3 -3
  12. package/Common/Core/StringArray.d.ts +1 -1
  13. package/Common/Core/VariantArray.d.ts +1 -1
  14. package/Common/DataModel/Box.d.ts +2 -2
  15. package/Common/DataModel/CardinalSpline1D.d.ts +2 -2
  16. package/Common/DataModel/Cell.d.ts +3 -3
  17. package/Common/DataModel/Cone.d.ts +2 -2
  18. package/Common/DataModel/Cylinder.d.ts +2 -2
  19. package/Common/DataModel/DataSet.d.ts +2 -2
  20. package/Common/DataModel/DataSetAttributes/FieldData.d.ts +1 -1
  21. package/Common/DataModel/DataSetAttributes.d.ts +3 -3
  22. package/Common/DataModel/ITKHelper.js +16 -20
  23. package/Common/DataModel/ImageData.d.ts +36 -36
  24. package/Common/DataModel/KochanekSpline1D.d.ts +1 -1
  25. package/Common/DataModel/Line.d.ts +2 -2
  26. package/Common/DataModel/PiecewiseFunction.d.ts +2 -2
  27. package/Common/DataModel/Plane.d.ts +2 -2
  28. package/Common/DataModel/PointSet.d.ts +3 -3
  29. package/Common/DataModel/PolyData.d.ts +3 -3
  30. package/Common/DataModel/Polygon.d.ts +2 -2
  31. package/Common/DataModel/SelectionNode.d.ts +2 -2
  32. package/Common/DataModel/Sphere.d.ts +2 -2
  33. package/Common/DataModel/Spline1D.d.ts +1 -1
  34. package/Common/DataModel/Spline3D.d.ts +1 -1
  35. package/Common/DataModel/Triangle.d.ts +2 -2
  36. package/Common/Transform/LandmarkTransform.d.ts +2 -2
  37. package/Filters/General/AppendPolyData.d.ts +1 -1
  38. package/Filters/General/ImageCropFilter.d.ts +1 -1
  39. package/Filters/General/ImageOutlineFilter.d.ts +1 -1
  40. package/Filters/General/ImageSliceFilter.d.ts +2 -2
  41. package/Filters/General/ImageStreamline.d.ts +135 -0
  42. package/Filters/General/LineFilter.d.ts +1 -1
  43. package/Filters/General/OutlineFilter.d.ts +1 -1
  44. package/Filters/General/TriangleFilter.d.ts +1 -1
  45. package/Filters/General/TubeFilter.d.ts +2 -2
  46. package/Filters/Sources/Arrow2DSource.d.ts +2 -2
  47. package/Filters/Sources/ArrowSource.d.ts +2 -2
  48. package/Filters/Sources/CircleSource.d.ts +2 -2
  49. package/Filters/Sources/ConeSource.d.ts +2 -2
  50. package/Filters/Sources/CubeSource.d.ts +2 -2
  51. package/Filters/Sources/Cursor3D.d.ts +3 -3
  52. package/Filters/Sources/CylinderSource.d.ts +2 -2
  53. package/Filters/Sources/LineSource.d.ts +2 -2
  54. package/Filters/Sources/PlaneSource.d.ts +2 -2
  55. package/Filters/Sources/PointSource.d.ts +2 -2
  56. package/Filters/Sources/SphereSource.d.ts +2 -2
  57. package/Filters/Texture/TextureMapToPlane.d.ts +1 -1
  58. package/Filters/Texture/TextureMapToSphere.d.ts +1 -1
  59. package/IO/Core/DataAccessHelper/HtmlDataAccessHelper.d.ts +9 -0
  60. package/IO/Core/DataAccessHelper/HttpDataAccessHelper.d.ts +9 -0
  61. package/IO/Core/DataAccessHelper/JSZipDataAccessHelper.d.ts +13 -0
  62. package/IO/Core/DataAccessHelper/LiteHttpDataAccessHelper.d.ts +9 -0
  63. package/IO/Core/DataAccessHelper.d.ts +32 -0
  64. package/IO/Core/HttpDataSetReader.d.ts +226 -0
  65. package/IO/Core/HttpSceneLoader.d.ts +5 -5
  66. package/IO/Core/ImageStream/DefaultProtocol.d.ts +1 -1
  67. package/IO/Core/ImageStream/ViewStream.d.ts +4 -4
  68. package/IO/Core/ImageStream.d.ts +3 -3
  69. package/IO/Core/WSLinkClient.d.ts +1 -1
  70. package/IO/Geometry/DracoReader.d.ts +13 -9
  71. package/IO/Geometry/PLYReader.d.ts +13 -9
  72. package/IO/Geometry/PLYWriter.d.ts +2 -2
  73. package/IO/Geometry/STLReader.d.ts +14 -9
  74. package/IO/Geometry/STLWriter.d.ts +2 -2
  75. package/IO/Misc/ElevationReader.d.ts +11 -6
  76. package/IO/Misc/ITKImageReader.d.ts +1 -1
  77. package/IO/Misc/ITKPolyDataReader.d.ts +1 -1
  78. package/IO/Misc/JSONNucleoReader.d.ts +13 -9
  79. package/IO/Misc/JSONReader.d.ts +4 -4
  80. package/IO/Misc/MTLReader.d.ts +11 -7
  81. package/IO/Misc/OBJReader.d.ts +10 -6
  82. package/IO/Misc/PDBReader.d.ts +10 -6
  83. package/IO/XML/XMLImageDataReader.d.ts +1 -1
  84. package/IO/XML/XMLPolyDataReader.d.ts +1 -1
  85. package/IO/XML/XMLReader.d.ts +20 -16
  86. package/Interaction/Manipulators/MouseRangeManipulator.js +55 -1
  87. package/Interaction/Widgets/OrientationMarkerWidget.d.ts +22 -8
  88. package/Interaction/Widgets/OrientationMarkerWidget.js +62 -37
  89. package/Rendering/Core/AbstractMapper.d.ts +2 -2
  90. package/Rendering/Core/AbstractMapper3D.d.ts +2 -2
  91. package/Rendering/Core/AbstractPicker.d.ts +4 -4
  92. package/Rendering/Core/Actor.d.ts +21 -18
  93. package/Rendering/Core/Actor2D.d.ts +5 -5
  94. package/Rendering/Core/AnnotatedCubeActor.d.ts +1 -1
  95. package/Rendering/Core/AxesActor.d.ts +1 -1
  96. package/Rendering/Core/Camera.d.ts +2 -2
  97. package/Rendering/Core/CellPicker.d.ts +5 -5
  98. package/Rendering/Core/ColorTransferFunction.d.ts +1 -1
  99. package/Rendering/Core/Coordinate.d.ts +2 -2
  100. package/Rendering/Core/Follower.d.ts +2 -2
  101. package/Rendering/Core/Glyph3DMapper.d.ts +2 -2
  102. package/Rendering/Core/ImageMapper.d.ts +3 -3
  103. package/Rendering/Core/ImageProperty.d.ts +11 -2
  104. package/Rendering/Core/ImageProperty.js +3 -2
  105. package/Rendering/Core/ImageSlice.d.ts +4 -4
  106. package/Rendering/Core/Light.d.ts +2 -2
  107. package/Rendering/Core/Mapper.d.ts +5 -5
  108. package/Rendering/Core/Mapper2D.d.ts +4 -3
  109. package/Rendering/Core/Picker.d.ts +5 -5
  110. package/Rendering/Core/PixelSpaceCallbackMapper.d.ts +2 -2
  111. package/Rendering/Core/PointPicker.d.ts +3 -3
  112. package/Rendering/Core/Prop.d.ts +5 -5
  113. package/Rendering/Core/Prop3D.d.ts +2 -2
  114. package/Rendering/Core/Property.d.ts +2 -2
  115. package/Rendering/Core/Property2D.d.ts +2 -2
  116. package/Rendering/Core/RenderWindow.d.ts +4 -4
  117. package/Rendering/Core/RenderWindowInteractor.d.ts +2 -2
  118. package/Rendering/Core/Renderer.d.ts +17 -16
  119. package/Rendering/Core/ScalarBarActor.d.ts +3 -3
  120. package/Rendering/Core/Skybox.d.ts +1 -1
  121. package/Rendering/Core/SphereMapper.d.ts +1 -1
  122. package/Rendering/Core/StickMapper.d.ts +1 -1
  123. package/Rendering/Core/Texture.d.ts +1 -1
  124. package/Rendering/Core/Viewport.d.ts +4 -4
  125. package/Rendering/Core/Volume.d.ts +4 -4
  126. package/Rendering/Core/VolumeMapper.d.ts +2 -2
  127. package/Rendering/Core/VolumeProperty.d.ts +1 -1
  128. package/Rendering/Misc/CanvasView.d.ts +2 -2
  129. package/Rendering/Misc/FullScreenRenderWindow.d.ts +8 -8
  130. package/Rendering/Misc/GenericRenderWindow.d.ts +6 -6
  131. package/Rendering/Misc/RemoteView.d.ts +3 -3
  132. package/Rendering/Misc/RenderWindowWithControlBar.d.ts +2 -2
  133. package/Rendering/Misc/SynchronizableRenderWindow.d.ts +4 -3
  134. package/Rendering/Misc/TextureLODsDownloader.d.ts +4 -4
  135. package/Rendering/OpenGL/ImageMapper.js +1 -1
  136. package/Rendering/OpenGL/RenderWindow.d.ts +18 -18
  137. package/Rendering/OpenGL/VolumeMapper.js +16 -1
  138. package/Rendering/OpenGL/glsl/vtkVolumeFS.glsl.js +1 -1
  139. package/Rendering/SceneGraph/RenderPass.d.ts +2 -2
  140. package/Rendering/SceneGraph/ViewNode.d.ts +2 -2
  141. package/Rendering/SceneGraph/ViewNodeFactory.d.ts +1 -1
  142. package/Rendering/WebGPU/HardwareSelectionPass.js +0 -1
  143. package/Rendering/WebGPU/ImageMapper.js +1 -1
  144. package/Rendering/WebGPU/OrderIndependentTranslucentPass.js +1 -3
  145. package/Rendering/WebGPU/RenderEncoder.js +1 -4
  146. package/Widgets/Core/AbstractWidgetFactory.js +5 -3
  147. package/Widgets/Manipulators/LineManipulator.d.ts +1 -1
  148. package/Widgets/Manipulators/PlaneManipulator.d.ts +1 -1
  149. package/Widgets/Manipulators/TrackballManipulator.d.ts +1 -1
  150. package/Widgets/Representations/ResliceCursorContextRepresentation.d.ts +1 -1
  151. package/Widgets/Representations/WidgetRepresentation.d.ts +1 -1
  152. package/index.d.ts +7 -0
  153. package/interfaces.d.ts +4 -4
  154. package/macros.d.ts +1 -1
  155. package/package.json +1 -1
  156. package/types.d.ts +22 -1
  157. package/vtk.d.ts +7 -2
@@ -1,6 +1,6 @@
1
1
  import { mat4 } from "gl-matrix";
2
- import { Bounds, Vector3, Range } from '@kitware/vtk.js/types';
3
- import vtkProp, { IPropInitialValues } from '@kitware/vtk.js/Rendering/Core/Prop';
2
+ import { Bounds, Vector3, Range } from '../../types';
3
+ import vtkProp, { IPropInitialValues } from './Prop';
4
4
 
5
5
  export interface IProp3DInitialValues extends IPropInitialValues {
6
6
  origin?: number[];
@@ -1,5 +1,5 @@
1
- import { vtkObject } from '@kitware/vtk.js/interfaces';
2
- import { RGBColor } from '@kitware/vtk.js/types';
1
+ import { vtkObject } from '../../interfaces';
2
+ import { RGBColor } from '../../types';
3
3
 
4
4
  export enum Shading {
5
5
  FLAT,
@@ -1,5 +1,5 @@
1
- import { vtkObject } from '@kitware/vtk.js/interfaces';
2
- import { RGBColor } from '@kitware/vtk.js/types';
1
+ import { vtkObject } from '../../interfaces';
2
+ import { RGBColor } from '../../types';
3
3
 
4
4
  interface IProperty2DInitialValues{
5
5
  color?: RGBColor;
@@ -1,7 +1,7 @@
1
- import { vtkObject, vtkSubscription } from '@kitware/vtk.js/interfaces';
2
- import vtkRenderer from '@kitware/vtk.js/Rendering/Core/Renderer';
3
- import vtkRenderWindowInteractor from '@kitware/vtk.js/Rendering/Core/RenderWindowInteractor';
4
- // import vtkOpenGLRenderWindow from '@kitware/vtk.js/OpenGL/RenderWindow';
1
+ import { vtkObject, vtkSubscription } from '../../interfaces';
2
+ import vtkRenderer from './Renderer';
3
+ import vtkRenderWindowInteractor from './RenderWindowInteractor';
4
+ // import vtkOpenGLRenderWindow from '../../OpenGL/RenderWindow';
5
5
 
6
6
  export interface IRenderWindowInitialValues {
7
7
  renderers?: vtkRenderer[],
@@ -1,5 +1,5 @@
1
- import { vtkObject } from '@kitware/vtk.js/interfaces';
2
- import vtkRenderer from '@kitware/vtk.js/Rendering/Core/Renderer';
1
+ import { vtkObject } from '../../interfaces';
2
+ import vtkRenderer from './Renderer';
3
3
 
4
4
  export enum Device {
5
5
  Unknown,
@@ -1,13 +1,13 @@
1
- import { Bounds } from '@kitware/vtk.js/types';
1
+ import { Bounds, Nullable } from '../../types';
2
2
 
3
- import vtkCamera from '@kitware/vtk.js/Rendering/Core/Camera';
4
- import vtkLight from '@kitware/vtk.js/Rendering/Core/Light';
5
- import vtkRenderWindow from '@kitware/vtk.js/Rendering/Core/RenderWindow';
6
- import vtkProp3D from '@kitware/vtk.js/Rendering/Core/Prop3D';
7
- import vtkViewport, { IViewportInitialValues } from '@kitware/vtk.js/Rendering/Core/Viewport';
8
- import vtkVolume from '@kitware/vtk.js/Rendering/Core/Volume';
9
- import vtkTexture from '@kitware/vtk.js/Rendering/Core/Texture';
10
- import vtkActor from '@kitware/vtk.js/Rendering/Core/Actor';
3
+ import vtkCamera from './Camera';
4
+ import vtkLight from './Light';
5
+ import vtkRenderWindow from './RenderWindow';
6
+ import vtkProp3D from './Prop3D';
7
+ import vtkViewport, { IViewportInitialValues } from './Viewport';
8
+ import vtkVolume from './Volume';
9
+ import vtkTexture from './Texture';
10
+ import vtkActor from './Actor';
11
11
 
12
12
 
13
13
  export interface IRendererInitialValues extends IViewportInitialValues {
@@ -47,14 +47,14 @@ export interface vtkRenderer extends vtkViewport {
47
47
  isActiveCameraCreated(): boolean;
48
48
 
49
49
  /**
50
- *
51
- * @param actor
50
+ * Add different types of props to the renderer.
51
+ * @param {vtkActor} actor The vtkActor instance.
52
52
  */
53
53
  addActor(actor: vtkActor): boolean;
54
54
 
55
55
  /**
56
56
  * Add a light to the list of lights.
57
- * @param light The vtkLight instance.
57
+ * @param {vtkLight} light The vtkLight instance.
58
58
  */
59
59
  addLight(light: vtkLight): void;
60
60
 
@@ -75,9 +75,9 @@ export interface vtkRenderer extends vtkViewport {
75
75
  createLight(): vtkLight;
76
76
 
77
77
  /**
78
- *
78
+ * Compute the bounding box of all the visible props Used in ResetCamera() and ResetCameraClippingRange()
79
79
  */
80
- computeVisiblePropBounds(): number[];
80
+ computeVisiblePropBounds(): Bounds;
81
81
 
82
82
  /**
83
83
  * Get the active camera
@@ -128,6 +128,7 @@ export interface vtkRenderer extends vtkViewport {
128
128
  *
129
129
  */
130
130
  getClippingRangeExpansion(): number;
131
+
131
132
  /**
132
133
  *
133
134
  * @default null
@@ -226,7 +227,7 @@ export interface vtkRenderer extends vtkViewport {
226
227
  *
227
228
  * @default null
228
229
  */
229
- getRenderWindow(): vtkRenderWindow | null;
230
+ getRenderWindow(): Nullable<vtkRenderWindow>;
230
231
 
231
232
  /**
232
233
  *
@@ -337,7 +338,7 @@ export interface vtkRenderer extends vtkViewport {
337
338
  * Specify the camera to use for this renderer.
338
339
  * @param {vtkCamera} camera The camera object to use.
339
340
  */
340
- setActiveCamera(camera: vtkCamera | null): boolean;
341
+ setActiveCamera(camera: vtkCamera): boolean;
341
342
 
342
343
  /**
343
344
  *
@@ -1,6 +1,6 @@
1
- import vtkScalarsToColors from '@kitware/vtk.js/Common/Core/ScalarsToColors';
2
- import { Size, Vector2, Vector3 } from '@kitware/vtk.js/types';
3
- import vtkActor, { IActorInitialValues } from '@kitware/vtk.js/Rendering/Core/Actor';
1
+ import vtkScalarsToColors from '../../Common/Core/ScalarsToColors';
2
+ import { Size, Vector2, Vector3 } from '../../types';
3
+ import vtkActor, { IActorInitialValues } from './Actor';
4
4
 
5
5
 
6
6
  export interface ITextSizes {
@@ -1,4 +1,4 @@
1
- import vtkActor, { IActorInitialValues } from '@kitware/vtk.js/Rendering/Core/Actor';
1
+ import vtkActor, { IActorInitialValues } from './Actor';
2
2
 
3
3
  export interface ISkyboxInitialValues extends IActorInitialValues {
4
4
  format?: string;
@@ -1,4 +1,4 @@
1
- import vtkMapper, { IMapperInitialValues } from '@kitware/vtk.js/Rendering/Core/Mapper';
1
+ import vtkMapper, { IMapperInitialValues } from './Mapper';
2
2
 
3
3
  export interface ISphereInitialValues extends IMapperInitialValues {
4
4
  radius?: number;
@@ -1,4 +1,4 @@
1
- import vtkMapper, { IMapperInitialValues } from '@kitware/vtk.js/Rendering/Core/Mapper';
1
+ import vtkMapper, { IMapperInitialValues } from './Mapper';
2
2
 
3
3
  interface IStickMappereInitialValues extends IMapperInitialValues{
4
4
  radius?: number;
@@ -1,4 +1,4 @@
1
- import { vtkAlgorithm } from '@kitware/vtk.js/interfaces';
1
+ import { vtkAlgorithm } from '../../interfaces';
2
2
 
3
3
  export interface ITextureInitialValues {
4
4
  repeat?: boolean;
@@ -1,8 +1,8 @@
1
1
 
2
- import { vtkObject } from '@kitware/vtk.js/interfaces';
3
- import { RGBColor } from '@kitware/vtk.js/types';
4
- import vtkActor2D from '@kitware/vtk.js/Rendering/Core/Actor2D';
5
- import vtkProp from '@kitware/vtk.js/Rendering/Core/Prop';
2
+ import { vtkObject } from '../../interfaces';
3
+ import { RGBColor } from '../../types';
4
+ import vtkActor2D from './Actor2D';
5
+ import vtkProp from './Prop';
6
6
 
7
7
  export interface IViewportInitialValues {
8
8
  background?: RGBColor;
@@ -1,7 +1,7 @@
1
- import { Bounds } from '@kitware/vtk.js/types';
2
- import vtkProp3D, { IProp3DInitialValues } from '@kitware/vtk.js/Rendering/Core/Prop3D';
3
- import vtkVolumeMapper from '@kitware/vtk.js/Rendering/Core/VolumeMapper';
4
- import vtkVolumeProperty from '@kitware/vtk.js/Rendering/Core/VolumeProperty';
1
+ import { Bounds } from '../../types';
2
+ import vtkProp3D, { IProp3DInitialValues } from './Prop3D';
3
+ import vtkVolumeMapper from './VolumeMapper';
4
+ import vtkVolumeProperty from './VolumeProperty';
5
5
 
6
6
  /**
7
7
  *
@@ -1,5 +1,5 @@
1
- import { Bounds, Range } from '@kitware/vtk.js/types';
2
- import vtkAbstractMapper, { IAbstractMapperInitialValues } from '@kitware/vtk.js/Rendering/Core/AbstractMapper';
1
+ import { Bounds, Range } from '../../types';
2
+ import vtkAbstractMapper, { IAbstractMapperInitialValues } from './AbstractMapper';
3
3
 
4
4
  export enum BlendMode {
5
5
  COMPOSITE_BLEND,
@@ -1,4 +1,4 @@
1
- import { vtkObject } from '@kitware/vtk.js/interfaces';
1
+ import { vtkObject } from '../../interfaces';
2
2
 
3
3
  export enum InterpolationType {
4
4
  NEAREST,
@@ -1,5 +1,5 @@
1
- import { vtkObject } from '@kitware/vtk.js/interfaces';
2
- import { Size } from '@kitware/vtk.js/types';
1
+ import { vtkObject } from '../../interfaces';
2
+ import { Size } from '../../types';
3
3
 
4
4
 
5
5
  /**
@@ -1,11 +1,11 @@
1
- import { vtkObject } from '@kitware/vtk.js/interfaces';
2
- import { RGBColor } from '@kitware/vtk.js/types';
3
- import vtkRenderer from '@kitware/vtk.js/Rendering/Core/Renderer';
4
- import vtkRenderWindow from '@kitware/vtk.js/Rendering/Core/RenderWindow';
5
- import vtkRenderWindowInteractor from '@kitware/vtk.js/Rendering/Core/RenderWindowInteractor';
6
-
7
- // import vtkOpenGLRenderWindow from '@kitware/vtk.js/OpenGL/RenderWindow';
8
- // import vtkWebGPURenderWindow from '@kitware/vtk.js/WebGPU/RenderWindow';
1
+ import { vtkObject } from '../../interfaces';
2
+ import { RGBColor } from '../../types';
3
+ import vtkRenderer from '../Core/Renderer';
4
+ import vtkRenderWindow from '../Core/RenderWindow';
5
+ import vtkRenderWindowInteractor from '../Core/RenderWindowInteractor';
6
+
7
+ // import vtkOpenGLRenderWindow from '../../OpenGL/RenderWindow';
8
+ // import vtkWebGPURenderWindow from '../../WebGPU/RenderWindow';
9
9
 
10
10
 
11
11
  /**
@@ -1,9 +1,9 @@
1
- import { vtkObject, vtkSubscription } from '@kitware/vtk.js/interfaces';
2
- import { RGBColor } from '@kitware/vtk.js/types';
3
- import vtkRenderer from '@kitware/vtk.js/Rendering/Core/Renderer';
4
- import vtkRenderWindow from '@kitware/vtk.js/Rendering/Core/RenderWindow';
5
- import vtkRenderWindowInteractor from '@kitware/vtk.js/Rendering/Core/RenderWindowInteractor';
6
- import vtkOpenGLRenderWindow from '@kitware/vtk.js/Rendering/OpenGL/RenderWindow';
1
+ import { vtkObject, vtkSubscription } from '../../interfaces';
2
+ import { RGBColor } from '../../types';
3
+ import vtkRenderer from '../Core/Renderer';
4
+ import vtkRenderWindow from '../Core/RenderWindow';
5
+ import vtkRenderWindowInteractor from '../Core/RenderWindowInteractor';
6
+ import vtkOpenGLRenderWindow from '../OpenGL/RenderWindow';
7
7
 
8
8
 
9
9
  /**
@@ -1,6 +1,6 @@
1
- import { vtkObject } from '@kitware/vtk.js/interfaces';
2
- import vtkCanvasView from '@kitware/vtk.js/Rendering/Misc/CanvasView';
3
- import vtkViewStream from '@kitware/vtk.js/IO/Core/ImageStream/ViewStream';
1
+ import { vtkObject } from '../../interfaces';
2
+ import vtkCanvasView from './CanvasView';
3
+ import vtkViewStream from '../../IO/Core/ImageStream/ViewStream';
4
4
 
5
5
  interface IRemoteViewInitialValues {
6
6
  viewId?: string;
@@ -1,6 +1,6 @@
1
1
 
2
- import { Placement } from '@kitware/vtk.js/types';
3
- import vtkGenericRenderWindow, { IGenericRenderWindowInitialValues } from '@kitware/vtk.js/Rendering/Misc/GenericRenderWindow';
2
+ import { Placement } from '../../types';
3
+ import vtkGenericRenderWindow, { IGenericRenderWindowInitialValues } from './GenericRenderWindow';
4
4
 
5
5
  /**
6
6
  *
@@ -1,4 +1,5 @@
1
- import vtkRenderWindow, { IRenderWindowInitialValues } from '@kitware/vtk.js/Rendering/Core/RenderWindow';
1
+ import { Nullable } from '../../types';
2
+ import vtkRenderWindow, { IRenderWindowInitialValues } from '../Core/RenderWindow';
2
3
 
3
4
  // Keeps state for client / server scene synchronization.
4
5
  export interface ISynchronizerContext {
@@ -27,8 +28,8 @@ export interface ISynchronizerContext {
27
28
 
28
29
  export interface ISynchronizableRenderWindowInitialValues extends IRenderWindowInitialValues {
29
30
  synchronizerContextName?: string; // default: 'default':
30
- synchronizerContext?: ISynchronizerContext | null;
31
- synchronizedViewId?: string | null;
31
+ synchronizerContext?: Nullable<ISynchronizerContext>;
32
+ synchronizedViewId?: Nullable<string>;
32
33
  }
33
34
 
34
35
  // Server-side view state.
@@ -1,6 +1,6 @@
1
- import { vtkObject } from '@kitware/vtk.js/interfaces';
2
- import { CrossOrigin } from '@kitware/vtk.js/types';
3
- import vtkTexture from '@kitware/vtk.js/Rendering/Core/Texture';
1
+ import { vtkObject } from '../../interfaces';
2
+ import { CrossOrigin, Nullable } from '../../types';
3
+ import vtkTexture from '../Core/Texture';
4
4
 
5
5
  /**
6
6
  *
@@ -27,7 +27,7 @@ export interface vtkTextureLODsDownloader extends vtkObject {
27
27
  /**
28
28
  * Get the crossorigin attribute
29
29
  */
30
- getCrossOrigin(): CrossOrigin | null;
30
+ getCrossOrigin(): Nullable<CrossOrigin>;
31
31
 
32
32
  /**
33
33
  * Get the list of files to download
@@ -320,7 +320,7 @@ function vtkOpenGLImageMapper(publicAPI, model) {
320
320
  var target = iComps ? _i : 0;
321
321
  var cfun = actor.getProperty().getRGBTransferFunction(target);
322
322
 
323
- if (cfun) {
323
+ if (cfun && actor.getProperty().getUseLookupTableScalarRange()) {
324
324
  var cRange = cfun.getRange();
325
325
  cw = cRange[1] - cRange[0];
326
326
  cl = 0.5 * (cRange[1] + cRange[0]);
@@ -1,9 +1,9 @@
1
- import { vtkAlgorithm, vtkObject } from '@kitware/vtk.js/interfaces';
2
- import { Size, Vector2, Vector3 } from '@kitware/vtk.js/types';
3
- import { vtkRenderer } from '@kitware/vtk.js/Rendering/Core/Renderer';
4
- import { VtkDataTypes } from '@kitware/vtk.js/Common/Core/DataArray';
5
- import vtkTexture from '@kitware/vtk.js/Rendering/Core/Texture';
6
- import vtkViewStream from '@kitware/vtk.js/IO/Core/ImageStream/ViewStream';
1
+ import { vtkAlgorithm, vtkObject } from '../../interfaces';
2
+ import { Nullable, Size, Vector2, Vector3 } from '../../types';
3
+ import { vtkRenderer } from '../../Rendering/Core/Renderer';
4
+ import { VtkDataTypes } from '../../Common/Core/DataArray';
5
+ import vtkTexture from '../Core/Texture';
6
+ import vtkViewStream from '../../IO/Core/ImageStream/ViewStream';
7
7
 
8
8
  /**
9
9
  *
@@ -199,7 +199,7 @@ export interface vtkOpenGLRenderWindow extends vtkOpenGLRenderWindowBase {
199
199
  *
200
200
  * @param options
201
201
  */
202
- get3DContext(options: object): WebGLRenderingContext | null;
202
+ get3DContext(options: object): Nullable<WebGLRenderingContext>;
203
203
 
204
204
  /**
205
205
  *
@@ -241,20 +241,20 @@ export interface vtkOpenGLRenderWindow extends vtkOpenGLRenderWindowBase {
241
241
 
242
242
  /**
243
243
  *
244
- * @param vtktype
245
- * @param numComps
246
- * @param useFloat
244
+ * @param {VtkDataTypes} vtktype
245
+ * @param {Number} numComps
246
+ * @param {Boolean} useFloat
247
247
  */
248
248
  getDefaultTextureInternalFormat(vtktype: VtkDataTypes, numComps: number, useFloat: boolean): void;
249
249
 
250
250
  /**
251
- *
252
- * @param {HTMLImageElement} img
251
+ *
252
+ * @param {HTMLImageElement} img The background image.
253
253
  */
254
254
  setBackgroundImage(img: HTMLImageElement): void;
255
255
 
256
256
  /**
257
- *
257
+ *
258
258
  * @param {Boolean} value
259
259
  */
260
260
  setUseBackgroundImage(value: boolean): void;
@@ -273,7 +273,7 @@ export interface vtkOpenGLRenderWindow extends vtkOpenGLRenderWindowBase {
273
273
  * @param {String} format
274
274
  * @param {IOptions} options
275
275
  */
276
- captureNextImage(format: string, options: IOptions): Promise<string> | null;
276
+ captureNextImage(format: string, options: IOptions): Nullable<Promise<string>>;
277
277
 
278
278
  /**
279
279
  *
@@ -297,20 +297,20 @@ export interface vtkOpenGLRenderWindow extends vtkOpenGLRenderWindowBase {
297
297
 
298
298
  /**
299
299
  *
300
- * @param stream
300
+ * @param {vtkViewStream} stream The vtkViewStream instance.
301
301
  */
302
302
  setViewStream(stream: vtkViewStream): boolean;
303
303
 
304
304
  /**
305
305
  *
306
- * @param {Vector2} size
306
+ * @param {Vector2} size
307
307
  */
308
308
  setSize(size: Vector2): void;
309
309
 
310
310
  /**
311
311
  *
312
- * @param {Number} x
313
- * @param {Number} y
312
+ * @param {Number} x
313
+ * @param {Number} y
314
314
  */
315
315
  setSize(x: number, y: number): void;
316
316
 
@@ -520,6 +520,9 @@ function vtkOpenGLVolumeMapper(publicAPI, model) {
520
520
  var size = publicAPI.getRenderTargetSize();
521
521
  program.setUniformf('vpWidth', size[0]);
522
522
  program.setUniformf('vpHeight', size[1]);
523
+ var offset = publicAPI.getRenderTargetOffset();
524
+ program.setUniformf('vpOffsetX', offset[0] / size[0]);
525
+ program.setUniformf('vpOffsetY', offset[1] / size[1]);
523
526
  }
524
527
  }
525
528
 
@@ -688,7 +691,19 @@ function vtkOpenGLVolumeMapper(publicAPI, model) {
688
691
  return [model._smallViewportWidth, model._smallViewportHeight];
689
692
  }
690
693
 
691
- return model.openGLRenderWindow.getFramebufferSize();
694
+ var _model$openGLRenderer = model.openGLRenderer.getTiledSizeAndOrigin(),
695
+ usize = _model$openGLRenderer.usize,
696
+ vsize = _model$openGLRenderer.vsize;
697
+
698
+ return [usize, vsize];
699
+ };
700
+
701
+ publicAPI.getRenderTargetOffset = function () {
702
+ var _model$openGLRenderer2 = model.openGLRenderer.getTiledSizeAndOrigin(),
703
+ lowerLeftU = _model$openGLRenderer2.lowerLeftU,
704
+ lowerLeftV = _model$openGLRenderer2.lowerLeftV;
705
+
706
+ return [lowerLeftU, lowerLeftV];
692
707
  };
693
708
 
694
709
  publicAPI.renderPieceStart = function (ren, actor) {
@@ -1,3 +1,3 @@
1
- var vtkVolumeFS = "//VTK::System::Dec\n\n/*=========================================================================\n\n Program: Visualization Toolkit\n Module: vtkVolumeFS.glsl\n\n Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen\n All rights reserved.\n See Copyright.txt or http://www.kitware.com/Copyright.htm for details.\n\n This software is distributed WITHOUT ANY WARRANTY; without even\n the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR\n PURPOSE. See the above copyright notice for more information.\n\n=========================================================================*/\n// Template for the volume mappers fragment shader\n\n// the output of this shader\n//VTK::Output::Dec\n\nvarying vec3 vertexVCVSOutput;\n\n// first declare the settings from the mapper\n// that impact the code paths in here\n\n// always set vtkNumComponents 1,2,3,4\n//VTK::NumComponents\n\n// possibly define vtkTrilinearOn\n//VTK::TrilinearOn\n\n// possibly define vtkIndependentComponents\n//VTK::IndependentComponentsOn\n\n// possibly define any \"proportional\" components\n//VTK::vtkProportionalComponents\n\n// Define the blend mode to use\n#define vtkBlendMode //VTK::BlendMode\n\n// Possibly define vtkImageLabelOutlineOn\n//VTK::ImageLabelOutlineOn\n\n#ifdef vtkImageLabelOutlineOn\nuniform int outlineThickness;\nuniform float vpWidth;\nuniform float vpHeight;\nuniform mat4 PCWCMatrix;\nuniform mat4 vWCtoIDX;\n#endif\n\n// define vtkLightComplexity\n//VTK::LightComplexity\n#if vtkLightComplexity > 0\nuniform float vSpecularPower;\nuniform float vAmbient;\nuniform float vDiffuse;\nuniform float vSpecular;\n//VTK::Light::Dec\n#endif\n\n// possibly define vtkGradientOpacityOn\n//VTK::GradientOpacityOn\n#ifdef vtkGradientOpacityOn\nuniform float goscale0;\nuniform float goshift0;\nuniform float gomin0;\nuniform float gomax0;\n#if defined(vtkIndependentComponentsOn) && (vtkNumComponents > 1)\nuniform float goscale1;\nuniform float goshift1;\nuniform float gomin1;\nuniform float gomax1;\n#if vtkNumComponents >= 3\nuniform float goscale2;\nuniform float goshift2;\nuniform float gomin2;\nuniform float gomax2;\n#endif\n#if vtkNumComponents >= 4\nuniform float goscale3;\nuniform float goshift3;\nuniform float gomin3;\nuniform float gomax3;\n#endif\n#endif\n#endif\n\n// if you want to see the raw tiled\n// data in webgl1 uncomment the following line\n// #define debugtile\n\n// camera values\nuniform float camThick;\nuniform float camNear;\nuniform float camFar;\nuniform int cameraParallel;\n\n// values describing the volume geometry\nuniform vec3 vOriginVC;\nuniform vec3 vSpacing;\nuniform ivec3 volumeDimensions; // 3d texture dimensions\nuniform vec3 vPlaneNormal0;\nuniform float vPlaneDistance0;\nuniform vec3 vPlaneNormal1;\nuniform float vPlaneDistance1;\nuniform vec3 vPlaneNormal2;\nuniform float vPlaneDistance2;\nuniform vec3 vPlaneNormal3;\nuniform float vPlaneDistance3;\nuniform vec3 vPlaneNormal4;\nuniform float vPlaneDistance4;\nuniform vec3 vPlaneNormal5;\nuniform float vPlaneDistance5;\n\n//VTK::ClipPlane::Dec\n\n// opacity and color textures\nuniform sampler2D otexture;\nuniform float oshift0;\nuniform float oscale0;\nuniform sampler2D ctexture;\nuniform float cshift0;\nuniform float cscale0;\n\n// jitter texture\nuniform sampler2D jtexture;\n\n// some 3D texture values\nuniform float sampleDistance;\nuniform vec3 vVCToIJK;\n\n// the heights defined below are the locations\n// for the up to four components of the tfuns\n// the tfuns have a height of 2XnumComps pixels so the\n// values are computed to hit the middle of the two rows\n// for that component\n#ifdef vtkIndependentComponentsOn\n#if vtkNumComponents == 2\nuniform float mix0;\nuniform float mix1;\n#define height0 0.25\n#define height1 0.75\n#endif\n#if vtkNumComponents == 3\nuniform float mix0;\nuniform float mix1;\nuniform float mix2;\n#define height0 0.17\n#define height1 0.5\n#define height2 0.83\n#endif\n#if vtkNumComponents == 4\nuniform float mix0;\nuniform float mix1;\nuniform float mix2;\nuniform float mix3;\n#define height0 0.125\n#define height1 0.375\n#define height2 0.625\n#define height3 0.875\n#endif\n#endif\n\n#if vtkNumComponents >= 2\nuniform float oshift1;\nuniform float oscale1;\nuniform float cshift1;\nuniform float cscale1;\n#endif\n#if vtkNumComponents >= 3\nuniform float oshift2;\nuniform float oscale2;\nuniform float cshift2;\nuniform float cscale2;\n#endif\n#if vtkNumComponents >= 4\nuniform float oshift3;\nuniform float oscale3;\nuniform float cshift3;\nuniform float cscale3;\n#endif\n\nuniform vec4 ipScalarRangeMin;\nuniform vec4 ipScalarRangeMax;\n\n// declaration for intermixed geometry\n//VTK::ZBuffer::Dec\n\n// Lighting values\n//VTK::Light::Dec\n\n//=======================================================================\n// Webgl2 specific version of functions\n#if __VERSION__ == 300\n\nuniform highp sampler3D texture1;\n\nvec4 getTextureValue(vec3 pos)\n{\n vec4 tmp = texture(texture1, pos);\n#if vtkNumComponents == 1\n tmp.a = tmp.r;\n#endif\n#if vtkNumComponents == 2\n tmp.a = tmp.g;\n#endif\n#if vtkNumComponents == 3\n tmp.a = length(tmp.rgb);\n#endif\n return tmp;\n}\n\n//=======================================================================\n// WebGL1 specific version of functions\n#else\n\nuniform sampler2D texture1;\n\nuniform float texWidth;\nuniform float texHeight;\nuniform int xreps;\nuniform int xstride;\nuniform int ystride;\n\n// if computing trilinear values from multiple z slices\n#ifdef vtkTrilinearOn\nvec4 getTextureValue(vec3 ijk)\n{\n float zoff = 1.0/float(volumeDimensions.z);\n vec4 val1 = getOneTextureValue(ijk);\n vec4 val2 = getOneTextureValue(vec3(ijk.xy, ijk.z + zoff));\n\n float indexZ = float(volumeDimensions)*ijk.z;\n float zmix = indexZ - floor(indexZ);\n\n return mix(val1, val2, zmix);\n}\n\nvec4 getOneTextureValue(vec3 ijk)\n#else // nearest or fast linear\nvec4 getTextureValue(vec3 ijk)\n#endif\n{\n vec3 tdims = vec3(volumeDimensions);\n\n#ifdef debugtile\n vec2 tpos = vec2(ijk.x, ijk.y);\n vec4 tmp = texture2D(texture1, tpos);\n tmp.a = 1.0;\n\n#else\n int z = int(ijk.z * tdims.z);\n int yz = z / xreps;\n int xz = z - yz*xreps;\n\n int tileWidth = volumeDimensions.x/xstride;\n int tileHeight = volumeDimensions.y/ystride;\n\n xz *= tileWidth;\n yz *= tileHeight;\n\n float ni = float(xz) + (ijk.x*float(tileWidth));\n float nj = float(yz) + (ijk.y*float(tileHeight));\n\n vec2 tpos = vec2(ni/texWidth, nj/texHeight);\n\n vec4 tmp = texture2D(texture1, tpos);\n\n#if vtkNumComponents == 1\n tmp.a = tmp.r;\n#endif\n#if vtkNumComponents == 2\n tmp.g = tmp.a;\n#endif\n#if vtkNumComponents == 3\n tmp.a = length(tmp.rgb);\n#endif\n#endif\n\n return tmp;\n}\n\n// End of Webgl1 specific code\n//=======================================================================\n#endif\n\n//=======================================================================\n// compute the normal and gradient magnitude for a position\nvec4 computeNormal(vec3 pos, float scalar, vec3 tstep)\n{\n vec4 result;\n\n result.x = getTextureValue(pos + vec3(tstep.x, 0.0, 0.0)).a - scalar;\n result.y = getTextureValue(pos + vec3(0.0, tstep.y, 0.0)).a - scalar;\n result.z = getTextureValue(pos + vec3(0.0, 0.0, tstep.z)).a - scalar;\n\n // divide by spacing\n result.xyz /= vSpacing;\n\n result.w = length(result.xyz);\n\n // rotate to View Coords\n result.xyz =\n result.x * vPlaneNormal0 +\n result.y * vPlaneNormal2 +\n result.z * vPlaneNormal4;\n\n if (result.w > 0.0)\n {\n result.xyz /= result.w;\n }\n return result;\n}\n\n#ifdef vtkImageLabelOutlineOn\nvec3 fragCoordToIndexSpace(vec4 fragCoord) {\n vec4 pcPos = vec4(\n (fragCoord.x / vpWidth - 0.5) * 2.0,\n (fragCoord.y / vpHeight - 0.5) * 2.0,\n (fragCoord.z - 0.5) * 2.0,\n 1.0);\n\n vec4 worldCoord = PCWCMatrix * pcPos;\n vec4 vertex = (worldCoord/worldCoord.w);\n\n return (vWCtoIDX * vertex).xyz / vec3(volumeDimensions);\n}\n#endif\n\n//=======================================================================\n// compute the normals and gradient magnitudes for a position\n// for independent components\nmat4 computeMat4Normal(vec3 pos, vec4 tValue, vec3 tstep)\n{\n mat4 result;\n vec4 distX = getTextureValue(pos + vec3(tstep.x, 0.0, 0.0)) - tValue;\n vec4 distY = getTextureValue(pos + vec3(0.0, tstep.y, 0.0)) - tValue;\n vec4 distZ = getTextureValue(pos + vec3(0.0, 0.0, tstep.z)) - tValue;\n\n // divide by spacing\n distX /= vSpacing.x;\n distY /= vSpacing.y;\n distZ /= vSpacing.z;\n\n mat3 rot;\n rot[0] = vPlaneNormal0;\n rot[1] = vPlaneNormal2;\n rot[2] = vPlaneNormal4;\n\n#if !defined(vtkComponent0Proportional)\n result[0].xyz = vec3(distX.r, distY.r, distZ.r);\n result[0].a = length(result[0].xyz);\n result[0].xyz *= rot;\n if (result[0].w > 0.0)\n {\n result[0].xyz /= result[0].w;\n }\n#endif\n\n// optionally compute the 2nd component\n#if vtkNumComponents >= 2 && !defined(vtkComponent1Proportional)\n result[1].xyz = vec3(distX.g, distY.g, distZ.g);\n result[1].a = length(result[1].xyz);\n result[1].xyz *= rot;\n if (result[1].w > 0.0)\n {\n result[1].xyz /= result[1].w;\n }\n#endif\n\n// optionally compute the 3rd component\n#if vtkNumComponents >= 3 && !defined(vtkComponent2Proportional)\n result[2].xyz = vec3(distX.b, distY.b, distZ.b);\n result[2].a = length(result[2].xyz);\n result[2].xyz *= rot;\n if (result[2].w > 0.0)\n {\n result[2].xyz /= result[2].w;\n }\n#endif\n\n// optionally compute the 4th component\n#if vtkNumComponents >= 4 && !defined(vtkComponent3Proportional)\n result[3].xyz = vec3(distX.a, distY.a, distZ.a);\n result[3].a = length(result[3].xyz);\n result[3].xyz *= rot;\n if (result[3].w > 0.0)\n {\n result[3].xyz /= result[3].w;\n }\n#endif\n\n return result;\n}\n\n//=======================================================================\n// Given a normal compute the gradient opacity factors\n//\nfloat computeGradientOpacityFactor(\n vec4 normal, float goscale, float goshift, float gomin, float gomax)\n{\n#if defined(vtkGradientOpacityOn)\n return clamp(normal.a*goscale + goshift, gomin, gomax);\n#else\n return 1.0;\n#endif\n}\n\n#if vtkLightComplexity > 0\nvoid applyLighting(inout vec3 tColor, vec4 normal)\n{\n vec3 diffuse = vec3(0.0, 0.0, 0.0);\n vec3 specular = vec3(0.0, 0.0, 0.0);\n //VTK::Light::Impl\n tColor.rgb = tColor.rgb*(diffuse*vDiffuse + vAmbient) + specular*vSpecular;\n}\n#endif\n\n//=======================================================================\n// Given a texture value compute the color and opacity\n//\nvec4 getColorForValue(vec4 tValue, vec3 posIS, vec3 tstep)\n{\n#ifdef vtkImageLabelOutlineOn\n vec3 centerPosIS = fragCoordToIndexSpace(gl_FragCoord); // pos in texture space\n vec4 centerValue = getTextureValue(centerPosIS);\n bool pixelOnBorder = false;\n vec4 tColor = texture2D(ctexture, vec2(centerValue.r * cscale0 + cshift0, 0.5));\n\n // Get alpha of segment from opacity function.\n tColor.a = texture2D(otexture, vec2(centerValue.r * oscale0 + oshift0, 0.5)).r;\n\n // Only perform outline check on fragments rendering voxels that aren't invisible.\n // Saves a bunch of needless checks on the background.\n // TODO define epsilon when building shader?\n if (float(tColor.a) > 0.01) {\n for (int i = -outlineThickness; i <= outlineThickness; i++) {\n for (int j = -outlineThickness; j <= outlineThickness; j++) {\n if (i == 0 || j == 0) {\n continue;\n }\n\n vec4 neighborPixelCoord = vec4(gl_FragCoord.x + float(i),\n gl_FragCoord.y + float(j),\n gl_FragCoord.z, gl_FragCoord.w);\n\n vec3 neighborPosIS = fragCoordToIndexSpace(neighborPixelCoord);\n vec4 value = getTextureValue(neighborPosIS);\n\n // If any of my neighbours are not the same value as I\n // am, this means I am on the border of the segment.\n // We can break the loops\n if (any(notEqual(value, centerValue))) {\n pixelOnBorder = true;\n break;\n }\n }\n\n if (pixelOnBorder == true) {\n break;\n }\n }\n\n // If I am on the border, I am displayed at full opacity\n if (pixelOnBorder == true) {\n tColor.a = 1.0;\n }\n }\n\n#else\n // compute the normal and gradient magnitude if needed\n // We compute it as a vec4 if possible otherwise a mat4\n //\n vec4 goFactor = vec4(1.0,1.0,1.0,1.0);\n\n // compute the normal vectors as needed\n #if (vtkLightComplexity > 0) || defined(vtkGradientOpacityOn)\n #if defined(vtkIndependentComponentsOn) && (vtkNumComponents > 1)\n mat4 normalMat = computeMat4Normal(posIS, tValue, tstep);\n #if !defined(vtkComponent0Proportional)\n vec4 normal0 = normalMat[0];\n #endif\n #if !defined(vtkComponent1Proportional)\n vec4 normal1 = normalMat[1];\n #endif\n #if vtkNumComponents > 2\n #if !defined(vtkComponent2Proportional)\n vec4 normal2 = normalMat[2];\n #endif\n #if vtkNumComponents > 3\n #if !defined(vtkComponent3Proportional)\n vec4 normal3 = normalMat[3];\n #endif\n #endif\n #endif\n #else\n vec4 normal0 = computeNormal(posIS, tValue.a, tstep);\n #endif\n #endif\n\n // compute gradient opacity factors as needed\n #if defined(vtkGradientOpacityOn)\n #if !defined(vtkComponent0Proportional)\n goFactor.x =\n computeGradientOpacityFactor(normal0, goscale0, goshift0, gomin0, gomax0);\n #endif\n #if defined(vtkIndependentComponentsOn) && (vtkNumComponents > 1)\n #if !defined(vtkComponent1Proportional)\n goFactor.y =\n computeGradientOpacityFactor(normal1, goscale1, goshift1, gomin1, gomax1);\n #endif\n #if vtkNumComponents > 2\n #if !defined(vtkComponent2Proportional)\n goFactor.z =\n computeGradientOpacityFactor(normal2, goscale2, goshift2, gomin2, gomax2);\n #endif\n #if vtkNumComponents > 3\n #if !defined(vtkComponent3Proportional)\n goFactor.w =\n computeGradientOpacityFactor(normal3, goscale3, goshift3, gomin3, gomax3);\n #endif\n #endif\n #endif\n #endif\n #endif\n\n // single component is always independent\n #if vtkNumComponents == 1\n vec4 tColor = texture2D(ctexture, vec2(tValue.r * cscale0 + cshift0, 0.5));\n tColor.a = goFactor.x*texture2D(otexture, vec2(tValue.r * oscale0 + oshift0, 0.5)).r;\n #endif\n\n #if defined(vtkIndependentComponentsOn) && vtkNumComponents >= 2\n vec4 tColor = mix0*texture2D(ctexture, vec2(tValue.r * cscale0 + cshift0, height0));\n #if !defined(vtkComponent0Proportional)\n tColor.a = goFactor.x*mix0*texture2D(otexture, vec2(tValue.r * oscale0 + oshift0, height0)).r;\n #else\n float pwfValue = texture2D(otexture, vec2(tValue.r * oscale0 + oshift0, height0)).r;\n tColor *= pwfValue;\n tColor.a *= mix(pwfValue, 1.0, (1.0 - mix0));\n #endif\n\n vec3 tColor1 = mix1*texture2D(ctexture, vec2(tValue.g * cscale1 + cshift1, height1)).rgb;\n #if !defined(vtkComponent1Proportional)\n tColor.a += goFactor.y*mix1*texture2D(otexture, vec2(tValue.g * oscale1 + oshift1, height1)).r;\n #else\n float pwfValue = texture2D(otexture, vec2(tValue.g * oscale1 + oshift1, height1)).r;\n tColor1 *= pwfValue;\n tColor.a *= mix(pwfValue, 1.0, (1.0 - mix1));\n #endif\n\n #if vtkNumComponents >= 3\n vec3 tColor2 = mix2*texture2D(ctexture, vec2(tValue.b * cscale2 + cshift2, height2)).rgb;\n #if !defined(vtkComponent2Proportional)\n tColor.a += goFactor.z*mix2*texture2D(otexture, vec2(tValue.b * oscale2 + oshift2, height2)).r;\n #else\n float pwfValue = texture2D(otexture, vec2(tValue.b * oscale2 + oshift2, height2)).r;\n tColor2 *= pwfValue;\n tColor.a *= mix(pwfValue, 1.0, (1.0 - mix2));\n #endif\n\n #if vtkNumComponents >= 4\n vec3 tColor3 = mix3*texture2D(ctexture, vec2(tValue.a * cscale3 + cshift3, height3)).rgb;\n #if !defined(vtkComponent3Proportional)\n tColor.a += goFactor.w*mix3*texture2D(otexture, vec2(tValue.a * oscale3 + oshift3, height3)).r;\n #else\n float pwfValue = texture2D(otexture, vec2(tValue.a * oscale3 + oshift3, height3)).r;\n tColor3 *= pwfValue;\n tColor.a *= mix(pwfValue, 1.0, (1.0 - mix3));\n #endif\n #endif\n #endif\n #else // then not independent\n\n #if vtkNumComponents == 2\n float lum = tValue.r * cscale0 + cshift0;\n float alpha = goFactor.x*texture2D(otexture, vec2(tValue.a * oscale1 + oshift1, 0.5)).r;\n vec4 tColor = vec4(lum, lum, lum, alpha);\n #endif\n #if vtkNumComponents == 3\n vec4 tColor;\n tColor.r = tValue.r * cscale0 + cshift0;\n tColor.g = tValue.g * cscale1 + cshift1;\n tColor.b = tValue.b * cscale2 + cshift2;\n tColor.a = goFactor.x*texture2D(otexture, vec2(tValue.a * oscale0 + oshift0, 0.5)).r;\n #endif\n #if vtkNumComponents == 4\n vec4 tColor;\n tColor.r = tValue.r * cscale0 + cshift0;\n tColor.g = tValue.g * cscale1 + cshift1;\n tColor.b = tValue.b * cscale2 + cshift2;\n tColor.a = goFactor.x*texture2D(otexture, vec2(tValue.a * oscale3 + oshift3, 0.5)).r;\n #endif\n #endif // dependent\n\n // apply lighting if requested as appropriate\n #if vtkLightComplexity > 0\n #if !defined(vtkComponent0Proportional)\n applyLighting(tColor.rgb, normal0);\n #endif\n #if defined(vtkIndependentComponentsOn) && vtkNumComponents >= 2\n #if !defined(vtkComponent1Proportional)\n applyLighting(tColor1, normal1);\n #endif\n #if vtkNumComponents >= 3\n #if !defined(vtkComponent2Proportional)\n applyLighting(tColor2, normal2);\n #endif\n #if vtkNumComponents >= 4\n #if !defined(vtkComponent3Proportional)\n applyLighting(tColor3, normal3);\n #endif\n #endif\n #endif\n #endif\n#endif\n\n// perform final independent blend as needed\n#if defined(vtkIndependentComponentsOn) && vtkNumComponents >= 2\n tColor.rgb += tColor1;\n#if vtkNumComponents >= 3\n tColor.rgb += tColor2;\n#if vtkNumComponents >= 4\n tColor.rgb += tColor3;\n#endif\n#endif\n#endif\n\n#endif\n\n\n\n\n\n\n\nreturn tColor;\n}\n\nbool valueWithinScalarRange(vec4 val, vec4 min, vec4 max) {\n bool withinRange = false;\n #if vtkNumComponents == 1\n if (val.r >= min.r && val.r <= max.r) {\n withinRange = true;\n }\n #endif\n #if defined(vtkIndependentComponentsOn) && vtkNumComponents == 2\n if (val.r >= min.r && val.r <= max.r &&\n val.g >= min.g && val.g <= max.g) {\n withinRange = true;\n }\n #endif\n #if defined(vtkIndependentComponentsOn) && vtkNumComponents >= 3\n if (all(greaterThanEqual(val, ipScalarRangeMin)) &&\n all(lessThanEqual(val, ipScalarRangeMax))) {\n withinRange = true;\n }\n #endif\n return withinRange;\n}\n\n//=======================================================================\n// Apply the specified blend mode operation along the ray's path.\n//\nvoid applyBlend(vec3 posIS, vec3 endIS, float sampleDistanceIS, vec3 tdims)\n{\n vec3 tstep = 1.0/tdims;\n\n // start slightly inside and apply some jitter\n vec3 delta = endIS - posIS;\n vec3 stepIS = normalize(delta)*sampleDistanceIS;\n float raySteps = length(delta)/sampleDistanceIS;\n\n // avoid 0.0 jitter\n float jitter = 0.01 + 0.99*texture2D(jtexture, gl_FragCoord.xy/32.0).r;\n float stepsTraveled = jitter;\n\n // local vars for the loop\n vec4 color = vec4(0.0, 0.0, 0.0, 0.0);\n vec4 tValue;\n vec4 tColor;\n\n // if we have less than one step then pick the middle point\n // as our value\n // if (raySteps <= 1.0)\n // {\n // posIS = (posIS + endIS)*0.5;\n // }\n\n // Perform initial step at the volume boundary\n // compute the scalar\n tValue = getTextureValue(posIS);\n\n #if vtkBlendMode == 0 // COMPOSITE_BLEND\n // now map through opacity and color\n tColor = getColorForValue(tValue, posIS, tstep);\n\n // handle very thin volumes\n if (raySteps <= 1.0)\n {\n tColor.a = 1.0 - pow(1.0 - tColor.a, raySteps);\n gl_FragData[0] = tColor;\n return;\n }\n\n tColor.a = 1.0 - pow(1.0 - tColor.a, jitter);\n color = vec4(tColor.rgb*tColor.a, tColor.a);\n posIS += (jitter*stepIS);\n\n for (int i = 0; i < //VTK::MaximumSamplesValue ; ++i)\n {\n if (stepsTraveled + 1.0 >= raySteps) { break; }\n\n // compute the scalar\n tValue = getTextureValue(posIS);\n\n // now map through opacity and color\n tColor = getColorForValue(tValue, posIS, tstep);\n\n float mix = (1.0 - color.a);\n\n // this line should not be needed but nvidia seems to not handle\n // the break correctly on windows/chrome 58 angle\n //mix = mix * sign(max(raySteps - stepsTraveled - 1.0, 0.0));\n\n color = color + vec4(tColor.rgb*tColor.a, tColor.a)*mix;\n stepsTraveled++;\n posIS += stepIS;\n if (color.a > 0.99) { color.a = 1.0; break; }\n }\n\n if (color.a < 0.99 && (raySteps - stepsTraveled) > 0.0)\n {\n posIS = endIS;\n\n // compute the scalar\n tValue = getTextureValue(posIS);\n\n // now map through opacity and color\n tColor = getColorForValue(tValue, posIS, tstep);\n tColor.a = 1.0 - pow(1.0 - tColor.a, raySteps - stepsTraveled);\n\n float mix = (1.0 - color.a);\n color = color + vec4(tColor.rgb*tColor.a, tColor.a)*mix;\n }\n\n gl_FragData[0] = vec4(color.rgb/color.a, color.a);\n #endif\n #if vtkBlendMode == 1 || vtkBlendMode == 2\n // MAXIMUM_INTENSITY_BLEND || MINIMUM_INTENSITY_BLEND\n // Find maximum/minimum intensity along the ray.\n\n // Define the operation we will use (min or max)\n #if vtkBlendMode == 1\n #define OP max\n #else\n #define OP min\n #endif\n\n // If the clipping range is shorter than the sample distance\n // we can skip the sampling loop along the ray.\n if (raySteps <= 1.0)\n {\n gl_FragData[0] = getColorForValue(tValue, posIS, tstep);\n return;\n }\n\n vec4 value = tValue;\n posIS += (jitter*stepIS);\n\n // Sample along the ray until MaximumSamplesValue,\n // ending slightly inside the total distance\n for (int i = 0; i < //VTK::MaximumSamplesValue ; ++i)\n {\n // If we have reached the last step, break\n if (stepsTraveled + 1.0 >= raySteps) { break; }\n\n // compute the scalar\n tValue = getTextureValue(posIS);\n\n // Update the maximum value if necessary\n value = OP(tValue, value);\n\n // Otherwise, continue along the ray\n stepsTraveled++;\n posIS += stepIS;\n }\n\n // Perform the last step along the ray using the\n // residual distance\n posIS = endIS;\n tValue = getTextureValue(posIS);\n value = OP(tValue, value);\n\n // Now map through opacity and color\n gl_FragData[0] = getColorForValue(value, posIS, tstep);\n #endif\n #if vtkBlendMode == 3 || vtkBlendMode == 4 //AVERAGE_INTENSITY_BLEND || ADDITIVE_BLEND\n vec4 sum = vec4(0.);\n\n if (valueWithinScalarRange(tValue, ipScalarRangeMin, ipScalarRangeMax)) {\n sum += tValue;\n }\n\n if (raySteps <= 1.0) {\n gl_FragData[0] = getColorForValue(sum, posIS, tstep);\n return;\n }\n\n posIS += (jitter*stepIS);\n\n // Sample along the ray until MaximumSamplesValue,\n // ending slightly inside the total distance\n for (int i = 0; i < //VTK::MaximumSamplesValue ; ++i)\n {\n // If we have reached the last step, break\n if (stepsTraveled + 1.0 >= raySteps) { break; }\n\n // compute the scalar\n tValue = getTextureValue(posIS);\n\n // One can control the scalar range by setting the AverageIPScalarRange to disregard scalar values, not in the range of interest, from the average computation.\n // Notes:\n // - We are comparing all values in the texture to see if any of them\n // are outside of the scalar range. In the future we might want to allow\n // scalar ranges for each component.\n if (valueWithinScalarRange(tValue, ipScalarRangeMin, ipScalarRangeMax)) {\n // Sum the values across each step in the path\n sum += tValue;\n }\n stepsTraveled++;\n posIS += stepIS;\n }\n\n // Perform the last step along the ray using the\n // residual distance\n posIS = endIS;\n\n // compute the scalar\n tValue = getTextureValue(posIS);\n\n // One can control the scalar range by setting the IPScalarRange to disregard scalar values, not in the range of interest, from the average computation\n if (valueWithinScalarRange(tValue, ipScalarRangeMin, ipScalarRangeMax)) {\n sum += tValue;\n\n stepsTraveled++;\n }\n\n #if vtkBlendMode == 3 // Average\n sum /= vec4(stepsTraveled, stepsTraveled, stepsTraveled, 1.0);\n #endif\n\n gl_FragData[0] = getColorForValue(sum, posIS, tstep);\n #endif\n}\n\n//=======================================================================\n// Compute a new start and end point for a given ray based\n// on the provided bounded clipping plane (aka a rectangle)\nvoid getRayPointIntersectionBounds(\n vec3 rayPos, vec3 rayDir,\n vec3 planeDir, float planeDist,\n inout vec2 tbounds, vec3 vPlaneX, vec3 vPlaneY,\n float vSize1, float vSize2)\n{\n float result = dot(rayDir, planeDir);\n if (abs(result) < 1e-6)\n {\n return;\n }\n result = -1.0 * (dot(rayPos, planeDir) + planeDist) / result;\n vec3 xposVC = rayPos + rayDir*result;\n vec3 vxpos = xposVC - vOriginVC;\n vec2 vpos = vec2(\n dot(vxpos, vPlaneX),\n dot(vxpos, vPlaneY));\n\n // on some apple nvidia systems this does not work\n // if (vpos.x < 0.0 || vpos.x > vSize1 ||\n // vpos.y < 0.0 || vpos.y > vSize2)\n // even just\n // if (vpos.x < 0.0 || vpos.y < 0.0)\n // fails\n // so instead we compute a value that represents in and out\n //and then compute the return using this value\n float xcheck = max(0.0, vpos.x * (vpos.x - vSize1)); // 0 means in bounds\n float check = sign(max(xcheck, vpos.y * (vpos.y - vSize2))); // 0 means in bounds, 1 = out\n\n tbounds = mix(\n vec2(min(tbounds.x, result), max(tbounds.y, result)), // in value\n tbounds, // out value\n check); // 0 in 1 out\n}\n\n//=======================================================================\n// given a\n// - ray direction (rayDir)\n// - starting point (vertexVCVSOutput)\n// - bounding planes of the volume\n// - optionally depth buffer values\n// - far clipping plane\n// compute the start/end distances of the ray we need to cast\nvec2 computeRayDistances(vec3 rayDir, vec3 tdims)\n{\n vec2 dists = vec2(100.0*camFar, -1.0);\n\n vec3 vSize = vSpacing*(tdims - 1.0);\n\n // all this is in View Coordinates\n getRayPointIntersectionBounds(vertexVCVSOutput, rayDir,\n vPlaneNormal0, vPlaneDistance0, dists, vPlaneNormal2, vPlaneNormal4,\n vSize.y, vSize.z);\n getRayPointIntersectionBounds(vertexVCVSOutput, rayDir,\n vPlaneNormal1, vPlaneDistance1, dists, vPlaneNormal2, vPlaneNormal4,\n vSize.y, vSize.z);\n getRayPointIntersectionBounds(vertexVCVSOutput, rayDir,\n vPlaneNormal2, vPlaneDistance2, dists, vPlaneNormal0, vPlaneNormal4,\n vSize.x, vSize.z);\n getRayPointIntersectionBounds(vertexVCVSOutput, rayDir,\n vPlaneNormal3, vPlaneDistance3, dists, vPlaneNormal0, vPlaneNormal4,\n vSize.x, vSize.z);\n getRayPointIntersectionBounds(vertexVCVSOutput, rayDir,\n vPlaneNormal4, vPlaneDistance4, dists, vPlaneNormal0, vPlaneNormal2,\n vSize.x, vSize.y);\n getRayPointIntersectionBounds(vertexVCVSOutput, rayDir,\n vPlaneNormal5, vPlaneDistance5, dists, vPlaneNormal0, vPlaneNormal2,\n vSize.x, vSize.y);\n\n //VTK::ClipPlane::Impl\n\n // do not go behind front clipping plane\n dists.x = max(0.0,dists.x);\n\n // do not go PAST far clipping plane\n float farDist = -camThick/rayDir.z;\n dists.y = min(farDist,dists.y);\n\n // Do not go past the zbuffer value if set\n // This is used for intermixing opaque geometry\n //VTK::ZBuffer::Impl\n\n return dists;\n}\n\n//=======================================================================\n// Compute the index space starting position (pos) and end\n// position\n//\nvoid computeIndexSpaceValues(out vec3 pos, out vec3 endPos, out float sampleDistanceIS, vec3 rayDir, vec2 dists)\n{\n // compute starting and ending values in volume space\n pos = vertexVCVSOutput + dists.x*rayDir;\n pos = pos - vOriginVC;\n // convert to volume basis and origin\n pos = vec3(\n dot(pos, vPlaneNormal0),\n dot(pos, vPlaneNormal2),\n dot(pos, vPlaneNormal4));\n\n endPos = vertexVCVSOutput + dists.y*rayDir;\n endPos = endPos - vOriginVC;\n endPos = vec3(\n dot(endPos, vPlaneNormal0),\n dot(endPos, vPlaneNormal2),\n dot(endPos, vPlaneNormal4));\n\n float delta = length(endPos - pos);\n\n pos *= vVCToIJK;\n endPos *= vVCToIJK;\n\n float delta2 = length(endPos - pos);\n sampleDistanceIS = sampleDistance*delta2/delta;\n}\n\nvoid main()\n{\n\n vec3 rayDirVC;\n\n if (cameraParallel == 1)\n {\n // Camera is parallel, so the rayDir is just the direction of the camera.\n rayDirVC = vec3(0.0, 0.0, -1.0);\n } else {\n // camera is at 0,0,0 so rayDir for perspective is just the vc coord\n rayDirVC = normalize(vertexVCVSOutput);\n }\n\n vec3 tdims = vec3(volumeDimensions);\n\n // compute the start and end points for the ray\n vec2 rayStartEndDistancesVC = computeRayDistances(rayDirVC, tdims);\n\n // do we need to composite? aka does the ray have any length\n // If not, bail out early\n if (rayStartEndDistancesVC.y <= rayStartEndDistancesVC.x)\n {\n discard;\n }\n\n // IS = Index Space\n vec3 posIS;\n vec3 endIS;\n float sampleDistanceIS;\n computeIndexSpaceValues(posIS, endIS, sampleDistanceIS, rayDirVC, rayStartEndDistancesVC);\n\n // Perform the blending operation along the ray\n applyBlend(posIS, endIS, sampleDistanceIS, tdims);\n}\n";
1
+ var vtkVolumeFS = "//VTK::System::Dec\n\n/*=========================================================================\n\n Program: Visualization Toolkit\n Module: vtkVolumeFS.glsl\n\n Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen\n All rights reserved.\n See Copyright.txt or http://www.kitware.com/Copyright.htm for details.\n\n This software is distributed WITHOUT ANY WARRANTY; without even\n the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR\n PURPOSE. See the above copyright notice for more information.\n\n=========================================================================*/\n// Template for the volume mappers fragment shader\n\n// the output of this shader\n//VTK::Output::Dec\n\nvarying vec3 vertexVCVSOutput;\n\n// first declare the settings from the mapper\n// that impact the code paths in here\n\n// always set vtkNumComponents 1,2,3,4\n//VTK::NumComponents\n\n// possibly define vtkTrilinearOn\n//VTK::TrilinearOn\n\n// possibly define vtkIndependentComponents\n//VTK::IndependentComponentsOn\n\n// possibly define any \"proportional\" components\n//VTK::vtkProportionalComponents\n\n// Define the blend mode to use\n#define vtkBlendMode //VTK::BlendMode\n\n// Possibly define vtkImageLabelOutlineOn\n//VTK::ImageLabelOutlineOn\n\n#ifdef vtkImageLabelOutlineOn\nuniform int outlineThickness;\nuniform float vpWidth;\nuniform float vpHeight;\nuniform float vpOffsetX;\nuniform float vpOffsetY;\nuniform mat4 PCWCMatrix;\nuniform mat4 vWCtoIDX;\n#endif\n\n// define vtkLightComplexity\n//VTK::LightComplexity\n#if vtkLightComplexity > 0\nuniform float vSpecularPower;\nuniform float vAmbient;\nuniform float vDiffuse;\nuniform float vSpecular;\n//VTK::Light::Dec\n#endif\n\n// possibly define vtkGradientOpacityOn\n//VTK::GradientOpacityOn\n#ifdef vtkGradientOpacityOn\nuniform float goscale0;\nuniform float goshift0;\nuniform float gomin0;\nuniform float gomax0;\n#if defined(vtkIndependentComponentsOn) && (vtkNumComponents > 1)\nuniform float goscale1;\nuniform float goshift1;\nuniform float gomin1;\nuniform float gomax1;\n#if vtkNumComponents >= 3\nuniform float goscale2;\nuniform float goshift2;\nuniform float gomin2;\nuniform float gomax2;\n#endif\n#if vtkNumComponents >= 4\nuniform float goscale3;\nuniform float goshift3;\nuniform float gomin3;\nuniform float gomax3;\n#endif\n#endif\n#endif\n\n// if you want to see the raw tiled\n// data in webgl1 uncomment the following line\n// #define debugtile\n\n// camera values\nuniform float camThick;\nuniform float camNear;\nuniform float camFar;\nuniform int cameraParallel;\n\n// values describing the volume geometry\nuniform vec3 vOriginVC;\nuniform vec3 vSpacing;\nuniform ivec3 volumeDimensions; // 3d texture dimensions\nuniform vec3 vPlaneNormal0;\nuniform float vPlaneDistance0;\nuniform vec3 vPlaneNormal1;\nuniform float vPlaneDistance1;\nuniform vec3 vPlaneNormal2;\nuniform float vPlaneDistance2;\nuniform vec3 vPlaneNormal3;\nuniform float vPlaneDistance3;\nuniform vec3 vPlaneNormal4;\nuniform float vPlaneDistance4;\nuniform vec3 vPlaneNormal5;\nuniform float vPlaneDistance5;\n\n//VTK::ClipPlane::Dec\n\n// opacity and color textures\nuniform sampler2D otexture;\nuniform float oshift0;\nuniform float oscale0;\nuniform sampler2D ctexture;\nuniform float cshift0;\nuniform float cscale0;\n\n// jitter texture\nuniform sampler2D jtexture;\n\n// some 3D texture values\nuniform float sampleDistance;\nuniform vec3 vVCToIJK;\n\n// the heights defined below are the locations\n// for the up to four components of the tfuns\n// the tfuns have a height of 2XnumComps pixels so the\n// values are computed to hit the middle of the two rows\n// for that component\n#ifdef vtkIndependentComponentsOn\n#if vtkNumComponents == 2\nuniform float mix0;\nuniform float mix1;\n#define height0 0.25\n#define height1 0.75\n#endif\n#if vtkNumComponents == 3\nuniform float mix0;\nuniform float mix1;\nuniform float mix2;\n#define height0 0.17\n#define height1 0.5\n#define height2 0.83\n#endif\n#if vtkNumComponents == 4\nuniform float mix0;\nuniform float mix1;\nuniform float mix2;\nuniform float mix3;\n#define height0 0.125\n#define height1 0.375\n#define height2 0.625\n#define height3 0.875\n#endif\n#endif\n\n#if vtkNumComponents >= 2\nuniform float oshift1;\nuniform float oscale1;\nuniform float cshift1;\nuniform float cscale1;\n#endif\n#if vtkNumComponents >= 3\nuniform float oshift2;\nuniform float oscale2;\nuniform float cshift2;\nuniform float cscale2;\n#endif\n#if vtkNumComponents >= 4\nuniform float oshift3;\nuniform float oscale3;\nuniform float cshift3;\nuniform float cscale3;\n#endif\n\nuniform vec4 ipScalarRangeMin;\nuniform vec4 ipScalarRangeMax;\n\n// declaration for intermixed geometry\n//VTK::ZBuffer::Dec\n\n// Lighting values\n//VTK::Light::Dec\n\n//=======================================================================\n// Webgl2 specific version of functions\n#if __VERSION__ == 300\n\nuniform highp sampler3D texture1;\n\nvec4 getTextureValue(vec3 pos)\n{\n vec4 tmp = texture(texture1, pos);\n#if vtkNumComponents == 1\n tmp.a = tmp.r;\n#endif\n#if vtkNumComponents == 2\n tmp.a = tmp.g;\n#endif\n#if vtkNumComponents == 3\n tmp.a = length(tmp.rgb);\n#endif\n return tmp;\n}\n\n//=======================================================================\n// WebGL1 specific version of functions\n#else\n\nuniform sampler2D texture1;\n\nuniform float texWidth;\nuniform float texHeight;\nuniform int xreps;\nuniform int xstride;\nuniform int ystride;\n\n// if computing trilinear values from multiple z slices\n#ifdef vtkTrilinearOn\nvec4 getTextureValue(vec3 ijk)\n{\n float zoff = 1.0/float(volumeDimensions.z);\n vec4 val1 = getOneTextureValue(ijk);\n vec4 val2 = getOneTextureValue(vec3(ijk.xy, ijk.z + zoff));\n\n float indexZ = float(volumeDimensions)*ijk.z;\n float zmix = indexZ - floor(indexZ);\n\n return mix(val1, val2, zmix);\n}\n\nvec4 getOneTextureValue(vec3 ijk)\n#else // nearest or fast linear\nvec4 getTextureValue(vec3 ijk)\n#endif\n{\n vec3 tdims = vec3(volumeDimensions);\n\n#ifdef debugtile\n vec2 tpos = vec2(ijk.x, ijk.y);\n vec4 tmp = texture2D(texture1, tpos);\n tmp.a = 1.0;\n\n#else\n int z = int(ijk.z * tdims.z);\n int yz = z / xreps;\n int xz = z - yz*xreps;\n\n int tileWidth = volumeDimensions.x/xstride;\n int tileHeight = volumeDimensions.y/ystride;\n\n xz *= tileWidth;\n yz *= tileHeight;\n\n float ni = float(xz) + (ijk.x*float(tileWidth));\n float nj = float(yz) + (ijk.y*float(tileHeight));\n\n vec2 tpos = vec2(ni/texWidth, nj/texHeight);\n\n vec4 tmp = texture2D(texture1, tpos);\n\n#if vtkNumComponents == 1\n tmp.a = tmp.r;\n#endif\n#if vtkNumComponents == 2\n tmp.g = tmp.a;\n#endif\n#if vtkNumComponents == 3\n tmp.a = length(tmp.rgb);\n#endif\n#endif\n\n return tmp;\n}\n\n// End of Webgl1 specific code\n//=======================================================================\n#endif\n\n//=======================================================================\n// compute the normal and gradient magnitude for a position\nvec4 computeNormal(vec3 pos, float scalar, vec3 tstep)\n{\n vec4 result;\n\n result.x = getTextureValue(pos + vec3(tstep.x, 0.0, 0.0)).a - scalar;\n result.y = getTextureValue(pos + vec3(0.0, tstep.y, 0.0)).a - scalar;\n result.z = getTextureValue(pos + vec3(0.0, 0.0, tstep.z)).a - scalar;\n\n // divide by spacing\n result.xyz /= vSpacing;\n\n result.w = length(result.xyz);\n\n // rotate to View Coords\n result.xyz =\n result.x * vPlaneNormal0 +\n result.y * vPlaneNormal2 +\n result.z * vPlaneNormal4;\n\n if (result.w > 0.0)\n {\n result.xyz /= result.w;\n }\n return result;\n}\n\n#ifdef vtkImageLabelOutlineOn\nvec3 fragCoordToIndexSpace(vec4 fragCoord) {\n vec4 pcPos = vec4(\n (fragCoord.x / vpWidth - vpOffsetX - 0.5) * 2.0,\n (fragCoord.y / vpHeight - vpOffsetY - 0.5) * 2.0,\n (fragCoord.z - 0.5) * 2.0,\n 1.0);\n\n vec4 worldCoord = PCWCMatrix * pcPos;\n vec4 vertex = (worldCoord/worldCoord.w);\n\n return (vWCtoIDX * vertex).xyz / vec3(volumeDimensions);\n}\n#endif\n\n//=======================================================================\n// compute the normals and gradient magnitudes for a position\n// for independent components\nmat4 computeMat4Normal(vec3 pos, vec4 tValue, vec3 tstep)\n{\n mat4 result;\n vec4 distX = getTextureValue(pos + vec3(tstep.x, 0.0, 0.0)) - tValue;\n vec4 distY = getTextureValue(pos + vec3(0.0, tstep.y, 0.0)) - tValue;\n vec4 distZ = getTextureValue(pos + vec3(0.0, 0.0, tstep.z)) - tValue;\n\n // divide by spacing\n distX /= vSpacing.x;\n distY /= vSpacing.y;\n distZ /= vSpacing.z;\n\n mat3 rot;\n rot[0] = vPlaneNormal0;\n rot[1] = vPlaneNormal2;\n rot[2] = vPlaneNormal4;\n\n#if !defined(vtkComponent0Proportional)\n result[0].xyz = vec3(distX.r, distY.r, distZ.r);\n result[0].a = length(result[0].xyz);\n result[0].xyz *= rot;\n if (result[0].w > 0.0)\n {\n result[0].xyz /= result[0].w;\n }\n#endif\n\n// optionally compute the 2nd component\n#if vtkNumComponents >= 2 && !defined(vtkComponent1Proportional)\n result[1].xyz = vec3(distX.g, distY.g, distZ.g);\n result[1].a = length(result[1].xyz);\n result[1].xyz *= rot;\n if (result[1].w > 0.0)\n {\n result[1].xyz /= result[1].w;\n }\n#endif\n\n// optionally compute the 3rd component\n#if vtkNumComponents >= 3 && !defined(vtkComponent2Proportional)\n result[2].xyz = vec3(distX.b, distY.b, distZ.b);\n result[2].a = length(result[2].xyz);\n result[2].xyz *= rot;\n if (result[2].w > 0.0)\n {\n result[2].xyz /= result[2].w;\n }\n#endif\n\n// optionally compute the 4th component\n#if vtkNumComponents >= 4 && !defined(vtkComponent3Proportional)\n result[3].xyz = vec3(distX.a, distY.a, distZ.a);\n result[3].a = length(result[3].xyz);\n result[3].xyz *= rot;\n if (result[3].w > 0.0)\n {\n result[3].xyz /= result[3].w;\n }\n#endif\n\n return result;\n}\n\n//=======================================================================\n// Given a normal compute the gradient opacity factors\n//\nfloat computeGradientOpacityFactor(\n vec4 normal, float goscale, float goshift, float gomin, float gomax)\n{\n#if defined(vtkGradientOpacityOn)\n return clamp(normal.a*goscale + goshift, gomin, gomax);\n#else\n return 1.0;\n#endif\n}\n\n#if vtkLightComplexity > 0\nvoid applyLighting(inout vec3 tColor, vec4 normal)\n{\n vec3 diffuse = vec3(0.0, 0.0, 0.0);\n vec3 specular = vec3(0.0, 0.0, 0.0);\n //VTK::Light::Impl\n tColor.rgb = tColor.rgb*(diffuse*vDiffuse + vAmbient) + specular*vSpecular;\n}\n#endif\n\n//=======================================================================\n// Given a texture value compute the color and opacity\n//\nvec4 getColorForValue(vec4 tValue, vec3 posIS, vec3 tstep)\n{\n#ifdef vtkImageLabelOutlineOn\n vec3 centerPosIS = fragCoordToIndexSpace(gl_FragCoord); // pos in texture space\n vec4 centerValue = getTextureValue(centerPosIS);\n bool pixelOnBorder = false;\n vec4 tColor = texture2D(ctexture, vec2(centerValue.r * cscale0 + cshift0, 0.5));\n\n // Get alpha of segment from opacity function.\n tColor.a = texture2D(otexture, vec2(centerValue.r * oscale0 + oshift0, 0.5)).r;\n\n // Only perform outline check on fragments rendering voxels that aren't invisible.\n // Saves a bunch of needless checks on the background.\n // TODO define epsilon when building shader?\n if (float(tColor.a) > 0.01) {\n for (int i = -outlineThickness; i <= outlineThickness; i++) {\n for (int j = -outlineThickness; j <= outlineThickness; j++) {\n if (i == 0 || j == 0) {\n continue;\n }\n\n vec4 neighborPixelCoord = vec4(gl_FragCoord.x + float(i),\n gl_FragCoord.y + float(j),\n gl_FragCoord.z, gl_FragCoord.w);\n\n vec3 neighborPosIS = fragCoordToIndexSpace(neighborPixelCoord);\n vec4 value = getTextureValue(neighborPosIS);\n\n // If any of my neighbours are not the same value as I\n // am, this means I am on the border of the segment.\n // We can break the loops\n if (any(notEqual(value, centerValue))) {\n pixelOnBorder = true;\n break;\n }\n }\n\n if (pixelOnBorder == true) {\n break;\n }\n }\n\n // If I am on the border, I am displayed at full opacity\n if (pixelOnBorder == true) {\n tColor.a = 1.0;\n }\n }\n\n#else\n // compute the normal and gradient magnitude if needed\n // We compute it as a vec4 if possible otherwise a mat4\n //\n vec4 goFactor = vec4(1.0,1.0,1.0,1.0);\n\n // compute the normal vectors as needed\n #if (vtkLightComplexity > 0) || defined(vtkGradientOpacityOn)\n #if defined(vtkIndependentComponentsOn) && (vtkNumComponents > 1)\n mat4 normalMat = computeMat4Normal(posIS, tValue, tstep);\n #if !defined(vtkComponent0Proportional)\n vec4 normal0 = normalMat[0];\n #endif\n #if !defined(vtkComponent1Proportional)\n vec4 normal1 = normalMat[1];\n #endif\n #if vtkNumComponents > 2\n #if !defined(vtkComponent2Proportional)\n vec4 normal2 = normalMat[2];\n #endif\n #if vtkNumComponents > 3\n #if !defined(vtkComponent3Proportional)\n vec4 normal3 = normalMat[3];\n #endif\n #endif\n #endif\n #else\n vec4 normal0 = computeNormal(posIS, tValue.a, tstep);\n #endif\n #endif\n\n // compute gradient opacity factors as needed\n #if defined(vtkGradientOpacityOn)\n #if !defined(vtkComponent0Proportional)\n goFactor.x =\n computeGradientOpacityFactor(normal0, goscale0, goshift0, gomin0, gomax0);\n #endif\n #if defined(vtkIndependentComponentsOn) && (vtkNumComponents > 1)\n #if !defined(vtkComponent1Proportional)\n goFactor.y =\n computeGradientOpacityFactor(normal1, goscale1, goshift1, gomin1, gomax1);\n #endif\n #if vtkNumComponents > 2\n #if !defined(vtkComponent2Proportional)\n goFactor.z =\n computeGradientOpacityFactor(normal2, goscale2, goshift2, gomin2, gomax2);\n #endif\n #if vtkNumComponents > 3\n #if !defined(vtkComponent3Proportional)\n goFactor.w =\n computeGradientOpacityFactor(normal3, goscale3, goshift3, gomin3, gomax3);\n #endif\n #endif\n #endif\n #endif\n #endif\n\n // single component is always independent\n #if vtkNumComponents == 1\n vec4 tColor = texture2D(ctexture, vec2(tValue.r * cscale0 + cshift0, 0.5));\n tColor.a = goFactor.x*texture2D(otexture, vec2(tValue.r * oscale0 + oshift0, 0.5)).r;\n #endif\n\n #if defined(vtkIndependentComponentsOn) && vtkNumComponents >= 2\n vec4 tColor = mix0*texture2D(ctexture, vec2(tValue.r * cscale0 + cshift0, height0));\n #if !defined(vtkComponent0Proportional)\n tColor.a = goFactor.x*mix0*texture2D(otexture, vec2(tValue.r * oscale0 + oshift0, height0)).r;\n #else\n float pwfValue = texture2D(otexture, vec2(tValue.r * oscale0 + oshift0, height0)).r;\n tColor *= pwfValue;\n tColor.a *= mix(pwfValue, 1.0, (1.0 - mix0));\n #endif\n\n vec3 tColor1 = mix1*texture2D(ctexture, vec2(tValue.g * cscale1 + cshift1, height1)).rgb;\n #if !defined(vtkComponent1Proportional)\n tColor.a += goFactor.y*mix1*texture2D(otexture, vec2(tValue.g * oscale1 + oshift1, height1)).r;\n #else\n float pwfValue = texture2D(otexture, vec2(tValue.g * oscale1 + oshift1, height1)).r;\n tColor1 *= pwfValue;\n tColor.a *= mix(pwfValue, 1.0, (1.0 - mix1));\n #endif\n\n #if vtkNumComponents >= 3\n vec3 tColor2 = mix2*texture2D(ctexture, vec2(tValue.b * cscale2 + cshift2, height2)).rgb;\n #if !defined(vtkComponent2Proportional)\n tColor.a += goFactor.z*mix2*texture2D(otexture, vec2(tValue.b * oscale2 + oshift2, height2)).r;\n #else\n float pwfValue = texture2D(otexture, vec2(tValue.b * oscale2 + oshift2, height2)).r;\n tColor2 *= pwfValue;\n tColor.a *= mix(pwfValue, 1.0, (1.0 - mix2));\n #endif\n\n #if vtkNumComponents >= 4\n vec3 tColor3 = mix3*texture2D(ctexture, vec2(tValue.a * cscale3 + cshift3, height3)).rgb;\n #if !defined(vtkComponent3Proportional)\n tColor.a += goFactor.w*mix3*texture2D(otexture, vec2(tValue.a * oscale3 + oshift3, height3)).r;\n #else\n float pwfValue = texture2D(otexture, vec2(tValue.a * oscale3 + oshift3, height3)).r;\n tColor3 *= pwfValue;\n tColor.a *= mix(pwfValue, 1.0, (1.0 - mix3));\n #endif\n #endif\n #endif\n #else // then not independent\n\n #if vtkNumComponents == 2\n float lum = tValue.r * cscale0 + cshift0;\n float alpha = goFactor.x*texture2D(otexture, vec2(tValue.a * oscale1 + oshift1, 0.5)).r;\n vec4 tColor = vec4(lum, lum, lum, alpha);\n #endif\n #if vtkNumComponents == 3\n vec4 tColor;\n tColor.r = tValue.r * cscale0 + cshift0;\n tColor.g = tValue.g * cscale1 + cshift1;\n tColor.b = tValue.b * cscale2 + cshift2;\n tColor.a = goFactor.x*texture2D(otexture, vec2(tValue.a * oscale0 + oshift0, 0.5)).r;\n #endif\n #if vtkNumComponents == 4\n vec4 tColor;\n tColor.r = tValue.r * cscale0 + cshift0;\n tColor.g = tValue.g * cscale1 + cshift1;\n tColor.b = tValue.b * cscale2 + cshift2;\n tColor.a = goFactor.x*texture2D(otexture, vec2(tValue.a * oscale3 + oshift3, 0.5)).r;\n #endif\n #endif // dependent\n\n // apply lighting if requested as appropriate\n #if vtkLightComplexity > 0\n #if !defined(vtkComponent0Proportional)\n applyLighting(tColor.rgb, normal0);\n #endif\n #if defined(vtkIndependentComponentsOn) && vtkNumComponents >= 2\n #if !defined(vtkComponent1Proportional)\n applyLighting(tColor1, normal1);\n #endif\n #if vtkNumComponents >= 3\n #if !defined(vtkComponent2Proportional)\n applyLighting(tColor2, normal2);\n #endif\n #if vtkNumComponents >= 4\n #if !defined(vtkComponent3Proportional)\n applyLighting(tColor3, normal3);\n #endif\n #endif\n #endif\n #endif\n#endif\n\n// perform final independent blend as needed\n#if defined(vtkIndependentComponentsOn) && vtkNumComponents >= 2\n tColor.rgb += tColor1;\n#if vtkNumComponents >= 3\n tColor.rgb += tColor2;\n#if vtkNumComponents >= 4\n tColor.rgb += tColor3;\n#endif\n#endif\n#endif\n\n#endif\n\n\n\n\n\n\n\nreturn tColor;\n}\n\nbool valueWithinScalarRange(vec4 val, vec4 min, vec4 max) {\n bool withinRange = false;\n #if vtkNumComponents == 1\n if (val.r >= min.r && val.r <= max.r) {\n withinRange = true;\n }\n #endif\n #if defined(vtkIndependentComponentsOn) && vtkNumComponents == 2\n if (val.r >= min.r && val.r <= max.r &&\n val.g >= min.g && val.g <= max.g) {\n withinRange = true;\n }\n #endif\n #if defined(vtkIndependentComponentsOn) && vtkNumComponents >= 3\n if (all(greaterThanEqual(val, ipScalarRangeMin)) &&\n all(lessThanEqual(val, ipScalarRangeMax))) {\n withinRange = true;\n }\n #endif\n return withinRange;\n}\n\n//=======================================================================\n// Apply the specified blend mode operation along the ray's path.\n//\nvoid applyBlend(vec3 posIS, vec3 endIS, float sampleDistanceIS, vec3 tdims)\n{\n vec3 tstep = 1.0/tdims;\n\n // start slightly inside and apply some jitter\n vec3 delta = endIS - posIS;\n vec3 stepIS = normalize(delta)*sampleDistanceIS;\n float raySteps = length(delta)/sampleDistanceIS;\n\n // avoid 0.0 jitter\n float jitter = 0.01 + 0.99*texture2D(jtexture, gl_FragCoord.xy/32.0).r;\n float stepsTraveled = jitter;\n\n // local vars for the loop\n vec4 color = vec4(0.0, 0.0, 0.0, 0.0);\n vec4 tValue;\n vec4 tColor;\n\n // if we have less than one step then pick the middle point\n // as our value\n // if (raySteps <= 1.0)\n // {\n // posIS = (posIS + endIS)*0.5;\n // }\n\n // Perform initial step at the volume boundary\n // compute the scalar\n tValue = getTextureValue(posIS);\n\n #if vtkBlendMode == 0 // COMPOSITE_BLEND\n // now map through opacity and color\n tColor = getColorForValue(tValue, posIS, tstep);\n\n // handle very thin volumes\n if (raySteps <= 1.0)\n {\n tColor.a = 1.0 - pow(1.0 - tColor.a, raySteps);\n gl_FragData[0] = tColor;\n return;\n }\n\n tColor.a = 1.0 - pow(1.0 - tColor.a, jitter);\n color = vec4(tColor.rgb*tColor.a, tColor.a);\n posIS += (jitter*stepIS);\n\n for (int i = 0; i < //VTK::MaximumSamplesValue ; ++i)\n {\n if (stepsTraveled + 1.0 >= raySteps) { break; }\n\n // compute the scalar\n tValue = getTextureValue(posIS);\n\n // now map through opacity and color\n tColor = getColorForValue(tValue, posIS, tstep);\n\n float mix = (1.0 - color.a);\n\n // this line should not be needed but nvidia seems to not handle\n // the break correctly on windows/chrome 58 angle\n //mix = mix * sign(max(raySteps - stepsTraveled - 1.0, 0.0));\n\n color = color + vec4(tColor.rgb*tColor.a, tColor.a)*mix;\n stepsTraveled++;\n posIS += stepIS;\n if (color.a > 0.99) { color.a = 1.0; break; }\n }\n\n if (color.a < 0.99 && (raySteps - stepsTraveled) > 0.0)\n {\n posIS = endIS;\n\n // compute the scalar\n tValue = getTextureValue(posIS);\n\n // now map through opacity and color\n tColor = getColorForValue(tValue, posIS, tstep);\n tColor.a = 1.0 - pow(1.0 - tColor.a, raySteps - stepsTraveled);\n\n float mix = (1.0 - color.a);\n color = color + vec4(tColor.rgb*tColor.a, tColor.a)*mix;\n }\n\n gl_FragData[0] = vec4(color.rgb/color.a, color.a);\n #endif\n #if vtkBlendMode == 1 || vtkBlendMode == 2\n // MAXIMUM_INTENSITY_BLEND || MINIMUM_INTENSITY_BLEND\n // Find maximum/minimum intensity along the ray.\n\n // Define the operation we will use (min or max)\n #if vtkBlendMode == 1\n #define OP max\n #else\n #define OP min\n #endif\n\n // If the clipping range is shorter than the sample distance\n // we can skip the sampling loop along the ray.\n if (raySteps <= 1.0)\n {\n gl_FragData[0] = getColorForValue(tValue, posIS, tstep);\n return;\n }\n\n vec4 value = tValue;\n posIS += (jitter*stepIS);\n\n // Sample along the ray until MaximumSamplesValue,\n // ending slightly inside the total distance\n for (int i = 0; i < //VTK::MaximumSamplesValue ; ++i)\n {\n // If we have reached the last step, break\n if (stepsTraveled + 1.0 >= raySteps) { break; }\n\n // compute the scalar\n tValue = getTextureValue(posIS);\n\n // Update the maximum value if necessary\n value = OP(tValue, value);\n\n // Otherwise, continue along the ray\n stepsTraveled++;\n posIS += stepIS;\n }\n\n // Perform the last step along the ray using the\n // residual distance\n posIS = endIS;\n tValue = getTextureValue(posIS);\n value = OP(tValue, value);\n\n // Now map through opacity and color\n gl_FragData[0] = getColorForValue(value, posIS, tstep);\n #endif\n #if vtkBlendMode == 3 || vtkBlendMode == 4 //AVERAGE_INTENSITY_BLEND || ADDITIVE_BLEND\n vec4 sum = vec4(0.);\n\n if (valueWithinScalarRange(tValue, ipScalarRangeMin, ipScalarRangeMax)) {\n sum += tValue;\n }\n\n if (raySteps <= 1.0) {\n gl_FragData[0] = getColorForValue(sum, posIS, tstep);\n return;\n }\n\n posIS += (jitter*stepIS);\n\n // Sample along the ray until MaximumSamplesValue,\n // ending slightly inside the total distance\n for (int i = 0; i < //VTK::MaximumSamplesValue ; ++i)\n {\n // If we have reached the last step, break\n if (stepsTraveled + 1.0 >= raySteps) { break; }\n\n // compute the scalar\n tValue = getTextureValue(posIS);\n\n // One can control the scalar range by setting the AverageIPScalarRange to disregard scalar values, not in the range of interest, from the average computation.\n // Notes:\n // - We are comparing all values in the texture to see if any of them\n // are outside of the scalar range. In the future we might want to allow\n // scalar ranges for each component.\n if (valueWithinScalarRange(tValue, ipScalarRangeMin, ipScalarRangeMax)) {\n // Sum the values across each step in the path\n sum += tValue;\n }\n stepsTraveled++;\n posIS += stepIS;\n }\n\n // Perform the last step along the ray using the\n // residual distance\n posIS = endIS;\n\n // compute the scalar\n tValue = getTextureValue(posIS);\n\n // One can control the scalar range by setting the IPScalarRange to disregard scalar values, not in the range of interest, from the average computation\n if (valueWithinScalarRange(tValue, ipScalarRangeMin, ipScalarRangeMax)) {\n sum += tValue;\n\n stepsTraveled++;\n }\n\n #if vtkBlendMode == 3 // Average\n sum /= vec4(stepsTraveled, stepsTraveled, stepsTraveled, 1.0);\n #endif\n\n gl_FragData[0] = getColorForValue(sum, posIS, tstep);\n #endif\n}\n\n//=======================================================================\n// Compute a new start and end point for a given ray based\n// on the provided bounded clipping plane (aka a rectangle)\nvoid getRayPointIntersectionBounds(\n vec3 rayPos, vec3 rayDir,\n vec3 planeDir, float planeDist,\n inout vec2 tbounds, vec3 vPlaneX, vec3 vPlaneY,\n float vSize1, float vSize2)\n{\n float result = dot(rayDir, planeDir);\n if (abs(result) < 1e-6)\n {\n return;\n }\n result = -1.0 * (dot(rayPos, planeDir) + planeDist) / result;\n vec3 xposVC = rayPos + rayDir*result;\n vec3 vxpos = xposVC - vOriginVC;\n vec2 vpos = vec2(\n dot(vxpos, vPlaneX),\n dot(vxpos, vPlaneY));\n\n // on some apple nvidia systems this does not work\n // if (vpos.x < 0.0 || vpos.x > vSize1 ||\n // vpos.y < 0.0 || vpos.y > vSize2)\n // even just\n // if (vpos.x < 0.0 || vpos.y < 0.0)\n // fails\n // so instead we compute a value that represents in and out\n //and then compute the return using this value\n float xcheck = max(0.0, vpos.x * (vpos.x - vSize1)); // 0 means in bounds\n float check = sign(max(xcheck, vpos.y * (vpos.y - vSize2))); // 0 means in bounds, 1 = out\n\n tbounds = mix(\n vec2(min(tbounds.x, result), max(tbounds.y, result)), // in value\n tbounds, // out value\n check); // 0 in 1 out\n}\n\n//=======================================================================\n// given a\n// - ray direction (rayDir)\n// - starting point (vertexVCVSOutput)\n// - bounding planes of the volume\n// - optionally depth buffer values\n// - far clipping plane\n// compute the start/end distances of the ray we need to cast\nvec2 computeRayDistances(vec3 rayDir, vec3 tdims)\n{\n vec2 dists = vec2(100.0*camFar, -1.0);\n\n vec3 vSize = vSpacing*(tdims - 1.0);\n\n // all this is in View Coordinates\n getRayPointIntersectionBounds(vertexVCVSOutput, rayDir,\n vPlaneNormal0, vPlaneDistance0, dists, vPlaneNormal2, vPlaneNormal4,\n vSize.y, vSize.z);\n getRayPointIntersectionBounds(vertexVCVSOutput, rayDir,\n vPlaneNormal1, vPlaneDistance1, dists, vPlaneNormal2, vPlaneNormal4,\n vSize.y, vSize.z);\n getRayPointIntersectionBounds(vertexVCVSOutput, rayDir,\n vPlaneNormal2, vPlaneDistance2, dists, vPlaneNormal0, vPlaneNormal4,\n vSize.x, vSize.z);\n getRayPointIntersectionBounds(vertexVCVSOutput, rayDir,\n vPlaneNormal3, vPlaneDistance3, dists, vPlaneNormal0, vPlaneNormal4,\n vSize.x, vSize.z);\n getRayPointIntersectionBounds(vertexVCVSOutput, rayDir,\n vPlaneNormal4, vPlaneDistance4, dists, vPlaneNormal0, vPlaneNormal2,\n vSize.x, vSize.y);\n getRayPointIntersectionBounds(vertexVCVSOutput, rayDir,\n vPlaneNormal5, vPlaneDistance5, dists, vPlaneNormal0, vPlaneNormal2,\n vSize.x, vSize.y);\n\n //VTK::ClipPlane::Impl\n\n // do not go behind front clipping plane\n dists.x = max(0.0,dists.x);\n\n // do not go PAST far clipping plane\n float farDist = -camThick/rayDir.z;\n dists.y = min(farDist,dists.y);\n\n // Do not go past the zbuffer value if set\n // This is used for intermixing opaque geometry\n //VTK::ZBuffer::Impl\n\n return dists;\n}\n\n//=======================================================================\n// Compute the index space starting position (pos) and end\n// position\n//\nvoid computeIndexSpaceValues(out vec3 pos, out vec3 endPos, out float sampleDistanceIS, vec3 rayDir, vec2 dists)\n{\n // compute starting and ending values in volume space\n pos = vertexVCVSOutput + dists.x*rayDir;\n pos = pos - vOriginVC;\n // convert to volume basis and origin\n pos = vec3(\n dot(pos, vPlaneNormal0),\n dot(pos, vPlaneNormal2),\n dot(pos, vPlaneNormal4));\n\n endPos = vertexVCVSOutput + dists.y*rayDir;\n endPos = endPos - vOriginVC;\n endPos = vec3(\n dot(endPos, vPlaneNormal0),\n dot(endPos, vPlaneNormal2),\n dot(endPos, vPlaneNormal4));\n\n float delta = length(endPos - pos);\n\n pos *= vVCToIJK;\n endPos *= vVCToIJK;\n\n float delta2 = length(endPos - pos);\n sampleDistanceIS = sampleDistance*delta2/delta;\n}\n\nvoid main()\n{\n\n vec3 rayDirVC;\n\n if (cameraParallel == 1)\n {\n // Camera is parallel, so the rayDir is just the direction of the camera.\n rayDirVC = vec3(0.0, 0.0, -1.0);\n } else {\n // camera is at 0,0,0 so rayDir for perspective is just the vc coord\n rayDirVC = normalize(vertexVCVSOutput);\n }\n\n vec3 tdims = vec3(volumeDimensions);\n\n // compute the start and end points for the ray\n vec2 rayStartEndDistancesVC = computeRayDistances(rayDirVC, tdims);\n\n // do we need to composite? aka does the ray have any length\n // If not, bail out early\n if (rayStartEndDistancesVC.y <= rayStartEndDistancesVC.x)\n {\n discard;\n }\n\n // IS = Index Space\n vec3 posIS;\n vec3 endIS;\n float sampleDistanceIS;\n computeIndexSpaceValues(posIS, endIS, sampleDistanceIS, rayDirVC, rayStartEndDistancesVC);\n\n // Perform the blending operation along the ray\n applyBlend(posIS, endIS, sampleDistanceIS, tdims);\n}\n";
2
2
 
3
3
  export { vtkVolumeFS as v };
@@ -1,5 +1,5 @@
1
- import { vtkObject } from '@kitware/vtk.js/interfaces';
2
- import vtkViewNode from '@kitware/vtk.js/Rendering/SceneGraph/ViewNode';
1
+ import { vtkObject } from '../../interfaces';
2
+ import vtkViewNode from './ViewNode';
3
3
 
4
4
  /**
5
5
  *
@@ -1,5 +1,5 @@
1
- import { vtkObject } from '@kitware/vtk.js/interfaces';
2
- import vtkRenderPass from '@kitware/vtk.js/Rendering/SceneGraph/RenderPass';
1
+ import { vtkObject } from '../../interfaces';
2
+ import vtkRenderPass from './RenderPass';
3
3
 
4
4
  export enum PASS_TYPES {
5
5
  'Build',
@@ -1,4 +1,4 @@
1
- import { vtkObject } from '@kitware/vtk.js/interfaces';
1
+ import { vtkObject } from '../../interfaces';
2
2
 
3
3
  /**
4
4
  *