VTK  9.7.1
vtkSSAOPass.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
20 #ifndef vtkSSAOPass_h
21 #define vtkSSAOPass_h
22 
23 #include "vtkImageProcessingPass.h"
24 #include "vtkRenderingOpenGL2Module.h" // For export macro
25 #include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
26 
27 #include "vtkTextureObject.h" // For texture format enum
28 
29 #include <vector> // For vector
30 
31 VTK_ABI_NAMESPACE_BEGIN
32 class vtkMatrix4x4;
35 
36 class VTKRENDERINGOPENGL2_EXPORT VTK_MARSHALAUTO vtkSSAOPass : public vtkImageProcessingPass
37 {
38 public:
39  static vtkSSAOPass* New();
41  void PrintSelf(ostream& os, vtkIndent indent) override;
42 
46  void Render(const vtkRenderState* s) override;
47 
51  void ReleaseGraphicsResources(vtkWindow* w) override;
52 
56  bool PreReplaceShaderValues(std::string& vertexShader, std::string& geometryShader,
57  std::string& fragmentShader, vtkAbstractMapper* mapper, vtkProp* prop) override;
58 
62  bool PostReplaceShaderValues(std::string& vertexShader, std::string& geometryShader,
63  std::string& fragmentShader, vtkAbstractMapper* mapper, vtkProp* prop) override;
64 
68  bool SetShaderParameters(vtkShaderProgram* program, vtkAbstractMapper* mapper, vtkProp* prop,
69  vtkOpenGLVertexArrayObject* VAO = nullptr) override;
70 
72 
76  vtkGetMacro(Radius, double);
77  vtkSetMacro(Radius, double);
79 
81 
85  vtkGetMacro(KernelSize, unsigned int);
86  vtkSetClampMacro(KernelSize, unsigned int, 1, 1000);
88 
90 
94  vtkGetMacro(Bias, double);
95  vtkSetMacro(Bias, double);
97 
99 
104  vtkGetMacro(Blur, bool);
105  vtkSetMacro(Blur, bool);
106  vtkBooleanMacro(Blur, bool);
108 
113  vtkSetMacro(DepthFormat, int);
114  vtkGetMacro(DepthFormat, int);
115 
117 
123  vtkGetMacro(VolumeOpacityThreshold, double);
124  vtkSetClampMacro(VolumeOpacityThreshold, double, 0.0, 1.0);
126 
128 
132  vtkGetMacro(IntensityScale, double);
133  vtkSetMacro(IntensityScale, double);
135 
137 
143  vtkGetMacro(IntensityShift, double);
144  vtkSetClampMacro(IntensityShift, double, 0.0, 1.0);
146 
147 protected:
148  vtkSSAOPass() = default;
149  ~vtkSSAOPass() override = default;
150 
155  void PreRenderProp(vtkProp* prop) override;
159  void PostRenderProp(vtkProp* prop) override;
160 
161  void ComputeKernel();
162  void InitializeGraphicsResources(vtkOpenGLRenderWindow* renWin, int w, int h);
163 
164  void RenderDelegate(const vtkRenderState* s, int w, int h);
165  void RenderSSAO(vtkOpenGLRenderWindow* renWin, vtkMatrix4x4* projection, int w, int h);
166  void RenderCombine(vtkOpenGLRenderWindow* renWin);
167 
168  vtkTextureObject* ColorTexture = nullptr;
169  vtkTextureObject* PositionTexture = nullptr;
170  vtkTextureObject* NormalTexture = nullptr;
171  vtkTextureObject* SSAOTexture = nullptr;
172  vtkTextureObject* DepthTexture = nullptr;
173 
174  int DepthFormat = vtkTextureObject::Float32;
175 
176  vtkOpenGLFramebufferObject* FrameBufferObject = nullptr;
177 
178  vtkOpenGLQuadHelper* SSAOQuadHelper = nullptr;
179  vtkOpenGLQuadHelper* CombineQuadHelper = nullptr;
180 
181  std::vector<float> Kernel;
182  unsigned int KernelSize = 32;
183  double Radius = 0.5;
184  double Bias = 0.01;
185  bool Blur = false;
186 
187  double VolumeOpacityThreshold = 0.9;
188 
189  double IntensityScale = 1.0;
190  double IntensityShift = 0.0;
191 
192 private:
193  vtkSSAOPass(const vtkSSAOPass&) = delete;
194  void operator=(const vtkSSAOPass&) = delete;
195 };
196 
197 VTK_ABI_NAMESPACE_END
198 #endif
OpenGL rendering window.
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:49
virtual void PostRenderProp(vtkProp *prop)
Called in PreRender to give a chance to subclasses to clean up information keys.
Implement a screen-space ambient occlusion pass.
Definition: vtkSSAOPass.h:36
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:31
virtual void PreRenderProp(vtkProp *prop)
Called in PreRender to give a chance to subclasses to set additional information keys.
void ReleaseGraphicsResources(vtkWindow *w) override
Release graphics resources and ask components to release their own resources.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
Convenient class for post-processing passes.
window superclass for vtkRenderWindow
Definition: vtkWindow.h:41
Context in which a vtkRenderPass will render.
void RenderDelegate(const vtkRenderState *s, int width, int height, int newWidth, int newHeight, vtkOpenGLFramebufferObject *fbo, vtkTextureObject *target)
Render delegate with a image of different dimensions than the original one.
a simple class to control print indentation
Definition: vtkIndent.h:28
The VertexArrayObject class uses, or emulates, vertex array objects.
std::vector< float > Kernel
Definition: vtkSSAOPass.h:181
Internal class which encapsulates OpenGL FramebufferObject.
abstract class specifies interface to map data
virtual bool PreReplaceShaderValues(std::string &vertexShader, std::string &geometryShader, std::string &fragmentShader, vtkAbstractMapper *mapper, vtkProp *prop)
Use vtkShaderProgram::Substitute to replace.
abstracts an OpenGL texture object.
virtual void Render(const vtkRenderState *s)=0
Perform rendering according to a render state s.
Class to make rendering a full screen quad easier.
#define VTK_MARSHALAUTO
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
virtual bool SetShaderParameters(vtkShaderProgram *program, vtkAbstractMapper *mapper, vtkProp *prop, vtkOpenGLVertexArrayObject *VAO=nullptr)
Update the uniforms of the shader program.
virtual bool PostReplaceShaderValues(std::string &vertexShader, std::string &geometryShader, std::string &fragmentShader, vtkAbstractMapper *mapper, vtkProp *prop)
Use vtkShaderProgram::Substitute to replace.
The ShaderProgram uses one or more Shader objects.