Monday, December 17, 2012

Deformable Terrain

I have added an algorithm to blast off (destroy) terrain based on user input. I am using the following algorithm to achieve the same.

  • When the user clicks on the output screen, depending on the coordinates, a ray is generated from the camera into the screen.
  • This ray is traced for a random distance and then the terrain at that location is marked for destruction.
  • A random radius is generated.
  • The center and the radius of the circle to be destroyed are stored in an array and passed to the Tessellation Evaluation Shader (TES).
  • The TES flattens the height based on some value generated using Perlin noise.
  • The TES then perturbs the vertices by small amounts to give the destroyed area some random shape.
The number of deformations are currently limited by the array size as the 4.0 shaders do not allow dynamic arrays. 
The red ellipse above shows the destroyed part of the terrain

No comments:

Post a Comment