1 /*=========================================================================
2 
3   Program:   Visualization Toolkit
4   Module:    vtkGaussianBlurPass.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 // .NAME vtkGaussianBlurPass - Implement a post-processing Gaussian blur
16 // render pass.
17 // .SECTION Description
18 // Blur the image renderered by its delegate. Blurring uses a Gaussian low-pass
19 // filter with a 5x5 kernel.
20 //
21 // This pass expects an initialized depth buffer and color buffer.
22 // Initialized buffers means they have been cleared with farest z-value and
23 // background color/gradient/transparent color.
24 // An opaque pass may have been performed right after the initialization.
25 //
26 // The delegate is used once.
27 //
28 // Its delegate is usually set to a vtkCameraPass or to a post-processing pass.
29 //
30 // This pass requires a OpenGL context that supports texture objects (TO),
31 // framebuffer objects (FBO) and GLSL. If not, it will emit an error message
32 // and will render its delegate and return.
33 //
34 // .SECTION Implementation
35 // As the filter is separable, it first blurs the image horizontally and then
36 // vertically. This reduces the number of texture sampling to 5 per pass.
37 // In addition, as texture sampling can already blend texel values in linear
38 // mode, by adjusting the texture coordinate accordingly, only 3 texture
39 // sampling are actually necessary.
40 // Reference: OpenGL Bloom Toturial by Philip Rideout, section
41 // Exploit Hardware Filtering  http://prideout.net/bloom/index.php#Sneaky
42 
43 // .SECTION See Also
44 // vtkRenderPass
45 
46 #ifndef vtkGaussianBlurPass_h
47 #define vtkGaussianBlurPass_h
48 
49 #include "vtkRenderingOpenGLModule.h" // For export macro
50 #include "vtkImageProcessingPass.h"
51 
52 class vtkOpenGLRenderWindow;
53 class vtkDepthPeelingPassLayerList; // Pimpl
54 class vtkShaderProgram2;
55 class vtkShader2;
56 class vtkFrameBufferObject;
57 class vtkTextureObject;
58 
59 class VTKRENDERINGOPENGL_EXPORT vtkGaussianBlurPass : public vtkImageProcessingPass
60 {
61 public:
62   static vtkGaussianBlurPass *New();
63   vtkTypeMacro(vtkGaussianBlurPass,vtkImageProcessingPass);
64   void PrintSelf(ostream& os, vtkIndent indent);
65 
66   //BTX
67   // Description:
68   // Perform rendering according to a render state \p s.
69   // \pre s_exists: s!=0
70   virtual void Render(const vtkRenderState *s);
71   //ETX
72 
73   // Description:
74   // Release graphics resources and ask components to release their own
75   // resources.
76   // \pre w_exists: w!=0
77   void ReleaseGraphicsResources(vtkWindow *w);
78 
79  protected:
80   // Description:
81   // Default constructor. DelegatePass is set to NULL.
82   vtkGaussianBlurPass();
83 
84   // Description:
85   // Destructor.
86   virtual ~vtkGaussianBlurPass();
87 
88   // Description:
89   // Graphics resources.
90   vtkFrameBufferObject *FrameBufferObject;
91   vtkTextureObject *Pass1; // render target for the scene
92   vtkTextureObject *Pass2; // render target for the horizontal pass
93   vtkShaderProgram2 *BlurProgram; // blur shader
94 
95   bool Supported;
96   bool SupportProbed;
97 
98  private:
99   vtkGaussianBlurPass(const vtkGaussianBlurPass&);  // Not implemented.
100   void operator=(const vtkGaussianBlurPass&);  // Not implemented.
101 };
102 
103 #endif
104