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 / Terrain generator

Author
Message
Madscientist
14
Years of Service
User Offline
Joined: 23rd Aug 2009
Location: Between a rock and a hard place
Posted: 17th Oct 2010 04:14
I decided to create a terrain heightmap generator that generates a map based of the Plasma Fractal Algorithm. I got the algorithm to work some what but for some reason the code only generates half the map which probably has to do with it having a recursive function. Any ideas why?


My computer surpasses all the technologies of the day. What computer do I have?

Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 17th Oct 2010 19:37
Quote: "Any ideas why?"


I'm fairly sure you've got in a muddle with the (X,Y) coordinates of your corner points - and I suspect you calculate the new values more than once in the middle of the edges as soon as you divide.

Also, your code seems unnecessarily elaborate. Any reason why you didn't just use



with (X1,Y1) and (X2,Y2) being the top left and bottom right corners?
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 17th Oct 2010 20:10
Try this. It still isn't quite right - you need to stop the repeated entries which probably cause the loss of continuity. But at least the whole square is filled.

Madscientist
14
Years of Service
User Offline
Joined: 23rd Aug 2009
Location: Between a rock and a hard place
Posted: 18th Oct 2010 03:46
Thanks GG! I had the 4 corners because I figured it would be easier to keep track of the data. But changing the 4 coords to 2 coords fix it or did you do something else?

My computer surpasses all the technologies of the day. What computer do I have?

Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 18th Oct 2010 12:00
Quote: "or did you do something else"


Yes. I found it easier to write amended code that way - the error was in your referencing of the corners when you called the divide recursion. The recursion idea itself was fine.

I've also made a few other changes to make the results look better. I'm on the wrong machine at the moment but will edit this post with the new code later today.

I did something similar a few years back using the diamond-square algorithm but your method is much simpler and more flexible (for example it is easy to extend to three dimensions). Would you object if I used it? I'll credit the idea to you of course.

Thanks for posting an interesting problem.
Madscientist
14
Years of Service
User Offline
Joined: 23rd Aug 2009
Location: Between a rock and a hard place
Posted: 18th Oct 2010 13:50
You can use it however you like. Thanks for the help. Yeah the corner positions were giving me problems before.

My computer surpasses all the technologies of the day. What computer do I have?

zappi
13
Years of Service
User Offline
Joined: 16th Oct 2010
Location: with your mother
Posted: 18th Oct 2010 15:18
good idea!!
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 18th Oct 2010 17:47
Here's the revised version. Experiment with different values of reduce# to get rougher or smoother heightmaps.

General Jackson
User Banned
Posted: 18th Oct 2010 19:38
Can I use this too?
Pretty please?

Madscientist
14
Years of Service
User Offline
Joined: 23rd Aug 2009
Location: Between a rock and a hard place
Posted: 18th Oct 2010 19:47
Pretty sweet. Yes, you can use this code however you want. Gonna apply the heightmap to a terrain and post a screenshot when I get back to my home computer.

My computer surpasses all the technologies of the day. What computer do I have?

Madscientist
14
Years of Service
User Offline
Joined: 23rd Aug 2009
Location: Between a rock and a hard place
Posted: 19th Oct 2010 05:10 Edited at: 19th Oct 2010 05:13
Added to it, made image generation faster with memblocks. Also creates a terrain object with it.


My computer surpasses all the technologies of the day. What computer do I have?

Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 19th Oct 2010 12:43
Nice.
Madscientist
14
Years of Service
User Offline
Joined: 23rd Aug 2009
Location: Between a rock and a hard place
Posted: 24th Oct 2010 00:53
Need more help GG. My plan is to generate a terrain rgb map for one of your terrain shaders that makes the red textured with a certain image, and green and blue textured with others. So I base each rgb value off a different color range and create a new image. However my equations are somehow off.


My computer surpasses all the technologies of the day. What computer do I have?

Login to post a reply

Server time is: 2024-05-02 15:38:31
Your offset time is: 2024-05-02 15:38:31