Realistic looking earth

Started by
4 comments, last by hero79 19 years, 1 month ago
Hello, i`m just a beginner in 3d programming and i`d like to create realistic looking earth in opengl, could anybody help me with some theory how to do that ? Thanks.
Advertisement
I don´t know how much you´ve managed to do already... but:

First of all, you should probably learn to load a texture, then to apply it on a surface. Some of the tutorials on nehe.gamedev.net show how to do that... if you don´t learn how to put a texture on a simple surface, you won´t understand how to put it on an earth-shaped object.

When you´ve learnt how to put textures on a simple surface (like a plane or a rectangle), try putting it on a sphere (since planets are shaped like that). You can probably do something like this (at least it´s what I just did in my solar system project):
glBindTexture(GL_TEXTURE_2D, texture_id[0]);}; //if texture_id are pointers to the textures.
glutSolidSphere(k, x, y);

next step is to find a good earth texture in the right format, http://vrml.base.com/vrml/archive/space/mars.sgi.com/worlds/CyberMarz/earthTexture.jpg is probably fine if you are able to load textures from jpeg files.

You should also change the two glTexGeni calls which you have somewhere in the code, to make the texture on the sphere look good, into:

glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);

After that, you should probably be done. And the earth should look just fine, unless I forgot something. =)

Btw, this is how earth in my solar system project is looking for the moment:
http://www.darkbits.org/~anders/sun.jpg
I´ve also added light to it (coming from the sun), so that´s why the side which is facing away from the sun is dark.
It all depends on definition of realistic.

Advanced stuff can contain multiple procedural algorithms, LOD algorithms, and a library of shaders. Basically, a year of development from a dedicated programmer.
He is a beginner, so he probably just means a sphere with earth textures.. at least that´s how I would define a realistic looking earth. =)
Here are highly detailed earth textures from NASA (21600 x 21600 pixels). This site has them in smaller and more convenient form.

Basic steps to create a good looking earth from that:

1) Download the textures, scale them down to a reasonable size.
2) Render a sphere with OpenGL, and map the texture onto it.
3) For better effect, you can add some simple lighting.
4) Voilà - an earth :)

You can add some cool pixelshader magic later on, maybe to get a glowing atmosphere or moving clouds.
Thank ppl. I`ll try Vindicator`s explanation.

This topic is closed to new replies.

Advertisement