VTK  9.0.1
vtkDepthPeelingPass.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkDepthPeelingPass.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 =========================================================================*/
50 #ifndef vtkDepthPeelingPass_h
51 #define vtkDepthPeelingPass_h
52 
53 #include "vtkOpenGLRenderPass.h"
54 #include "vtkRenderingOpenGL2Module.h" // For export macro
55 #include <vector> // STL Header
56 
58 class vtkTextureObject;
60 class vtkOpenGLState;
62 
63 class VTKRENDERINGOPENGL2_EXPORT vtkDepthPeelingPass : public vtkOpenGLRenderPass
64 {
65 public:
66  static vtkDepthPeelingPass* New();
68  void PrintSelf(ostream& os, vtkIndent indent) override;
69 
74  void Render(const vtkRenderState* s) override;
75 
81  void ReleaseGraphicsResources(vtkWindow* w) override;
82 
84 
90  vtkGetObjectMacro(TranslucentPass, vtkRenderPass);
91  virtual void SetTranslucentPass(vtkRenderPass* translucentPass);
93 
95 
104  vtkSetClampMacro(OcclusionRatio, double, 0.0, 0.5);
105  vtkGetMacro(OcclusionRatio, double);
107 
109 
114  vtkSetMacro(MaximumNumberOfPeels, int);
115  vtkGetMacro(MaximumNumberOfPeels, int);
117 
118  // vtkOpenGLRenderPass virtuals:
119  bool PostReplaceShaderValues(std::string& vertexShader, std::string& geometryShader,
120  std::string& fragmentShader, vtkAbstractMapper* mapper, vtkProp* prop) override;
121  bool SetShaderParameters(vtkShaderProgram* program, vtkAbstractMapper* mapper, vtkProp* prop,
122  vtkOpenGLVertexArrayObject* VAO = nullptr) override;
123 
124  // Set Opaque Z texture, this must be set from the outer FO
125  void SetOpaqueZTexture(vtkTextureObject*);
126 
127  // Set Opaque RGBA texture, this must be set from the outer FO
128  void SetOpaqueRGBATexture(vtkTextureObject*);
129 
134  vtkSetMacro(DepthFormat, int);
135 
136 protected:
141 
145  ~vtkDepthPeelingPass() override;
146 
149 
151 
159 
170 
177 
179 
182 
183  // obtained from the outer FO, we read from them
188 
189  // each peel merges two color buffers into one result
190  vtkTextureObject* TranslucentRGBATexture[3];
193 
194  // each peel compares a prior Z and writes to next
195  vtkTextureObject* TranslucentZTexture[2];
197 
198  void BlendIntermediatePeels(vtkOpenGLRenderWindow* renWin, bool);
199  void BlendFinalPeel(vtkOpenGLRenderWindow* renWin);
200 
201  // useful to store
203 
204 private:
205  vtkDepthPeelingPass(const vtkDepthPeelingPass&) = delete;
206  void operator=(const vtkDepthPeelingPass&) = delete;
207 };
208 
209 #endif
vtkDepthPeelingPass::OpaqueZTexture
vtkTextureObject * OpaqueZTexture
Definition: vtkDepthPeelingPass.h:184
vtkDepthPeelingPass
Implement Depth Peeling for use within a framebuffer pass.
Definition: vtkDepthPeelingPass.h:63
vtkRenderPass::ReleaseGraphicsResources
virtual void ReleaseGraphicsResources(vtkWindow *w)
Release graphics resources and ask components to release their own resources.
vtkOpenGLRenderPass::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkDepthPeelingPass::ViewportHeight
int ViewportHeight
Definition: vtkDepthPeelingPass.h:157
vtkDepthPeelingPass::PeelCount
int PeelCount
Definition: vtkDepthPeelingPass.h:192
vtkObject::New
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on.
vtkTimeStamp
record modification and/or execution time
Definition: vtkTimeStamp.h:32
vtkRenderPass::Render
virtual void Render(const vtkRenderState *s)=0
Perform rendering according to a render state s.
vtkOpenGLFramebufferObject
Internal class which encapsulates OpenGL FramebufferObject.
Definition: vtkOpenGLFramebufferObject.h:181
vtkDepthPeelingPass::Framebuffer
vtkOpenGLFramebufferObject * Framebuffer
Definition: vtkDepthPeelingPass.h:178
vtkOpenGLQuadHelper
Class to make rendering a full screen quad easier.
Definition: vtkOpenGLQuadHelper.h:57
vtkDepthPeelingPass::DepthFormat
int DepthFormat
Definition: vtkDepthPeelingPass.h:196
vtkDepthPeelingPass::OwnOpaqueZTexture
bool OwnOpaqueZTexture
Definition: vtkDepthPeelingPass.h:186
vtkWindow
window superclass for vtkRenderWindow
Definition: vtkWindow.h:37
vtkDepthPeelingPass::State
vtkOpenGLState * State
Definition: vtkDepthPeelingPass.h:202
vtkOpenGLRenderPass::SetShaderParameters
virtual bool SetShaderParameters(vtkShaderProgram *program, vtkAbstractMapper *mapper, vtkProp *prop, vtkOpenGLVertexArrayObject *VAO=nullptr)
Update the uniforms of the shader program.
vtkDepthPeelingPass::ColorDrawCount
int ColorDrawCount
Definition: vtkDepthPeelingPass.h:191
vtkDepthPeelingPass::ViewportY
int ViewportY
Definition: vtkDepthPeelingPass.h:155
vtkShaderProgram
The ShaderProgram uses one or more Shader objects.
Definition: vtkShaderProgram.h:44
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkTextureObject
abstracts an OpenGL texture object.
Definition: vtkTextureObject.h:40
vtkDepthPeelingPass::ViewportX
int ViewportX
Cache viewport values for depth peeling.
Definition: vtkDepthPeelingPass.h:154
vtkOpenGLRenderPass::PostReplaceShaderValues
virtual bool PostReplaceShaderValues(std::string &vertexShader, std::string &geometryShader, std::string &fragmentShader, vtkAbstractMapper *mapper, vtkProp *prop)
Use vtkShaderProgram::Substitute to replace //VTK::XXX:YYY declarations in the shader sources.
vtkDepthPeelingPass::TranslucentPass
vtkRenderPass * TranslucentPass
Definition: vtkDepthPeelingPass.h:147
vtkProp
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:53
vtkX3D::string
@ string
Definition: vtkX3D.h:496
vtkDepthPeelingPass::IntermediateBlend
vtkOpenGLQuadHelper * IntermediateBlend
Definition: vtkDepthPeelingPass.h:181
vtkDepthPeelingPass::FinalBlend
vtkOpenGLQuadHelper * FinalBlend
Definition: vtkDepthPeelingPass.h:180
vtkOpenGLRenderPass
Abstract render pass with shader modifications.
Definition: vtkOpenGLRenderPass.h:38
vtkDepthPeelingPass::ViewportWidth
int ViewportWidth
Definition: vtkDepthPeelingPass.h:156
vtkOpenGLRenderPass.h
vtkOpenGLRenderWindow
OpenGL rendering window.
Definition: vtkOpenGLRenderWindow.h:51
vtkRenderState
Context in which a vtkRenderPass will render.
Definition: vtkRenderState.h:40
vtkDepthPeelingPass::OpaqueRGBATexture
vtkTextureObject * OpaqueRGBATexture
Definition: vtkDepthPeelingPass.h:185
vtkDepthPeelingPass::OwnOpaqueRGBATexture
bool OwnOpaqueRGBATexture
Definition: vtkDepthPeelingPass.h:187
vtkOpenGLState
OpenGL state storage.
Definition: vtkOpenGLState.h:79
vtkOpenGLVertexArrayObject
The VertexArrayObject class uses, or emulates, vertex array objects.
Definition: vtkOpenGLVertexArrayObject.h:36
vtkDepthPeelingPass::MaximumNumberOfPeels
int MaximumNumberOfPeels
In case of depth peeling, define the maximum number of peeling layers.
Definition: vtkDepthPeelingPass.h:176
vtkAbstractMapper
abstract class specifies interface to map data
Definition: vtkAbstractMapper.h:52
vtkDepthPeelingPass::CheckTime
vtkTimeStamp CheckTime
Definition: vtkDepthPeelingPass.h:148
vtkDepthPeelingPass::OcclusionRatio
double OcclusionRatio
In case of use of depth peeling technique for rendering translucent material, define the threshold un...
Definition: vtkDepthPeelingPass.h:169
vtkRenderPass
Perform part of the rendering of a vtkRenderer.
Definition: vtkRenderPass.h:56