I am struggling with some simple and yet hard problem, and need some help…
Trying to render this simple scene.
White rectangle has Z value of 0.001, while green looking triangles have Z value of 0, so if i correctly understood opengl coordinate system white rectangle should be closer to the came than grass.
What i am doing wrong here? If i change the order of object creation, e.g. white rectangle last - everything works correctly, but i assume this kind of things should be handled without manual sorting on GPU itself?
Projection is created like this:
glm::mat4 projection = glm::perspective(1.f, 1.f, 0.0f, 25.0f); glm::mat4 model = glm::mat4(1.0f); glm::vec3 cameraPosition = glm::vec3(0, 0.5, 1); glm::vec3 cameraLooksAt = glm::vec3(0, 0.5, 0); glm::vec3 cameraHead = glm::vec3(0, 1, 0); glm::mat4 mvp = projection * glm::lookAt(cameraPosition, cameraLooksAt, cameraHead) * model;
Everything regarding the camera works perfectly, i can rotate it, bring it closer to these objects or even flip, everything works logically to me and correctly, except this z-coordinate situation.
What i am doing wrong?