Please note: Originally posted in stack overflow, redirected due to nature of problem.
I am making a procedural mesh game. I am trying to calculate the temperature for the player's current chunk by getting nearby temperature values and interpolating.
The way this works is, let's say we are at world space 95, 0, 65 (x,y,z). What I do is:
1) generate, using perlin noise, temperature values for every 20 squares (smartly generated to only do so to the 4 squares most relevant to us at any given time). We will get the points: 80, 0, 60 100, 0, 60 80, 0, 80 100, 0, 80
Each of these points is fed into a perlin noise generator and spits out a number. That number is the temperature.
So, in order to make the climate smoothly transition, I need to figure out how to get the distance each point weighted against its temperature so I can calculate the temperature of the space I am standing in.
If there is a name for this (there must be, I'm essentially sampling a gradient made by four points) and a way to do it, please just link that instead.
I tried taking the distance from my point to each point and multiplying that number against the temperature at that point, but I'm not sure if that's a correct first step, or what to do from there (just average the four resulting numbers?!).