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[" + std::to_string(
glLightIDs_[i]) +
"]";
252 std::string strMaterial =
"gl_FrontLightProduct[" + std::to_string(
glLightIDs_[i]) +
"]";
256 strCode +=
"vec3 vLightVS = " + strLight +
".position.xyz;\n";
258 strCode +=
"vec3 vLightVS = " + strLight +
".position.xyz - " + strFragPos +
".xyz;\n";
260 strCode +=
"vec3 vLightDir = normalize(vLightVS);\n";
263 strCode +=
"vec4 colLight = " + strMaterial +
".ambient;\n";
266 strCode +=
"float ldotn = dot(vLightDir, " + strNormal +
");\n";
267 strCode +=
"ldotn = clamp(ldotn, 0.0, 1.0);\n";
268 strCode +=
"colLight += ldotn * ";
269 if (_textured && _phong)
270 strCode +=
"diffColor * ";
275 strCode +=
"vColor[2];\n";
277 strCode +=
"gl_Color;\n";
280 strCode += strMaterial +
".diffuse;\n";
283 strCode +=
"colLight += floor(ldotn + 0.9) * pow(ldotn, gl_FrontMaterial.shininess) * " + strMaterial +
".specular;\n";
287 strCode += strColor +
".rgb += colLight.rgb;\n";
291 strCode +=
"float fLenSq = dot(vLightVS, vLightVS);\n";
292 strCode +=
"float atten = " + strLight +
".constantAttenuation + " +
293 strLight +
".linearAttenuation * sqrt(fLenSq) + " +
294 strLight +
".quadraticAttenuation * fLenSq;\n";
297 strCode += strColor +
".rgb += colLight.rgb / atten;\n";
301 strCode +=
"float spot = -dot(vLightDir, " + strLight +
".spotDirection);\n";
302 strCode +=
"spot *= step(" + strLight +
".spotCosCutoff, spot);\n";
303 strCode +=
"spot *= pow(spot, " + strLight +
".spotExponent);\n";
305 strCode += strColor +
".rgb += " +
"(spot / atten) * colLight.rgb;\n";
312 const char* szVertexShader[] = {
"varying vec2 vTexCoord;",
313 "varying vec3 vNormal; // normal: view space",
314 "varying vec4 vPosVS; // position in view space",
315 "varying vec4 vColor; // used in gouraud / flat shading only",
319 " gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;",
321 " vNormal = gl_NormalMatrix * gl_Normal; // gl_NormalMatrix : upper left 3x3 of WorldViewIT",
322 " vPosVS = (gl_ModelViewMatrix * gl_Vertex);",
323 " vTexCoord = gl_MultiTexCoord0.xy;",
328 const char* szGeometryShaderStart[] = {
330 "#extension GL_ARB_geometry_shader4 : enable",
332 "varying vec2 vTexCoord[3];",
333 "varying vec4 vPosVS[3];",
334 "varying vec3 vNormal[3];",
335 "varying vec4 vColor[3];",
337 "varying vec2 VTexCoord;",
338 "varying vec3 VNormal;",
339 "varying vec4 VPosVS;",
340 "varying vec4 VColor;",
345 " // recompute triangle normal",
347 " vec3 normal = cross(gl_PositionIn[1].xyz - gl_PositionIn[0].xyz, gl_PositionIn[2].xyz - gl_PositionIn[0].xyz);",
348 " normal = normalize(normal);",
349 " normal = gl_NormalMatrix * normal;",
352 " VPosVS = (gl_PositionIn[0] + gl_PositionIn[1] + gl_PositionIn[2]) / 3.0;",
353 " VPosVS = gl_ModelViewMatrix * VPosVS; // triangle center in view space needed for point and spot lights",
354 " vec4 color = vec4(gl_FrontMaterial.emission.rgb, gl_FrontMaterial.diffuse.a);",
357 const char* szGeometryShaderEnd[] = {
359 " for(int i = 0; i < 3; i++)",
361 " gl_Position = gl_ModelViewProjectionMatrix * gl_PositionIn[i];",
362 " VTexCoord = vTexCoord[i];",
363 " VNormal = normal;",
364 " VPosVS = vPosVS[i];",
373 const char* szFragmentShaderStart[] = {
"varying vec2 vTexCoord;",
374 "varying vec3 vNormal; ",
375 "varying vec4 vPosVS;",
376 "varying vec4 vColor;",
378 "uniform sampler2D DiffuseTex;",
379 "uniform sampler2DRect DepthBlenderTex;",
380 "uniform sampler2DRect FrontBlenderTex;",
382 "#define MAX_DEPTH 1.0",
387 " // window-space depth interpolated linearly in screen space",
388 " float fragDepth = gl_FragCoord.z;",
390 " vec2 depthBlender = texture2DRect(DepthBlenderTex, gl_FragCoord.xy).xy;",
391 " vec4 forwardTemp = texture2DRect(FrontBlenderTex, gl_FragCoord.xy);",
393 " // Depths and 1.0-alphaMult always increase",
394 " // so we can use pass-through by default with MAX blending",
395 " gl_FragData[0].xy = depthBlender;",
397 " // Front colors always increase (DST += SRC*ALPHA_MULT)",
398 " // so we can use pass-through by default with MAX blending",
399 " gl_FragData[1] = forwardTemp;",
401 " // Because over blending makes color increase or decrease,",
402 " // we cannot pass-through by default.",
403 " // Each pass, only one fragment writes a color greater than 0",
404 " gl_FragData[2] = vec4(0.0);",
406 " float nearestDepth = -depthBlender.x;",
407 " float farthestDepth = depthBlender.y;",
408 " float alphaMultiplier = 1.0 - forwardTemp.w;",
410 " if (fragDepth < nearestDepth || fragDepth > farthestDepth) {",
411 " // Skip this depth in the peeling algorithm",
412 " gl_FragData[0].xy = vec2(-MAX_DEPTH);",
416 " if (fragDepth > nearestDepth && fragDepth < farthestDepth) {",
417 " // This fragment needs to be peeled again",
418 " gl_FragData[0].xy = vec2(-fragDepth, fragDepth);",
422 " // If we made it here, this fragment is on the peeled layer from last pass",
423 " // therefore, we need to shade it, and make sure it is not peeled any farther",
426 const char* szFragmentShaderEnd[] = {
"",
427 " gl_FragData[0].xy = vec2(-MAX_DEPTH);",
429 " if (fragDepth == nearestDepth) {",
430 " gl_FragData[1].xyz += color.rgb * color.a * alphaMultiplier;",
431 " gl_FragData[1].w = 1.0 - alphaMultiplier * (1.0 - color.a);",
433 " gl_FragData[2] += color;",
440 for (
unsigned int i = 0; i <
sizeof(szVertexShader) /
sizeof(
char*); ++i)
442 std::string str = szVertexShader[i];
445 if (!strncmp(
"varying vec4 vColor", str.c_str(), strlen(
"varying vec4 vColor")))
453 _strVertexShaderOut->push_back(str);
457 if (!_phong && !_flatShaded && !_wireFrame)
460 _strVertexShaderOut->push_back(
"\nvec4 color = vec4(gl_FrontMaterial.emission.rgb, gl_FrontMaterial.diffuse.a);");
461 _strVertexShaderOut->push_back(
"\nvec3 normal = vNormal;\n");
463 std::string::size_type curPos = 0;
464 std::string::size_type newLinePos = strCode.find_first_of(
'\n');
465 while (newLinePos != std::string::npos)
467 _strVertexShaderOut->push_back(strCode.substr(curPos, newLinePos - curPos + 1));
468 curPos = newLinePos + 1;
469 newLinePos = strCode.find_first_of(
'\n', curPos);
471 _strVertexShaderOut->push_back(
"\nvColor = color;\n");
476 _strVertexShaderOut->push_back(
"vColor = gl_Color;\n");
477 _strVertexShaderOut->push_back(
"gl_Position = gl_Vertex;\n");
480 _strVertexShaderOut->push_back(
"\n}");
483 for (
unsigned int i = 0; i <
sizeof(szFragmentShaderStart) /
sizeof(
char*); ++i)
485 std::string str = szFragmentShaderStart[i];
488 if (!strncmp(
"varying vec4 vColor", str.c_str(), strlen(
"varying vec4 vColor")))
497 if (!strncmp(
"varying vec2 vTexCoord", str.c_str(), strlen(
"varying vec2 vTexCoord")))
498 str =
"varying vec2 VTexCoord;";
499 if (!strncmp(
"varying vec3 vNormal", str.c_str(), strlen(
"varying vec3 vNormal")))
500 str =
"varying vec3 VNormal;";
501 if (!strncmp(
"varying vec4 vPosVS", str.c_str(), strlen(
"varying vec4 vPosVS")))
502 str =
"varying vec4 VPosVS;";
503 if (!strncmp(
"varying vec4 vColor", str.c_str(), strlen(
"varying vec4 vColor")))
504 str =
"varying vec4 VColor;";
507 _strFragmentShaderOut->push_back(str);
514 _strFragmentShaderOut->push_back(
" vec3 normal = normalize(vNormal);\n");
516 _strFragmentShaderOut->push_back(
" vec4 color = vec4(gl_FrontMaterial.emission.rgb, gl_FrontMaterial.diffuse.a);\n");
518 _strFragmentShaderOut->push_back(
" vec4 diffColor = texture2D(DiffuseTex, vTexCoord); color.a *= diffColor.a;\n");
522 _strFragmentShaderOut->push_back(
" vec4 color = vec4(gl_FrontMaterial.emission.rgb, gl_FrontMaterial.diffuse.a);\n");
523 _strFragmentShaderOut->push_back(
" vec4 vColor = VColor;\n");
525 _strFragmentShaderOut->push_back(
" vec4 diffColor = texture2D(DiffuseTex, VTexCoord); color.a *= diffColor.a;\n");
531 _strFragmentShaderOut->push_back(
" color = diffColor * vColor;\n");
533 _strFragmentShaderOut->push_back(
" color = vColor;\n");
538 std::string::size_type curPos = 0;
539 std::string::size_type newLinePos = strCode.find_first_of(
'\n');
540 while (newLinePos != std::string::npos)
542 _strFragmentShaderOut->push_back(strCode.substr(curPos, newLinePos - curPos + 1));
543 curPos = newLinePos + 1;
544 newLinePos = strCode.find_first_of(
'\n', curPos);
549 _strFragmentShaderOut->push_back(
" vec4 color = vColor;\n");
551 for (
unsigned int i = 0; i <
sizeof(szFragmentShaderEnd) /
sizeof(
char*); ++i)
553 std::string str = szFragmentShaderEnd[i];
555 _strFragmentShaderOut->push_back(str);
562 for (
unsigned int i = 0; i <
sizeof(szGeometryShaderStart) /
sizeof(
char*); ++i)
564 std::string str = szGeometryShaderStart[i];
566 _strGeometryShaderOut->push_back(str);
570 std::string::size_type curPos = 0;
571 std::string::size_type newLinePos = strCode.find_first_of(
'\n');
572 while (newLinePos != std::string::npos)
574 _strGeometryShaderOut->push_back(strCode.substr(curPos, newLinePos - curPos + 1));
575 curPos = newLinePos + 1;
576 newLinePos = strCode.find_first_of(
'\n', curPos);
579 for (
unsigned int i = 0; i <
sizeof(szGeometryShaderEnd) /
sizeof(
char*); ++i)
581 std::string str = szGeometryShaderEnd[i];
583 _strGeometryShaderOut->push_back(str);
589#ifdef DEPTHPEELING_SHADER_EXPORT
590 FILE* pShaderOut = fopen(
"peel_vertex.glsl",
"wt");
591 for (GLSL::StringList::iterator it = _strVertexShaderOut->begin(); it != _strVertexShaderOut->end(); ++it)
592 fprintf(pShaderOut, it->c_str());
596 pShaderOut = fopen(
"peel_frag.glsl",
"wt");
597 for (GLSL::StringList::iterator it = _strFragmentShaderOut->begin(); it != _strFragmentShaderOut->end(); ++it)
598 fprintf(pShaderOut, it->c_str());
603 pShaderOut = fopen(
"peel_geom.glsl",
"wt");
604 for (GLSL::StringList::iterator it = _strGeometryShaderOut->begin(); it != _strGeometryShaderOut->end(); ++it)
605 fprintf(pShaderOut, it->c_str());
613template <
class Action>
626 dm = _globalDrawMode;
641 dmShaded &=
~ACG::SceneGraph::DrawModes::WIREFRAME;
642 dmShaded &=
~ACG::SceneGraph::DrawModes::HIDDENLINE;
648 ret &= traverseDrawApplyAction(_node, _action, _globalDrawMode, _pass, _peelPass);
677 ret &= _action(_node);
687 ACG::GLState::lockDepthFunc();
690 shaderIndex = PEEL_SHADER_WIREFRAME;
698 if (shaderIndex & PEEL_SHADER_FLAT)
708 ret &= _action(_node);
716 ACG::GLState::unlockDepthFunc();
727template <
class Action>
743 if_has_enter(_action, _node);
750 process_children &= traverseDrawApplyAction(_node, _action, _globalDrawMode, _pass, _peelPass);
752 if (process_children) {
759 traverseDraw(*cIt, _action, _globalDrawMode, _pass, _peelPass);
764 traverseDraw(*cIt, _action, _globalDrawMode, _pass, _peelPass);
773 traverseDrawApplyAction(_node, _action, _globalDrawMode, _pass, _peelPass);
777 if_has_leave(_action, _node);
795 for(
unsigned int pass = BaseNode::PASS_1; pass <= (BaseNode::PASS_1 + max_passes); ++pass) {
798 traverseDraw (_sceneGraphRoot, action, _drawMode, pass, _peelPass);
812 traverse_multipass(_sceneGraphRoot, action, *_glState, _drawMode);
819 bool rebuildShaders =
false;
826 unsigned int prevIDs[8];
841 rebuildShaders =
true;
843 else rebuildShaders =
true;
858 for (
unsigned int i = 0; i < PEEL_NUM_COMBINATIONS; ++i)
860 GLuint texturedDrawMode = 0, flatDrawMode = 0, phongDrawMode = 0, vertexColorDrawMode = 0, gouraudDrawMode = 0;
862 texturedDrawMode = i & PEEL_SHADER_TEXTURED;
863 flatDrawMode = i & PEEL_SHADER_FLAT;
864 phongDrawMode = i & PEEL_SHADER_PHONG;
865 vertexColorDrawMode = i & PEEL_SHADER_VERTEXCOLORS;
866 gouraudDrawMode = i & PEEL_SHADER_GOURAUD;
868 if (i != PEEL_SHADER_WIREFRAME)
871 if (flatDrawMode && phongDrawMode)
continue;
872 if (flatDrawMode && gouraudDrawMode)
continue;
873 if (phongDrawMode && gouraudDrawMode)
continue;
875 if (phongDrawMode + flatDrawMode + gouraudDrawMode == 0)
continue;
888 GLSL::StringList strVertexShader, strFragmentShader, strGeometryShader;
889 generatePeelingShaders(&strVertexShader, &strFragmentShader, &strGeometryShader, texturedDrawMode != 0, flatDrawMode != 0, phongDrawMode != 0, vertexColorDrawMode != 0, i == PEEL_SHADER_WIREFRAME);
919#ifdef DEPTHPEELING_SHADER_EXPORT
920 char szFileName[256];
921 sprintf(szFileName,
"peel_vertex_%02u.glsl", i);
922 FILE* pShaderOut = fopen(szFileName,
"wt");
923 for (GLSL::StringList::iterator it = strVertexShader.begin(); it != strVertexShader.end(); ++it)
924 fprintf(pShaderOut, it->c_str());
928 sprintf(szFileName,
"peel_frag%02u.glsl", i);
929 pShaderOut = fopen(szFileName,
"wt");
930 for (GLSL::StringList::iterator it = strFragmentShader.begin(); it != strFragmentShader.end(); ++it)
931 fprintf(pShaderOut, it->c_str());
936 sprintf(szFileName,
"peel_geom%02u.glsl", i);
937 pShaderOut = fopen(szFileName,
"wt");
938 for (GLSL::StringList::iterator it = strGeometryShader.begin(); it != strGeometryShader.end(); ++it)
939 fprintf(pShaderOut, it->c_str());
951 const char* szVertexShader[] = {
954 " gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;",
957 const char* szFragmentShader[] = {
958 "uniform vec4 ObjectColor;",
959 "uniform sampler2DRect DepthBlenderTex;",
960 "uniform sampler2DRect FrontBlenderTex;",
962 "#define MAX_DEPTH 1.0",
967 " // window-space depth interpolated linearly in screen space",
968 " float fragDepth = gl_FragCoord.z;",
970 " vec2 depthBlender = texture2DRect(DepthBlenderTex, gl_FragCoord.xy).xy;",
971 " vec4 forwardTemp = texture2DRect(FrontBlenderTex, gl_FragCoord.xy);",
973 " // Depths and 1.0-alphaMult always increase",
974 " // so we can use pass-through by default with MAX blending",
975 " gl_FragData[0].xy = depthBlender;",
977 " // Front colors always increase (DST += SRC*ALPHA_MULT)",
978 " // so we can use pass-through by default with MAX blending",
979 " gl_FragData[1] = forwardTemp;",
981 " // Because over blending makes color increase or decrease,",
982 " // we cannot pass-through by default.",
983 " // Each pass, only one fragment writes a color greater than 0",
984 " gl_FragData[2] = vec4(0.0);",
986 " float nearestDepth = -depthBlender.x;",
987 " float farthestDepth = depthBlender.y;",
988 " float alphaMultiplier = 1.0 - forwardTemp.w;",
990 " if (fragDepth < nearestDepth || fragDepth > farthestDepth) {",
991 " // Skip this depth in the peeling algorithm",
992 " gl_FragData[0].xy = vec2(-MAX_DEPTH);",
996 " if (fragDepth > nearestDepth && fragDepth < farthestDepth) {",
997 " // This fragment needs to be peeled again",
998 " gl_FragData[0].xy = vec2(-fragDepth, fragDepth);",
1002 " // If we made it here, this fragment is on the peeled layer from last pass",
1003 " // therefore, we need to shade it, and make sure it is not peeled any farther",
1004 " vec4 color = ObjectColor;",
1005 " gl_FragData[0].xy = vec2(-MAX_DEPTH);",
1007 " if (fragDepth == nearestDepth) {",
1008 " gl_FragData[1].xyz += color.rgb * color.a * alphaMultiplier;",
1009 " gl_FragData[1].w = 1.0 - alphaMultiplier * (1.0 - color.a);",
1011 " gl_FragData[2] += color;",
1015 GLSL::StringList strVertexShader, strFragmentShader;
1016 for (
unsigned int i = 0; i <
sizeof(szVertexShader) /
sizeof(
char*); ++i)
1018 std::string str = szVertexShader[i];
1020 strVertexShader.push_back(str);
1023 for (
unsigned int i = 0; i <
sizeof(szFragmentShader) /
sizeof(
char*); ++i)
1025 std::string str = szFragmentShader[i];
1027 strFragmentShader.push_back(str);
1035 peelShaders_[PEEL_SHADER_HIDDENLINE*3 + 0] = pVertexSh;
1036 peelHiddenLine->
attach(pVertexSh);
1042 peelHiddenLine->
attach(pFragSh);
1044 peelHiddenLine->
link();
1054 return PEEL_SHADER_WIREFRAME;
1065 if (phong && flat) flat =
false;
1066 if (flat && gouraud) gouraud =
false;
1067 if (gouraud && phong) phong =
false;
1070 if ((!phong) && (!gouraud) && (!flat)) gouraud =
true;
1072 unsigned int idx = 0;
1074 if (flat) idx |= PEEL_SHADER_FLAT;
1075 if (gouraud) idx |= PEEL_SHADER_GOURAUD;
1076 if (phong) idx |= PEEL_SHADER_PHONG;
1077 if (vertexColor) idx |= PEEL_SHADER_VERTEXCOLORS;
1078 if (textured) idx |= PEEL_SHADER_TEXTURED;
1083QString DepthPeelingPlugin::checkOpenGL() {
1085 return QString(
"Classic depth peeling Rendering-plugin is not compatible with core contexts.");
1087 return QString(
"Insufficient OpenGL Version! OpenGL 2.0 or higher required");
1090 QString missing =
"";
1093 missing +=
"Missing Extension GL_ARB_geometry_shader4\n";
1096 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