2
I’m having a problem with the Depth Test
. I have a scene where it contains three objects. A plane a cube and a cylinder. In my Render I am doing for when rendering the cube it should disable the Depth Test. With this the cube (orange) should overlap the plane (green) and the cylinder (blue). But this does not happen.
Render normal with Depth Test on and in GL_LEQUAL mode.
Render with Depth Test off only for cube.
The cube overlaps the green plane, but does not overlap the blue cylinder.
void HOpenGLForwardRenderer::RenderOpaqueMesh(HGameObject* gameObject, HMaterial* material, HShader::HRenderPass pass)
{
gEngine = HEngine::GetInstance();
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);
glDepthMask(true);
if (gameObject->mName == "Cube.1") {
glDisable(GL_DEPTH_TEST);
}
else {
glEnable(GL_DEPTH_TEST);
}
glDepthFunc(GL_LEQUAL);
glUseProgram(pass.gpuProgram);....
What could I be doing wrong? I’m using Opengl 2.1 and three shaders one for each object but with the same code (only changes color).
#version 120
uniform mat4 HEngine_MatrixMVP;
attribute vec3 in_Position;
void main()
{
gl_Position = HEngine_MatrixMVP * vec4(in_Position, 1.0);
}
#version 120
void main()
{
gl_FragColor = vec4(0.8, 0.4, 0, 1);
}