not going to lie it took me a hot minute to realize you do need a midpoint to invert height. would sea level be a good mid point? im not sure how i can assist in this project but if you can point me in the right direction i will help however i can.

chat gpt said you could use this other option:

[Spoiler]
give me algerbraic logic for inverting a height map simmilar to this:
upper bounds: 99
lower bounds:-44
ChatGPT said:
ChatGPT
To invert a height map with specified upper and lower bounds algebraically, you can express the relationship between the original value and its mapped output. Let's say you want to map a height value hh from the range defined by:
Upper bound U=99U=99
Lower bound L=−44L=−44
Step 1: Normalizing the Height Value
First, you need to normalize the height value to a range between 0 and 1:
n=h−LU−L
n=U−Lh−L
Where nn is the normalized value.
Step 2: Inverting the Normalized Value
To invert the mapping, you need to derive hh from nn. If you have a normalized value n′n′ that you want to invert back to height h′h′:
h′=n′⋅(U−L)+L
h′=n′⋅(U−L)+L
Example
If you have a normalized value n′=0.5n′=0.5, you can find the original height:
h′=0.5⋅(99−(−44))+(−44)
h′=0.5⋅(99−(−44))+(−44)
Calculating it:
h′=0.5⋅(143)−44=71.5−44=27.5
h′=0.5⋅(143)−44=71.5−44=27.5
Summary
Normalize: n=h−LU−Ln=U−Lh−L
Invert: h′=n′⋅(U−L)+Lh′=n′⋅(U−L)+L
This approach will let you invert any height value within the bounds you've specified. If you have specific values or cases you'd like to explore, feel free to share!

edit:

sea level is sometimes way bellow groundlevel. so maybe an average height might be a good midpoint but that might not be possible.

some old code i made that inverts speed:

[Spoiler]
if ud.speed then
if ud.speed > highestspeed then
highestspeed = ud.speed
end
if ud.speed < lowestspeed then
lowestspeed = ud.speed
end
end
if ud.speed then
local distance_speed_midpoint = ud.speed - lowestspeed
ud.speed = highestspeed - distance_speed_midpoint
end

ofc you wont need any of this because your a code wizzard and far above my level =D

i would write it myself but im not sure how to even begin.