1

I have a simple solar system simulation where the planets orbit the Sun. But I want to create a starry background, it doesnt have to be an accurate representation.

I tried downloading a picture of a star sky, then map that as a texture to a large sphere. Then place the sphere so it encompasses the entire scene, but no matter the picture, they were all very dim. At least, i think. I couldnt even see the stars. When I shrunk the sphere down, then I could see it was actually texturing it, but it wasnt bright at all.

Are there any other ways to go about doing this? Thanks

Alonzo Robbe
  • 465
  • 1
  • 8
  • 23
  • 2
    Have you tried disabling lighting for the sphere? – Matt Lacey May 21 '18 at 06:26
  • Use a cube map texture. And remember to draw it without lighting it (only texture). – Dori May 21 '18 at 06:28
  • What you are attempting is a sky dome. Either increase the resolution of the sky bitmap or reduce the size of the sky dome. Disable default lighting. – seccpur May 21 '18 at 06:54
  • What you are attempting is a sky dome. Either increase the resolution of the sky bitmap or reduce the size of the sky dome. Disable default lighting. – seccpur May 21 '18 at 06:56
  • 2
    without code,texture and screenshots we can only quess. The problem might be anywhere (wrong color, lighting, resolution etc). see [swift sphere combine star data](https://stackoverflow.com/a/40171880/2521214) for hybrid approach and [Is it possible to make realistic n-body solar system simulation in matter of size and mass?](https://stackoverflow.com/a/28020934/2521214) for some additional ideas and stuff ... – Spektre May 21 '18 at 07:06

1 Answers1

0

You're almost there!

  1. You need to disable lighting for the sphere, so even if it's not lit you can see the texture.
  2. Additionally you'll want to enable self-illumination so the stars emit their own light.

Also you might want to look into skyboxes which are the standard way for non geometrical environments in 3D scenes.

Peter O.
  • 32,158
  • 14
  • 82
  • 96
Ethyl
  • 136
  • 2
  • 6
  • I used `glDisable(GL_LIGHTING)` (then enabled it ) then drew it, but I still cannot see the sphere. could it be maybe the texture itself is stretching too much? Is there a way to make it so the texture stays the same size, but gets pasted onto the sphere multiple times to cover it? – Alonzo Robbe May 24 '18 at 11:17
  • Actually Ive just found out that the inside of the sphere isnt actually seen. So the problem isnt that its too dark, its that the inside of the sphere isnt textured. Mightve been common knowledge, but was news to me. Is there any way to texture the inside or should I just not bother with this method? – Alonzo Robbe May 24 '18 at 12:04
  • Ok nvm. So I just `glScalef(-1,-1,-1)` and placed it at the centre of the scene. good enough for me – Alonzo Robbe May 24 '18 at 12:10
  • There might be multiple reasons why your sphere is not being rendered. The first is lighting (if it's too far from a light, it'll be dark - 100% shadows). It might also be too far from the camera (far clip plane). Once you got it rendered, you have to check the mapping coordinates that stretch your texture, so you have to find the right setup to map your texture to a sphere (you might want to switch to a cube and use a proper skybox texture though) – Ethyl May 24 '18 at 12:28