# How to Apply Noise to Vertices?

## Recommended Posts

The following functionality applies the current vertices' positions to the same vertices(No change to the mesh).

``````var arr = mesh.getVerticesData(BABYLON.VertexBuffer.PositionKind);

for (var i = 0; i <mesh.getTotalVertices(); i = i++){
var fx = arr[i * 3 + 0]; var fy = arr[i * 3 + 1]; var fz = arr[i * 3 + 2];

arr[i * 3 + 0] = fx;
arr[i * 3 + 1] = fy;
arr[i * 3 + 2] = fz;
}

mesh.setVerticesData(BABYLON.VertexBuffer.PositionKind, arr);``````

I'm unsure as to how to apply a random noise, that still takes into account the vertices that are on the same position?

If I use something like fx/fy/fz + a random value, the faces split up, and creates holes in the mesh.

##### Share on other sites

There are two basic construction methods for a mesh

1. Corners on a mesh share vertices and normals
2. Corners on a mesh do not share vertices and normals. ( A flat shaded mesh)

In BJS a sphere is created using method 1 and a box using method 2.

Should you apply random noise to a mesh constructed with method 2 then the faces will split apart.

PGs

Randomised Sphere (but still split along seam)

more on smoothing function here but not the added TRUE parameter for applyToMesh since we need to maintain update-ability of the mesh

##### Share on other sites

Hmm.

I might be missing something here.

Look at my imported model:

The model has smoothing groups (From 3Ds max). Flat-shaded or smooth doesn't seem to make a difference.

Might this be due to the way the model is exported or created in 3Ds max?

##### Share on other sites

Do not know anything about 3D max.

##### Share on other sites

Hmm. For now, I've been using morph targets, but I'd like some more randomization without having multiple models.

I'll try another model, as the one in this example was a quick one, where I applied the push modifier due to weird normal behavier. This was a bad fix, but the quickest one.

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.