Take the 2-minute tour ×
Blender Stack Exchange is a question and answer site for people who use Blender to create 3D graphics, animations, or games. It's 100% free, no registration required.

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:

enter image description here

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.

share|improve this question
2  
It seems someone has implemented a patch which allows you to define your own distortion with a map. –  gandalf3 Apr 8 at 6:50

2 Answers 2

I am not sure if it can be down in Python. But definitely possible in C.

Blender Cycles support non-planar lenses ala fisheye. You can find the user documentation for it on the wiki.

A walkthrough (and patch) from the developer who implemented this feature can be found on Dalai Felinto's website.

share|improve this answer

I'm not saying it's possible with python, but here's somewhere to start: 1,2. As a side note, blender's model is to shoot out one ray per square, unless anti-aliasing is enabled under the render panel. With antialising, it uses the specified amount of samples and mixing algorithm.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.