diff options
author | Håkan Ardö <hakanardo> | 2021-12-07 20:54:36 +0300 |
---|---|---|
committer | Brecht Van Lommel <brecht@blender.org> | 2021-12-07 22:05:57 +0300 |
commit | 24e016546302f4f174d2356f50ec09d9f9d968a1 (patch) | |
tree | ef2caa5d7767be6eb5a7ce90dda573408c66f82e /intern/cycles/scene | |
parent | 205254150ae261051ac2e2f3b83e1bc90c042dc3 (diff) |
Cycles: add Fisheye Lens Polynomial camera model
This allows real world cameras to be modeled by specifying the coordinates of a
4th degree polynomial that relates a pixels distance (in mm) from the optical
center on the sensor to the angle (in radians) of the world ray that is
projected onto that pixel.
This is available as part of the panoramic lens type, however it can also be
used to model lens distortions in projective cameras for example.
Differential Revision: https://developer.blender.org/D12691
Diffstat (limited to 'intern/cycles/scene')
-rw-r--r-- | intern/cycles/scene/camera.cpp | 10 | ||||
-rw-r--r-- | intern/cycles/scene/camera.h | 6 |
2 files changed, 16 insertions, 0 deletions
diff --git a/intern/cycles/scene/camera.cpp b/intern/cycles/scene/camera.cpp index 5bafe736fb5..12e106779e3 100644 --- a/intern/cycles/scene/camera.cpp +++ b/intern/cycles/scene/camera.cpp @@ -100,6 +100,7 @@ NODE_DEFINE(Camera) panorama_type_enum.insert("mirrorball", PANORAMA_MIRRORBALL); panorama_type_enum.insert("fisheye_equidistant", PANORAMA_FISHEYE_EQUIDISTANT); panorama_type_enum.insert("fisheye_equisolid", PANORAMA_FISHEYE_EQUISOLID); + panorama_type_enum.insert("fisheye_lens_polynomial", PANORAMA_FISHEYE_LENS_POLYNOMIAL); SOCKET_ENUM(panorama_type, "Panorama Type", panorama_type_enum, PANORAMA_EQUIRECTANGULAR); SOCKET_FLOAT(fisheye_fov, "Fisheye FOV", M_PI_F); @@ -112,6 +113,12 @@ NODE_DEFINE(Camera) SOCKET_FLOAT(fov_pre, "FOV Pre", M_PI_4_F); SOCKET_FLOAT(fov_post, "FOV Post", M_PI_4_F); + SOCKET_FLOAT(fisheye_polynomial_k0, "Fisheye Polynomial K0", 0.0f); + SOCKET_FLOAT(fisheye_polynomial_k1, "Fisheye Polynomial K1", 0.0f); + SOCKET_FLOAT(fisheye_polynomial_k2, "Fisheye Polynomial K2", 0.0f); + SOCKET_FLOAT(fisheye_polynomial_k3, "Fisheye Polynomial K3", 0.0f); + SOCKET_FLOAT(fisheye_polynomial_k4, "Fisheye Polynomial K4", 0.0f); + static NodeEnum stereo_eye_enum; stereo_eye_enum.insert("none", STEREO_NONE); stereo_eye_enum.insert("left", STEREO_LEFT); @@ -418,6 +425,9 @@ void Camera::update(Scene *scene) -longitude_min, latitude_min - latitude_max, -latitude_min + M_PI_2_F); + kcam->fisheye_lens_polynomial_bias = fisheye_polynomial_k0; + kcam->fisheye_lens_polynomial_coefficients = make_float4(fisheye_polynomial_k1, fisheye_polynomial_k2, + fisheye_polynomial_k3, fisheye_polynomial_k4); switch (stereo_eye) { case STEREO_LEFT: diff --git a/intern/cycles/scene/camera.h b/intern/cycles/scene/camera.h index 58e39599267..50586287bea 100644 --- a/intern/cycles/scene/camera.h +++ b/intern/cycles/scene/camera.h @@ -105,6 +105,12 @@ class Camera : public Node { NODE_SOCKET_API(float, longitude_min) NODE_SOCKET_API(float, longitude_max) + NODE_SOCKET_API(float, fisheye_polynomial_k0) + NODE_SOCKET_API(float, fisheye_polynomial_k1) + NODE_SOCKET_API(float, fisheye_polynomial_k2) + NODE_SOCKET_API(float, fisheye_polynomial_k3) + NODE_SOCKET_API(float, fisheye_polynomial_k4) + /* panorama stereo */ NODE_SOCKET_API(StereoEye, stereo_eye) NODE_SOCKET_API(bool, use_spherical_stereo) |