Drake Designer
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros Pages
vtkEDLShading.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: ParaView
4  Module: vtkEDLShading.h
5 
6  Copyright (c) 2005-2008 Sandia Corporation, Kitware Inc.
7  All rights reserved.
8 
9  ParaView is a free software; you can redistribute it and/or modify it
10  under the terms of the ParaView license version 1.2.
11 
12  See License_v1.2.txt for the full ParaView license.
13  A copy of this license can be obtained by contacting
14  Kitware Inc.
15  28 Corporate Drive
16  Clifton Park, NY 12065
17  USA
18 
19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR
23 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 
31 =========================================================================*/
32 /*----------------------------------------------------------------------
33 Acknowledgement:
34 This algorithm is the result of joint work by Electricité de France,
35 CNRS, Collège de France and Université J. Fourier as part of the
36 Ph.D. thesis of Christian BOUCHENY.
37 ------------------------------------------------------------------------*/
38 // .NAME vtkEDLShading
39 //
40 // .SECTION Description
41 // Implement an EDL offscreen shading.
42 // Shade the image renderered by its delegate. Two image resolutions are used
43 //
44 // This pass expects an initialized depth buffer and color buffer.
45 // Initialized buffers means they have been cleared with farest z-value and
46 // background color/gradient/transparent color.
47 // An opaque pass may have been performed right after the initialization.
48 //
49 // The delegate is used once.
50 //
51 // Its delegate is usually set to a vtkCameraPass or to a post-processing pass.
52 //
53 // This pass requires a OpenGL context that supports texture objects (TO),
54 // framebuffer objects (FBO) and GLSL. If not, it will emit an error message
55 // and will render its delegate and return.
56 //
57 
58 #ifndef __vtkEDLShading_h
59 #define __vtkEDLShading_h
60 
61 #define EDL_HIGH_RESOLUTION_ON 1
62 #define EDL_LOW_RESOLUTION_ON 1
63 
64 //#define VTK_EDL_SHADING_DEBUG
65 
67 
68 #include <vtkDRCFiltersModule.h>
69 
70 class vtkOpenGLRenderWindow;
71 class vtkDepthPeelingPassLayerList; // Pimpl
72 class vtkShaderProgram2;
73 class vtkShader2;
74 class vtkFrameBufferObject;
75 class vtkTextureObject;
76 
78 {
79 public:
80  static vtkEDLShading *New();
82  void PrintSelf(ostream& os, vtkIndent indent);
83 
84  //BTX
85  // Description:
86  // Perform rendering according to a render state \p s.
87  // \pre s_exists: s!=0
88  virtual void Render(const vtkRenderState *s);
89  //ETX
90 
91  // Description:
92  // Release graphics resources and ask components to release their own
93  // resources.
94  // \pre w_exists: w!=0
95  void ReleaseGraphicsResources(vtkWindow *w);
96 
97  protected:
98  // Description:
99  // Default constructor. DelegatePass is set to NULL.
100  vtkEDLShading();
101 
102  // Description:
103  // Destructor.
104  virtual ~vtkEDLShading();
105 
106  // Description:
107  // Initialization of required framebuffer objects
108  void EDLInitializeFramebuffers(vtkRenderState &s);
109 
110  // Description:
111  // Initialization of required GLSL shaders
112  void EDLInitializeShaders();
113 
114  // Description:
115  // Render EDL in full resolution buffer
116  bool EDLShadeHigh(vtkRenderState &s);
117 
118  // Description:
119  // Render EDL in middle resolution buffer
120  bool EDLShadeLow(vtkRenderState &s);
121 
122  // Description:
123  // Render EDL in middle resolution buffer
124  bool EDLBlurLow(vtkRenderState &s);
125 
126  // Description:
127  // Compose color and shaded images
128  bool EDLCompose(const vtkRenderState *s);
129 
130  // Description:
131  // Framebuffer object and textures for initial projection
132  vtkFrameBufferObject *ProjectionFBO;
133  // used to record scene data
134  vtkTextureObject *ProjectionColorTexture;
135  // color render target for projection pass
136  vtkTextureObject *ProjectionDepthTexture;
137  // depth render target for projection pass
138 
139  // Framebuffer objects and textures for EDL
140  vtkFrameBufferObject *EDLHighFBO;
141  // for EDL full res shading
142  vtkTextureObject *EDLHighShadeTexture;
143  // color render target for EDL full res pass
144  vtkFrameBufferObject *EDLLowFBO;
145  // for EDL low res shading (image size/4)
146  vtkTextureObject *EDLLowShadeTexture;
147  // color render target for EDL low res pass
148  vtkTextureObject *EDLLowBlurTexture;
149  // color render target for EDL low res
150  // bilateral filter pass
151 
152  // Shader prohrams
153  vtkShaderProgram2 *EDLShadeProgram;
154  vtkShaderProgram2 *EDLComposeProgram;
155  vtkShaderProgram2 *BilateralProgram;
156 
157  float EDLNeighbours[32];
159  int EDLLowResFactor; // basically 4
160 
161  float Zn; // near clipping plane
162  float Zf; // far clipping plane
163 
164  private:
165  vtkEDLShading(const vtkEDLShading&); // Not implemented.
166  void operator=(const vtkEDLShading&); // Not implemented.
167 };
168 
169 #endif
vtkShaderProgram2 * BilateralProgram
vtkTextureObject * ProjectionDepthTexture
vtkTextureObject * EDLLowShadeTexture
vtkTextureObject * EDLHighShadeTexture
vtkFrameBufferObject * EDLHighFBO
vtkTypeRevisionMacro(vtkDepthImageProcessingPass, vtkRenderPass)
vtkTextureObject * ProjectionColorTexture
vtkFrameBufferObject * ProjectionFBO
vtkShaderProgram2 * EDLComposeProgram
vtkShaderProgram2 * EDLShadeProgram
void PrintSelf(ostream &os, vtkIndent indent)
vtkTextureObject * EDLLowBlurTexture
vtkFrameBufferObject * EDLLowFBO
#define VTKDRCFILTERS_EXPORT
void ReleaseGraphicsResources(vtkWindow *w)