Place items on a displaced surface
Overview
If you use Displacement maps to create terrain, then this effect can help. It allows you to position the objects on the Z axis to match the displaced mesh with additional controls to randomise each item's position on the Z axis. To use it download and load items on displaced surface.eff and follow these steps:
-
Add item(s) in the Geometry rollout in the usual way. You can mix items of different heights.
-
Align Forest Pack with the displaced plane on the Z axis.
-
In the Transform rollout, enter a value of 100% for both the Z Min and Z Max parameters. Activate Z > Map and Probability map.
-
Apply the displacement texture to the Map input slot.
-
Feel free to add any Scale randomisation, the effect can compensate for differently sized items.
-
In the Distribution rollout, set the Collision Height to 100%. Once the value has been changed, collisions can be turned off if you don't need them.
-
Go to the Effects rollout and click DisplacementSize select the Amount Controller of the V-Ray Displacement modifier (or other similar plugin) that is applied to the surface. The tree's Z position is now driven by this value, changing the parameter also automatically updates Forest Pack's distribution.
-
Use zRandMin and zRandMax to add additional Z position randomisation to the items after displacement.
-
Use AltitudeLimitTop to hide objects above a certain height.
-
Use AltitudeLimitBottom to hide objects below certain height.
-
Use topFalloff to gradually scale objects to 0 as they approach the height set in AltitudeLimitTop.
-
Use bottomFalloff to gradually scale objects to 0 as they approach the height set in AltitudeLimitBottom.
This effect will not allow you to use the Slope or Direction controls in the surface rollout.
Effect Script
#set position
real actualHeight = (fpItem.collisionHeight/fpItem.scale.z)*1;
real displacedPercentage = fpItem.position.z/actualHeight;
fpItem.position.z =(displacedPercentage*DisplacementSize)+randomReal(zRandMin, zRandMax);
#Limit by altitude
fpItem.visible = if(fpItem.position.z<AltitudeLimitTop,if(fpItem.position.z>AltitudeLimitBottom,1,0),0);
#Size by altitude
vector falloffScale = if(fpItem.position.z>AltitudeLimitTop-topFalloff, ((topFalloff-(fpItem.position.z-(AltitudeLimitTop-topFalloff)))/topFalloff)*fpItem.scale,fpItem.scale);
fpItem.scale = falloffScale;
falloffScale = if(fpItem.position.z<AltitudeLimitBottom+BottomFalloff, (((fpItem.position.z-AltitudeLimitBottom))/BottomFalloff)*fpItem.scale,fpItem.Scale);
fpItem.scale = falloffScale;
You can find this Effect within the Forest Effects Library.
Sample scene: displacementEffect.max
This Effect Uses
Parameters
-
DisplacementSize
Type: Scene Units
This reads the value of another controller in the scene. Use it to select the Amount parameter of a displacement modifier.
-
zRandMin
Type: Scene Units
-
zRandMax
Type: Scene Units
-
AltitudeLimitTop
Type: Scene Units
-
AltitudeLimitBottom
Type: Scene Units
-
topFalloff
Type: Scene Units
-
bottomFalloff
Type: Scene Units
Attributes
-
fpItem.position
Position vector of individual fp Item.
-
fpItem.collisionHeight
The collision height of collision sphere for the current item.
Functions
-
randomReal(a,b)
Returns a real random number in the range a,b