Jump to content
  • Advertisement
Sign in to follow this  
RyxiaN

Raising Terrain - Falloff

This topic is 2779 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 working in SlimDX, but this problem isn't really SlimDX related, so feel free to move the post if you there's a better place for it!

Anyway, I'm working on a 3D world editor in SlimDX and it's going pretty good. But I have a slight problem with the cursor falloff. Let me show you a picture of how I want my terrain to raise with 0% falloff and how I want it to raise with 100% falloff:

0% falloff:
Falloff_Question_04.png

100% falloff:
Falloff_Question_01.png

Now, I have some trouble getting this "exponential function" working. Currently I'm using this formula to get the FalloffFactor: 1 - distance * falloff, where distance is a floating value between 0.0 and 1.0 (1.0 is furthest away, 0.0 is cloest to the cursor position (middle)) and falloff is a floating value between 0.0 and 1.0, where 1.0 is 100% falloff and 0.0 is 0%! Simple! But this is obviously wrong, I get this linear looking hill:
Falloff_Question_02.png

I think you get the point by now :D So, does anyone know how to get this oval effect? Like an exponential function that returns a falloff factor value between 0.0 and 1.0? Thanks in advance!

// Ryxian


Edit:
Managed to get a perfect function at 100% falloff and 0% falloff: 1 - distance^2 / maxDistance^2 * falloff. distance is no longer between 0.0 and 1.0, but the actual distance. This gives a nice curve, but at falloffs like 50% it turns out something like this: (note that everything is drawn in paint, but I think you get the picture)
Falloff_Question_06.png

I would like something like this:
Falloff_Question_05.png

Basically, I still want the smooth edge, but I want it to be more steep at the edge, and more flat near the middle.

Share this post


Link to post
Share on other sites
Advertisement
height - distance^X * falloff * height

Height is the height at the center, falloff should be between 0 and 1. Try out different values for X, but somewhere between 5 and 10 should give pretty steep edges. Distance is expected to be between 0 and 1, so divide actual distance by range of your 'brush'.

Share this post


Link to post
Share on other sites
Cheers, worked like a charm! Used 3 as X btw. (: Also used 1 as your 'height', but meh. :D

private float CalculateFalloff(float falloff, float distance) {
return 1.0F - MathHelper.Power(distance, 3F) * falloff;
}

Share this post


Link to post
Share on other sites
Sorry for double-posting, but I figured I could post this in the same topic! Does anyone have a clue on how to do a Smooth-brush? Like the Startcraft II editor.

Thanks!

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!