VTK  9.7.1
vtkOpenGLFluidMapper.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
18 #ifndef vtkOpenGLFluidMapper_h
19 #define vtkOpenGLFluidMapper_h
20 
22 
23 #include "vtkOpenGLHelper.h" // used for ivars
24 #include "vtkRenderingOpenGL2Module.h" // For export macro
25 #include "vtkShader.h" // for methods
26 #include "vtkSmartPointer.h" // for ivars
27 #include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
28 
29 #include <map> //for methods
30 
31 VTK_ABI_NAMESPACE_BEGIN
32 class vtkMatrix3x3;
33 class vtkMatrix4x4;
36 class vtkOpenGLState;
39 class vtkPolyData;
40 class vtkTextureObject;
41 
42 class VTKRENDERINGOPENGL2_EXPORT VTK_MARSHALAUTO vtkOpenGLFluidMapper
44 {
45 public:
46  static vtkOpenGLFluidMapper* New();
48  void PrintSelf(ostream& os, vtkIndent indent) override;
49 
51 
54  void SetInputData(vtkPolyData* in);
55  vtkPolyData* GetInput();
57 
59 
62  vtkSetMacro(ScalarVisibility, bool);
63  vtkGetMacro(ScalarVisibility, bool);
64  vtkBooleanMacro(ScalarVisibility, bool);
66 
68 
75  vtkSetMacro(ParticleRadius, float);
76  vtkGetMacro(ParticleRadius, float);
78 
80 
86  vtkSetMacro(SurfaceFilterIterations, vtkTypeUInt32);
87  vtkGetMacro(SurfaceFilterIterations, vtkTypeUInt32);
89 
91 
95  vtkSetMacro(ThicknessAndVolumeColorFilterIterations, vtkTypeUInt32);
96  vtkGetMacro(ThicknessAndVolumeColorFilterIterations, vtkTypeUInt32);
98 
100 
107  vtkSetMacro(SurfaceFilterRadius, vtkTypeUInt32);
108  vtkGetMacro(SurfaceFilterRadius, vtkTypeUInt32);
110 
112 
116  vtkSetMacro(ThicknessAndVolumeColorFilterRadius, float);
117  vtkGetMacro(ThicknessAndVolumeColorFilterRadius, float);
119 
124  {
125  BilateralGaussian = 0,
127  // New filter method can be added here,
128  NumFilterMethods
129  };
130 
132 
135  vtkSetMacro(SurfaceFilterMethod, vtkOpenGLFluidMapper::FluidSurfaceFilterMethod);
136  vtkGetMacro(SurfaceFilterMethod, vtkOpenGLFluidMapper::FluidSurfaceFilterMethod);
138 
144  void SetNarrowRangeFilterParameters(float lambda, float mu)
145  {
146  this->NRFilterLambda = lambda;
147  this->NRFilterMu = mu;
148  }
149 
154  void SetBilateralGaussianFilterParameter(float sigmaDepth)
155  {
156  this->BiGaussFilterSigmaDepth = sigmaDepth;
157  }
158 
163  {
164  UnfilteredOpaqueSurface = 0,
169  NumDisplayModes
170  };
171 
173 
176  vtkSetMacro(DisplayMode, vtkOpenGLFluidMapper::FluidDisplayMode);
177  vtkGetMacro(DisplayMode, vtkOpenGLFluidMapper::FluidDisplayMode);
179 
181 
186  vtkSetVector3Macro(AttenuationColor, float);
187  vtkGetVector3Macro(AttenuationColor, float);
189 
191 
195  vtkSetVector3Macro(OpaqueColor, float);
196  vtkGetVector3Macro(OpaqueColor, float);
198 
200 
206  vtkSetMacro(ParticleColorPower, float);
207  vtkGetMacro(ParticleColorPower, float);
209 
211 
217  vtkSetMacro(ParticleColorScale, float);
218  vtkGetMacro(ParticleColorScale, float);
220 
222 
228  vtkSetMacro(AttenuationScale, float);
229  vtkGetMacro(AttenuationScale, float);
231 
233 
239  vtkSetMacro(AdditionalReflection, float);
240  vtkGetMacro(AdditionalReflection, float);
242 
244 
250  vtkSetMacro(RefractionScale, float);
251  vtkGetMacro(RefractionScale, float);
253 
255 
258  vtkSetMacro(RefractiveIndex, float);
259  vtkGetMacro(RefractiveIndex, float);
261 
265  void Render(vtkRenderer* ren, vtkVolume* vol) override;
266 
272  void ReleaseGraphicsResources(vtkWindow* w) override;
273 
274 protected:
276  ~vtkOpenGLFluidMapper() override;
277 
281  void UpdateDepthThicknessColorShaders(
282  vtkOpenGLHelper& glHelper, vtkRenderer* renderer, vtkVolume* vol);
283 
287  void SetDepthThicknessColorShaderParameters(
288  vtkOpenGLHelper& glHelper, vtkRenderer* renderer, vtkVolume* vol);
289 
293  void SetupBuffers(vtkOpenGLRenderWindow* renderWindow);
294 
298  void RenderParticles(vtkRenderer* renderer, vtkVolume* vol);
299 
300  // Public parameters, their usage are stated at their Get/Set functions
301  // ======>>>>>
302  float ParticleRadius = 1.0f;
303 
304  FluidSurfaceFilterMethod SurfaceFilterMethod = FluidSurfaceFilterMethod::NarrowRange;
305  vtkTypeUInt32 SurfaceFilterIterations = 3u;
306  vtkTypeUInt32 SurfaceFilterRadius = 5u;
307  float NRFilterLambda = 10.0f;
308  float NRFilterMu = 1.0f;
309  float BiGaussFilterSigmaDepth = 10.0f;
310 
311  vtkTypeUInt32 ThicknessAndVolumeColorFilterIterations = 3u;
312  vtkTypeUInt32 ThicknessAndVolumeColorFilterRadius = 10u;
313 
314  FluidDisplayMode DisplayMode = FluidDisplayMode::TransparentFluidVolume;
315 
316  float OpaqueColor[3]{ 0.0f, 0.0f, 0.95f };
317  float AttenuationColor[3]{ 0.5f, 0.2f, 0.05f };
318  float ParticleColorPower = 0.1f;
319  float ParticleColorScale = 1.0f;
320  float AttenuationScale = 1.0f;
321  float AdditionalReflection = 0.0f;
322  float RefractionScale = 1.0f;
323  float RefractiveIndex = 1.33f;
324 
325  bool ScalarVisibility = false;
326  bool InDepthPass = true;
327 
328  // Private parameters ======>>>>>
329 
330  // Indicate that the input data has a color buffer
331  bool HasVertexColor = false;
332 
333  // Cache viewport dimensions
338 
339  // Cache camera parameters
346 
347  // Frame buffers
353 
354  // Screen quad render
355  vtkOpenGLQuadHelper* QuadFluidDepthFilter[NumFilterMethods]{ nullptr, nullptr };
356  vtkOpenGLQuadHelper* QuadThicknessFilter = nullptr;
357  vtkOpenGLQuadHelper* QuadFluidNormal = nullptr;
358  vtkOpenGLQuadHelper* QuadFinalBlend = nullptr;
359 
360  // The VBO and its layout for rendering particles
362  vtkTimeStamp VBOBuildTime; // When was the OpenGL VBO updated?
364 
365  // Texture buffers
367  {
368  OpaqueZ = 0,
376  NumTexBuffers
377  };
378 
379  // These are optional texture buffers
381  {
382  Color = 0,
384  NumOptionalTexBuffers
385  };
386 
387  vtkTextureObject* TexBuffer[NumTexBuffers];
388  vtkTextureObject* OptionalTexBuffer[NumOptionalTexBuffers];
390 
391 private:
393  void operator=(const vtkOpenGLFluidMapper&) = delete;
394 };
395 
396 VTK_ABI_NAMESPACE_END
397 #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:40
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:31
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:24
vtkSmartPointer< vtkOpenGLFramebufferObject > FBFilterDepth
Abstract class for a volume mapper.
abstract specification for renderers
Definition: vtkRenderer.h:63
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:71
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:64
window superclass for vtkRenderWindow
Definition: vtkWindow.h:41
OpenGL state storage.
a simple class to control print indentation
Definition: vtkIndent.h:28
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()
#define VTK_MARSHALAUTO
vtkSmartPointer< vtkOpenGLFramebufferObject > FBFluidEyeZ
represent and manipulate 3x3 transformation matrices
Definition: vtkMatrix3x3.h:26
vtkSmartPointer< vtkOpenGLFramebufferObject > FBCompNormal
manage vertex buffer objects shared within a mapper
vtkSmartPointer< vtkOpenGLVertexBufferObjectGroup > VBOs
Render fluid from position data (and color, if available)