50 #include "ClassicDepthPeeling.hh" 52 #include <ObjectTypes/Light/LightNode.hh> 54 #include <ACG/GL/GLError.hh> 61 DepthPeelingPlugin::DepthPeelingPlugin() :
67 for (
unsigned int i = 0; i < 16; ++i)
68 lightTypes_[i] = LIGHTTYPE_POINT;
70 for (
unsigned int i = 0; i < PEEL_NUM_COMBINATIONS; ++i)
73 for (
unsigned int i = 0; i < PEEL_NUM_COMBINATIONS*3; ++i)
76 for (
unsigned int i = 0; i < 8; ++i)
79 for (
unsigned int i = 0; i < 4; ++i)
80 blendDualPeelProg_[i] = 0;
82 for (
unsigned int i = 0; i < 16; ++i)
88 DepthPeelingPlugin::~DepthPeelingPlugin() {
93 DepthPeelingPlugin::ViewerResources::ViewerResources()
95 rtWidth_ = rtHeight_ = 0;
97 glWidth_ = glHeight_ = 0;
99 memset(blendDualPeelTexID_, 0, 7*4);
101 blendDualPeelFbo_ = 0;
104 void DepthPeelingPlugin::initializePlugin()
106 memset(blendShaders_, 0,
sizeof(blendShaders_));
107 memset(peelShaders_, 0,
sizeof(peelShaders_));
109 memset(blendDualPeelProg_, 0,
sizeof(blendDualPeelProg_));
110 memset(peelProgs_, 0,
sizeof(peelProgs_));
120 void DepthPeelingPlugin::exit()
127 QString DepthPeelingPlugin::rendererName() {
128 return QString(
"Classical Depth Peeling Renderer");
150 glVertex2f(x0, y0-h);
151 glVertex2f(x0+w, y0-h);
152 glVertex2f(x0+w, y0);
181 if (lightID != GL_INVALID_ENUM)
183 int id = lightID - GL_LIGHT0;
188 lightTypes_[
numLights_] = LIGHTTYPE_DIRECTIONAL;
189 else if (light.spotCutoff() > 179.5f)
213 traverseLightNodes(*cIt);
218 traverseLightNodes(*cIt);
229 GLSL::StringList* _strFragmentShaderOut,
230 GLSL::StringList* _strGeometryShaderOut,
237 if (_flatShaded) _phong =
false;
238 if (_vertexColor) _phong =
false;
240 std::string strColor =
"color";
241 std::string strNormal =
"normal";
242 std::string strFragPos =
"vPosVS";
245 strFragPos =
"VPosVS";
248 _flatShaded = _vertexColor = _textured = _phong =
false;
250 std::string strCode =
"";
252 for (
unsigned int i = 0; i <
numLights_ && (!_wireFrame); ++i)
257 std::string strLight =
"gl_LightSource[";
258 std::string strMaterial =
"gl_FrontLightProduct[";
261 sprintf(szTmp,
"%u]", glLightIDs_[i]);
264 strMaterial += szTmp;
268 if (lightTypes_[i] == LIGHTTYPE_DIRECTIONAL)
269 strCode +=
"vec3 vLightVS = " + strLight +
".position.xyz;\n";
271 strCode +=
"vec3 vLightVS = " + strLight +
".position.xyz - " + strFragPos +
".xyz;\n";
273 strCode +=
"vec3 vLightDir = normalize(vLightVS);\n";
276 strCode +=
"vec4 colLight = " + strMaterial +
".ambient;\n";
279 strCode +=
"float ldotn = dot(vLightDir, " + strNormal +
");\n";
280 strCode +=
"ldotn = clamp(ldotn, 0.0, 1.0);\n";
281 strCode +=
"colLight += ldotn * ";
282 if (_textured && _phong)
283 strCode +=
"diffColor * ";
288 strCode +=
"vColor[2];\n";
290 strCode +=
"gl_Color;\n";
293 strCode += strMaterial +
".diffuse;\n";
296 strCode +=
"colLight += floor(ldotn + 0.9) * pow(ldotn, gl_FrontMaterial.shininess) * " + strMaterial +
".specular;\n";
299 if (lightTypes_[i] == LIGHTTYPE_DIRECTIONAL)
300 strCode += strColor +
".rgb += colLight.rgb;\n";
304 strCode +=
"float fLenSq = dot(vLightVS, vLightVS);\n";
305 strCode +=
"float atten = " + strLight +
".constantAttenuation + " +
306 strLight +
".linearAttenuation * sqrt(fLenSq) + " +
307 strLight +
".quadraticAttenuation * fLenSq;\n";
309 if (lightTypes_[i] == LIGHTTYPE_POINT)
310 strCode += strColor +
".rgb += colLight.rgb / atten;\n";
314 strCode +=
"float spot = -dot(vLightDir, " + strLight +
".spotDirection);\n";
315 strCode +=
"spot *= step(" + strLight +
".spotCosCutoff, spot);\n";
316 strCode +=
"spot *= pow(spot, " + strLight +
".spotExponent);\n";
318 strCode += strColor +
".rgb += " +
"(spot / atten) * colLight.rgb;\n";
325 const char* szVertexShader[] = {
"varying vec2 vTexCoord;",
326 "varying vec3 vNormal; // normal: view space",
327 "varying vec4 vPosVS; // position in view space",
328 "varying vec4 vColor; // used in gouraud / flat shading only",
332 " gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;",
334 " vNormal = gl_NormalMatrix * gl_Normal; // gl_NormalMatrix : upper left 3x3 of WorldViewIT",
335 " vPosVS = (gl_ModelViewMatrix * gl_Vertex);",
336 " vTexCoord = gl_MultiTexCoord0.xy;",
341 const char* szGeometryShaderStart[] = {
343 "#extension GL_ARB_geometry_shader4 : enable",
345 "varying vec2 vTexCoord[3];",
346 "varying vec4 vPosVS[3];",
347 "varying vec3 vNormal[3];",
348 "varying vec4 vColor[3];",
350 "varying vec2 VTexCoord;",
351 "varying vec3 VNormal;",
352 "varying vec4 VPosVS;",
353 "varying vec4 VColor;",
358 " // recompute triangle normal",
360 " vec3 normal = cross(gl_PositionIn[1].xyz - gl_PositionIn[0].xyz, gl_PositionIn[2].xyz - gl_PositionIn[0].xyz);",
361 " normal = normalize(normal);",
362 " normal = gl_NormalMatrix * normal;",
365 " VPosVS = (gl_PositionIn[0] + gl_PositionIn[1] + gl_PositionIn[2]) / 3.0;",
366 " VPosVS = gl_ModelViewMatrix * VPosVS; // triangle center in view space needed for point and spot lights",
367 " vec4 color = vec4(gl_FrontMaterial.emission.rgb, gl_FrontMaterial.diffuse.a);",
370 const char* szGeometryShaderEnd[] = {
372 " for(int i = 0; i < 3; i++)",
374 " gl_Position = gl_ModelViewProjectionMatrix * gl_PositionIn[i];",
375 " VTexCoord = vTexCoord[i];",
376 " VNormal = normal;",
377 " VPosVS = vPosVS[i];",
386 const char* szFragmentShaderStart[] = {
"varying vec2 vTexCoord;",
387 "varying vec3 vNormal; ",
388 "varying vec4 vPosVS;",
389 "varying vec4 vColor;",
391 "uniform sampler2D DiffuseTex;",
392 "uniform sampler2DRect DepthBlenderTex;",
393 "uniform sampler2DRect FrontBlenderTex;",
395 "#define MAX_DEPTH 1.0",
400 " // window-space depth interpolated linearly in screen space",
401 " float fragDepth = gl_FragCoord.z;",
403 " vec2 depthBlender = texture2DRect(DepthBlenderTex, gl_FragCoord.xy).xy;",
404 " vec4 forwardTemp = texture2DRect(FrontBlenderTex, gl_FragCoord.xy);",
406 " // Depths and 1.0-alphaMult always increase",
407 " // so we can use pass-through by default with MAX blending",
408 " gl_FragData[0].xy = depthBlender;",
410 " // Front colors always increase (DST += SRC*ALPHA_MULT)",
411 " // so we can use pass-through by default with MAX blending",
412 " gl_FragData[1] = forwardTemp;",
414 " // Because over blending makes color increase or decrease,",
415 " // we cannot pass-through by default.",
416 " // Each pass, only one fragment writes a color greater than 0",
417 " gl_FragData[2] = vec4(0.0);",
419 " float nearestDepth = -depthBlender.x;",
420 " float farthestDepth = depthBlender.y;",
421 " float alphaMultiplier = 1.0 - forwardTemp.w;",
423 " if (fragDepth < nearestDepth || fragDepth > farthestDepth) {",
424 " // Skip this depth in the peeling algorithm",
425 " gl_FragData[0].xy = vec2(-MAX_DEPTH);",
429 " if (fragDepth > nearestDepth && fragDepth < farthestDepth) {",
430 " // This fragment needs to be peeled again",
431 " gl_FragData[0].xy = vec2(-fragDepth, fragDepth);",
435 " // If we made it here, this fragment is on the peeled layer from last pass",
436 " // therefore, we need to shade it, and make sure it is not peeled any farther",
439 const char* szFragmentShaderEnd[] = {
"",
440 " gl_FragData[0].xy = vec2(-MAX_DEPTH);",
442 " if (fragDepth == nearestDepth) {",
443 " gl_FragData[1].xyz += color.rgb * color.a * alphaMultiplier;",
444 " gl_FragData[1].w = 1.0 - alphaMultiplier * (1.0 - color.a);",
446 " gl_FragData[2] += color;",
453 for (
unsigned int i = 0; i <
sizeof(szVertexShader) /
sizeof(
char*); ++i)
455 std::string str = szVertexShader[i];
458 if (!strncmp(
"varying vec4 vColor", str.c_str(), strlen(
"varying vec4 vColor")))
466 _strVertexShaderOut->push_back(str);
470 if (!_phong && !_flatShaded && !_wireFrame)
473 _strVertexShaderOut->push_back(
"\nvec4 color = vec4(gl_FrontMaterial.emission.rgb, gl_FrontMaterial.diffuse.a);");
474 _strVertexShaderOut->push_back(
"\nvec3 normal = vNormal;\n");
476 std::string::size_type curPos = 0;
477 std::string::size_type newLinePos = strCode.find_first_of(
'\n');
478 while (newLinePos != std::string::npos)
480 _strVertexShaderOut->push_back(strCode.substr(curPos, newLinePos - curPos + 1));
481 curPos = newLinePos + 1;
482 newLinePos = strCode.find_first_of(
'\n', curPos);
484 _strVertexShaderOut->push_back(
"\nvColor = color;\n");
489 _strVertexShaderOut->push_back(
"vColor = gl_Color;\n");
490 _strVertexShaderOut->push_back(
"gl_Position = gl_Vertex;\n");
493 _strVertexShaderOut->push_back(
"\n}");
496 for (
unsigned int i = 0; i <
sizeof(szFragmentShaderStart) /
sizeof(
char*); ++i)
498 std::string str = szFragmentShaderStart[i];
501 if (!strncmp(
"varying vec4 vColor", str.c_str(), strlen(
"varying vec4 vColor")))
510 if (!strncmp(
"varying vec2 vTexCoord", str.c_str(), strlen(
"varying vec2 vTexCoord")))
511 str =
"varying vec2 VTexCoord;";
512 if (!strncmp(
"varying vec3 vNormal", str.c_str(), strlen(
"varying vec3 vNormal")))
513 str =
"varying vec3 VNormal;";
514 if (!strncmp(
"varying vec4 vPosVS", str.c_str(), strlen(
"varying vec4 vPosVS")))
515 str =
"varying vec4 VPosVS;";
516 if (!strncmp(
"varying vec4 vColor", str.c_str(), strlen(
"varying vec4 vColor")))
517 str =
"varying vec4 VColor;";
520 _strFragmentShaderOut->push_back(str);
527 _strFragmentShaderOut->push_back(
" vec3 normal = normalize(vNormal);\n");
529 _strFragmentShaderOut->push_back(
" vec4 color = vec4(gl_FrontMaterial.emission.rgb, gl_FrontMaterial.diffuse.a);\n");
531 _strFragmentShaderOut->push_back(
" vec4 diffColor = texture2D(DiffuseTex, vTexCoord); color.a *= diffColor.a;\n");
535 _strFragmentShaderOut->push_back(
" vec4 color = vec4(gl_FrontMaterial.emission.rgb, gl_FrontMaterial.diffuse.a);\n");
536 _strFragmentShaderOut->push_back(
" vec4 vColor = VColor;\n");
538 _strFragmentShaderOut->push_back(
" vec4 diffColor = texture2D(DiffuseTex, VTexCoord); color.a *= diffColor.a;\n");
544 _strFragmentShaderOut->push_back(
" color = diffColor * vColor;\n");
546 _strFragmentShaderOut->push_back(
" color = vColor;\n");
551 std::string::size_type curPos = 0;
552 std::string::size_type newLinePos = strCode.find_first_of(
'\n');
553 while (newLinePos != std::string::npos)
555 _strFragmentShaderOut->push_back(strCode.substr(curPos, newLinePos - curPos + 1));
556 curPos = newLinePos + 1;
557 newLinePos = strCode.find_first_of(
'\n', curPos);
562 _strFragmentShaderOut->push_back(
" vec4 color = VColor;\n");
564 for (
unsigned int i = 0; i <
sizeof(szFragmentShaderEnd) /
sizeof(
char*); ++i)
566 std::string str = szFragmentShaderEnd[i];
568 _strFragmentShaderOut->push_back(str);
575 for (
unsigned int i = 0; i <
sizeof(szGeometryShaderStart) /
sizeof(
char*); ++i)
577 std::string str = szGeometryShaderStart[i];
579 _strGeometryShaderOut->push_back(str);
583 std::string::size_type curPos = 0;
584 std::string::size_type newLinePos = strCode.find_first_of(
'\n');
585 while (newLinePos != std::string::npos)
587 _strGeometryShaderOut->push_back(strCode.substr(curPos, newLinePos - curPos + 1));
588 curPos = newLinePos + 1;
589 newLinePos = strCode.find_first_of(
'\n', curPos);
592 for (
unsigned int i = 0; i <
sizeof(szGeometryShaderEnd) /
sizeof(
char*); ++i)
594 std::string str = szGeometryShaderEnd[i];
596 _strGeometryShaderOut->push_back(str);
602 #ifdef DEPTHPEELING_SHADER_EXPORT 603 FILE* pShaderOut = fopen(
"peel_vertex.glsl",
"wt");
604 for (GLSL::StringList::iterator it = _strVertexShaderOut->begin(); it != _strVertexShaderOut->end(); ++it)
605 fprintf(pShaderOut, it->c_str());
609 pShaderOut = fopen(
"peel_frag.glsl",
"wt");
610 for (GLSL::StringList::iterator it = _strFragmentShaderOut->begin(); it != _strFragmentShaderOut->end(); ++it)
611 fprintf(pShaderOut, it->c_str());
616 pShaderOut = fopen(
"peel_geom.glsl",
"wt");
617 for (GLSL::StringList::iterator it = _strGeometryShaderOut->begin(); it != _strGeometryShaderOut->end(); ++it)
618 fprintf(pShaderOut, it->c_str());
626 template <
class Action>
639 dm = _globalDrawMode;
654 dmShaded &= ~
ACG::SceneGraph::DrawModes::WIREFRAME;
655 dmShaded &= ~
ACG::SceneGraph::DrawModes::HIDDENLINE;
661 ret &= traverseDrawApplyAction(_node, _action, _globalDrawMode, _pass, _peelPass);
669 unsigned int shaderIndex = getPeelShaderIndex(dm);
672 GLenum prev_depth = glStateTmp_->depthFunc();
673 if (dm & ACG::SceneGraph::DrawModes::HIDDENLINE)
681 GLSL::Program* peelProg = peelProgs_[PEEL_SHADER_HIDDENLINE];
685 peelProg->
setUniform(
"ObjectColor", glStateTmp_->clear_color());
690 ret &= _action(_node);
700 ACG::GLState::lockDepthFunc();
703 shaderIndex = PEEL_SHADER_WIREFRAME;
711 if (shaderIndex & PEEL_SHADER_FLAT)
721 ret &= _action(_node);
727 if (dm & ACG::SceneGraph::DrawModes::HIDDENLINE)
729 ACG::GLState::unlockDepthFunc();
740 template <
class Action>
756 if_has_enter(_action, _node);
763 process_children &= traverseDrawApplyAction(_node, _action, _globalDrawMode, _pass, _peelPass);
765 if (process_children) {
772 traverseDraw(*cIt, _action, _globalDrawMode, _pass, _peelPass);
777 traverseDraw(*cIt, _action, _globalDrawMode, _pass, _peelPass);
786 traverseDrawApplyAction(_node, _action, _globalDrawMode, _pass, _peelPass);
790 if_has_leave(_action, _node);
808 for(
unsigned int pass = BaseNode::PASS_1; pass <= (BaseNode::PASS_1 + max_passes); ++pass) {
811 traverseDraw (_sceneGraphRoot, action, _drawMode, pass, _peelPass);
832 bool rebuildShaders =
false;
839 unsigned int prevIDs[8];
843 memcpy(prevIDs, glLightIDs_,
sizeof(
unsigned int) * numLights_);
846 traverseLightNodes(sceneGraphRoot);
849 if (numLights_ == prevNum)
852 if (memcmp(prevLights, lightTypes_,
sizeof(
LightType) * numLights_) ||
853 memcmp(prevIDs, glLightIDs_,
sizeof(
unsigned int) * numLights_))
854 rebuildShaders =
true;
856 else rebuildShaders =
true;
861 for (
unsigned int i = 0; i <
sizeof(peelShaders_) /
sizeof(peelShaders_[0]); ++i)
863 delete peelShaders_[i]; peelShaders_[i] = 0;
866 for (
unsigned int i = 0; i <
sizeof(peelProgs_) /
sizeof(peelProgs_[0]); ++i)
868 delete peelProgs_[i]; peelProgs_[i] = 0;
871 for (
unsigned int i = 0; i < PEEL_NUM_COMBINATIONS; ++i)
873 GLuint texturedDrawMode = 0, flatDrawMode = 0, phongDrawMode = 0, vertexColorDrawMode = 0, gouraudDrawMode = 0;
875 texturedDrawMode = i & PEEL_SHADER_TEXTURED;
876 flatDrawMode = i & PEEL_SHADER_FLAT;
877 phongDrawMode = i & PEEL_SHADER_PHONG;
878 vertexColorDrawMode = i & PEEL_SHADER_VERTEXCOLORS;
879 gouraudDrawMode = i & PEEL_SHADER_GOURAUD;
881 if (i != PEEL_SHADER_WIREFRAME)
884 if (flatDrawMode && phongDrawMode)
continue;
885 if (flatDrawMode && gouraudDrawMode)
continue;
886 if (phongDrawMode && gouraudDrawMode)
continue;
888 if (phongDrawMode + flatDrawMode + gouraudDrawMode == 0)
continue;
901 GLSL::StringList strVertexShader, strFragmentShader, strGeometryShader;
902 generatePeelingShaders(&strVertexShader, &strFragmentShader, &strGeometryShader, texturedDrawMode != 0, flatDrawMode != 0, phongDrawMode != 0, vertexColorDrawMode != 0, i == PEEL_SHADER_WIREFRAME);
910 peelShaders_[i*3 + 0] = pVertexSh;
911 peelProgs_[i]->attach(pVertexSh);
918 peelShaders_[i*3 + 1] = pGeomSh;
919 peelProgs_[i]->attach(pGeomSh);
925 peelShaders_[i*3 + 2] = pFragSh;
926 peelProgs_[i]->attach(pFragSh);
928 peelProgs_[i]->link();
932 #ifdef DEPTHPEELING_SHADER_EXPORT 933 char szFileName[256];
934 sprintf(szFileName,
"peel_vertex_%02u.glsl", i);
935 FILE* pShaderOut = fopen(szFileName,
"wt");
936 for (GLSL::StringList::iterator it = strVertexShader.begin(); it != strVertexShader.end(); ++it)
937 fprintf(pShaderOut, it->c_str());
941 sprintf(szFileName,
"peel_frag%02u.glsl", i);
942 pShaderOut = fopen(szFileName,
"wt");
943 for (GLSL::StringList::iterator it = strFragmentShader.begin(); it != strFragmentShader.end(); ++it)
944 fprintf(pShaderOut, it->c_str());
949 sprintf(szFileName,
"peel_geom%02u.glsl", i);
950 pShaderOut = fopen(szFileName,
"wt");
951 for (GLSL::StringList::iterator it = strGeometryShader.begin(); it != strGeometryShader.end(); ++it)
952 fprintf(pShaderOut, it->c_str());
964 const char* szVertexShader[] = {
967 " gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;",
970 const char* szFragmentShader[] = {
971 "uniform vec4 ObjectColor;",
972 "uniform sampler2DRect DepthBlenderTex;",
973 "uniform sampler2DRect FrontBlenderTex;",
975 "#define MAX_DEPTH 1.0",
980 " // window-space depth interpolated linearly in screen space",
981 " float fragDepth = gl_FragCoord.z;",
983 " vec2 depthBlender = texture2DRect(DepthBlenderTex, gl_FragCoord.xy).xy;",
984 " vec4 forwardTemp = texture2DRect(FrontBlenderTex, gl_FragCoord.xy);",
986 " // Depths and 1.0-alphaMult always increase",
987 " // so we can use pass-through by default with MAX blending",
988 " gl_FragData[0].xy = depthBlender;",
990 " // Front colors always increase (DST += SRC*ALPHA_MULT)",
991 " // so we can use pass-through by default with MAX blending",
992 " gl_FragData[1] = forwardTemp;",
994 " // Because over blending makes color increase or decrease,",
995 " // we cannot pass-through by default.",
996 " // Each pass, only one fragment writes a color greater than 0",
997 " gl_FragData[2] = vec4(0.0);",
999 " float nearestDepth = -depthBlender.x;",
1000 " float farthestDepth = depthBlender.y;",
1001 " float alphaMultiplier = 1.0 - forwardTemp.w;",
1003 " if (fragDepth < nearestDepth || fragDepth > farthestDepth) {",
1004 " // Skip this depth in the peeling algorithm",
1005 " gl_FragData[0].xy = vec2(-MAX_DEPTH);",
1009 " if (fragDepth > nearestDepth && fragDepth < farthestDepth) {",
1010 " // This fragment needs to be peeled again",
1011 " gl_FragData[0].xy = vec2(-fragDepth, fragDepth);",
1015 " // If we made it here, this fragment is on the peeled layer from last pass",
1016 " // therefore, we need to shade it, and make sure it is not peeled any farther",
1017 " vec4 color = ObjectColor;",
1018 " gl_FragData[0].xy = vec2(-MAX_DEPTH);",
1020 " if (fragDepth == nearestDepth) {",
1021 " gl_FragData[1].xyz += color.rgb * color.a * alphaMultiplier;",
1022 " gl_FragData[1].w = 1.0 - alphaMultiplier * (1.0 - color.a);",
1024 " gl_FragData[2] += color;",
1028 GLSL::StringList strVertexShader, strFragmentShader;
1029 for (
unsigned int i = 0; i <
sizeof(szVertexShader) /
sizeof(
char*); ++i)
1031 std::string str = szVertexShader[i];
1033 strVertexShader.push_back(str);
1036 for (
unsigned int i = 0; i <
sizeof(szFragmentShader) /
sizeof(
char*); ++i)
1038 std::string str = szFragmentShader[i];
1040 strFragmentShader.push_back(str);
1048 peelShaders_[PEEL_SHADER_HIDDENLINE*3 + 0] = pVertexSh;
1049 peelHiddenLine->
attach(pVertexSh);
1054 peelShaders_[PEEL_SHADER_HIDDENLINE*3 + 2] = pFragSh;
1055 peelHiddenLine->
attach(pFragSh);
1057 peelHiddenLine->
link();
1067 return PEEL_SHADER_WIREFRAME;
1078 if (phong && flat) flat =
false;
1079 if (flat && gouraud) gouraud =
false;
1080 if (gouraud && phong) phong =
false;
1083 if ((!phong) && (!gouraud) && (!flat)) gouraud =
true;
1085 unsigned int idx = 0;
1087 if (flat) idx |= PEEL_SHADER_FLAT;
1088 if (gouraud) idx |= PEEL_SHADER_GOURAUD;
1089 if (phong) idx |= PEEL_SHADER_PHONG;
1090 if (vertexColor) idx |= PEEL_SHADER_VERTEXCOLORS;
1091 if (textured) idx |= PEEL_SHADER_TEXTURED;
1096 QString DepthPeelingPlugin::checkOpenGL() {
1099 return QString(
"Insufficient OpenGL Version! OpenGL 2.0 or higher required");
1102 QString missing =
"";
1105 missing +=
"Missing Extension GL_ARB_geometry_shader4\n";
1108 missing +=
"Missing Extension GL_ARB_vertex_program\n";
1114 #if QT_VERSION < 0x050000 StatusMode status() const
Get node's status.
DrawMode POINTS_COLORED
draw colored, but not lighted points (requires point colors)
void next_render_pass()
increment render pass counter
void attach(PtrConstShader _shader)
Attaches a shader object to the program object.
ChildIter childrenEnd()
Returns: end-iterator of children.
void setSource(const StringList &source)
Upload the source of the shader.
std::vector< BaseNode * >::iterator ChildIter
allows to iterate over children
DrawMode SOLID_SMOOTH_SHADED
draw smooth shaded (Gouraud shaded) faces (requires halfedge normals)
DrawMode HIDDENLINE
draw hidden line (2 rendering passes needed)
DrawMode SOLID_FLAT_SHADED
draw flat shaded faces (requires face normals)
bool compile(bool verbose=true)
Compile the shader object.
void reset_render_pass()
reset render pass counter
DrawMode DEFAULT
use the default (global) draw mode and not the node's own.
DrawMode WIREFRAME
draw wireframe
DrawMode SOLID_FACES_COLORED_SMOOTH_SHADED
draw smooth shaded and colored faces (requires vertex normals and face colors)
static void unlockDepthRange()
unlock depth range
DrawModes::DrawMode drawMode() const
Return the own draw modes of this node.
static void lockProgram()
lock the program
int numLights_
Number of Lights.
void traverse_multipass(BaseNode *_node, Action &_action, const unsigned int &_pass)
void link()
Links the shader objects to the program.
Hide this node and its children.
Execute action on node first and then on its children.
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
bool multipassNodeActive(const unsigned int _i) const
Get Node status to traverse in a specific pass.
DrawMode SOLID_FACES_COLORED_FLAT_SHADED
draw flat shaded and colored faces (requires face normals and colors)
void use()
Enables the program object for using.
Draw this node, but hide children.
bool openGLVersion(const int _major, const int _minor)
const GLenum & depthFunc() const
get glDepthFunc() that is supposed to be active
DrawMode SOLID_TEXTURED
draw textured faces
DrawMode SOLID_FACES_COLORED
draw colored, but not lighted faces using face colors
static void depthRange(GLclampd _zNear, GLclampd _zFar)
replaces glDepthRange, supports locking
void getLightSource(LightSource *_light) const
Get the light source parameters.
void updatePeelingShaderSet()
regenerates peeling shaders based on light nodes in scenegraph
unsigned int max_render_passes() const
get maximum number of render passes
DrawMode SOLID_PHONG_SHADED
draw phong shaded faces
void traverseLightNodes(BaseNode *_node)
find all light nodes in the scene
void setGeometryInputType(GLint _type)
Set Type of Geometry.
static void unlockProgram()
unlock the program
Hide this node, but draw children.
ChildIter childrenBegin()
Returns: begin-iterator of children.
void setUniform(const char *_name, GLint _value)
Set int uniform to specified value.
void drawScenePass(ACG::GLState *_glState, ACG::SceneGraph::DrawModes::DrawMode _drawMode, BaseNode *_sceneGraphRoot)
draw the current scene
unsigned int getPeelShaderIndex(ACG::SceneGraph::DrawModes::DrawMode _drawMode)
converts a drawmode to the correct shading program index
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)
Namespace providing different geometric functions concerning angles.
void setGeometryVertexCount(GLint _numVerticesOut)
Sets the maximum vertex output of the geometry shader.
void setGeometryOutputType(GLint _type)
Set output type of geometry.
DrawMode SOLID_POINTS_COLORED
draw colored, but not lighted faces using interpolated vertex colors
Draw node in second pass.
bool multipassStatusActive(const unsigned int _i) const
Get multipass status to traverse in a specific pass.
Execute action the children first and then on this node.
DrawMode SOLID_TEXTURED_SHADED
draw smooth shaded textured faces
bool checkExtensionSupported(const std::string &_extension)
ACG::SceneGraph::BaseNode * getSceneGraphRootNode()
get scenegraph root node
LightType
light type enumeration
unsigned int traverseMode() const
Return how the node should be traversed.
static void lockDepthRange()
lock depth range
Structure to hold options for one LightSource.