Cycles: Fix wrong camera in volume check when domain is only visible to camera rays

This commit is contained in:
Sergey Sharybin 2016-04-04 19:30:38 +02:00
parent ac8f4ba530
commit 65f279b770
6 changed files with 46 additions and 36 deletions

@ -299,38 +299,39 @@ ccl_device_intersect bool scene_intersect_shadow_all(KernelGlobals *kg, const Ra
#ifdef __VOLUME__
ccl_device_intersect bool scene_intersect_volume(KernelGlobals *kg,
const Ray *ray,
Intersection *isect)
Intersection *isect,
const uint visibility)
{
# ifdef __OBJECT_MOTION__
if(kernel_data.bvh.have_motion) {
# ifdef __HAIR__
if(kernel_data.bvh.have_curves)
return bvh_intersect_volume_hair_motion(kg, ray, isect);
return bvh_intersect_volume_hair_motion(kg, ray, isect, visibility);
# endif /* __HAIR__ */
return bvh_intersect_volume_motion(kg, ray, isect);
return bvh_intersect_volume_motion(kg, ray, isect, visibility);
}
# endif /* __OBJECT_MOTION__ */
# ifdef __HAIR__
if(kernel_data.bvh.have_curves)
return bvh_intersect_volume_hair(kg, ray, isect);
return bvh_intersect_volume_hair(kg, ray, isect, visibility);
# endif /* __HAIR__ */
# ifdef __KERNEL_CPU__
# ifdef __INSTANCING__
if(kernel_data.bvh.have_instancing)
return bvh_intersect_volume_instancing(kg, ray, isect);
return bvh_intersect_volume_instancing(kg, ray, isect, visibility);
# endif /* __INSTANCING__ */
return bvh_intersect_volume(kg, ray, isect);
return bvh_intersect_volume(kg, ray, isect, visibility);
# else /* __KERNEL_CPU__ */
# ifdef __INSTANCING__
return bvh_intersect_volume_instancing(kg, ray, isect);
return bvh_intersect_volume_instancing(kg, ray, isect, visibility);
# else
return bvh_intersect_volume(kg, ray, isect);
return bvh_intersect_volume(kg, ray, isect, visibility);
# endif /* __INSTANCING__ */
# endif /* __KERNEL_CPU__ */
@ -341,30 +342,31 @@ ccl_device_intersect bool scene_intersect_volume(KernelGlobals *kg,
ccl_device_intersect uint scene_intersect_volume_all(KernelGlobals *kg,
const Ray *ray,
Intersection *isect,
const uint max_hits)
const uint max_hits,
const uint visibility)
{
# ifdef __OBJECT_MOTION__
if(kernel_data.bvh.have_motion) {
# ifdef __HAIR__
if(kernel_data.bvh.have_curves)
return bvh_intersect_volume_all_hair_motion(kg, ray, isect, max_hits);
return bvh_intersect_volume_all_hair_motion(kg, ray, isect, max_hits, visibility);
# endif /* __HAIR__ */
return bvh_intersect_volume_all_motion(kg, ray, isect, max_hits);
return bvh_intersect_volume_all_motion(kg, ray, isect, max_hits, visibility);
}
# endif /* __OBJECT_MOTION__ */
# ifdef __HAIR__
if(kernel_data.bvh.have_curves)
return bvh_intersect_volume_all_hair(kg, ray, isect, max_hits);
return bvh_intersect_volume_all_hair(kg, ray, isect, max_hits, visibility);
# endif /* __HAIR__ */
# ifdef __INSTANCING__
if(kernel_data.bvh.have_instancing)
return bvh_intersect_volume_all_instancing(kg, ray, isect, max_hits);
return bvh_intersect_volume_all_instancing(kg, ray, isect, max_hits, visibility);
# endif /* __INSTANCING__ */
return bvh_intersect_volume_all(kg, ray, isect, max_hits);
return bvh_intersect_volume_all(kg, ray, isect, max_hits, visibility);
}
#endif /* __VOLUME_RECORD_ALL__ */

@ -33,7 +33,8 @@
ccl_device bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
const Ray *ray,
Intersection *isect)
Intersection *isect,
const uint visibility)
{
/* todo:
* - test if pushing distance on the stack helps (for non shadow rays)
@ -56,8 +57,6 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
float3 idir = bvh_inverse_direction(dir);
int object = OBJECT_NONE;
const uint visibility = PATH_RAY_ALL_VISIBILITY;
#if BVH_FEATURE(BVH_MOTION)
Transform ob_itfm;
#endif
@ -336,13 +335,15 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
ccl_device_inline bool BVH_FUNCTION_NAME(KernelGlobals *kg,
const Ray *ray,
Intersection *isect)
Intersection *isect,
const uint visibility)
{
#ifdef __QBVH__
if(kernel_data.bvh.use_qbvh) {
return BVH_FUNCTION_FULL_NAME(QBVH)(kg,
ray,
isect);
isect,
visibility);
}
else
#endif
@ -350,7 +351,8 @@ ccl_device_inline bool BVH_FUNCTION_NAME(KernelGlobals *kg,
kernel_assert(kernel_data.bvh.use_qbvh == false);
return BVH_FUNCTION_FULL_NAME(BVH)(kg,
ray,
isect);
isect,
visibility);
}
}

@ -34,7 +34,8 @@
ccl_device uint BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
const Ray *ray,
Intersection *isect_array,
const uint max_hits)
const uint max_hits,
const uint visibility)
{
/* todo:
* - test if pushing distance on the stack helps (for non shadow rays)
@ -59,8 +60,6 @@ ccl_device uint BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
int object = OBJECT_NONE;
float isect_t = tmax;
const uint visibility = PATH_RAY_ALL_VISIBILITY;
#if BVH_FEATURE(BVH_MOTION)
Transform ob_itfm;
#endif
@ -430,14 +429,16 @@ ccl_device uint BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
ccl_device_inline uint BVH_FUNCTION_NAME(KernelGlobals *kg,
const Ray *ray,
Intersection *isect_array,
const uint max_hits)
const uint max_hits,
const uint visibility)
{
#ifdef __QBVH__
if(kernel_data.bvh.use_qbvh) {
return BVH_FUNCTION_FULL_NAME(QBVH)(kg,
ray,
isect_array,
max_hits);
max_hits,
visibility);
}
else
#endif
@ -446,7 +447,8 @@ ccl_device_inline uint BVH_FUNCTION_NAME(KernelGlobals *kg,
return BVH_FUNCTION_FULL_NAME(BVH)(kg,
ray,
isect_array,
max_hits);
max_hits,
visibility);
}
}

@ -29,7 +29,8 @@
ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg,
const Ray *ray,
Intersection *isect)
Intersection *isect,
const uint visibility)
{
/* TODO(sergey):
* - Test if pushing distance on the stack helps.
@ -51,8 +52,6 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg,
float3 idir = bvh_inverse_direction(dir);
int object = OBJECT_NONE;
const uint visibility = PATH_RAY_ALL_VISIBILITY;
#if BVH_FEATURE(BVH_MOTION)
Transform ob_itfm;
#endif

@ -30,7 +30,8 @@
ccl_device uint BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg,
const Ray *ray,
Intersection *isect_array,
const uint max_hits)
const uint max_hits,
const uint visibility)
{
/* TODO(sergey):
* - Test if pushing distance on the stack helps.
@ -54,8 +55,6 @@ ccl_device uint BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg,
int object = OBJECT_NONE;
float isect_t = tmax;
const uint visibility = PATH_RAY_ALL_VISIBILITY;
#if BVH_FEATURE(BVH_MOTION)
Transform ob_itfm;
#endif

@ -994,12 +994,14 @@ ccl_device void kernel_volume_stack_init(KernelGlobals *kg,
int stack_index = 0, enclosed_index = 0;
const uint visibility = PATH_RAY_ALL_VISIBILITY | kernel_data.integrator.layer_flag;
#ifdef __VOLUME_RECORD_ALL__
Intersection hits[2*VOLUME_STACK_SIZE];
uint num_hits = scene_intersect_volume_all(kg,
&volume_ray,
hits,
2*VOLUME_STACK_SIZE);
2*VOLUME_STACK_SIZE,
visibility);
if(num_hits > 0) {
int enclosed_volumes[VOLUME_STACK_SIZE];
Intersection *isect = hits;
@ -1048,7 +1050,7 @@ ccl_device void kernel_volume_stack_init(KernelGlobals *kg,
step < 2 * VOLUME_STACK_SIZE)
{
Intersection isect;
if(!scene_intersect_volume(kg, &volume_ray, &isect)) {
if(!scene_intersect_volume(kg, &volume_ray, &isect, visibility)) {
break;
}
@ -1159,7 +1161,8 @@ ccl_device void kernel_volume_stack_update_for_subsurface(KernelGlobals *kg,
uint num_hits = scene_intersect_volume_all(kg,
&volume_ray,
hits,
2*VOLUME_STACK_SIZE);
2*VOLUME_STACK_SIZE,
PATH_RAY_ALL_VISIBILITY);
if(num_hits > 0) {
Intersection *isect = hits;
@ -1175,7 +1178,10 @@ ccl_device void kernel_volume_stack_update_for_subsurface(KernelGlobals *kg,
Intersection isect;
int step = 0;
while(step < 2 * VOLUME_STACK_SIZE &&
scene_intersect_volume(kg, &volume_ray, &isect))
scene_intersect_volume(kg,
&volume_ray,
&isect,
PATH_RAY_ALL_VISIBILITY))
{
ShaderData sd;
shader_setup_from_ray(kg, &sd, &isect, &volume_ray);