Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1] 2

Author Topic: World domination  (Read 4403 times)

Thief^

  • Bay Watcher
  • Official crazy person
    • View Profile
World domination
« on: September 23, 2010, 12:42:32 pm »

Just thought I'd share one of my little projects.

At work, I am a terrain rendering programmer for an upcoming console game. Also branched out into terrain deformation, terrain collision, terrain streaming, and terrain pretty much everything else.

Because of this, I recently got shown a university student's paper on procedural terrain generation. It interested me, so naturally I have had a go at implementing it myself in my free time. (To be clear, the following is not for the game I'm writing at work, it's a free time project.)
I chose a technique called midpoint displacement (the wiki article is pretty terrible though). Here are the results:

Selected Eyecandy:


All images:
Test 1 - First test, single terrain cell, colour assigned by height
Test 2 - Same as test 1 but with new random seed
Test 3 - 4x4 terrain cells
Test 4 - 8x8 terrain cells? Maybe 16x16. Algorithm clearly doesn't scale well this way...
Test 5 - Back to 3x3 cells, with wrapping enabled (but glitching on edge)
Test 6 / Shifted - Same as test 5, but wrapping is fixed. Also shifted image manually to center the resulting island to get a better look
Test 7 - Forced low seed points around edge, makes an island in the middle, don't need to shift image now
Test 8 - Up to 4x4 cells, bigger island
Test 9 / Heightmap - Heightmap export

Test 10 - Adapt algorithm to work with triangles instead of squares, output result to a model file which is later rendered in 3d. Back to 1 cell (which is now triangular).
Test 11 - Up subdivision another couple of steps. Result is awesome.

Any guesses as to why I adapted the algorithm to triangles?
« Last Edit: September 23, 2010, 12:48:19 pm by Thief^ »
Logged
Dwarven blood types are not A, B, AB, O but Ale, Wine, Beer, Rum, Whisky and so forth.
It's not an embark so much as seven dwarves having a simultaneous strange mood and going off to build an artifact fortress that menaces with spikes of awesome and hanging rings of death.

ILikePie

  • Bay Watcher
  • Call me Ron
    • View Profile
Re: World domination
« Reply #1 on: September 23, 2010, 02:30:54 pm »

Any guesses as to why I adapted the algorithm to triangles?
Because they look better in 3d? Also, that's some pretty neat stuff.
Can you post the code? I tried making something like this in 2d a while back and failed.
Logged

Thief^

  • Bay Watcher
  • Official crazy person
    • View Profile
Re: World domination
« Reply #2 on: September 23, 2010, 03:45:23 pm »

Any guesses as to why I adapted the algorithm to triangles?
Because they look better in 3d?
Nope, it's something to do with polyhedra...

Also, that's some pretty neat stuff.
Can you post the code? I tried making something like this in 2d a while back and failed.
I might do, after the next set of images (generating now)...
8/9...
« Last Edit: September 23, 2010, 04:35:21 pm by Thief^ »
Logged
Dwarven blood types are not A, B, AB, O but Ale, Wine, Beer, Rum, Whisky and so forth.
It's not an embark so much as seven dwarves having a simultaneous strange mood and going off to build an artifact fortress that menaces with spikes of awesome and hanging rings of death.

Thief^

  • Bay Watcher
  • Official crazy person
    • View Profile
Re: World domination
« Reply #3 on: September 23, 2010, 04:53:54 pm »

Octahedron test:

isocahedron test:


Thoughts?
Logged
Dwarven blood types are not A, B, AB, O but Ale, Wine, Beer, Rum, Whisky and so forth.
It's not an embark so much as seven dwarves having a simultaneous strange mood and going off to build an artifact fortress that menaces with spikes of awesome and hanging rings of death.

ILikePie

  • Bay Watcher
  • Call me Ron
    • View Profile
Re: World domination
« Reply #4 on: September 23, 2010, 05:08:24 pm »

The octahedron looks smoother for some reason.
Logged

Korbac

  • Bay Watcher
  • I'm very annoying, so tell me to STFU if need be
    • View Profile
Re: World domination
« Reply #5 on: September 23, 2010, 05:32:21 pm »

Any guesses as to why I adapted the algorithm to triangles?

Is it because modelling height differences is easier this way? :)
Logged

Soadreqm

  • Bay Watcher
  • I'm okay with this. I'm okay with a lot of things.
    • View Profile
Re: World domination
« Reply #6 on: September 24, 2010, 04:58:40 am »

I think it's because a sphere is easier to divide into triangles than squares. That is to say, POSSIBLE to divide into triangles.
Logged

Thief^

  • Bay Watcher
  • Official crazy person
    • View Profile
