Home > SpaceSim > Heightmaps and Force Fields

Heightmaps and Force Fields

Work is proceeding on my space war game (SWG); it would be nice if I came up with a proper name for it but for now SWG shall suffice.  For the past couple of weeks I’ve been looking into missile mechanics and shield simulation.  For the missiles I simulate fuel load and consumption, albeit crudely, such that the missile has a limited flight time before tumbling into a fit of self-destructing acrobatics accompanied by a flash of yellow sparkles.

A work buddy suggested that I tackle force fields next and he had the good idea to use a ripple effect – the same sort of ripple effect you get when you drop a badger into a lake.  There is a very simple algorithm[1] that you can use to produce a variable heightmap for use in a water effect and thought this would be suitable for deforming my shields.

The Update method is called once per frame to update the simulation:

Here’s some shots of the ripple effect:

image

image

…and corresponding textured-mesh view:

image

Then of course I went to apply it to an ellipsoid and I was sort of stumped as to how to deformate a 3D object – something with no edges no less.  Realising I was a bit of a buffoon, the obvious answer was not to procedurally modify the mesh via a heightmap but rather use the heightmap as an input into a parallax shader where we can fiddle with the surface normals thus giving the illusion of heightened depth.  So I kept my code above for creating the heightmap but I just tossed the mesh modification.

I wanted my shader to be transparent so the alpha component is merely the heightmap value.

image

Here is a short video of the outcome.

———————————–
[1] “2D Water”, http://freespace.virgin.net/hugo.elias/graphics/x_water.htm

Advertisements
Categories: SpaceSim Tags: , ,
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: