diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2012-04-30 16:49:26 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2012-04-30 16:49:26 +0400 |
commit | 1d8c79818870b92df46c443d7778438aa67d019c (patch) | |
tree | ba3fc305671261e40851d8a230a33ebe19396e95 /intern/cycles/render/camera.cpp | |
parent | 796dd8a321108df26757fb9df5c2aa6eb42c9633 (diff) |
Cycles: support for motion vector and UV passes.
Most of the changes are related to adding support for motion data throughout
the code. There's some code for actual camera/object motion blur raytracing
but it's unfinished (it badly slows down the raytracing kernel even when the
option is turned off), so that code it disabled still.
Motion vector export from Blender tries to avoid computing derived meshes
when the mesh does not have a deforming modifier, and it also won't store
motion vectors for every vertex if only the object or camera is moving.
Diffstat (limited to 'intern/cycles/render/camera.cpp')
-rw-r--r-- | intern/cycles/render/camera.cpp | 39 |
1 files changed, 30 insertions, 9 deletions
diff --git a/intern/cycles/render/camera.cpp b/intern/cycles/render/camera.cpp index f9290dfc835..e9ca7c3a366 100644 --- a/intern/cycles/render/camera.cpp +++ b/intern/cycles/render/camera.cpp @@ -25,8 +25,7 @@ CCL_NAMESPACE_BEGIN Camera::Camera() { - shutteropen = 0.0f; - shutterclose = 1.0f; + shuttertime = 1.0f; aperturesize = 0.0f; focaldistance = 10.0f; @@ -35,6 +34,10 @@ Camera::Camera() matrix = transform_identity(); + motion.pre = transform_identity(); + motion.post = transform_identity(); + use_motion = false; + type = CAMERA_PERSPECTIVE; fov = M_PI_F/4.0f; @@ -124,7 +127,7 @@ void Camera::update() need_device_update = true; } -void Camera::device_update(Device *device, DeviceScene *dscene) +void Camera::device_update(Device *device, DeviceScene *dscene, Scene *scene) { update(); @@ -140,10 +143,28 @@ void Camera::device_update(Device *device, DeviceScene *dscene) kcam->rastertocamera = rastertocamera; kcam->cameratoworld = cameratoworld; kcam->worldtoscreen = transform_inverse(screentoworld); - kcam->worldtoraster = transform_inverse(rastertoworld); + kcam->worldtoraster = worldtoraster; kcam->worldtondc = transform_inverse(ndctoworld); kcam->worldtocamera = transform_inverse(cameratoworld); + /* camera motion */ + Scene::MotionType need_motion = scene->need_motion(); + + if(need_motion == Scene::MOTION_PASS) { + if(use_motion) { + kcam->motion.pre = transform_inverse(motion.pre * rastertocamera); + kcam->motion.post = transform_inverse(motion.post * rastertocamera); + } + else { + kcam->motion.pre = worldtoraster; + kcam->motion.post = worldtoraster; + } + } + else if(need_motion == Scene::MOTION_BLUR) { + /* todo: exact camera position will not be hit this way */ + transform_motion_decompose(&kcam->motion, &motion); + } + /* depth of field */ kcam->aperturesize = aperturesize; kcam->focaldistance = focaldistance; @@ -151,8 +172,7 @@ void Camera::device_update(Device *device, DeviceScene *dscene) kcam->bladesrotation = bladesrotation; /* motion blur */ - kcam->shutteropen = shutteropen; - kcam->shutterclose = shutterclose; + kcam->shuttertime= (need_motion == Scene::MOTION_BLUR)? shuttertime: 0.0f; /* type */ kcam->type = type; @@ -175,8 +195,7 @@ void Camera::device_free(Device *device, DeviceScene *dscene) bool Camera::modified(const Camera& cam) { - return !((shutteropen == cam.shutteropen) && - (shutterclose == cam.shutterclose) && + return !((shuttertime== cam.shuttertime) && (aperturesize == cam.aperturesize) && (blades == cam.blades) && (bladesrotation == cam.bladesrotation) && @@ -192,7 +211,9 @@ bool Camera::modified(const Camera& cam) (right == cam.right) && (bottom == cam.bottom) && (top == cam.top) && - (matrix == cam.matrix)); + (matrix == cam.matrix) && + (motion == cam.motion) && + (use_motion == cam.use_motion)); } void Camera::tag_update() |