VTK  9.0.20201128
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 =========================================================================*/
29 #ifndef vtkSSAOPass_h
30 #define vtkSSAOPass_h
31 
32 #include "vtkImageProcessingPass.h"
33 #include "vtkRenderingOpenGL2Module.h" // For export macro
34 
35 #include <vector> // For vector
36 
37 class vtkMatrix4x4;
40 class vtkTextureObject;
41 
42 class VTKRENDERINGOPENGL2_EXPORT vtkSSAOPass : public vtkImageProcessingPass
43 {
44 public:
45  static vtkSSAOPass* New();
47  void PrintSelf(ostream& os, vtkIndent indent) override;
48 
52  void Render(const vtkRenderState* s) override;
53 
57  void ReleaseGraphicsResources(vtkWindow* w) override;
58 
62  bool PreReplaceShaderValues(std::string& vertexShader, std::string& geometryShader,
63  std::string& fragmentShader, vtkAbstractMapper* mapper, vtkProp* prop) override;
64 
68  bool PostReplaceShaderValues(std::string& vertexShader, std::string& geometryShader,
69  std::string& fragmentShader, vtkAbstractMapper* mapper, vtkProp* prop) override;
70 
74  bool SetShaderParameters(vtkShaderProgram* program, vtkAbstractMapper* mapper, vtkProp* prop,
75  vtkOpenGLVertexArrayObject* VAO = nullptr) override;
76 
78 
82  vtkGetMacro(Radius, double);
83  vtkSetMacro(Radius, double);
85 
87 
91  vtkGetMacro(KernelSize, unsigned int);
92  vtkSetClampMacro(KernelSize, unsigned int, 1, 1000);
94 
96 
100  vtkGetMacro(Bias, double);
101  vtkSetMacro(Bias, double);
103 
105 
110  vtkGetMacro(Blur, bool);
111  vtkSetMacro(Blur, bool);
112  vtkBooleanMacro(Blur, bool);
114 
115 protected:
116  vtkSSAOPass() = default;
117  ~vtkSSAOPass() override = default;
118 
119  void ComputeKernel();
120  void InitializeGraphicsResources(vtkOpenGLRenderWindow* renWin, int w, int h);
121 
122  void RenderDelegate(const vtkRenderState* s, int w, int h);
123  void RenderSSAO(vtkOpenGLRenderWindow* renWin, vtkMatrix4x4* projection, int w, int h);
124  void RenderCombine(vtkOpenGLRenderWindow* renWin);
125 
126  vtkTextureObject* ColorTexture = nullptr;
127  vtkTextureObject* PositionTexture = nullptr;
128  vtkTextureObject* NormalTexture = nullptr;
129  vtkTextureObject* SSAOTexture = nullptr;
130  vtkTextureObject* DepthTexture = nullptr;
131 
132  vtkOpenGLFramebufferObject* FrameBufferObject = nullptr;
133 
134  vtkOpenGLQuadHelper* SSAOQuadHelper = nullptr;
135  vtkOpenGLQuadHelper* CombineQuadHelper = nullptr;
136 
137  std::vector<float> Kernel;
138  unsigned int KernelSize = 32;
139  double Radius = 0.5;
140  double Bias = 0.01;
141  bool Blur = false;
142 
143 private:
144  vtkSSAOPass(const vtkSSAOPass&) = delete;
145  void operator=(const vtkSSAOPass&) = delete;
146 };
147 
148 #endif
vtkImageProcessingPass::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkImageProcessingPass.h
vtkObject::New
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on.
vtkSSAOPass
Implement a screen-space ambient occlusion pass.
Definition: vtkSSAOPass.h:42
vtkImageProcessingPass::RenderDelegate
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.
vtkOpenGLRenderPass::PreReplaceShaderValues
virtual bool PreReplaceShaderValues(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.
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
vtkOpenGLQuadHelper
Class to make rendering a full screen quad easier.
Definition: vtkOpenGLQuadHelper.h:57
vtkSSAOPass::Kernel
std::vector< float > Kernel
Definition: vtkSSAOPass.h:137
vtkImageProcessingPass::ReleaseGraphicsResources
void ReleaseGraphicsResources(vtkWindow *w) override
Release graphics resources and ask components to release their own resources.
vtkWindow
window superclass for vtkRenderWindow
Definition: vtkWindow.h:38
vtkOpenGLRenderPass::SetShaderParameters
virtual bool SetShaderParameters(vtkShaderProgram *program, vtkAbstractMapper *mapper, vtkProp *prop, vtkOpenGLVertexArrayObject *VAO=nullptr)
Update the uniforms of the shader program.
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
vtkMatrix4x4
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:35
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.
vtkProp
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:56
vtkX3D::string
Definition: vtkX3D.h:496
vtkOpenGLRenderWindow
OpenGL rendering window.
Definition: vtkOpenGLRenderWindow.h:53
vtkRenderState
Context in which a vtkRenderPass will render.
Definition: vtkRenderState.h:40
vtkOpenGLVertexArrayObject
The VertexArrayObject class uses, or emulates, vertex array objects.
Definition: vtkOpenGLVertexArrayObject.h:36
h
vtkImageProcessingPass
Convenient class for post-processing passes. render pass.
Definition: vtkImageProcessingPass.h:38
vtkAbstractMapper
abstract class specifies interface to map data
Definition: vtkAbstractMapper.h:52