Re: World domination
« Reply #7 on: September 24, 2010, 05:12:06 am »

*ding* *ding* *ding* that is the right answer.

It's called a geodesic sphere. Created by repeatedly subdividing the triangles of a polyhedron, and pushing the points out to lie on the surface of a sphere.
Midpoint displacement terrain generation works by repeatedly subdividing a basic shape (I'd only found line and square versions, but it seems to work fine with triangles too) and pushing the points in/out by a random amount.

Combine the two and you get a planet, like this one:


I'm currently using my own software renderer (from uni), but it doesn't know how to output anything but .tga files. Any recommendations of a free 3d renderer (that can handle a few-million triangle model without difficulty) I could use to render a "spinning planet" animation?
« Last Edit: September 24, 2010, 05:13:57 am by Thief^ »
Logged
Dwarven blood types are not A, B, AB, O but Ale, Wine, Beer, Rum, Whisky and so forth.
It's not an embark so much as seven dwarves having a simultaneous strange mood and going off to build an artifact fortress that menaces with spikes of awesome and hanging rings of death.

ILikePie

  • Bay Watcher
  • Call me Ron
    • View Profile
Re: World domination
« Reply #8 on: September 24, 2010, 05:19:04 am »

Maybe Blender would do. I've haven't done much with it due to it being terribly complex, but it looks pretty good.
Logged

nbonaparte

  • Bay Watcher
    • View Profile
Re: World domination
« Reply #9 on: September 25, 2010, 02:57:07 am »

Unless your computer is really powerful, Blender will have some issues with millions of verts. However, blender doesn't need that. Normal mapping lets you fake it well.
Logged
A service to the forum: clowns=demons, cotton candy=adamantine, clown car=adamantine tube, circus=hell, circus tent=demonic fortress.

Thief^

  • Bay Watcher
  • Official crazy person
    • View Profile
Re: World domination
« Reply #10 on: September 25, 2010, 03:29:32 am »

Ever tried to normal map or texture a sphere?

EDIT: I should add that the above images are vertex coloured.
Should give you an idea of the vertex density.
« Last Edit: September 25, 2010, 03:37:42 am by Thief^ »
Logged
Dwarven blood types are not A, B, AB, O but Ale, Wine, Beer, Rum, Whisky and so forth.
It's not an embark so much as seven dwarves having a simultaneous strange mood and going off to build an artifact fortress that menaces with spikes of awesome and hanging rings of death.

nbonaparte

  • Bay Watcher
    • View Profile
Re: World domination
« Reply #11 on: September 26, 2010, 01:10:41 am »

EDIT: I should add that the above images are vertex coloured.
Should give you an idea of the vertex density.
buh..... WHY?!

And you could always map the vertex colors to a normal/color map onto a lower density sphere. That's how game models get high detail.
Logged
A service to the forum: clowns=demons, cotton candy=adamantine, clown car=adamantine tube, circus=hell, circus tent=demonic fortress.

Thief^

  • Bay Watcher
  • Official crazy person
    • View Profile
Re: World domination
« Reply #12 on: September 27, 2010, 04:26:59 am »

I am a game developer you know :P

Perhaps you don't realise that normal maps are best generated by taking a delta between a (very) high poly model and a low poly model?

And generating textures for this thing would basically involve rendering it...

EDIT: Also the aformentioned problem with UV-wrapping (unwrapping?) a sphere. Distortion ftw.
« Last Edit: September 27, 2010, 04:59:14 am by Thief^ »
Logged
Dwarven blood types are not A, B, AB, O but Ale, Wine, Beer, Rum, Whisky and so forth.
It's not an embark so much as seven dwarves having a simultaneous strange mood and going off to build an artifact fortress that menaces with spikes of awesome and hanging rings of death.

qwertyuiopas

  • Bay Watcher
  • Photoshop is for elves who cannot use MSPaint.
    • View Profile
    • uristqwerty.ca, my current (barren) site.
Re: World domination
« Reply #13 on: September 27, 2010, 04:54:59 pm »

Simply switching to larger triangles for distant areas would probably be good enough at first.
Logged
Eh?
Eh!

Thief^

  • Bay Watcher
  • Official crazy person
    • View Profile
Re: World domination
« Reply #14 on: September 27, 2010, 05:00:03 pm »

Exactly, when I decide to make this thing realtime I'll do exactly that.

For now I think I'll need to add directional lighting to my commandline renderer (it only does ambient and point atm).
Logged
Dwarven blood types are not A, B, AB, O but Ale, Wine, Beer, Rum, Whisky and so forth.
It's not an embark so much as seven dwarves having a simultaneous strange mood and going off to build an artifact fortress that menaces with spikes of awesome and hanging rings of death.
Pages: [1] 2