Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Terrain Easing Command | By MelonBP
- This command will let you ease selected terrain into a flat plane. There are 5 variables (a, b, u, v, w) in the command that are available for you to configure some things (explained below). These variables are assigned values at the beginning of the expression, and to change them just adjust the numbers to your preference.
- ## The command:
- //deform a=1.2;b=5;u=15;v=15;w=0.3;y=(y+1)*(e^((a*x)^(2*b)+(a*z)^(2*b))+(1-e^(-(a*x)^(2*b)-(a*z)^(2*b)))*w*(sin(u*x)+sin(v*z)))-1
- ## The variables:
- * 'a' controls the distance from the center of the selection at which the terrain flattens out. Counterintuitively, though, a larger value for 'a' means a shorter "radius", and vice versa.
- * 'b' controls the steepness of the terrain falloff. The larger the value of this variable, the steeper the "ease" will be. Important note: 'b' *must* be a positive integer, or else some weird stuff will probably happen.
- * 'u' controls how wavy the edge of the terrain is in the x-direction, and 'v' does the same in the z-direction. These variables are actually the frequency of a sine function, so larger values result in more frequent waves, and vice versa.
- * 'w' controls the amplitude of the edge-waves. Larger values mean more pronounced waves, and vice versa.
- For reference, the variables used for each demo picture in my tweet are:
- * Top right:
- a=1.2;b=5,u=15;v=15;w=0.3
- * Bottom left:
- a=1.5;b=2;u=8;v=15;w=0.4
- * Bottom right:
- a=1.3;b=3;u=9;v=5;w=0.45
- The default variable settings in the command should yield a good result, but I encourage you to mess around with them and make something unique and interesting. Enjoy!
- --
- ### The nerd shit:
- So what this command essentially does is scale the y-axis of the selected region along its horizontal border. The way I achieved this is by using a 3-dimensional sort of "bell curve" function for the scale factor at any (x,z) point in the selection. This function gives outputs near 1 for inputs (x,z) near 0, and outputs near 0 for inputs away from 0, and also has a nice easing transition between these output values, which is a bonus. So the command evaluates this function at every point, and scales in the y-direction accordingly. Scaling (multiplying) by ~1 doesn't change much, but scaling by ~0 collapses the height almost entirely. Since the function transitions smoothly between these two edge cases, the deformed terrain also gets a smooth transition into the border.
- The //deform command creates a coordinate system within the selection with axes ranging from -1 to 1 between the boundaries. This convention cooperates nicely with the "bell curve", which takes x and z coordinates as inputs, but the y-axis needs to be transformed a bit. Since y=0 is the vertical center of the selection by default, this means that scaling a height by 0 contracts the column of blocks to the middle instead of the bottom. So to compensate for this, the y-axis is offset by +1 (-1 at the bottom becomes 0, 0 at the center becomes 1, 1 at the top becomes 2) and then the y-axis is scaled down by 0.5 (0 at the bottom stays 0, 1 at the center becomes 0.5, 2 at the top becomes 1). Now, the y-coordinates within the selection range from 0 to 1 from bottom to top, so scaling in this direction works as it should.
- Finally, the "waves" exist in the command because the edge of the terrain would be very uniform otherwise. The waves provide some variation along the falloff, but also *only* along the falloff; otherwise, the shape of the central terrain would be noticeably affected. Subtracting the same "bell curve" function from 1 results in the inverse of the scale factors that are used to scale the terrain's height So this "inverse bell" (I made that name up) is the scale factor for the waves.
- I hope that explanation made sense :P
Add Comment
Please, Sign In to add comment