MeshSurfaceSampler on a mesh with noise ShaderMaterial

Hello everyone, I can’t find a solution to my problem. Maybe someone can help me.

I want to make a noisy mesh with dots randomly scattered on its surface.

Here are the steps:

  1. Started off with a SphereBufferGeometry
  2. Used a ShaderMaterial to make it more bumpy (ashima noise)
  3. This distorted sphere is my surface for the sampler (white distorted wireframe mesh in the pic)

4) Here is my problem: I tried to use the sampler, but it doesn’t read the changed vertex position of the mesh(sphere). The dots are scattered on the original mesh, ignoring the vertex position attribute changes performed via ShaderMaterial.

I believe a solution to it is a simple trick, but I ran out of ideas.
Here is a fiddle to illustrate the problem:
JSFiddle - MeshSurfaceSampler on a noisy mesh

MeshSurfaceSampler (on JS side) knows nothing about how vertices were shifted on GPU.

1 Like

Thanks for the info, I understand. Bummer.
Do you have any ideas if it’s possible to somehow recalculate it? To feed js with the data from GPU? Or it’s simply not possible via MeshSurfaceSampler and I need to look for solutions outside of it?

Specifically for a sphere, you can compute the same noise value (with the same formula) for its vertices and for positions of instanced spheres on its surface.
A quick and rough example from scratch:


Another option is to apply noise on JS side to a mesh. Then use MeshSurfaceSampler for positioning of objects on the mesh.
What approach to use is up to you :slight_smile:

1 Like

@prisoner849 Thank you so much for your help!:slight_smile:

@pxpx You’re welcome :handshake:

1 Like