Skybox rendering best practices
What are the "best practices" for rendering a skybox?
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).
Some time ago I found skydome sample like here: http://www.rastertek.com/tertut10.html
But I wonder: is it a good idea to create a sphere for rendering sky?
Any ideas why is it better than sampling from cube?
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.
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.
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!