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/kernel/kernel_montecarlo.h
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/kernel/kernel_montecarlo.h')
-rw-r--r--intern/cycles/kernel/kernel_montecarlo.h51
1 files changed, 51 insertions, 0 deletions
diff --git a/intern/cycles/kernel/kernel_montecarlo.h b/intern/cycles/kernel/kernel_montecarlo.h
index 68f007cfd97..3fb4d41ce06 100644
--- a/intern/cycles/kernel/kernel_montecarlo.h
+++ b/intern/cycles/kernel/kernel_montecarlo.h
@@ -224,6 +224,57 @@ __device float3 equirectangular_to_direction(float u, float v)
cos(theta));
}
+/* Fisheye <- Cartesian direction */
+
+__device float3 fisheye_to_direction(float u, float v, float fov, Ray *ray)
+{
+ u = (u - 0.5f) * 2.f;
+ v = (v - 0.5f) * 2.f;
+
+ float r = sqrt(u*u + v*v);
+
+ if (r > 1.0) {
+ ray->t = 0.f;
+ return make_float3(0.f,0.f,0.f);
+ }
+
+ float phi = acosf((r!=0.f)?u/r:0.f);
+ float theta = asinf(r) * (fov / M_PI_F);
+
+ if (v < 0.f) phi = -phi;
+
+ return make_float3(
+ cosf(theta),
+ -cosf(phi)*sinf(theta),
+ sinf(phi)*sinf(theta)
+ );
+}
+
+__device float3 fisheye_equisolid_to_direction(float u, float v, float lens, float fov, float width, float height, Ray *ray)
+{
+ u = (u - 0.5f) * width;
+ v = (v - 0.5f) * height;
+
+ float rmax = 2.f * lens * sinf(fov * 0.5f);
+ float r = sqrt(u*u + v*v);
+
+ if (r > rmax) {
+ ray->t = 0.f;
+ return make_float3(0.f,0.f,0.f);
+ }
+
+ float phi = acosf((r!=0.f)?u/r:0.f);
+ float theta = 2.f * asinf(r/(2.f * lens));
+
+ if (v < 0.f) phi = -phi;
+
+ return make_float3(
+ cosf(theta),
+ -cosf(phi)*sinf(theta),
+ sinf(phi)*sinf(theta)
+ );
+}
+
/* Mirror Ball <-> Cartesion direction */
__device float3 mirrorball_to_direction(float u, float v)