Attempt to fix skidding mark's color

This commit is contained in:
Vincent Lejeune 2014-03-19 01:25:44 +01:00
parent d9c5d415cd
commit 9a6d15a865
5 changed files with 9 additions and 3 deletions

View File

@ -2,6 +2,7 @@ uniform sampler2D tex;
#if __VERSION__ >= 130 #if __VERSION__ >= 130
in vec2 uv; in vec2 uv;
in vec4 color;
out vec4 FragColor; out vec4 FragColor;
#else #else
varying vec2 uv; varying vec2 uv;
@ -11,5 +12,5 @@ varying vec2 uv;
void main() void main()
{ {
FragColor = texture(tex, uv); FragColor = texture(tex, uv) * color;
} }

View File

@ -4,7 +4,9 @@ uniform mat4 TextureMatrix;
#if __VERSION__ >= 130 #if __VERSION__ >= 130
in vec3 Position; in vec3 Position;
in vec2 Texcoord; in vec2 Texcoord;
in vec4 Color;
out vec2 uv; out vec2 uv;
out vec4 color;
#else #else
attribute vec3 Position; attribute vec3 Position;
attribute vec2 Texcoord; attribute vec2 Texcoord;
@ -16,4 +18,5 @@ void main()
{ {
uv = (TextureMatrix * vec4(Texcoord, 1., 1.)).xy; uv = (TextureMatrix * vec4(Texcoord, 1., 1.)).xy;
gl_Position = ModelViewProjectionMatrix * vec4(Position, 1.); gl_Position = ModelViewProjectionMatrix * vec4(Position, 1.);
color = Color;
} }

View File

@ -873,6 +873,7 @@ namespace MeshShader
GLuint TransparentShader::Program; GLuint TransparentShader::Program;
GLuint TransparentShader::attrib_position; GLuint TransparentShader::attrib_position;
GLuint TransparentShader::attrib_texcoord; GLuint TransparentShader::attrib_texcoord;
GLuint TransparentShader::attrib_color;
GLuint TransparentShader::uniform_MVP; GLuint TransparentShader::uniform_MVP;
GLuint TransparentShader::uniform_TM; GLuint TransparentShader::uniform_TM;
GLuint TransparentShader::uniform_tex; 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()); Program = LoadProgram(file_manager->getAsset("shaders/transparent.vert").c_str(), file_manager->getAsset("shaders/transparent.frag").c_str());
attrib_position = glGetAttribLocation(Program, "Position"); attrib_position = glGetAttribLocation(Program, "Position");
attrib_texcoord = glGetAttribLocation(Program, "Texcoord"); attrib_texcoord = glGetAttribLocation(Program, "Texcoord");
attrib_color = glGetAttribLocation(Program, "Color");
uniform_MVP = glGetUniformLocation(Program, "ModelViewProjectionMatrix"); uniform_MVP = glGetUniformLocation(Program, "ModelViewProjectionMatrix");
uniform_TM = glGetUniformLocation(Program, "TextureMatrix"); uniform_TM = glGetUniformLocation(Program, "TextureMatrix");
uniform_tex = glGetUniformLocation(Program, "tex"); uniform_tex = glGetUniformLocation(Program, "tex");

View File

@ -210,7 +210,7 @@ class TransparentShader
{ {
public: public:
static GLuint Program; 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 GLuint uniform_MVP, uniform_TM, uniform_tex;
static void init(); static void init();

View File

@ -815,7 +815,7 @@ void initvaostate(GLMesh &mesh, TransparentMaterial TranspMat)
break; break;
case TM_DEFAULT: case TM_DEFAULT:
mesh.vao_first_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer, 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; break;
} }
mesh.vao_glow_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer, MeshShader::ColorizeShader::attrib_position, -1, -1, -1, -1, -1, -1, mesh.Stride); mesh.vao_glow_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer, MeshShader::ColorizeShader::attrib_position, -1, -1, -1, -1, -1, -1, mesh.Stride);