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  * $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 
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  // optionally specify shader mod ids
158  std::vector<unsigned int> shaderMods;
159 
160  // preprocessor macros for the shaders
161  // these are added to all shaders directly after the #version directive
162  QStringList macros;
163 
165  QString toString() const;
166 
169 
172 
173  // color material for input vertex colors: GL_EMISSION, GL_AMBIENT, GL_DIFFUSE, GL_SPECULAR, GL_AMBIENT_AND_DIFFUSE
174  // Usage of vertex colors in lighting function, as diffuse, emission, ambient color .. see glColorMaterial()
175  // default: GL_AMBIENT_AND_DIFFUSE
176  GLenum colorMaterialMode;
177 
178  struct TextureType
179  {
180  GLenum type;
181  bool shadow;
182  };
183 private:
184  // 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
186  std::map<size_t,TextureType> textureTypes_;
187 
188 public:
189  const std::map<size_t,TextureType>& textureTypes() const {return textureTypes_;}
190 
194  void addTextureType(GLenum _type, bool _shadow, size_t _stage)
195  {
196  TextureType t;
197  t.type = _type;
198  t.shadow = _shadow;
199  textureTypes_[_stage] = t;
200  }
201 
203  void clearTextures(){textureTypes_.clear();}
204 
205  bool textured()const {return !textureTypes_.empty();}
206 
207 
208 
209  // automatic texture coordinate generation, emulation of glTexGen
210  // this takes priority over any texcoords provided via addTextureType
211 
212  // dimension of generated texture coordinate: 0,1,2,3,4 (default: 0 - disabled)
213  int texGenDim;
214 
215  // texture generation mode: GL_OBJECT_LINEAR, GL_EYE_LINEAR, GL_SPHERE_MAP, GL_NORMAL_MAP, GL_REFLECTION_MAP
216  GLenum texGenMode;
217 
218  // generate texture coordinates per vertex or fragment
219  // default: false -> per vertex
220  bool texGenPerFragment;
221 
222  void enableTexGenObjectLinear(int _dim = 2)
223  {
224  texGenDim = std::max(std::min(_dim, 4), 0);
225  texGenMode = GL_OBJECT_LINEAR;
226  }
227 
228  void enableTexGenEyeLinear(int _dim = 2)
229  {
230  texGenDim = std::max(std::min(_dim, 4), 0);
231  texGenMode = GL_EYE_LINEAR;
232  }
233 
234  void enableTexGenSphericalMap(int _dim = 2)
235  {
236  texGenDim = std::max(std::min(_dim, 2), 0);
237  texGenMode = GL_SPHERE_MAP;
238  }
239 
240  void enableTexGenNormalMap(int _dim = 3)
241  {
242  texGenDim = std::max(std::min(_dim, 3), 0);
243  texGenMode = GL_NORMAL_MAP;
244  }
245 
246  void enableTexGenReflectionMap(int _dim = 3)
247  {
248  texGenDim = std::max(std::min(_dim, 3), 0);
249  texGenMode = GL_REFLECTION_MAP;
250  }
251 
252  void disableTexGen() { texGenDim = 0; }
253 
254 
255  // comparison operator
256  bool operator == (const ShaderGenDesc& _rhs) const
257  {
258  if (numLights != _rhs.numLights)
259  return false;
260 
261  if (shadeMode != _rhs.shadeMode)
262  return false;
263 
264  if (vertexColors != _rhs.vertexColors)
265  return false;
266 
267  if (textured() != _rhs.textured())
268  return false;
269 
270  if (vertexColors)
271  {
272  if (vertexColorsInterpolator != _rhs.vertexColorsInterpolator)
273  return false;
274 
275  if (colorMaterialMode != _rhs.colorMaterialMode)
276  return false;
277  }
278 
279  if (fragmentTemplateFile != _rhs.fragmentTemplateFile)
280  return false;
281 
282  if (geometryTemplateFile != _rhs.geometryTemplateFile)
283  return false;
284 
285  if (vertexTemplateFile != _rhs.vertexTemplateFile)
286  return false;
287 
288  if (tessControlTemplateFile != _rhs.tessControlTemplateFile)
289  return false;
290 
291  if (tessEvaluationTemplateFile != _rhs.tessEvaluationTemplateFile)
292  return false;
293 
294  if (macros != _rhs.macros)
295  return false;
296 
297  if (texGenDim != _rhs.texGenDim)
298  return false;
299 
300  if (texGenDim)
301  {
302  if (texGenMode != _rhs.texGenMode)
303  return false;
304 
305  if (texGenPerFragment != _rhs.texGenPerFragment)
306  return false;
307  }
308 
309  if (shaderMods != _rhs.shaderMods)
310  return false;
311 
312  if (numLights)
313  return memcmp(lightTypes, _rhs.lightTypes, numLights * sizeof(ShaderGenLightType)) == 0;
314 
315  return true;
316  }
317 };
318 
319 
524 class ACGDLLEXPORT ShaderGenerator
525 {
526 public:
527 
528  ShaderGenerator();
529  virtual ~ShaderGenerator();
530 
531 
533  {
534  DefaultIODesc();
535 
537  bool inputTexCoord_, // texcoords
538  inputColor_, // vertex colors
539  inputNormal_; // view space normals
540 
542  bool passPosVS_, // view space position
543  passPosOS_, // object space position
544  passTexCoord_, // texcoords
545  passColor_, // vertex colors
546  passNormalVS_, // view space normals
547  passNormalOS_; // object space normals
548  };
549 
550 
553  void setGLSLVersion(int _version);
554 
557  void addIncludeFile(QString _fileName);
558 
561  void initVertexShaderIO(const ShaderGenDesc* _desc, const DefaultIODesc* _iodesc);
562 
565  void initTessControlShaderIO(const ShaderGenDesc* _desc, ShaderGenerator* _prevStage, const DefaultIODesc* _iodesc);
566 
569  void initTessEvalShaderIO(const ShaderGenDesc* _desc, ShaderGenerator* _prevStage, const DefaultIODesc* _iodesc);
570 
573  void initGeometryShaderIO(const ShaderGenDesc* _desc, ShaderGenerator* _prevStage, const DefaultIODesc* _iodesc);
574 
577  void initFragmentShaderIO(const ShaderGenDesc* _desc, ShaderGenerator* _prevStage, const DefaultIODesc* _iodesc);
578 
586  void initDefaultUniforms();
587 
596  void addInput(const QString& _input);
597 
606  void addInput(const QString& _type, const QString& _varname) { addInput(_type + QString(" ") + _varname); }
607 
616  void addOutput(const QString& _output);
617 
626  void addOutput(const QString& _type, const QString& _varname) { addOutput(_type + QString(" ") + _varname); }
627 
628 
637  void addUniform(QString _uniform, QString _comment = "");
638 
646  void addDefine(const QString& _define);
647 
651  void addIODefine(const QString& _macroName, const QString& _resolvedName);
652 
656  void addMacros(const QStringList& _macros);
657 
665  bool hasDefine(QString _define) const;
666 
674  void addLayout(QString _layout);
675 
676 
691  void addRawIOBlock(QStringList _codeBlock) {rawIO_.append(_codeBlock);}
692 
695  void addLight(int lightIndex_, ShaderGenLightType _light);
696 
702  void buildShaderCode(QStringList* _pMainCode, const QStringList& _defaultLightingFunctions);
703 
706  const QStringList& getShaderCode();
707 
712  void saveToFile(const char* _fileName);
713 
714 
727  void matchInputs(const ShaderGenerator* _previousShaderStage, bool _passToNextStage, QString _inputPrefix = "outVertex", QString _outputPrefix = "outGeometry");
728 
739  void defineIOAbstraction(const DefaultIODesc* _iodesc, bool _vs, bool _fs);
740 
743  int getNumOutputs() const;
744 
749  QString getOutputName(int _id) const;
750 
753  int getNumInputs() const;
754 
759  QString getInputName(int _id) const;
760 
766  QString getIOMapName(int _inId) const;
767 
768 
769 public:
770 
771  struct Keywords
772  {
773  Keywords();
774 
775  // preprocessor macros that can be defined
776 
777  // request vertex attributes that should be available in all shader stages:
778  QString macro_requestPosVS, // view space position
779  macro_requestPosOS, // object space position
780  macro_requestTexcoord, // mesh texture coordinate
781  macro_requestVertexColor, // vertex color
782  macro_requestNormalVS, // view space normal
783  macro_requestNormalOS, // object space normal
784 
785  macro_requestRenormalize; // normal should be renormalized before using it for lighting
786 
787  // input / output abstraction macros
788  QString macro_inputPosVS,
789  macro_inputPosOS,
790  macro_inputPosCS,
791  macro_inputNormalVS,
792  macro_inputNormalOS,
793  macro_inputTexcoord,
794  macro_inputVertexColor,
795 
796  macro_outputPosVS,
797  macro_outputPosOS,
798  macro_outputPosCS,
799  macro_outputNormalVS,
800  macro_outputNormalOS,
801  macro_outputTexcoord,
802  macro_outputVertexColor;
803 
804  // default input/output variable names without prefixes
805  QString ioPosCS,
806  ioPosOS,
807  ioPosVS,
808  ioNormalVS,
809  ioNormalOS,
810  ioTexcoord,
811  ioColor;
812 
813  // input/output prefix at each shader stage
814  QString vs_inputPrefix,
815  vs_outputPrefix,
816  tcs_outputPrefix,
817  tes_outputPrefix,
818  gs_outputPrefix,
819  fs_outputPrefix;
820 
821  // actual input/output of vertex shader
822  QString vs_inputPosition,
823  vs_inputNormal,
824  vs_inputTexCoord,
825  vs_inputColor,
826  vs_outputPosCS,
827  vs_outputPosVS,
828  vs_outputPosOS,
829  vs_outputTexCoord,
830  vs_outputNormalVS,
831  vs_outputNormalOS,
832  vs_outputVertexColor,
833  fs_outputFragmentColor;
834  };
835 
836  static const Keywords keywords;
837 
838 private:
839 
844  void addStringToList(QString _str, QStringList* _list, QString _prefix = "", QString _postfix = "");
845 
849  void addIOToCode(const QStringList& _cmds);
850 
851  QStringList code_;
852 
853 
855  QStringList imports_;
856 
857  int version_;
858 
859  QStringList inputs_;
860  QStringList outputs_;
861  QStringList uniforms_;
862  QStringList genDefines_;
863  QStringList layouts_;
864 
866  QStringList rawIO_;
867 
870 
873 
875  QString inputPrefix_;
876 
878  QString outputPrefix_;
879 };
880 
881 
882 
938 class ACGDLLEXPORT ShaderModifier
939 {
940  friend class ShaderProgGenerator;
941 
942 public:
943  ShaderModifier(void);
944  virtual ~ShaderModifier(void);
945 
957  virtual void modifyVertexIO(ShaderGenerator* _shader) {}
958 
971  virtual void modifyVertexBeginCode(QStringList* _code) {}
972 
986  virtual void modifyVertexEndCode(QStringList* _code) {}
987 
999  virtual void modifyGeometryIO(ShaderGenerator* _shader) {}
1000 
1012  virtual void modifyTessControlIO(ShaderGenerator* _shader) {}
1013 
1025  virtual void modifyTessEvalIO(ShaderGenerator* _shader) {}
1026 
1038  virtual void modifyFragmentIO(ShaderGenerator* _shader) {}
1039 
1054  virtual void modifyFragmentBeginCode(QStringList* _code) {}
1055 
1070  virtual void modifyFragmentEndCode(QStringList* _code) {}
1071 
1089  virtual void modifyLightingCode(QStringList* _code, int _lightId, ShaderGenLightType _lightType) {}
1090 
1095  virtual bool replaceDefaultLightingCode() {return false;}
1096 
1101  unsigned int getID() {return modifierID_;}
1102 
1103 
1136  static ShaderModifier* loadFromFile(QString _filename);
1137 
1138 
1139 // operator unsigned int() const {return modifierID_;}
1140  operator std::vector<unsigned int>() const {return std::vector<unsigned int>(1,modifierID_);}
1141 
1142  std::vector<unsigned int> operator | (const std::vector<unsigned int>& _v) const
1143  {
1144  std::vector<unsigned int> r(1 + _v.size(), modifierID_);
1145  for (size_t i = 0; i < _v.size(); ++i)
1146  r[i + 1] = _v[i];
1147  return r;
1148  }
1149 
1150 private:
1151  unsigned int modifierID_;
1152 };
1153 
1154 
1158 class ACGDLLEXPORT ShaderProgGenerator
1159 {
1160 public:
1161 
1166  static void setShaderDir(QString _dir);
1167 
1171  static QString getShaderDir();
1172 
1176  ShaderProgGenerator(const ShaderGenDesc* _desc);
1177 
1182  ShaderProgGenerator(const ShaderGenDesc* _desc, const std::vector<unsigned int>& _modifierIDs);
1183 
1188  ShaderProgGenerator(const ShaderGenDesc* _desc, const std::vector<unsigned int>* _modifierIDs);
1189 
1195  ShaderProgGenerator(const ShaderGenDesc* _desc, const unsigned int* _modifierIDs, unsigned int _numModifiers);
1196 
1202  ShaderProgGenerator(const ShaderGenDesc* _desc, ShaderModifier* const* _modifiers, unsigned int _numModifiers);
1203 
1208  ShaderProgGenerator(const ShaderGenDesc* _desc, const std::vector<ShaderModifier*>& _modifiers);
1209 
1214  ShaderProgGenerator(const ShaderGenDesc* _desc, const std::vector<ShaderModifier*>* _modifiers);
1215 
1216  virtual ~ShaderProgGenerator(void);
1217 
1218 
1219  void saveVertexShToFile(const char* _fileName);
1220  void saveGeometryShToFile(const char* _fileName);
1221  void saveFragmentShToFile(const char* _fileName);
1222 
1225  const QStringList& getVertexShaderCode();
1226 
1229  const QStringList& getTessControlShaderCode();
1230 
1233  const QStringList& getTessEvaluationShaderCode();
1234 
1237  const QStringList& getGeometryShaderCode();
1238 
1241  const QStringList& getFragmentShaderCode();
1242 
1243 
1246  int getNumActiveModifiers() const;
1247 
1250  ShaderModifier* getActiveModifier(int _i);
1251 
1252 
1259  static unsigned int registerModifier(ShaderModifier* _modifier);
1260 
1263  bool hasGeometryShader() const;
1264 
1267  bool hasTessControlShader() const;
1268 
1271  bool hasTessEvaluationShader() const;
1272 
1275  void generateShaders();
1276 
1282  static bool loadStringListFromFile(QString _fileName, QStringList* _out);
1283 
1287  static QString getAbsFilePath(QString _fileName);
1288 
1289 private:
1290 
1293  void loadShaderTemplateFromFile();
1294 
1297  void scanShaderTemplate(QStringList& _templateSrc, QString _templateFilename, QStringList* _outLayoutDirectives = 0);
1298 
1301  void init(const ShaderGenDesc* _desc, ShaderModifier* const* _modifiers, unsigned int _numActiveMods);
1302  void init(const ShaderGenDesc* _desc, const unsigned int* _modifiers, unsigned int _numActiveMods);
1303 
1304  void buildVertexShader();
1305  void buildTessControlShader();
1306  void buildTessEvalShader();
1307  void buildGeometryShader();
1308  void buildFragmentShader();
1309 
1310  void addVertexBeginCode(QStringList* _code);
1311  void addVertexEndCode(QStringList* _code);
1312 
1313  void addFragmentBeginCode(QStringList* _code);
1314  void addFragmentEndCode(QStringList* _code);
1315 
1320  void addLightingFunctions(QStringList* _code);
1321 
1324  void addLightingCode(QStringList* _code);
1325 
1328  void modifyLightingCode(QStringList* _code, ShaderModifier* _modifier);
1329 
1332  void addTexGenCode(QStringList* _code, bool _fragmentShader);
1333 
1335  static QString getPathName(QString _strFileName);
1336 
1339  int checkForIncludes(QString _str, ShaderGenerator* _gen, QString _includePath);
1340 
1343  int checkForIncludes(QString _str, QStringList* _outImport, QString _includePath);
1344 
1345 
1347  void initGenDefines(ShaderGenerator* _gen);
1348 
1349  static void loadLightingFunctions();
1350 
1351  ShaderGenerator* vertex_;
1352  ShaderGenerator* tessControl_;
1353  ShaderGenerator* tessEval_;
1354  ShaderGenerator* geometry_;
1355  ShaderGenerator* fragment_;
1356 
1357  QStringList vertexTemplate_;
1358  QStringList tessControlTemplate_;
1359  QStringList tessEvalTemplate_;
1360  QStringList geometryTemplate_;
1361  QStringList fragmentTemplate_;
1362 
1363  ShaderGenDesc desc_;
1364  std::vector<ShaderModifier*> activeMods_;
1365 
1366 
1369  static std::vector<ShaderModifier*> registeredModifiers_;
1370 
1373  QString tessControlShaderFile_;
1374  QString tessEvalShaderFile_;
1375  QString geometryShaderFile_;
1376  QString fragmentShaderFile_;
1377 
1379  QStringList tessControlLayout_;
1380  QStringList tessEvalLayout_;
1381 
1382 
1385 
1388 
1389 
1390  static QString shaderDir_;
1391  static QStringList lightingCode_;
1392 
1393 
1394 };
1395 
1396 
1397 //=============================================================================
1398 } // namespace ACG
1399 //=============================================================================
QString vertexColorsInterpolator
interpolation qualifier for input vertex colors: "flat", "smooth", "noperspective" ...
bool inputTexCoord_
default attributes that should be imported in vertex shader
void clearTextures()
disables texture support and removes all texture types
QString vertexShaderFile_
path + filename to shader templates
QString toString() const
convert ShaderGenDesc to string format for debugging
virtual void modifyLightingCode(QStringList *_code, int _lightId, ShaderGenLightType _lightType)
Modify the default lighting code of the shader generator.
void addOutput(const QString &_type, const QString &_varname)
Add one GLSL output specifier.
virtual void modifyFragmentEndCode(QStringList *_code)
Append code the the fragment shader.
QStringList rawIO_
io block as glsl code
void addInput(const QString &_type, const QString &_varname)
Add one GLSL input specifier.
virtual void modifyVertexBeginCode(QStringList *_code)
Append code the the vertex shader.
virtual void modifyVertexEndCode(QStringList *_code)
Append code the the vertex shader.
void addTextureType(GLenum _type, bool _shadow, size_t _stage)
adds a texture type to the shader and enables texturing.
virtual void modifyTessEvalIO(ShaderGenerator *_shader)
Add your own inputs/outputs to the tessellation evaluation shader.
bool renormalizeLighting_
renormalize before lighting, default false, can be activated via "#define SG_REQUEST_RENORMALIZE" ...
void addRawIOBlock(QStringList _codeBlock)
Add a raw glsl IO code block.
bool inputArrays_
inputs of shader are arrays (tess-control, tess-eval, geometry)
QString outputPrefix_
prefix of outputs of this shader
QStringList imports_
glsl code imports (with #include )
QString inputPrefix_
prefix of inputs to this shader, same as prefix of ouputs of previous stage
bool normalizeTexColors
Defines if the textureVariable is normalized or not, if multiple textures are used.
static int numRegisteredModifiers_
registered shader modifier
Namespace providing different geometric functions concerning angles.
Definition: DBSCANT.cc:51
virtual void modifyFragmentBeginCode(QStringList *_code)
Append code the the fragment shader.
bool passPosVS_
default attributes that should be passed down from vertex shader
virtual void modifyTessControlIO(ShaderGenerator *_shader)
Add your own inputs/outputs to the tessellation control shader.
virtual void modifyVertexIO(ShaderGenerator *_shader)
Add your own inputs/outputs to the vertex shader.
virtual void modifyFragmentIO(ShaderGenerator *_shader)
Add your own inputs/outputs to the fragment shader.
std::map< size_t, TextureType > textureTypes_
holds the texture types (second) and the stage id (first). if empty, shader does not support textures...
bool outputArrays_
outputs of shader are arrays (tess-control)
virtual void modifyGeometryIO(ShaderGenerator *_shader)
Add your own inputs/outputs to the geometry shader.
ShaderGenerator::DefaultIODesc ioDesc_
default IO descriptor for the vertex shader
virtual bool replaceDefaultLightingCode()
Specify whether this modifier replaces or extends the default lighting code.
unsigned int getID()
Returns the modifier ID.
QStringList tessControlLayout_
layout() directives scanned from loaded templates