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 generation and texturing...

Author
Message
WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 9th Sep 2011 01:35
1. the height map data (created by perlin noise) goes from 0 to 255.
2. I've created 4 random textures.
3. create a blank bitmap (to merge the 4 textures)
4. For each pixel on the blanks bitmap:
a. get the equivalent pixel from the height map
b. depending on the height choose which of the 4 textures to use
c. copy the pixel from the selected texture over to the blank bitmap
5. grab the final image from the bitmap
6. delete everything else

The code for this is in the above post. I'll add a link shortly to the entire project as it stands...

Warning! May contain Nuts!
Mugen Wizardry
User Banned
Posted: 9th Sep 2011 01:40
i need to know what values u used for set blend mapping on

CHECK OUT MY WEBSITE AT http://imageposeidon.com/ !
WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 9th Sep 2011 01:42
On this current algorithm I haven't used blend mapping. I've actually merged 4 textures into just 1. Although I have created a detail map and applied that to the object too...

Warning! May contain Nuts!
JackDawson
14
Years of Service
User Offline
Joined: 12th Jul 2011
Location:
Posted: 9th Sep 2011 01:45
Looks awesome bro. Keep up the good work.

"Life is like a box of chocolates.. eat it before it melts."
WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 9th Sep 2011 01:50 Edited at: 9th Sep 2011 01:52
DOWNLOAD the entire project as it stands from here:

http://csnorwood.site40.net/_Misc_Media/terrain_gen_DBP.zip

Those that don't fully understand what it's doing then I apologise. I haven't been as thorough with this proto code with comments as it's only a trial run for when I convert it to C++...

EDIT: You must have Matrix1Utils although the exe will run...

Warning! May contain Nuts!
WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 11th Sep 2011 22:40 Edited at: 11th Sep 2011 23:07
Added more detail to the terrain texture. I used a little cheat (programmers have good habits of cheating). I increased the perlin noise map so I could get a better resolution for when I needed to mix the 4 textures together. The mixed textures don't look so blocky anymore...

What I need to do now:

1 - Split the map into limbs so I can have unlimited sizes of terrains. This will also be the same for the textures.

2 - Using the perlin noise code I can now make the terrain into and endless unlimited terrain. This can be done by simply altering the vertices and indices as the terrain moves up, down, left or right. I got this idea from the 'libnoise utils' website. (Will only be applicable to C++ version though)



Download the DBP and C++ code here...

EDIT: Forgot to mention, I've also fixed the intermittent spikes that would appear on some terrains.

Warning! May contain Nuts!
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 12th Sep 2011 00:45
The vertical looks less stretched now, did you do something to it?

WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 12th Sep 2011 01:22
Yeah. I originally had the height multiplied by 2. I'm going to try adding a water later to it next to see what it looks like. I've almost got it generating million of alien like terrains...

Warning! May contain Nuts!
WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 13th Sep 2011 18:12


Now instead of generating 4 textures first and then blending them, this new function is optimised and generates one texture on the fly. Now I'm considering adding this into either an exe or dll so it will be even faster. It basically does the same as in the image above but takes now 1/4 of the time to generate.

Warning! May contain Nuts!
WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 13th Sep 2011 19:52
Erm... I now have a problem... I've changed the code so that it can "LOCK PIXELS" by using "CREATE MEMBLOCK FROM IMAGE", but as every time I use peeks and pokes, I get errors in DBP...

This is the new code that causes memblock out of range error:



I'm assuming 4 bytes per pixel with an offset of 12 (I've added 2 to skip the alpha if any to be safe) from the memblock start position. The image has been created with a power of 2 so it won't be stretched so my pixels pitch value should be correct.

Can anybody help me with this error?

Warning! May contain Nuts!

Login to post a reply

Server time is: 2026-07-10 06:08:32
Your offset time is: 2026-07-10 06:08:32