Hi, new to Godot and 3D in general. I've been experimenting with some procedural low-poly terrain generation through code and I think it's going really well for my first 3D environment. The goal is to make a flat surface to walk around on, then slope that surface downward into the water like a little island. I'm having trouble with some UV logic now, though.
I'm generating the mesh through code as outlined in this tutorial:
The terrain basically forms a random rectangle then generates tris of random sizes to give it a more rounded/interesting shape. To texture the top part, I can just pass the x and z coordinates of the vertices and have it work brilliantly.

To texture the slope downward, however, I want my pattern to constantly be pointed toward the center of the island. Easy enough for the edges - the top/bottom edges use their x/y coordinates and the left/right edges just use their z/y coordinates. However, for the generated "corner" slopes, using just their x or z coordinate for the UVs has it favour one side then break the tiling on the other, which I guess is expected.
What I'm looking for is some kind of math/logic that will allow me to grab the right coordinates from both the left side (in this case, z/y UVs) and the right side (in this case, x/y UVs) to keep the texture repeating properly. I know it'll skew it a bit, but I'll happily take that over cutting it off. I suspect there is also some other solution I haven't considered that maybe checks the slope's angle to get its direction, regardless of whether it's on the "left" or "bottom" side of the generated mesh. Like I said, new to 3D, so any tips will greatly help my understanding of how this stuff works. Thanks!