Cleanup: remove Cycles layer bits checking in the kernel.
At some point the idea was that we could have an optimization where we could render multiple render layers without re-exporting the scene, by just updating the layer bits. We are not doing this now and in practice with the available render layer control like exclude layers it's not always possible anyway. This makes it easier to support an arbitrary number of layers in the future (hopefully this summer), and frees up some useful bits in the kernel. Reviewed By: sergey, dingto Differential Revision: https://developer.blender.org/D2020
This commit is contained in:
@@ -365,13 +365,12 @@ Object *BlenderSync::sync_object(BL::Object& b_parent,
|
||||
}
|
||||
|
||||
/* make holdout objects on excluded layer invisible for non-camera rays */
|
||||
if(use_holdout && (layer_flag & render_layer.exclude_layer))
|
||||
if(use_holdout && (layer_flag & render_layer.exclude_layer)) {
|
||||
visibility &= ~(PATH_RAY_ALL_VISIBILITY - PATH_RAY_CAMERA);
|
||||
}
|
||||
|
||||
/* camera flag is not actually used, instead is tested against render layer
|
||||
* flags */
|
||||
if(visibility & PATH_RAY_CAMERA) {
|
||||
visibility |= layer_flag << PATH_RAY_LAYER_SHIFT;
|
||||
/* hide objects not on render layer from camera rays */
|
||||
if(!(layer_flag & render_layer.layer)) {
|
||||
visibility &= ~PATH_RAY_CAMERA;
|
||||
}
|
||||
|
||||
@@ -572,7 +571,6 @@ void BlenderSync::sync_objects(BL::SpaceView3D& b_v3d, float motion_time)
|
||||
bool hide = (render_layer.use_viewport_visibility)? b_ob.hide(): b_ob.hide_render();
|
||||
uint ob_layer = get_layer(b_base->layers(),
|
||||
b_base->layers_local_view(),
|
||||
render_layer.use_localview,
|
||||
object_is_light(b_ob),
|
||||
scene_layers);
|
||||
hide = hide || !(ob_layer & scene_layer);
|
||||
|
@@ -269,8 +269,6 @@ void BlenderSync::sync_integrator()
|
||||
SAMPLING_NUM_PATTERNS,
|
||||
SAMPLING_PATTERN_SOBOL);
|
||||
|
||||
integrator->layer_flag = render_layer.layer;
|
||||
|
||||
integrator->sample_clamp_direct = get_float(cscene, "sample_clamp_direct");
|
||||
integrator->sample_clamp_indirect = get_float(cscene, "sample_clamp_indirect");
|
||||
#ifdef __CAMERA_MOTION__
|
||||
@@ -377,8 +375,7 @@ void BlenderSync::sync_render_layers(BL::SpaceView3D& b_v3d, const char *layer)
|
||||
layer = layername.c_str();
|
||||
}
|
||||
else {
|
||||
render_layer.use_localview = (b_v3d.local_view() ? true : false);
|
||||
render_layer.scene_layer = get_layer(b_v3d.layers(), b_v3d.layers_local_view(), render_layer.use_localview);
|
||||
render_layer.scene_layer = get_layer(b_v3d.layers(), b_v3d.layers_local_view());
|
||||
render_layer.layer = render_layer.scene_layer;
|
||||
render_layer.exclude_layer = 0;
|
||||
render_layer.holdout_layer = 0;
|
||||
@@ -421,7 +418,6 @@ void BlenderSync::sync_render_layers(BL::SpaceView3D& b_v3d, const char *layer)
|
||||
render_layer.use_surfaces = b_rlay->use_solid();
|
||||
render_layer.use_hair = b_rlay->use_strand();
|
||||
render_layer.use_viewport_visibility = false;
|
||||
render_layer.use_localview = false;
|
||||
|
||||
render_layer.bound_samples = (use_layer_samples == 1);
|
||||
if(use_layer_samples != 2) {
|
||||
|
@@ -185,7 +185,6 @@ private:
|
||||
use_surfaces(true),
|
||||
use_hair(true),
|
||||
use_viewport_visibility(false),
|
||||
use_localview(false),
|
||||
samples(0), bound_samples(false)
|
||||
{}
|
||||
|
||||
@@ -200,7 +199,6 @@ private:
|
||||
bool use_surfaces;
|
||||
bool use_hair;
|
||||
bool use_viewport_visibility;
|
||||
bool use_localview;
|
||||
int samples;
|
||||
bool bound_samples;
|
||||
} render_layer;
|
||||
|
@@ -275,7 +275,6 @@ static inline uint get_layer(const BL::Array<int, 20>& array)
|
||||
|
||||
static inline uint get_layer(const BL::Array<int, 20>& array,
|
||||
const BL::Array<int, 8>& local_array,
|
||||
bool use_local,
|
||||
bool is_light = false,
|
||||
uint scene_layers = (1 << 20) - 1)
|
||||
{
|
||||
@@ -300,13 +299,6 @@ static inline uint get_layer(const BL::Array<int, 20>& array,
|
||||
layer |= (1 << (20+i));
|
||||
}
|
||||
|
||||
/* we don't have spare bits for localview (normally 20-28) because
|
||||
* PATH_RAY_LAYER_SHIFT uses 20-32. So - check if we have localview and if
|
||||
* so, shift local view bits down to 1-8, since this is done for the view
|
||||
* port only - it should be OK and not conflict with render layers. */
|
||||
if(use_local)
|
||||
layer >>= 20;
|
||||
|
||||
return layer;
|
||||
}
|
||||
|
||||
|
@@ -131,9 +131,6 @@ ccl_device_inline uint path_state_ray_visibility(KernelGlobals *kg, PathState *s
|
||||
/* todo: this is not supported as its own ray visibility yet */
|
||||
if(state->flag & PATH_RAY_VOLUME_SCATTER)
|
||||
flag |= PATH_RAY_DIFFUSE;
|
||||
/* for camera visibility, use render layer flags */
|
||||
if(flag & PATH_RAY_CAMERA)
|
||||
flag |= kernel_data.integrator.layer_flag;
|
||||
|
||||
return flag;
|
||||
}
|
||||
|
@@ -276,10 +276,7 @@ enum SamplingPattern {
|
||||
SAMPLING_NUM_PATTERNS,
|
||||
};
|
||||
|
||||
/* these flags values correspond to raytypes in osl.cpp, so keep them in sync!
|
||||
*
|
||||
* for ray visibility tests in BVH traversal, the upper 20 bits are used for
|
||||
* layer visibility tests. */
|
||||
/* these flags values correspond to raytypes in osl.cpp, so keep them in sync! */
|
||||
|
||||
enum PathRayFlag {
|
||||
PATH_RAY_CAMERA = 1,
|
||||
@@ -303,9 +300,6 @@ enum PathRayFlag {
|
||||
PATH_RAY_MIS_SKIP = 2048,
|
||||
PATH_RAY_DIFFUSE_ANCESTOR = 4096,
|
||||
PATH_RAY_SINGLE_PASS_DONE = 8192,
|
||||
|
||||
/* we need layer member flags to be the 20 upper bits */
|
||||
PATH_RAY_LAYER_SHIFT = (32-20)
|
||||
};
|
||||
|
||||
/* Closure Label */
|
||||
@@ -1081,9 +1075,6 @@ typedef struct KernelIntegrator {
|
||||
/* seed */
|
||||
int seed;
|
||||
|
||||
/* render layer */
|
||||
int layer_flag;
|
||||
|
||||
/* clamp */
|
||||
float sample_clamp_direct;
|
||||
float sample_clamp_indirect;
|
||||
|
@@ -1026,14 +1026,13 @@ 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,
|
||||
visibility);
|
||||
PATH_RAY_ALL_VISIBILITY);
|
||||
if(num_hits > 0) {
|
||||
int enclosed_volumes[VOLUME_STACK_SIZE];
|
||||
Intersection *isect = hits;
|
||||
@@ -1083,7 +1082,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, visibility)) {
|
||||
if(!scene_intersect_volume(kg, &volume_ray, &isect, PATH_RAY_ALL_VISIBILITY)) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
@@ -50,7 +50,6 @@ NODE_DEFINE(Integrator)
|
||||
SOCKET_BOOLEAN(caustics_refractive, "Refractive Caustics", true);
|
||||
SOCKET_FLOAT(filter_glossy, "Filter Glossy", 0.0f);
|
||||
SOCKET_INT(seed, "Seed", 0);
|
||||
SOCKET_INT(layer_flag, "Layer Flag", ~0);
|
||||
SOCKET_FLOAT(sample_clamp_direct, "Sample Clamp Direct", 0.0f);
|
||||
SOCKET_FLOAT(sample_clamp_indirect, "Sample Clamp Indirect", 0.0f);
|
||||
SOCKET_BOOLEAN(motion_blur, "Motion Blur", false);
|
||||
@@ -137,7 +136,6 @@ void Integrator::device_update(Device *device, DeviceScene *dscene, Scene *scene
|
||||
kintegrator->filter_glossy = (filter_glossy == 0.0f)? FLT_MAX: 1.0f/filter_glossy;
|
||||
|
||||
kintegrator->seed = hash_int(seed);
|
||||
kintegrator->layer_flag = layer_flag << PATH_RAY_LAYER_SHIFT;
|
||||
|
||||
kintegrator->use_ambient_occlusion =
|
||||
((Pass::contains(scene->film->passes, PASS_AO)) || dscene->data.background.ao_factor != 0.0f);
|
||||
|
@@ -51,7 +51,6 @@ public:
|
||||
float filter_glossy;
|
||||
|
||||
int seed;
|
||||
int layer_flag;
|
||||
|
||||
float sample_clamp_direct;
|
||||
float sample_clamp_indirect;
|
||||
|
Reference in New Issue
Block a user