Archived

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

3D terrain editor

This topic is 4954 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

Dear, First of all I hope I''ve placed my post in the correct category, because I''m just a beginner, so i wandered if i should have placed this post in the "Beginners" category. But lets get to the point, Last month I''ve read the book by Jim Adams, "Programming role playing games with directx". It''s a fine book wich explains everything very well, but I still have one single problem, and that''s the terrain. Since I''m planning to make a RPG, I also wanted an exterior, that should be big! You can compare it with The Elder Scrols III : Morrowind (no, not so big, but like it)That''s where troubles come, how should I render such a giant terrain?, how should I make it?, should I build a terrain editor that will let you raise and lower terrain and place objects in it?Should I use cells just like Morrowind, but how works that? That are a lot of questions and I wandered if somebody could help me with some tutorials or advise. Tantalos

Share this post


Link to post
Share on other sites
To render the terrain, you can use some kind of adaptive LOD technique. Search for ''ROAM'' or ''GeoMipMapping''.

Unless you plan to edit the terrain heightmap yourself, using a text editor, it would be advisable to create an editor.

Share this post


Link to post
Share on other sites
A fine book indeed. In fact, there are several books also available on terrain rendering. It is WAY too complicated to be able to explain in this forum. The basic gist is:

You can render terrain several ways. To name several:

1) Brute Force
2) Geomipmapping
3) ROAM algorithm
4) ROAM II algorithm

1) Brute force is taking the geometry and shoving it into the pipeline as is, no matter how close the camera is to the terrain. This would generally be one big index buffer (although you can render it in patches also). You would be using too much CPU time to cull each vertex (in my opinion), but using patches of terrain (say 17x17 vertices makes a patch), you can get better cpu utilization through culling patches and by using an algorithm such as quad tree. This is the easy approach, but totally dogs the video card GPU.

2) Geomipmapping is adjusting the level of detail (LOD) of the terrain based on how far away each segment (section or patch) is from the camera. It''s synomymous to texture mipmapping, where the higher detailed textures are used when your camera is right in front of an object, and lower level textures are used (in powers of 2) when your camera gets further away. Of course, you have to filter between the two levels of textures to make it look good, otherwise you would notice the texture changing from say 5 feet away from a crate versus 6 feet away from the crate. The same problem exists in geomipmapping. You can actually see the height values re-adjusting as you move closer to certain patches. You have to add error correction algorithms to help reduce the visibility of such abnormalities.

3 & 4) ROAM and ROAM II...well it''s complicated to describe.

One thing you have to deal with in real time level of detail adjustment is cracks. I can''t describe them very well either without a drawing.

So, as you can see, it''s not really something you can gain much understanding about here. You need to locate a good set of tutorials or a book. I prefer books because they are done by professionals who want to make money (and no one really feels like writing a book and putting it online in the form of a tutorial just to be nice). So you can find tutorials that are good for certain things, to a certain degree, but I would recommend a book devoted to terrain.

I will edit this post tonight and put the books I''ve read. I can''t remember the title and author off the top of my head.

Good luck,
Chris

Share this post


Link to post
Share on other sites
Dear Chris,

Whow, I can't wait for you tell me the books you have read.
But I was thinking.....

First I have to make an editor that can raise and lower terrain,
In that program you can add cells: Cell 1 (0,0)
Cell 2 (1,0)
ect.
When you make a cell in your render viewport an square appears,
like so______
| |
| |
|______|
In that square a simple plain appears, that you can raise and lower.

In this way you can add cells, and make more land.
At the end you can even add object(planting,trees,treasurs,characters,monsters,buildings,ect.)

~~~~~~~~~
Here you save the data in a file and find a way to render it.
~~~~~~~~

When a player starts(or loads) the game you render the cells around him:
_______ _______ _______
| || || |
|___r___||___r___||___r___|
| || || |
|___r___||___P___||___r___|
| || || |
|___r___||___r___||___r___|[p=player][r=must be rendered]

When the player enters a different cell you don't have to render everything again:
_______ _______ _______
| || || |
|___r___||___r___||___r___|
| || || |
|___ar__||___p___||___ar__|
| || || |
|___ar__||___ar__||___ar__|
| || || |
|___f___||___f___||___f___|[p=player][r=must be rendered]
[ar=already rendered][f=can be freed]

Here only 3 cells must be rendered instead of the first 8.

Maybe you can even render these cells using quad/octtrees and the objects in these cells by simply using the viewing frustrum.
When the player reaches a part that is not made with the editor(he reaches the end of the map)you just render a simple default cell, one with some water(sea) and the plane(with default texture)like so:
_______ _______ _______
| || || |
|___rd__||___rd__||___rd__|
| || || |
|___r___||___P___||___r___|
| || || |
|___r___||___r___||___r___|[p=plyer][r=normal rendered cell]
[rd=not created cell, where the default cell in rendered]

Whoesh, my fingers hurt, what a story!
What do you think can it be done?

Oops what happened with my ascii art?



[edited by - Tantalos on May 19, 2004 4:40:34 PM]

Share this post


Link to post
Share on other sites
This is what geo mip mapping does... But each cell can be a bit of terrain say 9*9 or 17*17.

MWhat you have to remember is when you stand on a mountain you can see huge amounts of terrain , maybe the whole island ... How do you handle that. A Quad tree will not help as these are visible - a poor way is to use fog.

With bruteforce drawing each cell you would have to render billions of triangles. And textures make the problem worse.

