How to read pixels of texture?

You are close!

Check this project and the terrain-distribute script on how to read pixel data directly. Most notably these two methods:

TerrainDistribute.prototype.getImageData()
TerrainDistribute.prototype.distribute()

https://playcanvas.com/project/539384/overview/tiled-terrain-manager

https://playcanvas.com/editor/code/539384?tabs=11346077

2 Likes