Création d'un compte pour un collaborateur extérieur au laboratoire depuis l'intranet ICube : https://intranet.icube.unistra.fr/fr/labs/member/profile

Commit 5f83b5b9 authored by Sylvain Thery's avatar Sylvain Thery
Browse files

enhance rendering of text by mixing front & back color

parent 8b62d1d9
...@@ -54,6 +54,7 @@ protected: ...@@ -54,6 +54,7 @@ protected:
static std::string fragmentShaderText1; static std::string fragmentShaderText1;
static std::string fragmentShaderText2; static std::string fragmentShaderText2;
static std::string fragmentShaderText3;
static Strings3D* m_instance0; static Strings3D* m_instance0;
......
...@@ -36,8 +36,10 @@ namespace Utils ...@@ -36,8 +36,10 @@ namespace Utils
std::string Strings3D::fragmentShaderText2 = 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; Strings3D* Strings3D::m_instance0 = NULL;
...@@ -70,22 +72,28 @@ Strings3D::Strings3D(bool withBackground, const Geom::Vec3f& bgc, bool with_plan ...@@ -70,22 +72,28 @@ Strings3D::Strings3D(bool withBackground, const Geom::Vec3f& bgc, bool with_plan
if (with_plane) if (with_plane)
glxvert.append("#define WITH_PLANE 1"); glxvert.append("#define WITH_PLANE 1");
glxvert.append(vertexShaderText); glxvert.append(vertexShaderText);
std::string glxfrag(*GLSLShader::DEFINES_GL);
std::string glxfrag(*GLSLShader::DEFINES_GL);
glxfrag.append(fragmentShaderText1); glxfrag.append(fragmentShaderText1);
std::string background;
if (!withBackground) if (!withBackground)
glxfrag.append("if (lum == 0.0) discard;\n"); {
else if (bgc*bgc > 0.0) glxfrag.append(fragmentShaderText2);
}
else
{ {
std::stringstream ss; std::stringstream ss;
ss << " if (lum==0.0) gl_FragColor=vec4("; ss << "vec4 backColor = vec4(" <<bgc[0] << "," << bgc[1] << "," << bgc[2] << ",color[3]);\n";
ss << bgc[0] << "," << bgc[1] << "," << bgc[2] << ",color[3]);\n else\n"; // ss << "vec4 backColor = vec4(0.2,0.1,0.4);\n";
background.append(ss.str()); glxfrag.append(ss.str());
glxfrag.append(fragmentShaderText3);
} }
glxfrag.append(background);
glxfrag.append(fragmentShaderText2);
std::cout << "===================================="<< std::endl;
std::cout << glxfrag << std::endl;
std::cout << "===================================="<< std::endl;
loadShadersFromMemory(glxvert.c_str(), glxfrag.c_str()); loadShadersFromMemory(glxvert.c_str(), glxfrag.c_str());
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment