Sign in to follow this  

Skybox rendering

Recommended Posts

I've been trying to implement skybox rendering. I have it mostly working, except that when I move the camera, the polygons of my skybox will sometimes flicker out of view, showing the backdrop color behind it.

I'm using a textured cube with the vertex order reversed to represent the skybox.

I'm setting the depthstencilstate to this:


My vertex shader looks like this:

VS_OUT VS(float3 Pos : POSITION, float2 Tex: TEXCOORD0)
VS_OUT output = (VS_OUT)0;
//make z and w the same so that the depth is always considered 1
return output;

I'm rendering the skybox after everything else. Could this just be a problem with my graphics card? I'm currently running on an intel integrated card on my laptop with dx9.

It all works perfectly except for when I start to move or rotate the camera.

Edit: I was able to try it on another computer, and the problem disappeared. So it must have something to do with the intel card. Is there any way I could prevent this problem from occurring though?

Share this post

Link to post
Share on other sites
In my implementation [DX10], I had to set the depth test to D3D10_COMPARISON_LESS_EQUAL so that the skybox is always in front of the background of the scene (I mean even if the sybox depth and z buffer cleaning value are both 1.0)

If I don't apply this test type (just LESS), some pixels of the skybox are not rendered (because these are exactly at the same depth than the background : 1.0)

I hope that may help (?) :rolleyes:

Share this post

Link to post
Thanks for the reply! I'm still having some trouble getting it to work though.

My skybox cube is 2 units long along each side. My scene is 4096 units long.

If I use the regular depth settings on the viewport when rendering the skybox, I can't see anything except the skybox, which is how it should behave since the geometry is so small.

When I set the depth settings on the viewport to both 1, I can see for a little ways, but my skybox still appears to intersect the scene geometry. I've made sure i'm using the same viewprojection matrix for both the scene and the skybox.

If I increase the scale factor of the world matrix of the skybox to a very high value (1000), I am able to get it to not intersect the geometry. If I have the scale set to 1000, but I set the viewport depth settings back to normal, it will still intersect the scene geometry. So I at least know that settings the depth values to 1 is helping to some degree. Should this be expected? I'd rather not have to worry about setting the scale of the skybox depending on how large the scene is. My understanding is that setting the viewport to always use 1 as the depth value, and LESS_EQUAL as the comparison operator should cause the skybox to never intersect the scene geometry.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this