VTK
vtkOpenGLGPUVolumeRayCastMapper.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: vtkOpenGLGPUVolumeRayCastMapper.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 vtkOpenGLGPUVolumeRayCastMapper_h
17#define vtkOpenGLGPUVolumeRayCastMapper_h
18
19#include "vtkRenderingVolumeOpenGL2Module.h" // For export macro
20
22
23// Forward declarations
24class vtkOpenGLCamera;
29
30//----------------------------------------------------------------------------
31class VTKRENDERINGVOLUMEOPENGL2_EXPORT vtkOpenGLGPUVolumeRayCastMapper :
33{
34public:
36
37 enum Passes
38 {
40 DepthPass = 1
41 };
42
44 void PrintSelf( ostream& os, vtkIndent indent );
45
46 // Description:
47 // Low level API to enable access to depth texture in
48 // RenderToTexture mode. It will return either NULL if
49 // RenderToImage was never turned on or texture captured
50 // the last time RenderToImage was on.
52
53 // Description:
54 // Low level API to enable access to color texture in
55 // RenderToTexture mode. It will return either NULL if
56 // RenderToImage was never turned on or texture captured
57 // the last time RenderToImage was on.
59
60 // Description:
61 // Low level API to export the depth texture as vtkImageData in
62 // RenderToImage mode.
64
65 // Description:
66 // Low level API to export the color texture as vtkImageData in
67 // RenderToImage mode.
69
70 // Description:
71 // Mapper can have multiple passes and internally it will set
72 // the state. The state can not be set externally explicitly
73 // but can be set indirectly depending on the options set by
74 // the user.
75 vtkGetMacro(CurrentPass, int);
76
78
85 vtkSetVector2Macro(NoiseTextureSize, int);
87
88protected:
91
92 // Description:
93 // Delete OpenGL objects.
94 // \post done: this->OpenGLObjectsCreated==0
95 virtual void ReleaseGraphicsResources(vtkWindow *window);
97
98 // Description:
99 // Build vertex and fragment shader for the volume rendering
101 int noOfComponents,
102 int independentComponents);
103
104 // Description:
105 // Build vertex and fragment shader for the volume rendering
106 void BuildShader(vtkRenderer* ren, vtkVolume* vol, int noOfCmponents);
107
108 // TODO Take these out as these are no longer needed
109 // Methods called by the AMR Volume Mapper.
110 virtual void PreRender(vtkRenderer * vtkNotUsed(ren),
111 vtkVolume *vtkNotUsed(vol),
112 double vtkNotUsed(datasetBounds)[6],
113 double vtkNotUsed(scalarRange)[2],
114 int vtkNotUsed(noOfComponents),
115 unsigned int vtkNotUsed(numberOfLevels)) {};
116
117 // \pre input is up-to-date
118 virtual void RenderBlock(vtkRenderer *vtkNotUsed(ren),
119 vtkVolume *vtkNotUsed(vol),
120 unsigned int vtkNotUsed(level)) {}
121
122 virtual void PostRender(vtkRenderer *vtkNotUsed(ren),
123 int vtkNotUsed(noOfComponents)) {}
124
125 // Description:
126 // Rendering volume on GPU
128
129 // Description:
130 // Method that performs the actual rendering given a volume and a shader
132 vtkVolume* vol,
133 vtkImageData* input,
134 vtkOpenGLCamera* cam,
135 vtkShaderProgram* shaderProgram,
136 int noOfComponents,
137 int independentComponents);
138
139 // Description:
140 // Update the reduction factor of the render viewport (this->ReductionFactor)
141 // according to the time spent in seconds to render the previous frame
142 // (this->TimeToDraw) and a time in seconds allocated to render the next
143 // frame (allocatedTime).
144 // \pre valid_current_reduction_range: this->ReductionFactor>0.0 && this->ReductionFactor<=1.0
145 // \pre positive_TimeToDraw: this->TimeToDraw>=0.0
146 // \pre positive_time: allocatedTime>0
147 // \post valid_new_reduction_range: this->ReductionFactor>0.0 && this->ReductionFactor<=1.0
148 void ComputeReductionFactor(double allocatedTime);
149
150 // Description:
151 // Empty implementation.
152 void GetReductionRatio(double* ratio)
153 {
154 ratio[0] = ratio[1] = ratio[2] = 1.0;
155 }
156
157
158 // Description:
159 // Empty implementation.
160 virtual int IsRenderSupported(vtkRenderWindow *vtkNotUsed(window),
161 vtkVolumeProperty *vtkNotUsed(property))
162 {
163 return 1;
164 }
165
168
169private:
170 class vtkInternal;
171 vtkInternal* Impl;
172
173 vtkImplicitFunction* NoiseGenerator;
174 int NoiseTextureSize[2];
175
177 const vtkOpenGLGPUVolumeRayCastMapper&) VTK_DELETE_FUNCTION;
178 void operator=(const vtkOpenGLGPUVolumeRayCastMapper&) VTK_DELETE_FUNCTION;
179};
180
181#endif // vtkOpenGLGPUVolumeRayCastMapper_h
Ray casting performed on the GPU.
topologically and geometrically regular array of data
Definition: vtkImageData.h:46
abstract interface for implicit functions
a simple class to control print indentation
Definition: vtkIndent.h:40
OpenGL camera.
void GPURender(vtkRenderer *ren, vtkVolume *vol)
Handled in the subclass - the actual render method.
virtual void PostRender(vtkRenderer *vtkNotUsed(ren), int vtkNotUsed(noOfComponents))
virtual void RenderBlock(vtkRenderer *vtkNotUsed(ren), vtkVolume *vtkNotUsed(vol), unsigned int vtkNotUsed(level))
virtual void ReleaseGraphicsResources(vtkWindow *window)
Release any graphics resources that are being consumed by this mapper.
void DoGPURender(vtkRenderer *ren, vtkVolume *vol, vtkImageData *input, vtkOpenGLCamera *cam, vtkShaderProgram *shaderProgram, int noOfComponents, int independentComponents)
void ComputeReductionFactor(double allocatedTime)
void GetColorImage(vtkImageData *im)
Low level API to export the color texture as vtkImageData in RenderToImage mode.
void SetNoiseGenerator(vtkImplicitFunction *generator)
Sets a user defined function to generate the ray jittering noise.
virtual void PreRender(vtkRenderer *vtkNotUsed(ren), vtkVolume *vtkNotUsed(vol), double vtkNotUsed(datasetBounds)[6], double vtkNotUsed(scalarRange)[2], int vtkNotUsed(noOfComponents), unsigned int vtkNotUsed(numberOfLevels))
vtkTextureObject * GetColorTexture()
void PrintSelf(ostream &os, vtkIndent indent)
Methods invoked by print to print information about the object including superclasses.
void BuildDepthPassShader(vtkRenderer *ren, vtkVolume *vol, int noOfComponents, int independentComponents)
vtkGenericOpenGLResourceFreeCallback * ResourceCallback
void BuildShader(vtkRenderer *ren, vtkVolume *vol, int noOfCmponents)
void GetDepthImage(vtkImageData *im)
Low level API to export the depth texture as vtkImageData in RenderToImage mode.
vtkTextureObject * GetDepthTexture()
static vtkOpenGLGPUVolumeRayCastMapper * New()
virtual int IsRenderSupported(vtkRenderWindow *vtkNotUsed(window), vtkVolumeProperty *vtkNotUsed(property))
Based on hardware and properties, we may or may not be able to render using 3D texture mapping.
create a window for renderers to draw into
abstract specification for renderers
Definition: vtkRenderer.h:64
The ShaderProgram uses one or more Shader objects.
abstracts an OpenGL texture object.
represents the common properties for rendering a volume.
represents a volume (data & properties) in a rendered scene
Definition: vtkVolume.h:51
window superclass for vtkRenderWindow
Definition: vtkWindow.h:35
@ level
Definition: vtkX3D.h:395