I'm having some trouble with rendering Master Cheif in Java using LWJGL and GLSL shaders where the is some flickering, dissapearing of polygons and strange colouring. And for the life of me I can't figure out why.
What it should look like:
What it does look like when I move the camera a little:
Shaders: https://github.com/marko5049/LucidEngine/tree/master/src/res/shaders
MainShaders: LightingMain ShdaowMapping Smapler Filters
All the code: https://github.com/marko5049/LucidEngine
StaticMesh:
public void addVertices(Vertex[] vertices, int[] indices, boolean calcNorm) {
if(calcNorm) {
vertices = calcNormals(vertices, indices);
}
handler.setSize(indices.length);
EngineCore.polycount += indices.length/3;
glBindBuffer(GL_ARRAY_BUFFER, handler.getVbo());
glBufferData(GL_ARRAY_BUFFER, Util.createFlippedBuffer(vertices), GL_STATIC_DRAW);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, handler.getIbo());
glBufferData(GL_ELEMENT_ARRAY_BUFFER, Util.createFlippedBuffer(indices), GL_STATIC_DRAW);
}
private void finalDraw(int typeIndex) {
glEnableVertexAttribArray(0);
glEnableVertexAttribArray(1);
glEnableVertexAttribArray(2);
glEnableVertexAttribArray(3);
glBindBuffer(GL_ARRAY_BUFFER, handler.getVbo());
glVertexAttribPointer(0, 3, GL_FLOAT, false, Vertex.SIZE * 4, 0);
glVertexAttribPointer(1, 2, GL_FLOAT, false, Vertex.SIZE * 4, 12);
glVertexAttribPointer(2, 3, GL_FLOAT, false, Vertex.SIZE * 4, 20);
glVertexAttribPointer(3, 3, GL_FLOAT, false, Vertex.SIZE * 4, 32);
glVertexAttribPointer(3, 3, GL_FLOAT, false, Vertex.SIZE * 4, 44);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, handler.getIbo());
glDrawElements(typeIndex, handler.getSize(), GL_UNSIGNED_INT, 0);
glDisableVertexAttribArray(0);
glDisableVertexAttribArray(1);
glDisableVertexAttribArray(2);
glDisableVertexAttribArray(3);
}