diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2014-05-27 17:56:59 +0400 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2014-05-27 18:09:36 +0400 |
commit | 517094a6977abd2ca3f50f15780fc15fdb125b99 (patch) | |
tree | fbe26e865d1c45ea1974c392089b3f65dd2d067a /intern/cycles/kernel/kernel_camera.h | |
parent | 12abe94de827d9ae9c0dd6cc49bc6c3e377842ad (diff) |
Cycles: new camera_direction_from_point
Reviewers: brecht
Differential Revision: https://developer.blender.org/D556
Diffstat (limited to 'intern/cycles/kernel/kernel_camera.h')
-rw-r--r-- | intern/cycles/kernel/kernel_camera.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/intern/cycles/kernel/kernel_camera.h b/intern/cycles/kernel/kernel_camera.h index 7fc66a9fdee..6b03abe9708 100644 --- a/intern/cycles/kernel/kernel_camera.h +++ b/intern/cycles/kernel/kernel_camera.h @@ -262,6 +262,20 @@ ccl_device_inline float camera_distance(KernelGlobals *kg, float3 P) return len(P - camP); } +ccl_device_inline float3 camera_direction_from_point(KernelGlobals *kg, float3 P) +{ + Transform cameratoworld = kernel_data.cam.cameratoworld; + + if(kernel_data.cam.type == CAMERA_ORTHOGRAPHIC) { + float3 camD = make_float3(cameratoworld.x.z, cameratoworld.y.z, cameratoworld.z.z); + return -camD; + } + else { + float3 camP = make_float3(cameratoworld.x.w, cameratoworld.y.w, cameratoworld.z.w); + return normalize(camP - P); + } +} + ccl_device_inline float3 camera_world_to_ndc(KernelGlobals *kg, ShaderData *sd, float3 P) { if(kernel_data.cam.type != CAMERA_PANORAMA) { |