This is my first post on the forums. I’m having what I believe to be some depth-test related issues? For example, in the first image you can see through the nearest wall to the furthest one behind it. This can also be seen in the second image? I know a common mistake can be forgetting “GL_DEPTH_BUFFER_BIT” when calling glClear but I’ve double checked and the flag is indeed set.
Hum, this looks like the bug I have been stuck with for the last 3 days: A whitish overlay coming from nowhere. In my case, it looks like an uninitialized 2nd texture superimposed. I am also getting the bands like on your 1st shot in the back. The catch is I am only using one texture stage. And you?
If the checkerboard we sort of see on the floor and ceiling is part of your intended texture with the right spacing, then I’d say you also have something superimposed. Is it consistent? In my case the ghost texture will vary from plain white to snow, to a random image based on what I have run before. I describe it in the previous thread with the shader and a few routines I use.
Hey, thanks for the reply. I don’t think my issue is with texturing, I believe it’s more a depth issue since the farthest wall is visible instead of the nearest wall. Similarly, in the second picture, faces/polygons which shouldn’t be visible are visible. Have added a third image, this one is more of a close-up of the second.
It’s currently set to counter-clockwise, changing it to CW didn’t do anything for it, I also tried disabling culling and the issue persists. You can see in the image below, where the dress is being drawn in favor of the hand (which is closer to the camera and no the camera is sufficiently far away so it’s not just clipping through).
I am inverting the vertex positions z component, I did this when loading obj files with DX11
Well, there’s your problem. DirectX uses a left handed coordinate system OpenGL a right handed one, so no need to invert the z axis.
And the questions about the defaults where mostly in case you change them elsewhere in your code and have a code path that does not set them back to the expected values.
Thank you for the reply, thing is I tried removing the inversion while trying out the other suggestions made and even with the inversion removed the model still renders incorrectly? See the image below:
This isn’t what Carsten is talking about. He’s talking about the near/far distances in the projection matrix (gluPerspective or similar). If the near distance is too small, the depth buffer resolution will be too coarse in most of the scene.
The default depth range setting (equivalent to glDepthRange(0.f, 1.f)) is fine.
If the model isn’t symmetrical about the Z=0 plane, inverting the model’s Z will be visibly apparent. If the model is symmetrical, inverting its Z won’t matter (except that it will reverse the winding direction, which only matters if you’re using glEnable(GL_CULL_FACE) or two-sided lighting).
How are you generating the projection matrix? If you aren’t using gluPerspective, check that the resulting matrix matches that in the gluPerspective documentation in terms of signs. The signs should look like:
[+ 0 0 0]
[0 + 0 0]
[0 0 - -]
[0 0 - 0]
The model-view matrix should have a positive determinant and be affine (i.e. the bottom row should be [0 0 0 1]).
Hi, thanks for getting back to me. I’m using glm perspective with fov: 90, aspect ratio: 4/3, near: 0.0 and far 1.0. The resulting matrix though is mostly empty? The signs are + along the top row with the others being zero… this is extremely frustrating.
Never use a near value of 0, it breaks the math used for the projection, see also the “Notes” section of gluPerspective. You can use a small positive number for near, but generally want to use as large a value as possible considering the size of the scene - if possible keep the ratio of far/near below 10^5 for good depth buffer resolution.