Displacement map on shape

I am trying to apply displacement map on a face of a box.

PG link

It works on a sphere, but no on a box :frowning:

Can anybody explain how to apply displacement map on one face of a box?

Thanks!!

You must set the vertices updatable:

https://www.babylonjs-playground.com/#WUYDVT#25
image

You can subdivide the cube to increase the vertex count to get better result, but itโ€™s still not very nice:

https://www.babylonjs-playground.com/#WUYDVT#26
image

The cube is not really suited for this displacement map.

Note that thereโ€™s a bug with Mesh.increaseVertices, the PG above will only work once this PR is merged:

2 Likes

Thanks for the explanation!!

How about I create a ground using CreateGroundFromHeightMap and merge it with the face of the cube that I want?

Do you think it would be too inefficient?

Is sphere the only shape that can be used with displacement map??

Any shape can be used with displacement map, but the result will depend on this shape and the map.

You can also create a ground and apply the displacement map on it.

Sorry for the late reply! Yes, applying a displacement map on a ground sounds like a smart idea :smiley:

1 Like