Create a sphere with soft edges

I am very new to OpenGL and am creating a scientific visualization of the Galaxy. I am using texture mapping to draw the disc and spiral arms of the Galaxy. The galactic hub is a squashed sphere of stars and I’m unsure how to draw that. It should look like a soft glowing ball. Doesn’t have to be perfect, just something without the hard edge of a normal sphere. This also has to be rendered in real-time.

Any pointers would be appreciated.

Why don’t you simply use a (couple of) sprite(s)?

When I think of sprites, I think of something that is billboarded. I don’t think that will work in this case. The galactic bulge is an oblate spheroid (squashed sphere) and I need to show it from various angles. Can that be done with sprites? I guess if I sheared them appropriately they might look OK. Is that likely to be the easiest way?

maybe some sort of metaballs, asociating an alpha factor to the force could work

To answer your question:

Hundreds of sprites randomly scattered in the desired area (3d space)

The max-alpha-value in the sprite should be rather low, so that you need multiple sprites to get full brightness. This will result in a really soft, haze-like volume.

I’m with Riven. If you use a single sprite (or billboard) for every star, the center of your galaxy will be filled with overlapping sprites. Because they are half-transparent, you’ll get the haze you’re looking for.
And because most stars look exactly the same no matter what angle you’re looking at, the billboarding technique won’t be too obvious.

OK, I can probably do that. Couldn’t have a sprite for every star (there are probably 10 billion stars in the core) but I can do a couple of hundred and that should give the desired effect.

There is a totally different possibility that I also don’t know how to do . Maybe someone can help. The Galaxy as a whole has a shape similar to a flying saucer. There is a bulge in the center and then the spiral arms lie in a thin disc that taper to an edge on the periphery of the disc. I have a nice artist’s rendition of a face-on view of the Galaxy. I can use that to texture map the flying saucer shape. I have experimented doing this with just two discs using gluDisk() and it looks pretty nice when rotated.

So, I have no clue how to create the flying saucer shape. Is it feasible to do something like this programmatically, or should I use some modeling tool to create it? Can JOGL even read something written by a modeling tool? Can you recommend a free or at least inexpensive tool to do this with.

See, lots of questions. That’s why this is posted in the “Newless clubie” section.

Thanks everyone for the help.

Bill

I believe this is a practical, rather than an openGL question :slight_smile:
This is where I think a little math kicks in. If you find a function that correctly describes the maximum “height” of stars, given the distance of the centre, you have your bounds, and you can generate some random stars. A Gauss curve looks like a good start.

In my example, the XY plane is flat, and the Z coordinate is the height

for 100 stars, do the following:
{
  x = random number between -1 and 1
  y = random number between -1 and 1

  if you want more stars in the centre, you could do x = x*x and y = y*y a couple times
  d = distance off center = Math.sqrt(x*x + y*y)

  z = random number between  - Math.E^(-(d^2)) and + Math.E^(-(d^2))
}

now you have a set of stars, with coordinates between -1 and +1 for x,y and z. There will be a bias for the centre of the galaxy, and near the centre, the galaxy will be “thicker”. The only part I’m not sure how to do easily is the spirals. Perhaps you’ll need to venture into polar functions for that?

The other way would be to fire up your favorite 3D editor, and manually place as many vertices as you would like stars in your galaxy. Since you place them manually, you can make sure there are more vertices (=stars) in the middle, and the total of the galaxy gets this nice flying saucer-shaped … shape ::slight_smile:
If you export it to Alias/Wavefront .obj format, you’ll find it’s a text file and it’s VERY easy to parse.

Thanks for the response, but I think you misunderstood the new technique I proposed. Rather than do this as a particle system, I wanted to explore the possibility of creating a flying saucer-like shape out of triangles (or quads, or something) and then texture it with my image of the galaxy. The question is how to model the shape? Rather than brute force, I would think there would be some 3-D modeling application I could use and then load the generated model into my JOGL app. The question would be can JOGL or some additional library be able to read the output of the modeler? Which modeling app to use?

Theoretically, JOGL can handle any file format, but of course, you’ll have to do the programming. You’ll have to write some code that knows the layout of a certain 3D file, and supplies these vertices to the JOGL engine. There are a few model loaders out here (do a search on the boards), and it’s fairly easy to write your own piece of code that can read the Alias/Wavefront .obj format. Almost all editors will let you export to a .obj file.

However, if you display the entire galaxy as a solid model, wouldn’t the old problem of the “hazy” core come up again? Besides, if you move your solid shape, I think the illusion of a galaxy will be lost. It’ll just be a flying saucer with stars painted all over it :wink:
The galaxy is a particle system, after all 8)

[quote]I’m with Riven.
[/quote]
Well, I’m with bahuman on this one.

A solid geometry is about the opposite of the effect you wanted. It won’t look fuzzy at all, and you’ll suffer from ugly ‘artifacts’ as certain triangles will get invisible as they lay on exactly the same plane as the camera-to-triangle plane (what’s the name) … most other triangles will show a skewed texture for this very same reason.

It will really look … crap :slight_smile:

enjoy

DP

Nice article, but unfortunately not at all what the OP needs.

why not? Modify the shaders to sample from the near texels and smooth out using the bluring techniques in that article…

He wanted smoothed edges, he can get smoothed edges with that technique…

DP

Because a galaxy based on solid geometry is a bad idea, as described above.

You have to read between the lines - not giving what is asked for, but what is needed.