VTK  9.1.0
vtkDualDepthPeelingPass.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: vtkDualDepthPeelingPass.h
5
6 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7 All rights reserved.
8 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9
10 This software is distributed WITHOUT ANY WARRANTY; without even
11 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12 PURPOSE. See the above copyright notice for more information.
13
14=========================================================================*/
15
51#ifndef vtkDualDepthPeelingPass_h
52#define vtkDualDepthPeelingPass_h
53
54#include "vtkDepthPeelingPass.h"
55#include "vtkRenderingOpenGL2Module.h" // For export macro
56
57#include <array> // For std::array!
58
65
66class VTKRENDERINGOPENGL2_EXPORT vtkDualDepthPeelingPass : public vtkDepthPeelingPass
67{
68public:
71 void PrintSelf(ostream& os, vtkIndent indent) override;
72
73 void Render(const vtkRenderState* s) override;
75
77
82 vtkGetObjectMacro(VolumetricPass, vtkRenderPass) virtual void SetVolumetricPass(
83 vtkRenderPass* volumetricPass);
85
86 // vtkOpenGLRenderPass virtuals:
87 bool PreReplaceShaderValues(std::string& vertexShader, std::string& geometryShader,
88 std::string& fragmentShader, vtkAbstractMapper* mapper, vtkProp* prop) override;
89 bool PostReplaceShaderValues(std::string& vertexShader, std::string& geometryShader,
90 std::string& fragmentShader, vtkAbstractMapper* mapper, vtkProp* prop) override;
92 vtkOpenGLVertexArrayObject* VAO = nullptr) override;
94
95protected:
96 bool PostReplaceTranslucentShaderValues(std::string& vertexShader, std::string& geometryShader,
97 std::string& fragmentShader, vtkAbstractMapper* mapper, vtkProp* prop);
98 bool PreReplaceVolumetricShaderValues(std::string& vertexShader, std::string& geometryShader,
99 std::string& fragmentShader, vtkAbstractMapper* mapper, vtkProp* prop);
104
105 // Name the textures used by this render pass. These are indexes into
106 // this->Textures
108 {
109 BackTemp = 0, // RGBA8 back-to-front peeling buffer
110 Back, // RGBA8 back-to-front accumulation buffer
111 FrontA, // RGBA8 front-to-back accumulation buffer
112 FrontB, // RGBA8 front-to-back accumulation buffer
113 DepthA, // RG32F min-max depth buffer
114 DepthB, // RG32F min-max depth buffer
115 OpaqueDepth, // Stores the depth map from the opaque passes
116
117 NumberOfTextures
118 };
119
120 // The stages of this multipass render pass:
122 {
126
128 Inactive = -1,
129 };
130
132 {
134 VolumetricPeel
135 };
136
139
141 vtkSetMacro(CurrentPeelType, PeelType);
142
147
152
157
159
163 void Initialize(const vtkRenderState* state);
164
166
174
179 void ActivateDrawBuffer(TextureName id) { this->ActivateDrawBuffers(&id, 1); }
180 template <size_t NumTextures>
181 void ActivateDrawBuffers(const std::array<TextureName, NumTextures>& a)
182 {
183 this->ActivateDrawBuffers(a.data(), a.size());
184 }
185 void ActivateDrawBuffers(const TextureName* ids, size_t numTextures);
191 void Prepare();
192
196
198
200
204 void Peel();
205
206 // Depending on whether we're handling volumes or not, we'll initialize the
207 // front destination buffer by either clearing it or copying the last peel's
208 // output into it.
212
215
218
220
223
226
232
233 void Finalize();
234
236
239
243
248
249 vtkTextureObject* Textures[NumberOfTextures];
250
251 TextureName FrontSource; // The current front source buffer
252 TextureName FrontDestination; // The current front destination buffer
253 TextureName DepthSource; // The current depth source buffer
254 TextureName DepthDestination; // The current depth destination buffer
255
259
266 unsigned int OcclusionThreshold;
267
268 int TranslucentRenderCount; // Debug info, counts number of geometry passes.
269 int VolumetricRenderCount; // Debug info, counts number of volumetric passes.
270
271 // Cached state:
276
277private:
279 void operator=(const vtkDualDepthPeelingPass&) = delete;
280};
281
282#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.
bool PreReplaceVolumetricShaderValues(std::string &vertexShader, std::string &geometryShader, std::string &fragmentShader, vtkAbstractMapper *mapper, vtkProp *prop)
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:
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:113
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:67
Perform part of the rendering of a vtkRenderer.
Definition: vtkRenderPass.h:57
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
Definition: vtkTimeStamp.h:52
window superclass for vtkRenderWindow
Definition: vtkWindow.h:36
@ string
Definition: vtkX3D.h:496
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:287