Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Subotron

Best way to program a high-detailed, huge (infinite) world

This topic is 5721 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''ve been programming for a few years now with OpenGL/DirectX, and most of the time I''m trying to create a graphics engine that is capable of producing a world that can be as big as I want it to be (read: infinite) so I can create an enormous world. This has always been my goal. In the last few years, I tried different methods of creating virtual worlds. I tried making data files with coords and more info for each polygon/vertex, and load those data files in and display the polies. I tried making heightmaps, and stretching textures on them. I''ve tried some more stuff. What I''ve been working on for the last 6 months was a method which worked this way: I create a heightmap image of 1024x1024 pixels. I create a texture of 2048x2048 pixels. I use the heightmap image to create a map (each pixel of the heightmap image resembles the height of one vertex on the map) and I stretch the texture over the map. Then, using multi-texturing, I add a detail texture over it to get the detail I want. The problems I''ve encountered: 1. The heightmap image cannot be much bigger than 1024x1024, because else there will be too much polygons. I''ve tried solving this using frustum culling & octrees, but the speed gain is not enough to create a heightmap image with nearly-infinite size. Possible solution: Create different heightmap images and load only a few at once. Problem: how do I know which ones to load, and when do I switch (don''t want the landscape to popup suddenly, the change should go unnoticed) 2. The stretched texture should be quite small. It''s 2048x2048 atm, which is already too big, and even bigger is impossible. (Mayor speed loss) I can''t think of a good solution here 3. When I add the detail texture, I don''t know how often to repeat that texture. Say if I put the whole texture on 1 poly, the detail will be quite small. It the poly is close, this looks great, but once the poly is not really close to the camera you don''t see the detail anymore (mipmapping effects) If I stretch the detail texture more, it gives detail in the distance too, but now the ground close to the camera is not detailed enough anymore I don''t really know a solution. I have to figure out a way to make the detail texture stretch more if it''s far away but I don''t know how to do this. 4. Can''t make overhangs (like caves) with heightmaps 5. I want to insert some buildings/trees/friemel/other objects on the heightmap (a heightmap is not a complete world yet) but I don''t know how to implement this without hard-coding all the poly''s... If you have any thoughts on this, any solutions for the problems, or if you have a way to make the landscapes like I want them to be, please respond. I appreciate any thoughts about the subject. Thanks in advance!

Share this post


Link to post
Share on other sites
Advertisement
I''ve been putting some thought into a method of dealing with an arbitrarily sized and detailed world.

The world is stored as a height map at a very rough scale, say one sq. km per pixel. The area around the player is then expanded into main memory using procedural methods (such as perlin noise) to a detail level of one metre. At this point, overlays may be applied to the map. These overlays deform the map to show such things as roads, rivers, etc.

A trianglular mesh is created that is just larger than the camera''s view frustum. It is set up so that there is less detail the further you get from the camera. The vertices of this mesh are transformed by the camera''s position and orientation and the x,z (assuming y is up) values are used to look-up the height from the expanded map in main memory.

As the camera moves about, you will have to expand new map areas, so your procedures to do this will have to run fast enough in real time.

The frustum shaped mesh is used to minimize overdraw, but it will fail if the camera is positioned too far above the ground, or if it rotates too far off being paralell to the ground.

If anyone know of any serious flaws with the above approach, I''d love to hear them, as I''m pretty much just a beginner in terrain rendering.

Share this post


Link to post
Share on other sites
I''ll take a wack at this.

1. The heightmap image cannot be much bigger than 1024x1024, because else there will be too much polygons. I''ve tried solving this using frustum culling & octrees, but the speed gain is not enough to create a heightmap image with nearly-infinite size.

---With frustum culling, an implicit quadtree (the heightmap''s a regular grid) a nice LOD algo. and possibly an occlusion algo, there shouldn''t be a problem with too many polygons. That leaves the actual storage and retrieval of a very large number (near-infinite) of heights. If you break the height map into blocks that are just larger than the visible range (far clipping plane) then you can load up the surrounding blocks around where the player is:
XXX
XOX
XXX
and once they move into another block, slowly load in the new set of nine (at least four will already be loaded). Try a thread that just loops and makes sure that the current block is fully loaded, else loads part of an ajacent block that is visible, else loads part of an ajacent block that isn''t visible, else sleeps. I have no idea how fast this is, though.


