44#include "ClassicDepthPeeling.hh"
46#include <ObjectTypes/Light/LightNode.hh>
48#include <ACG/GL/GLError.hh>
55DepthPeelingPlugin::DepthPeelingPlugin() :
61 for (
unsigned int i = 0; i < 16; ++i)
62 lightTypes_[i] = LIGHTTYPE_POINT;
64 for (
unsigned int i = 0; i < PEEL_NUM_COMBINATIONS; ++i)
67 for (
unsigned int i = 0; i < PEEL_NUM_COMBINATIONS*3; ++i)
70 for (
unsigned int i = 0; i < 8; ++i)
73 for (
unsigned int i = 0; i < 4; ++i)
74 blendDualPeelProg_[i] = 0;
76 for (
unsigned int i = 0; i < 16; ++i)
82DepthPeelingPlugin::~DepthPeelingPlugin() {
87DepthPeelingPlugin::ViewerResources::ViewerResources()
98void DepthPeelingPlugin::initializePlugin()
114void DepthPeelingPlugin::exit()
121QString DepthPeelingPlugin::rendererName() {
122 return QString(
"Classical Depth Peeling Renderer");
144 glVertex2f(x0, y0-h);
145 glVertex2f(x0+w, y0-h);
146 glVertex2f(x0+w, y0);
175 if (lightID != GL_INVALID_ENUM)
177 int id = lightID - GL_LIGHT0;
183 else if (light.spotCutoff() > 179.5f)
223 GLSL::StringList* _strFragmentShaderOut,
224 GLSL::StringList* _strGeometryShaderOut,
231 if (_flatShaded) _phong =
false;
232 if (_vertexColor) _phong =
false;
234 std::string strColor =
"color";
235 std::string strNormal =
"normal";
236 std::string strFragPos =
"vPosVS";
239 strFragPos =
"VPosVS";
242 _flatShaded = _vertexColor = _textured = _phong =
false;
244 std::string strCode =
"";
246 for (
unsigned int i = 0; i <
numLights_ && (!_wireFrame); ++i)
251 std::string strLight =
"gl_LightSource[";
252 std::string strMaterial =
"gl_FrontLightProduct[";
258 strMaterial += szTmp;
263 strCode +=
"vec3 vLightVS = " + strLight +
".position.xyz;\n";
265 strCode +=
"vec3 vLightVS = " + strLight +
".position.xyz - " + strFragPos +
".xyz;\n";
267 strCode +=
"vec3 vLightDir = normalize(vLightVS);\n";
270 strCode +=
"vec4 colLight = " + strMaterial +
".ambient;\n";
273 strCode +=
"float ldotn = dot(vLightDir, " + strNormal +
");\n";
274 strCode +=
"ldotn = clamp(ldotn, 0.0, 1.0);\n";
275 strCode +=
"colLight += ldotn * ";
276 if (_textured && _phong)
277 strCode +=
"diffColor * ";
282 strCode +=
"vColor[2];\n";
284 strCode +=
"gl_Color;\n";
287 strCode += strMaterial +
".diffuse;\n";
290 strCode +=
"colLight += floor(ldotn + 0.9) * pow(ldotn, gl_FrontMaterial.shininess) * " + strMaterial +
".specular;\n";
294 strCode += strColor +
".rgb += colLight.rgb;\n";
298 strCode +=
"float fLenSq = dot(vLightVS, vLightVS);\n";
299 strCode +=
"float atten = " + strLight +
".constantAttenuation + " +
300 strLight +
".linearAttenuation * sqrt(fLenSq) + " +
301 strLight +
".quadraticAttenuation * fLenSq;\n";
304 strCode += strColor +
".rgb += colLight.rgb / atten;\n";
308 strCode +=
"float spot = -dot(vLightDir, " + strLight +
".spotDirection);\n";
309 strCode +=
"spot *= step(" + strLight +
".spotCosCutoff, spot);\n";
310 strCode +=
"spot *= pow(spot, " + strLight +
".spotExponent);\n";
312 strCode += strColor +
".rgb += " +
"(spot / atten) * colLight.rgb;\n";
319 const char* szVertexShader[] = {
"varying vec2 vTexCoord;",
320 "varying vec3 vNormal; // normal: view space",
321 "varying vec4 vPosVS; // position in view space",
322 "varying vec4 vColor; // used in gouraud / flat shading only",
326 " gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;",
328 " vNormal = gl_NormalMatrix * gl_Normal; // gl_NormalMatrix : upper left 3x3 of WorldViewIT",
329 " vPosVS = (gl_ModelViewMatrix * gl_Vertex);",
330 " vTexCoord = gl_MultiTexCoord0.xy;",
335 const char* szGeometryShaderStart[] = {
337 "#extension GL_ARB_geometry_shader4 : enable",
339 "varying vec2 vTexCoord[3];",
340 "varying vec4 vPosVS[3];",
341 "varying vec3 vNormal[3];",
342 "varying vec4 vColor[3];",
344 "varying vec2 VTexCoord;",
345 "varying vec3 VNormal;",
346 "varying vec4 VPosVS;",
347 "varying vec4 VColor;",
352 " // recompute triangle normal",
354 " vec3 normal = cross(gl_PositionIn[1].xyz - gl_PositionIn[0].xyz, gl_PositionIn[2].xyz - gl_PositionIn[0].xyz);",
355 " normal = normalize(normal);",
356 " normal = gl_NormalMatrix * normal;",
359 " VPosVS = (gl_PositionIn[0] + gl_PositionIn[1] + gl_PositionIn[2]) / 3.0;",
360 " VPosVS = gl_ModelViewMatrix * VPosVS; // triangle center in view space needed for point and spot lights",
361 " vec4 color = vec4(gl_FrontMaterial.emission.rgb, gl_FrontMaterial.diffuse.a);",
364 const char* szGeometryShaderEnd[] = {
366 " for(int i = 0; i < 3; i++)",
368 " gl_Position = gl_ModelViewProjectionMatrix * gl_PositionIn[i];",
369 " VTexCoord = vTexCoord[i];",
370 " VNormal = normal;",
371 " VPosVS = vPosVS[i];",
380 const char* szFragmentShaderStart[] = {
"varying vec2 vTexCoord;",
381 "varying vec3 vNormal; ",
382 "varying vec4 vPosVS;",
383 "varying vec4 vColor;",
385 "uniform sampler2D DiffuseTex;",
386 "uniform sampler2DRect DepthBlenderTex;",
387 "uniform sampler2DRect FrontBlenderTex;",
389 "#define MAX_DEPTH 1.0",
394 " // window-space depth interpolated linearly in screen space",
395 " float fragDepth = gl_FragCoord.z;",
397 " vec2 depthBlender = texture2DRect(DepthBlenderTex, gl_FragCoord.xy).xy;",
398 " vec4 forwardTemp = texture2DRect(FrontBlenderTex, gl_FragCoord.xy);",
400 " // Depths and 1.0-alphaMult always increase",
401 " // so we can use pass-through by default with MAX blending",
402 " gl_FragData[0].xy = depthBlender;",
404 " // Front colors always increase (DST += SRC*ALPHA_MULT)",
405 " // so we can use pass-through by default with MAX blending",
406 " gl_FragData[1] = forwardTemp;",
408 " // Because over blending makes color increase or decrease,",
409 " // we cannot pass-through by default.",
410 " // Each pass, only one fragment writes a color greater than 0",
411 " gl_FragData[2] = vec4(0.0);",
413 " float nearestDepth = -depthBlender.x;",
414 " float farthestDepth = depthBlender.y;",
415 " float alphaMultiplier = 1.0 - forwardTemp.w;",
417 " if (fragDepth < nearestDepth || fragDepth > farthestDepth) {",
418 " // Skip this depth in the peeling algorithm",
419 " gl_FragData[0].xy = vec2(-MAX_DEPTH);",
423 " if (fragDepth > nearestDepth && fragDepth < farthestDepth) {",
424 " // This fragment needs to be peeled again",
425 " gl_FragData[0].xy = vec2(-fragDepth, fragDepth);",
429 " // If we made it here, this fragment is on the peeled layer from last pass",
430 " // therefore, we need to shade it, and make sure it is not peeled any farther",
433 const char* szFragmentShaderEnd[] = {
"",
434 " gl_FragData[0].xy = vec2(-MAX_DEPTH);",
436 " if (fragDepth == nearestDepth) {",
437 " gl_FragData[1].xyz += color.rgb * color.a * alphaMultiplier;",
438 " gl_FragData[1].w = 1.0 - alphaMultiplier * (1.0 - color.a);",
440 " gl_FragData[2] += color;",
447 for (
unsigned int i = 0; i <
sizeof(szVertexShader) /
sizeof(
char*); ++i)
449 std::string str = szVertexShader[i];
452 if (!strncmp(
"varying vec4 vColor", str.c_str(), strlen(
"varying vec4 vColor")))
460 _strVertexShaderOut->push_back(str);
464 if (!_phong && !_flatShaded && !_wireFrame)
467 _strVertexShaderOut->push_back(
"\nvec4 color = vec4(gl_FrontMaterial.emission.rgb, gl_FrontMaterial.diffuse.a);");
468 _strVertexShaderOut->push_back(
"\nvec3 normal = vNormal;\n");
470 std::string::size_type curPos = 0;
471 std::string::size_type newLinePos = strCode.find_first_of(
'\n');
472 while (newLinePos != std::string::npos)
474 _strVertexShaderOut->push_back(strCode.substr(curPos, newLinePos - curPos + 1));
475 curPos = newLinePos + 1;
476 newLinePos = strCode.find_first_of(
'\n', curPos);
478 _strVertexShaderOut->push_back(
"\nvColor = color;\n");
483 _strVertexShaderOut->push_back(
"vColor = gl_Color;\n");
484 _strVertexShaderOut->push_back(
"gl_Position = gl_Vertex;\n");
487 _strVertexShaderOut->push_back(
"\n}");
490 for (
unsigned int i = 0; i <
sizeof(szFragmentShaderStart) /
sizeof(
char*); ++i)
492 std::string str = szFragmentShaderStart[i];
495 if (!strncmp(
"varying vec4 vColor", str.c_str(), strlen(
"varying vec4 vColor")))
504 if (!strncmp(
"varying vec2 vTexCoord", str.c_str(), strlen(
"varying vec2 vTexCoord")))
505 str =
"varying vec2 VTexCoord;";
506 if (!strncmp(
"varying vec3 vNormal", str.c_str(), strlen(
"varying vec3 vNormal")))
507 str =
"varying vec3 VNormal;";
508 if (!strncmp(
"varying vec4 vPosVS", str.c_str(), strlen(
"varying vec4 vPosVS")))
509 str =
"varying vec4 VPosVS;";
510 if (!strncmp(
"varying vec4 vColor", str.c_str(), strlen(
"varying vec4 vColor")))
511 str =
"varying vec4 VColor;";
514 _strFragmentShaderOut->push_back(str);
521 _strFragmentShaderOut->push_back(
" vec3 normal = normalize(vNormal);\n");
523 _strFragmentShaderOut->push_back(
" vec4 color = vec4(gl_FrontMaterial.emission.rgb, gl_FrontMaterial.diffuse.a);\n");
525 _strFragmentShaderOut->push_back(
" vec4 diffColor = texture2D(DiffuseTex, vTexCoord); color.a *= diffColor.a;\n");
529 _strFragmentShaderOut->push_back(
" vec4 color = vec4(gl_FrontMaterial.emission.rgb, gl_FrontMaterial.diffuse.a);\n");
530 _strFragmentShaderOut->push_back(
" vec4 vColor = VColor;\n");
532 _strFragmentShaderOut->push_back(
" vec4 diffColor = texture2D(DiffuseTex, VTexCoord); color.a *= diffColor.a;\n");
538 _strFragmentShaderOut->push_back(
" color = diffColor * vColor;\n");
540 _strFragmentShaderOut->push_back(
" color = vColor;\n");
545 std::string::size_type curPos = 0;
546 std::string::size_type newLinePos = strCode.find_first_of(
'\n');
547 while (newLinePos != std::string::npos)
549 _strFragmentShaderOut->push_back(strCode.substr(curPos, newLinePos - curPos + 1));
550 curPos = newLinePos + 1;
551 newLinePos = strCode.find_first_of(
'\n', curPos);
556 _strFragmentShaderOut->push_back(
" vec4 color = vColor;\n");
558 for (
unsigned int i = 0; i <
sizeof(szFragmentShaderEnd) /
sizeof(
char*); ++i)
560 std::string str = szFragmentShaderEnd[i];
562 _strFragmentShaderOut->push_back(str);
569 for (
unsigned int i = 0; i <
sizeof(szGeometryShaderStart) /
sizeof(
char*); ++i)
571 std::string str = szGeometryShaderStart[i];
573 _strGeometryShaderOut->push_back(str);
577 std::string::size_type curPos = 0;
578 std::string::size_type newLinePos = strCode.find_first_of(
'\n');
579 while (newLinePos != std::string::npos)
581 _strGeometryShaderOut->push_back(strCode.substr(curPos, newLinePos - curPos + 1));
582 curPos = newLinePos + 1;
583 newLinePos = strCode.find_first_of(
'\n', curPos);
586 for (
unsigned int i = 0; i <
sizeof(szGeometryShaderEnd) /
sizeof(
char*); ++i)
588 std::string str = szGeometryShaderEnd[i];
590 _strGeometryShaderOut->push_back(str);
596#ifdef DEPTHPEELING_SHADER_EXPORT
597 FILE* pShaderOut = fopen(
"peel_vertex.glsl",
"wt");
598 for (GLSL::StringList::iterator it = _strVertexShaderOut->begin(); it != _strVertexShaderOut->end(); ++it)
599 fprintf(pShaderOut, it->c_str());
603 pShaderOut = fopen(
"peel_frag.glsl",
"wt");
604 for (GLSL::StringList::iterator it = _strFragmentShaderOut->begin(); it != _strFragmentShaderOut->end(); ++it)
605 fprintf(pShaderOut, it->c_str());
610 pShaderOut = fopen(
"peel_geom.glsl",
"wt");
611 for (GLSL::StringList::iterator it = _strGeometryShaderOut->begin(); it != _strGeometryShaderOut->end(); ++it)
612 fprintf(pShaderOut, it->c_str());
620template <
class Action>
633 dm = _globalDrawMode;
648 dmShaded &=
~ACG::SceneGraph::DrawModes::WIREFRAME;
649 dmShaded &=
~ACG::SceneGraph::DrawModes::HIDDENLINE;
655 ret &= traverseDrawApplyAction(_node, _action, _globalDrawMode, _pass, _peelPass);
684 ret &= _action(_node);
694 ACG::GLState::lockDepthFunc();
697 shaderIndex = PEEL_SHADER_WIREFRAME;
705 if (shaderIndex & PEEL_SHADER_FLAT)
715 ret &= _action(_node);
723 ACG::GLState::unlockDepthFunc();
734template <
class Action>
750 if_has_enter(_action, _node);
757 process_children &= traverseDrawApplyAction(_node, _action, _globalDrawMode, _pass, _peelPass);
759 if (process_children) {
766 traverseDraw(*cIt, _action, _globalDrawMode, _pass, _peelPass);
771 traverseDraw(*cIt, _action, _globalDrawMode, _pass, _peelPass);
780 traverseDrawApplyAction(_node, _action, _globalDrawMode, _pass, _peelPass);
784 if_has_leave(_action, _node);
802 for(
unsigned int pass = BaseNode::PASS_1; pass <= (BaseNode::PASS_1 + max_passes); ++pass) {
805 traverseDraw (_sceneGraphRoot, action, _drawMode, pass, _peelPass);
819 traverse_multipass(_sceneGraphRoot, action, *_glState, _drawMode);
826 bool rebuildShaders =
false;
833 unsigned int prevIDs[8];
848 rebuildShaders =
true;
850 else rebuildShaders =
true;
865 for (
unsigned int i = 0; i < PEEL_NUM_COMBINATIONS; ++i)
867 GLuint texturedDrawMode = 0, flatDrawMode = 0, phongDrawMode = 0, vertexColorDrawMode = 0, gouraudDrawMode = 0;
869 texturedDrawMode = i & PEEL_SHADER_TEXTURED;
870 flatDrawMode = i & PEEL_SHADER_FLAT;
871 phongDrawMode = i & PEEL_SHADER_PHONG;
872 vertexColorDrawMode = i & PEEL_SHADER_VERTEXCOLORS;
873 gouraudDrawMode = i & PEEL_SHADER_GOURAUD;
875 if (i != PEEL_SHADER_WIREFRAME)
878 if (flatDrawMode && phongDrawMode)
continue;
879 if (flatDrawMode && gouraudDrawMode)
continue;
880 if (phongDrawMode && gouraudDrawMode)
continue;
882 if (phongDrawMode + flatDrawMode + gouraudDrawMode == 0)
continue;
895 GLSL::StringList strVertexShader, strFragmentShader, strGeometryShader;
896 generatePeelingShaders(&strVertexShader, &strFragmentShader, &strGeometryShader, texturedDrawMode != 0, flatDrawMode != 0, phongDrawMode != 0, vertexColorDrawMode != 0, i == PEEL_SHADER_WIREFRAME);
926#ifdef DEPTHPEELING_SHADER_EXPORT
927 char szFileName[256];
928 sprintf(szFileName,
"peel_vertex_%02u.glsl", i);
929 FILE* pShaderOut = fopen(szFileName,
"wt");
930 for (GLSL::StringList::iterator it = strVertexShader.begin(); it != strVertexShader.end(); ++it)
931 fprintf(pShaderOut, it->c_str());
935 sprintf(szFileName,
"peel_frag%02u.glsl", i);
936 pShaderOut = fopen(szFileName,
"wt");
937 for (GLSL::StringList::iterator it = strFragmentShader.begin(); it != strFragmentShader.end(); ++it)
938 fprintf(pShaderOut, it->c_str());
943 sprintf(szFileName,
"peel_geom%02u.glsl", i);
944 pShaderOut = fopen(szFileName,
"wt");
945 for (GLSL::StringList::iterator it = strGeometryShader.begin(); it != strGeometryShader.end(); ++it)
946 fprintf(pShaderOut, it->c_str());
958 const char* szVertexShader[] = {
961 " gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;",
964 const char* szFragmentShader[] = {
965 "uniform vec4 ObjectColor;",
966 "uniform sampler2DRect DepthBlenderTex;",
967 "uniform sampler2DRect FrontBlenderTex;",
969 "#define MAX_DEPTH 1.0",
974 " // window-space depth interpolated linearly in screen space",
975 " float fragDepth = gl_FragCoord.z;",
977 " vec2 depthBlender = texture2DRect(DepthBlenderTex, gl_FragCoord.xy).xy;",
978 " vec4 forwardTemp = texture2DRect(FrontBlenderTex, gl_FragCoord.xy);",
980 " // Depths and 1.0-alphaMult always increase",
981 " // so we can use pass-through by default with MAX blending",
982 " gl_FragData[0].xy = depthBlender;",
984 " // Front colors always increase (DST += SRC*ALPHA_MULT)",
985 " // so we can use pass-through by default with MAX blending",
986 " gl_FragData[1] = forwardTemp;",
988 " // Because over blending makes color increase or decrease,",
989 " // we cannot pass-through by default.",
990 " // Each pass, only one fragment writes a color greater than 0",
991 " gl_FragData[2] = vec4(0.0);",
993 " float nearestDepth = -depthBlender.x;",
994 " float farthestDepth = depthBlender.y;",
995 " float alphaMultiplier = 1.0 - forwardTemp.w;",
997 " if (fragDepth < nearestDepth || fragDepth > farthestDepth) {",
998 " // Skip this depth in the peeling algorithm",
999 " gl_FragData[0].xy = vec2(-MAX_DEPTH);",
1003 " if (fragDepth > nearestDepth && fragDepth < farthestDepth) {",
1004 " // This fragment needs to be peeled again",
1005 " gl_FragData[0].xy = vec2(-fragDepth, fragDepth);",
1009 " // If we made it here, this fragment is on the peeled layer from last pass",
1010 " // therefore, we need to shade it, and make sure it is not peeled any farther",
1011 " vec4 color = ObjectColor;",
1012 " gl_FragData[0].xy = vec2(-MAX_DEPTH);",
1014 " if (fragDepth == nearestDepth) {",
1015 " gl_FragData[1].xyz += color.rgb * color.a * alphaMultiplier;",
1016 " gl_FragData[1].w = 1.0 - alphaMultiplier * (1.0 - color.a);",
1018 " gl_FragData[2] += color;",
1022 GLSL::StringList strVertexShader, strFragmentShader;
1023 for (
unsigned int i = 0; i <
sizeof(szVertexShader) /
sizeof(
char*); ++i)
1025 std::string str = szVertexShader[i];
1027 strVertexShader.push_back(str);
1030 for (
unsigned int i = 0; i <
sizeof(szFragmentShader) /
sizeof(
char*); ++i)
1032 std::string str = szFragmentShader[i];
1034 strFragmentShader.push_back(str);
1042 peelShaders_[PEEL_SHADER_HIDDENLINE*3 + 0] = pVertexSh;
1043 peelHiddenLine->
attach(pVertexSh);
1049 peelHiddenLine->
attach(pFragSh);
1051 peelHiddenLine->
link();
1061 return PEEL_SHADER_WIREFRAME;
1072 if (phong && flat) flat =
false;
1073 if (flat && gouraud) gouraud =
false;
1074 if (gouraud && phong) phong =
false;
1077 if ((!phong) && (!gouraud) && (!flat)) gouraud =
true;
1079 unsigned int idx = 0;
1081 if (flat) idx |= PEEL_SHADER_FLAT;
1082 if (gouraud) idx |= PEEL_SHADER_GOURAUD;
1083 if (phong) idx |= PEEL_SHADER_PHONG;
1084 if (vertexColor) idx |= PEEL_SHADER_VERTEXCOLORS;
1085 if (textured) idx |= PEEL_SHADER_TEXTURED;
1090QString DepthPeelingPlugin::checkOpenGL() {
1092 return QString(
"Classic depth peeling Rendering-plugin is not compatible with core contexts.");
1094 return QString(
"Insufficient OpenGL Version! OpenGL 2.0 or higher required");
1097 QString missing =
"";
1100 missing +=
"Missing Extension GL_ARB_geometry_shader4\n";
1103 missing +=
"Missing Extension GL_ARB_vertex_program\n";
static void lockProgram()
lock the program
static void lockDepthRange()
lock depth range
unsigned int max_render_passes() const
get maximum number of render passes
static void depthRange(GLclampd _zNear, GLclampd _zFar)
replaces glDepthRange, supports locking
static void unlockDepthRange()
unlock depth range
const Vec4f & clear_color() const
get background color
static void unlockProgram()
unlock the program
void reset_render_pass()
reset render pass counter
const GLenum & depthFunc() const
get glDepthFunc() that is supposed to be active
void next_render_pass()
increment render pass counter
ChildIter childrenBegin()
Returns: begin-iterator of children.
ChildIter childrenEnd()
Returns: end-iterator of children.
DrawModes::DrawMode drawMode() const
Return the own draw modes of this node.
unsigned int traverseMode() const
Return how the node should be traversed.
bool multipassStatusActive(const unsigned int _i) const
Get multipass status to traverse in a specific pass.
@ HideNode
Hide this node, but draw children.
@ HideChildren
Draw this node, but hide children.
@ HideSubtree
Hide this node and its children.
@ ChildrenFirst
Execute action the children first and then on this node.
@ NodeFirst
Execute action on node first and then on its children.
@ SecondPass
Draw node in second pass.
bool multipassNodeActive(const unsigned int _i) const
Get Node status to traverse in a specific pass.
std::vector< BaseNode * >::iterator ChildIter
allows to iterate over children
StatusMode status() const
Get node's status.
void getLightSource(LightSource *_light) const
Get the light source parameters.
Structure to hold options for one LightSource.
bool directional() const
Check if the light source is a directional light source.
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
GLSL::Shader * peelShaders_[PEEL_NUM_COMBINATIONS *3]
generated shader set
GLuint blendQueryID_
fragment query
void setGeometryVertexCount(GLint _numVerticesOut)
Sets the maximum vertex output of the geometry shader.
void setGeometryOutputType(GLint _type)
Set output type of geometry.
void link()
Links the shader objects to the program.
void use()
Enables the program object for using.
void setGeometryInputType(GLint _type)
Set Type of Geometry.
void setUniform(const char *_name, GLint _value)
Set int uniform to specified value.
void attach(PtrConstShader _shader)
Attaches a shader object to the program object.
bool compile(bool verbose=true)
Compile the shader object.
void setSource(const StringList &source)
Upload the source of the shader.
DrawMode SOLID_SMOOTH_SHADED
draw smooth shaded (Gouraud shaded) faces (requires halfedge normals)
DrawMode SOLID_PHONG_SHADED
draw phong shaded faces
DrawMode SOLID_FACES_COLORED_SMOOTH_SHADED
draw smooth shaded and colored faces (requires vertex normals and face colors)
DrawMode POINTS_COLORED
draw colored, but not lighted points (requires point colors)
DrawMode SOLID_TEXTURED_SHADED
draw smooth shaded textured faces
DrawMode SOLID_FACES_COLORED
draw colored, but not lighted faces using face colors
DrawMode DEFAULT
use the default (global) draw mode and not the node's own.
DrawMode SOLID_FACES_COLORED_FLAT_SHADED
draw flat shaded and colored faces (requires face normals and colors)
DrawMode WIREFRAME
draw wireframe
DrawMode HIDDENLINE
draw hidden line (2 rendering passes needed)
DrawMode SOLID_POINTS_COLORED
draw colored, but not lighted faces using interpolated vertex colors
DrawMode SOLID_TEXTURED
draw textured faces
DrawMode SOLID_FLAT_SHADED
draw flat shaded faces (requires face normals)
Namespace providing different geometric functions concerning angles.
bool checkExtensionSupported(const std::string &_extension)
bool openGLVersion(const int _major, const int _minor, bool _verbose)
bool compatibilityProfile()
get opengl core profile setting
ACG::SceneGraph::BaseNode * getSceneGraphRootNode()
get scenegraph root node
unsigned int glWidth_
viewer window width
GLuint blendDualPeelFbo_
depth peeling fbo
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