VTK  9.4.20250102
vtkDualDepthPeelingPass.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
3
39#ifndef vtkDualDepthPeelingPass_h
40#define vtkDualDepthPeelingPass_h
41
42#include "vtkDepthPeelingPass.h"
43#include "vtkRenderingOpenGL2Module.h" // For export macro
44#include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
45
46#include <array> // For std::array!
47
48VTK_ABI_NAMESPACE_BEGIN
55
56class VTKRENDERINGOPENGL2_EXPORT VTK_MARSHALAUTO vtkDualDepthPeelingPass
57 : public vtkDepthPeelingPass
58{
59public:
62 void PrintSelf(ostream& os, vtkIndent indent) override;
63
64 void Render(const vtkRenderState* s) override;
66
68
73 vtkGetObjectMacro(VolumetricPass, vtkRenderPass)
74 virtual void SetVolumetricPass(vtkRenderPass* volumetricPass);
76
77 // vtkOpenGLRenderPass virtuals:
78 bool PreReplaceShaderValues(std::string& vertexShader, std::string& geometryShader,
79 std::string& fragmentShader, vtkAbstractMapper* mapper, vtkProp* prop) override;
80 bool PostReplaceShaderValues(std::string& vertexShader, std::string& geometryShader,
81 std::string& fragmentShader, vtkAbstractMapper* mapper, vtkProp* prop) override;
82 bool SetShaderParameters(vtkShaderProgram* program, vtkAbstractMapper* mapper, vtkProp* prop,
83 vtkOpenGLVertexArrayObject* VAO = nullptr) override;
84 vtkMTimeType GetShaderStageMTime() override;
85
86protected:
87 bool PostReplaceTranslucentShaderValues(std::string& vertexShader, std::string& geometryShader,
88 std::string& fragmentShader, vtkAbstractMapper* mapper, vtkProp* prop);
89 bool PreReplaceVolumetricShaderValues(std::string& vertexShader, std::string& geometryShader,
90 std::string& fragmentShader, vtkAbstractMapper* mapper, vtkProp* prop);
91 bool SetTranslucentShaderParameters(vtkShaderProgram* program, vtkAbstractMapper* mapper,
93 bool SetVolumetricShaderParameters(vtkShaderProgram* program, vtkAbstractMapper* mapper,
95
96 // Name the textures used by this render pass. These are indexes into
97 // this->Textures
99 {
100 BackTemp = 0, // RGBA8 back-to-front peeling buffer
101 Back, // RGBA8 back-to-front accumulation buffer
102 FrontA, // RGBA8 front-to-back accumulation buffer
103 FrontB, // RGBA8 front-to-back accumulation buffer
104 DepthA, // RG32F min-max depth buffer
105 DepthB, // RG32F min-max depth buffer
106 OpaqueDepth, // Stores the depth map from the opaque passes
107
108 NumberOfTextures
109 };
110
111 // The stages of this multipass render pass:
113 {
117
119 Inactive = -1,
120 };
121
123 {
125 VolumetricPeel
126 };
127
130
132 vtkSetMacro(CurrentPeelType, PeelType);
133
138
143
148
150
154 void Initialize(const vtkRenderState* state);
155
157
165
170 void ActivateDrawBuffer(TextureName id) { this->ActivateDrawBuffers(&id, 1); }
171 template <size_t NumTextures>
172 void ActivateDrawBuffers(const std::array<TextureName, NumTextures>& a)
173 {
174 this->ActivateDrawBuffers(a.data(), a.size());
175 }
176 void ActivateDrawBuffers(const TextureName* ids, size_t numTextures);
182 void Prepare();
183
187
189
191
195 void Peel();
196
197 // Depending on whether we're handling volumes or not, we'll initialize the
198 // front destination buffer by either clearing it or copying the last peel's
199 // output into it.
203
206
209
211
214
217
223
224 void Finalize();
225
227
230
234
239
240 vtkTextureObject* Textures[NumberOfTextures];
241
242 TextureName FrontSource; // The current front source buffer
243 TextureName FrontDestination; // The current front destination buffer
244 TextureName DepthSource; // The current depth source buffer
245 TextureName DepthDestination; // The current depth destination buffer
246
250
257 unsigned int OcclusionThreshold;
258
259 int TranslucentRenderCount; // Debug info, counts number of geometry passes.
260 int VolumetricRenderCount; // Debug info, counts number of volumetric passes.
261
262 // Cached state:
267
268private:
270 void operator=(const vtkDualDepthPeelingPass&) = delete;
271};
272
273VTK_ABI_NAMESPACE_END
274#endif // vtkDualDepthPeelingPass_h
abstract class specifies interface to map data
Implement Depth Peeling for use within a framebuffer pass.
Implements the dual depth peeling algorithm.
static vtkDualDepthPeelingPass * New()
void ActivateDrawBuffers(const std::array< TextureName, NumTextures > &a)
Bind and activate draw buffers.
void InitDepthTexture(vtkTextureObject *tex, const vtkRenderState *s)
Initialize helpers.
void PeelVolumesOutsideTranslucentRange()
void ReleaseGraphicsResources(vtkWindow *w) override
Release graphics resources and ask components to release their own resources.
void RenderVolumetricPass()
Render any volumetric geometry.
void Prepare()
Fill textures with initial values, bind the framebuffer.
void ActivateDrawBuffer(TextureName id)
Bind and activate draw buffers.
void StartTranslucentOcclusionQuery()
~vtkDualDepthPeelingPass() override
void InitializeTargetsForVolumetricPass()
void Initialize(const vtkRenderState *state)
Allocate and configure FBOs and textures.
vtkOpenGLQuadHelper * BlendHelper
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void SetCurrentStage(ShaderStage stage)
void SwapFrontBufferSourceDest()
Swap the src/dest render targets:
vtkOpenGLQuadHelper * CopyDepthHelper
void InitializeTargetsForTranslucentPass()
void FreeGLObjects()
Release all FBOs and textures.
void Peel()
Render the scene to produce the next set of peels.
vtkOpenGLQuadHelper * BackBlendHelper
void RenderTranslucentPass()
Render the translucent pass geometry, counting number of render calls.
void Render(const vtkRenderState *s) override
Perform rendering according to a render state s.
void ActivateDrawBuffers(const TextureName *ids, size_t numTextures)
Bind and activate draw buffers.
void StartVolumetricOcclusionQuery()
void CopyFrontSourceToFrontDestination()
vtkOpenGLQuadHelper * CopyColorHelper
const vtkRenderState * RenderState
void InitOpaqueDepthTexture(vtkTextureObject *tex, const vtkRenderState *s)
Initialize helpers.
void InitColorTexture(vtkTextureObject *tex, const vtkRenderState *s)
Initialize helpers.
void InitFramebuffer(const vtkRenderState *s)
Initialize helpers.
a simple class to control print indentation
Definition vtkIndent.h:108
Internal class which encapsulates OpenGL FramebufferObject.
Class to make rendering a full screen quad easier.
The VertexArrayObject class uses, or emulates, vertex array objects.
abstract superclass for all actors, volumes and annotations
Definition vtkProp.h:66
Perform part of the rendering of a vtkRenderer.
Context in which a vtkRenderPass will render.
Asynchronously measures GPU execution times for a series of events.
The ShaderProgram uses one or more Shader objects.
abstracts an OpenGL texture object.
record modification and/or execution time
window superclass for vtkRenderWindow
Definition vtkWindow.h:48
vtkTypeUInt32 vtkMTimeType
Definition vtkType.h:270
#define VTK_MARSHALAUTO