2. The stretched texture should be quite small. It''s 2048x2048 atm, which is already too big, and even bigger is impossible. (Mayor speed loss)

---You need''nt have a texture that large. Just get a few smaller textures and find a way to blend them (highest point is 100% texture A, lowest point is 100% texture B, interpolate the rest). That, together with a good detail texture can look quite good.

I can''t think of a good solution here
3. When I add the detail texture, I don''t know how often to repeat that texture. Say if I put the whole texture on 1 poly, the detail will be quite small. It the poly is close, this looks great, but once the poly is not really close to the camera you don''t see the detail anymore (mipmapping effects)
If I stretch the detail texture more, it gives detail in the distance too, but now the ground close to the camera is not detailed enough anymore

---I haven''t tried it myself, but I''ve seen people with both a near and far detail texture, again just interpolate between the two. The near is as a good setting for close polys, the far for far polys.

4. Can''t make overhangs (like caves) with heightmaps

---Nope. The hack is to treat the heightmap as the lowest elevation and everything else as a separate polygon with a special case collision, LOD, etc. Kinda messy. Might be better dealing with a more free form mesh than heightmaps if this is something you really want to do. Can''t help you out much here.

5. I want to insert some buildings/trees/friemel/other objects on the heightmap (a heightmap is not a complete world yet) but I don''t know how to implement this without hard-coding all the poly''s...

Either create them in a modeling program and export them out, or hard code em into your own format and save em. Then you can add stuff like occlusion geometry to objects and all kinds of fun stuff (Do you really want to draw all of that landscape hidden behind that house?).

There are some great posts on most of this stuff in the forums, if you can find it... Just check out google for most of it, and for anything specific, there are many people here than can help a lot more than me.

karg

Share this post


Link to post
Share on other sites
some resources on paging large terrain datasets:

chunklod
demeter

both page terrain from disk as needed. demeter is more accessable but the chunklod method looks more powerful and could probably be used on things other than heightmaps - eg modelled caves, building etc

Share this post


Link to post
Share on other sites
The only method that allows for infinite worlds is one in which you tile together heightmaps (or whatever data set you use). When you add a new one into the scene, initially make it completely flat and have the vertices expand upwards as the user gets closer. Also, use fog or haze so the user doesn''t see the flat ground itself popping into view. This should work. The heightmaps would be loaded from disk.

~CGameProgrammer( );

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I''m sorry, but I can''t see the resemblance between infinite and all the ideas put forward here, as they are all *limited* in some way. They mere fact that your PC has a *limited* amount of storage space should be enough of clue for you not to use the word infinite. My 2c.

Share this post


Link to post
Share on other sites
The only thing you can do to get a really infinite terrain, is to generate it on the fly. For example using realtime fractal systems, basically creating new heightmap values as they are needed, instead of pre-storing this information.

Share this post


Link to post
Share on other sites
First of all, thanks for the help. I see some pretty usefull ideas here, and I will study them closer after I''ve posted this message

Of course, infinite world is not possible (unless created on the fly, like Yann said) because you can never make enough heightmaps to have an infinite world. My idea is to use the shape of a planet (round) so the edges of the map are connected again

Like this

ABCD(A starts again here)
ABCD(A starts again here)
ABCD(A starts again here)
ABCD(A starts again here)

but still I need a really big amount of heightmaps. As for the blending method (interpolating textures based on height) this is possible, but you don''t get very varied landscapes that way. Using one texture, you can make it exactly the way you like (you can also do things like including a path of stones to walk on and stuff) this gives you much more flexibility. I''ll have to find a solution for that problem too...

As for the terrain loading, loading the 9 chunks in the

XXX
X0X
XXX

way was something I thought about too, and it seems really good. A lot of poly''s, but with octree/frustrum culling it shouldn''t be a problem. I''ll use fog for the popup, yes.

Korvan, your method is new to me, I''ll try to dig some articles up about this subject so I can try.

Thanx all for the help!

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I use a basic technique:

- a generated ocean which is infinite
- some heightmaps to make islands where the player is.

Share this post


Link to post
Share on other sites
A seeded random number generator can be used to create predictable psuedo random results. You can use this to develop an algorithm that can take a seed value to generate different parts of the world as you approach them. Since you''re using a seed, you''ll be able to generate the same world every time.

Miracle Man Studios Inc

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!