Followers 0

# Flatten tool - angle

## 1 post in this topic

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.

0

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

## Create an account

Register a new account