Jump to content
  • Advertisement
Sign in to follow this  
  • entries
  • comments
  • views

In the rough

Sign in to follow this  


Playing with the random values.

Okay, so I didn't get onto displaying the heightmap in a 3d view yet. I've been messing around with my class structure and the random offset generator I use for the height displacements. Mainly this is because I realized that I haven't set it out very well for generating portions of the map at a time. My ideal is to be able to generate the top few subdivisions at map-load and be able to "page" in higher-detail sections for when the player zooms in on particular spots.

I wasn't particularly happy with the method I was using for the random displacements. What I have now I feel is much better. Before I was working with a hard-coded height offset that would be multiplied by a dampening weight on each subdivision iteration. I found this to be too fiddly, so I came up with a much simpler setting. The algo I'm using for setting the midpoint height is:
1) Get average (A) of surrounding height values (shape depends on whether we're in the diamond or the square step of the algo).
2) Get maximum difference (D) between the average and the surrounding height values.
3) Get pseudo-random number (P) between -1.0 and 1.0 for the heightmap coordinate.
4) Height value = A + (D * P * R) where R is a "roughness" constant.

Different values of R give (you guessed it) varying degrees of roughness to the terrain. I could use a particular constant for an entire map, but I also plan on allowing the user to set the constant on a per-seed-cell basis (so you can make some spots on the map rougher and some smoother). Here is the output of 3 iterations, using different values for R:
R = 0.4F

R = 0.6F

R = 0.8F

R = 1.0F

R = 1.5F
Sign in to follow this  


Recommended Comments

There are no comments to display.

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
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!