Author Topic: Terrain Generator  (Read 11102 times)

Offline SBlectric

  • Mc. Print
  • *
  • Posts: 49
  • Coding is neat I guess
    • View Profile
    • SBlectric Studios
Terrain Generator
« on: 2014-Jul-09 »
I've been looking into fractal terrain generation lately, as I'm currently working on a Minecraft clone and want to have a good randomized, realistic terrain. Well, I ended up porting an old C++ Perlin Noise routine into GLBasic, then adding a GUI wrapper to control its output.

At the moment, it only draws and exports 2D representations of terrains, but I will soon add in 3D viewing/exporting.




New 1.2 release on 7/29!
Download it here: http://sblectric.com/downloads/TerrainGen-v1.2.zip
C++ and GLBasic code included for the actual algorithm.
« Last Edit: 2014-Jul-29 by SBlectric »
Cool stuff and whatever

Offline Slydog

  • Prof. Inline
  • *****
  • Posts: 930
  • KodeSource
    • View Profile
    • KodeSource
Re: Terrain Generator
« Reply #1 on: 2014-Jul-09 »
Looking great!

If you're interested, here's a thread discussing voxel style graphics, and algorithms to only add exposed quad faces of a random voxel grouping.  Later perlin noise (simple implementation) is added to make it appear more Minecraft like. 

http://www.glbasic.com/forum/index.php?topic=9499.0

Seems to work fast enough for small worlds (128x128).  Some more optimization would be needed for larger worlds maybe.  It does implement a chunking system, by breaking the world into predetermined size chunks (8x8x8 for example).  This concept speeds up the calculation, plus updating a voxel is much quicker.

Keep us posted on your progress, looks promising. :good:
My current project (WIP) :: TwistedMaze <<  [Updated: 2015-11-25]

Offline mentalthink

  • Prof. Inline
  • *****
  • Posts: 3357
  • Integrated Brain
    • View Profile
Re: Terrain Generator
« Reply #2 on: 2014-Jul-09 »
Nice and interesting program, thanks for the code always it's good learning C++ for GLbasic , thanks.

Offline MrPlow

  • Prof. Inline
  • *****
  • Posts: 1435
    • View Profile
Re: Terrain Generator
« Reply #3 on: 2014-Jul-11 »
Very nice!
Looking forward to 3D version
Comp:
Speccy-48k, Speccy-128k, Amigas, PCs

Offline matchy

  • Prof. Inline
  • *****
  • Posts: 1540
    • View Profile
Re: Terrain Generator
« Reply #4 on: 2014-Jul-11 »
Great stuff and just what I was looking for my flat 3D environment and catchup on a bit of inlining. :enc:
« Last Edit: 2014-Jul-12 by matchy »

Offline SBlectric

  • Mc. Print
  • *
  • Posts: 49
  • Coding is neat I guess
    • View Profile
    • SBlectric Studios
Re: Terrain Generator
« Reply #5 on: 2014-Jul-13 »
It's working really great on my Minecraft clone. Looks good so far! Here's a video of its current status (terrain, physics (still buggy), block placement, walking, etc.)
https://drive.google.com/file/d/0B2Ez6zqWxZAZVWpyMjRKZEhtZWM/edit?usp=sharing
Cool stuff and whatever

Offline matchy

  • Prof. Inline
  • *****
  • Posts: 1540
    • View Profile
Re: Terrain Generator
« Reply #6 on: 2014-Jul-13 »
Hey!  =D You know I like that. How about some more distance views?  :whistle:

Offline SBlectric

  • Mc. Print
  • *
  • Posts: 49
  • Coding is neat I guess
    • View Profile
    • SBlectric Studios
Re: Terrain Generator
« Reply #7 on: 2014-Jul-13 »
Here's a good one:
Cool stuff and whatever

Offline Ian Price

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 4143
  • On the shoulders of giants.
    • View Profile
    • My Apps
Re: Terrain Generator
« Reply #8 on: 2014-Jul-14 »
Nice  =D =D =D
I came. I saw. I played.

Offline Slydog

  • Prof. Inline
  • *****
  • Posts: 930
  • KodeSource
    • View Profile
    • KodeSource
Re: Terrain Generator
« Reply #9 on: 2014-Jul-14 »
I agree, very nice!

Are you telling me this is running at 936 FPS?
What size world is this? 256x64x256?

What's next?  Add/destroy a block?  Water?  Can't wait.
My current project (WIP) :: TwistedMaze <<  [Updated: 2015-11-25]

Offline SBlectric

  • Mc. Print
  • *
  • Posts: 49
  • Coding is neat I guess
    • View Profile
    • SBlectric Studios
Re: Terrain Generator
« Reply #10 on: 2014-Jul-14 »
It's more like 500-800 now that I added placement, and I achieve this by grouping all the blocks in a chunk into a single object, so instead of ~300 draw calls per chunk like I was getting before, it's now only 1 per chunk.
Here's a video: <a href="http://www.youtube.com/watch?v=gdixHklaKm8" target="_blank">http://www.youtube.com/watch?v=gdixHklaKm8</a>
Yep, world size is 16x16 chunks, or 256x256x256.
« Last Edit: 2014-Jul-14 by SBlectric »
Cool stuff and whatever

Offline Schranz0r

  • Premium User :)
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 5013
  • O Rly?
    • View Profile
Re: Terrain Generator
« Reply #11 on: 2014-Jul-18 »
You code this in GLBasic?
Impressive...!

Did you use VBO or Immediate Mode?
I <3 DGArray's :D

PC:
AMD RYzen 7 1700 @3.9Ghz, 16GB HyperX Fury 2666Mhz Ram, ASUS ROG GTX 1060 STRIX 6GB, Windows 10 Pro 64Bit, MSi Tomahawk B350 Mainboard

Offline erico

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 4177
    • View Profile
    • Portfolio
Re: Terrain Generator
« Reply #12 on: 2014-Jul-18 »
Indeed, really neat. :good:

Offline mentalthink

  • Prof. Inline
  • *****
  • Posts: 3357
  • Integrated Brain
    • View Profile
Re: Terrain Generator
« Reply #13 on: 2014-Jul-18 »
 :nw: :nw: :nw: guapísimo, How many polys you can move?¿, really this it's very good, and the Editor, I love the simple UI....

Super!!!

Offline SBlectric

  • Mc. Print
  • *
  • Posts: 49
  • Coding is neat I guess
    • View Profile
    • SBlectric Studios
Re: Terrain Generator
« Reply #14 on: 2014-Jul-19 »
I guess technically it's VBO mode, as I'm loading all of the chunks' vertices and data into memory at startup/chunk update. As for the amount of polygons, it renders two per block face (pretty standard, I don't have poly grouping or anything fancy), and only renders the block faces it calculates to be visible (colliding with an air block).
Cool stuff and whatever