Input condition:
There are some sampled points are on the surface of the mesh(excluded geometry).
We already known these sampled points’s world coordinates and color.
Expected result:
The mesh’s material(each pixel color of surface) is colored according to some sampled points’ color.
The situation should use fragmentshader?
Is there 3D sampled points’s texture (not DataArrayTexture)?
Please give some examples, thanks!
For that you can simply use MeshBasicMaterial and .color property that can be set and changed any time, not sure why would you need 3D texture or use custom fragment shader.
The MeshBasicMaterial and .color is for vertex’s color of mesh, for example:three.js examples
This way is impossible to fix the issue.
My case’s condition is as follows:
Sampled points are not equal to vertex of mesh.
Sampled points have different colors.
The sequence steps of the program is as follows:
- Firstly, create the mesh just once when program startup.
- Change sampled distance to 1 cm, get irregular sampled points on surface of the mesh.
- Then, update the mesh’s material color according to sampled points’ colors.
- Change sampled distance to 2 cm, get 2nd new irregular sampled points on surface of the mesh.
- Then, update the mesh’s material color according to 2nd new sampled points’ colors.
Not sure I follow:
in this setup:
new THREE.MeshBasicMaterial({
color: 0xffffff,
}),
the color is applied to the whole mesh (in fragment shader to each pixel), not to individual vertices
in this setup:
new THREE.MeshBasicMaterial({
color: 0xffffff,
vertexColors: true,
}),
and if you provide ‘color’ attribute - colors are assigned to vertices and mixed with the material color.
So you have both options, see this example:
Change vertexColors: false to vertexColors: true and observe the difference.