Commit 442c231a authored by Sylvain Thery's avatar Sylvain Thery

add transparency possibility (using black color( 0.0,0.0,0.0) in simpleColor and perVertexColor

usage: constructor with true parameter
parent 4a94810e
......@@ -5,5 +5,9 @@ VARYING_FRAG vec3 color;
FRAG_OUT_DEF;
void main()
{
#ifdef BLACK_TRANSPARENCY
if (dot(color,color) == 0.0)
discard;
#endif
gl_FragColor=vec4(color,0.0);
}
......@@ -48,7 +48,7 @@ protected:
void restoreUniformsAttribs();
public:
ShaderColorPerVertex();
ShaderColorPerVertex(bool black_is_transparent = false);
unsigned int setAttributePosition(VBO* vbo);
......
......@@ -7,7 +7,6 @@ uniform vec3 lightPosition;
uniform vec4 ambient;
VARYING_IN vec3 colorVertex[];
VARYING_OUT vec4 ColorFS;
void main(void)
......
......@@ -5,5 +5,9 @@ uniform vec4 color;
FRAG_OUT_DEF;
void main()
{
#ifdef BLACK_TRANSPARENCY
if (dot(color,color) == 0.0)
discard;
#endif
gl_FragColor=color;
}
......@@ -52,7 +52,7 @@ protected:
void restoreUniformsAttribs();
public:
ShaderSimpleColor();
ShaderSimpleColor(bool back_is_transparent = false);
void setColor(const Geom::Vec4f& color);
......
......@@ -58,7 +58,7 @@ namespace Utils
// "}";
ShaderColorPerVertex::ShaderColorPerVertex()
ShaderColorPerVertex::ShaderColorPerVertex(bool black_is_transparent)
{
m_nameVS = "ShaderColorPerVertex_vs";
m_nameFS = "ShaderColorPerVertex_fs";
......@@ -68,6 +68,8 @@ ShaderColorPerVertex::ShaderColorPerVertex()
glxvert.append(vertexShaderText);
std::string glxfrag(*GLSLShader::DEFINES_GL);
if (black_is_transparent)
glxfrag.append("#define BLACK_TRANSPARENCY 1\n");
glxfrag.append(fragmentShaderText);
loadShadersFromMemory(glxvert.c_str(), glxfrag.c_str());
......
......@@ -54,7 +54,7 @@ namespace Utils
// "}";
ShaderSimpleColor::ShaderSimpleColor()
ShaderSimpleColor::ShaderSimpleColor(bool black_is_transparent)
{
m_nameVS = "ShaderSimpleColor_vs";
m_nameFS = "ShaderSimpleColor_fs";
......@@ -66,6 +66,8 @@ ShaderSimpleColor::ShaderSimpleColor()
glxvert.append(vertexShaderText);
std::string glxfrag(*GLSLShader::DEFINES_GL);
if (black_is_transparent)
glxfrag.append("#define BLACK_TRANSPARENCY 1\n");
glxfrag.append(fragmentShaderText);
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