Jump to content
  • Advertisement
Sign in to follow this  
hero79

OpenGL Realistic looking earth

This topic is 4874 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

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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. =)

Share this post


Link to post
Share on other sites
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.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!