2011-04-27 11:58:34 +00:00
|
|
|
/*
|
2013-08-18 14:16:15 +00:00
|
|
|
* Copyright 2011-2013 Blender Foundation
|
2011-04-27 11:58:34 +00:00
|
|
|
*
|
2013-08-18 14:16:15 +00:00
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
2011-04-27 11:58:34 +00:00
|
|
|
*
|
2013-08-18 14:16:15 +00:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2011-04-27 11:58:34 +00:00
|
|
|
*
|
2013-08-18 14:16:15 +00:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
2014-12-25 01:50:24 +00:00
|
|
|
* limitations under the License.
|
2011-04-27 11:58:34 +00:00
|
|
|
*/
|
|
|
|
|
Cycles: Make all #include statements relative to cycles source directory
The idea is to make include statements more explicit and obvious where the
file is coming from, additionally reducing chance of wrong header being
picked up.
For example, it was not obvious whether bvh.h was refferring to builder
or traversal, whenter node.h is a generic graph node or a shader node
and cases like that.
Surely this might look obvious for the active developers, but after some
time of not touching the code it becomes less obvious where file is coming
from.
This was briefly mentioned in T50824 and seems @brecht is fine with such
explicitness, but need to agree with all active developers before committing
this.
Please note that this patch is lacking changes related on GPU/OpenCL
support. This will be solved if/when we all agree this is a good idea to move
forward.
Reviewers: brecht, lukasstockner97, maiself, nirved, dingto, juicyfruit, swerner
Reviewed By: lukasstockner97, maiself, nirved, dingto
Subscribers: brecht
Differential Revision: https://developer.blender.org/D2586
2017-03-28 18:39:14 +00:00
|
|
|
#include "render/camera.h"
|
|
|
|
#include "render/mesh.h"
|
|
|
|
#include "render/object.h"
|
|
|
|
#include "render/scene.h"
|
|
|
|
#include "render/tables.h"
|
2011-04-27 11:58:34 +00:00
|
|
|
|
Cycles: Make all #include statements relative to cycles source directory
The idea is to make include statements more explicit and obvious where the
file is coming from, additionally reducing chance of wrong header being
picked up.
For example, it was not obvious whether bvh.h was refferring to builder
or traversal, whenter node.h is a generic graph node or a shader node
and cases like that.
Surely this might look obvious for the active developers, but after some
time of not touching the code it becomes less obvious where file is coming
from.
This was briefly mentioned in T50824 and seems @brecht is fine with such
explicitness, but need to agree with all active developers before committing
this.
Please note that this patch is lacking changes related on GPU/OpenCL
support. This will be solved if/when we all agree this is a good idea to move
forward.
Reviewers: brecht, lukasstockner97, maiself, nirved, dingto, juicyfruit, swerner
Reviewed By: lukasstockner97, maiself, nirved, dingto
Subscribers: brecht
Differential Revision: https://developer.blender.org/D2586
2017-03-28 18:39:14 +00:00
|
|
|
#include "device/device.h"
|
2012-10-15 21:12:58 +00:00
|
|
|
|
Cycles: Make all #include statements relative to cycles source directory
The idea is to make include statements more explicit and obvious where the
file is coming from, additionally reducing chance of wrong header being
picked up.
For example, it was not obvious whether bvh.h was refferring to builder
or traversal, whenter node.h is a generic graph node or a shader node
and cases like that.
Surely this might look obvious for the active developers, but after some
time of not touching the code it becomes less obvious where file is coming
from.
This was briefly mentioned in T50824 and seems @brecht is fine with such
explicitness, but need to agree with all active developers before committing
this.
Please note that this patch is lacking changes related on GPU/OpenCL
support. This will be solved if/when we all agree this is a good idea to move
forward.
Reviewers: brecht, lukasstockner97, maiself, nirved, dingto, juicyfruit, swerner
Reviewed By: lukasstockner97, maiself, nirved, dingto
Subscribers: brecht
Differential Revision: https://developer.blender.org/D2586
2017-03-28 18:39:14 +00:00
|
|
|
#include "util/util_foreach.h"
|
|
|
|
#include "util/util_function.h"
|
|
|
|
#include "util/util_math_cdf.h"
|
|
|
|
#include "util/util_vector.h"
|
2011-04-27 11:58:34 +00:00
|
|
|
|
|
|
|
CCL_NAMESPACE_BEGIN
|
|
|
|
|
2015-10-27 08:16:04 +00:00
|
|
|
static float shutter_curve_eval(float x,
|
2016-05-07 22:28:21 +00:00
|
|
|
array<float>& shutter_curve)
|
2015-10-27 08:16:04 +00:00
|
|
|
{
|
2016-10-24 10:26:12 +00:00
|
|
|
if(shutter_curve.size() == 0) {
|
2016-05-07 22:28:21 +00:00
|
|
|
return 1.0f;
|
2016-10-24 10:26:12 +00:00
|
|
|
}
|
2016-05-07 22:28:21 +00:00
|
|
|
|
|
|
|
x *= shutter_curve.size();
|
2015-10-27 08:16:04 +00:00
|
|
|
int index = (int)x;
|
|
|
|
float frac = x - index;
|
2016-05-07 22:28:21 +00:00
|
|
|
if(index < shutter_curve.size() - 1) {
|
2015-10-27 08:16:04 +00:00
|
|
|
return lerp(shutter_curve[index], shutter_curve[index + 1], frac);
|
|
|
|
}
|
|
|
|
else {
|
2016-05-07 22:28:21 +00:00
|
|
|
return shutter_curve[shutter_curve.size() - 1];
|
2015-10-27 08:16:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-07 22:28:21 +00:00
|
|
|
NODE_DEFINE(Camera)
|
|
|
|
{
|
|
|
|
NodeType* type = NodeType::add("camera", create);
|
|
|
|
|
|
|
|
SOCKET_FLOAT(shuttertime, "Shutter Time", 1.0f);
|
|
|
|
|
|
|
|
static NodeEnum motion_position_enum;
|
|
|
|
motion_position_enum.insert("start", MOTION_POSITION_START);
|
|
|
|
motion_position_enum.insert("center", MOTION_POSITION_CENTER);
|
|
|
|
motion_position_enum.insert("end", MOTION_POSITION_END);
|
|
|
|
SOCKET_ENUM(motion_position, "Motion Position", motion_position_enum, MOTION_POSITION_CENTER);
|
|
|
|
|
|
|
|
static NodeEnum rolling_shutter_type_enum;
|
|
|
|
rolling_shutter_type_enum.insert("none", ROLLING_SHUTTER_NONE);
|
|
|
|
rolling_shutter_type_enum.insert("top", ROLLING_SHUTTER_TOP);
|
|
|
|
SOCKET_ENUM(rolling_shutter_type, "Rolling Shutter Type", rolling_shutter_type_enum, ROLLING_SHUTTER_NONE);
|
|
|
|
SOCKET_FLOAT(rolling_shutter_duration, "Rolling Shutter Duration", 0.1f);
|
|
|
|
|
|
|
|
SOCKET_FLOAT_ARRAY(shutter_curve, "Shutter Curve", array<float>());
|
|
|
|
|
|
|
|
SOCKET_FLOAT(aperturesize, "Aperture Size", 0.0f);
|
|
|
|
SOCKET_FLOAT(focaldistance, "Focal Distance", 10.0f);
|
2016-06-12 15:12:25 +00:00
|
|
|
SOCKET_UINT(blades, "Blades", 0);
|
2016-05-07 22:28:21 +00:00
|
|
|
SOCKET_FLOAT(bladesrotation, "Blades Rotation", 0.0f);
|
|
|
|
|
|
|
|
SOCKET_TRANSFORM(matrix, "Matrix", transform_identity());
|
|
|
|
|
|
|
|
SOCKET_FLOAT(aperture_ratio, "Aperture Ratio", 1.0f);
|
|
|
|
|
|
|
|
static NodeEnum type_enum;
|
|
|
|
type_enum.insert("perspective", CAMERA_PERSPECTIVE);
|
|
|
|
type_enum.insert("orthograph", CAMERA_ORTHOGRAPHIC);
|
|
|
|
type_enum.insert("panorama", CAMERA_PANORAMA);
|
|
|
|
SOCKET_ENUM(type, "Type", type_enum, CAMERA_PERSPECTIVE);
|
|
|
|
|
|
|
|
static NodeEnum panorama_type_enum;
|
|
|
|
panorama_type_enum.insert("equirectangular", PANORAMA_EQUIRECTANGULAR);
|
|
|
|
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);
|
|
|
|
SOCKET_ENUM(panorama_type, "Panorama Type", panorama_type_enum, PANORAMA_EQUIRECTANGULAR);
|
|
|
|
|
|
|
|
SOCKET_FLOAT(fisheye_fov, "Fisheye FOV", M_PI_F);
|
|
|
|
SOCKET_FLOAT(fisheye_lens, "Fisheye Lens", 10.5f);
|
|
|
|
SOCKET_FLOAT(latitude_min, "Latitude Min", -M_PI_2_F);
|
|
|
|
SOCKET_FLOAT(latitude_max, "Latitude Max", M_PI_2_F);
|
|
|
|
SOCKET_FLOAT(longitude_min, "Longitude Min", -M_PI_F);
|
|
|
|
SOCKET_FLOAT(longitude_max, "Longitude Max", M_PI_F);
|
|
|
|
SOCKET_FLOAT(fov, "FOV", M_PI_4_F);
|
|
|
|
SOCKET_FLOAT(fov_pre, "FOV Pre", M_PI_4_F);
|
|
|
|
SOCKET_FLOAT(fov_post, "FOV Post", M_PI_4_F);
|
|
|
|
|
|
|
|
static NodeEnum stereo_eye_enum;
|
|
|
|
stereo_eye_enum.insert("none", STEREO_NONE);
|
|
|
|
stereo_eye_enum.insert("left", STEREO_LEFT);
|
|
|
|
stereo_eye_enum.insert("right", STEREO_RIGHT);
|
|
|
|
SOCKET_ENUM(stereo_eye, "Stereo Eye", stereo_eye_enum, STEREO_NONE);
|
|
|
|
|
|
|
|
SOCKET_FLOAT(interocular_distance, "Interocular Distance", 0.065f);
|
|
|
|
SOCKET_FLOAT(convergence_distance, "Convergence Distance", 30.0f * 0.065f);
|
|
|
|
|
|
|
|
SOCKET_BOOLEAN(use_pole_merge, "Use Pole Merge", false);
|
|
|
|
SOCKET_FLOAT(pole_merge_angle_from, "Pole Merge Angle From", 60.0f * M_PI_F / 180.0f);
|
|
|
|
SOCKET_FLOAT(pole_merge_angle_to, "Pole Merge Angle To", 75.0f * M_PI_F / 180.0f);
|
|
|
|
|
|
|
|
SOCKET_FLOAT(sensorwidth, "Sensor Width", 0.036f);
|
|
|
|
SOCKET_FLOAT(sensorheight, "Sensor Height", 0.024f);
|
|
|
|
|
|
|
|
SOCKET_FLOAT(nearclip, "Near Clip", 1e-5f);
|
|
|
|
SOCKET_FLOAT(farclip, "Far Clip", 1e5f);
|
|
|
|
|
|
|
|
SOCKET_FLOAT(viewplane.left, "Viewplane Left", 0);
|
|
|
|
SOCKET_FLOAT(viewplane.right, "Viewplane Right", 0);
|
|
|
|
SOCKET_FLOAT(viewplane.bottom, "Viewplane Bottom", 0);
|
|
|
|
SOCKET_FLOAT(viewplane.top, "Viewplane Top", 0);
|
|
|
|
|
|
|
|
SOCKET_FLOAT(border.left, "Border Left", 0);
|
|
|
|
SOCKET_FLOAT(border.right, "Border Right", 0);
|
|
|
|
SOCKET_FLOAT(border.bottom, "Border Bottom", 0);
|
|
|
|
SOCKET_FLOAT(border.top, "Border Top", 0);
|
|
|
|
|
|
|
|
return type;
|
|
|
|
}
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
Camera::Camera()
|
2016-05-07 22:28:21 +00:00
|
|
|
: Node(node_type)
|
2011-04-27 11:58:34 +00:00
|
|
|
{
|
2015-10-27 08:16:04 +00:00
|
|
|
shutter_table_offset = TABLE_OFFSET_INVALID;
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2016-05-07 22:28:21 +00:00
|
|
|
width = 1024;
|
|
|
|
height = 512;
|
|
|
|
resolution = 1;
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2012-04-30 12:49:26 +00:00
|
|
|
motion.pre = transform_identity();
|
|
|
|
motion.post = transform_identity();
|
|
|
|
use_motion = false;
|
2015-07-21 13:36:35 +00:00
|
|
|
use_perspective_motion = false;
|
2012-04-30 12:49:26 +00:00
|
|
|
|
2016-05-07 22:28:21 +00:00
|
|
|
shutter_curve.resize(RAMP_TABLE_SIZE);
|
|
|
|
for(int i = 0; i < shutter_curve.size(); ++i) {
|
|
|
|
shutter_curve[i] = 1.0f;
|
|
|
|
}
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2016-05-07 22:28:21 +00:00
|
|
|
compute_auto_viewplane();
|
2012-06-06 23:27:43 +00:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
screentoworld = transform_identity();
|
|
|
|
rastertoworld = transform_identity();
|
|
|
|
ndctoworld = transform_identity();
|
|
|
|
rastertocamera = transform_identity();
|
|
|
|
cameratoworld = transform_identity();
|
|
|
|
worldtoraster = transform_identity();
|
|
|
|
|
|
|
|
dx = make_float3(0.0f, 0.0f, 0.0f);
|
|
|
|
dy = make_float3(0.0f, 0.0f, 0.0f);
|
|
|
|
|
|
|
|
need_update = true;
|
|
|
|
need_device_update = true;
|
2015-05-14 14:08:13 +00:00
|
|
|
need_flags_update = true;
|
2012-09-04 13:29:07 +00:00
|
|
|
previous_need_motion = -1;
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Camera::~Camera()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-02-14 17:40:31 +00:00
|
|
|
void Camera::compute_auto_viewplane()
|
|
|
|
{
|
2015-09-08 08:07:08 +00:00
|
|
|
if(type == CAMERA_PANORAMA) {
|
|
|
|
viewplane.left = 0.0f;
|
|
|
|
viewplane.right = 1.0f;
|
|
|
|
viewplane.bottom = 0.0f;
|
2014-02-14 17:40:31 +00:00
|
|
|
viewplane.top = 1.0f;
|
|
|
|
}
|
|
|
|
else {
|
2015-09-08 08:07:08 +00:00
|
|
|
float aspect = (float)width/(float)height;
|
|
|
|
if(width >= height) {
|
|
|
|
viewplane.left = -aspect;
|
|
|
|
viewplane.right = aspect;
|
|
|
|
viewplane.bottom = -1.0f;
|
|
|
|
viewplane.top = 1.0f;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
viewplane.left = -1.0f;
|
|
|
|
viewplane.right = 1.0f;
|
|
|
|
viewplane.bottom = -1.0f/aspect;
|
|
|
|
viewplane.top = 1.0f/aspect;
|
|
|
|
}
|
2014-02-14 17:40:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
void Camera::update()
|
|
|
|
{
|
|
|
|
if(!need_update)
|
|
|
|
return;
|
2015-01-27 16:36:14 +00:00
|
|
|
|
|
|
|
/* Full viewport to camera border in the viewport. */
|
|
|
|
Transform fulltoborder = transform_from_viewplane(viewport_camera_border);
|
|
|
|
Transform bordertofull = transform_inverse(fulltoborder);
|
|
|
|
|
2011-12-20 12:25:37 +00:00
|
|
|
/* ndc to raster */
|
2015-01-27 16:36:14 +00:00
|
|
|
Transform ndctoraster = transform_scale(width, height, 1.0f) * bordertofull;
|
2016-04-11 20:49:09 +00:00
|
|
|
Transform full_ndctoraster = transform_scale(full_width, full_height, 1.0f) * bordertofull;
|
2011-04-27 11:58:34 +00:00
|
|
|
|
|
|
|
/* raster to screen */
|
2015-01-27 16:36:14 +00:00
|
|
|
Transform screentondc = fulltoborder * transform_from_viewplane(viewplane);
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2012-11-21 01:00:03 +00:00
|
|
|
Transform screentoraster = ndctoraster * screentondc;
|
2011-04-27 11:58:34 +00:00
|
|
|
Transform rastertoscreen = transform_inverse(screentoraster);
|
2016-04-11 20:49:09 +00:00
|
|
|
Transform full_screentoraster = full_ndctoraster * screentondc;
|
|
|
|
Transform full_rastertoscreen = transform_inverse(full_screentoraster);
|
2011-04-27 11:58:34 +00:00
|
|
|
|
|
|
|
/* screen to camera */
|
2015-11-21 21:14:13 +00:00
|
|
|
Transform cameratoscreen;
|
2012-02-28 16:44:54 +00:00
|
|
|
if(type == CAMERA_PERSPECTIVE)
|
2015-11-21 21:14:13 +00:00
|
|
|
cameratoscreen = transform_perspective(fov, nearclip, farclip);
|
2012-02-28 16:44:54 +00:00
|
|
|
else if(type == CAMERA_ORTHOGRAPHIC)
|
2015-11-21 21:14:13 +00:00
|
|
|
cameratoscreen = transform_orthographic(nearclip, farclip);
|
2011-04-27 11:58:34 +00:00
|
|
|
else
|
2015-11-21 21:14:13 +00:00
|
|
|
cameratoscreen = transform_identity();
|
2012-11-21 01:00:03 +00:00
|
|
|
|
2015-11-21 21:14:13 +00:00
|
|
|
Transform screentocamera = transform_inverse(cameratoscreen);
|
2011-04-27 11:58:34 +00:00
|
|
|
|
|
|
|
rastertocamera = screentocamera * rastertoscreen;
|
2016-04-11 20:49:09 +00:00
|
|
|
Transform full_rastertocamera = screentocamera * full_rastertoscreen;
|
2012-11-21 01:00:03 +00:00
|
|
|
cameratoraster = screentoraster * cameratoscreen;
|
2011-04-27 11:58:34 +00:00
|
|
|
|
|
|
|
cameratoworld = matrix;
|
|
|
|
screentoworld = cameratoworld * screentocamera;
|
|
|
|
rastertoworld = cameratoworld * rastertocamera;
|
|
|
|
ndctoworld = rastertoworld * ndctoraster;
|
2012-11-21 01:00:03 +00:00
|
|
|
|
|
|
|
/* note we recompose matrices instead of taking inverses of the above, this
|
|
|
|
* is needed to avoid inverting near degenerate matrices that happen due to
|
|
|
|
* precision issues with large scenes */
|
|
|
|
worldtocamera = transform_inverse(matrix);
|
|
|
|
worldtoscreen = cameratoscreen * worldtocamera;
|
|
|
|
worldtondc = screentondc * worldtoscreen;
|
|
|
|
worldtoraster = ndctoraster * worldtondc;
|
2011-04-27 11:58:34 +00:00
|
|
|
|
|
|
|
/* differentials */
|
2012-02-28 16:44:54 +00:00
|
|
|
if(type == CAMERA_ORTHOGRAPHIC) {
|
2011-04-27 11:58:34 +00:00
|
|
|
dx = transform_direction(&rastertocamera, make_float3(1, 0, 0));
|
|
|
|
dy = transform_direction(&rastertocamera, make_float3(0, 1, 0));
|
2016-04-11 20:49:09 +00:00
|
|
|
full_dx = transform_direction(&full_rastertocamera, make_float3(1, 0, 0));
|
|
|
|
full_dy = transform_direction(&full_rastertocamera, make_float3(0, 1, 0));
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
2012-02-28 16:44:54 +00:00
|
|
|
else if(type == CAMERA_PERSPECTIVE) {
|
2012-04-16 08:35:21 +00:00
|
|
|
dx = transform_perspective(&rastertocamera, make_float3(1, 0, 0)) -
|
|
|
|
transform_perspective(&rastertocamera, make_float3(0, 0, 0));
|
|
|
|
dy = transform_perspective(&rastertocamera, make_float3(0, 1, 0)) -
|
|
|
|
transform_perspective(&rastertocamera, make_float3(0, 0, 0));
|
2016-04-11 20:49:09 +00:00
|
|
|
full_dx = transform_perspective(&full_rastertocamera, make_float3(1, 0, 0)) -
|
|
|
|
transform_perspective(&full_rastertocamera, make_float3(0, 0, 0));
|
|
|
|
full_dy = transform_perspective(&full_rastertocamera, make_float3(0, 1, 0)) -
|
|
|
|
transform_perspective(&full_rastertocamera, make_float3(0, 0, 0));
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
2012-02-28 16:44:54 +00:00
|
|
|
else {
|
2015-04-25 22:42:26 +00:00
|
|
|
dx = make_float3(0.0f, 0.0f, 0.0f);
|
|
|
|
dy = make_float3(0.0f, 0.0f, 0.0f);
|
2012-02-28 16:44:54 +00:00
|
|
|
}
|
2011-04-27 11:58:34 +00:00
|
|
|
|
|
|
|
dx = transform_direction(&cameratoworld, dx);
|
|
|
|
dy = transform_direction(&cameratoworld, dy);
|
2016-04-11 20:49:09 +00:00
|
|
|
full_dx = transform_direction(&cameratoworld, full_dx);
|
|
|
|
full_dy = transform_direction(&cameratoworld, full_dy);
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2015-07-21 13:36:35 +00:00
|
|
|
/* TODO(sergey): Support other types of camera. */
|
|
|
|
if(type == CAMERA_PERSPECTIVE) {
|
|
|
|
/* TODO(sergey): Move to an utility function and de-duplicate with
|
|
|
|
* calculation above.
|
|
|
|
*/
|
|
|
|
Transform screentocamera_pre =
|
|
|
|
transform_inverse(transform_perspective(fov_pre,
|
|
|
|
nearclip,
|
|
|
|
farclip));
|
|
|
|
Transform screentocamera_post =
|
|
|
|
transform_inverse(transform_perspective(fov_post,
|
|
|
|
nearclip,
|
|
|
|
farclip));
|
|
|
|
perspective_motion.pre = screentocamera_pre * rastertoscreen;
|
|
|
|
perspective_motion.post = screentocamera_post * rastertoscreen;
|
|
|
|
}
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
need_update = false;
|
|
|
|
need_device_update = true;
|
2015-05-14 14:08:13 +00:00
|
|
|
need_flags_update = true;
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
|
2012-04-30 12:49:26 +00:00
|
|
|
void Camera::device_update(Device *device, DeviceScene *dscene, Scene *scene)
|
2011-04-27 11:58:34 +00:00
|
|
|
{
|
2012-10-15 21:12:58 +00:00
|
|
|
Scene::MotionType need_motion = scene->need_motion(device->info.advanced_shading);
|
2012-09-04 13:29:07 +00:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
update();
|
|
|
|
|
2015-03-27 19:15:15 +00:00
|
|
|
if(previous_need_motion != need_motion) {
|
2012-09-04 13:29:07 +00:00
|
|
|
/* scene's motion model could have been changed since previous device
|
|
|
|
* camera update this could happen for example in case when one render
|
|
|
|
* layer has got motion pass and another not */
|
|
|
|
need_device_update = true;
|
|
|
|
}
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
if(!need_device_update)
|
|
|
|
return;
|
|
|
|
|
|
|
|
KernelCamera *kcam = &dscene->data.cam;
|
|
|
|
|
|
|
|
/* store matrices */
|
|
|
|
kcam->screentoworld = screentoworld;
|
|
|
|
kcam->rastertoworld = rastertoworld;
|
|
|
|
kcam->rastertocamera = rastertocamera;
|
|
|
|
kcam->cameratoworld = cameratoworld;
|
2012-11-21 01:00:03 +00:00
|
|
|
kcam->worldtocamera = worldtocamera;
|
|
|
|
kcam->worldtoscreen = worldtoscreen;
|
2012-04-30 12:49:26 +00:00
|
|
|
kcam->worldtoraster = worldtoraster;
|
2012-11-21 01:00:03 +00:00
|
|
|
kcam->worldtondc = worldtondc;
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2012-04-30 12:49:26 +00:00
|
|
|
/* camera motion */
|
2012-05-02 09:33:45 +00:00
|
|
|
kcam->have_motion = 0;
|
2015-07-21 13:36:35 +00:00
|
|
|
kcam->have_perspective_motion = 0;
|
2012-04-30 12:49:26 +00:00
|
|
|
|
|
|
|
if(need_motion == Scene::MOTION_PASS) {
|
2015-07-21 13:36:35 +00:00
|
|
|
/* TODO(sergey): Support perspective (zoom, fov) motion. */
|
2012-05-07 10:53:09 +00:00
|
|
|
if(type == CAMERA_PANORAMA) {
|
|
|
|
if(use_motion) {
|
|
|
|
kcam->motion.pre = transform_inverse(motion.pre);
|
|
|
|
kcam->motion.post = transform_inverse(motion.post);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
kcam->motion.pre = kcam->worldtocamera;
|
|
|
|
kcam->motion.post = kcam->worldtocamera;
|
|
|
|
}
|
2012-04-30 12:49:26 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-05-07 10:53:09 +00:00
|
|
|
if(use_motion) {
|
2012-11-21 01:00:03 +00:00
|
|
|
kcam->motion.pre = cameratoraster * transform_inverse(motion.pre);
|
|
|
|
kcam->motion.post = cameratoraster * transform_inverse(motion.post);
|
2012-05-07 10:53:09 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
kcam->motion.pre = worldtoraster;
|
|
|
|
kcam->motion.post = worldtoraster;
|
|
|
|
}
|
2012-04-30 12:49:26 +00:00
|
|
|
}
|
|
|
|
}
|
2012-10-09 18:37:14 +00:00
|
|
|
#ifdef __CAMERA_MOTION__
|
2012-04-30 12:49:26 +00:00
|
|
|
else if(need_motion == Scene::MOTION_BLUR) {
|
2012-05-02 09:33:45 +00:00
|
|
|
if(use_motion) {
|
2012-11-29 00:43:50 +00:00
|
|
|
transform_motion_decompose((DecompMotionTransform*)&kcam->motion, &motion, &matrix);
|
2012-05-02 09:33:45 +00:00
|
|
|
kcam->have_motion = 1;
|
|
|
|
}
|
2015-07-21 13:36:35 +00:00
|
|
|
if(use_perspective_motion) {
|
|
|
|
kcam->perspective_motion = perspective_motion;
|
|
|
|
kcam->have_perspective_motion = 1;
|
|
|
|
}
|
2012-04-30 12:49:26 +00:00
|
|
|
}
|
2012-10-09 18:37:14 +00:00
|
|
|
#endif
|
2012-04-30 12:49:26 +00:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
/* depth of field */
|
2011-09-16 13:14:02 +00:00
|
|
|
kcam->aperturesize = aperturesize;
|
2011-04-27 11:58:34 +00:00
|
|
|
kcam->focaldistance = focaldistance;
|
2011-09-16 13:14:02 +00:00
|
|
|
kcam->blades = (blades < 3)? 0.0f: blades;
|
|
|
|
kcam->bladesrotation = bladesrotation;
|
2011-04-27 11:58:34 +00:00
|
|
|
|
|
|
|
/* motion blur */
|
2012-10-09 18:37:14 +00:00
|
|
|
#ifdef __CAMERA_MOTION__
|
2013-01-23 16:56:02 +00:00
|
|
|
kcam->shuttertime = (need_motion == Scene::MOTION_BLUR) ? shuttertime: -1.0f;
|
2015-10-27 08:16:04 +00:00
|
|
|
|
2016-05-07 23:44:01 +00:00
|
|
|
scene->lookup_tables->remove_table(&shutter_table_offset);
|
2015-10-27 08:16:04 +00:00
|
|
|
if(need_motion == Scene::MOTION_BLUR) {
|
|
|
|
vector<float> shutter_table;
|
|
|
|
util_cdf_inverted(SHUTTER_TABLE_SIZE,
|
|
|
|
0.0f,
|
|
|
|
1.0f,
|
|
|
|
function_bind(shutter_curve_eval, _1, shutter_curve),
|
|
|
|
false,
|
|
|
|
shutter_table);
|
|
|
|
shutter_table_offset = scene->lookup_tables->add_table(dscene,
|
|
|
|
shutter_table);
|
|
|
|
kcam->shutter_table_offset = (int)shutter_table_offset;
|
|
|
|
}
|
2012-10-09 18:37:14 +00:00
|
|
|
#else
|
2013-01-23 16:56:02 +00:00
|
|
|
kcam->shuttertime = -1.0f;
|
2012-10-09 18:37:14 +00:00
|
|
|
#endif
|
2011-04-27 11:58:34 +00:00
|
|
|
|
|
|
|
/* type */
|
2012-02-28 16:44:54 +00:00
|
|
|
kcam->type = type;
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2014-08-27 08:51:50 +00:00
|
|
|
/* anamorphic lens bokeh */
|
|
|
|
kcam->inv_aperture_ratio = 1.0f / aperture_ratio;
|
|
|
|
|
2012-05-04 16:20:51 +00:00
|
|
|
/* panorama */
|
|
|
|
kcam->panorama_type = panorama_type;
|
|
|
|
kcam->fisheye_fov = fisheye_fov;
|
|
|
|
kcam->fisheye_lens = fisheye_lens;
|
2015-01-14 18:14:45 +00:00
|
|
|
kcam->equirectangular_range = make_float4(longitude_min - longitude_max, -longitude_min,
|
|
|
|
latitude_min - latitude_max, -latitude_min + M_PI_2_F);
|
2012-05-04 16:20:51 +00:00
|
|
|
|
Multi-View: Cycles - Spherical Stereo support (VR Panoramas)
This is a new option for panorama cameras to render
stereo that can be used in virtual reality devices
The option is available under the camera panel when Multi-View is enabled (Views option in the Render Layers panel)
Known limitations:
------------------
* Parallel convergence is not supported (you need to set a convergence distance really high to simulate this effect).
* Pivot was not supposed to affect the render but it does, this has to be looked at, but for now set it to CENTER
* Derivatives in perspective camera need to be pre-computed or we shuld get rid of kcam->dx/dy (Sergey words, I don't fully grasp the implication shere)
* This works in perspective mode and in panorama mode. However, for fully benefit from this effect in perspective mode you need to render a cube map. (there is an addon for this, developed separately, perhaps we could include it in master).
* We have no support for "neck distance" at the moment. This is supposed to help with objects at short distances.
* We have no support to rotate the "Up Axis" of the stereo plane. Meaning, we hardcode 0,0,1 as UP, and create the stereo pair related to that. (although we could take the camera local UP when rendering panoramas, this wouldn't work for perspective cameras.
* We have no support for interocular distance attenuation based on the proximity of the poles (which helps to reduce the pole rotation effect/artifact).
THIS NEEDS DOCS - both in 2.78 release log and the Blender manual.
Meanwhile you can read about it here: http://code.blender.org/2015/03/1451
This patch specifically dates from March 2015, as you can see in the code.blender.org post. Many thanks to all the reviewers, testers and minor sponsors who helped me maintain spherical-stereo for 1 year.
All that said, have fun with this. This feature was what got me started with Multi-View development (at the time what I was looking for was Fulldome stereo support, but the implementation is the same). In order to make this into Blender I had to make it aiming at a less-specic user-case Thus Multi-View started. (this was December 2012, during Siggraph Asia and a chat I had with Paul Bourke during the conference). I don't have the original patch anymore, but you can find a re-based version of it from March 2013, right before I start with the Multi-View project https://developer.blender.org/P332
Reviewers: sergey, dingto
Subscribers: #cycles
Differential Revision: https://developer.blender.org/D1223
2016-03-10 12:28:29 +00:00
|
|
|
switch(stereo_eye) {
|
|
|
|
case STEREO_LEFT:
|
|
|
|
kcam->interocular_offset = -interocular_distance * 0.5f;
|
|
|
|
break;
|
|
|
|
case STEREO_RIGHT:
|
|
|
|
kcam->interocular_offset = interocular_distance * 0.5f;
|
|
|
|
break;
|
|
|
|
case STEREO_NONE:
|
|
|
|
default:
|
|
|
|
kcam->interocular_offset = 0.0f;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
kcam->convergence_distance = convergence_distance;
|
2016-05-17 12:12:29 +00:00
|
|
|
if(use_pole_merge) {
|
|
|
|
kcam->pole_merge_angle_from = pole_merge_angle_from;
|
|
|
|
kcam->pole_merge_angle_to = pole_merge_angle_to;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
kcam->pole_merge_angle_from = -1.0f;
|
|
|
|
kcam->pole_merge_angle_to = -1.0f;
|
|
|
|
}
|
Multi-View: Cycles - Spherical Stereo support (VR Panoramas)
This is a new option for panorama cameras to render
stereo that can be used in virtual reality devices
The option is available under the camera panel when Multi-View is enabled (Views option in the Render Layers panel)
Known limitations:
------------------
* Parallel convergence is not supported (you need to set a convergence distance really high to simulate this effect).
* Pivot was not supposed to affect the render but it does, this has to be looked at, but for now set it to CENTER
* Derivatives in perspective camera need to be pre-computed or we shuld get rid of kcam->dx/dy (Sergey words, I don't fully grasp the implication shere)
* This works in perspective mode and in panorama mode. However, for fully benefit from this effect in perspective mode you need to render a cube map. (there is an addon for this, developed separately, perhaps we could include it in master).
* We have no support for "neck distance" at the moment. This is supposed to help with objects at short distances.
* We have no support to rotate the "Up Axis" of the stereo plane. Meaning, we hardcode 0,0,1 as UP, and create the stereo pair related to that. (although we could take the camera local UP when rendering panoramas, this wouldn't work for perspective cameras.
* We have no support for interocular distance attenuation based on the proximity of the poles (which helps to reduce the pole rotation effect/artifact).
THIS NEEDS DOCS - both in 2.78 release log and the Blender manual.
Meanwhile you can read about it here: http://code.blender.org/2015/03/1451
This patch specifically dates from March 2015, as you can see in the code.blender.org post. Many thanks to all the reviewers, testers and minor sponsors who helped me maintain spherical-stereo for 1 year.
All that said, have fun with this. This feature was what got me started with Multi-View development (at the time what I was looking for was Fulldome stereo support, but the implementation is the same). In order to make this into Blender I had to make it aiming at a less-specic user-case Thus Multi-View started. (this was December 2012, during Siggraph Asia and a chat I had with Paul Bourke during the conference). I don't have the original patch anymore, but you can find a re-based version of it from March 2013, right before I start with the Multi-View project https://developer.blender.org/P332
Reviewers: sergey, dingto
Subscribers: #cycles
Differential Revision: https://developer.blender.org/D1223
2016-03-10 12:28:29 +00:00
|
|
|
|
2012-05-04 16:20:51 +00:00
|
|
|
/* sensor size */
|
|
|
|
kcam->sensorwidth = sensorwidth;
|
|
|
|
kcam->sensorheight = sensorheight;
|
|
|
|
|
2012-05-07 10:53:09 +00:00
|
|
|
/* render size */
|
|
|
|
kcam->width = width;
|
|
|
|
kcam->height = height;
|
2013-04-15 21:38:31 +00:00
|
|
|
kcam->resolution = resolution;
|
2012-05-07 10:53:09 +00:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
/* store differentials */
|
2011-12-20 12:25:45 +00:00
|
|
|
kcam->dx = float3_to_float4(dx);
|
|
|
|
kcam->dy = float3_to_float4(dy);
|
2011-04-27 11:58:34 +00:00
|
|
|
|
|
|
|
/* clipping */
|
|
|
|
kcam->nearclip = nearclip;
|
|
|
|
kcam->cliplength = (farclip == FLT_MAX)? FLT_MAX: farclip - nearclip;
|
|
|
|
|
2014-09-16 17:49:59 +00:00
|
|
|
/* Camera in volume. */
|
|
|
|
kcam->is_inside_volume = 0;
|
2015-02-02 17:06:31 +00:00
|
|
|
|
2015-11-20 09:42:34 +00:00
|
|
|
/* Rolling shutter effect */
|
|
|
|
kcam->rolling_shutter_type = rolling_shutter_type;
|
|
|
|
kcam->rolling_shutter_duration = rolling_shutter_duration;
|
|
|
|
|
2015-02-02 17:06:31 +00:00
|
|
|
previous_need_motion = need_motion;
|
|
|
|
}
|
|
|
|
|
2015-03-27 10:47:55 +00:00
|
|
|
void Camera::device_update_volume(Device * /*device*/,
|
2015-02-02 17:06:31 +00:00
|
|
|
DeviceScene *dscene,
|
|
|
|
Scene *scene)
|
|
|
|
{
|
2015-05-14 14:08:13 +00:00
|
|
|
if(!need_device_update && !need_flags_update) {
|
2015-02-02 17:06:31 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
KernelCamera *kcam = &dscene->data.cam;
|
2014-10-02 21:46:31 +00:00
|
|
|
BoundBox viewplane_boundbox = viewplane_bounds_get();
|
|
|
|
for(size_t i = 0; i < scene->objects.size(); ++i) {
|
|
|
|
Object *object = scene->objects[i];
|
|
|
|
if(object->mesh->has_volume &&
|
|
|
|
viewplane_boundbox.intersects(object->bounds))
|
|
|
|
{
|
|
|
|
/* TODO(sergey): Consider adding more grained check. */
|
|
|
|
kcam->is_inside_volume = 1;
|
|
|
|
break;
|
2014-09-16 17:49:59 +00:00
|
|
|
}
|
|
|
|
}
|
2015-02-02 17:06:31 +00:00
|
|
|
need_device_update = false;
|
2015-05-14 14:08:13 +00:00
|
|
|
need_flags_update = false;
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
|
2015-10-27 08:16:04 +00:00
|
|
|
void Camera::device_free(Device * /*device*/,
|
|
|
|
DeviceScene * /*dscene*/,
|
|
|
|
Scene *scene)
|
2011-04-27 11:58:34 +00:00
|
|
|
{
|
2016-05-07 23:44:01 +00:00
|
|
|
scene->lookup_tables->remove_table(&shutter_table_offset);
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
|
2016-05-29 09:20:10 +00:00
|
|
|
bool Camera::modified(const Camera& cam)
|
|
|
|
{
|
|
|
|
return !Node::equals(cam);
|
|
|
|
}
|
|
|
|
|
2012-10-15 21:12:58 +00:00
|
|
|
bool Camera::motion_modified(const Camera& cam)
|
|
|
|
{
|
|
|
|
return !((motion == cam.motion) &&
|
2016-05-07 22:28:21 +00:00
|
|
|
(use_motion == cam.use_motion) &&
|
|
|
|
(use_perspective_motion == cam.use_perspective_motion));
|
2012-10-15 21:12:58 +00:00
|
|
|
}
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
void Camera::tag_update()
|
|
|
|
{
|
|
|
|
need_update = true;
|
|
|
|
}
|
|
|
|
|
2014-09-16 17:49:59 +00:00
|
|
|
float3 Camera::transform_raster_to_world(float raster_x, float raster_y)
|
|
|
|
{
|
|
|
|
float3 D, P;
|
|
|
|
if(type == CAMERA_PERSPECTIVE) {
|
|
|
|
D = transform_perspective(&rastertocamera,
|
|
|
|
make_float3(raster_x, raster_y, 0.0f));
|
2015-01-19 14:28:28 +00:00
|
|
|
float3 Pclip = normalize(D);
|
2014-09-16 17:49:59 +00:00
|
|
|
P = make_float3(0.0f, 0.0f, 0.0f);
|
|
|
|
/* TODO(sergey): Aperture support? */
|
|
|
|
P = transform_point(&cameratoworld, P);
|
|
|
|
D = normalize(transform_direction(&cameratoworld, D));
|
|
|
|
/* TODO(sergey): Clipping is conditional in kernel, and hence it could
|
|
|
|
* be mistakes in here, currently leading to wrong camera-in-volume
|
|
|
|
* detection.
|
|
|
|
*/
|
2015-01-19 14:28:28 +00:00
|
|
|
P += nearclip * D / Pclip.z;
|
2014-09-16 17:49:59 +00:00
|
|
|
}
|
2015-03-27 19:15:15 +00:00
|
|
|
else if(type == CAMERA_ORTHOGRAPHIC) {
|
2014-09-16 17:49:59 +00:00
|
|
|
D = make_float3(0.0f, 0.0f, 1.0f);
|
|
|
|
/* TODO(sergey): Aperture support? */
|
|
|
|
P = transform_perspective(&rastertocamera,
|
|
|
|
make_float3(raster_x, raster_y, 0.0f));
|
|
|
|
P = transform_point(&cameratoworld, P);
|
|
|
|
D = normalize(transform_direction(&cameratoworld, D));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
assert(!"unsupported camera type");
|
|
|
|
}
|
|
|
|
return P;
|
|
|
|
}
|
|
|
|
|
|
|
|
BoundBox Camera::viewplane_bounds_get()
|
|
|
|
{
|
|
|
|
/* TODO(sergey): This is all rather stupid, but is there a way to perform
|
|
|
|
* checks we need in a more clear and smart fasion?
|
|
|
|
*/
|
|
|
|
BoundBox bounds = BoundBox::empty;
|
2014-10-02 18:37:05 +00:00
|
|
|
|
|
|
|
if(type == CAMERA_PANORAMA) {
|
Multi-View: Cycles - Spherical Stereo support (VR Panoramas)
This is a new option for panorama cameras to render
stereo that can be used in virtual reality devices
The option is available under the camera panel when Multi-View is enabled (Views option in the Render Layers panel)
Known limitations:
------------------
* Parallel convergence is not supported (you need to set a convergence distance really high to simulate this effect).
* Pivot was not supposed to affect the render but it does, this has to be looked at, but for now set it to CENTER
* Derivatives in perspective camera need to be pre-computed or we shuld get rid of kcam->dx/dy (Sergey words, I don't fully grasp the implication shere)
* This works in perspective mode and in panorama mode. However, for fully benefit from this effect in perspective mode you need to render a cube map. (there is an addon for this, developed separately, perhaps we could include it in master).
* We have no support for "neck distance" at the moment. This is supposed to help with objects at short distances.
* We have no support to rotate the "Up Axis" of the stereo plane. Meaning, we hardcode 0,0,1 as UP, and create the stereo pair related to that. (although we could take the camera local UP when rendering panoramas, this wouldn't work for perspective cameras.
* We have no support for interocular distance attenuation based on the proximity of the poles (which helps to reduce the pole rotation effect/artifact).
THIS NEEDS DOCS - both in 2.78 release log and the Blender manual.
Meanwhile you can read about it here: http://code.blender.org/2015/03/1451
This patch specifically dates from March 2015, as you can see in the code.blender.org post. Many thanks to all the reviewers, testers and minor sponsors who helped me maintain spherical-stereo for 1 year.
All that said, have fun with this. This feature was what got me started with Multi-View development (at the time what I was looking for was Fulldome stereo support, but the implementation is the same). In order to make this into Blender I had to make it aiming at a less-specic user-case Thus Multi-View started. (this was December 2012, during Siggraph Asia and a chat I had with Paul Bourke during the conference). I don't have the original patch anymore, but you can find a re-based version of it from March 2013, right before I start with the Multi-View project https://developer.blender.org/P332
Reviewers: sergey, dingto
Subscribers: #cycles
Differential Revision: https://developer.blender.org/D1223
2016-03-10 12:28:29 +00:00
|
|
|
if(use_spherical_stereo == false) {
|
|
|
|
bounds.grow(make_float3(cameratoworld.x.w,
|
|
|
|
cameratoworld.y.w,
|
|
|
|
cameratoworld.z.w));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
float half_eye_distance = interocular_distance * 0.5f;
|
|
|
|
|
|
|
|
bounds.grow(make_float3(cameratoworld.x.w + half_eye_distance,
|
|
|
|
cameratoworld.y.w,
|
|
|
|
cameratoworld.z.w));
|
|
|
|
|
|
|
|
bounds.grow(make_float3(cameratoworld.z.w,
|
|
|
|
cameratoworld.y.w + half_eye_distance,
|
|
|
|
cameratoworld.z.w));
|
|
|
|
|
|
|
|
bounds.grow(make_float3(cameratoworld.x.w - half_eye_distance,
|
|
|
|
cameratoworld.y.w,
|
|
|
|
cameratoworld.z.w));
|
|
|
|
|
|
|
|
bounds.grow(make_float3(cameratoworld.x.w,
|
|
|
|
cameratoworld.y.w - half_eye_distance,
|
|
|
|
cameratoworld.z.w));
|
|
|
|
}
|
2014-10-02 18:37:05 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
bounds.grow(transform_raster_to_world(0.0f, 0.0f));
|
|
|
|
bounds.grow(transform_raster_to_world(0.0f, (float)height));
|
|
|
|
bounds.grow(transform_raster_to_world((float)width, (float)height));
|
|
|
|
bounds.grow(transform_raster_to_world((float)width, 0.0f));
|
|
|
|
if(type == CAMERA_PERSPECTIVE) {
|
2015-04-13 12:08:51 +00:00
|
|
|
/* Center point has the most distance in local Z axis,
|
2014-10-02 18:37:05 +00:00
|
|
|
* use it to construct bounding box/
|
|
|
|
*/
|
|
|
|
bounds.grow(transform_raster_to_world(0.5f*width, 0.5f*height));
|
|
|
|
}
|
2014-09-16 17:49:59 +00:00
|
|
|
}
|
|
|
|
return bounds;
|
|
|
|
}
|
|
|
|
|
2016-04-11 20:49:09 +00:00
|
|
|
float Camera::world_to_raster_size(float3 P)
|
|
|
|
{
|
|
|
|
if(type == CAMERA_ORTHOGRAPHIC) {
|
|
|
|
return min(len(full_dx), len(full_dy));
|
|
|
|
}
|
|
|
|
else if(type == CAMERA_PERSPECTIVE) {
|
|
|
|
/* Calculate as if point is directly ahead of the camera. */
|
|
|
|
float3 raster = make_float3(0.5f*width, 0.5f*height, 0.0f);
|
|
|
|
float3 Pcamera = transform_perspective(&rastertocamera, raster);
|
|
|
|
|
|
|
|
/* dDdx */
|
|
|
|
float3 Ddiff = transform_direction(&cameratoworld, Pcamera);
|
|
|
|
float3 dx = len_squared(full_dx) < len_squared(full_dy) ? full_dx : full_dy;
|
|
|
|
float3 dDdx = normalize(Ddiff + dx) - normalize(Ddiff);
|
|
|
|
|
|
|
|
/* dPdx */
|
|
|
|
float dist = len(transform_point(&worldtocamera, P));
|
|
|
|
float3 D = normalize(Ddiff);
|
|
|
|
return len(dist*dDdx - dot(dist*dDdx, D)*D);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// TODO(mai): implement for CAMERA_PANORAMA
|
|
|
|
assert(!"pixel width calculation for panoramic projection not implemented yet");
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1.0f;
|
|
|
|
}
|
|
|
|
|
2015-01-27 16:36:14 +00:00
|
|
|
CCL_NAMESPACE_END
|