I'm surprised how difficult it is to find information on this particular scenario so please let me know what the easiest way is. I'd like to know what's the simplest GDScript example for offsetting the vertices of a CSG node along their normals, for instance on a CSGSphere3D for random terrain on a planet.
I only need a few basic rules to be followed: The script must iterate through all vertices, read the intensity of a 3D noise at that location, then move the vertice up or down based on noise value. Movement is done in the normal direction not on a fixed axis, so for a sphere it goes toward or away from its center. The script should modify geometry on the CSG node it's being ran on, it should be computed after children's geometry was merged into self and before self's geometry affects its parent. Obviously collisions should be recalculated, CSG nodes do this automatically so hopefully the script doesn't explicitly need to trigger it.
I won't use shader displacement as it doesn't affect collisions, I'd have gladly made a custom shader but with no way to make it collide it would result in ghost terrain. As I may have things such as tunnels or caves cutting through the terrain as well as objects merging with it, I explicitly want CSG for its extra flexibility, hopefully the same vertex functions can run on both CSG and standard meshes.