Jump to content
  • Advertisement
Sign in to follow this  
Riko Ophorst

Skybox rendering best practices

This topic is 571 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 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
Advertisement

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
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!