Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Fault Formation: Help

Author
Message
DigitalFury
13
Years of Service
User Offline
Joined: 30th Jul 2010
Location: United States
Posted: 30th Nov 2010 04:00 Edited at: 2nd Dec 2010 02:06
I followed tutorial from: "light house 3d" and I can't seem to figure out the displacement part. It isn't very clear.

Here is what the tutorial said to do for displacement:

Quote: "The Displacement Factor

Another issue of this algorithm, is by how much we should displace the terrain heights at each iteration. The simplest solution is to consider the displacement a constant at every iteration. Another approach is to decrease the height displacement at each iteration without letting it reach zero. We could drop linearly the displacement factor from iteration 1 to iteration n, and then just keep it constant for iterations greater than n. For instance, to decrease the height displacement linearly as the number of iterations increases we could write in pseudo code:

Special care must be taken when choosing the value n, as well as dispn. If dispn is much smaller than disp0 then the value of n should be sufficiently large, otherwise the displacement factor will decay too fast and the initial iterations will leave significant marks on the terrain. In this case if n is not large enough then the faults created by the first iterations will be visible regardeless of how many iterations we run. "


FaultFormation(Size, Iterations):
- Size = Size of Image
- Iterations = How many passes the algorithm makes


What I need help with:
The determinate is suppose to remove or add by a certain amount. I don't understand how to calculate the determinate. Check the quote on how to calculate the determinate. I need help figuring out what the quote is telling me about calculating the determinate. It is a bit confusing.

Fault Formation Resources:
http://www.lighthouse3d.com/opengl/terrain/index.php3?fault
http://www.m3xbox.com/GPU_blog/?p=10

Any help is appreciated.

DigitalFury

Attachments

Login to view attachments
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 1st Dec 2010 02:46
I've implemented this before, it's somewhere in the DBP challenge thread.

Basically, you draw an imaginary line from random points across the terrain (or matrix in DBP terms). The line stretches all the way across the terrain from point A to point B. Everything to the right of the line is lowered by a certain amount, everything to the left of the line is raised a certain amount. Do this process once and that's 1 iteration. Apply several iterations over the terrain and you'll get a naturally-looking bumpy terrain. Apply a simple smoothing algorithm over the terrain and the results can be very good.

"Only the educated are free" ~Epictetus
"Imagination is more important than knowledge..." ~Einstein
DigitalFury
13
Years of Service
User Offline
Joined: 30th Jul 2010
Location: United States
Posted: 1st Dec 2010 02:49 Edited at: 2nd Dec 2010 02:06
@Phaelax - Found the thread. Would take me a lifetime to look though 198 pages. Any clue where it is at? I am using a heightmap instead of directly editing the terrain. The part I am having problems with is the displacement calculation. Any insight?

Thanks for your help. Hopefully later I can post a revised function.

Thanks Again,

DigitalFury

Attachments

Login to view attachments
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 1st Dec 2010 20:54 Edited at: 1st Dec 2010 21:03
If you're trying to use the fault formation to build a heightmap, then start with a neutral grey color for the whole image. Instead of raising/lowering points, you'd adjust the brightness of the pixels on either side of the line. Lighten them to increase height, lower them to decrease height.

Here's an example. This image shows the stages of a height map during 4 iterations of the fault formation.


Notice how a random line is drawn(imaginary) and the pixels are brightened or darkened on either side. Now blur the image a little to get smoother transitions between the heights (unless you just want cliff-like terrain).

"Only the educated are free" ~Epictetus
"Imagination is more important than knowledge..." ~Einstein

Attachments

Login to view attachments
DigitalFury
13
Years of Service
User Offline
Joined: 30th Jul 2010
Location: United States
Posted: 1st Dec 2010 21:29 Edited at: 2nd Dec 2010 02:05
@Phaelax - I understand how it works. I wrote the function for doing just that. The tricky part is that determinate. How much should be added/subtracted each interation.

Attachments

Login to view attachments
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 2nd Dec 2010 01:55
That's really up to you and the desired results you want. Realistic amounts would be relative to the size of the terrain itself.

"Only the educated are free" ~Epictetus
"Imagination is more important than knowledge..." ~Einstein
DigitalFury
13
Years of Service
User Offline
Joined: 30th Jul 2010
Location: United States
Posted: 2nd Dec 2010 02:12 Edited at: 2nd Dec 2010 02:15
@Phaelax - What would you suggest I do for the displacement? I don't exactly know what I am suppose to get before I blur it.

Here is the results I got:



This is what I was told to do to find the Displacement Factor:

Quote: "The Displacement Factor

Another issue of this algorithm, is by how much we should displace the terrain heights at each iteration. The simplest solution is to consider the displacement a constant at every iteration. Another approach is to decrease the height displacement at each iteration without letting it reach zero. We could drop linearly the displacement factor from iteration 1 to iteration n, and then just keep it constant for iterations greater than n. For instance, to decrease the height displacement linearly as the number of iterations increases we could write in pseudo code:

Special care must be taken when choosing the value n, as well as dispn. If dispn is much smaller than disp0 then the value of n should be sufficiently large, otherwise the displacement factor will decay too fast and the initial iterations will leave significant marks on the terrain. In this case if n is not large enough then the faults created by the first iterations will be visible regardeless of how many iterations we run. "


This is what I came up with:


I don't know what it is suppose to look like.

According to this website I should get this:


I don't think I am even close to that. Any ideas why?

Thanks,

DigitalFury
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 2nd Dec 2010 02:53
well the 200 iterations looks close, the main difference being the example uses anti-aliased lines and yours doesn't. (no big deal if you blur the image later).

Gimme a few minutes to look over everything.

"Only the educated are free" ~Epictetus
"Imagination is more important than knowledge..." ~Einstein
DigitalFury
13
Years of Service
User Offline
Joined: 30th Jul 2010
Location: United States
Posted: 4th Dec 2010 06:12
@Phaelax - Did you look over everything yet?

Quote: "200 iterations looks close."


That is good. What do I have to do other then smooth it?

Quote: "main difference being the example uses anti-aliased lines "


Should I use anti-aliased lines? Does it really matter?

Thanks,

DigitalFury
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 4th Dec 2010 20:17 Edited at: 4th Dec 2010 20:18
Ok, look at the following, specifically where you cap the height to 1.0


In the "else" clause, shouldn't you be checking if the height is less than 0 and not greater than 1 since you're subtracting the displacement amount?

Looking at some of your results it looked like there was too much white in some areas, and I'd say its due to capping the height at 1.0.

Here's what I'd do. Don't cap the height, not yet at least. You could have several segments in the image with varying height segments, but after a certain point they all become forced to the max limit of 1. Over time that builds up larger white spots. Keep track of the highest amount. It's possible you could end up with numbers as high as 2.0 or more. That's fine. When you're done doing the fault formation and ready to draw the image, loop through all the coordinates and divide each one by whatever the maximum height was that you tracked. This will ensure everything stays between 0 and 1, at which point you can multiple that by 255 to get your color.


As for blurring or smoothing, the lighthouse website has an article on that as well:
http://www.lighthouse3d.com/opengl/terrain/index.php3?smoothing

Basically, you just average each point based on its neighbors.

"Only the educated are free" ~Epictetus
"Imagination is more important than knowledge..." ~Einstein

Login to post a reply

Server time is: 2024-05-10 02:05:42
Your offset time is: 2024-05-10 02:05:42