diff --git a/data/shaders/transparent.frag b/data/shaders/transparent.frag index 4de578afd..f6585ef9d 100644 --- a/data/shaders/transparent.frag +++ b/data/shaders/transparent.frag @@ -2,6 +2,7 @@ uniform sampler2D tex; #if __VERSION__ >= 130 in vec2 uv; +in vec4 color; out vec4 FragColor; #else varying vec2 uv; @@ -11,5 +12,5 @@ varying vec2 uv; void main() { - FragColor = texture(tex, uv); + FragColor = texture(tex, uv) * color; } diff --git a/data/shaders/transparent.vert b/data/shaders/transparent.vert index 9692fc549..e6c6b13fe 100644 --- a/data/shaders/transparent.vert +++ b/data/shaders/transparent.vert @@ -4,7 +4,9 @@ uniform mat4 TextureMatrix; #if __VERSION__ >= 130 in vec3 Position; in vec2 Texcoord; +in vec4 Color; out vec2 uv; +out vec4 color; #else attribute vec3 Position; attribute vec2 Texcoord; @@ -16,4 +18,5 @@ void main() { uv = (TextureMatrix * vec4(Texcoord, 1., 1.)).xy; gl_Position = ModelViewProjectionMatrix * vec4(Position, 1.); + color = Color; } diff --git a/src/graphics/shaders.cpp b/src/graphics/shaders.cpp index 53a1d1879..26e80c2a9 100644 --- a/src/graphics/shaders.cpp +++ b/src/graphics/shaders.cpp @@ -873,6 +873,7 @@ namespace MeshShader GLuint TransparentShader::Program; GLuint TransparentShader::attrib_position; GLuint TransparentShader::attrib_texcoord; + GLuint TransparentShader::attrib_color; GLuint TransparentShader::uniform_MVP; GLuint TransparentShader::uniform_TM; GLuint TransparentShader::uniform_tex; @@ -882,6 +883,7 @@ namespace MeshShader Program = LoadProgram(file_manager->getAsset("shaders/transparent.vert").c_str(), file_manager->getAsset("shaders/transparent.frag").c_str()); attrib_position = glGetAttribLocation(Program, "Position"); attrib_texcoord = glGetAttribLocation(Program, "Texcoord"); + attrib_color = glGetAttribLocation(Program, "Color"); uniform_MVP = glGetUniformLocation(Program, "ModelViewProjectionMatrix"); uniform_TM = glGetUniformLocation(Program, "TextureMatrix"); uniform_tex = glGetUniformLocation(Program, "tex"); diff --git a/src/graphics/shaders.hpp b/src/graphics/shaders.hpp index b9d904756..000eb1db6 100644 --- a/src/graphics/shaders.hpp +++ b/src/graphics/shaders.hpp @@ -210,7 +210,7 @@ class TransparentShader { public: static GLuint Program; - static GLuint attrib_position, attrib_texcoord; + static GLuint attrib_position, attrib_texcoord, attrib_color; static GLuint uniform_MVP, uniform_TM, uniform_tex; static void init(); diff --git a/src/graphics/stkmesh.cpp b/src/graphics/stkmesh.cpp index 1f18ad4d3..fecc72506 100644 --- a/src/graphics/stkmesh.cpp +++ b/src/graphics/stkmesh.cpp @@ -815,7 +815,7 @@ void initvaostate(GLMesh &mesh, TransparentMaterial TranspMat) break; case TM_DEFAULT: mesh.vao_first_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer, - MeshShader::TransparentShader::attrib_position, MeshShader::TransparentShader::attrib_texcoord, -1, -1, -1, -1, -1, mesh.Stride); + MeshShader::TransparentShader::attrib_position, MeshShader::TransparentShader::attrib_texcoord, -1, -1, -1, -1, MeshShader::TransparentShader::attrib_color, mesh.Stride); break; } mesh.vao_glow_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer, MeshShader::ColorizeShader::attrib_position, -1, -1, -1, -1, -1, -1, mesh.Stride);