Thanks for your responses.
Is there, by any chance, texture coords in vertices bigger than 1.0?
No I manually input the data:
m_tileMesh = new MESH[m_numOfTiles];
VERTEX Vertices[4];
for (int x = 0; x < m_width; x++)
for (int z = 0; z < m_height; z++)
{
// VECTOR2f is the texture coordinate
Vertices[0] = VERTEX(VECTOR3f(x + 0.5f, z + 0.5f, 10.0f), VECTOR2f(0.0f, 0.0f), VECTOR3f());
Vertices[1] = VERTEX(VECTOR3f(x + 0.5f, z + -0.5f, 10.0f), VECTOR2f(1.0f, 0.0f), VECTOR3f());
Vertices[2] = VERTEX(VECTOR3f(x + -0.5f, z + -0.5f, 10.0f), VECTOR2f(1.0f, 1.0f), VECTOR3f());
Vertices[3] = VERTEX(VECTOR3f(x + -0.5f, z + 0.5f, 10.0f), VECTOR2f(0.0f, 1.0f), VECTOR3f());
uint Indices[] = { 0, 1, 2, 0, 2, 3 };
m_tileMesh[z + x * m_width].LoadNewMesh(Vertices, 4, Indices, 6);
}
I must say again that using just ONE of the textures works just fine, that being any of them, but using 2 or more at once makes it bug out.
First of all, I have no idea why you're doing the "multiply texture colour by texcoords" thing - no offense intended, but that just seems ... insane.
I'm trying to make an rts game, and as such the tiles need to blend. Each corner of every tile is a seperate texture, so I'm needing to blend 4 textures together (or 3 really since it's 2trangles for each quad, but im not optimizing yet, just trying to get it working).
Secondly, we'll also need to see your glActiveTexture, glBindTexture and glUniform1i calls for setting up the textures and for associating uniform locations with each texture unit. Your shader looks fine (aside from that weird colour * texcoord thing) so it's more probable that the problem you're having is in these calls.
Ok here we go:
void MAP::DrawMap()
{
// Makes this shader the current shader
m_shader->Bind();
// m_shader->GetProgramID() get's the ID of the shader.
glUniform1i(glGetUniformLocation(m_shader->GetProgramID(), "gTex0"), GL_TEXTURE0);
glUniform1i(glGetUniformLocation(m_shader->GetProgramID(), "gTex1"), GL_TEXTURE1);
glUniform1i(glGetUniformLocation(m_shader->GetProgramID(), "gTex2"), GL_TEXTURE2);
glUniform1i(glGetUniformLocation(m_shader->GetProgramID(), "gTex3"), GL_TEXTURE3);
for (int x = 0; x < m_width; x++)
for (int z = 0; z < m_height; z++)
{
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, m_tilePoint[m_tile[x * m_width + z].m_tilePoint[0]].m_texID);
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, m_tilePoint[m_tile[x * m_width + z].m_tilePoint[1]].m_texID);
glActiveTexture(GL_TEXTURE2);
glBindTexture(GL_TEXTURE_2D, m_tilePoint[m_tile[x * m_width + z].m_tilePoint[2]].m_texID);
glActiveTexture(GL_TEXTURE3);
glBindTexture(GL_TEXTURE_2D, m_tilePoint[m_tile[x * m_width + z].m_tilePoint[3]].m_texID);
m_tileMesh[z + x * m_width].Render(); // Draws the tile
}
}
I try to keep my posts as short as I can.
Also just for reference, here it is rendering ONE of the colors in the shader for the tiles (behind the cubes):
So changing which single texture to make the fragcolor would make it pick the texture in one of the other corners, and they fade out just like this.
Any help is greatly appreciated, or if you know an easier way to blend 4 textures together for my purposes, I would also appreciate your input.
Thanks
Edit: changed the background color to blue, doing "FragColor = color1 + color2;" instead of "FragColor = colorx;" //x being any color, and when adding two colors, it doesn't render anything at all. as in I just see blue background, no black squares.