Jump to content
  • Advertisement
Sign in to follow this  

Skybox rendering

This topic is 2552 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Messing with the projected z and w coordinates can screw things up. An easier approach is to use the viewport to force the Z value to 1. Just set MinDepth and MaxDepth to 1.0.

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
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!