VTK  9.2.6
vtkSSAOPass.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkSSAOPass.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 =========================================================================*/
32 #ifndef vtkSSAOPass_h
33 #define vtkSSAOPass_h
34 
35 #include "vtkImageProcessingPass.h"
36 #include "vtkRenderingOpenGL2Module.h" // For export macro
37 
38 #include <vector> // For vector
39 
40 class vtkMatrix4x4;
43 class vtkTextureObject;
44 
45 class VTKRENDERINGOPENGL2_EXPORT vtkSSAOPass : public vtkImageProcessingPass
46 {
47 public:
48  static vtkSSAOPass* New();
50  void PrintSelf(ostream& os, vtkIndent indent) override;
51 
55  void Render(const vtkRenderState* s) override;
56 
60  void ReleaseGraphicsResources(vtkWindow* w) override;
61 
65  bool PreReplaceShaderValues(std::string& vertexShader, std::string& geometryShader,
66  std::string& fragmentShader, vtkAbstractMapper* mapper, vtkProp* prop) override;
67 
71  bool PostReplaceShaderValues(std::string& vertexShader, std::string& geometryShader,
72  std::string& fragmentShader, vtkAbstractMapper* mapper, vtkProp* prop) override;
73 
77  bool SetShaderParameters(vtkShaderProgram* program, vtkAbstractMapper* mapper, vtkProp* prop,
78  vtkOpenGLVertexArrayObject* VAO = nullptr) override;
79 
81 
85  vtkGetMacro(Radius, double);
86  vtkSetMacro(Radius, double);
88 
90 
94  vtkGetMacro(KernelSize, unsigned int);
95  vtkSetClampMacro(KernelSize, unsigned int, 1, 1000);
97 
99 
103  vtkGetMacro(Bias, double);
104  vtkSetMacro(Bias, double);
106 
108 
113  vtkGetMacro(Blur, bool);
114  vtkSetMacro(Blur, bool);
115  vtkBooleanMacro(Blur, bool);
117 
118 protected:
119  vtkSSAOPass() = default;
120  ~vtkSSAOPass() override = default;
121 
122  void ComputeKernel();
123  void InitializeGraphicsResources(vtkOpenGLRenderWindow* renWin, int w, int h);
124 
125  void RenderDelegate(const vtkRenderState* s, int w, int h);
126  void RenderSSAO(vtkOpenGLRenderWindow* renWin, vtkMatrix4x4* projection, int w, int h);
127  void RenderCombine(vtkOpenGLRenderWindow* renWin);
128 
129  vtkTextureObject* ColorTexture = nullptr;
130  vtkTextureObject* PositionTexture = nullptr;
131  vtkTextureObject* NormalTexture = nullptr;
132  vtkTextureObject* SSAOTexture = nullptr;
133  vtkTextureObject* DepthTexture = nullptr;
134 
135  vtkOpenGLFramebufferObject* FrameBufferObject = nullptr;
136 
137  vtkOpenGLQuadHelper* SSAOQuadHelper = nullptr;
138  vtkOpenGLQuadHelper* CombineQuadHelper = nullptr;
139 
140  std::vector<float> Kernel;
141  unsigned int KernelSize = 32;
142  double Radius = 0.5;
143  double Bias = 0.01;
144  bool Blur = false;
145 
146 private:
147  vtkSSAOPass(const vtkSSAOPass&) = delete;
148  void operator=(const vtkSSAOPass&) = delete;
149 };
150 
151 #endif
OpenGL rendering window.
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:56
Implement a screen-space ambient occlusion pass.
Definition: vtkSSAOPass.h:45
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:41
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:38
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:39
The VertexArrayObject class uses, or emulates, vertex array objects.
std::vector< float > Kernel
Definition: vtkSSAOPass.h:140
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.