для этой страницы,
отображается код на другом
The World Clutter node allows scattering a set of identical nodes (node references) randomly across the scene practically in one click. There is no need any longer to position, scale, and rotate every single object by hand and constantly mind the performance factor. World Clutter automatically places nodes in the scene with random parameters, all of which can be efficiently controlled, and renders them only around the camera. WorldClutter object is used to scatter non-geometry objects, such as decals, particles systems, and so on. But if you want to scatter identical meshes, it is better to use Mesh Clutter.
World Clutter scatters objects procedurally and therefore even more memory-efficient. At the same time it means that scattered objects cannot be moved.
- The WorldClutter class to edit world clutters via API
Creating a World Clutter#
To create the World Clutter object, do the following:
- Add a World Clutter node: on the Menu Bar, choose Create -> Clutter -> Node.
- Locate the world clutter on the scene.
Objects in a Clutter are node references that are scattered throughout a definite area and for each of which the probability of its appearing is controlled.
|Probability slider||The higher the probability, the more often a node reference can be seen compared to other Clutter objects. Let's say, we create a coast with wood chips and algae. We create wood chips decal and algae decal and save them as *.node files (create a NodeReference file). If the probability slider for algae is near to zero, the coast is thick with wood chips and only several algae are seen among them. Changing the probability of appearing does not affect the number of rendered objects, it only specifies the proportion between several clutter objects.
|Add||Add a reference node to the list of Clutter objects.|
|Remove||Delete all selected node references from the list. To select an object, a box near it should be checked.|
|Reload||Reload all the node references in the Clutter. After a node reference was edited, the saved changes are not automatically applied to the same nodes scattered by the Clutter. It happens because a reference node after being loaded once is copied from the internal cache, which allows creating a lot of copies really fast. Reload option updates this cache and the changes in objects parameters come in effect.|
World Clutter Parameters#
The World Clutter is rendered as a 2D grid, in each cell of which a number of clutter objects are randomly placed depending on the Clutter density and probability of appearing. The cells are generated one by one starting from the nearest ones. This approach allows to control how close or far the scattered objects are from each other and at the same time reduce the rendering load when the camera moves and farther cells become visible.
Once added and scattered, the objects cannot be moved or rotated. The only way to change the scattering pattern is to change the seed.
|The size of the clutter bounding box along X and Y axis. Within this area objects will be scattered with specified density.
|Step for cells||Cell size in units. The number of cells in the Clutter is defined in the following way: size of the Clutter (both alongX and Y) is divided by the step.
|Density||Density specifies how many objects there are per square unit. In case there are more than one object in the Clutter, probability will be taken into account, but will not change the resulting number of all rendered objects.
|Visibility distance||Across the visibility distance the number of objects is strictly specified by the density parameters. It means that all objects that should be present are found in place.
|Fade Distance||Across the fade distance the number of objects gradually decreases, as they disappear randomly one by one. Fade distance is measured starting from the Visibility distance. If fade distance is set, there is no clear line where the objects that are contained in the Clutter abruptly disappear. Instead, a few of them will be left smoothly blend into the background without any visual noise.
For the best result, it is also recommended to combine this effect with objects fade-out.
|Spawn Rate||Determines how many cells (in which the world clutter is rendered) are updated each frame.
Setting too high number of updated cells may lead to a performance spike.
|Seed||The seed value for pseudo random number generator allows to create different patterns of automatic positioning. The seed is either be set manually or an engine provides a random value for a seed (Randomize option).|
Randomizing Clutter Objects#
To randomize the appearance of objects that compose the World Clutter, two types of values are used:
- Mean value (i.e.Scale, Offset, Rotation) defines the average value. This is the basic value that will be randomly made higher or lower.
- Spread value defines the range for possible variation of the parameter. The higher the value, the more diverse the final result will be.
Spread value is optional: if set to 0, it will not influence the simulation process and only the mean value will be used for all objects.
After these values are specified, each parameter is calculated according to the following formula:
- Result = Mean + Random * Spread
|Min and Max Scale||The scale mean value of scattered objects depends on the minimum and maximum scale mean values and the image mask values: the mask values are used to linearly interpolate between the minimum and maximum scale values.
|Offset||Height offset parameter controls whether all objects are positioned at one height or some are found higher or lower. For example, with offset stones can be dug deep into the ground so that only a small top part is visible, or placed higher and look bigger.
Rotation Y Rotation Z
|These parameters allow to randomly orient the scattered objects.
Masking Areas with Objects#
Having objects uniformly scattered in all directions and places is naturally not very convenient. Instead of creating a number of small World Clutter nodes that cover a limited location, a big one can be used with a mask.
|Image Mask||Areas across which the objects are randomly scattered and areas where there will be no objects from the list. For example, on the terrain a mask allows to scatter rubbish across certain areas, while leaving other places free of it
To paint the image mask directly in the scene, use Mask Editor.
|Threshold for mask||To control the strength of masking, a mask threshold is used. It checks the masked density for an area and if a threshold value is higher than the color value of the mask, objects are scattered across it. If the masked density is not enough, the places is left bare.
|Mesh Mask||A mesh-based mask can be used to place the objects. Vector masking allows not to depend the mask texture resolution and create roads, rivers, etc. with extremely high precision. A mesh for masking should be a simple planar mesh.|
|Inverse||The Inverse flag toggles if the objects are placed inside or outside the mesh contour.|
|Min and Max mask values||As a solution for advanced objects distribution and memory consumption optimization not only a whole mask, but any required part of it can be applied to the object. It means that different multiple objects can share the same mask, but use different levels.
By default, each channel of the image mask specifies the areas and the density of growth in the [0;255] color density range. However, by using Min value and Max value, you can specify any color density range within and the part of the mask, which contains the corresponding values, will be used to scatter the nodes.
For example, there is the following R8 image mask:
Several node objects that represent nodes of different heights can share this mask as follows:
|Flip X||Image Mask horizontal flip.|
|Flip Y||Image Mask vertical flip.|
|Cutout Intersection||Cutout bit mask. This mask is used to cut out clutter objects in the areas of intersection with objects and decals (e.g. can be used to remove vegetation under houses or from the surface of roads projected using decals). Clutter objects will be cut out by objects and decals that have their intersection masks matching this one (one bit at least).|
|Cutout Inverse||Toggles the value that indicates whether the clutter objects should be rendered inside or outside the areas determined by the cutout intersection mask.|
Orienting along the Relief#
Unless objects in the World Clutter are scattered over a completely flat and non-tilted surface, they can be automatically positioned to precisely repeat ups and downs of the relief without any effort. For that, an underlying surface should be made a parent of the World Clutter node. (If there are some nodes in the hierarchy between a terrain or mesh node and World Clutter, intersections will still be checked.)
A parent for intersection can only be a terrain or a mesh object. The mesh should be terrain-like, i.e. it should have only one surface vertically, along the Z coordinate.
|Intersection||After the Intersection box is checked, objects in the World Clutter will be scattered across the surface of the parent object.
|Orientation||This option allows to set a parent surface normal vector as the initial orientation for scattered objects. It means, if the surface in some place is vertical, the up direction for objects scattered over it will be actually pointing to the side.
|Angle||Just like in the case with grass, the scattering can take into account how steep the slope is.