Jump to content

Making stars bright enough to see from lightyears away


Recommended Posts

I'm trying to build a realistic 3D star map.

But my stars are too faint to see, because they are far away. I need them to be far away so the constellations look right from Earth.

I'd like the light from the stars to have infinite range, even if they end up being single pixels to the camera.

I have set up a playground where I had hoped to see the constellation Orion, but I see no stars.

Here is the playground:


My actual database has over 100,000 stars, but I can limit the ones I draw to only the brightest N if needed.

In the end, I'd like to animate a faster-than-light trip from star to star.

Link to comment
Share on other sites

Instead of using just a sphere to represent each star, I'd take a hybrid LOD approach, using a single mesh rendered as a point cloud for all stars in the database e.g. like this PG


If material.pointSize = 1 then all stars should be visible irrespective of distance.

Then I'd use a star mapped billboards for stars when they are closer, centred on (and hiding) the respective point. Then for close stars I'd use a sphere. 

I made a celestial sphere from the Tyco2 star data many years ago using a similar approach, which displayed points and mapped tris that accurately depicted star magnitude and colour etc.

Link to comment
Share on other sites

Since the camera supposedly will be around our solar system, the stars don't actually have to be at their true distances, just have to appear at their correct location in space, relative to the camera; so you could scale down the distances quite a bit. Changing px_per_ly to .01 already makes them appear.

Link to comment
Share on other sites

Your sun is at 0,0,0, and earth.x is -100.  From where your camera is, the distance between sun & earth is about half of my display.  Some of your x's are > 10k.  That is about 10 feet to the right of my display. 

The Z of your Rigel is -24k, but your camera's Z is only -300.  Rigel is way way way behind the camera.  I moved the camera z_offset to -2000, and the sun approached 4 pixels.  I do not think that light is your problem.

Link to comment
Share on other sites

Thank you all for the help -- I'm getting much closer to a solution.

In reverse order:

JCPalmer -- You are absolutely correct. The camera was not aimed at Orion, so the stars seemed to be all over the place. I fixed that in the following playground.

Convergence -- You are also absolutely correct. I was not clear in my problem statement. If the camera is stuck on Earth, we can play games with the distances. But my plan is to allow the user to travel from star to star, and watch how the constellations change as the perspective changes. In the following playground, I multiply the distance by 0.01 as you suggest, and the stars do indeed appear. However, they are not quite in the right places, because that will only happen if they are very far away. Changing 100,000 star positions to get them to look right at closer distances is not a task I feel capable of completing. :-)

That said, the suggestion to make them closer was a great help in discovering my other problems, and at least now you can see something that almost looks like Orion. I was ecstatic when that happened.

Inteja -- I am convinced that your suggestion is the way to go. However, I am too new at Babylon.js to figure out what I am doing wrong when I try to implement it. I think there is something fundamental about mesh creation that I don't understand yet.

In this playground:


there is a variable called use_custom_mesh. When it is false, you can see Orion, thanks to Convergence's help. When it is true, you can see my failed attempt to make a mesh out of the star positions. Is it easy for anyone to see what I am missing? I've been looking at playgrounds that create meshes, and I can't see what I am doing wrong.

Thanks again to all of you -- I think I am getting really close...


Link to comment
Share on other sites

Along the lines of scaling to 100,000 stars, you will not get there.  The actual number I do not know, but you cannot have that many meshes each with its own material.  You can get down to 3 meshes earth, sun, & masterStar, and making all the stars instances of masterStar(instances must use the same material, or the sun could be used).  This will reduce your draw calls to 2, and the geometry to load to the gpu.

You will then have a javascript problem.  Each frame, the render thread will have to calculate a 16 element world matrix for each mesh, whether it is a instance of not.  This contains the location, scale, and rotation.  You cannot get rid of the checking on of each, but since the stars are fixed, you can make the calc be avoided by freezing.  See  http://www.babylonjs-playground.com/#OCR2S#6    Not sure why my sun is read.

The points cloud will not let you travel to them, I think.  When you get there they should no-longer be points.

Link to comment
Share on other sites

In this playground:


I have 6,000 stars. I tried 60,000, and my machine could handle it (i7-5960 @ 3 GHz and 64 GB of ram),

but things got slow, so I backed off. I'd like it to run on cheap laptops. :-) 6,000 stars is more than the naked eye can see, so I think it will do nicely. I'll recalculate which stars are in the 6,000 as we visit each star.

The sun was red for you because your masterStar was on top of it.

I moved that out of the loop, and we got Rigel back in Orion.

We are left with the problem of keeping the stars visible when we go full scale (needed to keep the constellations right, and to prevent nearby stars from being disks). The pointCloud was going to fix that, but I still haven't found out what I am doing wrong there. If there is a way to make the spheres visible at infinity, that would make the pointCloud unnecessary. But I haven't given up on pointCloud -- it still seems to me like it should work.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...