I was looking into how the Fisheye Lens Polynomial could help us creating distortion directly on the lens. There is a great open source database of lens distortion and lens vignetting available: https://lensfun.github.io/
The problem is that in Blender we have a 4th degree polynomial, while the database uses a third degree polynomial (a, b and c) or a simpler single value (k1) when the lens distortion is rather linear.
Is there a way to easily convert these into k0, k1, k2 and k3 values for the Fisheye lens polynomial?
I didn’t look into this specific situation, but normally a 3d degree polynomial is the same as a 4th degree polynomial with the 4th term set to zero?
So if you database specifies only k0,k1,k2 isn’t it enough to just set k3 to 0?
Mind you, I didn’t actually look at the code, but math wise this seems logical.
From a look at the lensfun API docs, they don’t seem to use the same distortion model, even if both involve polynomials. There’s no easy conversion I think.
Sorry to revive this old thread, but I just wondered if there was any way to “link” or use the “Fisheye Polynomial” lens with the results of the Motion Tracker.
I hoped that I could use the lens distortion of the solution to directly render from Cycles with a correctly distorted lens. Is this possible? So far I haven’t found anything useful, the K0 - K4 parameters don’t seem to match the ones found in the Motion Tracker. Also the FOV (default 180°) doesn’t do much.
And on top the default values of the Fisheye Polynomial are very weird. The values in the screenshot above are the defaults BTW.
And on a side note, wouldn’t it be awesome to be able to feed Cycles’ cameras an STMap directly, so it could directly output ANY kind of lens distortion?
The main advantage is that depending on how much lens distortion there is it saves a lot of render time.
If you’re e.g. rendering for a fisheye lens you have to render something like this:
Just to redistort it back to a rectangular format. If you’re directly rendering “through the STMap”, you only render pixels that are visible. Also if you’re rendering undistorted and redistort in comp, you spend a lot of pixels / samples in the stretched corners that are afterwards compressed to a fraction of a pixel.
Yeah you’re right.
It would save pixels and therefore rendertime and it would easily support all distortion models. Through an STMap image sequence, it could also easily support distortion that changes over time.
The render would be dependent on the resolution of the provided STMap though but that’s to be expected.
I’m tempted to say that if your AD doesn’t like the amount of distortion and you need to re-render, that might take more time than keeping it in post
Anyway STMaps are super easy to do in comp, and with the real time compositing this makes it much easier. For what it’s worth, I’m adding it to the next version of my add-on.
Keeping them in comp opens up other opportunities that’s right. But having a choice is always nice and maybe some other crazy or artistic possibilities come with STMap lens rendering or whatever you might call it.
In my use cases (integration of products in footage shot in camera, sometimes with weird anamorphic lenses just like right now or doing all kinds of set extensions) the lens distortion is not my choice but it totally depends on the lenses they used during shooting their stuff.
If they decide to get rid of their actual lens distortion, they will have to undistort their footage together with my 3D on it anyway.