Merge branch 'blender-v3.0-release'

This commit is contained in:
Brecht Van Lommel 2021-10-28 22:42:04 +02:00
commit adf82fe943
4 changed files with 41 additions and 25 deletions

View File

@ -306,15 +306,15 @@ ccl_device_inline void camera_sample_panorama(ccl_constant KernelCamera *cam,
}
#endif
P = transform_point(&cameratoworld, P);
D = normalize(transform_direction(&cameratoworld, D));
/* Stereo transform */
bool use_stereo = cam->interocular_offset != 0.0f;
if (use_stereo) {
spherical_stereo_transform(cam, &P, &D);
}
P = transform_point(&cameratoworld, P);
D = normalize(transform_direction(&cameratoworld, D));
ray->P = P;
ray->D = D;
@ -325,19 +325,19 @@ ccl_device_inline void camera_sample_panorama(ccl_constant KernelCamera *cam,
* and simply take their differences. */
float3 Pcenter = Pcamera;
float3 Dcenter = panorama_to_direction(cam, Pcenter.x, Pcenter.y);
Pcenter = transform_point(&cameratoworld, Pcenter);
Dcenter = normalize(transform_direction(&cameratoworld, Dcenter));
if (use_stereo) {
spherical_stereo_transform(cam, &Pcenter, &Dcenter);
}
Pcenter = transform_point(&cameratoworld, Pcenter);
Dcenter = normalize(transform_direction(&cameratoworld, Dcenter));
float3 Px = transform_perspective(&rastertocamera, make_float3(raster_x + 1.0f, raster_y, 0.0f));
float3 Dx = panorama_to_direction(cam, Px.x, Px.y);
Px = transform_point(&cameratoworld, Px);
Dx = normalize(transform_direction(&cameratoworld, Dx));
if (use_stereo) {
spherical_stereo_transform(cam, &Px, &Dx);
}
Px = transform_point(&cameratoworld, Px);
Dx = normalize(transform_direction(&cameratoworld, Dx));
differential3 dP, dD;
dP.dx = Px - Pcenter;
@ -345,11 +345,11 @@ ccl_device_inline void camera_sample_panorama(ccl_constant KernelCamera *cam,
float3 Py = transform_perspective(&rastertocamera, make_float3(raster_x, raster_y + 1.0f, 0.0f));
float3 Dy = panorama_to_direction(cam, Py.x, Py.y);
Py = transform_point(&cameratoworld, Py);
Dy = normalize(transform_direction(&cameratoworld, Dy));
if (use_stereo) {
spherical_stereo_transform(cam, &Py, &Dy);
}
Py = transform_point(&cameratoworld, Py);
Dy = normalize(transform_direction(&cameratoworld, Dy));
dP.dy = Py - Pcenter;
dD.dy = Dy - Dcenter;

View File

@ -159,9 +159,11 @@ ccl_device void integrator_intersect_closest(KernelGlobals kg, IntegratorState s
if (path_state_ao_bounce(kg, state)) {
ray.t = kernel_data.integrator.ao_bounces_distance;
const float object_ao_distance = kernel_tex_fetch(__objects, last_isect_object).ao_distance;
if (object_ao_distance != 0.0f) {
ray.t = object_ao_distance;
if (last_isect_object != OBJECT_NONE) {
const float object_ao_distance = kernel_tex_fetch(__objects, last_isect_object).ao_distance;
if (object_ao_distance != 0.0f) {
ray.t = object_ao_distance;
}
}
}

View File

@ -119,9 +119,6 @@ ccl_device_inline bool subsurface_disk(KernelGlobals kg,
float sum_weights = 0.0f;
for (int hit = 0; hit < num_eval_hits; hit++) {
/* Quickly retrieve P and Ng without setting up ShaderData. */
const float3 hit_P = ray.P + ray.D * ss_isect.hits[hit].t;
/* Get geometric normal. */
const int object = ss_isect.hits[hit].object;
const int object_flag = kernel_tex_fetch(__object_flag, object);
@ -131,11 +128,24 @@ ccl_device_inline bool subsurface_disk(KernelGlobals kg,
}
if (!(object_flag & SD_OBJECT_TRANSFORM_APPLIED)) {
/* Transform normal to world space. */
Transform itfm;
object_fetch_transform_motion_test(kg, object, time, &itfm);
Transform tfm = object_fetch_transform_motion_test(kg, object, time, &itfm);
hit_Ng = normalize(transform_direction_transposed(&itfm, hit_Ng));
/* Transform t to world space, except for OptiX where it already is. */
#ifdef __KERNEL_OPTIX__
(void)tfm;
#else
float3 D = transform_direction(&itfm, ray.D);
D = normalize(D) * ss_isect.hits[hit].t;
ss_isect.hits[hit].t = len(transform_direction(&tfm, D));
#endif
}
/* Quickly retrieve P and Ng without setting up ShaderData. */
const float3 hit_P = ray.P + ray.D * ss_isect.hits[hit].t;
/* Probability densities for local frame axes. */
const float pdf_N = pick_pdf_N * fabsf(dot(disk_N, hit_Ng));
const float pdf_T = pick_pdf_T * fabsf(dot(disk_T, hit_Ng));

View File

@ -592,22 +592,26 @@ BoundBox Camera::viewplane_bounds_get()
if (camera_type == CAMERA_PANORAMA) {
if (use_spherical_stereo == false) {
bounds.grow(make_float3(cameratoworld.x.w, cameratoworld.y.w, cameratoworld.z.w));
bounds.grow(make_float3(cameratoworld.x.w, cameratoworld.y.w, cameratoworld.z.w), nearclip);
}
else {
float half_eye_distance = interocular_distance * 0.5f;
bounds.grow(make_float3(
cameratoworld.x.w + half_eye_distance, cameratoworld.y.w, cameratoworld.z.w));
bounds.grow(
make_float3(cameratoworld.x.w + half_eye_distance, cameratoworld.y.w, cameratoworld.z.w),
nearclip);
bounds.grow(make_float3(
cameratoworld.z.w, cameratoworld.y.w + half_eye_distance, cameratoworld.z.w));
bounds.grow(
make_float3(cameratoworld.z.w, cameratoworld.y.w + half_eye_distance, cameratoworld.z.w),
nearclip);
bounds.grow(make_float3(
cameratoworld.x.w - half_eye_distance, cameratoworld.y.w, cameratoworld.z.w));
bounds.grow(
make_float3(cameratoworld.x.w - half_eye_distance, cameratoworld.y.w, cameratoworld.z.w),
nearclip);
bounds.grow(make_float3(
cameratoworld.x.w, cameratoworld.y.w - half_eye_distance, cameratoworld.z.w));
bounds.grow(
make_float3(cameratoworld.x.w, cameratoworld.y.w - half_eye_distance, cameratoworld.z.w),
nearclip);
}
}
else {