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 =========================================================================*/
26 #ifndef vtkOpenGLFluidMapper_h
27 #define vtkOpenGLFluidMapper_h
28 
30 
31 #include "vtkOpenGLHelper.h" // used for ivars
32 #include "vtkRenderingOpenGL2Module.h" // For export macro
33 #include "vtkShader.h" // for methods
34 #include "vtkSmartPointer.h" // for ivars
35 
36 #include <map> //for methods
37 
38 class vtkMatrix3x3;
39 class vtkMatrix4x4;
42 class vtkOpenGLState;
45 class vtkPolyData;
46 class vtkTextureObject;
47 
48 class VTKRENDERINGOPENGL2_EXPORT vtkOpenGLFluidMapper : public vtkAbstractVolumeMapper
49 {
50 public:
51  static vtkOpenGLFluidMapper* New();
53  void PrintSelf(ostream& os, vtkIndent indent) override;
54 
56 
59  void SetInputData(vtkPolyData* in);
60  vtkPolyData* GetInput();
62 
64 
67  vtkSetMacro(ScalarVisibility, bool);
68  vtkGetMacro(ScalarVisibility, bool);
69  vtkBooleanMacro(ScalarVisibility, bool);
71 
73 
80  vtkSetMacro(ParticleRadius, float);
81  vtkGetMacro(ParticleRadius, float);
83 
85 
91  vtkSetMacro(SurfaceFilterIterations, uint32_t);
92  vtkGetMacro(SurfaceFilterIterations, uint32_t);
94 
96 
100  vtkSetMacro(ThicknessAndVolumeColorFilterIterations, uint32_t);
101  vtkGetMacro(ThicknessAndVolumeColorFilterIterations, uint32_t);
103 
105 
112  vtkSetMacro(SurfaceFilterRadius, uint32_t);
113  vtkGetMacro(SurfaceFilterRadius, uint32_t);
115 
117 
121  vtkSetMacro(ThicknessAndVolumeColorFilterRadius, float);
122  vtkGetMacro(ThicknessAndVolumeColorFilterRadius, float);
124 
129  {
130  BilateralGaussian = 0,
132  // New filter method can be added here,
133  NumFilterMethods
134  };
135 
137 
140  vtkSetMacro(SurfaceFilterMethod, vtkOpenGLFluidMapper::FluidSurfaceFilterMethod);
141  vtkGetMacro(SurfaceFilterMethod, vtkOpenGLFluidMapper::FluidSurfaceFilterMethod);
143 
149  void SetNarrowRangeFilterParameters(float lambda, float mu)
150  {
151  this->NRFilterLambda = lambda;
152  this->NRFilterMu = mu;
153  }
154 
159  void SetBilateralGaussianFilterParameter(float sigmaDepth)
160  {
161  this->BiGaussFilterSigmaDepth = sigmaDepth;
162  }
163 
168  {
169  UnfilteredOpaqueSurface = 0,
174  NumDisplayModes
175  };
176 
178 
181  vtkSetMacro(DisplayMode, vtkOpenGLFluidMapper::FluidDisplayMode);
182  vtkGetMacro(DisplayMode, vtkOpenGLFluidMapper::FluidDisplayMode);
184 
186 
191  vtkSetVector3Macro(AttenuationColor, float);
192  vtkGetVector3Macro(AttenuationColor, float);
194 
196 
200  vtkSetVector3Macro(OpaqueColor, float);
201  vtkGetVector3Macro(OpaqueColor, float);
203 
205 
211  vtkSetMacro(ParticleColorPower, float);
212  vtkGetMacro(ParticleColorPower, float);
214 
216 
222  vtkSetMacro(ParticleColorScale, float);
223  vtkGetMacro(ParticleColorScale, float);
225 
227 
233  vtkSetMacro(AttenuationScale, float);
234  vtkGetMacro(AttenuationScale, float);
236 
238 
244  vtkSetMacro(AdditionalReflection, float);
245  vtkGetMacro(AdditionalReflection, float);
247 
249 
255  vtkSetMacro(RefractionScale, float);
256  vtkGetMacro(RefractionScale, float);
258 
260 
263  vtkSetMacro(RefractiveIndex, float);
264  vtkGetMacro(RefractiveIndex, float);
266 
270  void Render(vtkRenderer* ren, vtkVolume* vol) override;
271 
277  void ReleaseGraphicsResources(vtkWindow* w) override;
278 
279 protected:
281  ~vtkOpenGLFluidMapper() override;
282 
286  void UpdateDepthThicknessColorShaders(
287  vtkOpenGLHelper& glHelper, vtkRenderer* renderer, vtkVolume* vol);
288 
292  void SetDepthThicknessColorShaderParameters(
293  vtkOpenGLHelper& glHelper, vtkRenderer* renderer, vtkVolume* vol);
294 
298  void SetupBuffers(vtkOpenGLRenderWindow* const renderWindow);
299 
303  void RenderParticles(vtkRenderer* renderer, vtkVolume* vol);
304 
305  // Public parameters, their usage are stated at their Get/Set functions
306  // ======>>>>>
307  float ParticleRadius = 1.0f;
308 
309  FluidSurfaceFilterMethod SurfaceFilterMethod = FluidSurfaceFilterMethod::NarrowRange;
310  uint32_t SurfaceFilterIterations = 3u;
311  uint32_t SurfaceFilterRadius = 5u;
312  float NRFilterLambda = 10.0f;
313  float NRFilterMu = 1.0f;
314  float BiGaussFilterSigmaDepth = 10.0f;
315 
316  uint32_t ThicknessAndVolumeColorFilterIterations = 3u;
317  uint32_t ThicknessAndVolumeColorFilterRadius = 10u;
318 
319  FluidDisplayMode DisplayMode = FluidDisplayMode::TransparentFluidVolume;
320 
321  float OpaqueColor[3]{ 0.0f, 0.0f, 0.95f };
322  float AttenuationColor[3]{ 0.5f, 0.2f, 0.05f };
323  float ParticleColorPower = 0.1f;
324  float ParticleColorScale = 1.0f;
325  float AttenuationScale = 1.0f;
326  float AdditionalReflection = 0.0f;
327  float RefractionScale = 1.0f;
328  float RefractiveIndex = 1.33f;
329 
330  bool ScalarVisibility = false;
331  bool InDepthPass = true;
332 
333  // Private parameters ======>>>>>
334 
335  // Indicate that the input data has a color buffer
336  bool HasVertexColor = false;
337 
338  // Cache viewport dimensions
343 
344  // Cache camera parameters
351 
352  // Frame buffers
358 
359  // Screen quad render
360  vtkOpenGLQuadHelper* QuadFluidDepthFilter[NumFilterMethods]{ nullptr, nullptr };
361  vtkOpenGLQuadHelper* QuadThicknessFilter = nullptr;
362  vtkOpenGLQuadHelper* QuadFluidNormal = nullptr;
363  vtkOpenGLQuadHelper* QuadFinalBlend = nullptr;
364 
365  // The VBO and its layout for rendering particles
367  vtkTimeStamp VBOBuildTime; // When was the OpenGL VBO updated?
369 
370  // Texture buffers
372  {
373  OpaqueZ = 0,
381  NumTexBuffers
382  };
383 
384  // These are optional texture buffers
386  {
387  Color = 0,
389  NumOptionalTexBuffers
390  };
391 
392  vtkTextureObject* TexBuffer[NumTexBuffers];
393  vtkTextureObject* OptionalTexBuffer[NumOptionalTexBuffers];
395 
396 private:
398  void operator=(const vtkOpenGLFluidMapper&) = delete;
399 };
400 
401 #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:61
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:37
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)