VTK  9.5.2
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
15#ifndef vtkOpenGLFluidMapper_h
16#define vtkOpenGLFluidMapper_h
17
19
20#include "vtkOpenGLHelper.h" // used for ivars
21#include "vtkRenderingOpenGL2Module.h" // For export macro
22#include "vtkShader.h" // for methods
23#include "vtkSmartPointer.h" // for ivars
24#include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
25
26#include <map> //for methods
27
28VTK_ABI_NAMESPACE_BEGIN
29class vtkMatrix3x3;
30class vtkMatrix4x4;
33class vtkOpenGLState;
36class vtkPolyData;
38
39class VTKRENDERINGOPENGL2_EXPORT VTK_MARSHALAUTO vtkOpenGLFluidMapper
41{
42public:
45 void PrintSelf(ostream& os, vtkIndent indent) override;
46
48
54
56
59 vtkSetMacro(ScalarVisibility, bool);
60 vtkGetMacro(ScalarVisibility, bool);
61 vtkBooleanMacro(ScalarVisibility, bool);
63
65
72 vtkSetMacro(ParticleRadius, float);
73 vtkGetMacro(ParticleRadius, float);
75
77
83 vtkSetMacro(SurfaceFilterIterations, vtkTypeUInt32);
84 vtkGetMacro(SurfaceFilterIterations, vtkTypeUInt32);
86
88
92 vtkSetMacro(ThicknessAndVolumeColorFilterIterations, vtkTypeUInt32);
93 vtkGetMacro(ThicknessAndVolumeColorFilterIterations, vtkTypeUInt32);
95
97
104 vtkSetMacro(SurfaceFilterRadius, vtkTypeUInt32);
105 vtkGetMacro(SurfaceFilterRadius, vtkTypeUInt32);
107
109
113 vtkSetMacro(ThicknessAndVolumeColorFilterRadius, float);
114 vtkGetMacro(ThicknessAndVolumeColorFilterRadius, float);
116
121 {
122 BilateralGaussian = 0,
124 // New filter method can be added here,
125 NumFilterMethods
126 };
127
129
132 vtkSetMacro(SurfaceFilterMethod, vtkOpenGLFluidMapper::FluidSurfaceFilterMethod);
133 vtkGetMacro(SurfaceFilterMethod, vtkOpenGLFluidMapper::FluidSurfaceFilterMethod);
135
141 void SetNarrowRangeFilterParameters(float lambda, float mu)
142 {
143 this->NRFilterLambda = lambda;
144 this->NRFilterMu = mu;
145 }
146
152 {
153 this->BiGaussFilterSigmaDepth = sigmaDepth;
154 }
155
160 {
161 UnfilteredOpaqueSurface = 0,
166 NumDisplayModes
167 };
168
170
173 vtkSetMacro(DisplayMode, vtkOpenGLFluidMapper::FluidDisplayMode);
174 vtkGetMacro(DisplayMode, vtkOpenGLFluidMapper::FluidDisplayMode);
176
178
183 vtkSetVector3Macro(AttenuationColor, float);
184 vtkGetVector3Macro(AttenuationColor, float);
186
188
192 vtkSetVector3Macro(OpaqueColor, float);
193 vtkGetVector3Macro(OpaqueColor, float);
195
197
203 vtkSetMacro(ParticleColorPower, float);
204 vtkGetMacro(ParticleColorPower, float);
206
208
214 vtkSetMacro(ParticleColorScale, float);
215 vtkGetMacro(ParticleColorScale, float);
217
219
225 vtkSetMacro(AttenuationScale, float);
226 vtkGetMacro(AttenuationScale, float);
228
230
236 vtkSetMacro(AdditionalReflection, float);
237 vtkGetMacro(AdditionalReflection, float);
239
241
247 vtkSetMacro(RefractionScale, float);
248 vtkGetMacro(RefractionScale, float);
250
252
255 vtkSetMacro(RefractiveIndex, float);
256 vtkGetMacro(RefractiveIndex, float);
258
262 void Render(vtkRenderer* ren, vtkVolume* vol) override;
263
270
271protected:
274
279 vtkOpenGLHelper& glHelper, vtkRenderer* renderer, vtkVolume* vol);
280
285 vtkOpenGLHelper& glHelper, vtkRenderer* renderer, vtkVolume* vol);
286
291
295 void RenderParticles(vtkRenderer* renderer, vtkVolume* vol);
296
297 // Public parameters, their usage are stated at their Get/Set functions
298 // ======>>>>>
299 float ParticleRadius = 1.0f;
300
301 FluidSurfaceFilterMethod SurfaceFilterMethod = FluidSurfaceFilterMethod::NarrowRange;
302 vtkTypeUInt32 SurfaceFilterIterations = 3u;
303 vtkTypeUInt32 SurfaceFilterRadius = 5u;
304 float NRFilterLambda = 10.0f;
305 float NRFilterMu = 1.0f;
306 float BiGaussFilterSigmaDepth = 10.0f;
307
308 vtkTypeUInt32 ThicknessAndVolumeColorFilterIterations = 3u;
309 vtkTypeUInt32 ThicknessAndVolumeColorFilterRadius = 10u;
310
311 FluidDisplayMode DisplayMode = FluidDisplayMode::TransparentFluidVolume;
312
313 float OpaqueColor[3]{ 0.0f, 0.0f, 0.95f };
314 float AttenuationColor[3]{ 0.5f, 0.2f, 0.05f };
315 float ParticleColorPower = 0.1f;
316 float ParticleColorScale = 1.0f;
317 float AttenuationScale = 1.0f;
318 float AdditionalReflection = 0.0f;
319 float RefractionScale = 1.0f;
320 float RefractiveIndex = 1.33f;
321
322 bool ScalarVisibility = false;
323 bool InDepthPass = true;
324
325 // Private parameters ======>>>>>
326
327 // Indicate that the input data has a color buffer
328 bool HasVertexColor = false;
329
330 // Cache viewport dimensions
335
336 // Cache camera parameters
343
344 // Frame buffers
350
351 // Screen quad render
352 vtkOpenGLQuadHelper* QuadFluidDepthFilter[NumFilterMethods]{ nullptr, nullptr };
353 vtkOpenGLQuadHelper* QuadThicknessFilter = nullptr;
354 vtkOpenGLQuadHelper* QuadFluidNormal = nullptr;
355 vtkOpenGLQuadHelper* QuadFinalBlend = nullptr;
356
357 // The VBO and its layout for rendering particles
359 vtkTimeStamp VBOBuildTime; // When was the OpenGL VBO updated?
361
362 // Texture buffers
364 {
365 OpaqueZ = 0,
373 NumTexBuffers
374 };
375
376 // These are optional texture buffers
378 {
379 Color = 0,
381 NumOptionalTexBuffers
382 };
383
384 vtkTextureObject* TexBuffer[NumTexBuffers];
385 vtkTextureObject* OptionalTexBuffer[NumOptionalTexBuffers];
387
388private:
390 void operator=(const vtkOpenGLFluidMapper&) = delete;
391};
392
393VTK_ABI_NAMESPACE_END
394#endif
Abstract class for a volume mapper.
a simple class to control print indentation
Definition vtkIndent.h:29
represent and manipulate 3x3 transformation matrices
represent and manipulate 4x4 transformation matrices
Render fluid from position data (and color, if available)
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.
vtkPolyData * GetInput()
Specify the input data to map.
vtkSmartPointer< vtkOpenGLFramebufferObject > FBFluidEyeZ
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.
static vtkOpenGLFluidMapper * New()
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.
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:72
abstract specification for renderers
Definition vtkRenderer.h:60
Hold a reference to a vtkObjectBase instance.
abstracts an OpenGL texture object.
record modification and/or execution time
represents a volume (data & properties) in a rendered scene
Definition vtkVolume.h:41
window superclass for vtkRenderWindow
Definition vtkWindow.h:26
int vtkTypeBool
Definition vtkABI.h:64
#define VTK_MARSHALAUTO