Developer Documentation
Loading...
Searching...
No Matches
ClassicDepthPeeling.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#include <QObject>
45
49
51
52#include <map>
53
54
56{
57 Q_OBJECT
58 Q_INTERFACES(BaseInterface)
59 Q_INTERFACES(RenderInterface)
60 Q_INTERFACES(LoggingInterface)
61
62 Q_PLUGIN_METADATA(IID "org.OpenFlipper.Plugins.Plugin-Render-Old-DepthPeeling")
63
64signals:
65 // LoggingInterface
66 void log(Logtype _type, QString _message);
67 void log(QString _message);
68
69
70public :
71
74
75 QString name() { return (QString("Dual Depth Peeling Plugin using classic rendering pipeling")); };
76 QString description( ) { return (QString(tr("Order independent transparency renderer (classic pipeline)"))); };
77
78public slots:
79 QString version() { return QString("1.0"); };
80
81private slots:
82
83 //BaseInterface
84 void initializePlugin();
85 void exit();
86
87 // RenderInterface
88 void render(ACG::GLState* _glState, Viewer::ViewerProperties& _properties);
89 QString rendererName();
90 void supportedDrawModes(ACG::SceneGraph::DrawModes::DrawMode& _mode);
91 QString checkOpenGL();
92
93private:
94
96 void destroyResources();
97
99 void destroyResources(int _viewerId);
100
102 void reloadResources(int _viewerId);
103
105 void drawQuadProj(float _x0 = -1.0f, float _y0 = 1.0f,
106 float _w = 2.0f, float _h = 2.0f);
107
109 void traverseLightNodes(BaseNode* _node);
110
112 void generatePeelingShaders(GLSL::StringList* _strVertexShaderOut,
113 GLSL::StringList* _strFragmentShaderOut,
114 GLSL::StringList* _strGeometryShaderOut,
115 bool _textured, bool _flatShaded, bool _phong, bool _vertexColor, bool _wireFrame);
116
119
121 void drawScenePass(ACG::GLState* _glState, ACG::SceneGraph::DrawModes::DrawMode _drawMode, BaseNode* _sceneGraphRoot);
122
123 void drawScenePeelPass(ACG::GLState* _glState, ACG::SceneGraph::DrawModes::DrawMode _drawMode, BaseNode* _sceneGraphRoot, int _peelPass);
124
125 template <class Action>
126 void traverseDraw(BaseNode* _node, Action& _action, ACG::SceneGraph::DrawModes::DrawMode _globalDrawMode, int _pass, int _peelPass);
127
128 template <class Action>
129 bool traverseDrawApplyAction(BaseNode* _node, Action& _action, ACG::SceneGraph::DrawModes::DrawMode _globalDrawMode, int _pass, int _peelPass);
130
133
134private:
135
137 {
139
141 unsigned int glWidth_;
142
144 unsigned int glHeight_;
145
147 unsigned int rtWidth_;
149 unsigned int rtHeight_;
150
155 };
156
157 std::map<int, ViewerResources> viewerRes_;
158
161
164
165 // note that shader flags are only good easy shader indexing
166 // some combinations like phong + flat make no sense
167 enum
168 {
169 PEEL_SHADER_WIREFRAME = 0, // wireframe is a special case here, not combinable with others
170 PEEL_SHADER_HIDDENLINE = 1, // hiddenline is another special case, it renders geometry in background color
171 PEEL_SHADER_TEXTURED = 0x1,
172 PEEL_SHADER_PHONG = 0x2,
173 PEEL_SHADER_GOURAUD = 0x4,
174 PEEL_SHADER_FLAT = 0x8,
175 PEEL_SHADER_VERTEXCOLORS = 0x10,
176 PEEL_NUM_COMBINATIONS = 0x20,
177 PEEL_SHADER_NUM_FLAGS = 5
178 };
180 GLSL::Shader* peelShaders_[PEEL_NUM_COMBINATIONS*3]; // interleaved: vertex, geometry, fragment
181
183 GLSL::Program* peelProgs_[PEEL_NUM_COMBINATIONS];
184
187
190
193
196 {
197 LIGHTTYPE_DIRECTIONAL = 0,
198 LIGHTTYPE_POINT,
199 LIGHTTYPE_SPOT
200 };
201
205 GLuint glLightIDs_[16];
206};
Logtype
Log types for Message Window.
Interface class from which all plugins have to be created.
QString name()
Return a name for the plugin.
QString description()
Return a description of what the plugin is doing.
void drawQuadProj(float _x0=-1.0f, float _y0=1.0f, float _w=2.0f, float _h=2.0f)
draw a quad in projection space (only positions)
GLSL::Program * peelProgs_[PEEL_NUM_COMBINATIONS]
generates shader programs
void traverseLightNodes(BaseNode *_node)
find all light nodes in the scene
void destroyResources()
free all gl resources
void updatePeelingShaderSet()
regenerates peeling shaders based on light nodes in scenegraph
LightType
light type enumeration
GLuint numLights_
number of used lights in the scene
GLSL::Shader * blendShaders_[8]
shader resources
ACG::GLState * glStateTmp_
current glState ptr for hiddenline rendering
GLuint glLightIDs_[16]
matching GL light id
GLSL::Program * blendDualPeelProg_[4]
depth peeling programs
void drawScenePass(ACG::GLState *_glState, ACG::SceneGraph::DrawModes::DrawMode _drawMode, BaseNode *_sceneGraphRoot)
draw the current scene
LightType lightTypes_[16]
registered lights in the scene
void generatePeelingShaders(GLSL::StringList *_strVertexShaderOut, GLSL::StringList *_strFragmentShaderOut, GLSL::StringList *_strGeometryShaderOut, bool _textured, bool _flatShaded, bool _phong, bool _vertexColor, bool _wireFrame)
peel shader generator based on lights and texture mode
unsigned int getPeelShaderIndex(ACG::SceneGraph::DrawModes::DrawMode _drawMode)
converts a drawmode to the correct shading program index
void reloadResources(int _viewerId)
reload gl resources
GLSL::Shader * peelShaders_[PEEL_NUM_COMBINATIONS *3]
generated shader set
GLuint blendQueryID_
fragment query
GLSL program class.
A generic shader base class.
Definition GLSLShader.hh:71
Interface for all Plugins which do logging to the logging window of the framework.
Interface to add additional rendering functions from within plugins.
unsigned int glWidth_
viewer window width
unsigned int rtWidth_
render target width
GLuint blendDualPeelTexID_[7]
render target textures: {depth0, depth1, front_blend0, front_blend1, back_temp0, back_temp1,...
unsigned int glHeight_
viewer window height
unsigned int rtHeight_
render target height