Jump to content

How to Apply Noise to Vertices?


Raggar
 Share

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.

Link to comment
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)

(read more here )

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)

Flat Shaded Randomised Sphere

Randomised Box

"Smoothed Randomised Box

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

 

Link to comment
Share on other sites

  • 3 weeks later...

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.

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...