VTK  9.7.20260817
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
41
42#ifndef vtkDualDepthPeelingPass_h
43#define vtkDualDepthPeelingPass_h
44
45#include "vtkDepthPeelingPass.h"
46#include "vtkRenderingOpenGL2Module.h" // For export macro
47#include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
48
49#include <array> // For std::array!
50
51VTK_ABI_NAMESPACE_BEGIN
58
59class VTKRENDERINGOPENGL2_EXPORT VTK_MARSHALAUTO vtkDualDepthPeelingPass
60 : public vtkDepthPeelingPass
61{
62public:
65 void PrintSelf(ostream& os, vtkIndent indent) override;
66
67 void Render(const vtkRenderState* s) override;
69
71
76 vtkGetObjectMacro(VolumetricPass, vtkRenderPass)
77 virtual void SetVolumetricPass(vtkRenderPass* volumetricPass);
79
80 // vtkOpenGLRenderPass virtuals:
81 bool PreReplaceShaderValues(std::string& vertexShader, std::string& geometryShader,
82 std::string& fragmentShader, vtkAbstractMapper* mapper, vtkProp* prop) override;
83 bool PostReplaceShaderValues(std::string& vertexShader, std::string& geometryShader,
84 std::string& fragmentShader, vtkAbstractMapper* mapper, vtkProp* prop) override;
86 vtkOpenGLVertexArrayObject* VAO = nullptr) override;
88
89protected:
90 bool PostReplaceTranslucentShaderValues(std::string& vertexShader, std::string& geometryShader,
91 std::string& fragmentShader, vtkAbstractMapper* mapper, vtkProp* prop);
92 bool PreReplaceVolumetricShaderValues(std::string& vertexShader, std::string& geometryShader,
93 std::string& fragmentShader, vtkAbstractMapper* mapper, vtkProp* prop);
98
99 // Name the textures used by this render pass. These are indexes into
100 // this->Textures
102 {
103 BackTemp = 0, // RGBA8 back-to-front peeling buffer
104 Back, // RGBA8 back-to-front accumulation buffer
105 FrontA, // RGBA8 front-to-back accumulation buffer
106 FrontB, // RGBA8 front-to-back accumulation buffer
107 DepthA, // RG32F min-max depth buffer
108 DepthB, // RG32F min-max depth buffer
109 OpaqueDepth, // Stores the depth map from the opaque passes
110
112 };
113
114 // The stages of this multipass render pass:
124
130
133
136
141
146
151
153
157 void Initialize(const vtkRenderState* state);
158
160
168
174 template <size_t NumTextures>
175 void ActivateDrawBuffers(const std::array<TextureName, NumTextures>& a)
176 {
177 this->ActivateDrawBuffers(a.data(), a.size());
178 }
179 void ActivateDrawBuffers(const TextureName* ids, size_t numTextures);
181
185 void Prepare();
186
190
192
194
198 void Peel();
199
200 // Depending on whether we're handling volumes or not, we'll initialize the
201 // front destination buffer by either clearing it or copying the last peel's
202 // output into it.
206
209
212
214
217
220
226
227 void Finalize();
228
230
233
237
242
244
245 TextureName FrontSource; // The current front source buffer
246 TextureName FrontDestination; // The current front destination buffer
247 TextureName DepthSource; // The current depth source buffer
248 TextureName DepthDestination; // The current depth destination buffer
249
253
260 unsigned int OcclusionThreshold;
261
262 int TranslucentRenderCount; // Debug info, counts number of geometry passes.
263 int VolumetricRenderCount; // Debug info, counts number of volumetric passes.
264
265 // Cached state:
270
271private:
273 void operator=(const vtkDualDepthPeelingPass&) = delete;
274};
275
276VTK_ABI_NAMESPACE_END
277#endif // vtkDualDepthPeelingPass_h
abstract class specifies interface to map data
vtkDepthPeelingPass()
Default constructor.
static vtkDualDepthPeelingPass * New()
virtual void SetVolumetricPass(vtkRenderPass *volumetricPass)
Delegate for rendering the volumetric geometry, if needed.
void ActivateDrawBuffers(const std::array< TextureName, NumTextures > &a)
Bind and activate draw buffers.
bool PreReplaceVolumetricShaderValues(std::string &vertexShader, std::string &geometryShader, std::string &fragmentShader, vtkAbstractMapper *mapper, vtkProp *prop)
void InitDepthTexture(vtkTextureObject *tex, const vtkRenderState *s)
Initialize helpers.
vtkTextureObject * Textures[NumberOfTextures]
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:
vtkMTimeType GetShaderStageMTime() override
For multi-stage render passes that need to change shader code during a single pass,...
bool SetTranslucentShaderParameters(vtkShaderProgram *program, vtkAbstractMapper *mapper, vtkProp *prop, vtkOpenGLVertexArrayObject *VAO)
vtkOpenGLQuadHelper * CopyDepthHelper
void InitializeTargetsForTranslucentPass()
bool SetShaderParameters(vtkShaderProgram *program, vtkAbstractMapper *mapper, vtkProp *prop, vtkOpenGLVertexArrayObject *VAO=nullptr) override
Update the uniforms of the shader program.
void FreeGLObjects()
Release all FBOs and textures.
void Peel()
Render the scene to produce the next set of peels.
vtkOpenGLQuadHelper * BackBlendHelper
bool PostReplaceShaderValues(std::string &vertexShader, std::string &geometryShader, std::string &fragmentShader, vtkAbstractMapper *mapper, vtkProp *prop) override
Use vtkShaderProgram::Substitute to replace.
void RenderTranslucentPass()
Render the translucent pass geometry, counting number of render calls.
bool PreReplaceShaderValues(std::string &vertexShader, std::string &geometryShader, std::string &fragmentShader, vtkAbstractMapper *mapper, vtkProp *prop) override
Use vtkShaderProgram::Substitute to replace.
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.
bool PostReplaceTranslucentShaderValues(std::string &vertexShader, std::string &geometryShader, std::string &fragmentShader, vtkAbstractMapper *mapper, vtkProp *prop)
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.
bool SetVolumetricShaderParameters(vtkShaderProgram *program, vtkAbstractMapper *mapper, vtkProp *prop, vtkOpenGLVertexArrayObject *VAO)
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:68
vtkRenderPass()
Default constructor.
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:62
vtkTypeUInt32 vtkMTimeType
Definition vtkType.h:318
#define VTK_MARSHALAUTO