private Color32 GetCameraPixelBilinear(uint[] cameraPixels, int cameraNum, float u, float v)
{
u *= cameraWidth;
v *= cameraHeight;
int left = (int)Math.Floor(u);
int right = (int)Math.Min(cameraWidth - 1, left + 1);
int top = (int)Math.Floor(v);
int bottom = (int)Math.Min(cameraHeight - 1, top + 1);
float uFrac = u - left;
float vFrac = v - top;
int baseIdx = cameraNum * cameraWidth * cameraHeight;
int topRow = baseIdx + top * cameraWidth;
int bottomRow = baseIdx + bottom * cameraWidth;
uint topLeft = cameraPixels[topRow + left ];
uint topRight = cameraPixels[topRow + right];
uint bottomLeft = cameraPixels[bottomRow + left ];
uint bottomRight = cameraPixels[bottomRow + right];
float r = Mathf.Lerp(Mathf.Lerp( topLeft >> 16 , bottomLeft >> 16 , vFrac),
Mathf.Lerp( topRight >> 16 , bottomRight >> 16 , vFrac), uFrac);
float g = Mathf.Lerp(Mathf.Lerp((topLeft >> 8) & 0xFF, (bottomLeft >> 8) & 0xFF, vFrac),
Mathf.Lerp((topRight >> 8) & 0xFF, (bottomRight >> 8) & 0xFF, vFrac), uFrac);
float b = Mathf.Lerp(Mathf.Lerp( topLeft & 0xFF, bottomLeft & 0xFF, vFrac),
Mathf.Lerp( topRight & 0xFF, bottomRight & 0xFF, vFrac), uFrac);
return new Color(r / 255.0f, g / 255.0f, b / 255.0f, 1.0f);
}