Skip to main content

vScriptValRelaxScatterOnMesh

Scatter points on the surface of an OBJ mesh, then move each point to spread them out over several relaxation passes.

IntermediateMograph / ScriptValScriptValArrayJSON
vScriptValRelaxScatterOnMesh node

vScriptValRelaxScatterOnMesh reads an OBJ mesh from a file, a URL or text, scatters Point Count points on its triangles and improves their spacing in Relax Iterations passes. Candidates Per Point and Relax Strength control each pass.

Parameters​

ParameterTypeDefaultDescription
Input SourceDropdownFileWhere the OBJ mesh comes from, File, URL or Text. Default File.
FilenameText—Path of the OBJ file. Shown when Input Source is File.
URLText—Address of an OBJ file. Hidden until Input Source is URL.
InputText—OBJ text. Hidden until Input Source is Text.
Scale File Units ByFloat1Multiplier applied to the vertex coordinates. Default 1.
+6 more parameters
ParameterTypeDefaultDescription
Point CountInteger1000Number of points. Minimum 2, default 1000.
Random SeedInteger0Seed of the random generator. Minimum 0, default 0.
Relax IterationsInteger5Number of relaxation passes over all points. Minimum 0, default 5.
Candidates Per PointInteger2Number of new positions tried for each point in each pass. Minimum 1, default 2.
Relax StrengthFloat1Probability that a better candidate replaces the point. Range 0 to 1, default 1.
Surface OffsetFloat0Distance each point is moved along the triangle normal. Default 0.
Read the full description

The node reads the vertex and face lines of the OBJ text, multiplies the vertices by Scale File Units By, and splits faces with more than three vertices into triangles. Point Count points are placed at random positions with a probability proportional to triangle area, and moved along the triangle normal by Surface Offset. If the mesh has no usable triangle, the node outputs nothing.

Each relaxation pass visits every point in order. For a point, the node creates Candidates Per Point new random positions on the mesh. A candidate replaces the point if its distance to the nearest other point is larger than the distance of the point it would replace. With Relax Strength below 1, a replacement that passes this test is carried out only with that probability.

With the defaults (1000 points, 5 iterations, 2 candidates, Relax Strength 1) the node outputs 1000 points. Relax Iterations of 0 gives the plain random scatter. The nearest-neighbor check compares a point with all others, so the node gets slower with higher point counts and more iterations.

The random generator is seeded with Random Seed, so the same Seed, mesh and settings give the same points. The positions are always on the mesh surface, because every candidate is a fresh random position on a triangle. Point Count has a minimum of 2.

Example Connections​

vScriptValRelaxScatterOnMesh.Output -> vScriptValCameraProjection.ArrayA
vScriptValCameraProjection.Output -> vScriptValShapeRender.ArrayPoint
Background.Output -> vScriptValShapeRender.Input