With GeoMip mapping the cells far away are rendered in much lower detail ie 17*17 = 600 triangles are rendered as 2.

It is very important to consider textures before you begin. That is where the problems come from.

Ben

Share this post


Link to post
Share on other sites
quote:
Original post by Tantalos
Dear Chris,

Whow, I can''t wait for you tell me the books you have read.



Sorry, not home yet. Will be a bit later.

quote:

But I was thinking.....

First I have to make an editor that can raise and lower terrain,
In that program you can add cells: Cell 1 (0,0)
Cell 2 (1,0)
ect.
When you make a cell in your render viewport an square appears,
like so______
| |
| |
|______|
In that square a simple plain appears, that you can raise and lower.

In this way you can add cells, and make more land.
At the end you can even add object(planting,trees,treasurs,characters,monsters,buildings,ect.)



It sounds like you are going to make a camera at a tilted angle, but not allow first person style viewing. Like Command & Conquer. Am I right? This is a lot easier to achieve because you know exactly what you will be culling.

quote:

~~~~~~~~~
Here you save the data in a file and find a way to render it.
~~~~~~~~

When a player starts(or loads) the game you render the cells around him:
_______ _______ _______
| || || |
|___r___||___r___||___r___|
| || || |
|___r___||___P___||___r___|
| || || |
|___r___||___r___||___r___|[p=player][r=must be rendered]

When the player enters a different cell you don''t have to render everything again:



You don''t have to render everything again? Maybe I misunderstand what you mean. Most of the time you should be clearing your frame and rendering it from scratch, so you can''t really utilize something that was already drawn. I mean, you could, but as soon as the camera moves or any of the geometry on the screen moves (tank or soldier) then you have to redraw things.

Consider also for your editor (as an improvement, wouldn''t put it in the first run) adding the ability to move multiple squares at a time (height wise) with patterns. For instance, they can select a 10x10 selection grid and a pattern that produces a strong incline (like a mountain) and when they click on the 10x10 patch, it lifts up all of the patches sharply. Then they could select a pattern that produces a weak incline (like a hill) and when they click on a 10x10 patch, it lifts the patches slowly, so that there is not much incline between the outer quads toward the inner quads. Just some ideas to think about when developing.

Chris

Share this post


Link to post
Share on other sites
Tantalos,

Since you admit that you''re a beginner, I will suggest that you start small. At least in the beginning, why not create a moderate terrain that is not so large that you require an advanced technique such as the ones described? Why not just create a terrain that can be rendered as a single, static mesh with one texture, on reasonable hardware? For example, you can create a nice, rolling terrain that is fairly expansive and looks decent enough with just 100 x 100 points. That would yield 2 x (100 x 100) = 20,000 triangles, which is not too big to render without a paged, LOD terrain scheme. For example, you can send this to DirectX or OpenGL as a single mesh and it should render quite quickly at a good frame rate on a decent graphics card.

As for how to create the heightfield, one very popular way is to use PhotoShop. Or Paint Shop Pro. Or MS Paint. Any paint program. Create an image, filled with a grey value (128, 128, 128), that is 100 x 100 pixels. Now, use the paint program''s tools to brighten or darken areas. The 128 value will be, say, sea level. Everywhere that is brighter than that is a mountain. Everywhere darker is under water. You can map the intensity to height. If you allow 10 meters for every step in intensity, then you can have an ocean that is -1280 meters deep and mountains that are 1280 meters tall. (You could use red and blue together to give you 16 bits of resolution in the height, which would give you a range of 65536 meters in height if you allow 1 meter per step.)

Then, build a mesh out of the image. Every pixel represents a quadrilateral---two triangles. Each pixel represents a fixed width and length, say 10 meters wide/long per pixel. This spacing defines the x and y values at the corners of the quadrilateral represented by each pixel. You''ll notice that the vertices lie along horizontal lines and vertical lines that exist along the boundaries between pixels. The height at any corner is the average height of all pixels that touch the corner---using the mapping described in the previous paragraph.

Make sure that you generate triangle strips or an indexed mesh...only generate each vertex once. For example, in the middle of the image, each vertex will be touched by 4 pixels. Do NOT create 4 vertices---one for each pixel! That would be bad! Create one vertex and have the triangles for the pixels that touch the vertex point to the single vertex. This is vastly more efficient for rendering.

I hope that helps a bit. Again, until you get something up and running satisfactorily, I strongly suggest that you start SMALL . You''ll be happier that way!

Graham Rhodes
Principal Scientist
Applied Research Associates, Inc.

Share this post


Link to post
Share on other sites
Thanks for all the responses!

@bklooste, I have to admit, I forgot to think about mountains,
thanks for the tip on Geomipmapping.

@Supernat2, see what you mean about having to render all over again. I was thinking about something like a camera at a tilted angle but not so far away(well, now you talk about 1st person view, Hmmmmmm)

@So you say that I should use a heightmap to create a terrain,
the terrain will be limited, and my big exploring aspect will be gone.

Share this post


Link to post
Share on other sites
Here are the books I''ve read.

"Real-Time 3D Terrain Engines using C++ and DirectX 9" by Greg Snook. Good book, I''m reading it a second time, very complicated though.

"Focus On 3D Terrain Programming" by Andre LaMothe. Good book, not specifically written for DirectX, but you can get some major concepts in it. Most are more easily understood than in the other book. Start with this one.

Chris

Share this post


Link to post
Share on other sites