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
ShaderGenerator.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 * $Revision$ *
45 * $Author$ *
46 * $Date$ *
47 * *
48 \*===========================================================================*/
49
50 #pragma once
51
52 #include <QStringList>
53 #include <QString>
54 #include <string>
55 #include <list>
56 #include <map>
57 #include <vector>
58
59 #include <ACG/GL/gl.hh>
60 #include <ACG/Config/ACGDefines.hh>
61
62
63 namespace ACG
64 {
65
66
67 // #define MAX_SHADER_INPUT_UNITS 32
68 // #define MAX_SHADER_CONSTANTS 0x200
69 // #define MAX_SHADER_GEN_DEFINES 0x100
70 #define SG_MAX_SHADER_LIGHTS 8
71
72 enum ShaderGenLightType
73 {
74 SG_LIGHT_DIRECTIONAL = 0,
75 SG_LIGHT_POINT,
76 SG_LIGHT_SPOT,
77 SG_LIGHT_FORCE_DWORD = 0xFFFFFFFF
78 };
79
80 enum ShaderGenShadeMode
81 {
82 SG_SHADE_UNLIT = 0,
83 SG_SHADE_FLAT,
84 SG_SHADE_GOURAUD,
85 SG_SHADE_PHONG,
86 SG_SHADE_FORCE_DWORD = 0xFFFFFFFF
87 };
88
89 class ShaderGenDesc
90 {
91
92 public:
93 ShaderGenDesc() :
94 version(150),
95 numLights(0),
96 shadeMode(SG_SHADE_UNLIT),
97 vertexColors(false),
98 vertexTemplateFile(""),
99 tessControlTemplateFile(""),
100 tessEvaluationTemplateFile(""),
101 geometryTemplateFile(""),
102 fragmentTemplateFile(""),
103 normalizeTexColors(true),
104 colorMaterialMode(GL_AMBIENT_AND_DIFFUSE),
105 textureTypes_(),
106 texGenDim(0),
107 texGenMode(GL_EYE_LINEAR),
108 texGenPerFragment(false)
109 {
110 for ( unsigned int i = 0 ; i < SG_MAX_SHADER_LIGHTS ; ++i)
111 lightTypes[i] = SG_LIGHT_DIRECTIONAL;
112 }
113
114 //In case, something crashes with the light types, try this hammer ;-)
115 // const ShaderGenDesc& operator= (const ShaderGenDesc& _rhs) {
116 //
117 // version = _rhs.version;
118 //
119 // numLights = _rhs.numLights;
120 //
121 // std::copy(_rhs.lightTypes,_rhs.lightTypes+SG_MAX_SHADER_LIGHTS,lightTypes);
122 // textureTypes_ = _rhs.textureTypes_;
123 //
124 // shadeMode = _rhs.shadeMode;
125 // vertexColors = _rhs.vertexColors;
126 // vertexTemplateFile = _rhs.vertexTemplateFile;
127 // tessControlTemplateFile = _rhs.tessControlTemplateFile;
128 // tessEvaluationTemplateFile = _rhs.tessEvaluationTemplateFile;
129 // geometryTemplateFile = _rhs.geometryTemplateFile;
130 // fragmentTemplateFile = _rhs.fragmentTemplateFile;
131 //
132 // textureTypes_ = _rhs.textureTypes_;
133 //
134 // return *this;
135 // }
136
137 // glsl version, i.e. 130, 150, 330 etc.
138 // Versions before 130 are not supported (deprecated "varying", "ftransform".. stuff)
139 // Specification of each version available on http://www.opengl.org/registry/
140 // default: 150 (OpenGL 3.2, supports geometry shaders, msaa samplers, gl_PrimitiveID )
141 int version;
142
143 int numLights;
144 ShaderGenLightType lightTypes[SG_MAX_SHADER_LIGHTS];
145
146 ShaderGenShadeMode shadeMode;
147
148 bool vertexColors;
149
150 // optionally specify shader template file names
151 QString vertexTemplateFile;
152 QString tessControlTemplateFile;
153 QString tessEvaluationTemplateFile;
154 QString geometryTemplateFile;
155 QString fragmentTemplateFile;
156
157 // preprocessor macros for the shaders
158 // these are added to all shaders directly after the #version directive
159 QStringList macros;
160
162 QString toString() const;
163
165 bool normalizeTexColors;
166
168 QString vertexColorsInterpolator;
169
170 // color material for input vertex colors: GL_EMISSION, GL_AMBIENT, GL_DIFFUSE, GL_SPECULAR, GL_AMBIENT_AND_DIFFUSE
171 // Usage of vertex colors in lighting function, as diffuse, emission, ambient color .. see glColorMaterial()
172 // default: GL_AMBIENT_AND_DIFFUSE
173 GLenum colorMaterialMode;
174
175 struct TextureType
176 {
177 GLenum type;
178 bool shadow;
179 };
180 private:
181 // TODO: remove this, multitexturing always requires some customization! should be done via custom shader templates or mods. only allow one diffuse texture, as this is something commonly used and intentions are clear
183 std::map<size_t,TextureType> textureTypes_;
184
185 public:
186 const std::map<size_t,TextureType>& textureTypes() const {return textureTypes_;}
187
191 void addTextureType(GLenum _type, bool _shadow, size_t _stage)
192 {
193 TextureType t;
194 t.type = _type;
195 t.shadow = _shadow;
196 textureTypes_[_stage] = t;
197 }
198
200 void clearTextures(){textureTypes_.clear();}
201
202 bool textured()const {return !textureTypes_.empty();}
203
204
205
206 // automatic texture coordinate generation, emulation of glTexGen
207 // this takes priority over any texcoords provided via addTextureType
208
209 // dimension of generated texture coordinate: 0,1,2,3,4 (default: 0 - disabled)
210 int texGenDim;
211
212 // texture generation mode: GL_OBJECT_LINEAR, GL_EYE_LINEAR, GL_SPHERE_MAP, GL_NORMAL_MAP, GL_REFLECTION_MAP
213 GLenum texGenMode;
214
215 // generate texture coordinates per vertex or fragment
216 // default: false -> per vertex
217 bool texGenPerFragment;
218
219 void enableTexGenObjectLinear(int _dim = 2)
220 {
221 texGenDim = std::max(std::min(_dim, 4), 0);
222 texGenMode = GL_OBJECT_LINEAR;
223 }
224
225 void enableTexGenEyeLinear(int _dim = 2)
226 {
227 texGenDim = std::max(std::min(_dim, 4), 0);
228 texGenMode = GL_EYE_LINEAR;
229 }
230
231 void enableTexGenSphericalMap(int _dim = 2)
232 {
233 texGenDim = std::max(std::min(_dim, 2), 0);
234 texGenMode = GL_SPHERE_MAP;
235 }
236
237 void enableTexGenNormalMap(int _dim = 3)
238 {
239 texGenDim = std::max(std::min(_dim, 3), 0);
240 texGenMode = GL_NORMAL_MAP;
241 }
242
243 void enableTexGenReflectionMap(int _dim = 3)
244 {
245 texGenDim = std::max(std::min(_dim, 3), 0);
246 texGenMode = GL_REFLECTION_MAP;
247 }
248
249 void disableTexGen() { texGenDim = 0; }
250
251
252 // comparison operator
253 bool operator == (const ShaderGenDesc& _rhs) const
254 {
255 if (numLights != _rhs.numLights)
256 return false;
257
258 if (shadeMode != _rhs.shadeMode)
259 return false;
260
261 if (vertexColors != _rhs.vertexColors)
262 return false;
263
264 if (textured() != _rhs.textured())
265 return false;
266
267 if (vertexColors)
268 {
269 if (vertexColorsInterpolator != _rhs.vertexColorsInterpolator)
270 return false;
271
272 if (colorMaterialMode != _rhs.colorMaterialMode)
273 return false;
274 }
275
276 if (fragmentTemplateFile != _rhs.fragmentTemplateFile)
277 return false;
278
279 if (geometryTemplateFile != _rhs.geometryTemplateFile)
280 return false;
281
282 if (vertexTemplateFile != _rhs.vertexTemplateFile)
283 return false;
284
285 if (tessControlTemplateFile != _rhs.tessControlTemplateFile)
286 return false;
287
288 if (tessEvaluationTemplateFile != _rhs.tessEvaluationTemplateFile)
289 return false;
290
291 if (macros != _rhs.macros)
292 return false;
293
294 if (texGenDim != _rhs.texGenDim)
295 return false;
296
297 if (texGenDim)
298 {
299 if (texGenMode != _rhs.texGenMode)
300 return false;
301
302 if (texGenPerFragment != _rhs.texGenPerFragment)
303 return false;
304 }
305
306 if (numLights)
307 return memcmp(lightTypes, _rhs.lightTypes, numLights * sizeof(ShaderGenLightType)) == 0;
308
309 return true;
310 }
311 };
312
313
518 class ACGDLLEXPORT ShaderGenerator
519 {
520 public:
521
522 ShaderGenerator();
523 virtual ~ShaderGenerator();
524
525
526 struct DefaultIODesc
527 {
528 DefaultIODesc();
529
531 bool inputTexCoord_, // texcoords
532 inputColor_, // vertex colors
533 inputNormal_; // view space normals
534
536 bool passPosVS_, // view space position
537 passPosOS_, // object space position
538 passTexCoord_, // texcoords
539 passColor_, // vertex colors
540 passNormalVS_, // view space normals
541 passNormalOS_; // object space normals
542 };
543
544
547 void setGLSLVersion(int _version);
548
551 void addIncludeFile(QString _fileName);
552
555 void initVertexShaderIO(const ShaderGenDesc* _desc, const DefaultIODesc* _iodesc);
556
559 void initTessControlShaderIO(const ShaderGenDesc* _desc, ShaderGenerator* _prevStage, const DefaultIODesc* _iodesc);
560
563 void initTessEvalShaderIO(const ShaderGenDesc* _desc, ShaderGenerator* _prevStage, const DefaultIODesc* _iodesc);
564
567 void initGeometryShaderIO(const ShaderGenDesc* _desc, ShaderGenerator* _prevStage, const DefaultIODesc* _iodesc);
568
571 void initFragmentShaderIO(const ShaderGenDesc* _desc, ShaderGenerator* _prevStage, const DefaultIODesc* _iodesc);
572
580 void initDefaultUniforms();
581
590 void addInput(const QString& _input);
591
600 void addInput(const QString& _type, const QString& _varname) { addInput(_type + QString(" ") + _varname); }
601
610 void addOutput(const QString& _output);
611
620 void addOutput(const QString& _type, const QString& _varname) { addOutput(_type + QString(" ") + _varname); }
621
622
631 void addUniform(QString _uniform, QString _comment = "");
632
640 void addDefine(const QString& _define);
641
645 void addIODefine(const QString& _macroName, const QString& _resolvedName);
646
650 void addMacros(const QStringList& _macros);
651
659 bool hasDefine(QString _define) const;
660
668 void addLayout(QString _layout);
669
670
685 void addRawIOBlock(QStringList _codeBlock) {rawIO_.append(_codeBlock);}
686
689 void addLight(int lightIndex_, ShaderGenLightType _light);
690
696 void buildShaderCode(QStringList* _pMainCode, const QStringList& _defaultLightingFunctions);
697
700 const QStringList& getShaderCode();
701
706 void saveToFile(const char* _fileName);
707
708
721 void matchInputs(const ShaderGenerator* _previousShaderStage, bool _passToNextStage, QString _inputPrefix = "outVertex", QString _outputPrefix = "outGeometry");
722
733 void defineIOAbstraction(const DefaultIODesc* _iodesc, bool _vs, bool _fs);
734
737 int getNumOutputs() const;
738
743 QString getOutputName(int _id) const;
744
747 int getNumInputs() const;
748
753 QString getInputName(int _id) const;
754
760 QString getIOMapName(int _inId) const;
761
762
763 public:
764
765 struct Keywords
766 {
767 Keywords();
768
769 // preprocessor macros that can be defined
770
771 // request vertex attributes that should be available in all shader stages:
772 QString macro_requestPosVS, // view space position
773 macro_requestPosOS, // object space position
774 macro_requestTexcoord, // mesh texture coordinate
775 macro_requestVertexColor, // vertex color
776 macro_requestNormalVS, // view space normal
777 macro_requestNormalOS, // object space normal
778
779 macro_requestRenormalize; // normal should be renormalized before using it for lighting
780
781 // input / output abstraction macros
782 QString macro_inputPosVS,
783 macro_inputPosOS,
784 macro_inputPosCS,
785 macro_inputNormalVS,
786 macro_inputNormalOS,
787 macro_inputTexcoord,
788 macro_inputVertexColor,
789
790 macro_outputPosVS,
791 macro_outputPosOS,
792 macro_outputPosCS,
793 macro_outputNormalVS,
794 macro_outputNormalOS,
795 macro_outputTexcoord,
796 macro_outputVertexColor;
797
798 // default input/output variable names without prefixes
799 QString ioPosCS,
800 ioPosOS,
801 ioPosVS,
802 ioNormalVS,
803 ioNormalOS,
804 ioTexcoord,
805 ioColor;
806
807 // input/output prefix at each shader stage
808 QString vs_inputPrefix,
809 vs_outputPrefix,
810 tcs_outputPrefix,
811 tes_outputPrefix,
812 gs_outputPrefix,
813 fs_outputPrefix;
814
815 // actual input/output of vertex shader
816 QString vs_inputPosition,
817 vs_inputNormal,
818 vs_inputTexCoord,
819 vs_inputColor,
820 vs_outputPosCS,
821 vs_outputPosVS,
822 vs_outputPosOS,
823 vs_outputTexCoord,
824 vs_outputNormalVS,
825 vs_outputNormalOS,
826 vs_outputVertexColor,
827 fs_outputFragmentColor;
828 };
829
830 static const Keywords keywords;
831
832 private:
833
838 void addStringToList(QString _str, QStringList* _list, QString _prefix = "", QString _postfix = "");
839
843 void addIOToCode(const QStringList& _cmds);
844
845 QStringList code_;
846
847
849 QStringList imports_;
850
851 int version_;
852
853 QStringList inputs_;
854 QStringList outputs_;
855 QStringList uniforms_;
856 QStringList genDefines_;
857 QStringList layouts_;
858
860 QStringList rawIO_;
861
863 bool inputArrays_;
864
866 bool outputArrays_;
867
869 QString inputPrefix_;
870
872 QString outputPrefix_;
873 };
874
875
876
932 class ACGDLLEXPORT ShaderModifier
933 {
934 friend class ShaderProgGenerator;
935
936 public:
937 ShaderModifier(void);
938 virtual ~ShaderModifier(void);
939
951 virtual void modifyVertexIO(ShaderGenerator* _shader) {}
952
965 virtual void modifyVertexBeginCode(QStringList* _code) {}
966
980 virtual void modifyVertexEndCode(QStringList* _code) {}
981
993 virtual void modifyGeometryIO(ShaderGenerator* _shader) {}
994
1006 virtual void modifyTessControlIO(ShaderGenerator* _shader) {}
1007
1019 virtual void modifyTessEvalIO(ShaderGenerator* _shader) {}
1020
1032 virtual void modifyFragmentIO(ShaderGenerator* _shader) {}
1033
1048 virtual void modifyFragmentBeginCode(QStringList* _code) {}
1049
1064 virtual void modifyFragmentEndCode(QStringList* _code) {}
1065
1083 virtual void modifyLightingCode(QStringList* _code, int _lightId, ShaderGenLightType _lightType) {}
1084
1089 virtual bool replaceDefaultLightingCode() {return false;}
1090
1095 unsigned int getID() {return modifierID_;}
1096
1097
1130 static ShaderModifier* loadFromFile(QString _filename);
1131
1132
1133 // operator unsigned int() const {return modifierID_;}
1134 operator std::vector<unsigned int>() const {return std::vector<unsigned int>(1,modifierID_);}
1135
1136 std::vector<unsigned int> operator | (const std::vector<unsigned int>& _v) const
1137 {
1138 std::vector<unsigned int> r(1 + _v.size(), modifierID_);
1139 for (size_t i = 0; i < _v.size(); ++i)
1140 r[i + 1] = _v[i];
1141 return r;
1142 }
1143
1144 private:
1145 unsigned int modifierID_;
1146 };
1147
1148
1152 class ACGDLLEXPORT ShaderProgGenerator
1153 {
1154 public:
1155
1160 static void setShaderDir(QString _dir);
1161
1165 static QString getShaderDir();
1166
1170 ShaderProgGenerator(const ShaderGenDesc* _desc);
1171
1176 ShaderProgGenerator(const ShaderGenDesc* _desc, const std::vector<unsigned int>& _modifierIDs);
1177
1182 ShaderProgGenerator(const ShaderGenDesc* _desc, const std::vector<unsigned int>* _modifierIDs);
1183
1189 ShaderProgGenerator(const ShaderGenDesc* _desc, const unsigned int* _modifierIDs, unsigned int _numModifiers);
1190
1196 ShaderProgGenerator(const ShaderGenDesc* _desc, ShaderModifier* const* _modifiers, unsigned int _numModifiers);
1197
1202 ShaderProgGenerator(const ShaderGenDesc* _desc, const std::vector<ShaderModifier*>& _modifiers);
1203
1208 ShaderProgGenerator(const ShaderGenDesc* _desc, const std::vector<ShaderModifier*>* _modifiers);
1209
1210 virtual ~ShaderProgGenerator(void);
1211
1212
1213 void saveVertexShToFile(const char* _fileName);
1214 void saveGeometryShToFile(const char* _fileName);
1215 void saveFragmentShToFile(const char* _fileName);
1216
1219 const QStringList& getVertexShaderCode();
1220
1223 const QStringList& getTessControlShaderCode();
1224
1227 const QStringList& getTessEvaluationShaderCode();
1228
1231 const QStringList& getGeometryShaderCode();
1232
1235 const QStringList& getFragmentShaderCode();
1236
1237
1240 int getNumActiveModifiers() const;
1241
1244 ShaderModifier* getActiveModifier(int _i);
1245
1246
1253 static unsigned int registerModifier(ShaderModifier* _modifier);
1254
1257 bool hasGeometryShader() const;
1258
1261 bool hasTessControlShader() const;
1262
1265 bool hasTessEvaluationShader() const;
1266
1269 void generateShaders();
1270
1276 static bool loadStringListFromFile(QString _fileName, QStringList* _out);
1277
1281 static QString getAbsFilePath(QString _fileName);
1282
1283 private:
1284
1287 void loadShaderTemplateFromFile();
1288
1291 void scanShaderTemplate(QStringList& _templateSrc, QString _templateFilename, QStringList* _outLayoutDirectives = 0);
1292
1295 void init(const ShaderGenDesc* _desc, ShaderModifier* const* _modifiers, unsigned int _numActiveMods);
1296 void init(const ShaderGenDesc* _desc, const unsigned int* _modifiers, unsigned int _numActiveMods);
1297
1298 void buildVertexShader();
1299 void buildTessControlShader();
1300 void buildTessEvalShader();
1301 void buildGeometryShader();
1302 void buildFragmentShader();
1303
1304 void addVertexBeginCode(QStringList* _code);
1305 void addVertexEndCode(QStringList* _code);
1306
1307 void addFragmentBeginCode(QStringList* _code);
1308 void addFragmentEndCode(QStringList* _code);
1309
1314 void addLightingFunctions(QStringList* _code);
1315
1318 void addLightingCode(QStringList* _code);
1319
1322 void modifyLightingCode(QStringList* _code, ShaderModifier* _modifier);
1323
1326 void addTexGenCode(QStringList* _code, bool _fragmentShader);
1327
1329 static QString getPathName(QString _strFileName);
1330
1333 int checkForIncludes(QString _str, ShaderGenerator* _gen, QString _includePath);
1334
1337 int checkForIncludes(QString _str, QStringList* _outImport, QString _includePath);
1338
1339
1341 void initGenDefines(ShaderGenerator* _gen);
1342
1343 static void loadLightingFunctions();
1344
1345 ShaderGenerator* vertex_;
1346 ShaderGenerator* tessControl_;
1347 ShaderGenerator* tessEval_;
1348 ShaderGenerator* geometry_;
1349 ShaderGenerator* fragment_;
1350
1351 QStringList vertexTemplate_;
1352 QStringList tessControlTemplate_;
1353 QStringList tessEvalTemplate_;
1354 QStringList geometryTemplate_;
1355 QStringList fragmentTemplate_;
1356
1357 ShaderGenDesc desc_;
1358 std::vector<ShaderModifier*> activeMods_;
1359
1360
1362 static int numRegisteredModifiers_;
1363 static std::vector<ShaderModifier*> registeredModifiers_;
1364
1366 QString vertexShaderFile_;
1367 QString tessControlShaderFile_;
1368 QString tessEvalShaderFile_;
1369 QString geometryShaderFile_;
1370 QString fragmentShaderFile_;
1371
1373 QStringList tessControlLayout_;
1374 QStringList tessEvalLayout_;
1375
1376
1378 ShaderGenerator::DefaultIODesc ioDesc_;
1379
1381 bool renormalizeLighting_;
1382
1383
1384 static QString shaderDir_;
1385 static QStringList lightingCode_;
1386
1387
1388 };
1389
1390
1391 //=============================================================================
1392 } // namespace ACG
1393 //=============================================================================
ACG::ShaderGenDesc::normalizeTexColors
bool normalizeTexColors
Defines if the textureVariable is normalized or not, if multiple textures are used.
Definition: ShaderGenerator.hh:165
ACG::ShaderGenerator::addOutput
void addOutput(const QString &_type, const QString &_varname)
Add one GLSL output specifier.
Definition: ShaderGenerator.hh:620
ACG::ShaderProgGenerator::tessControlLayout_
QStringList tessControlLayout_
layout() directives scanned from loaded templates
Definition: ShaderGenerator.hh:1373
ACG::ShaderModifier::modifyTessControlIO
virtual void modifyTessControlIO(ShaderGenerator *_shader)
Add your own inputs/outputs to the tessellation control shader.
Definition: ShaderGenerator.hh:1006
ACG
Namespace providing different geometric functions concerning angles.
Definition: DBSCANT.cc:51
ACG::ShaderProgGenerator::numRegisteredModifiers_
static int numRegisteredModifiers_
registered shader modifier
Definition: ShaderGenerator.hh:1362
ACG::ShaderGenerator::outputPrefix_
QString outputPrefix_
prefix of outputs of this shader
Definition: ShaderGenerator.hh:872
ACG::ShaderGenerator::addRawIOBlock
void addRawIOBlock(QStringList _codeBlock)
Add a raw glsl IO code block.
Definition: ShaderGenerator.hh:685
ACG::ShaderGenerator::DefaultIODesc
Definition: ShaderGenerator.hh:526
ACG::ShaderModifier::replaceDefaultLightingCode
virtual bool replaceDefaultLightingCode()
Specify whether this modifier replaces or extends the default lighting code.
Definition: ShaderGenerator.hh:1089
ACG::ShaderProgGenerator
Definition: ShaderGenerator.hh:1152
ACG::ShaderGenDesc::addTextureType
void addTextureType(GLenum _type, bool _shadow, size_t _stage)
adds a texture type to the shader and enables texturing.
Definition: ShaderGenerator.hh:191
ACG::ShaderModifier::modifyVertexBeginCode
virtual void modifyVertexBeginCode(QStringList *_code)
Append code the the vertex shader.
Definition: ShaderGenerator.hh:965
ACG::ShaderModifier::modifyVertexIO
virtual void modifyVertexIO(ShaderGenerator *_shader)
Add your own inputs/outputs to the vertex shader.
Definition: ShaderGenerator.hh:951
ACG::ShaderModifier::modifyGeometryIO
virtual void modifyGeometryIO(ShaderGenerator *_shader)
Add your own inputs/outputs to the geometry shader.
Definition: ShaderGenerator.hh:993
ACG::ShaderModifier::modifyFragmentEndCode
virtual void modifyFragmentEndCode(QStringList *_code)
Append code the the fragment shader.
Definition: ShaderGenerator.hh:1064
ACG::ShaderProgGenerator::ioDesc_
ShaderGenerator::DefaultIODesc ioDesc_
default IO descriptor for the vertex shader
Definition: ShaderGenerator.hh:1378
ACG::ShaderGenDesc::toString
QString toString() const
convert ShaderGenDesc to string format for debugging
Definition: ShaderGenerator.cc:2688
ACG::ShaderModifier::modifyTessEvalIO
virtual void modifyTessEvalIO(ShaderGenerator *_shader)
Add your own inputs/outputs to the tessellation evaluation shader.
Definition: ShaderGenerator.hh:1019
ACG::ShaderModifier::getID
unsigned int getID()
Returns the modifier ID.
Definition: ShaderGenerator.hh:1095
ACG::ShaderGenerator::DefaultIODesc::passPosVS_
bool passPosVS_
default attributes that should be passed down from vertex shader
Definition: ShaderGenerator.hh:536
ACG::ShaderModifier::modifyFragmentBeginCode
virtual void modifyFragmentBeginCode(QStringList *_code)
Append code the the fragment shader.
Definition: ShaderGenerator.hh:1048
ACG::ShaderGenDesc::vertexColorsInterpolator
QString vertexColorsInterpolator
interpolation qualifier for input vertex colors: "flat", "smooth", "noperspective" ...
Definition: ShaderGenerator.hh:168
ACG::ShaderGenerator::Keywords
Definition: ShaderGenerator.hh:765
ACG::ShaderModifier
Definition: ShaderGenerator.hh:932
ACG::ShaderGenerator::DefaultIODesc::inputTexCoord_
bool inputTexCoord_
default attributes that should be imported in vertex shader
Definition: ShaderGenerator.hh:531
ACG::ShaderGenDesc::clearTextures
void clearTextures()
disables texture support and removes all texture types
Definition: ShaderGenerator.hh:200
ACG::ShaderGenerator::addInput
void addInput(const QString &_type, const QString &_varname)
Add one GLSL input specifier.
Definition: ShaderGenerator.hh:600
ACG::ShaderGenDesc
Definition: ShaderGenerator.hh:89
ACG::ShaderGenerator::outputArrays_
bool outputArrays_
outputs of shader are arrays (tess-control)
Definition: ShaderGenerator.hh:866
ACG::ShaderModifier::modifyLightingCode
virtual void modifyLightingCode(QStringList *_code, int _lightId, ShaderGenLightType _lightType)
Modify the default lighting code of the shader generator.
Definition: ShaderGenerator.hh:1083
ACG::ShaderGenerator::inputArrays_
bool inputArrays_
inputs of shader are arrays (tess-control, tess-eval, geometry)
Definition: ShaderGenerator.hh:863
ACG::ShaderGenDesc::TextureType
Definition: ShaderGenerator.hh:175
ACG::ShaderGenDesc::textureTypes_
std::map< size_t, TextureType > textureTypes_
holds the texture types (second) and the stage id (first). if empty, shader does not support textures...
Definition: ShaderGenerator.hh:183
ACG::ShaderProgGenerator::renormalizeLighting_
bool renormalizeLighting_
renormalize before lighting, default false, can be activated via "#define SG_REQUEST_RENORMALIZE" ...
Definition: ShaderGenerator.hh:1381
ACG::ShaderModifier::modifyVertexEndCode
virtual void modifyVertexEndCode(QStringList *_code)
Append code the the vertex shader.
Definition: ShaderGenerator.hh:980
ACG::ShaderGenerator::rawIO_
QStringList rawIO_
io block as glsl code
Definition: ShaderGenerator.hh:860
ACG::ShaderGenerator::inputPrefix_
QString inputPrefix_
prefix of inputs to this shader, same as prefix of ouputs of previous stage
Definition: ShaderGenerator.hh:869
ACG::ShaderGenerator::imports_
QStringList imports_
glsl code imports (with #include )
Definition: ShaderGenerator.hh:849
ACG::ShaderGenerator
Definition: ShaderGenerator.hh:518
ACG::ShaderModifier::modifyFragmentIO
virtual void modifyFragmentIO(ShaderGenerator *_shader)
Add your own inputs/outputs to the fragment shader.
Definition: ShaderGenerator.hh:1032
ACG::ShaderProgGenerator::vertexShaderFile_
QString vertexShaderFile_
path + filename to shader templates
Definition: ShaderGenerator.hh:1366