What if we could render fisheye images directly from Blender? Yesterday I found out about the Equirectangular mode in Cycles. It got me quite thrilled (it’s been awhile since I was waiting for that).

This is only possible because Cycles is a full ray tracer render engine. Every pixel in the image is generated from a ray coming from the camera to anywhere in the scene. Enough talking. A quick hack in the code and tcharan:

 

IBL background plate + ibl toolkit (alignment addon) + cycles 'use panorama' + fisheye patch

And the nice thing is, it previews in 3D just as well:

What comes next? I will talk with Brecht to see if there is any pending design to have this implemented as another camera option. I would like to have an option to set the angle (so we don’t need to do only 180 degrees fisheyes). And to toggle between hemispherical and angular fisheye modes.

I you compile your own Blender and want to try the patch, get it here or:

Index: intern/cycles/kernel/kernel_montecarlo.h
===================================================================
--- intern/cycles/kernel/kernel_montecarlo.h    (revision 45899)
+++ intern/cycles/kernel/kernel_montecarlo.h    (working copy)
@@ -215,13 +215,29 @@
 
 __device float3 equirectangular_to_direction(float u, float v)
 {
+   u = (u - 0.5f) * 2.f;
+   v = (v - 0.5f) * 2.f;
+
+   float r = sqrt(u*u + v*v);
+   float theta = acosf(u/r);
+
+   if (v < 0.f) theta = -theta;
+
+   return make_float3(
+       sqrtf((1.f - r*r)),
+       -cosf(theta)*r,
+       sinf(theta)*r
+   );
+
+
+/*
    float phi = M_PI_F*(1.0f - 2.0f*u);
    float theta = M_PI_F*(1.0f - v);
-
    return make_float3(
        sin(theta)*cos(phi),
        sin(theta)*sin(phi),
        cos(theta));
+*/
 }
 
 /* Mirror Ball <-> Cartesion direction */

 


Dalai
* IBL from HDR Labs
* IBL Toolkit explained here.

9 Thoughts on “Fisheye in Cycles, yes we can !

  1. Wow, Dalai! That’s really great!

    And if we have the ability to change the set the angle manually it will bring us a lot of artistic freedom to achieve interesting effects. Thanks! 😀

  2. admin on April 24, 2012 at 1:11 pm said:

    Hey Virgílio,
    Yes, this is certainly in the plans.
    Let’s see what May brings to us 😉

  3. WOW! It’s awsome, thanks for share the script

  4. Pingback: Photographic Fisheye lens in Blender (Cycles) | Dalai Felinto

  5. hi! awesome stuff…

    I asked on another site and I thought I would ask here too since you are the expert on this stuff…

    I am shooting a short film with anamorphic lens! and i want to be able to composite 3d elements and effects into the plate shots using Blender / Cycles etc.

    What would I need to do – to simulate anamorphic lens? bokeh? blur? etc? is it possible with the built it cycles tools? or would you recommend splitting the scene up into foreground background items and doing something like a displacement node for distance and blur squeeze? ( anamorphic lenses squeeze more at a distance… you probably already know this. )

    Can you give any advice?

    cheers!

  6. btw I found this:

    http://books.google.com/books?id=J4UT1EXeZ2kC&pg=PA5&vq=1&dq=optical+lens+design+anamorphic&output=html_text&source=gbs_search_r&cad=1

    I would love an anamorphic lens distortion and aberration system and if Cycles if capable of real world light interaction – I wonder what it would take to get a setting for anamorphic lenses as well?

    Some of the most highly regarded films were shot with anamorphic lenses and that was part of their secret sauce for the look of the film… high end anamorphics are extremely expensive to even rent – and some places don’t even sell them ( Panavision ) — compositing elements into anamorphic shot footage is something Im trying to do – and would love a Blender based solution – and Im sure there must be others who would want this…. Zeiss is coming out with a new series of anamorphics and theres been a bit of a resurgence in interest in shooting with these lenses.

    Ok just thought Id drop this off in case theres someone out there who is also interested!

    🙂

  7. admin on May 7, 2012 at 7:45 pm said:

    Hi TJ,

    Regarding Anamorphic lens:
    I would like to (help) implement this system in Cycles:
    * https://graphics.stanford.edu/wikis/cs348b-11/Assignment3
    * http://www.graphics.stanford.edu/papers/camera/

    I don’t know how hard would that be, so I can’t promise anything. But I think it may be able to do anamorphic lens as well. Can you take a look at this material to see if it would fit what is needed for anamorphic lens?

    Perhaps, if you don’t need real dof, bokeh, … you can make a patch based on the fisheye panoramas. All you need is the function to map from UV to direction.
    And I will need to read on anamorphic lens, but if the principal is the same as with fisheye (and all the rays come from the camera nodal point/focus) you could render in blender and warp/stitch with an external software (e.g. Hugin)

Leave a Reply

Your email address will not be published. Required fields are marked *

Post Navigation