Jump to content
  • Advertisement
Sign in to follow this  

Flatten tool - angle

This topic is 2117 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm coming for advice how to make flatten tool with option angle.
What I have done?
Simple, I have whole function for making flat terrain, also in following picture you can see its working.


I'm using following formula to making terrain flatten:

// @change(float) = pow(0.2f, dt)
// @mapData[index](float): heightmap
// @y(float): height at cursor position
float changeFormula = change * mapData[index] + (1 - change) * y;

mapIndex[index] = changeFormula;

// sending mapIndex[index] to repaint

Now what I want to do with terrain?

Simple again... following picture for better describing



Biggest trouble for me is making formula, I don't know how to make it. If you are math genius tell me please what I need or if its very easy for you if you can solve it.



Share this post

Link to post
Share on other sites

If you know the plane equation of the flattening plane (ax + by + cz - d = 0), you can plug the x and y coordinates of any texel in the heightmap into it to retrieve the z-value of the plane on that position. Next, you can cut off any z-values that lie above the plane. z = min(z-in-map, z-on-plane).


The simplest way to come up with such a plane is to use the camera-viewport vector as the plane's normal (as to flatten in screen space) and set d = "dot(float3(x, y, height at cursor position), normal).

Edited by eppo

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!