Hi, I am trying to build some grass patches with MeshSurfaceSampler
with InstancedMesh
.
The patch surface i am sampling is a mesh with a merged geometry of a circles (with random thetaStart) and other shapes.
The patch is also mapped with a gradient texture
/// merge all surface geometries created in the loop for all images within the room
var merged_surface_geom = mergeBufferGeometries(surface_geom_array, false)
var grass_surface_mat = new THREE.MeshBasicMaterial({
color: 0xffffff,
side: 1,
opacity: 1,
map: colorTexture,
alphaMap: colorTexture,
alphaTest: 0.5,
transparent: true,
})
var grass_surface_mesh = new THREE.Mesh(
merged_surface_geom,
grass_surface_mat
)
grass_surface_mesh.visible = true
// add to subparent
single_world_grp.add(grass_surface_mesh)
var sampler = new MeshSurfaceSampler(grass_surface_mesh)
.setWeightAttribute('color')
.build()
With the summarized code above, i managed to create this. I am trying to make the grass grow more in the areas where there are colors (from the mapped texture?)
But as you can see, the grass seems to grow pretty evenly / randomly . How do i use ‘color’ weighted attribute from MeshSurfaceSampler to achieve the weighted sampling on colors?