Is it possible to create a custom nonlinear distortion lens in Blender?

I'm assuming that Blender superimposes a rectangular grid in front of the eye, and fires out a ray through the center of each cell on the grid, returning the colour for that pixel.

enter image description here

So my question reduces to: is it possible to replace this grid with my own warped grid?

EDIT: I'm most interested in a code-level solution -- this is for experimental project and as such I would like fine-grained control.

PS I can't find any tags, such as ray-tracing, eye-ray, lens, distortion


Why not use the compositor to achieve this affect?

Doing this in the compositor is really easy. All you need to do is to add a lens distortion node. enter image description here

enter image description here enter image description here

  • $\begingroup$ I thought cycles did support fish-eye lenses? $\endgroup$ – gandalf3 Mar 7 '14 at 21:23
  • $\begingroup$ @gandalf3 I see no option for it? $\endgroup$ – Vader Mar 7 '14 at 21:28
  • $\begingroup$ There is a fish-eye option in Camera > Panoramic > Type. $\endgroup$ – gandalf3 Mar 7 '14 at 21:41
  • 1
    $\begingroup$ oops you are right $\endgroup$ – Vader Mar 7 '14 at 22:05
  • $\begingroup$ But what if you want the camera to use the same lens distortion values (k1, k2, and k3) that camera tracking determines? $\endgroup$ – Chuck Jan 31 '15 at 20:20

If you want to work at the code level -

  1. You can use a custom blender code base by adding your own node that does what you want. Complicated but will give you access to the most data and the most flexibility that is available in the render engine.
  2. Pynodes allows you to create your own nodes, I'm not sure what capabilities these offer. There is a custom nodes example in templates. I believe luxrender uses pynodes to add nodes specific to luxrender.
  3. Create an OSL shader. The limitation would be the object with the osl shader so you probably won't get the full image distortion that you want.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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