I’m not aware of a solution, sorry. You need some sort of object detection to find the river in the image first. And then you have to map somehow the related parts of the image to a connected list of triangles. This is all non-trivial stuff.
I can only add advice of one of solution. After click, need to render screen like renderTarget, then get pixel color of clicked coordinate. Then in terrrain shader add uniform there can add selected pixel color. And into shader add code which highlight same pixel of color height. But its highlight all same pixels, not only arround.
If need hightlight only river, then maybe need second invisible terrain with texture where terrrain white, and river blue. Then click, run renderTarget, get pixel color. If color is blue, then in real terrain highlight river. Its mean need add in terrain shader code with uniform like:
You should look into flood fill and marching ants algorithm, that’s too broad so i can only describe it in short, especially since there’s plenty room for optimizations.
For a brief description of the solution:
Use a 1 channel Uint8Array mask in the resolution of the terrain
Use flood fill to mark the texels of the pixels of same height (or with tolerance) in that mask
Use marching ants to get the contour line of the mask
The mask could be obviously smaller by doing a flood fill bounding box pre-pass. You might also want or need to prevent 1 pixel lines from the flood fill causing too noisy details or the contouring to fail.
Technically it’s like the magic wand selection in Photoshop.
i didn’t know where to start with but what i needed was to select a space in the terrain and rather than just selecting the pixel i want it to select multiple pixel. For that it turned out that i need to create a contour tree but i dont know how to make a contour tree in my case where i have mesh, elevation map / height map data/image, and image to map over the terrain. Can you please help me !!!
What i described gives you the contour as a linked list you can simplify by angle then. If you don’t know how to do any of it you can also commission someone.