VTK  9.3.20240328
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 
28 #include <map> //for methods
29 
30 VTK_ABI_NAMESPACE_BEGIN
31 class vtkMatrix3x3;
32 class vtkMatrix4x4;
35 class vtkOpenGLState;
38 class vtkPolyData;
39 class vtkTextureObject;
40 
41 class VTKRENDERINGOPENGL2_EXPORT vtkOpenGLFluidMapper : public vtkAbstractVolumeMapper
42 {
43 public:
46  void PrintSelf(ostream& os, vtkIndent indent) override;
47 
49 
55 
57 
60  vtkSetMacro(ScalarVisibility, bool);
61  vtkGetMacro(ScalarVisibility, bool);
62  vtkBooleanMacro(ScalarVisibility, bool);
64 
66 
73  vtkSetMacro(ParticleRadius, float);
74  vtkGetMacro(ParticleRadius, float);
76 
78 
84  vtkSetMacro(SurfaceFilterIterations, uint32_t);
85  vtkGetMacro(SurfaceFilterIterations, uint32_t);
87 
89 
93  vtkSetMacro(ThicknessAndVolumeColorFilterIterations, uint32_t);
94  vtkGetMacro(ThicknessAndVolumeColorFilterIterations, uint32_t);
96 
98 
105  vtkSetMacro(SurfaceFilterRadius, uint32_t);
106  vtkGetMacro(SurfaceFilterRadius, uint32_t);
108 
110 
114  vtkSetMacro(ThicknessAndVolumeColorFilterRadius, float);
115  vtkGetMacro(ThicknessAndVolumeColorFilterRadius, float);
117 
122  {
123  BilateralGaussian = 0,
125  // New filter method can be added here,
126  NumFilterMethods
127  };
128 
130 
133  vtkSetMacro(SurfaceFilterMethod, vtkOpenGLFluidMapper::FluidSurfaceFilterMethod);
134  vtkGetMacro(SurfaceFilterMethod, vtkOpenGLFluidMapper::FluidSurfaceFilterMethod);
136 
142  void SetNarrowRangeFilterParameters(float lambda, float mu)
143  {
144  this->NRFilterLambda = lambda;
145  this->NRFilterMu = mu;
146  }
147 
152  void SetBilateralGaussianFilterParameter(float sigmaDepth)
153  {
154  this->BiGaussFilterSigmaDepth = sigmaDepth;
155  }
156 
161  {
162  UnfilteredOpaqueSurface = 0,
167  NumDisplayModes
168  };
169 
171 
174  vtkSetMacro(DisplayMode, vtkOpenGLFluidMapper::FluidDisplayMode);
175  vtkGetMacro(DisplayMode, vtkOpenGLFluidMapper::FluidDisplayMode);
177 
179 
184  vtkSetVector3Macro(AttenuationColor, float);
185  vtkGetVector3Macro(AttenuationColor, float);
187 
189 
193  vtkSetVector3Macro(OpaqueColor, float);
194  vtkGetVector3Macro(OpaqueColor, float);
196 
198 
204  vtkSetMacro(ParticleColorPower, float);
205  vtkGetMacro(ParticleColorPower, float);
207 
209 
215  vtkSetMacro(ParticleColorScale, float);
216  vtkGetMacro(ParticleColorScale, float);
218 
220 
226  vtkSetMacro(AttenuationScale, float);
227  vtkGetMacro(AttenuationScale, float);
229 
231 
237  vtkSetMacro(AdditionalReflection, float);
238  vtkGetMacro(AdditionalReflection, float);
240 
242 
248  vtkSetMacro(RefractionScale, float);
249  vtkGetMacro(RefractionScale, float);
251 
253 
256  vtkSetMacro(RefractiveIndex, float);
257  vtkGetMacro(RefractiveIndex, float);
259 
263  void Render(vtkRenderer* ren, vtkVolume* vol) override;
264 
271 
272 protected:
275 
280  vtkOpenGLHelper& glHelper, vtkRenderer* renderer, vtkVolume* vol);
281 
286  vtkOpenGLHelper& glHelper, vtkRenderer* renderer, vtkVolume* vol);
287 
291  void SetupBuffers(vtkOpenGLRenderWindow* renderWindow);
292 
296  void RenderParticles(vtkRenderer* renderer, vtkVolume* vol);
297 
298  // Public parameters, their usage are stated at their Get/Set functions
299  // ======>>>>>
300  float ParticleRadius = 1.0f;
301 
302  FluidSurfaceFilterMethod SurfaceFilterMethod = FluidSurfaceFilterMethod::NarrowRange;
303  uint32_t SurfaceFilterIterations = 3u;
304  uint32_t SurfaceFilterRadius = 5u;
305  float NRFilterLambda = 10.0f;
306  float NRFilterMu = 1.0f;
307  float BiGaussFilterSigmaDepth = 10.0f;
308 
309  uint32_t ThicknessAndVolumeColorFilterIterations = 3u;
310  uint32_t ThicknessAndVolumeColorFilterRadius = 10u;
311 
312  FluidDisplayMode DisplayMode = FluidDisplayMode::TransparentFluidVolume;
313 
314  float OpaqueColor[3]{ 0.0f, 0.0f, 0.95f };
315  float AttenuationColor[3]{ 0.5f, 0.2f, 0.05f };
316  float ParticleColorPower = 0.1f;
317  float ParticleColorScale = 1.0f;
318  float AttenuationScale = 1.0f;
319  float AdditionalReflection = 0.0f;
320  float RefractionScale = 1.0f;
321  float RefractiveIndex = 1.33f;
322 
323  bool ScalarVisibility = false;
324  bool InDepthPass = true;
325 
326  // Private parameters ======>>>>>
327 
328  // Indicate that the input data has a color buffer
329  bool HasVertexColor = false;
330 
331  // Cache viewport dimensions
336 
337  // Cache camera parameters
344 
345  // Frame buffers
351 
352  // Screen quad render
353  vtkOpenGLQuadHelper* QuadFluidDepthFilter[NumFilterMethods]{ nullptr, nullptr };
354  vtkOpenGLQuadHelper* QuadThicknessFilter = nullptr;
355  vtkOpenGLQuadHelper* QuadFluidNormal = nullptr;
356  vtkOpenGLQuadHelper* QuadFinalBlend = nullptr;
357 
358  // The VBO and its layout for rendering particles
360  vtkTimeStamp VBOBuildTime; // When was the OpenGL VBO updated?
362 
363  // Texture buffers
365  {
366  OpaqueZ = 0,
374  NumTexBuffers
375  };
376 
377  // These are optional texture buffers
379  {
380  Color = 0,
382  NumOptionalTexBuffers
383  };
384 
385  vtkTextureObject* TexBuffer[NumTexBuffers];
386  vtkTextureObject* OptionalTexBuffer[NumOptionalTexBuffers];
388 
389 private:
391  void operator=(const vtkOpenGLFluidMapper&) = delete;
392 };
393 
394 VTK_ABI_NAMESPACE_END
395 #endif
Abstract class for a volume mapper.
a simple class to control print indentation
Definition: vtkIndent.h:108
represent and manipulate 3x3 transformation matrices
Definition: vtkMatrix3x3.h:55
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:140
Render fluid from position data (and color, if available)
vtkMatrix3x3 * CamInvertedNorms
void SetInputData(vtkPolyData *in)
Specify the input data to map.
vtkSmartPointer< vtkOpenGLFramebufferObject > FBThickness
FluidDisplayMode
Display mode for the fluid, default value is TransparentFluidVolume.
void ReleaseGraphicsResources(vtkWindow *w) override
Release graphics resources and ask components to release their own resources.
vtkSmartPointer< vtkOpenGLVertexBufferObjectGroup > VBOs
void SetNarrowRangeFilterParameters(float lambda, float mu)
Optional parameters, exclusively for narrow range filter The first parameter is to control smoothing ...
void Render(vtkRenderer *ren, vtkVolume *vol) override
This calls RenderPiece.
vtkSmartPointer< vtkOpenGLFramebufferObject > FBCompNormal
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkSmartPointer< vtkOpenGLFramebufferObject > FBFluidEyeZ
vtkPolyData * GetInput()
Specify the input data to map.
vtkSmartPointer< vtkOpenGLFramebufferObject > FBFilterThickness
FluidSurfaceFilterMethod
Filter method to filter the depth buffer.
~vtkOpenGLFluidMapper() override
void SetupBuffers(vtkOpenGLRenderWindow *renderWindow)
Setup the texture buffers.
void UpdateDepthThicknessColorShaders(vtkOpenGLHelper &glHelper, vtkRenderer *renderer, vtkVolume *vol)
Perform string replacements on the shader templates.
void RenderParticles(vtkRenderer *renderer, vtkVolume *vol)
Render the fluid particles.
vtkSmartPointer< vtkOpenGLFramebufferObject > FBFilterDepth
void SetBilateralGaussianFilterParameter(float sigmaDepth)
Optional parameters, exclusively for bilateral gaussian filter The parameter is for controlling smoot...
vtkOpenGLHelper GLHelperDepthThickness
void SetDepthThicknessColorShaderParameters(vtkOpenGLHelper &glHelper, vtkRenderer *renderer, vtkVolume *vol)
Set the shader parameters related to the actor/mapper/camera.
static vtkOpenGLFluidMapper * New()
Internal class which encapsulates OpenGL FramebufferObject.
Class to make rendering a full screen quad easier.
OpenGL rendering window.
OpenGL state storage.
manage vertex buffer objects shared within a mapper
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:180
abstract specification for renderers
Definition: vtkRenderer.h:171
abstracts an OpenGL texture object.
record modification and/or execution time
Definition: vtkTimeStamp.h:44
represents a volume (data & properties) in a rendered scene
Definition: vtkVolume.h:119
window superclass for vtkRenderWindow
Definition: vtkWindow.h:47
@ Color
Definition: vtkX3D.h:46
int vtkTypeBool
Definition: vtkABI.h:64