VTK  9.3.0
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
25#include <map> //for methods
26
27VTK_ABI_NAMESPACE_BEGIN
28class vtkMatrix3x3;
29class vtkMatrix4x4;
32class vtkOpenGLState;
35class vtkPolyData;
37
38class VTKRENDERINGOPENGL2_EXPORT vtkOpenGLFluidMapper : public vtkAbstractVolumeMapper
39{
40public:
43 void PrintSelf(ostream& os, vtkIndent indent) override;
44
46
52
54
57 vtkSetMacro(ScalarVisibility, bool);
58 vtkGetMacro(ScalarVisibility, bool);
59 vtkBooleanMacro(ScalarVisibility, bool);
61
63
70 vtkSetMacro(ParticleRadius, float);
71 vtkGetMacro(ParticleRadius, float);
73
75
81 vtkSetMacro(SurfaceFilterIterations, uint32_t);
82 vtkGetMacro(SurfaceFilterIterations, uint32_t);
84
86
90 vtkSetMacro(ThicknessAndVolumeColorFilterIterations, uint32_t);
91 vtkGetMacro(ThicknessAndVolumeColorFilterIterations, uint32_t);
93
95
102 vtkSetMacro(SurfaceFilterRadius, uint32_t);
103 vtkGetMacro(SurfaceFilterRadius, uint32_t);
105
107
111 vtkSetMacro(ThicknessAndVolumeColorFilterRadius, float);
112 vtkGetMacro(ThicknessAndVolumeColorFilterRadius, float);
114
119 {
120 BilateralGaussian = 0,
122 // New filter method can be added here,
123 NumFilterMethods
124 };
125
127
130 vtkSetMacro(SurfaceFilterMethod, vtkOpenGLFluidMapper::FluidSurfaceFilterMethod);
131 vtkGetMacro(SurfaceFilterMethod, vtkOpenGLFluidMapper::FluidSurfaceFilterMethod);
133
139 void SetNarrowRangeFilterParameters(float lambda, float mu)
140 {
141 this->NRFilterLambda = lambda;
142 this->NRFilterMu = mu;
143 }
144
150 {
151 this->BiGaussFilterSigmaDepth = sigmaDepth;
152 }
153
158 {
159 UnfilteredOpaqueSurface = 0,
164 NumDisplayModes
165 };
166
168
171 vtkSetMacro(DisplayMode, vtkOpenGLFluidMapper::FluidDisplayMode);
172 vtkGetMacro(DisplayMode, vtkOpenGLFluidMapper::FluidDisplayMode);
174
176
181 vtkSetVector3Macro(AttenuationColor, float);
182 vtkGetVector3Macro(AttenuationColor, float);
184
186
190 vtkSetVector3Macro(OpaqueColor, float);
191 vtkGetVector3Macro(OpaqueColor, float);
193
195
201 vtkSetMacro(ParticleColorPower, float);
202 vtkGetMacro(ParticleColorPower, float);
204
206
212 vtkSetMacro(ParticleColorScale, float);
213 vtkGetMacro(ParticleColorScale, float);
215
217
223 vtkSetMacro(AttenuationScale, float);
224 vtkGetMacro(AttenuationScale, float);
226
228
234 vtkSetMacro(AdditionalReflection, float);
235 vtkGetMacro(AdditionalReflection, float);
237
239
245 vtkSetMacro(RefractionScale, float);
246 vtkGetMacro(RefractionScale, float);
248
250
253 vtkSetMacro(RefractiveIndex, float);
254 vtkGetMacro(RefractiveIndex, float);
256
260 void Render(vtkRenderer* ren, vtkVolume* vol) override;
261
268
269protected:
272
277 vtkOpenGLHelper& glHelper, vtkRenderer* renderer, vtkVolume* vol);
278
283 vtkOpenGLHelper& glHelper, vtkRenderer* renderer, vtkVolume* vol);
284
289
293 void RenderParticles(vtkRenderer* renderer, vtkVolume* vol);
294
295 // Public parameters, their usage are stated at their Get/Set functions
296 // ======>>>>>
297 float ParticleRadius = 1.0f;
298
299 FluidSurfaceFilterMethod SurfaceFilterMethod = FluidSurfaceFilterMethod::NarrowRange;
300 uint32_t SurfaceFilterIterations = 3u;
301 uint32_t SurfaceFilterRadius = 5u;
302 float NRFilterLambda = 10.0f;
303 float NRFilterMu = 1.0f;
304 float BiGaussFilterSigmaDepth = 10.0f;
305
306 uint32_t ThicknessAndVolumeColorFilterIterations = 3u;
307 uint32_t ThicknessAndVolumeColorFilterRadius = 10u;
308
309 FluidDisplayMode DisplayMode = FluidDisplayMode::TransparentFluidVolume;
310
311 float OpaqueColor[3]{ 0.0f, 0.0f, 0.95f };
312 float AttenuationColor[3]{ 0.5f, 0.2f, 0.05f };
313 float ParticleColorPower = 0.1f;
314 float ParticleColorScale = 1.0f;
315 float AttenuationScale = 1.0f;
316 float AdditionalReflection = 0.0f;
317 float RefractionScale = 1.0f;
318 float RefractiveIndex = 1.33f;
319
320 bool ScalarVisibility = false;
321 bool InDepthPass = true;
322
323 // Private parameters ======>>>>>
324
325 // Indicate that the input data has a color buffer
326 bool HasVertexColor = false;
327
328 // Cache viewport dimensions
333
334 // Cache camera parameters
341
342 // Frame buffers
348
349 // Screen quad render
350 vtkOpenGLQuadHelper* QuadFluidDepthFilter[NumFilterMethods]{ nullptr, nullptr };
351 vtkOpenGLQuadHelper* QuadThicknessFilter = nullptr;
352 vtkOpenGLQuadHelper* QuadFluidNormal = nullptr;
353 vtkOpenGLQuadHelper* QuadFinalBlend = nullptr;
354
355 // The VBO and its layout for rendering particles
357 vtkTimeStamp VBOBuildTime; // When was the OpenGL VBO updated?
359
360 // Texture buffers
362 {
363 OpaqueZ = 0,
371 NumTexBuffers
372 };
373
374 // These are optional texture buffers
376 {
377 Color = 0,
379 NumOptionalTexBuffers
380 };
381
382 vtkTextureObject* TexBuffer[NumTexBuffers];
383 vtkTextureObject* OptionalTexBuffer[NumOptionalTexBuffers];
385
386private:
388 void operator=(const vtkOpenGLFluidMapper&) = delete;
389};
390
391VTK_ABI_NAMESPACE_END
392#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:80
abstract specification for renderers
Definition vtkRenderer.h:59
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:40
window superclass for vtkRenderWindow
Definition vtkWindow.h:25
int vtkTypeBool
Definition vtkABI.h:64