Cycles: change perspective depth pass to be more standard

Now it matches Eevee, OpenGL and other renderers. Panoramic camera depth passes
are unchanged, and are still distance from the camera center.
This commit is contained in:
Brecht Van Lommel 2020-05-10 16:12:46 +02:00
parent 98c301d25e
commit 18cda8be87
2 changed files with 16 additions and 2 deletions

View File

@ -441,8 +441,22 @@ ccl_device_inline float camera_distance(KernelGlobals *kg, float3 P)
float3 camD = make_float3(cameratoworld.x.z, cameratoworld.y.z, cameratoworld.z.z);
return fabsf(dot((P - camP), camD));
}
else
else {
return len(P - camP);
}
}
ccl_device_inline float camera_z_depth(KernelGlobals *kg, float3 P)
{
if (kernel_data.cam.type != CAMERA_PANORAMA) {
Transform worldtocamera = kernel_data.cam.worldtocamera;
return transform_point(&worldtocamera, P).z;
}
else {
Transform cameratoworld = kernel_data.cam.cameratoworld;
float3 camP = make_float3(cameratoworld.x.w, cameratoworld.y.w, cameratoworld.z.w);
return len(P - camP);
}
}
ccl_device_inline float3 camera_direction_from_point(KernelGlobals *kg, float3 P)

View File

@ -194,7 +194,7 @@ ccl_device_inline void kernel_write_data_passes(KernelGlobals *kg,
average(shader_bsdf_alpha(kg, sd)) >= kernel_data.film.pass_alpha_threshold) {
if (state->sample == 0) {
if (flag & PASSMASK(DEPTH)) {
float depth = camera_distance(kg, sd->P);
float depth = camera_z_depth(kg, sd->P);
kernel_write_pass_float(buffer + kernel_data.film.pass_depth, depth);
}
if (flag & PASSMASK(OBJECT_ID)) {