Not logged in, Join Here! or Log In Below:  
News Articles Search    

Submitted by Jake Wolf, posted on December 14, 2000

Image Description, by Jake Wolf

Here's a shot of a space simulator I am working on. It started out as a project to help me learn OpenGL (already knew DirectX) and it's slowly evolving to a space simulator.

Here are some of the features already available:
  • Starfield and sun that can be randomly generated or loaded from a file.
  • Lighting and blending effects that simulate lighting.
  • Lens flare (still working on "pretty-ing" this one up).
  • Level of detail. Planets use less polygons when far.
  • Fog, to simulate the darkness of space. So that planets gradually come into view when approaching them.
  • Features to come:
  • Dynamic parametric clouds (to simulate gaseous planets like Saturn)
  • A heightmap for solid planets. this way, you'll be able to land or hover on a planets surface. Possibly mix that with a parametric approach to get a better LOD without immense heightmaps. (Anyone has tips or leads on this one? send me an email). thought about bumpmaps but my card does not support them, they kill my FPS.
  • 3ds or mesh file loader so I can add some spaceships to this mess.
  • Right now though, I am busy cleaning my code and making it modular. The demo runs on a P2 333 with a Riva TNT2 16MB at a speed of 30 to 60 FPS (depending of the features switched on). Also, I would like to take this opportunity to thank the folks at Discussion forum for helping me out and answering my questions, especially "Punchey" and "dmy". And of course, for a kick @ss site.

    Jake Wolf

    Image of the Day Gallery


    Message Center / Reader Comments: ( To Participate in the Discussion, Join the Community )
    Archive Notice: This thread is old and no longer active. It is here for reference purposes. This thread was created on an older version of the flipcode forums, before the site closed in 2005. Please keep that in mind as you view this thread, as many of the topics and opinions may be outdated.

    December 15, 2000, 12:51 AM

    Planet shadows are probably the easiest kind. :) Just use projected textures. Unfortunately, that AND material-mapping combined probably won't work too well (to properly do projected textures you need two-pipe multitexturing hardware, and to properly do material mapping you need two-pipe multitexturing hardware, and combining the two would require three pipes, which AFAIK only the Radeon provides).

    Oh, and basically, for doing material mapping with only one specular layer, you can do it without multitexture hardware, though it takes three passes. Simply draw the glossy material layer, set your blend function to GL_ONE_MINUS_SRC_COLOR, GL_ZERO and draw the material mapping texture (I'm assuming it goes from black for 0.0 and white for 1.0 :) and then set your blend function to GL_ONE, GL_ONE and draw the lower (lambertian) material. For more than that, though, you need to do one pass per material, where you just set your blend function to GL_ONE, GL_ONE (except the first layer, so that it'll overwrite stuff behind it in the zbuffer), and draw each layer with one texture unit being the material map, one texture unit being whatever it is for the material itself, and the operation between the two being multiply (i.e. modulate each pass by the material map for that pass's material).

    I don't know how you'd properly combine material maps with projected textures for shadows, in any case. Projected textures are definitely the best way to do a planet shadow, though, since it's very easy to do penumbras and the like. I suppose with a GeForce 2 which has the third 'shader' texture unit (which is basically a 1d-only texture unit) you could fake this by computing the illumination directly (which isn't THAT slow, it's just simple raytracing, and it's easy enough to determine which planets you'd have to trace against to begin with), but my suspicion is it just wouldn't look as good. Actually, you wouldn't even need a third shader unit if you just calculate your own lighting to begin with, or use glColorMaterial to let you modulate the OpenGL lighting with directly-computed shadowing or something... I guess for things on a planetary scale it'd look okay.

    The Wolf

    December 15, 2000, 01:18 AM

    I'll try that, Thanks :)


    December 15, 2000, 04:40 AM

    Just yesterday me and "Punchey" (mentioned above, who is working on a similar project) decided to combine our efforts and start a game,
    Basically it will be a space sim blast some aliens PLUS land on a ship or a planet and blast some more aliens.

    I like it big time!
    You grabbed the essentials of a good game in one sentence, only one question remaining now: how big is(are) my gun(s) in your game?

    The discussion about realism put aside(buy a MIR-ticket, all of you :), I think that your IOTD looks nice


    December 15, 2000, 10:49 AM

    Perhaps a dumb question (I usually stay quiet), but is the sun in the picture there actually the light source?

    Just the reflection from the planet looks like its coming slightly from the left of the sun.

    The Wolf

    December 15, 2000, 12:03 PM

    Cybok^Guideline : I like the way you think, Yes the game will have big and nasty weapons.

    vodzurk : To answer your question (no, it is not a dumb question), the sun you see is a texture, there is a light source at that location too.
    Basically the light is there for the lighting effect, the texture is there so you can "see" the light source.
    The camera is slightly to the left of the planet (that is why the lens flares is a little to the left), so the reflection is slightly to the left.
    hope that answers you question :)


    December 15, 2000, 12:13 PM

    fluffy - why whould you need single-pass multitexturing..?
    just do multipass multitexture, no troubles :)


    December 15, 2000, 02:01 PM

    led: Um, I thought the point of my ramble was that I was saying that you do, in fact, do multipass multitexture. However, certain layerings of effects you can't do easily in a layered manner (such as multiple material maps). Unless there's something obvious that I've been missing...

    Basically, to do multi-layered materialmapping, you need to take the sum of materialmap*material for each rendered material. With only single-texturing hardware, you can fake having two materials where the lower material is all full by doing three passes, material2 + black*(1-materialmap2) + material1, but I see no clear way to extend this for more materials without losing major amounts of precision or accuracy (remember, this is saturated arithmetic, not modulo).

    So to do proper, generalized (as in more than two with any sorts of characteristics) mapped materials (where the materials include a texturemap), you pretty much need two texture units as it is just to do the materials - to add in projected textures would require yet another texture unit. Obviously, for materials without a texturemap you only need one texture unit for the material.

    Actually, if you're only dealing with one shadow-casting lightsource you can always project the shadow texture afterwards, and in a space sim that would be a pretty acceptable setup (since you usually only have one lightsource casting a shadow on the planets :) but you do still get into trouble in, say, binary/trinary/etc. starsystems, and generalizing projected shadowmaps to arbitrary environments is quite difficult. Not that I'd use projected shadowmaps for anything other than a planetary simulation anyway (the reason I brought them up is because most planets are spheres and it's very easy to do projected shadowmaps as a result :)


    December 15, 2000, 02:20 PM

    Listen up, folks.

    1) Space is not dark like a dark fog. Light originates from stars and travels outward.
    2) Planets do not emit any large amount of light. They simply reflect the light from stars.

    If you've ever wondered how we know if other stars have planets orbiting them, it's not because we see them. We see the stars, not the planets. We can measure the planets' sizes and masses basically by analyzing two things: 1) How the star's light dims at certain periods, which is when the planet orbits the star and blocks the view, sort of like a little eclipse, and 2) the star's "wobble" that is caused by the gravitational attraction of the planet. So, of course, it's easier to find out whether nearby stars have planets orbiting them.

    Now that we've gto that straight, check this out: light fades at a rate that is a square of the distance. But that's huge distances. It's not like a planet will suddenly fade into view if you move a couple million miles. A light year is more like a billion miles! And we see regular light from stars 10s of light years away! Anyway... planets shuold be the same up close and far away. Although far away we tend to only "see the light" (pun intended)... so, no real details, just the reflected light which we might mistake for a far-away star even.

    Here endeth the post.



    December 15, 2000, 02:23 PM

    I just want to say,

    Come on, guys, doesn't Kurt drop enough astronomy links oyur way? Or is everyone just totally uninterested in science, opposite to Kurt? Coding is cool, but reality is cooler! ;-)


    December 15, 2000, 04:32 PM

    Ehm, disagree. Coding reality is even more kewl (at least for coders =)).


    December 15, 2000, 10:52 PM

    Greg, your sense of scale is off. A light year is 6 *trillion* miles, IIRC. :)


    December 16, 2000, 01:56 PM

    I just figured I'd add to this post, just for the hell of it
    oh, and here, I have to say "astronomy" and "Lens flare" and "Fog" just one more time too
    one last thing:

    you ppl at the end: the whole astro physics thing was covered in the first 500 posts, stop beating a dead horse and find a different carcase to pick at

    the only "Real" thing I have to say is that as an artist I generally don't think there should be much lens flare unless an object is between the camera and the light source to get an idea of how the "flare" should work watch car headlights at night as they go by, tilt your head left and rightstudy how that works, and stop guessing... your eye is a lens, right?

    that said the sim looks wonerful, and I once thought of a web browser that was part space sim where you could create your own planet (URL)that ppl could find by traveling through space to get there, have dog fights wage planetary wars etc. maybe rent space to businesses to set up their own planet... i don't know, just some ideas

    The Wolf

    December 16, 2000, 02:06 PM

    very cool idea NatureMan, in the future when VRML and bandwidth are better this stuff would be very possible, and very cool

    - Hargle -

    December 17, 2000, 06:34 PM

    I only just saw this IOTD and thought I'd add a bit. Pants earlier comment about light not reaching your eye though diffusion, and inteference, etc, is all true (I guess) but there's also the actual gravitational effect of massive objects on light, that actually 'bends' the light and so can mean that looking directly in the direction of a star might not mean you can see it because the light from the object has been bend away from your eye by gracitational effects...I think ;)


    December 18, 2000, 10:15 AM

    gravitational effects on light will only take place when such massive objects as blackholes are present. Planets and stars (prenova) dont have enough gravitational pull to bend light.

    This thread contains 45 messages.
    First Previous ( To view more messages, select a page: 0 1 ... out of 1) Next Last
    Hosting by Solid Eight Studios, maker of PhotoTangler Collage Maker.