Developer Documentation
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 #pragma once
45 
46 #include <QStringList>
47 #include <QString>
48 #include <string>
49 #include <list>
50 #include <map>
51 #include <vector>
52 
53 #include <ACG/GL/gl.hh>
54 #include <ACG/Config/ACGDefines.hh>
55 
56 
57 namespace ACG
58 {
59 
60 
61 // #define MAX_SHADER_INPUT_UNITS 32
62 // #define MAX_SHADER_CONSTANTS 0x200
63 // #define MAX_SHADER_GEN_DEFINES 0x100
64 #define SG_MAX_SHADER_LIGHTS 8
65 
66 enum ShaderGenLightType
67 {
68  SG_LIGHT_DIRECTIONAL = 0,
69  SG_LIGHT_POINT,
70  SG_LIGHT_SPOT,
71  SG_LIGHT_FORCE_DWORD = 0xFFFFFFFF
72 };
73 
74 enum ShaderGenShadeMode
75 {
76  SG_SHADE_UNLIT = 0,
77  SG_SHADE_FLAT,
78  SG_SHADE_GOURAUD,
79  SG_SHADE_PHONG,
80  SG_SHADE_FORCE_DWORD = 0xFFFFFFFF
81 };
82 
84 {
85 
86 public:
87  ShaderGenDesc() :
88  version(150),
89  numLights(0),
90  twoSidedLighting(false),
91  shadeMode(SG_SHADE_UNLIT),
92  vertexColors(false),
93  vertexTemplateFile(""),
94  tessControlTemplateFile(""),
95  tessEvaluationTemplateFile(""),
96  geometryTemplateFile(""),
97  fragmentTemplateFile(""),
98  normalizeTexColors(true),
99  colorMaterialMode(GL_AMBIENT_AND_DIFFUSE),
100  clipDistanceMask(0),
101  textureTypes_(),
102  texGenDim(0),
103  texGenMode(GL_EYE_LINEAR),
104  texGenPerFragment(false)
105  {
106  for ( unsigned int i = 0 ; i < SG_MAX_SHADER_LIGHTS ; ++i)
107  lightTypes[i] = SG_LIGHT_DIRECTIONAL;
108  if(!ACG::openGLVersionTest(3,2)) // version 140 or less
109  {
110  if(!ACG::openGLVersionTest(3,1)) // assume version 130
111  { // less is not supported
112  version = 130;
113  if(ACG::checkExtensionSupported("EXT_texture_buffer"))
114  macros.append("#extension GL_EXT_texture_buffer: enable");
115  }
116  else // version 140 texture buffer is part of spec
117  {
118  version = 140;
119  }
120  }
121  }
122 
123  //In case, something crashes with the light types, try this hammer ;-)
124 // const ShaderGenDesc& operator= (const ShaderGenDesc& _rhs) {
125 //
126 // version = _rhs.version;
127 //
128 // numLights = _rhs.numLights;
129 // twoSidedLighting = _rhs.twoSidedLighting;
130 //
131 // std::copy(_rhs.lightTypes,_rhs.lightTypes+SG_MAX_SHADER_LIGHTS,lightTypes);
132 // textureTypes_ = _rhs.textureTypes_;
133 //
134 // shadeMode = _rhs.shadeMode;
135 // vertexColors = _rhs.vertexColors;
136 // vertexTemplateFile = _rhs.vertexTemplateFile;
137 // tessControlTemplateFile = _rhs.tessControlTemplateFile;
138 // tessEvaluationTemplateFile = _rhs.tessEvaluationTemplateFile;
139 // geometryTemplateFile = _rhs.geometryTemplateFile;
140 // fragmentTemplateFile = _rhs.fragmentTemplateFile;
141 //
142 // textureTypes_ = _rhs.textureTypes_;
143 //
144 // return *this;
145 // }
146 
147  // glsl version, i.e. 130, 150, 330 etc.
148  // Versions before 130 are not supported (deprecated "varying", "ftransform".. stuff)
149  // Specification of each version available on http://www.opengl.org/registry/
150  // default: 150 (OpenGL 3.2, supports geometry shaders, msaa samplers, gl_PrimitiveID )
151  int version;
152 
153  int numLights;
154  ShaderGenLightType lightTypes[SG_MAX_SHADER_LIGHTS];
155 
156  bool twoSidedLighting;
157 
158  ShaderGenShadeMode shadeMode;
159 
160  bool vertexColors;
161 
162  // optionally specify shader template file names
163  QString vertexTemplateFile;
164  QString tessControlTemplateFile;
165  QString tessEvaluationTemplateFile;
166  QString geometryTemplateFile;
167  QString fragmentTemplateFile;
168 
169  // optionally specify shader mod ids
170  std::vector<unsigned int> shaderMods;
171 
172  // preprocessor macros for the shaders
173  // these are added to all shaders directly after the #version directive
174  QStringList macros;
175 
177  QString toString() const;
178 
181 
184 
187 
188  // color material for input vertex colors: GL_EMISSION, GL_AMBIENT, GL_DIFFUSE, GL_SPECULAR, GL_AMBIENT_AND_DIFFUSE
189  // Usage of vertex colors in lighting function, as diffuse, emission, ambient color .. see glColorMaterial()
190  // default: GL_AMBIENT_AND_DIFFUSE
191  GLenum colorMaterialMode;
192 
193  // Bitmask of enabled hardware clip planes.
194  // Bit i represents the i'th clip plane starting at the least significant bit.
195  // This is needed to pass the gl_ClipDistance[] array through the geometry shader stage.
196  uint clipDistanceMask;
197 
198  struct TextureType
199  {
200  GLenum type;
201  bool shadow;
202  };
203 private:
204  // 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
206  std::map<size_t,TextureType> textureTypes_;
207 
208 public:
209  const std::map<size_t,TextureType>& textureTypes() const {return textureTypes_;}
210 
214  void addTextureType(GLenum _type, bool _shadow, size_t _stage)
215  {
216  TextureType t;
217  t.type = _type;
218  t.shadow = _shadow;
219  textureTypes_[_stage] = t;
220  }
221 
223  void clearTextures(){textureTypes_.clear();}
224 
225  bool textured()const {return !textureTypes_.empty();}
226 
227 
228 
229  // automatic texture coordinate generation, emulation of glTexGen
230  // this takes priority over any texcoords provided via addTextureType
231 
232  // dimension of generated texture coordinate: 0,1,2,3,4 (default: 0 - disabled)
233  int texGenDim;
234 
235  // texture generation mode: GL_OBJECT_LINEAR, GL_EYE_LINEAR, GL_SPHERE_MAP, GL_NORMAL_MAP, GL_REFLECTION_MAP
236  GLenum texGenMode;
237 
238  // generate texture coordinates per vertex or fragment
239  // default: false -> per vertex
240  bool texGenPerFragment;
241 
242  void enableTexGenObjectLinear(int _dim = 2)
243  {
244  texGenDim = std::max(std::min(_dim, 4), 0);
245  texGenMode = GL_OBJECT_LINEAR;
246  }
247 
248  void enableTexGenEyeLinear(int _dim = 2)
249  {
250  texGenDim = std::max(std::min(_dim, 4), 0);
251  texGenMode = GL_EYE_LINEAR;
252  }
253 
254  void enableTexGenSphericalMap(int _dim = 2)
255  {
256  texGenDim = std::max(std::min(_dim, 2), 0);
257  texGenMode = GL_SPHERE_MAP;
258  }
259 
260  void enableTexGenNormalMap(int _dim = 3)
261  {
262  texGenDim = std::max(std::min(_dim, 3), 0);
263  texGenMode = GL_NORMAL_MAP;
264  }
265 
266  void enableTexGenReflectionMap(int _dim = 3)
267  {
268  texGenDim = std::max(std::min(_dim, 3), 0);
269  texGenMode = GL_REFLECTION_MAP;
270  }
271 
272  void disableTexGen() { texGenDim = 0; }
273 
274 
275  // comparison operator
276  bool operator == (const ShaderGenDesc& _rhs) const
277  {
278  if (numLights != _rhs.numLights)
279  return false;
280 
281  if ( twoSidedLighting != _rhs.twoSidedLighting )
282  return false;
283 
284  if (shadeMode != _rhs.shadeMode)
285  return false;
286 
287  if (vertexColors != _rhs.vertexColors)
288  return false;
289 
290  if (textured() != _rhs.textured())
291  return false;
292 
293  if (vertexColors)
294  {
295  if (vertexColorsInterpolator != _rhs.vertexColorsInterpolator)
296  return false;
297 
298  if (colorMaterialMode != _rhs.colorMaterialMode)
299  return false;
300  }
301 
302  if (!geometryTemplateFile.isEmpty())
303  {
304  // clip distance mask only affects the geometry shader
305  if (clipDistanceMask != _rhs.clipDistanceMask)
306  return false;
307  }
308 
309  if (fragmentTemplateFile != _rhs.fragmentTemplateFile)
310  return false;
311 
312  if (geometryTemplateFile != _rhs.geometryTemplateFile)
313  return false;
314 
315  if (vertexTemplateFile != _rhs.vertexTemplateFile)
316  return false;
317 
318  if (tessControlTemplateFile != _rhs.tessControlTemplateFile)
319  return false;
320 
321  if (tessEvaluationTemplateFile != _rhs.tessEvaluationTemplateFile)
322  return false;
323 
324  if (macros != _rhs.macros)
325  return false;
326 
327  if (texGenDim != _rhs.texGenDim)
328  return false;
329 
330  if (texGenDim)
331  {
332  if (texGenMode != _rhs.texGenMode)
333  return false;
334 
335  if (texGenPerFragment != _rhs.texGenPerFragment)
336  return false;
337  }
338 
339  if (shaderMods != _rhs.shaderMods)
340  return false;
341 
342  if (vertexNormalInterpolator != _rhs.vertexNormalInterpolator)
343  return false;
344 
345  if (numLights)
346  return memcmp(lightTypes, _rhs.lightTypes, numLights * sizeof(ShaderGenLightType)) == 0;
347 
348  return true;
349  }
350 };
351 
352 
557 class ACGDLLEXPORT ShaderGenerator
558 {
559 public:
560 
561  ShaderGenerator();
562  virtual ~ShaderGenerator();
563 
564 
566  {
567  DefaultIODesc();
568 
570  bool inputTexCoord_, // texcoords
571  inputColor_, // vertex colors
572  inputNormal_; // view space normals
573 
575  bool passPosVS_, // view space position
576  passPosOS_, // object space position
577  passTexCoord_, // texcoords
578  passColor_, // vertex colors
579  passNormalVS_, // view space normals
580  passNormalOS_; // object space normals
581  };
582 
583 
586  void setGLSLVersion(int _version);
587 
590  void addIncludeFile(QString _fileName);
591 
594  void initVertexShaderIO(const ShaderGenDesc* _desc, const DefaultIODesc* _iodesc);
595 
598  void initTessControlShaderIO(const ShaderGenDesc* _desc, ShaderGenerator* _prevStage, const DefaultIODesc* _iodesc);
599 
602  void initTessEvalShaderIO(const ShaderGenDesc* _desc, ShaderGenerator* _prevStage, const DefaultIODesc* _iodesc);
603 
606  void initGeometryShaderIO(const ShaderGenDesc* _desc, ShaderGenerator* _prevStage, const DefaultIODesc* _iodesc);
607 
610  void initFragmentShaderIO(const ShaderGenDesc* _desc, ShaderGenerator* _prevStage, const DefaultIODesc* _iodesc);
611 
619  void initDefaultUniforms();
620 
629  void addInput(const QString& _input);
630 
639  void addInput(const QString& _type, const QString& _varname) { addInput(_type + QString(" ") + _varname); }
640 
649  void addOutput(const QString& _output);
650 
659  void addOutput(const QString& _type, const QString& _varname) { addOutput(_type + QString(" ") + _varname); }
660 
661 
670  void addUniform(QString _uniform, QString _comment = "");
671 
679  void addDefine(const QString& _define);
680 
684  void addIODefine(const QString& _macroName, const QString& _resolvedName);
685 
689  void addMacros(const QStringList& _macros);
690 
698  bool hasDefine(QString _define) const;
699 
707  void addLayout(QString _layout);
708 
709 
724  void addRawIOBlock(QStringList _codeBlock) {rawIO_.append(_codeBlock);}
725 
728  void addLight(int lightIndex_, ShaderGenLightType _light);
729 
735  void buildShaderCode(QStringList* _pMainCode, const QStringList& _defaultLightingFunctions);
736 
739  const QStringList& getShaderCode();
740 
745  void saveToFile(const char* _fileName);
746 
747 
760  void matchInputs(const ShaderGenerator* _previousShaderStage, bool _passToNextStage, QString _inputPrefix = "outVertex", QString _outputPrefix = "outGeometry");
761 
772  void defineIOAbstraction(const DefaultIODesc* _iodesc, bool _vs, bool _fs);
773 
776  int getNumOutputs() const;
777 
782  QString getOutputName(int _id) const;
783 
786  int getNumInputs() const;
787 
792  QString getInputName(int _id) const;
793 
799  QString getIOMapName(int _inId) const;
800 
801 
802 public:
803 
804  struct Keywords
805  {
806  Keywords();
807 
808  // preprocessor macros that can be defined
809 
810  // request vertex attributes that should be available in all shader stages:
811  QString macro_requestPosVS, // view space position
812  macro_requestPosOS, // object space position
813  macro_requestTexcoord, // mesh texture coordinate
814  macro_requestVertexColor, // vertex color
815  macro_requestNormalVS, // view space normal
816  macro_requestNormalOS; // object space normal
817 
818  // input / output abstraction macros
819  QString macro_inputPosVS,
820  macro_inputPosOS,
821  macro_inputPosCS,
822  macro_inputNormalVS,
823  macro_inputNormalOS,
824  macro_inputTexcoord,
825  macro_inputVertexColor,
826 
827  macro_outputPosVS,
828  macro_outputPosOS,
829  macro_outputPosCS,
830  macro_outputNormalVS,
831  macro_outputNormalOS,
832  macro_outputTexcoord,
833  macro_outputVertexColor;
834 
835  // default input/output variable names without prefixes
836  QString ioPosCS,
837  ioPosOS,
838  ioPosVS,
839  ioNormalVS,
840  ioNormalOS,
841  ioTexcoord,
842  ioColor;
843 
844  // input/output prefix at each shader stage
845  QString vs_inputPrefix,
846  vs_outputPrefix,
847  tcs_outputPrefix,
848  tes_outputPrefix,
849  gs_outputPrefix,
850  fs_outputPrefix;
851 
852  // actual input/output of vertex shader
853  QString vs_inputPosition,
854  vs_inputNormal,
855  vs_inputTexCoord,
856  vs_inputColor,
857  vs_outputPosCS,
858  vs_outputPosVS,
859  vs_outputPosOS,
860  vs_outputTexCoord,
861  vs_outputNormalVS,
862  vs_outputNormalOS,
863  vs_outputVertexColor,
864  fs_outputFragmentColor;
865  };
866 
867  static const Keywords keywords;
868 
869 private:
870 
875  void addStringToList(QString _str, QStringList* _list, QString _prefix = "", QString _postfix = "");
876 
880  void addIOToCode(const QStringList& _cmds);
881 
882  QStringList code_;
883 
884 
886  QStringList imports_;
887 
888  int version_;
889 
890  QStringList inputs_;
891  QStringList outputs_;
892  QStringList uniforms_;
893  QStringList genDefines_;
894  QStringList layouts_;
895 
897  QStringList rawIO_;
898 
901 
904 
906  QString inputPrefix_;
907 
909  QString outputPrefix_;
910 };
911 
912 
913 
969 class ACGDLLEXPORT ShaderModifier
970 {
971  friend class ShaderProgGenerator;
972 
973 public:
974  ShaderModifier(void);
975  virtual ~ShaderModifier(void);
976 
988  virtual void modifyVertexIO(ShaderGenerator* _shader) {}
989 
1002  virtual void modifyVertexBeginCode(QStringList* _code) {}
1003 
1017  virtual void modifyVertexEndCode(QStringList* _code) {}
1018 
1030  virtual void modifyGeometryIO(ShaderGenerator* _shader) {}
1031 
1043  virtual void modifyTessControlIO(ShaderGenerator* _shader) {}
1044 
1056  virtual void modifyTessEvalIO(ShaderGenerator* _shader) {}
1057 
1069  virtual void modifyFragmentIO(ShaderGenerator* _shader) {}
1070 
1085  virtual void modifyFragmentBeginCode(QStringList* _code) {}
1086 
1101  virtual void modifyFragmentEndCode(QStringList* _code) {}
1102 
1120  virtual void modifyLightingCode(QStringList* _code, int _lightId, ShaderGenLightType _lightType) {}
1121 
1126  virtual bool replaceDefaultLightingCode() {return false;}
1127 
1132  unsigned int getID() {return modifierID_;}
1133 
1134 
1167  static ShaderModifier* loadFromFile(QString _filename);
1168 
1169 
1170 // operator unsigned int() const {return modifierID_;}
1171  operator std::vector<unsigned int>() const {return std::vector<unsigned int>(1,modifierID_);}
1172 
1173  std::vector<unsigned int> operator | (const std::vector<unsigned int>& _v) const
1174  {
1175  std::vector<unsigned int> r(1 + _v.size(), modifierID_);
1176  for (size_t i = 0; i < _v.size(); ++i)
1177  r[i + 1] = _v[i];
1178  return r;
1179  }
1180 
1181 private:
1182  unsigned int modifierID_;
1183 };
1184 
1185 
1189 class ACGDLLEXPORT ShaderProgGenerator
1190 {
1191 public:
1192 
1197  static void setShaderDir(QString _dir);
1198 
1202  static QString getShaderDir();
1203 
1207  explicit ShaderProgGenerator(const ShaderGenDesc* _desc);
1208 
1213  ShaderProgGenerator(const ShaderGenDesc* _desc, const std::vector<unsigned int>& _modifierIDs);
1214 
1219  ShaderProgGenerator(const ShaderGenDesc* _desc, const std::vector<unsigned int>* _modifierIDs);
1220 
1226  ShaderProgGenerator(const ShaderGenDesc* _desc, const unsigned int* _modifierIDs, unsigned int _numModifiers);
1227 
1233  ShaderProgGenerator(const ShaderGenDesc* _desc, ShaderModifier* const* _modifiers, unsigned int _numModifiers);
1234 
1239  ShaderProgGenerator(const ShaderGenDesc* _desc, const std::vector<ShaderModifier*>& _modifiers);
1240 
1245  ShaderProgGenerator(const ShaderGenDesc* _desc, const std::vector<ShaderModifier*>* _modifiers);
1246 
1247  virtual ~ShaderProgGenerator(void);
1248 
1249 
1250  void saveVertexShToFile(const char* _fileName);
1251  void saveGeometryShToFile(const char* _fileName);
1252  void saveFragmentShToFile(const char* _fileName);
1253 
1256  const QStringList& getVertexShaderCode();
1257 
1260  const QStringList& getTessControlShaderCode();
1261 
1264  const QStringList& getTessEvaluationShaderCode();
1265 
1268  const QStringList& getGeometryShaderCode();
1269 
1272  const QStringList& getFragmentShaderCode();
1273 
1274 
1277  int getNumActiveModifiers() const;
1278 
1281  ShaderModifier* getActiveModifier(int _i);
1282 
1283 
1290  static unsigned int registerModifier(ShaderModifier* _modifier);
1291 
1294  bool hasGeometryShader() const;
1295 
1298  bool hasTessControlShader() const;
1299 
1302  bool hasTessEvaluationShader() const;
1303 
1306  void generateShaders();
1307 
1313  static bool loadStringListFromFile(QString _fileName, QStringList* _out);
1314 
1318  static QString getAbsFilePath(QString _fileName);
1319 
1320 private:
1321 
1324  void loadShaderTemplateFromFile();
1325 
1328  void scanShaderTemplate(QStringList& _templateSrc, QString _templateFilename, QStringList* _outLayoutDirectives = 0);
1329 
1332  void init(const ShaderGenDesc* _desc, ShaderModifier* const* _modifiers, unsigned int _numActiveMods);
1333  void init(const ShaderGenDesc* _desc, const unsigned int* _modifiers, unsigned int _numActiveMods);
1334 
1335  void buildVertexShader();
1336  void buildTessControlShader();
1337  void buildTessEvalShader();
1338  void buildGeometryShader();
1339  void buildFragmentShader();
1340 
1341  void addVertexBeginCode(QStringList* _code);
1342  void addVertexEndCode(QStringList* _code);
1343 
1344  void addFragmentBeginCode(QStringList* _code);
1345  void addFragmentEndCode(QStringList* _code);
1346 
1351  void addLightingFunctions(QStringList* _code);
1352 
1355  void addLightingCode(QStringList* _code);
1356 
1359  void modifyLightingCode(QStringList* _code, ShaderModifier* _modifier);
1360 
1363  void addTexGenCode(QStringList* _code, bool _fragmentShader);
1364 
1366  static QString getPathName(QString _strFileName);
1367 
1370  int checkForIncludes(QString _str, ShaderGenerator* _gen, QString _includePath);
1371 
1374  int checkForIncludes(QString _str, QStringList* _outImport, QString _includePath);
1375 
1376 
1378  void initGenDefines(ShaderGenerator* _gen);
1379 
1380  static void loadLightingFunctions();
1381 
1382  ShaderGenerator* vertex_;
1383  ShaderGenerator* tessControl_;
1384  ShaderGenerator* tessEval_;
1385  ShaderGenerator* geometry_;
1386  ShaderGenerator* fragment_;
1387 
1388  QStringList vertexTemplate_;
1389  QStringList tessControlTemplate_;
1390  QStringList tessEvalTemplate_;
1391  QStringList geometryTemplate_;
1392  QStringList fragmentTemplate_;
1393 
1394  ShaderGenDesc desc_;
1395  std::vector<ShaderModifier*> activeMods_;
1396 
1397 
1400  static std::vector<ShaderModifier*> registeredModifiers_;
1401 
1404  QString tessControlShaderFile_;
1405  QString tessEvalShaderFile_;
1406  QString geometryShaderFile_;
1407  QString fragmentShaderFile_;
1408 
1410  QStringList tessControlLayout_;
1411  QStringList tessEvalLayout_;
1412 
1413 
1416 
1417 
1418  static QString shaderDir_;
1419  static QStringList lightingCode_;
1420 
1421 
1422 };
1423 
1424 
1425 //=============================================================================
1426 } // namespace ACG
1427 //=============================================================================
virtual void modifyGeometryIO(ShaderGenerator *_shader)
Add your own inputs/outputs to the geometry shader.
QString inputPrefix_
prefix of inputs to this shader, same as prefix of ouputs of previous stage
std::map< size_t, TextureType > textureTypes_
holds the texture types (second) and the stage id (first). if empty, shader does not support textures...
ShaderGenerator::DefaultIODesc ioDesc_
default IO descriptor for the vertex shader
bool inputArrays_
inputs of shader are arrays (tess-control, tess-eval, geometry)
Namespace providing different geometric functions concerning angles.
bool inputTexCoord_
default attributes that should be imported in vertex shader
virtual void modifyFragmentIO(ShaderGenerator *_shader)
Add your own inputs/outputs to the fragment shader.
virtual bool replaceDefaultLightingCode()
Specify whether this modifier replaces or extends the default lighting code.
QStringList imports_
glsl code imports (with #include )
void addRawIOBlock(QStringList _codeBlock)
Add a raw glsl IO code block.
void clearTextures()
disables texture support and removes all texture types
QString vertexColorsInterpolator
interpolation qualifier for input vertex colors: "flat", "smooth", "noperspective" ...
virtual void modifyVertexIO(ShaderGenerator *_shader)
Add your own inputs/outputs to the vertex shader.
void addOutput(const QString &_type, const QString &_varname)
Add one GLSL output specifier.
virtual void modifyTessEvalIO(ShaderGenerator *_shader)
Add your own inputs/outputs to the tessellation evaluation shader.
unsigned int getID()
Returns the modifier ID.
void addInput(const QString &_type, const QString &_varname)
Add one GLSL input specifier.
QString vertexShaderFile_
path + filename to shader templates
virtual void modifyLightingCode(QStringList *_code, int _lightId, ShaderGenLightType _lightType)
Modify the default lighting code of the shader generator.
bool ACGDLLEXPORT openGLVersionTest(const int _major, const int _minor)
Definition: gl.hh:275
virtual void modifyFragmentEndCode(QStringList *_code)
Append code the the fragment shader.
virtual void modifyTessControlIO(ShaderGenerator *_shader)
Add your own inputs/outputs to the tessellation control shader.
bool passPosVS_
default attributes that should be passed down from vertex shader
QString vertexNormalInterpolator
interpolation qualifier for vertex shader normal outputs: "flat", "smooth", "noperspective" ...
QStringList rawIO_
io block as glsl code
static int numRegisteredModifiers_
registered shader modifier
QStringList tessControlLayout_
layout() directives scanned from loaded templates
bool outputArrays_
outputs of shader are arrays (tess-control)
void addTextureType(GLenum _type, bool _shadow, size_t _stage)
adds a texture type to the shader and enables texturing.
QString toString() const
convert ShaderGenDesc to string format for debugging
bool checkExtensionSupported(const std::string &_extension)
Definition: gl.cc:107
virtual void modifyFragmentBeginCode(QStringList *_code)
Append code the the fragment shader.
virtual void modifyVertexBeginCode(QStringList *_code)
Append code the the vertex shader.
QString outputPrefix_
prefix of outputs of this shader
bool normalizeTexColors
Defines if the textureVariable is normalized or not, if multiple textures are used.
virtual void modifyVertexEndCode(QStringList *_code)
Append code the the vertex shader.