Planetary engine, Part VII

Published August 19, 2007
Advertisement
Planetary engine

See previous journal update for reference.

Displacements

As I mentionned in the previous update, I've experimented horizontal displacements to create cliffs, overhangs and hard edges. It also creates interesting rock formations, similar to what you'd find on volcanoes. The result is looking quite nice, but as expected there are some issues:

- texture deformations
- terrain is no longer a heightmap, so you can't take a world-space position and cast a ray down anymore, and sample the height in the heightfield to get back the world-space position on the terrain.
- lighting is messed up ( more about that soon ), as the deformation only moves the vertex and not the normal
- performance goes down yet a bit lower
- terrain can self-intersect if the displacement is too high

An overview of the algorithm:

- generate a planetary tangent space for the given sample position
- generate a height from procedural algorithms
- generate a vertex in planet space by displacing the vector going from the planet center to the surface by the planet radius plus the height
- use this new vertex as input to fractal noise - get 2 displacement values, one along x coordinate, another along z coordinate
- displace the mesh by using the tangent space and the given 2 displacement values.

Lighting

To generate normals I was simply derivating the heightfield ( taking the 4 adjacent heights ). But after displacement the mesh is no longer a heightfield, so there are two possibilities:

- the wrong ( but easy ) one, is to not do anything and ignore the displacement: lighting is not correct anymore, but it doesn't look too bad. The only real thing I'm worried about is when adding shadow maps later, the diffuse lighting won't match the angle at which the shadow map starts, so you might see strange artifacts.

- the right ( but hard ) way, is to generate the triangles on the cpu and perform a cross product between the adjacent triangles. Unfortunately, the hard part comes from the fact that you get seams between terrain patches, as you only have access to an adjacent patch's heightfield ( and not mesh ). Fixing it would require a few design changes in the terrain code.

I haven't decided which solution I'll finally use, I guess this will mostly depend on how serious the shadow mapping artifacts will be.

Collisions

Yesterday I also implemented collisions on the terrain, just for fun. Wasn't really hard to do it in the "brute force" way: when the mesh of a terrain patch is generated, I also create a collision mesh for it. I then implemented a canon-ball launcher with the left mouse click, and played with launching balls on the terrain for a good half-an-hour. It was funny to see them bounce and roll on this complex terrain. Performance was okay on the collision tests, but generating the collision mesh ( especially as each time a terrain patch gets subdivided in 4, it generates 4 children, each with its collision mesh ) causes small slowdowns.

Pictures time

As usual, click on an image for the 1024x768 version.
























0 likes 11 comments

Comments

Gaheris
Wow, this adds a lot. There are only few games featuring these kinds of displacements in terrain and they're all hand sculpted AFAIK. Great stuff!
August 19, 2007 12:43 PM
Vileedge
Honestly Flavien, that looks amazing . . . especially considering that the previously generated images looked amazing? The deformations seem completely natural, it will get even better when you can start applying other textures with different procedural seeds and, eventually, even flora.

The complexity of the work will definitely depend on those shadows, since the severity of artifacting could become serious.

Hey, I am going to ask for one little favor, could you make a video of yourself playing with the cannonballs on different areas, please? That would make an awesome techdemo video.

Amazing job my friend, simply amazing.

August 19, 2007 01:58 PM
dgreen02
Amazing work as usual.

Well done.
August 19, 2007 02:42 PM
bladerunner627
I think I just wet my pants.

That terrain is so sexy.
August 19, 2007 07:51 PM
Ysaneya
Quote:Original post by Vileedge
Hey, I am going to ask for one little favor, could you make a video of yourself playing with the cannonballs on different areas, please? That would make an awesome techdemo video.


Will do.. later. There are many issues to fix first, before I can take a good video :)

August 20, 2007 03:40 AM
zedz
nice one, looking way better than your old terrain stuff
so when are the trees etc coming (just joking)
August 20, 2007 04:48 AM
Ysaneya
Quote:Original post by zedz
nice one, looking way better than your old terrain stuff
so when are the trees etc coming (just joking)


No joke :) In a few months. There will be trees, rocks, various doodads/natural structures, even icebergs, why not ? And of course, volumetric clouds..
August 20, 2007 01:00 PM
gharen2
Wow very impressive!

This is just a question I'm asking out of idle curiosity, and feel free to ignore it if you're not comfortable with releasing these kinds of details, but are you using a custom physics engine, or a third party one?
August 21, 2007 11:49 PM
freemangl
Great work! IA.
August 22, 2007 09:22 AM
Ysaneya
Quote:Original post by gharen2
Wow very impressive!

This is just a question I'm asking out of idle curiosity, and feel free to ignore it if you're not comfortable with releasing these kinds of details, but are you using a custom physics engine, or a third party one?


I'm using ODE, an open-source physics library.
August 22, 2007 12:28 PM
venzon
Can't wait to see it textured!
August 23, 2007 07:14 PM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement
Advertisement