Sign in to follow this  

Skybox rendering best practices

Recommended Posts

I've been wondering about skyboxes lately. I know that a skybox can be rendered as a cube that's always centered around the camera with a cubemapped texture applied to it, but I'm wondering: are there better ways to do this?

What are the "best practices" for rendering a skybox?

Share this post


Link to post
Share on other sites

You can also render a single triangle that covers the entire viewport and use the same cubemap texture :)

 

It used to be that you'd draw the skybox first, and then draw the scene over the top of it. These days you want to draw all the opaque parts of the scene first, and then draw the skybox afterwards (to take advantage of the z-buffer's early rejection).

Share this post


Link to post
Share on other sites

a lot of games till use a sphere actually. The biggest advantage to a sphere vs the box is that with a sphere you can easily procedurally generate your sky.

 

vertex resolution makes color interpolation fluid. It's. Easy to correctly place your sun's sprite as a function of time. You won't have that weird corner case for cube mapped images.

Share this post


Link to post
Share on other sites

then draw the skybox afterwards (to take advantage of the z-buffer's early rejection).

 

good point !  never thought of that!   learn something new every day...


5 quads with individual textures (a box with no bottom) can also be used in lieu of a cubemap texture.  can be less work to create the textures.

Share this post


Link to post
Share on other sites

The advantage of a cubemap is that you can draw it on pretty much any arbitrary geometry and it will look right.  You just don't get that with individual face textures.

 

In modern APIs use seamless cubemapping: this is automatic in D3D but must be explicitly enabled in OpenGL.

 

Set depth range to zNear 1 and zFar 1 to automatically position your sky on the far clipping plane without worrying about sizing the box or other positioning issues (this can alternatively be done in your VS if you'd prefer to avoid the state change).

 

Rotate the texture matrix, draw multiple blended layers, go nuts and have fun: the most important thing is that once you get the basics right there are no other "best practices": let the needs of your program be the boss!

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