VTK  9.3.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 
26 #include <vector> // For vector
27 
28 VTK_ABI_NAMESPACE_BEGIN
29 class vtkMatrix4x4;
32 class vtkTextureObject;
33 
34 class VTKRENDERINGOPENGL2_EXPORT vtkSSAOPass : public vtkImageProcessingPass
35 {
36 public:
37  static vtkSSAOPass* New();
39  void PrintSelf(ostream& os, vtkIndent indent) override;
40 
44  void Render(const vtkRenderState* s) override;
45 
49  void ReleaseGraphicsResources(vtkWindow* w) override;
50 
54  bool PreReplaceShaderValues(std::string& vertexShader, std::string& geometryShader,
55  std::string& fragmentShader, vtkAbstractMapper* mapper, vtkProp* prop) override;
56 
60  bool PostReplaceShaderValues(std::string& vertexShader, std::string& geometryShader,
61  std::string& fragmentShader, vtkAbstractMapper* mapper, vtkProp* prop) override;
62 
66  bool SetShaderParameters(vtkShaderProgram* program, vtkAbstractMapper* mapper, vtkProp* prop,
67  vtkOpenGLVertexArrayObject* VAO = nullptr) override;
68 
70 
74  vtkGetMacro(Radius, double);
75  vtkSetMacro(Radius, double);
77 
79 
83  vtkGetMacro(KernelSize, unsigned int);
84  vtkSetClampMacro(KernelSize, unsigned int, 1, 1000);
86 
88 
92  vtkGetMacro(Bias, double);
93  vtkSetMacro(Bias, double);
95 
97 
102  vtkGetMacro(Blur, bool);
103  vtkSetMacro(Blur, bool);
104  vtkBooleanMacro(Blur, bool);
106 
107 protected:
108  vtkSSAOPass() = default;
109  ~vtkSSAOPass() override = default;
110 
111  void ComputeKernel();
112  void InitializeGraphicsResources(vtkOpenGLRenderWindow* renWin, int w, int h);
113 
114  void RenderDelegate(const vtkRenderState* s, int w, int h);
115  void RenderSSAO(vtkOpenGLRenderWindow* renWin, vtkMatrix4x4* projection, int w, int h);
116  void RenderCombine(vtkOpenGLRenderWindow* renWin);
117 
118  vtkTextureObject* ColorTexture = nullptr;
119  vtkTextureObject* PositionTexture = nullptr;
120  vtkTextureObject* NormalTexture = nullptr;
121  vtkTextureObject* SSAOTexture = nullptr;
122  vtkTextureObject* DepthTexture = nullptr;
123 
124  vtkOpenGLFramebufferObject* FrameBufferObject = nullptr;
125 
126  vtkOpenGLQuadHelper* SSAOQuadHelper = nullptr;
127  vtkOpenGLQuadHelper* CombineQuadHelper = nullptr;
128 
129  std::vector<float> Kernel;
130  unsigned int KernelSize = 32;
131  double Radius = 0.5;
132  double Bias = 0.01;
133  bool Blur = false;
134 
135 private:
136  vtkSSAOPass(const vtkSSAOPass&) = delete;
137  void operator=(const vtkSSAOPass&) = delete;
138 };
139 
140 VTK_ABI_NAMESPACE_END
141 #endif
OpenGL rendering window.
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:45
Implement a screen-space ambient occlusion pass.
Definition: vtkSSAOPass.h:34
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:30
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:27
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:129
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.
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.