VTK  9.0.1
vtkOpenGLFluidMapper.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4 
5  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
6  All rights reserved.
7  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
8 
9  This software is distributed WITHOUT ANY WARRANTY; without even
10  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11  PURPOSE. See the above copyright notice for more information.
12 
13 =========================================================================*/
23 #ifndef vtkOpenGLFluidMapper_h
24 #define vtkOpenGLFluidMapper_h
25 
27 
28 #include "vtkOpenGLHelper.h" // used for ivars
29 #include "vtkRenderingOpenGL2Module.h" // For export macro
30 #include "vtkShader.h" // for methods
31 #include "vtkSmartPointer.h" // for ivars
32 
33 #include <map> //for methods
34 
35 class vtkMatrix3x3;
36 class vtkMatrix4x4;
39 class vtkOpenGLState;
42 class vtkPolyData;
43 class vtkTextureObject;
44 
45 class VTKRENDERINGOPENGL2_EXPORT vtkOpenGLFluidMapper : public vtkAbstractVolumeMapper
46 {
47 public:
48  static vtkOpenGLFluidMapper* New();
50  void PrintSelf(ostream& os, vtkIndent indent) override;
51 
53 
56  void SetInputData(vtkPolyData* in);
57  vtkPolyData* GetInput();
59 
61 
64  vtkSetMacro(ScalarVisibility, bool);
65  vtkGetMacro(ScalarVisibility, bool);
66  vtkBooleanMacro(ScalarVisibility, bool);
68 
70 
77  vtkSetMacro(ParticleRadius, float);
78  vtkGetMacro(ParticleRadius, float);
80 
82 
88  vtkSetMacro(SurfaceFilterIterations, uint32_t);
89  vtkGetMacro(SurfaceFilterIterations, uint32_t);
91 
93 
97  vtkSetMacro(ThicknessAndVolumeColorFilterIterations, uint32_t);
98  vtkGetMacro(ThicknessAndVolumeColorFilterIterations, uint32_t);
100 
102 
109  vtkSetMacro(SurfaceFilterRadius, uint32_t);
110  vtkGetMacro(SurfaceFilterRadius, uint32_t);
112 
114 
118  vtkSetMacro(ThicknessAndVolumeColorFilterRadius, float);
119  vtkGetMacro(ThicknessAndVolumeColorFilterRadius, float);
121 
126  {
127  BilateralGaussian = 0,
129  // New filter method can be added here,
130  NumFilterMethods
131  };
132 
134 
137  vtkSetMacro(SurfaceFilterMethod, vtkOpenGLFluidMapper::FluidSurfaceFilterMethod);
138  vtkGetMacro(SurfaceFilterMethod, vtkOpenGLFluidMapper::FluidSurfaceFilterMethod);
140 
146  void SetNarrowRangeFilterParameters(float lambda, float mu)
147  {
148  this->NRFilterLambda = lambda;
149  this->NRFilterMu = mu;
150  }
151 
156  void SetBilateralGaussianFilterParameter(float sigmaDepth)
157  {
158  this->BiGaussFilterSigmaDepth = sigmaDepth;
159  }
160 
165  {
166  UnfilteredOpaqueSurface = 0,
171  NumDisplayModes
172  };
173 
175 
178  vtkSetMacro(DisplayMode, vtkOpenGLFluidMapper::FluidDisplayMode);
179  vtkGetMacro(DisplayMode, vtkOpenGLFluidMapper::FluidDisplayMode);
181 
183 
188  vtkSetVector3Macro(AttenuationColor, float);
189  vtkGetVector3Macro(AttenuationColor, float);
191 
193 
197  vtkSetVector3Macro(OpaqueColor, float);
198  vtkGetVector3Macro(OpaqueColor, float);
200 
202 
208  vtkSetMacro(ParticleColorPower, float);
209  vtkGetMacro(ParticleColorPower, float);
211 
213 
219  vtkSetMacro(ParticleColorScale, float);
220  vtkGetMacro(ParticleColorScale, float);
222 
224 
230  vtkSetMacro(AttenuationScale, float);
231  vtkGetMacro(AttenuationScale, float);
233 
235 
241  vtkSetMacro(AdditionalReflection, float);
242  vtkGetMacro(AdditionalReflection, float);
244 
246 
252  vtkSetMacro(RefractionScale, float);
253  vtkGetMacro(RefractionScale, float);
255 
257 
260  vtkSetMacro(RefractiveIndex, float);
261  vtkGetMacro(RefractiveIndex, float);
263 
267  void Render(vtkRenderer* ren, vtkVolume* vol) override;
268 
274  void ReleaseGraphicsResources(vtkWindow* w) override;
275 
276 protected:
278  ~vtkOpenGLFluidMapper() override;
279 
283  void UpdateDepthThicknessColorShaders(
284  vtkOpenGLHelper& glHelper, vtkRenderer* renderer, vtkVolume* vol);
285 
289  void SetDepthThicknessColorShaderParameters(
290  vtkOpenGLHelper& glHelper, vtkRenderer* renderer, vtkVolume* vol);
291 
295  void SetupBuffers(vtkOpenGLRenderWindow* const renderWindow);
296 
300  void RenderParticles(vtkRenderer* renderer, vtkVolume* vol);
301 
302  // Public parameters, their usage are stated at their Get/Set functions
303  // ======>>>>>
304  float ParticleRadius = 1.0f;
305 
306  FluidSurfaceFilterMethod SurfaceFilterMethod = FluidSurfaceFilterMethod::NarrowRange;
307  uint32_t SurfaceFilterIterations = 3u;
308  uint32_t SurfaceFilterRadius = 5u;
309  float NRFilterLambda = 10.0f;
310  float NRFilterMu = 1.0f;
311  float BiGaussFilterSigmaDepth = 10.0f;
312 
313  uint32_t ThicknessAndVolumeColorFilterIterations = 3u;
314  uint32_t ThicknessAndVolumeColorFilterRadius = 10u;
315 
316  FluidDisplayMode DisplayMode = FluidDisplayMode::TransparentFluidVolume;
317 
318  float OpaqueColor[3]{ 0.0f, 0.0f, 0.95f };
319  float AttenuationColor[3]{ 0.5f, 0.2f, 0.05f };
320  float ParticleColorPower = 0.1f;
321  float ParticleColorScale = 1.0f;
322  float AttenuationScale = 1.0f;
323  float AdditionalReflection = 0.0f;
324  float RefractionScale = 1.0f;
325  float RefractiveIndex = 1.33f;
326 
327  bool ScalarVisibility = false;
328  bool InDepthPass = true;
329 
330  // Private parameters ======>>>>>
331 
332  // Indicate that the input data has a color buffer
333  bool HasVertexColor = false;
334 
335  // Cache viewport dimensions
340 
341  // Cache camera parameters
348 
349  // Frame buffers
355 
356  // Screen quad render
357  vtkOpenGLQuadHelper* QuadFluidDepthFilter[NumFilterMethods]{ nullptr, nullptr };
358  vtkOpenGLQuadHelper* QuadThicknessFilter = nullptr;
359  vtkOpenGLQuadHelper* QuadFluidNormal = nullptr;
360  vtkOpenGLQuadHelper* QuadFinalBlend = nullptr;
361 
362  // The VBO and its layout for rendering particles
364  vtkTimeStamp VBOBuildTime; // When was the OpenGL VBO updated?
366 
367  // Texture buffers
369  {
370  OpaqueZ = 0,
378  NumTexBuffers
379  };
380 
381  // These are optional texture buffers
383  {
384  Color = 0,
386  NumOptionalTexBuffers
387  };
388 
389  vtkTextureObject* TexBuffer[NumTexBuffers];
390  vtkTextureObject* OptionalTexBuffer[NumOptionalTexBuffers];
392 
393 private:
395  void operator=(const vtkOpenGLFluidMapper&) = delete;
396 };
397 
398 #endif
OpenGL rendering window.
FluidDisplayMode
Display mode for the fluid, default value is TransparentFluidVolume.
represents a volume (data & properties) in a rendered scene
Definition: vtkVolume.h:44
FluidSurfaceFilterMethod
Filter method to filter the depth buffer.
void ReleaseGraphicsResources(vtkWindow *) override
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE Release any graphics resources that are being...
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:35
vtkSmartPointer< vtkOpenGLFramebufferObject > FBFilterThickness
void SetNarrowRangeFilterParameters(float lambda, float mu)
Optional parameters, exclusively for narrow range filter The first parameter is to control smoothing ...
virtual void Render(vtkRenderer *ren, vtkVolume *vol)=0
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE DO NOT USE THIS METHOD OUTSIDE OF THE RENDERI...
void SetBilateralGaussianFilterParameter(float sigmaDepth)
Optional parameters, exclusively for bilateral gaussian filter The parameter is for controlling smoot...
record modification and/or execution time
Definition: vtkTimeStamp.h:32
vtkSmartPointer< vtkOpenGLFramebufferObject > FBFilterDepth
Abstract class for a volume mapper.
abstract specification for renderers
Definition: vtkRenderer.h:58
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:84
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkOpenGLHelper GLHelperDepthThickness
int vtkTypeBool
Definition: vtkABI.h:69
window superclass for vtkRenderWindow
Definition: vtkWindow.h:34
OpenGL state storage.
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkMatrix3x3 * CamInvertedNorms
Internal class which encapsulates OpenGL FramebufferObject.
abstracts an OpenGL texture object.
Class to make rendering a full screen quad easier.
vtkSmartPointer< vtkOpenGLFramebufferObject > FBThickness
static vtkAlgorithm * New()
vtkSmartPointer< vtkOpenGLFramebufferObject > FBFluidEyeZ
represent and manipulate 3x3 transformation matrices
Definition: vtkMatrix3x3.h:33
vtkSmartPointer< vtkOpenGLFramebufferObject > FBCompNormal
manage vertex buffer objects shared within a mapper
vtkSmartPointer< vtkOpenGLVertexBufferObjectGroup > VBOs
Render fluid from position data (and color, if available)