# 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.

## Recommended Posts

Hello,

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.

Thanks.

##### 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

• ### Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• 9
• 11
• 15
• 21
• 26