I created a skybox in OpenGL (through LWJGL), but the only way I found to render it behind all objects was to make it very big. This leads to ugly edges between the 6 skybox planes.
Optimally, I would draw a small skybox and disable DepthTesting on all other objects, but since I want those to display in the right depth order, that isn't possible.
How can I do this?
Answer
glDepthRange (1, 1);
Job's a good 'un, done.
How this works:
glDepthRange()
remaps depth values for the purpose of interacting with the z-buffer. Setting glDepthRange(1,1);
makes every fragment, regardless of how close or far it actually is from the camera, be treated as if it was exactly at the far plane.
Remember to return it to its default glDepthRange(0,1)
-setting before drawing other objects. Further details in this StackOverflow question.
No comments:
Post a Comment