Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/render/film.cpp
| Show All 32 Lines | |||||
| static bool compare_pass_order(const Pass &a, const Pass &b) | static bool compare_pass_order(const Pass &a, const Pass &b) | ||||
| { | { | ||||
| if (a.components == b.components) | if (a.components == b.components) | ||||
| return (a.type < b.type); | return (a.type < b.type); | ||||
| return (a.components > b.components); | return (a.components > b.components); | ||||
| } | } | ||||
| NODE_DEFINE(Pass) | |||||
| { | |||||
| NodeType *type = NodeType::add("pass", create); | |||||
| static NodeEnum pass_type_enum; | |||||
| pass_type_enum.insert("combined", PASS_COMBINED); | |||||
| pass_type_enum.insert("depth", PASS_DEPTH); | |||||
| pass_type_enum.insert("normal", PASS_NORMAL); | |||||
| pass_type_enum.insert("uv", PASS_UV); | |||||
| pass_type_enum.insert("object_id", PASS_OBJECT_ID); | |||||
| pass_type_enum.insert("material_id", PASS_MATERIAL_ID); | |||||
| pass_type_enum.insert("motion", PASS_MOTION); | |||||
| pass_type_enum.insert("motion_weight", PASS_MOTION_WEIGHT); | |||||
| #ifdef __KERNEL_DEBUG__ | |||||
| pass_type_enum.insert("traversed_nodes", PASS_BVH_TRAVERSED_NODES); | |||||
| pass_type_enum.insert("traverse_instances", PASS_BVH_TRAVERSED_INSTANCES); | |||||
| pass_type_enum.insert("bvh_intersections", PASS_BVH_INTERSECTIONS); | |||||
| pass_type_enum.insert("ray_bounces", PASS_RAY_BOUNCES); | |||||
| #endif | |||||
| pass_type_enum.insert("render_time", PASS_RENDER_TIME); | |||||
| pass_type_enum.insert("cryptomatte", PASS_CRYPTOMATTE); | |||||
| pass_type_enum.insert("aov_color", PASS_AOV_COLOR); | |||||
| pass_type_enum.insert("aov_value", PASS_AOV_VALUE); | |||||
| pass_type_enum.insert("adaptive_aux_buffer", PASS_ADAPTIVE_AUX_BUFFER); | |||||
| pass_type_enum.insert("sample_count", PASS_SAMPLE_COUNT); | |||||
| pass_type_enum.insert("mist", PASS_MIST); | |||||
| pass_type_enum.insert("emission", PASS_EMISSION); | |||||
| pass_type_enum.insert("background", PASS_BACKGROUND); | |||||
| pass_type_enum.insert("ambient_occlusion", PASS_AO); | |||||
| pass_type_enum.insert("shadow", PASS_SHADOW); | |||||
| pass_type_enum.insert("diffuse_direct", PASS_DIFFUSE_DIRECT); | |||||
| pass_type_enum.insert("diffuse_indirect", PASS_DIFFUSE_INDIRECT); | |||||
| pass_type_enum.insert("diffuse_color", PASS_DIFFUSE_COLOR); | |||||
| pass_type_enum.insert("glossy_direct", PASS_GLOSSY_DIRECT); | |||||
| pass_type_enum.insert("glossy_indirect", PASS_GLOSSY_INDIRECT); | |||||
| pass_type_enum.insert("glossy_color", PASS_GLOSSY_COLOR); | |||||
| pass_type_enum.insert("transmission_direct", PASS_TRANSMISSION_DIRECT); | |||||
| pass_type_enum.insert("transmission_indirect", PASS_TRANSMISSION_INDIRECT); | |||||
| pass_type_enum.insert("transmission_color", PASS_TRANSMISSION_COLOR); | |||||
| pass_type_enum.insert("volume_direct", PASS_VOLUME_DIRECT); | |||||
| pass_type_enum.insert("volume_indirect", PASS_VOLUME_INDIRECT); | |||||
| pass_type_enum.insert("bake_primitive", PASS_BAKE_PRIMITIVE); | |||||
| pass_type_enum.insert("bake_differential", PASS_BAKE_DIFFERENTIAL); | |||||
| SOCKET_ENUM(type, "Type", pass_type_enum, PASS_COMBINED); | |||||
| SOCKET_STRING(name, "Name", ustring()); | |||||
| return type; | |||||
| } | |||||
| Pass::Pass() : Node(node_type) | |||||
| { | |||||
| } | |||||
| void Pass::add(PassType type, vector<Pass> &passes, const char *name) | void Pass::add(PassType type, vector<Pass> &passes, const char *name) | ||||
| { | { | ||||
| for (size_t i = 0; i < passes.size(); i++) { | for (size_t i = 0; i < passes.size(); i++) { | ||||
| if (passes[i].type != type) { | if (passes[i].type != type) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| /* An empty name is used as a placeholder to signal that any pass of | /* An empty name is used as a placeholder to signal that any pass of | ||||
| ▲ Show 20 Lines • Show All 276 Lines • ▼ Show 20 Lines | NODE_DEFINE(Film) | ||||
| SOCKET_INT(denoising_flags, "Denoising Flags", 0); | SOCKET_INT(denoising_flags, "Denoising Flags", 0); | ||||
| SOCKET_BOOLEAN(use_adaptive_sampling, "Use Adaptive Sampling", false); | SOCKET_BOOLEAN(use_adaptive_sampling, "Use Adaptive Sampling", false); | ||||
| return type; | return type; | ||||
| } | } | ||||
| Film::Film() : Node(node_type) | Film::Film() : Node(node_type) | ||||
| { | { | ||||
| Pass::add(PASS_COMBINED, passes); | |||||
| use_light_visibility = false; | use_light_visibility = false; | ||||
| filter_table_offset = TABLE_OFFSET_INVALID; | filter_table_offset = TABLE_OFFSET_INVALID; | ||||
| cryptomatte_passes = CRYPT_NONE; | cryptomatte_passes = CRYPT_NONE; | ||||
| display_pass = PASS_COMBINED; | display_pass = PASS_COMBINED; | ||||
| need_update = true; | need_update = true; | ||||
| } | } | ||||
| Film::~Film() | Film::~Film() | ||||
| { | { | ||||
| } | } | ||||
| void Film::add_default(Scene *scene) | |||||
| { | |||||
| Pass::add(PASS_COMBINED, scene->passes); | |||||
| } | |||||
| void Film::device_update(Device *device, DeviceScene *dscene, Scene *scene) | void Film::device_update(Device *device, DeviceScene *dscene, Scene *scene) | ||||
| { | { | ||||
| if (!need_update) | if (!need_update) | ||||
| return; | return; | ||||
| device_free(device, dscene, scene); | device_free(device, dscene, scene); | ||||
| KernelFilm *kfilm = &dscene->data.film; | KernelFilm *kfilm = &dscene->data.film; | ||||
| Show All 11 Lines | void Film::device_update(Device *device, DeviceScene *dscene, Scene *scene) | ||||
| kfilm->light_pass_flag = 0; | kfilm->light_pass_flag = 0; | ||||
| kfilm->pass_stride = 0; | kfilm->pass_stride = 0; | ||||
| kfilm->use_light_pass = use_light_visibility; | kfilm->use_light_pass = use_light_visibility; | ||||
| kfilm->pass_aov_value_num = 0; | kfilm->pass_aov_value_num = 0; | ||||
| kfilm->pass_aov_color_num = 0; | kfilm->pass_aov_color_num = 0; | ||||
| bool have_cryptomatte = false; | bool have_cryptomatte = false; | ||||
| for (size_t i = 0; i < passes.size(); i++) { | for (size_t i = 0; i < scene->passes.size(); i++) { | ||||
| Pass &pass = passes[i]; | Pass &pass = scene->passes[i]; | ||||
| if (pass.type == PASS_NONE) { | if (pass.type == PASS_NONE) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| /* Can't do motion pass if no motion vectors are available. */ | /* Can't do motion pass if no motion vectors are available. */ | ||||
| if (pass.type == PASS_MOTION || pass.type == PASS_MOTION_WEIGHT) { | if (pass.type == PASS_MOTION || pass.type == PASS_MOTION_WEIGHT) { | ||||
| if (scene->need_motion() != Scene::MOTION_PASS) { | if (scene->need_motion() != Scene::MOTION_PASS) { | ||||
| ▲ Show 20 Lines • Show All 212 Lines • ▼ Show 20 Lines | |||||
| void Film::device_free(Device * /*device*/, DeviceScene * /*dscene*/, Scene *scene) | void Film::device_free(Device * /*device*/, DeviceScene * /*dscene*/, Scene *scene) | ||||
| { | { | ||||
| scene->lookup_tables->remove_table(&filter_table_offset); | scene->lookup_tables->remove_table(&filter_table_offset); | ||||
| } | } | ||||
| bool Film::modified(const Film &film) | bool Film::modified(const Film &film) | ||||
| { | { | ||||
| return !Node::equals(film) || !Pass::equals(passes, film.passes); | return !Node::equals(film); | ||||
| } | } | ||||
| void Film::tag_passes_update(Scene *scene, const vector<Pass> &passes_, bool update_passes) | void Film::tag_passes_update(Scene *scene, const vector<Pass> &passes_, bool update_passes) | ||||
| { | { | ||||
| if (Pass::contains(passes, PASS_UV) != Pass::contains(passes_, PASS_UV)) { | if (Pass::contains(scene->passes, PASS_UV) != Pass::contains(passes_, PASS_UV)) { | ||||
| scene->geometry_manager->tag_update(scene); | scene->geometry_manager->tag_update(scene); | ||||
| foreach (Shader *shader, scene->shaders) | foreach (Shader *shader, scene->shaders) | ||||
| shader->need_update_geometry = true; | shader->need_update_geometry = true; | ||||
| } | } | ||||
| else if (Pass::contains(passes, PASS_MOTION) != Pass::contains(passes_, PASS_MOTION)) { | else if (Pass::contains(scene->passes, PASS_MOTION) != Pass::contains(passes_, PASS_MOTION)) { | ||||
| scene->geometry_manager->tag_update(scene); | scene->geometry_manager->tag_update(scene); | ||||
| } | } | ||||
| else if (Pass::contains(passes, PASS_AO) != Pass::contains(passes_, PASS_AO)) { | else if (Pass::contains(scene->passes, PASS_AO) != Pass::contains(passes_, PASS_AO)) { | ||||
| scene->integrator->tag_update(scene); | scene->integrator->tag_update(scene); | ||||
| } | } | ||||
| if (update_passes) { | if (update_passes) { | ||||
| passes = passes_; | scene->passes = passes_; | ||||
| } | } | ||||
| } | } | ||||
| void Film::tag_update(Scene * /*scene*/) | void Film::tag_update(Scene * /*scene*/) | ||||
| { | { | ||||
| need_update = true; | need_update = true; | ||||
| } | } | ||||
| int Film::get_aov_offset(string name, bool &is_color) | int Film::get_aov_offset(Scene *scene, string name, bool &is_color) | ||||
| { | { | ||||
| int num_color = 0, num_value = 0; | int num_color = 0, num_value = 0; | ||||
| foreach (const Pass &pass, passes) { | foreach (const Pass &pass, scene->passes) { | ||||
| if (pass.type == PASS_AOV_COLOR) { | if (pass.type == PASS_AOV_COLOR) { | ||||
| num_color++; | num_color++; | ||||
| } | } | ||||
| else if (pass.type == PASS_AOV_VALUE) { | else if (pass.type == PASS_AOV_VALUE) { | ||||
| num_value++; | num_value++; | ||||
| } | } | ||||
| else { | else { | ||||
| continue; | continue; | ||||
| Show All 12 Lines | |||||