Lean out

The lean out expression rotates trees towards the nearest include spline boundary, to use it.

  1. Create a Forest object with Splines defining the Include areas. Randomise rotation as you would Normally
  2. Go to the Effects rollout and enter a value in Lean_Out_Amount. This will determine the angle of the lean effect
  3. To adjust the distance from the boundary's edge that the lean out effect influences, edit the Lean_Out_Distance parameter.
  4. Because the lean out rotation overwrites any randomised rotation use used in the transform rollout you can reintroduce to rotation variation using the RandomWiggle parameter.


Effect Script

#Find vector to nearest border
Vector vec1  =  fpItem.areaIncNearest- fpItem.position;
#calculate lean angle
real angle = atan2(vec1.x,vec1.y)-degtorad(90);

#calculate falloff
real leanOutX = easeIN(fpItem.areaIncDistance,Lean_Out_Distance,0,fpItem.rotation.x,sin(angle+degtorad(randomReal(-randomWiggle,randomWiggle)))*Lean_Out_Amount);
real LeanOutY = easeIn(fpItem.areaIncDistance,Lean_Out_Distance,0,fpItem.rotation.y,cos(angle+degtorad(randomReal(-randomWiggle,randomWiggle)))*Lean_Out_Amount);

#assign lean angles to forest item
fpItem.rotation.x = leanOutX;
fpItem.rotation.y = leanOuty;

You can find this Effect within the Forest Effects Library.

This Effect Uses:


  • Lean_Out_Amount
    Type: Real
  • Lean_Out_Distance
    Type: Scene Units
  • RandomWiggle
    Type: Real


  • fpItem.areaIncNearest
    Vector to nearest include area edge.
  • fpItem.areaIncDistance
    Distance to nearest include area.
  • fpItem.position
    Position vector of individual fp Item.

  • fpItem.rotation.x
    Individual item's X rotation.

  • fpItem.rotation.y
    Individual item's Y rotation.


  • atan2(x,y)
    Returns the principal value of the arc tangent of y/x, expressed in radians
  • degToRad(p)
    Converts degrees to radians.
  • easeIn(x,x1,x2,y1,y2)
    Returns an ease-in interpolation between y1 and y2. Returns y1 when x < x1