VTK
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 
47 #ifndef vtkDualDepthPeelingPass_h
48 #define vtkDualDepthPeelingPass_h
49 
50 #include "vtkRenderingOpenGL2Module.h" // For export macro
51 #include "vtkDepthPeelingPass.h"
52 
56 class vtkShaderProgram;
57 class vtkTextureObject;
58 
59 class VTKRENDERINGOPENGL2_EXPORT vtkDualDepthPeelingPass:
60  public vtkDepthPeelingPass
61 {
62 public:
63  static vtkDualDepthPeelingPass* New();
65  virtual void PrintSelf(ostream &os, vtkIndent indent);
66 
67  virtual void Render(const vtkRenderState *s);
68  virtual void ReleaseGraphicsResources(vtkWindow *w);
69 
70  // vtkOpenGLRenderPass virtuals:
71  virtual bool ReplaceShaderValues(std::string &vertexShader,
72  std::string &geometryShader,
73  std::string &fragmentShader,
74  vtkAbstractMapper *mapper,
75  vtkProp *prop);
76  virtual bool SetShaderParameters(vtkShaderProgram *program,
77  vtkAbstractMapper *mapper, vtkProp *prop);
79 
80 protected:
81 
82  // Name the textures used by this render pass. These are indexes into
83  // this->Textures
85  {
86  BackTemp = 0, // RGBA8 back-to-front peeling buffer
87  Back, // RGBA8 back-to-front accumulation buffer
88  FrontA, // RGBA8 front-to-back accumulation buffer
89  FrontB, // RGBA8 front-to-back accumulation buffer
90  DepthA, // RG32F min-max depth buffer
91  DepthB, // RG32F min-max depth buffer
92  OpaqueDepth, // Stores the depth map from the opaque passes
93 
94  NumberOfTextures
95  };
96 
97  // The stages of this multipass render pass:
99  {
103 
105  Inactive = -1,
106  };
107 
110 
111  void SetCurrentStage(ShaderStage stage);
112 
116  void FreeGLObjects();
117 
121  void RenderTranslucentPass();
122 
126  void Initialize(const vtkRenderState *s);
127 
129 
132  void InitColorTexture(vtkTextureObject *tex, const vtkRenderState *s);
133  void InitDepthTexture(vtkTextureObject *tex, const vtkRenderState *s);
134  void InitOpaqueDepthTexture(vtkTextureObject *tex, const vtkRenderState *s);
135  void InitFramebuffer(const vtkRenderState *s);
137 
139 
142  void Prepare();
143  void InitializeOcclusionQuery();
144  void CopyOpaqueDepthBuffer();
145  void InitializeDepth();
147 
148  bool PeelingDone();
149 
153  void Peel();
154 
155  void InitializeTargets();
156 
157  void PeelRender();
158 
159  void BlendBackBuffer();
160  void StartOcclusionQuery();
161  void EndOcclusionQuery();
162 
166  void SwapTargets();
167 
168  void Finalize();
169 
170  void AlphaBlendRender();
171 
172  void BlendFinalImage();
173  void DeleteOcclusionQueryId();
174 
176 
180 
184 
188 
190  vtkTextureObject *Textures[NumberOfTextures];
191 
192  TextureName FrontSource; // The current front source buffer
193  TextureName FrontDestination; // The current front destination buffer
194  TextureName DepthSource; // The current depth source buffer
195  TextureName DepthDestination; // The current depth destination buffer
196 
199 
201  unsigned int OcclusionQueryId;
202  unsigned int WrittenPixels;
203  unsigned int OcclusionThreshold;
204 
205  int RenderCount; // Debug info, counts number of geometry passes.
206 
207 private:
208  vtkDualDepthPeelingPass(const vtkDualDepthPeelingPass&) VTK_DELETE_FUNCTION;
209  void operator=(const vtkDualDepthPeelingPass&) VTK_DELETE_FUNCTION;
210 };
211 
212 #endif // vtkDualDepthPeelingPass_h
vtkDualDepthPeelingPass::FrontDestination
TextureName FrontDestination
Definition: vtkDualDepthPeelingPass.h:193
vtkOpenGLRenderPass::GetShaderStageMTime
virtual vtkMTimeType GetShaderStageMTime()
For multi-stage render passes that need to change shader code during a single pass,...
vtkDualDepthPeelingPass
Implements the dual depth peeling algorithm.
Definition: vtkDualDepthPeelingPass.h:59
vtkDepthPeelingPass.h
vtkDepthPeelingPass::New
static vtkDepthPeelingPass * New()
vtkDepthPeelingPass
Implement an Order Independent Transparency render pass.
Definition: vtkDepthPeelingPass.h:53
vtkDualDepthPeelingPass::DepthB
Definition: vtkDualDepthPeelingPass.h:91
vtkOpenGLBufferObject
OpenGL buffer object.
Definition: vtkOpenGLBufferObject.h:32
vtkDualDepthPeelingPass::RenderState
const vtkRenderState * RenderState
Definition: vtkDualDepthPeelingPass.h:175
vtkDualDepthPeelingPass::InitializingDepth
Definition: vtkDualDepthPeelingPass.h:100
vtkDualDepthPeelingPass::TextureName
TextureName
Definition: vtkDualDepthPeelingPass.h:84
vtkTimeStamp
record modification and/or execution time
Definition: vtkTimeStamp.h:35
vtkDualDepthPeelingPass::CopyDepthProgram
vtkShaderProgram * CopyDepthProgram
Definition: vtkDualDepthPeelingPass.h:177
vtkDualDepthPeelingPass::CurrentStageTimeStamp
vtkTimeStamp CurrentStageTimeStamp
Definition: vtkDualDepthPeelingPass.h:198
vtkDualDepthPeelingPass::NumberOfPasses
Definition: vtkDualDepthPeelingPass.h:104
vtkDepthPeelingPass::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent)
Methods invoked by print to print information about the object including superclasses.
vtkDualDepthPeelingPass::BackBlendVBO
vtkOpenGLBufferObject * BackBlendVBO
Definition: vtkDualDepthPeelingPass.h:183
vtkDualDepthPeelingPass::RenderCount
int RenderCount
Definition: vtkDualDepthPeelingPass.h:205
vtkDepthPeelingPass::ReleaseGraphicsResources
void ReleaseGraphicsResources(vtkWindow *w)
Release graphics resources and ask components to release their own resources.
vtkDualDepthPeelingPass::FrontA
Definition: vtkDualDepthPeelingPass.h:88
vtkWindow
window superclass for vtkRenderWindow
Definition: vtkWindow.h:34
vtkDualDepthPeelingPass::WrittenPixels
unsigned int WrittenPixels
Definition: vtkDualDepthPeelingPass.h:202
vtkMTimeType
vtkTypeUInt64 vtkMTimeType
Definition: vtkType.h:248
vtkDualDepthPeelingPass::DepthDestination
TextureName DepthDestination
Definition: vtkDualDepthPeelingPass.h:195
vtkDualDepthPeelingPass::Back
Definition: vtkDualDepthPeelingPass.h:87
vtkDualDepthPeelingPass::BlendVBO
vtkOpenGLBufferObject * BlendVBO
Definition: vtkDualDepthPeelingPass.h:187
vtkDepthPeelingPass::SetShaderParameters
virtual bool SetShaderParameters(vtkShaderProgram *program, vtkAbstractMapper *mapper, vtkProp *prop)
Update the uniforms of the shader program.
vtkDualDepthPeelingPass::OcclusionThreshold
unsigned int OcclusionThreshold
Definition: vtkDualDepthPeelingPass.h:203
vtkDualDepthPeelingPass::Framebuffer
vtkFrameBufferObject2 * Framebuffer
Definition: vtkDualDepthPeelingPass.h:189
vtkDualDepthPeelingPass::CurrentStage
ShaderStage CurrentStage
Definition: vtkDualDepthPeelingPass.h:197
vtkDualDepthPeelingPass::BlendProgram
vtkShaderProgram * BlendProgram
Definition: vtkDualDepthPeelingPass.h:185
vtkDualDepthPeelingPass::CopyDepthVAO
vtkOpenGLVertexArrayObject * CopyDepthVAO
Definition: vtkDualDepthPeelingPass.h:178
vtkShaderProgram
The ShaderProgram uses one or more Shader objects.
Definition: vtkShaderProgram.h:44
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:39
vtkTextureObject
abstracts an OpenGL texture object.
Definition: vtkTextureObject.h:43
vtkDualDepthPeelingPass::DepthA
Definition: vtkDualDepthPeelingPass.h:90
vtkDualDepthPeelingPass::BackBlendProgram
vtkShaderProgram * BackBlendProgram
Definition: vtkDualDepthPeelingPass.h:181
vtkProp
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:47
vtkX3D::string
Definition: vtkX3D.h:490
vtkDualDepthPeelingPass::AlphaBlending
Definition: vtkDualDepthPeelingPass.h:102
vtkDualDepthPeelingPass::FrontSource
TextureName FrontSource
Definition: vtkDualDepthPeelingPass.h:192
vtkDualDepthPeelingPass::Peeling
Definition: vtkDualDepthPeelingPass.h:101
vtkDepthPeelingPass::Render
virtual void Render(const vtkRenderState *s)
Perform rendering according to a render state s.
vtkDualDepthPeelingPass::OcclusionQueryId
unsigned int OcclusionQueryId
Definition: vtkDualDepthPeelingPass.h:201
vtkDualDepthPeelingPass::OpaqueDepth
Definition: vtkDualDepthPeelingPass.h:92
vtkDualDepthPeelingPass::CurrentPeel
int CurrentPeel
Definition: vtkDualDepthPeelingPass.h:200
vtkDualDepthPeelingPass::FrontB
Definition: vtkDualDepthPeelingPass.h:89
vtkDualDepthPeelingPass::DepthSource
TextureName DepthSource
Definition: vtkDualDepthPeelingPass.h:194
vtkRenderState
Context in which a vtkRenderPass will render.
Definition: vtkRenderState.h:40
vtkDualDepthPeelingPass::CopyDepthVBO
vtkOpenGLBufferObject * CopyDepthVBO
Definition: vtkDualDepthPeelingPass.h:179
vtkFrameBufferObject2
Interface to OpenGL framebuffer object.
Definition: vtkFrameBufferObject2.h:86
vtkDualDepthPeelingPass::BlendVAO
vtkOpenGLVertexArrayObject * BlendVAO
Definition: vtkDualDepthPeelingPass.h:186
vtkOpenGLVertexArrayObject
The VertexArrayObject class uses, or emulates, vertex array objects.
Definition: vtkOpenGLVertexArrayObject.h:35
vtkDualDepthPeelingPass::BackBlendVAO
vtkOpenGLVertexArrayObject * BackBlendVAO
Definition: vtkDualDepthPeelingPass.h:182
vtkAbstractMapper
abstract class specifies interface to map data
Definition: vtkAbstractMapper.h:55
vtkDualDepthPeelingPass::ShaderStage
ShaderStage
Definition: vtkDualDepthPeelingPass.h:98
vtkDepthPeelingPass::ReplaceShaderValues
virtual bool ReplaceShaderValues(std::string &vertexShader, std::string &geometryShader, std::string &fragmentShader, vtkAbstractMapper *mapper, vtkProp *prop)
Is rendering at translucent geometry stage using depth peeling and rendering a layer other than the f...