• Create Account

## Flatten tool - angle

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

### #1glararan  Members

254
Like
0Likes
Like

Posted 03 January 2014 - 03:30 PM

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.

### #2eppo  Members

4598
Like
0Likes
Like

Posted 04 January 2014 - 12:41 PM

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, 04 January 2014 - 01:02 PM.

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.