[Bf-blender-cvs] [517094a] master: Cycles: new camera_direction_from_point
Dalai Felinto
noreply at git.blender.org
Tue May 27 16:10:46 CEST 2014
Commit: 517094a6977abd2ca3f50f15780fc15fdb125b99
Author: Dalai Felinto
Date: Tue May 27 10:56:59 2014 -0300
https://developer.blender.org/rB517094a6977abd2ca3f50f15780fc15fdb125b99
Cycles: new camera_direction_from_point
Reviewers: brecht
Differential Revision: https://developer.blender.org/D556
===================================================================
M intern/cycles/kernel/kernel_bake.h
M intern/cycles/kernel/kernel_camera.h
===================================================================
diff --git a/intern/cycles/kernel/kernel_bake.h b/intern/cycles/kernel/kernel_bake.h
index 4aae0aa..c843986 100644
--- a/intern/cycles/kernel/kernel_bake.h
+++ b/intern/cycles/kernel/kernel_bake.h
@@ -175,21 +175,13 @@ ccl_device void kernel_bake_evaluate(KernelGlobals *kg, ccl_global uint4 *input,
float time = TIME_INVALID;
int bounce = 0;
int transparent_bounce = 0;
- Transform cameratoworld = kernel_data.cam.cameratoworld;
/* light passes */
PathRadiance L;
shader_setup_from_sample(kg, &sd, P, Ng, I, shader, object, prim, u, v, t, time, bounce, transparent_bounce);
- if(kernel_data.cam.type == CAMERA_ORTHOGRAPHIC) {
- float3 camD = make_float3(cameratoworld.x.z, cameratoworld.y.z, cameratoworld.z.z);
- sd.I = -camD;
- }
- else {
- float3 camP = make_float3(cameratoworld.x.w, cameratoworld.y.w, cameratoworld.z.w);
- sd.I = normalize(camP - sd.P);
- }
+ sd.I = camera_direction_from_point(kg, sd.P);
/* update differentials */
sd.dP.dx = sd.dPdu * dudx + sd.dPdv * dvdx;
diff --git a/intern/cycles/kernel/kernel_camera.h b/intern/cycles/kernel/kernel_camera.h
index 7fc66a9..6b03abe 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) {
More information about the Bf-blender-cvs
mailing list