So I’ve almost finished my tile based colored lighting system for my game, but I’m having an issue when using the color blending.
To set the RGB levels for each tile, I use the following code which is based off my own ‘Buffer Object’ class:
(‘bo’ is an instance of the buffer object class)
bo.bindImage(i);
bo.setDepth(Tile.yPosToDepth(y) - 1.0f); //This line is not important to this issue (At least I don't think it is!)
bo.setRGB(r0, g0, b0);
bo.setUV(txmax, tymin);
bo.addVertex(x + tileSize, y + tileSize);
bo.setRGB(r1, g1, b1);
bo.setUV(txmin, tymin);
bo.addVertex(x, y + tileSize);
bo.setRGB(r3, g3, b3);
bo.setUV(txmin, tymax);
bo.addVertex(x, y);
bo.setRGB(r2, g2, b2);
bo.setUV(txmax, tymax);
bo.addVertex(x + tileSize, y);
This gets compiled exactly as you’d expect it to into a VBO. However the colour blending is not working properly when I use textures as shown in this image:
As you can see, the blue only shows up on the grey texture, not on the green.
However when I replace all my tiles with white textures I get the following result:
So the colour blending is working correctly!??!
Please note that green and blue lights are working completely fine, it just seems to be an issue with the blue channel.
Here are my texture loading parameters if it is of any help:
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER,GL11.GL_NEAREST);
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER,GL11.GL_NEAREST);
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_CLAMP);
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_CLAMP);
GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, width, height, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, b);
Also note, that GL_BLEND is enabled, in the images, the player’s shirt is green but that is still blending correctly and the random squares are rain, so just ignore them!
Thanks in advance!