Cycles: code refactoring, to do render layer visibility test a bit different,
replacing the camera visibility flag with object layer flags.
This commit is contained in:
parent
2f90cfd423
commit
b65061e2ae
@ -82,9 +82,9 @@ static void session_print_status()
|
||||
session_print(status);
|
||||
}
|
||||
|
||||
static BufferParams session_buffer_params()
|
||||
static BufferParams& session_buffer_params()
|
||||
{
|
||||
BufferParams buffer_params;
|
||||
static BufferParams buffer_params;
|
||||
buffer_params.width = options.width;
|
||||
buffer_params.height = options.height;
|
||||
buffer_params.full_width = options.width;
|
||||
|
@ -258,7 +258,6 @@ static void xml_read_integrator(const XMLReadState& state, pugi::xml_node node)
|
||||
xml_read_int(&integrator->min_bounce, node, "min_bounce");
|
||||
xml_read_int(&integrator->max_bounce, node, "max_bounce");
|
||||
xml_read_bool(&integrator->no_caustics, node, "no_caustics");
|
||||
xml_read_float(&integrator->blur_caustics, node, "blur_caustics");
|
||||
}
|
||||
|
||||
/* Camera */
|
||||
|
@ -154,7 +154,7 @@ void BlenderSync::sync_light(BL::Object b_parent, int b_index, BL::Object b_ob,
|
||||
|
||||
/* Object */
|
||||
|
||||
void BlenderSync::sync_object(BL::Object b_parent, int b_index, BL::Object b_ob, Transform& tfm, uint visibility)
|
||||
void BlenderSync::sync_object(BL::Object b_parent, int b_index, BL::Object b_ob, Transform& tfm, uint layer_flag)
|
||||
{
|
||||
/* light is handled separately */
|
||||
if(object_is_light(b_ob)) {
|
||||
@ -181,11 +181,19 @@ void BlenderSync::sync_object(BL::Object b_parent, int b_index, BL::Object b_ob,
|
||||
if(object_updated || (object->mesh && object->mesh->need_update)) {
|
||||
object->name = b_ob.name().c_str();
|
||||
object->tfm = tfm;
|
||||
|
||||
object->visibility = object_ray_visibility(b_ob) & visibility;
|
||||
|
||||
/* visibility flags for both parent */
|
||||
object->visibility = object_ray_visibility(b_ob) & PATH_RAY_ALL;
|
||||
if(b_parent.ptr.data != b_ob.ptr.data)
|
||||
object->visibility &= object_ray_visibility(b_parent);
|
||||
|
||||
/* camera flag is not actually used, instead is tested
|
||||
against render layer flags */
|
||||
if(object->visibility & PATH_RAY_CAMERA) {
|
||||
object->visibility |= layer_flag << PATH_RAY_LAYER_SHIFT;
|
||||
object->visibility &= ~PATH_RAY_CAMERA;
|
||||
}
|
||||
|
||||
object->tag_update(scene);
|
||||
}
|
||||
}
|
||||
@ -196,7 +204,6 @@ void BlenderSync::sync_objects(BL::SpaceView3D b_v3d)
|
||||
{
|
||||
/* layer data */
|
||||
uint scene_layer = render_layer.scene_layer;
|
||||
uint layer = render_layer.layer;
|
||||
|
||||
/* prepare for sync */
|
||||
light_map.pre_sync();
|
||||
@ -212,11 +219,6 @@ void BlenderSync::sync_objects(BL::SpaceView3D b_v3d)
|
||||
uint ob_layer = get_layer(b_ob->layers());
|
||||
|
||||
if(!hide && (ob_layer & scene_layer)) {
|
||||
uint visibility = PATH_RAY_ALL;
|
||||
|
||||
if(!(ob_layer & layer))
|
||||
visibility &= ~PATH_RAY_CAMERA;
|
||||
|
||||
if(b_ob->is_duplicator()) {
|
||||
/* dupli objects */
|
||||
object_create_duplilist(*b_ob, b_scene);
|
||||
@ -226,7 +228,7 @@ void BlenderSync::sync_objects(BL::SpaceView3D b_v3d)
|
||||
|
||||
for(b_ob->dupli_list.begin(b_dup); b_dup != b_ob->dupli_list.end(); ++b_dup) {
|
||||
Transform tfm = get_transform(b_dup->matrix());
|
||||
sync_object(*b_ob, b_index, b_dup->object(), tfm, visibility);
|
||||
sync_object(*b_ob, b_index, b_dup->object(), tfm, ob_layer);
|
||||
b_index++;
|
||||
}
|
||||
|
||||
@ -244,7 +246,7 @@ void BlenderSync::sync_objects(BL::SpaceView3D b_v3d)
|
||||
if(!hide) {
|
||||
/* object itself */
|
||||
Transform tfm = get_transform(b_ob->matrix_world());
|
||||
sync_object(*b_ob, 0, *b_ob, tfm, visibility);
|
||||
sync_object(*b_ob, 0, *b_ob, tfm, ob_layer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -122,9 +122,9 @@ bool BlenderSync::sync_recalc()
|
||||
|
||||
void BlenderSync::sync_data(BL::SpaceView3D b_v3d)
|
||||
{
|
||||
sync_render_layer(b_v3d);
|
||||
sync_integrator();
|
||||
sync_film();
|
||||
sync_render_layer(b_v3d);
|
||||
sync_shaders();
|
||||
sync_objects(b_v3d);
|
||||
}
|
||||
@ -152,9 +152,8 @@ void BlenderSync::sync_integrator()
|
||||
integrator->transparent_shadows = get_boolean(cscene, "use_transparent_shadows");
|
||||
|
||||
integrator->no_caustics = get_boolean(cscene, "no_caustics");
|
||||
integrator->blur_caustics = get_float(cscene, "blur_caustics");
|
||||
|
||||
integrator->seed = get_int(cscene, "seed");
|
||||
integrator->layer_flag = render_layer.layer;
|
||||
|
||||
if(integrator->modified(previntegrator))
|
||||
integrator->tag_update(scene);
|
||||
|
@ -78,7 +78,7 @@ private:
|
||||
|
||||
void sync_nodes(Shader *shader, BL::ShaderNodeTree b_ntree);
|
||||
Mesh *sync_mesh(BL::Object b_ob, bool object_updated);
|
||||
void sync_object(BL::Object b_parent, int b_index, BL::Object b_object, Transform& tfm, uint visibility);
|
||||
void sync_object(BL::Object b_parent, int b_index, BL::Object b_object, Transform& tfm, uint layer_flag);
|
||||
void sync_light(BL::Object b_parent, int b_index, BL::Object b_ob, Transform& tfm);
|
||||
|
||||
/* util */
|
||||
|
@ -130,13 +130,16 @@ __device_inline void path_state_next(KernelGlobals *kg, PathState *state, int la
|
||||
}
|
||||
}
|
||||
|
||||
__device_inline uint path_state_ray_visibility(PathState *state)
|
||||
__device_inline uint path_state_ray_visibility(KernelGlobals *kg, PathState *state)
|
||||
{
|
||||
uint flag = state->flag;
|
||||
|
||||
/* for visibility, diffuse/glossy are for reflection only */
|
||||
if(flag & PATH_RAY_TRANSMIT)
|
||||
flag &= ~(PATH_RAY_DIFFUSE|PATH_RAY_GLOSSY);
|
||||
/* for camera visibility, use render layer flags */
|
||||
if(flag & PATH_RAY_CAMERA)
|
||||
flag |= kernel_data.integrator.layer_flag;
|
||||
|
||||
return flag;
|
||||
}
|
||||
@ -249,7 +252,7 @@ __device float4 kernel_path_integrate(KernelGlobals *kg, RNG *rng, int sample, R
|
||||
for(;; rng_offset += PRNG_BOUNCE_NUM) {
|
||||
/* intersect scene */
|
||||
Intersection isect;
|
||||
uint visibility = path_state_ray_visibility(&state);
|
||||
uint visibility = path_state_ray_visibility(kg, &state);
|
||||
|
||||
if(!scene_intersect(kg, &ray, visibility, &isect)) {
|
||||
/* eval background shader if nothing hit */
|
||||
|
@ -100,7 +100,10 @@ enum PathTraceDimension {
|
||||
|
||||
/* these flag values correspond exactly to OSL defaults, so be careful not to
|
||||
* change this, or if you do, set the "raytypes" shading system attribute with
|
||||
* your own new ray types and bitflag values */
|
||||
* your own new ray types and bitflag values.
|
||||
*
|
||||
* for ray visibility tests in BVH traversal, the upper 20 bits are used for
|
||||
* layer visibility tests. */
|
||||
|
||||
enum PathRayFlag {
|
||||
PATH_RAY_CAMERA = 1,
|
||||
@ -117,7 +120,9 @@ enum PathRayFlag {
|
||||
|
||||
PATH_RAY_MIS_SKIP = 512,
|
||||
|
||||
PATH_RAY_ALL = (1|2|4|8|16|32|64|128|256|512)
|
||||
PATH_RAY_ALL = (1|2|4|8|16|32|64|128|256|512),
|
||||
|
||||
PATH_RAY_LAYER_SHIFT = (32-20)
|
||||
};
|
||||
|
||||
/* Closure Label */
|
||||
@ -383,10 +388,12 @@ typedef struct KernelIntegrator {
|
||||
|
||||
/* caustics */
|
||||
int no_caustics;
|
||||
float blur_caustics;
|
||||
|
||||
/* seed */
|
||||
int seed;
|
||||
|
||||
/* render layer */
|
||||
int layer_flag;
|
||||
} KernelIntegrator;
|
||||
|
||||
typedef struct KernelBVH {
|
||||
|
@ -41,9 +41,8 @@ Integrator::Integrator()
|
||||
transparent_shadows = false;
|
||||
|
||||
no_caustics = false;
|
||||
blur_caustics = 0.0f;
|
||||
|
||||
seed = 0;
|
||||
layer_flag = ~0;
|
||||
|
||||
need_update = true;
|
||||
}
|
||||
@ -81,9 +80,8 @@ void Integrator::device_update(Device *device, DeviceScene *dscene)
|
||||
kintegrator->transparent_shadows = transparent_shadows;
|
||||
|
||||
kintegrator->no_caustics = no_caustics;
|
||||
kintegrator->blur_caustics = blur_caustics;
|
||||
|
||||
kintegrator->seed = hash_int(seed);
|
||||
kintegrator->layer_flag = layer_flag << PATH_RAY_LAYER_SHIFT;
|
||||
|
||||
/* sobol directions table */
|
||||
int dimensions = PRNG_BASE_NUM + (max_bounce + transparent_max_bounce + 2)*PRNG_BOUNCE_NUM;
|
||||
@ -115,7 +113,7 @@ bool Integrator::modified(const Integrator& integrator)
|
||||
transparent_probalistic == integrator.transparent_probalistic &&
|
||||
transparent_shadows == integrator.transparent_shadows &&
|
||||
no_caustics == integrator.no_caustics &&
|
||||
blur_caustics == integrator.blur_caustics &&
|
||||
layer_flag == integrator.layer_flag &&
|
||||
seed == integrator.seed);
|
||||
}
|
||||
|
||||
|
@ -41,9 +41,9 @@ public:
|
||||
bool transparent_shadows;
|
||||
|
||||
bool no_caustics;
|
||||
float blur_caustics;
|
||||
|
||||
int seed;
|
||||
int layer_flag;
|
||||
|
||||
bool need_update;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user