SkyBox - need help
Hi,
How can i make the sky box be infinite far away?
I have tried to tide up the box to the camera , so when the camera moves,
the box moves with it. but its not perfect because on some point, the box will
start clipping the scene objects.
can anyone have better idea?
You are on the right track.
+ Render the skybox first, but disable depth test, so the box won't write the depth buffer, so won't clip anything.
Or you can set depth range to 0.99999 to 1.0 when drawing the skybox, and set depth test to GL_ALWAYS. That way you never have to clear the depth buffer at all, because the skybox will do it for you.
+ Render the skybox first, but disable depth test, so the box won't write the depth buffer, so won't clip anything.
Or you can set depth range to 0.99999 to 1.0 when drawing the skybox, and set depth test to GL_ALWAYS. That way you never have to clear the depth buffer at all, because the skybox will do it for you.
If you're using shaders, there's an easy trick that makes geometry become infinitely far away.
After transforming your vertex position in the vertex shader, set the z component to equal the w component.
At the pixel level, depth is computed by dividing z and w -- so if z and w are the same thing, depth comes out as 1.0 (100% depth), which means it's always at your camera's far plane.
After transforming your vertex position in the vertex shader, set the z component to equal the w component.
position = ...;position = position.xyww;//i.e. position.z = position.w
At the pixel level, depth is computed by dividing z and w -- so if z and w are the same thing, depth comes out as 1.0 (100% depth), which means it's always at your camera's far plane.
Quote:Original post by szecsThis used to be good advice, but on modern GPUs that use ZBuffer compression, you're advised to clear the depth every frame. These days clearing the ZBuffer is extremely fast, and if you don't clear it then the compression scheme eventually starts hurting performance instead of increasing performance.
That way you never have to clear the depth buffer at all, because the skybox will do it for you.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement