Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (476)
Games in Android Showcase (106)
games submitted by our members
Games in WIP (533)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Diamond Square Terrain  (Read 3569 times)
0 Members and 1 Guest are viewing this topic.
Offline opiop65

JGO Kernel


Medals: 153
Projects: 7
Exp: 3 years


JumpButton Studios


« Posted 2013-11-12 13:09:08 »



A few days ago I decided to look into terrain generation. My goal was to create enormous heightmaps to apply to spheres so I could create a randomly generated world. Well, I Googled left and right, I searched these forums, and I thought about it a lot. I couldn't find any pages that would really help me! Until I found this page:
http://www.gameprogrammer.com/fractal.html
It was the most useful link ever. A few days later, I had a program that could randomly generate a heightmap, then load it into my renderer and actually display it! I'm very excited, and proud to show off my creation. Here's a video showing it off:
<a href="http://www.youtube.com/v/8zgZNuprqzU?version=3&amp;hl=en_US&amp;start=" target="_blank">http://www.youtube.com/v/8zgZNuprqzU?version=3&amp;hl=en_US&amp;start=</a>
(on a side note, I have no idea how to embed youtube! Figured it out!)

On the more technical side of things, I use display lists that are called once when the heightmap is loaded in, and then they are never rebuilt. I use shaders to position and actually texture the triangles. I don't just color them. I use triangle strips because otherwise I would be using a ton more vertices, and that's about it!

Here's the donwload:
goo.gl/g5Cols
(Sorry, I forgot to change the angle in which the player is created. Just turn around and look up and you should see the map)
Press 'R' to generate a random map
Press 'H' to reload the original heightmap

Currently, this is Windows only, sorry!

The terrain generator is pretty fast; it can generate ~12 million triangles in less than 5 seconds! Feel free to use any of my code, just open it up using JD-GUI!

Offline lcass
« Reply #1 - Posted 2013-11-12 19:59:32 »

What libraries are you using for this?
Offline opiop65

JGO Kernel


Medals: 153
Projects: 7
Exp: 3 years


JumpButton Studios


« Reply #2 - Posted 2013-11-12 20:56:37 »

Just LWJGL and my ShaderUtils library, nothing else.

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline lcass
« Reply #3 - Posted 2013-11-12 21:11:57 »

very nice.
Offline Slyth2727
« Reply #4 - Posted 2013-11-12 23:20:39 »

I like this alot, good job. I remember reading an article on how the mountains for the Lord of the Rings movie were generated using that triangle breakdown method. That article you supplied reminded me of it Smiley.

Was I before Chuang Tzu who dreamt about being a butterfly, or am I now a butterfly who dreams about being Chuang Tzu?
Offline opiop65

JGO Kernel


Medals: 153
Projects: 7
Exp: 3 years


JumpButton Studios


« Reply #5 - Posted 2013-11-12 23:33:36 »

If I had a more powerful and a slightly more optimized/Intricate/advanced algorithm, I could totally render out something like that in probably a few days! But this wasn't that hard to implement!

Offline opiop65

JGO Kernel


Medals: 153
Projects: 7
Exp: 3 years


JumpButton Studios


« Reply #6 - Posted 2013-11-14 02:24:59 »



I know have some (bad) voxel rendering! You can tell that there aren't any voxels generated to fill in the gaps, but it works nonetheless Smiley Its not optimized as I'm still using display lists to render, I intended to switch to VBOs, but I was too lazy Tongue!

Offline Slyth2727
« Reply #7 - Posted 2013-11-14 04:09:04 »

Haha I like the gaps Smiley It makes it look funny somehow...
If you get into voxels, even if you don't optimise the code, I think you should check out some other generation algorithms because you can produce some pretty cool looking stuff. I also suggest you look at Marching Cubes generation for non voxel stuff, that way you can make things look more... connected? I dunno how to explain it, but if you use that and per pixel shader lighting combined with other generation methods you have some pretty nice looking stuff just from that!

Was I before Chuang Tzu who dreamt about being a butterfly, or am I now a butterfly who dreams about being Chuang Tzu?
Offline opiop65

JGO Kernel


Medals: 153
Projects: 7
Exp: 3 years


JumpButton Studios


« Reply #8 - Posted 2013-11-14 04:12:54 »

I've already gotten myself into voxels a little, I just took a break to work on little stuff like this, and I'm working on networking now! Honestly, terrain generation would not be high on my to do list, as this algorithm I have right now produces some pretty nice results!

The marching cubes generation idea sounds fun, I might look into that someday! But I'm just proud of myself for learning the Diamond Square algorithm, I'm not going to ruin that feeling with messing around with other algorithms yet Wink

Offline saucymeatman
« Reply #9 - Posted 2013-11-14 04:19:14 »

This is really cool (+1), love your mountain nipples haha.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline opiop65

JGO Kernel


Medals: 153
Projects: 7
Exp: 3 years


JumpButton Studios


« Reply #10 - Posted 2013-11-14 04:48:07 »

Haha, I know they really amuse me Smiley Thanks for the medal!

Offline lcass
« Reply #11 - Posted 2013-11-14 21:25:12 »

Cool, do you plan on developing this further or was it a test of diamond square algorithm? I would love to see a kind of medieval RTS built out of this like a city builder Cheesy
Offline opiop65

JGO Kernel


Medals: 153
Projects: 7
Exp: 3 years


JumpButton Studios


« Reply #12 - Posted 2013-11-15 02:14:56 »

I want to eventually get back into voxels, and maybe someday create a free roam type of game with this kind of terrain where you complete small missions and kill things. But who knows!

I do want to make use of this program later on, its just I don't need it right now. I eventually want to simulate planets with procedural terrain and lighting... but that's far off in the future after a few more years of OpenGL!

Offline RobinB

JGO Ninja


Medals: 44
Projects: 1
Exp: 3 years


Spacegame in progress


« Reply #13 - Posted 2013-11-15 11:33:54 »

I do want to make use of this program later on, its just I don't need it right now. I eventually want to simulate planets with procedural terrain and lighting... but that's far off in the future after a few more years of OpenGL!

This is less hard as you might think.
1. Create a sphere
2. For each point, multiply by a noise value (just use the x,y,z as input).

Thats it!.
After less then a hour work you could achieve this:


*However you will need to make some kind of LOD sytem if you want to be able to zoom.
Offline opiop65

JGO Kernel


Medals: 153
Projects: 7
Exp: 3 years


JumpButton Studios


« Reply #14 - Posted 2013-11-15 23:09:53 »

That's awesome! Could I overlay a height map onto the sphere? I'm guessing its a bunch of math because I'd have to UV map it, which I don't know how to do yet!

Offline RobinB

JGO Ninja


Medals: 44
Projects: 1
Exp: 3 years


Spacegame in progress


« Reply #15 - Posted 2013-11-16 14:22:06 »

That's awesome! Could I overlay a height map onto the sphere? I'm guessing its a bunch of math because I'd have to UV map it, which I don't know how to do yet!

Sure, and not so much:
1  
2  
text.y = 0.5f + (float)Math.asin(point.y) / PI;
text.x = 0.5f + (float)Math.atan2( point.z, point.x ) / (PI*2);
Offline opiop65

JGO Kernel


Medals: 153
Projects: 7
Exp: 3 years


JumpButton Studios


« Reply #16 - Posted 2013-11-16 14:24:08 »

Wow, thank you that's very helpful, I'll do that sometime soon Smiley

Offline unenergizer

Junior Member


Medals: 3
Exp: 1 year


Work hard, practice often, and you will succeed!


« Reply #17 - Posted 2013-11-21 05:52:17 »

Good job man! I must say this is pretty epic in my eyes!  Wink

JGO is AMAZING!
Steam: unenergizer
Offline gmmaster

Senior Newbie





« Reply #18 - Posted 2013-12-05 07:59:22 »

Good work! I'm just trying to draw a simple triangle strip grid and man I can't imagine how hard this was....

loopish's brother Cheesy
Offline AullenVerch

Senior Newbie




The univertse is vast!!


« Reply #19 - Posted 2013-12-13 06:55:30 »

The last couple of replies that were talking about making a procedural planet out of this are really interesting!! I can't wait to see how that is coming if you plan on going in that direction.
Offline opiop65

JGO Kernel


Medals: 153
Projects: 7
Exp: 3 years


JumpButton Studios


« Reply #20 - Posted 2013-12-13 23:45:48 »

The last couple of replies that were talking about making a procedural planet out of this are really interesting!! I can't wait to see how that is coming if you plan on going in that direction.
Thanks! I't actually not working on it right now (I have a voxel engine series that I'm still doing on YouTube! Link in my signature Wink , but I do someday want to come back to this with a little more knowledge on lighting and shadows so I can make the worlds look really good.

Offline RobinB

JGO Ninja


Medals: 44
Projects: 1
Exp: 3 years


Spacegame in progress


« Reply #21 - Posted 2013-12-14 10:56:55 »

The last couple of replies that were talking about making a procedural planet out of this are really interesting!! I can't wait to see how that is coming if you plan on going in that direction.

No worrys, i will Smiley (including "infinite" lod).
Offline opiop65

JGO Kernel


Medals: 153
Projects: 7
Exp: 3 years


JumpButton Studios


« Reply #22 - Posted 2013-12-14 14:32:28 »

Cool! I'm looking forward to seeing that done!

Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

pw (18 views)
2014-07-24 01:59:36

Riven (17 views)
2014-07-23 21:16:32

Riven (14 views)
2014-07-23 21:07:15

Riven (17 views)
2014-07-23 20:56:16

ctomni231 (45 views)
2014-07-18 06:55:21

Zero Volt (40 views)
2014-07-17 23:47:54

danieldean (32 views)
2014-07-17 23:41:23

MustardPeter (36 views)
2014-07-16 23:30:00

Cero (51 views)
2014-07-16 00:42:17

Riven (50 views)
2014-07-14 18:02:53
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!