Curvature of the Earth

Started by
15 comments, last by Leif 19 years, 2 months ago
Well hello, I'm currently writing an RTS in which most of the action occurs at sea. The map is massive, being about 250,000 square miles(which isn't a problem storage wise, as it's 99% ocean). Anyway, I want to include a few things to give a sense of scale as well as just make it look better. First, I would like to have ships sink below the horizon, which is pretty easy to do mathematically. I'm unsure of how to do that graphically. Would I just move the ship downwards when I render it? Second, is there any way to make good clouds? I read a gamasutra article awhile ago on the MS Flight Simulator 2k4 clouds, but that was actually more than I need at the moment. Third, I was wondering if there are any good tutorials for doing realistic moving water? As it's a *cough* fairly important part of my game, I would like to make it look good. If it's possible as well, I'm thinking about having two different water animations(shaders, maybe?), one for close by water, and one for far away water, as the two do look different. Ah, any help on any of these would be great! I'm making slow progress(of course...), but it's getting closer every couple years(*cough*). Thanks! Ryan
Advertisement
1) I've never actually spent any time out on the open seas observing what happens, so this is just speculation. I would think that the ship would need to be very large to be able to clearly see it sinking below the horizon. But often times, specifically for games, realistic isn't as important as "cool but still somewhat believable." So just tossing out an idea for it... make sure you the depth value of the ship is far enough to be behind everything else and than you could just slowly translate down so it appears to move behind the water. Again, not too sure how feasible it would be, just a suggestion.

2) I think "planar" clouds (planar in quotes because sometimes the corners of the "plane" are pulled down some to create a curved look) would be great for this situation. Here's the great sky thread in which Yann L goes into a lot of depth of how he did those skies. That whole thread is a definite read if you haven't yet.

3) Here's a great article about water rendering by Yann L. It's a great place to start and if you still need more help after it you should be able to find some help through google or coming back here and asking more questions.

- Kalidor

EDIT: Just reread my post, sorry about all the "great" adjectives. :P
1) Good point, hmmm, maybe I'll work on my other idea, which was a change in time when you moved(if it was a bigger map that covered half the globe, it would become night if you moved from one side to the other, or something like that). That might be easier and probably would add more to the gameplay.

2 & 3) Given a couple years I'll understand those! Just kidding. Those are both really good, although converting the clouds to what I'm doing might take a few small changes as I wanted the clouds between the player and the water.

Thank you very much! :)

Cheers,
Ryanmfw
Quote:Original post by ryanmfw
First, I would like to have ships sink below the horizon, which is pretty easy to do mathematically. I'm unsure of how to do that graphically. Would I just move the ship downwards when I render it?
Don't forget that the water under a ship that is past the horizon is also past the horizon. That means you have to clip the water "plane" at the horizon, or at least don't draw water behind the ship. Also, you can draw the water surface as a dome instead of a plane and get a horizon that way.
John BoltonLocomotive Games (THQ)Current Project: Destroy All Humans (Wii). IN STORES NOW!
Quote:Original post by JohnBolton
Quote:Original post by ryanmfw
First, I would like to have ships sink below the horizon, which is pretty easy to do mathematically. I'm unsure of how to do that graphically. Would I just move the ship downwards when I render it?
Don't forget that the water under a ship that is past the horizon is also past the horizon. That means you have to clip the water "plane" at the horizon, or at least don't draw water behind the ship. Also, you can draw the water surface as a dome instead of a plane and get a horizon that way.


I would probably just make it a plane that extends to the horizon(not an infinite horizon), and have ships past there be moved down.

This just made me think of something interesting though, how am I going to make the horizon curved? I guess I'll have to do a dome anyway, which just seems like more work. This is further convincing me to try something else and abandon this bit of realism. :)

Cheers,
Ryanmfw
I use the exact same technique myself, large water plane and have the ships sink lower and lower based on a simple formula that represents the curvature of the earth. It works well and the ships disappear in a natural way. The smoke from them is the first to be sighted and by climbing higher on my own ship I do see a little more of the ships far away. Although it only works as long as your viewpoint are fairly close to the sea level.

The horizon isn’t curved, it’s a flat line.

Leif…
Quote:Original post by Leif
The horizon isn’t curved, it’s a flat line.

True, but amazingly counterintuitive.
Hi,

My seem like the easy solution, but why not just scale the ship down in size has it get closer to the horizen?

And i think NVIDIA has a nice ship and sea demo out...!

Hope that helps,

Rob :-D
Why not doit the "easy" way, and simply make your level curve as an ocean would.
If your map is a sufficiently less than 1/6 of the surface of earth, then you can simply calculate the Z coordinates of your maps vertices so that the length of the vertex vector is R (= radius of earth.) That is if you have a vertex like v= (x,y,0) , you make a new one v'=(x,y,z) where z=sqrt(R-x^2-y^2).
Now all you need to do to make your ships go below horizont is to make sure they stay on the waterline. Also you need to make sure the ships bellies point down to the center of the earth (at (0,0,0)).
If you have islands and they are small enough, you can just place them in the ocean like the ships, or you can do a similar trick on them too.
I recommend you check www.vterrain.org. I'm not sure how often the site gets updated, I haven't been there in a year or two, but they've got articles on stuff like that.
Without order nothing can exist - without chaos nothing can evolve.

This topic is closed to new replies.

Advertisement