Cycles: new camera_direction_from_point

Reviewers: brecht

Differential Revision: https://developer.blender.org/D556
This commit is contained in:
Dalai Felinto
2014-05-27 10:56:59 -03:00
parent 12abe94de8
commit 517094a697
2 changed files with 15 additions and 9 deletions

View File

@@ -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;

View File

@@ -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) {