Render the sky -Texture on a sphere
843799Aug 6 2004 — edited Aug 10 2004I have a camera at an arbitrary 3d position an 3d angle.
I manage to render objects correctly according to their position relative to the camera.
Bet now I want to add some objects that are infinitely far away. (Like stars on the sky.)
How can I accomplish that?
My idea is to place a sphere around the camera, and then render texture on the inside of that sphere. I let the sphere move along with the camera so that the camera always is located in the middle of the sphere (I simply disregard the position of the camera). The texture painted on the inside of the sphere should now look like objects infinitely far away.
So,
When I render a pixel that is part of the sky, I calculate the xyz coordinates of the part of the sphere to render... (and then I am stuck!)
How do I transform xyz Cartesian coordinates (denoting a point on a sphere) to 2d bitmap coordinates?
How do I map a texture to a sphere (I only know how to map it to a polygon...)?
Or is there perhaps a better way to render the starts on the sky?