diff --git a/include/Utils/text3d.h b/include/Utils/text3d.h index 87e0b6fc24d73187782f135f6551e55cc6d10a99..860f8193af3938e3d45f234068d9840fb09a6a80 100644 --- a/include/Utils/text3d.h +++ b/include/Utils/text3d.h @@ -54,6 +54,7 @@ protected: static std::string fragmentShaderText1; static std::string fragmentShaderText2; + static std::string fragmentShaderText3; static Strings3D* m_instance0; diff --git a/src/Utils/text3d.cpp b/src/Utils/text3d.cpp index 88793d33cce12395ec32444ae8752c9dfa1b6a1b..987ee675f5d5a824b9d7d57e226fef8c70a0c3e0 100644 --- a/src/Utils/text3d.cpp +++ b/src/Utils/text3d.cpp @@ -36,8 +36,10 @@ namespace Utils std::string Strings3D::fragmentShaderText2 = -" gl_FragColor = color*lum;\n" -"}"; +" if (lum == 0.0) discard;\n gl_FragColor = color*lum;\n}"; + +std::string Strings3D::fragmentShaderText3 = +" gl_FragColor = mix(backColor,color,lum);\n}"; Strings3D* Strings3D::m_instance0 = NULL; @@ -70,22 +72,28 @@ Strings3D::Strings3D(bool withBackground, const Geom::Vec3f& bgc, bool with_plan if (with_plane) glxvert.append("#define WITH_PLANE 1"); glxvert.append(vertexShaderText); - std::string glxfrag(*GLSLShader::DEFINES_GL); + + std::string glxfrag(*GLSLShader::DEFINES_GL); glxfrag.append(fragmentShaderText1); - std::string background; if (!withBackground) - glxfrag.append("if (lum == 0.0) discard;\n"); - else if (bgc*bgc > 0.0) + { + glxfrag.append(fragmentShaderText2); + } + else { std::stringstream ss; - ss << " if (lum==0.0) gl_FragColor=vec4("; - ss << bgc[0] << "," << bgc[1] << "," << bgc[2] << ",color[3]);\n else\n"; - background.append(ss.str()); + ss << "vec4 backColor = vec4(" <