Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDalai Felinto <dfelinto@gmail.com>2012-05-04 20:20:51 +0400
committerDalai Felinto <dfelinto@gmail.com>2012-05-04 20:20:51 +0400
commitd7fbe03a8a128408c86687ef34273adddccdb347 (patch)
tree26d5768781582b1ed0164c20098449c7700051d9 /intern/cycles/blender
parentb6edcc4b33e782b4a91a61d1c46136c52a4172c9 (diff)
Fisheye Camera for Cycles
For sample images see: http://www.dalaifelinto.com/?p=399 (equisolid) http://www.dalaifelinto.com/?p=389 (equidistant) The 'use_panorama' option is now part of a new Camera type: 'Panorama'. Created two other panorama cameras: - Equisolid: most of lens in the market simulate this lens - e.g. Nikon, Canon, ...) this works as a real lens up to an extent. The final result takes the sensor dimensions into account also. .:. to simulate a Nikon DX2S with a 10.5mm lens do: sensor: 23.7 x 15.7 fisheye lens: 10.5 fisheye fov: 180 render dimensions: 4288 x 2848 - Equidistant: this is not a real lens model. Although the old equidistant lens simulate this lens. The result is always as a circular fisheye that takes the whole sensor (in other words, it doesn't take the sensor into consideration). This is perfect for fulldomes ;) For the UI we have 10 to 360 as soft values and 10 to 3600 as hard values (because we can). Reference material: http://www.hdrlabs.com/tutorials/downloads_files/HDRI%20for%20CGI.pdf http://www.bobatkins.com/photography/technical/field_of_view.html Note, this is not a real simulation of the light path through the lens. The ideal solution would be this: https://graphics.stanford.edu/wikis/cs348b-11/Assignment3 http://www.graphics.stanford.edu/papers/camera/ Thanks Brecht for the fix, suggestions and code review. Kudos for the dome community for keeping me stimulated on the topic since 2009 ;) Patch partly implemented during lab time at VisGraf, IMPA - Rio de Janeiro.
Diffstat (limited to 'intern/cycles/blender')
-rw-r--r--intern/cycles/blender/addon/enums.py6
-rw-r--r--intern/cycles/blender/addon/properties.py19
-rw-r--r--intern/cycles/blender/blender_camera.cpp50
3 files changed, 70 insertions, 5 deletions
diff --git a/intern/cycles/blender/addon/enums.py b/intern/cycles/blender/addon/enums.py
index b4b1646c10d..6cc3010eb0e 100644
--- a/intern/cycles/blender/addon/enums.py
+++ b/intern/cycles/blender/addon/enums.py
@@ -54,3 +54,9 @@ aperture_types = (
('RADIUS', "Radius", "Directly change the size of the aperture"),
('FSTOP', "F/stop", "Change the size of the aperture by f/stops"),
)
+
+panorama_types = (
+ ('EQUIRECTANGULAR', "Equirectangular", "Render the scene with a spherical camera, also known as Lat Long panorama"),
+ ('FISHEYE_EQUIDISTANT', "Fisheye Equidistant", "Ideal for fulldomes, ignore the sensor dimensions"),
+ ('FISHEYE_EQUISOLID', "Fisheye Equisolid", "Similar to most fisheye modern lens, take sensor dimensions into consideration"),
+ )
diff --git a/intern/cycles/blender/addon/properties.py b/intern/cycles/blender/addon/properties.py
index 35f97bf629f..fb066a3a939 100644
--- a/intern/cycles/blender/addon/properties.py
+++ b/intern/cycles/blender/addon/properties.py
@@ -278,6 +278,25 @@ class CyclesCameraSettings(bpy.types.PropertyGroup):
subtype='ANGLE',
default=0,
)
+ cls.panorama_type = EnumProperty(
+ name="Panorama Type",
+ description="Distortion to use for the calculation",
+ items=enums.panorama_types,
+ default='FISHEYE_EQUISOLID',
+ )
+ cls.fisheye_fov = FloatProperty(
+ name="Field of View",
+ description="Field of view for the fisheye lens",
+ min=0.1745, soft_max=2*math.pi, max=10.0*math.pi,
+ subtype='ANGLE',
+ default=math.pi,
+ )
+ cls.fisheye_lens = FloatProperty(
+ name="Fisheye Lens",
+ description="Lens focal length (mm))",
+ min=0.01, soft_max=15.0, max=100.0,
+ default=10.5,
+ )
@classmethod
def unregister(cls):
diff --git a/intern/cycles/blender/blender_camera.cpp b/intern/cycles/blender/blender_camera.cpp
index 55a32d8fc10..bdd02bb5086 100644
--- a/intern/cycles/blender/blender_camera.cpp
+++ b/intern/cycles/blender/blender_camera.cpp
@@ -48,6 +48,10 @@ struct BlenderCamera {
float2 pixelaspect;
+ PanoramaType panorama_type;
+ float fisheye_fov;
+ float fisheye_lens;
+
enum { AUTO, HORIZONTAL, VERTICAL } sensor_fit;
float sensor_width;
float sensor_height;
@@ -94,9 +98,37 @@ static void blender_camera_from_object(BlenderCamera *bcam, BL::Object b_ob)
bcam->nearclip = b_camera.clip_start();
bcam->farclip = b_camera.clip_end();
- bcam->type = (b_camera.type() == BL::Camera::type_ORTHO)? CAMERA_ORTHOGRAPHIC: CAMERA_PERSPECTIVE;
- if(bcam->type == CAMERA_PERSPECTIVE && b_camera.use_panorama())
- bcam->type = CAMERA_ENVIRONMENT;
+ switch(b_camera.type())
+ {
+ case BL::Camera::type_ORTHO:
+ bcam->type = CAMERA_ORTHOGRAPHIC;
+ break;
+ case BL::Camera::type_PANO:
+ bcam->type = CAMERA_PANORAMA;
+ break;
+ case BL::Camera::type_PERSP:
+ default:
+ bcam->type = CAMERA_PERSPECTIVE;
+ break;
+ }
+
+ switch(RNA_enum_get(&ccamera, "panorama_type"))
+ {
+ case 1:
+ bcam->panorama_type = PANORAMA_FISHEYE_EQUIDISTANT;
+ break;
+ case 2:
+ bcam->panorama_type = PANORAMA_FISHEYE_EQUISOLID;
+ break;
+ case 0:
+ default:
+ bcam->panorama_type = PANORAMA_EQUIRECTANGULAR;
+ break;
+ }
+
+ bcam->fisheye_fov = RNA_float_get(&ccamera, "fisheye_fov");
+ bcam->fisheye_lens = RNA_float_get(&ccamera, "fisheye_lens");
+
bcam->ortho_scale = b_camera.ortho_scale();
bcam->lens = b_camera.lens();
@@ -138,7 +170,7 @@ static Transform blender_camera_matrix(const Transform& tfm, CameraType type)
{
Transform result;
- if(type == CAMERA_ENVIRONMENT) {
+ if(type == CAMERA_PANORAMA) {
/* make it so environment camera needs to be pointed in the direction
of the positive x-axis to match an environment texture, this way
it is looking at the center of the texture */
@@ -172,6 +204,9 @@ static void blender_camera_sync(Camera *cam, BlenderCamera *bcam, int width, int
bool horizontal_fit;
float sensor_size;
+ cam->sensorwidth = bcam->sensor_width;
+ cam->sensorheight = bcam->sensor_height;
+
if(bcam->sensor_fit == BlenderCamera::AUTO) {
horizontal_fit = (xratio > yratio);
sensor_size = bcam->sensor_width;
@@ -203,7 +238,7 @@ static void blender_camera_sync(Camera *cam, BlenderCamera *bcam, int width, int
aspectratio = bcam->ortho_scale/2.0f;
}
- if(bcam->type == CAMERA_ENVIRONMENT) {
+ if(bcam->type == CAMERA_PANORAMA) {
/* set viewplane */
cam->left = 0.0f;
cam->right = 1.0f;
@@ -240,6 +275,11 @@ static void blender_camera_sync(Camera *cam, BlenderCamera *bcam, int width, int
/* type */
cam->type = bcam->type;
+ /* panorama */
+ cam->panorama_type = bcam->panorama_type;
+ cam->fisheye_fov = bcam->fisheye_fov;
+ cam->fisheye_lens = bcam->fisheye_lens;
+
/* perspective */
cam->fov = 2.0f*atan((0.5f*sensor_size)/bcam->lens/aspectratio);
cam->focaldistance = bcam->focaldistance;