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 =========================================================================*/
29 #ifndef vtkOpenGLFluidMapper_h
30 #define vtkOpenGLFluidMapper_h
31 
33 
34 #include "vtkOpenGLHelper.h" // used for ivars
35 #include "vtkRenderingOpenGL2Module.h" // For export macro
36 #include "vtkShader.h" // for methods
37 #include "vtkSmartPointer.h" // for ivars
38 
39 #include <map> //for methods
40 
41 class vtkMatrix3x3;
42 class vtkMatrix4x4;
45 class vtkOpenGLState;
48 class vtkPolyData;
49 class vtkTextureObject;
50 
51 class VTKRENDERINGOPENGL2_EXPORT vtkOpenGLFluidMapper : public vtkAbstractVolumeMapper
52 {
53 public:
54  static vtkOpenGLFluidMapper* New();
56  void PrintSelf(ostream& os, vtkIndent indent) override;
57 
59 
62  void SetInputData(vtkPolyData* in);
63  vtkPolyData* GetInput();
65 
67 
70  vtkSetMacro(ScalarVisibility, bool);
71  vtkGetMacro(ScalarVisibility, bool);
72  vtkBooleanMacro(ScalarVisibility, bool);
74 
76 
83  vtkSetMacro(ParticleRadius, float);
84  vtkGetMacro(ParticleRadius, float);
86 
88 
94  vtkSetMacro(SurfaceFilterIterations, uint32_t);
95  vtkGetMacro(SurfaceFilterIterations, uint32_t);
97 
99 
103  vtkSetMacro(ThicknessAndVolumeColorFilterIterations, uint32_t);
104  vtkGetMacro(ThicknessAndVolumeColorFilterIterations, uint32_t);
106 
108 
115  vtkSetMacro(SurfaceFilterRadius, uint32_t);
116  vtkGetMacro(SurfaceFilterRadius, uint32_t);
118 
120 
124  vtkSetMacro(ThicknessAndVolumeColorFilterRadius, float);
125  vtkGetMacro(ThicknessAndVolumeColorFilterRadius, float);
127 
132  {
133  BilateralGaussian = 0,
135  // New filter method can be added here,
136  NumFilterMethods
137  };
138 
140 
143  vtkSetMacro(SurfaceFilterMethod, vtkOpenGLFluidMapper::FluidSurfaceFilterMethod);
144  vtkGetMacro(SurfaceFilterMethod, vtkOpenGLFluidMapper::FluidSurfaceFilterMethod);
146 
152  void SetNarrowRangeFilterParameters(float lambda, float mu)
153  {
154  this->NRFilterLambda = lambda;
155  this->NRFilterMu = mu;
156  }
157 
162  void SetBilateralGaussianFilterParameter(float sigmaDepth)
163  {
164  this->BiGaussFilterSigmaDepth = sigmaDepth;
165  }
166 
171  {
172  UnfilteredOpaqueSurface = 0,
177  NumDisplayModes
178  };
179 
181 
184  vtkSetMacro(DisplayMode, vtkOpenGLFluidMapper::FluidDisplayMode);
185  vtkGetMacro(DisplayMode, vtkOpenGLFluidMapper::FluidDisplayMode);
187 
189 
194  vtkSetVector3Macro(AttenuationColor, float);
195  vtkGetVector3Macro(AttenuationColor, float);
197 
199 
203  vtkSetVector3Macro(OpaqueColor, float);
204  vtkGetVector3Macro(OpaqueColor, float);
206 
208 
214  vtkSetMacro(ParticleColorPower, float);
215  vtkGetMacro(ParticleColorPower, float);
217 
219 
225  vtkSetMacro(ParticleColorScale, float);
226  vtkGetMacro(ParticleColorScale, float);
228 
230 
236  vtkSetMacro(AttenuationScale, float);
237  vtkGetMacro(AttenuationScale, float);
239 
241 
247  vtkSetMacro(AdditionalReflection, float);
248  vtkGetMacro(AdditionalReflection, float);
250 
252 
258  vtkSetMacro(RefractionScale, float);
259  vtkGetMacro(RefractionScale, float);
261 
263 
266  vtkSetMacro(RefractiveIndex, float);
267  vtkGetMacro(RefractiveIndex, float);
269 
273  void Render(vtkRenderer* ren, vtkVolume* vol) override;
274 
280  void ReleaseGraphicsResources(vtkWindow* w) override;
281 
282 protected:
284  ~vtkOpenGLFluidMapper() override;
285 
289  void UpdateDepthThicknessColorShaders(
290  vtkOpenGLHelper& glHelper, vtkRenderer* renderer, vtkVolume* vol);
291 
295  void SetDepthThicknessColorShaderParameters(
296  vtkOpenGLHelper& glHelper, vtkRenderer* renderer, vtkVolume* vol);
297 
301  void SetupBuffers(vtkOpenGLRenderWindow* const renderWindow);
302 
306  void RenderParticles(vtkRenderer* renderer, vtkVolume* vol);
307 
308  // Public parameters, their usage are stated at their Get/Set functions
309  // ======>>>>>
310  float ParticleRadius = 1.0f;
311 
312  FluidSurfaceFilterMethod SurfaceFilterMethod = FluidSurfaceFilterMethod::NarrowRange;
313  uint32_t SurfaceFilterIterations = 3u;
314  uint32_t SurfaceFilterRadius = 5u;
315  float NRFilterLambda = 10.0f;
316  float NRFilterMu = 1.0f;
317  float BiGaussFilterSigmaDepth = 10.0f;
318 
319  uint32_t ThicknessAndVolumeColorFilterIterations = 3u;
320  uint32_t ThicknessAndVolumeColorFilterRadius = 10u;
321 
322  FluidDisplayMode DisplayMode = FluidDisplayMode::TransparentFluidVolume;
323 
324  float OpaqueColor[3]{ 0.0f, 0.0f, 0.95f };
325  float AttenuationColor[3]{ 0.5f, 0.2f, 0.05f };
326  float ParticleColorPower = 0.1f;
327  float ParticleColorScale = 1.0f;
328  float AttenuationScale = 1.0f;
329  float AdditionalReflection = 0.0f;
330  float RefractionScale = 1.0f;
331  float RefractiveIndex = 1.33f;
332 
333  bool ScalarVisibility = false;
334  bool InDepthPass = true;
335 
336  // Private parameters ======>>>>>
337 
338  // Indicate that the input data has a color buffer
339  bool HasVertexColor = false;
340 
341  // Cache viewport dimensions
346 
347  // Cache camera parameters
354 
355  // Frame buffers
361 
362  // Screen quad render
363  vtkOpenGLQuadHelper* QuadFluidDepthFilter[NumFilterMethods]{ nullptr, nullptr };
364  vtkOpenGLQuadHelper* QuadThicknessFilter = nullptr;
365  vtkOpenGLQuadHelper* QuadFluidNormal = nullptr;
366  vtkOpenGLQuadHelper* QuadFinalBlend = nullptr;
367 
368  // The VBO and its layout for rendering particles
370  vtkTimeStamp VBOBuildTime; // When was the OpenGL VBO updated?
372 
373  // Texture buffers
375  {
376  OpaqueZ = 0,
384  NumTexBuffers
385  };
386 
387  // These are optional texture buffers
389  {
390  Color = 0,
392  NumOptionalTexBuffers
393  };
394 
395  vtkTextureObject* TexBuffer[NumTexBuffers];
396  vtkTextureObject* OptionalTexBuffer[NumOptionalTexBuffers];
398 
399 private:
401  void operator=(const vtkOpenGLFluidMapper&) = delete;
402 };
403 
404 #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:67
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)