Developer Documentation

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
DepthPeeling.hh
1 /*===========================================================================*\
2 * *
3 * OpenFlipper *
4 * Copyright (c) 2001-2015, RWTH-Aachen University *
5 * Department of Computer Graphics and Multimedia *
6 * All rights reserved. *
7 * www.openflipper.org *
8 * *
9 *---------------------------------------------------------------------------*
10 * This file is part of OpenFlipper. *
11 *---------------------------------------------------------------------------*
12 * *
13 * Redistribution and use in source and binary forms, with or without *
14 * modification, are permitted provided that the following conditions *
15 * are met: *
16 * *
17 * 1. Redistributions of source code must retain the above copyright notice, *
18 * this list of conditions and the following disclaimer. *
19 * *
20 * 2. Redistributions in binary form must reproduce the above copyright *
21 * notice, this list of conditions and the following disclaimer in the *
22 * documentation and/or other materials provided with the distribution. *
23 * *
24 * 3. Neither the name of the copyright holder nor the names of its *
25 * contributors may be used to endorse or promote products derived from *
26 * this software without specific prior written permission. *
27 * *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
30 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
31 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
32 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
33 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
34 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
35 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
36 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
37 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
38 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
39 * *
40 \*===========================================================================*/
41
42
43
44 #pragma once
45
46
47 #include <QObject>
48
49 #include <OpenFlipper/BasePlugin/BaseInterface.hh>
50 #include <OpenFlipper/BasePlugin/RenderInterface.hh>
51 #include <OpenFlipper/BasePlugin/LoggingInterface.hh>
52
53
54 #include <ACG/GL/IRenderer.hh>
55 #include <ACG/GL/FBO.hh>
56
57 class DepthPeeling : public QObject, BaseInterface, RenderInterface, LoggingInterface, ACG::IRenderer
58 {
59 Q_OBJECT
60 Q_INTERFACES(BaseInterface)
61 Q_INTERFACES(RenderInterface)
62 Q_INTERFACES(LoggingInterface)
63
64 #if QT_VERSION >= 0x050000
65 Q_PLUGIN_METADATA(IID "org.OpenFlipper.Plugins.Plugin-Render-DepthPeeling")
66 #endif
67
68 signals:
69 // LoggingInterface
70 void log(Logtype _type, QString _message);
71 void log(QString _message);
72
73
74 public:
75 DepthPeeling();
76 ~DepthPeeling();
77
78 QString name() { return (QString("DepthPeeling Plugin")); };
79 QString description( ) { return (QString(tr("DepthPeeling Rendering Pipeline (Alpha Version!)"))); };
80
81
83 void addRenderObject(ACG::RenderObject* _renderObject);
84
85
86 public slots:
87 QString version() { return QString("1.0"); };
88
89 QString renderObjectsInfo(bool _outputShaderInfo);
90
91 QAction* optionsAction();
92
93 private slots:
94
95 //BaseInterface
96 void initializePlugin();
97 void exit(){}
98
99 // RenderInterface
100 void render(ACG::GLState* _glState, Viewer::ViewerProperties& _properties);
101 QString rendererName() {return QString("Alpha_Version_DepthPeeling");}
102 void supportedDrawModes(ACG::SceneGraph::DrawModes::DrawMode& _mode) {_mode = ACG::SceneGraph::DrawModes::DEFAULT;}
103
104 QString checkOpenGL();
105
106 void slotModeChanged( QAction * );
107
108
109 private:
110
111
113 void renderFrontPeeling(ACG::GLState* _glState, Viewer::ViewerProperties& _properties);
114
116 void renderDualPeeling(ACG::GLState* _glState, Viewer::ViewerProperties& _properties);
117
119 int peelMode_;
120
121 bool copyFrontDepth_;
122
124 int maxPeelCount_;
125
127 GLSL::Program* peelBlend_;
128
130 GLSL::Program* peelFinal_;
131
133 GLuint peelQueryID_;
134
135
137 GLSL::Program* peelBlendDual_;
138 GLSL::Program* peelFinalDual_;
139
140
142 struct ViewerResources
143 {
144 ViewerResources();
145 ~ViewerResources();
146
147 // resize textures
148 void resize(bool _dualPeeling, unsigned int _width, unsigned int _height);
149
151 unsigned int width_;
152
154 unsigned int height_;
155
156
157 // single layer depth peeling textures (front to back peeling)
158 // ping-pong buffer for (depth, front) targets
159 GLuint singleDepthTex_[2]; // float1: minDepth
160 GLuint singleFrontTex_[2]; // rgba: color of front-peeled layer
161 GLuint singleBlendTex_; // rgba: color accumulation buffer
162
163 ACG::FBO* singleFbo_; // targets: {depth0, front0, depth1, front1, blend}
164
165
166
167
168 // dual depth peeling textures
169 // ping-pong buffer for (depth, front, back) targets
170 GLuint dualDepthTex_[2]; // float2: (-minDepth, maxDepth)
171 GLuint dualFrontTex_[2]; // rgba: color of front-peeled layer
172 GLuint dualBackTex_[2]; // rgba: color of back-peeled layer
173 GLuint dualBlendTex_; // rgb: color accumulation buffer
174
175 ACG::FBO* dualFbo_; // targets: {depth0, front0, back0, depth1, front1, back1, blend}
176 };
177
179 void initDepthPeeling();
180
182 void initDualDepthPeeling();
183
188 std::map<int, ViewerResources> viewerRes_;
189
190
191
192
193 // debug functions
194 // GLSL::Program* dbgProg_;
195 //
196 // void dbgDrawTex(GLuint _texID);
197 };
Viewer::ViewerProperties
Definition: ViewerProperties.hh:119
DepthPeeling::peelBlend_
GLSL::Program * peelBlend_
blends one depth-layer into the current scene target
Definition: DepthPeeling.hh:127
BaseInterface
Interface class from which all plugins have to be created.
Definition: BaseInterface.hh:76
DepthPeeling::initDualDepthPeeling
void initDualDepthPeeling()
Allocate framebuffers and load shaders for dual-depth-peeling.
Definition: DepthPeeling.cc:1005
DepthPeeling::maxPeelCount_
int maxPeelCount_
max peel count
Definition: DepthPeeling.hh:124
DepthPeeling::peelQueryID_
GLuint peelQueryID_
occlusion query determining end of peeling (last layer)
Definition: DepthPeeling.hh:133
Logtype
Logtype
Log types for Message Window.
Definition: LoggingInterface.hh:103
ACG::SceneGraph::DrawModes::DEFAULT
DrawMode DEFAULT
use the default (global) draw mode and not the node's own.
Definition: DrawModes.cc:78
RenderInterface
Interface to add additional rendering functions from within plugins.
Definition: RenderInterface.hh:70
ACG::RenderObject
Interface class between scenegraph and renderer.
Definition: RenderObject.hh:105
DepthPeeling::description
QString description()
Return a description of what the plugin is doing.
Definition: DepthPeeling.hh:79
ACG::FBO
Definition: FBO.hh:83
LoggingInterface.hh
LoggingInterface
Interface for all Plugins which do logging to the logging window of the framework.
Definition: LoggingInterface.hh:123
ACG::GLState
Definition: GLState.hh:220
ACG::IRenderer
Definition: IRenderer.hh:84
DepthPeeling::ViewerResources
Collection of framebuffers for each viewport.
Definition: DepthPeeling.hh:142
ACG::SceneGraph::DrawModes::DrawMode
Specifies a DrawMode.
Definition: DrawModes.hh:294
DepthPeeling
Definition: DepthPeeling.hh:57
DepthPeeling::renderObjectsInfo
QString renderObjectsInfo(bool _outputShaderInfo)
Return a qstring of the current render objects.
Definition: DepthPeeling.cc:1029
DepthPeeling::peelMode_
int peelMode_
mode: 0 -> front to back peeling, 1 -> dual peeling
Definition: DepthPeeling.hh:119
DepthPeeling::optionsAction
QAction * optionsAction()
Return options menu.
Definition: DepthPeeling_qt.cc:60
DepthPeeling::renderDualPeeling
void renderDualPeeling(ACG::GLState *_glState, Viewer::ViewerProperties &_properties)
peel the scene with dual depth peeling, two layers per pass
Definition: DepthPeeling.cc:529
DepthPeeling::peelFinal_
GLSL::Program * peelFinal_
final copy into back-buffer
Definition: DepthPeeling.hh:130
GLSL::Program
GLSL program class.
Definition: GLSLShader.hh:217
DepthPeeling::renderFrontPeeling
void renderFrontPeeling(ACG::GLState *_glState, Viewer::ViewerProperties &_properties)
peel the scene from front to back, one layer per pass
Definition: DepthPeeling.cc:281
DepthPeeling::initDepthPeeling
void initDepthPeeling()
Allocate framebuffers and load shaders for depth-peeling.
Definition: DepthPeeling.cc:981
BaseInterface.hh
DepthPeeling::addRenderObject
void addRenderObject(ACG::RenderObject *_renderObject)
overide addRenderObject function to include OIT check
Definition: DepthPeeling.cc:822
DepthPeeling::peelBlendDual_
GLSL::Program * peelBlendDual_
dual depth peeling shaders
Definition: DepthPeeling.hh:137
DepthPeeling::ViewerResources::height_
unsigned int height_
viewer window height
Definition: DepthPeeling.hh:154
DepthPeeling::name
QString name()
Return a name for the plugin.
Definition: DepthPeeling.hh:78
RenderInterface.hh
DepthPeeling::viewerRes_
std::map< int, ViewerResources > viewerRes_
Definition: DepthPeeling.hh:188
DepthPeeling::ViewerResources::width_
unsigned int width_
viewer window width
Definition: DepthPeeling.hh:151