How to create the mesh which behaves like terrain at runtime with code?

I want to create a plane mesh for water rendering at runtime.
The mesh should have lots of verts because the water need vert animation effect and I want to optimize the number of verts.
So the most important thing is that the part which is more far to the camera should have less verts just like the unity terrain.
However, I know the relative algorithm.
Which should I start to learn?

you’re describing a tesselation shader to a T.

Unity - Manual: Tessellation Surface Shader examples in the Built-In Render Pipeline

Tessellation shader does not work well with metal.
I want to rendering ocean on mobile platform.
Does mesh of terrain in unity realized by tessellation shader?
Is there any other solution?

there is a bit of hacky way, that being parenting the water to the camera and calculating it’s height in shader where you do wave math. the trick here is to have the plane be subdivided more in the center, where the triangles matter more, thus removing the need for any runtime tesselation. you’ll also need to calculate some math for scrolling uv’s based on camera position.

and if you need to rotate the camera, parent the player instead.