Cycles: Remove hair support from volume BVH traversal
There are couple of reasons: - Volume shader on hair does behave really weird anyway and it's not something considered a bug really. - Volume BVH traversal were only used by camera-in-volume check, which doesn't really make sense to take hair into account since it'll be rendered wrong anyway. Such a removal makes both code easier to extend further (as in, no need to worry about those traversal for hair bvh) and also reduces stress on GPU compilers.
This commit is contained in:
parent
e4cdda548a
commit
ac00c17900
@ -111,24 +111,12 @@ CCL_NAMESPACE_BEGIN
|
||||
# include "geom_bvh_volume.h"
|
||||
#endif
|
||||
|
||||
#if defined(__VOLUME__) && defined(__HAIR__)
|
||||
# define BVH_FUNCTION_NAME bvh_intersect_volume_hair
|
||||
# define BVH_FUNCTION_FEATURES BVH_INSTANCING|BVH_HAIR|BVH_HAIR_MINIMUM_WIDTH
|
||||
# include "geom_bvh_volume.h"
|
||||
#endif
|
||||
|
||||
#if defined(__VOLUME__) && defined(__OBJECT_MOTION__)
|
||||
# define BVH_FUNCTION_NAME bvh_intersect_volume_motion
|
||||
# define BVH_FUNCTION_FEATURES BVH_INSTANCING|BVH_MOTION
|
||||
# include "geom_bvh_volume.h"
|
||||
#endif
|
||||
|
||||
#if defined(__VOLUME__) && defined(__HAIR__) && defined(__OBJECT_MOTION__)
|
||||
# define BVH_FUNCTION_NAME bvh_intersect_volume_hair_motion
|
||||
# define BVH_FUNCTION_FEATURES BVH_INSTANCING|BVH_HAIR|BVH_HAIR_MINIMUM_WIDTH|BVH_MOTION
|
||||
# include "geom_bvh_volume.h"
|
||||
#endif
|
||||
|
||||
/* Record all intersections - Shadow BVH traversal */
|
||||
|
||||
#if defined(__SHADOW_RECORD_ALL__)
|
||||
@ -175,24 +163,12 @@ CCL_NAMESPACE_BEGIN
|
||||
# include "geom_bvh_volume_all.h"
|
||||
#endif
|
||||
|
||||
#if defined(__VOLUME_RECORD_ALL__) && defined(__HAIR__)
|
||||
# define BVH_FUNCTION_NAME bvh_intersect_volume_all_hair
|
||||
# define BVH_FUNCTION_FEATURES BVH_INSTANCING|BVH_HAIR|BVH_HAIR_MINIMUM_WIDTH
|
||||
# include "geom_bvh_volume_all.h"
|
||||
#endif
|
||||
|
||||
#if defined(__VOLUME_RECORD_ALL__) && defined(__OBJECT_MOTION__)
|
||||
# define BVH_FUNCTION_NAME bvh_intersect_volume_all_motion
|
||||
# define BVH_FUNCTION_FEATURES BVH_INSTANCING|BVH_MOTION
|
||||
# include "geom_bvh_volume_all.h"
|
||||
#endif
|
||||
|
||||
#if defined(__VOLUME_RECORD_ALL__) && defined(__HAIR__) && defined(__OBJECT_MOTION__)
|
||||
# define BVH_FUNCTION_NAME bvh_intersect_volume_all_hair_motion
|
||||
# define BVH_FUNCTION_FEATURES BVH_INSTANCING|BVH_HAIR|BVH_HAIR_MINIMUM_WIDTH|BVH_MOTION
|
||||
# include "geom_bvh_volume_all.h"
|
||||
#endif
|
||||
|
||||
#undef BVH_FEATURE
|
||||
#undef BVH_NAME_JOIN
|
||||
#undef BVH_NAME_EVAL
|
||||
@ -304,36 +280,21 @@ ccl_device_intersect bool scene_intersect_volume(KernelGlobals *kg,
|
||||
{
|
||||
# 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, visibility);
|
||||
# endif /* __HAIR__ */
|
||||
|
||||
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, visibility);
|
||||
# endif /* __HAIR__ */
|
||||
|
||||
# ifdef __KERNEL_CPU__
|
||||
|
||||
# ifdef __INSTANCING__
|
||||
if(kernel_data.bvh.have_instancing)
|
||||
return bvh_intersect_volume_instancing(kg, ray, isect, visibility);
|
||||
# endif /* __INSTANCING__ */
|
||||
|
||||
return bvh_intersect_volume(kg, ray, isect, visibility);
|
||||
# else /* __KERNEL_CPU__ */
|
||||
|
||||
# ifdef __INSTANCING__
|
||||
return bvh_intersect_volume_instancing(kg, ray, isect, visibility);
|
||||
# else
|
||||
return bvh_intersect_volume(kg, ray, isect, visibility);
|
||||
# endif /* __INSTANCING__ */
|
||||
|
||||
# endif /* __KERNEL_CPU__ */
|
||||
}
|
||||
#endif /* __VOLUME__ */
|
||||
@ -347,25 +308,13 @@ ccl_device_intersect uint scene_intersect_volume_all(KernelGlobals *kg,
|
||||
{
|
||||
# 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, visibility);
|
||||
# endif /* __HAIR__ */
|
||||
|
||||
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, visibility);
|
||||
# endif /* __HAIR__ */
|
||||
|
||||
# ifdef __INSTANCING__
|
||||
if(kernel_data.bvh.have_instancing)
|
||||
return bvh_intersect_volume_all_instancing(kg, ray, isect, max_hits, visibility);
|
||||
# endif /* __INSTANCING__ */
|
||||
|
||||
return bvh_intersect_volume_all(kg, ray, isect, max_hits, visibility);
|
||||
}
|
||||
#endif /* __VOLUME_RECORD_ALL__ */
|
||||
|
@ -26,7 +26,6 @@
|
||||
* versions for each case without new features slowing things down.
|
||||
*
|
||||
* BVH_INSTANCING: object instancing
|
||||
* BVH_HAIR: hair curve rendering
|
||||
* BVH_MOTION: motion blur rendering
|
||||
*
|
||||
*/
|
||||
@ -231,26 +230,6 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
|
||||
}
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
#if BVH_FEATURE(BVH_HAIR)
|
||||
case PRIMITIVE_CURVE:
|
||||
case PRIMITIVE_MOTION_CURVE: {
|
||||
/* intersect ray against primitive */
|
||||
for(; primAddr < primAddr2; primAddr++) {
|
||||
kernel_assert(kernel_tex_fetch(__prim_type, primAddr) == type);
|
||||
/* only primitives from volume object */
|
||||
uint tri_object = (object == OBJECT_NONE)? kernel_tex_fetch(__prim_object, primAddr): object;
|
||||
int object_flag = kernel_tex_fetch(__object_flag, tri_object);
|
||||
if((object_flag & SD_OBJECT_HAS_VOLUME) == 0) {
|
||||
continue;
|
||||
}
|
||||
if(kernel_data.curve.curveflags & CURVE_KN_INTERPOLATE)
|
||||
bvh_cardinal_curve_intersect(kg, isect, P, dir, visibility, object, primAddr, ray->time, type, NULL, 0, 0);
|
||||
else
|
||||
bvh_curve_intersect(kg, isect, P, dir, visibility, object, primAddr, ray->time, type, NULL, 0, 0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
default: {
|
||||
break;
|
||||
|
@ -26,7 +26,6 @@
|
||||
* versions for each case without new features slowing things down.
|
||||
*
|
||||
* BVH_INSTANCING: object instancing
|
||||
* BVH_HAIR: hair curve rendering
|
||||
* BVH_MOTION: motion blur rendering
|
||||
*
|
||||
*/
|
||||
@ -283,49 +282,6 @@ ccl_device uint BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
|
||||
break;
|
||||
}
|
||||
#endif /* BVH_MOTION */
|
||||
#if BVH_FEATURE(BVH_HAIR)
|
||||
case PRIMITIVE_CURVE:
|
||||
case PRIMITIVE_MOTION_CURVE: {
|
||||
/* intersect ray against primitive */
|
||||
for(; primAddr < primAddr2; primAddr++) {
|
||||
kernel_assert(kernel_tex_fetch(__prim_type, primAddr) == type);
|
||||
/* only primitives from volume object */
|
||||
uint tri_object = (object == OBJECT_NONE)? kernel_tex_fetch(__prim_object, primAddr): object;
|
||||
int object_flag = kernel_tex_fetch(__object_flag, tri_object);
|
||||
if((object_flag & SD_OBJECT_HAS_VOLUME) == 0) {
|
||||
continue;
|
||||
}
|
||||
if(kernel_data.curve.curveflags & CURVE_KN_INTERPOLATE)
|
||||
hit = bvh_cardinal_curve_intersect(kg, isect_array, P, dir, visibility, object, primAddr, ray->time, type, NULL, 0, 0);
|
||||
else
|
||||
hit = bvh_curve_intersect(kg, isect_array, P, dir, visibility, object, primAddr, ray->time, type, NULL, 0, 0);
|
||||
if(hit) {
|
||||
/* Move on to next entry in intersections array. */
|
||||
isect_array++;
|
||||
num_hits++;
|
||||
# if BVH_FEATURE(BVH_INSTANCING)
|
||||
num_hits_in_instance++;
|
||||
# endif
|
||||
isect_array->t = isect_t;
|
||||
if(num_hits == max_hits) {
|
||||
# if BVH_FEATURE(BVH_INSTANCING)
|
||||
# if BVH_FEATURE(BVH_MOTION)
|
||||
float t_fac = 1.0f / len(transform_direction(&ob_itfm, dir));
|
||||
# else
|
||||
Transform itfm = object_fetch_transform(kg, object, OBJECT_INVERSE_TRANSFORM);
|
||||
float t_fac = 1.0f / len(transform_direction(&itfm, dir));
|
||||
# endif
|
||||
for(int i = 0; i < num_hits_in_instance; i++) {
|
||||
(isect_array-i-1)->t *= t_fac;
|
||||
}
|
||||
# endif /* BVH_FEATURE(BVH_INSTANCING) */
|
||||
return num_hits;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
#endif /* BVH_HAIR */
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
|
@ -22,7 +22,6 @@
|
||||
* versions for each case without new features slowing things down.
|
||||
*
|
||||
* BVH_INSTANCING: object instancing
|
||||
* BVH_HAIR: hair curve rendering
|
||||
* BVH_MOTION: motion blur rendering
|
||||
*
|
||||
*/
|
||||
@ -248,26 +247,6 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg,
|
||||
}
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
#if BVH_FEATURE(BVH_HAIR)
|
||||
case PRIMITIVE_CURVE:
|
||||
case PRIMITIVE_MOTION_CURVE: {
|
||||
for(; primAddr < primAddr2; primAddr++) {
|
||||
kernel_assert(kernel_tex_fetch(__prim_type, primAddr) == type);
|
||||
/* Only primitives from volume object. */
|
||||
uint tri_object = (object == OBJECT_NONE)? kernel_tex_fetch(__prim_object, primAddr): object;
|
||||
int object_flag = kernel_tex_fetch(__object_flag, tri_object);
|
||||
if((object_flag & SD_OBJECT_HAS_VOLUME) == 0) {
|
||||
continue;
|
||||
}
|
||||
/* Intersect ray against primitive. */
|
||||
if(kernel_data.curve.curveflags & CURVE_KN_INTERPOLATE)
|
||||
bvh_cardinal_curve_intersect(kg, isect, P, dir, visibility, object, primAddr, ray->time, type, NULL, 0, 0);
|
||||
else
|
||||
bvh_curve_intersect(kg, isect, P, dir, visibility, object, primAddr, ray->time, type, NULL, 0, 0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,6 @@
|
||||
* versions for each case without new features slowing things down.
|
||||
*
|
||||
* BVH_INSTANCING: object instancing
|
||||
* BVH_HAIR: hair curve rendering
|
||||
* BVH_MOTION: motion blur rendering
|
||||
*
|
||||
*/
|
||||
@ -300,49 +299,6 @@ ccl_device uint BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg,
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
#if BVH_FEATURE(BVH_HAIR)
|
||||
case PRIMITIVE_CURVE:
|
||||
case PRIMITIVE_MOTION_CURVE: {
|
||||
for(; primAddr < primAddr2; primAddr++) {
|
||||
kernel_assert(kernel_tex_fetch(__prim_type, primAddr) == type);
|
||||
/* Only primitives from volume object. */
|
||||
uint tri_object = (object == OBJECT_NONE)? kernel_tex_fetch(__prim_object, primAddr): object;
|
||||
int object_flag = kernel_tex_fetch(__object_flag, tri_object);
|
||||
if((object_flag & SD_OBJECT_HAS_VOLUME) == 0) {
|
||||
continue;
|
||||
}
|
||||
/* Intersect ray against primitive. */
|
||||
if(kernel_data.curve.curveflags & CURVE_KN_INTERPOLATE)
|
||||
hit = bvh_cardinal_curve_intersect(kg, isect_array, P, dir, visibility, object, primAddr, ray->time, type, NULL, 0, 0);
|
||||
else
|
||||
hit = bvh_curve_intersect(kg, isect_array, P, dir, visibility, object, primAddr, ray->time, type, NULL, 0, 0);
|
||||
if(hit) {
|
||||
/* Move on to next entry in intersections array. */
|
||||
isect_array++;
|
||||
num_hits++;
|
||||
# if BVH_FEATURE(BVH_INSTANCING)
|
||||
num_hits_in_instance++;
|
||||
# endif
|
||||
isect_array->t = isect_t;
|
||||
if(num_hits == max_hits) {
|
||||
# if BVH_FEATURE(BVH_INSTANCING)
|
||||
# if BVH_FEATURE(BVH_MOTION)
|
||||
float t_fac = 1.0f / len(transform_direction(&ob_itfm, dir));
|
||||
# else
|
||||
Transform itfm = object_fetch_transform(kg, object, OBJECT_INVERSE_TRANSFORM);
|
||||
float t_fac = 1.0f / len(transform_direction(&itfm, dir));
|
||||
# endif
|
||||
for(int i = 0; i < num_hits_in_instance; i++) {
|
||||
(isect_array-i-1)->t *= t_fac;
|
||||
}
|
||||
# endif /* BVH_FEATURE(BVH_INSTANCING) */
|
||||
return num_hits;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
#endif /* BVH_HAIR */
|
||||
}
|
||||
}
|
||||
#if BVH_FEATURE(BVH_INSTANCING)
|
||||
|
Loading…
Reference in New Issue
Block a user