Developer Documentation

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 #include <QAction>
49
50 #include <OpenFlipper/BasePlugin/BaseInterface.hh>
51 #include <OpenFlipper/BasePlugin/RenderInterface.hh>
52 #include <OpenFlipper/BasePlugin/LoggingInterface.hh>
53
54
55 #include <ACG/GL/IRenderer.hh>
56 #include <ACG/GL/FBO.hh>
57
58 class DepthPeeling : public QObject, BaseInterface, RenderInterface, LoggingInterface, ACG::IRenderer
59 {
60 Q_OBJECT
61 Q_INTERFACES(BaseInterface)
62 Q_INTERFACES(RenderInterface)
63 Q_INTERFACES(LoggingInterface)
64
65 Q_PLUGIN_METADATA(IID "org.OpenFlipper.Plugins.Plugin-Render-DepthPeeling")
66
67 signals:
68 // LoggingInterface
69 void log(Logtype _type, QString _message);
70 void log(QString _message);
71
72
73 public:
74 DepthPeeling();
75 ~DepthPeeling();
76
77 QString name() { return (QString("DepthPeeling Plugin")); };
78 QString description( ) { return (QString(tr("DepthPeeling Rendering Pipeline (Alpha Version!)"))); };
79
80
82 void addRenderObject(ACG::RenderObject* _renderObject);
83
84
85 public slots:
86 QString version() { return QString("1.0"); };
87
88 QString renderObjectsInfo(bool _outputShaderInfo);
89
90 QAction* optionsAction();
91
92 private slots:
93
94 //BaseInterface
95 void initializePlugin();
96 void exit();
97
98 // RenderInterface
99 void render(ACG::GLState* _glState, Viewer::ViewerProperties& _properties);
100 QString rendererName() {return QString("Alpha_Version_DepthPeeling");}
101 void supportedDrawModes(ACG::SceneGraph::DrawModes::DrawMode& _mode) {_mode = ACG::SceneGraph::DrawModes::DEFAULT;}
102
103 QString checkOpenGL();
104
105 void slotModeChanged( QAction * );
106
107
108 private:
109
110
112 void renderFrontPeeling(ACG::GLState* _glState, Viewer::ViewerProperties& _properties);
113
115 void renderDualPeeling(ACG::GLState* _glState, Viewer::ViewerProperties& _properties);
116
118 int peelMode_;
119
120 bool copyFrontDepth_;
121
123 int maxPeelCount_;
124
126 GLSL::Program* peelBlend_;
127
129 GLSL::Program* peelFinal_;
130
132 GLuint peelQueryID_;
133
134
136 GLSL::Program* peelBlendDual_;
137 GLSL::Program* peelFinalDual_;
138
139
141 struct ViewerResources
142 {
143 ViewerResources();
144 ~ViewerResources();
145
146 // resize textures
147 void resize(bool _dualPeeling, unsigned int _width, unsigned int _height);
148
150 unsigned int width_;
151
153 unsigned int height_;
154
155
156 // single layer depth peeling textures (front to back peeling)
157 // ping-pong buffer for (depth, front) targets
158 GLuint singleDepthTex_[2]; // float1: minDepth
159 GLuint singleFrontTex_[2]; // rgba: color of front-peeled layer
160 GLuint singleBlendTex_; // rgba: color accumulation buffer
161
162 ACG::FBO* singleFbo_; // targets: {depth0, front0, depth1, front1, blend}
163
164
165
166
167 // dual depth peeling textures
168 // ping-pong buffer for (depth, front, back) targets
169 GLuint dualDepthTex_[2]; // float2: (-minDepth, maxDepth)
170 GLuint dualFrontTex_[2]; // rgba: color of front-peeled layer
171 GLuint dualBackTex_[2]; // rgba: color of back-peeled layer
172 GLuint dualBlendTex_; // rgb: color accumulation buffer
173
174 ACG::FBO* dualFbo_; // targets: {depth0, front0, back0, depth1, front1, back1, blend}
175 };
176
178 void initDepthPeeling();
179
181 void initDualDepthPeeling();
182
187 std::map<int, ViewerResources> viewerRes_;
188
189
190
191
192 // debug functions
193 // GLSL::Program* dbgProg_;
194 //
195 // void dbgDrawTex(GLuint _texID);
196 };
DepthPeeling::name
QString name()
Return a name for the plugin.
Definition: DepthPeeling.hh:77
DepthPeeling::ViewerResources::width_
unsigned int width_
viewer window width
Definition: DepthPeeling.hh:150
DepthPeeling::maxPeelCount_
int maxPeelCount_
max peel count
Definition: DepthPeeling.hh:123
DepthPeeling::viewerRes_
std::map< int, ViewerResources > viewerRes_
Definition: DepthPeeling.hh:187
Logtype
Logtype
Log types for Message Window.
Definition: LoggingInterface.hh:92
RenderInterface.hh
LoggingInterface.hh
Viewer::ViewerProperties
Definition: ViewerProperties.hh:107
DepthPeeling::renderObjectsInfo
QString renderObjectsInfo(bool _outputShaderInfo)
Return a qstring of the current render objects.
Definition: DepthPeeling.cc:1080
DepthPeeling
Definition: DepthPeeling.hh:58
DepthPeeling::ViewerResources::height_
unsigned int height_
viewer window height
Definition: DepthPeeling.hh:153
ACG::RenderObject
Interface class between scenegraph and renderer.
Definition: RenderObject.hh:98
LoggingInterface
Interface for all Plugins which do logging to the logging window of the framework.
Definition: LoggingInterface.hh:112
GLSL::Program
GLSL program class.
Definition: GLSLShader.hh:211
ACG::SceneGraph::DrawModes::DEFAULT
DrawMode DEFAULT
use the default (global) draw mode and not the node&#39;s own.
Definition: DrawModes.cc:72
DepthPeeling::initDepthPeeling
void initDepthPeeling()
Allocate framebuffers and load shaders for depth-peeling.
Definition: DepthPeeling.cc:1008
ACG::GLState
Definition: GLState.hh:213
BaseInterface.hh
DepthPeeling::renderFrontPeeling
void renderFrontPeeling(ACG::GLState *_glState, Viewer::ViewerProperties &_properties)
peel the scene from front to back, one layer per pass
Definition: DepthPeeling.cc:296
DepthPeeling::initDualDepthPeeling
void initDualDepthPeeling()
Allocate framebuffers and load shaders for dual-depth-peeling.
Definition: DepthPeeling.cc:1045
BaseInterface
Interface class from which all plugins have to be created.
Definition: BaseInterface.hh:65
RenderInterface
Interface to add additional rendering functions from within plugins.
Definition: RenderInterface.hh:60
ACG::SceneGraph::DrawModes::DrawMode
Specifies a DrawMode.
Definition: DrawModes.hh:288
ACG::FBO
Definition: FBO.hh:71
DepthPeeling::ViewerResources
Collection of framebuffers for each viewport.
Definition: DepthPeeling.hh:141
DepthPeeling::optionsAction
QAction * optionsAction()
Return options menu.
Definition: DepthPeeling_qt.cc:53
DepthPeeling::addRenderObject
void addRenderObject(ACG::RenderObject *_renderObject)
overide addRenderObject function to include OIT check
Definition: DepthPeeling.cc:838
DepthPeeling::peelQueryID_
GLuint peelQueryID_
occlusion query determining end of peeling (last layer)
Definition: DepthPeeling.hh:132
DepthPeeling::peelFinal_
GLSL::Program * peelFinal_
final copy into back-buffer
Definition: DepthPeeling.hh:129
ACG::IRenderer
Definition: IRenderer.hh:78
DepthPeeling::peelMode_
int peelMode_
mode: 0 -> front to back peeling, 1 -> dual peeling
Definition: DepthPeeling.hh:118
DepthPeeling::renderDualPeeling
void renderDualPeeling(ACG::GLState *_glState, Viewer::ViewerProperties &_properties)
peel the scene with dual depth peeling, two layers per pass
Definition: DepthPeeling.cc:544
DepthPeeling::peelBlendDual_
GLSL::Program * peelBlendDual_
dual depth peeling shaders
Definition: DepthPeeling.hh:136
DepthPeeling::peelBlend_
GLSL::Program * peelBlend_
blends one depth-layer into the current scene target
Definition: DepthPeeling.hh:126
DepthPeeling::description
QString description()
Return a description of what the plugin is doing.
Definition: DepthPeeling.hh:78