• entries
    232
  • comments
    1462
  • views
    956536

Planetary engine, Part VII

Sign in to follow this  
Ysaneya

689 views

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.
























Sign in to follow this  


11 Comments


Recommended Comments

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!

Share this comment


Link to comment
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.

Share this comment


Link to comment
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 :)

Share this comment


Link to comment
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..

Share this comment


Link to comment
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?

Share this comment


Link to comment
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.

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now