Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4570864
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T19:25:22+00:00 2026-05-21T19:25:22+00:00

I am trying to come up with a technique to generate a height map

  • 0

I am trying to come up with a technique to generate a height map for a meteor crater. I’m trying to keep is small and simple at the moment, and have a simple algorithm where the centre of the crater is marked, and within its radius, pixels around it are coloured depending on how close to the center they are.

The problem with this method is it is producing V shaped craters, I require more ‘U’ shaped results. I’m unfarmilliar with the use of sine waves and I get the feeling interpolation wont work very quickly given how many pixels could be inside the meteor radius.

Any suggestions?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T19:25:22+00:00Added an answer on May 21, 2026 at 7:25 pm

    I assume you have a texture or other picture format that can be indexed over width and height (x,y) and that the crater is also given in x,y with x,y inside the texture, this would produce an algorithm like this.

    Texture2D texture = ...;
    Vector2 craterPosition = new Vector2(50,50);
    double maxDistance = Math.Sqrt(Math.Pow(texture.Width,2) + Math.Pow(texture.Height,2));
    for(int x = 0; x < texture.Width; x++)
    {
        for(int y = 0; y < texture.Height; y++)
        {
            double distance = Math.Sqrt(Math.Pow(x - craterPosition.x, 2) + Math.Pow(y - craterPosition.y, 2));
            //the lower distance is, the more intense the impact of the crater should be
            //I don't know your color scheme, but let's assume that R=0.0f is the lowest point and R = 1.0f is the highest
            distance /= maxDistance;
            double height = (Math.Cos(distance * Math.Pi + Math.Pi) + 1.0) / 2.0;
            texture[x,y] = new Color((float)height,0,0,1);        
        }
    }
    

    The most important line here is probably

    double height = (Math.Cos(distance * Math.Pi + Math.Pi) + 1.0) / 2.0;
    

    Take a look at the cosine curve http://upload.wikimedia.org/wikipedia/commons/thumb/b/b6/Cos.svg/500px-Cos.svg.png it has a nice smooth ‘crater like’ rounding from Pi to TwoPi. Since our distance variable is scaled from 0~1 we use distance *Pi + Pi. But this will give us a result from -1 to 1. So we add 1 to the end result and then divide by 2 to get a smooth result for the height between 0 and 1.

    I hope this helps you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to come up with a simple and efficient way to create a
I am trying come up with a way to pull the tables out of
I am trying to come up with the best way to render some hierarchical
I've been trying to come up with a way to create a 3 column
I'm trying to come up with a Java regex that will match a filename
I am trying to come up with such a solution that the user is
I am trying to come up with the best data structure for use in
We're trying to come up with a recommended design pattern for our team when
I am trying to come up with a best practices on project directory structure.
I'm trying to come up with a reusable JS or jQuery function that would

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.