This question is identical to Custom nonlinear distortion lens
With one difference: I'm only interested in a solution at the code level. Because that gives a fine-grained control.
How does one go about doing this?
Here is the setup:
For each square on that grid, a ray is shot out through each corner, returning a colour. The four corners are averaged, and the resultant colour is given to that pixel. (if there is more than a certain maximum allowed amount of variation between the 4 values, the square is cut up into 4 little squares, and so on, recursively)
That's the standard projection model I'm familiar with.
What I want to do is manually fire out rays myself.
I'm guessing that somewhere low down in the C code level, there is some routine that performs this operation.
But where? Can someone direct me? I would be very daunted to have to hunt it down myself through the Blender source code.
And can this be done in Python? Is there some command for firing a ray and retrieving the colour? If this is the case then I could in theory write my own ray projector, and save the resulting 2D RGB array to file.