SkyBox - need help

Recommended Posts

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?

Share on other sites
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.

Share on other sites
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.
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 szecsThat way you never have to clear the depth buffer at all, because the skybox will do it for you.
This 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.

Share on other sites
Wow tnx for the fast replies. Your both solutions sounds good. i'll try the second
one because its more generic ( I don't need to change the application code ).

tnx guys.

Create an account

Register a new account

• Forum Statistics

• Total Topics
628381
• Total Posts
2982360

• 10
• 9
• 15
• 24
• 11