VTK  9.1.0
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=========================================================================*/
23#ifndef vtkOpenGLFluidMapper_h
24#define vtkOpenGLFluidMapper_h
25
27
28#include "vtkOpenGLHelper.h" // used for ivars
29#include "vtkRenderingOpenGL2Module.h" // For export macro
30#include "vtkShader.h" // for methods
31#include "vtkSmartPointer.h" // for ivars
32
33#include <map> //for methods
34
35class vtkMatrix3x3;
36class vtkMatrix4x4;
39class vtkOpenGLState;
42class vtkPolyData;
44
45class VTKRENDERINGOPENGL2_EXPORT vtkOpenGLFluidMapper : public vtkAbstractVolumeMapper
46{
47public:
50 void PrintSelf(ostream& os, vtkIndent indent) override;
51
53
59
61
64 vtkSetMacro(ScalarVisibility, bool);
65 vtkGetMacro(ScalarVisibility, bool);
66 vtkBooleanMacro(ScalarVisibility, bool);
68
70
77 vtkSetMacro(ParticleRadius, float);
78 vtkGetMacro(ParticleRadius, float);
80
82
88 vtkSetMacro(SurfaceFilterIterations, uint32_t);
89 vtkGetMacro(SurfaceFilterIterations, uint32_t);
91
93
97 vtkSetMacro(ThicknessAndVolumeColorFilterIterations, uint32_t);
98 vtkGetMacro(ThicknessAndVolumeColorFilterIterations, uint32_t);
100
102
109 vtkSetMacro(SurfaceFilterRadius, uint32_t);
110 vtkGetMacro(SurfaceFilterRadius, uint32_t);
112
114
118 vtkSetMacro(ThicknessAndVolumeColorFilterRadius, float);
119 vtkGetMacro(ThicknessAndVolumeColorFilterRadius, float);
121
126 {
127 BilateralGaussian = 0,
129 // New filter method can be added here,
130 NumFilterMethods
131 };
132
134
137 vtkSetMacro(SurfaceFilterMethod, vtkOpenGLFluidMapper::FluidSurfaceFilterMethod);
138 vtkGetMacro(SurfaceFilterMethod, vtkOpenGLFluidMapper::FluidSurfaceFilterMethod);
140
146 void SetNarrowRangeFilterParameters(float lambda, float mu)
147 {
148 this->NRFilterLambda = lambda;
149 this->NRFilterMu = mu;
150 }
151
157 {
158 this->BiGaussFilterSigmaDepth = sigmaDepth;
159 }
160
165 {
166 UnfilteredOpaqueSurface = 0,
171 NumDisplayModes
172 };
173
175
178 vtkSetMacro(DisplayMode, vtkOpenGLFluidMapper::FluidDisplayMode);
179 vtkGetMacro(DisplayMode, vtkOpenGLFluidMapper::FluidDisplayMode);
181
183
188 vtkSetVector3Macro(AttenuationColor, float);
189 vtkGetVector3Macro(AttenuationColor, float);
191
193
197 vtkSetVector3Macro(OpaqueColor, float);
198 vtkGetVector3Macro(OpaqueColor, float);
200
202
208 vtkSetMacro(ParticleColorPower, float);
209 vtkGetMacro(ParticleColorPower, float);
211
213
219 vtkSetMacro(ParticleColorScale, float);
220 vtkGetMacro(ParticleColorScale, float);
222
224
230 vtkSetMacro(AttenuationScale, float);
231 vtkGetMacro(AttenuationScale, float);
233
235
241 vtkSetMacro(AdditionalReflection, float);
242 vtkGetMacro(AdditionalReflection, float);
244
246
252 vtkSetMacro(RefractionScale, float);
253 vtkGetMacro(RefractionScale, float);
255
257
260 vtkSetMacro(RefractiveIndex, float);
261 vtkGetMacro(RefractiveIndex, float);
263
267 void Render(vtkRenderer* ren, vtkVolume* vol) override;
268
275
276protected:
279
284 vtkOpenGLHelper& glHelper, vtkRenderer* renderer, vtkVolume* vol);
285
290 vtkOpenGLHelper& glHelper, vtkRenderer* renderer, vtkVolume* vol);
291
295 void SetupBuffers(vtkOpenGLRenderWindow* const renderWindow);
296
300 void RenderParticles(vtkRenderer* renderer, vtkVolume* vol);
301
302 // Public parameters, their usage are stated at their Get/Set functions
303 // ======>>>>>
304 float ParticleRadius = 1.0f;
305
306 FluidSurfaceFilterMethod SurfaceFilterMethod = FluidSurfaceFilterMethod::NarrowRange;
307 uint32_t SurfaceFilterIterations = 3u;
308 uint32_t SurfaceFilterRadius = 5u;
309 float NRFilterLambda = 10.0f;
310 float NRFilterMu = 1.0f;
311 float BiGaussFilterSigmaDepth = 10.0f;
312
313 uint32_t ThicknessAndVolumeColorFilterIterations = 3u;
314 uint32_t ThicknessAndVolumeColorFilterRadius = 10u;
315
316 FluidDisplayMode DisplayMode = FluidDisplayMode::TransparentFluidVolume;
317
318 float OpaqueColor[3]{ 0.0f, 0.0f, 0.95f };
319 float AttenuationColor[3]{ 0.5f, 0.2f, 0.05f };
320 float ParticleColorPower = 0.1f;
321 float ParticleColorScale = 1.0f;
322 float AttenuationScale = 1.0f;
323 float AdditionalReflection = 0.0f;
324 float RefractionScale = 1.0f;
325 float RefractiveIndex = 1.33f;
326
327 bool ScalarVisibility = false;
328 bool InDepthPass = true;
329
330 // Private parameters ======>>>>>
331
332 // Indicate that the input data has a color buffer
333 bool HasVertexColor = false;
334
335 // Cache viewport dimensions
340
341 // Cache camera parameters
348
349 // Frame buffers
355
356 // Screen quad render
357 vtkOpenGLQuadHelper* QuadFluidDepthFilter[NumFilterMethods]{ nullptr, nullptr };
358 vtkOpenGLQuadHelper* QuadThicknessFilter = nullptr;
359 vtkOpenGLQuadHelper* QuadFluidNormal = nullptr;
360 vtkOpenGLQuadHelper* QuadFinalBlend = nullptr;
361
362 // The VBO and its layout for rendering particles
364 vtkTimeStamp VBOBuildTime; // When was the OpenGL VBO updated?
366
367 // Texture buffers
369 {
370 OpaqueZ = 0,
378 NumTexBuffers
379 };
380
381 // These are optional texture buffers
383 {
384 Color = 0,
386 NumOptionalTexBuffers
387 };
388
389 vtkTextureObject* TexBuffer[NumTexBuffers];
390 vtkTextureObject* OptionalTexBuffer[NumOptionalTexBuffers];
392
393private:
395 void operator=(const vtkOpenGLFluidMapper&) = delete;
396};
397
398#endif
Abstract class for a volume mapper.
a simple class to control print indentation
Definition: vtkIndent.h:113
represent and manipulate 3x3 transformation matrices
Definition: vtkMatrix3x3.h:63
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:145
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.
vtkPolyData * GetInput()
Specify the input data to map.
vtkSmartPointer< vtkOpenGLFramebufferObject > FBFluidEyeZ
vtkSmartPointer< vtkOpenGLFramebufferObject > FBFilterThickness
FluidSurfaceFilterMethod
Filter method to filter the depth buffer.
void SetupBuffers(vtkOpenGLRenderWindow *const renderWindow)
Setup the texture buffers.
~vtkOpenGLFluidMapper() override
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:195
abstract specification for renderers
Definition: vtkRenderer.h:173
abstracts an OpenGL texture object.
record modification and/or execution time
Definition: vtkTimeStamp.h:52
represents a volume (data & properties) in a rendered scene
Definition: vtkVolume.h:134
window superclass for vtkRenderWindow
Definition: vtkWindow.h:36
@ Color
Definition: vtkX3D.h:52
int vtkTypeBool
Definition: vtkABI.h:69