Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/render/coverage.cpp
| Show First 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | |||||
| void Coverage::init_path_trace() | void Coverage::init_path_trace() | ||||
| { | { | ||||
| kg->coverage_object = kg->coverage_material = kg->coverage_asset = NULL; | kg->coverage_object = kg->coverage_material = kg->coverage_asset = NULL; | ||||
| if (kernel_data.film.cryptomatte_passes & CRYPT_ACCURATE) { | if (kernel_data.film.cryptomatte_passes & CRYPT_ACCURATE) { | ||||
| if (kernel_data.film.cryptomatte_passes & CRYPT_OBJECT) { | if (kernel_data.film.cryptomatte_passes & CRYPT_OBJECT) { | ||||
| coverage_object.clear(); | coverage_object.clear(); | ||||
| coverage_object.resize(tile.w * tile.h); | coverage_object.resize(tile.get_w() * tile.get_h()); | ||||
| } | } | ||||
| if (kernel_data.film.cryptomatte_passes & CRYPT_MATERIAL) { | if (kernel_data.film.cryptomatte_passes & CRYPT_MATERIAL) { | ||||
| coverage_material.clear(); | coverage_material.clear(); | ||||
| coverage_material.resize(tile.w * tile.h); | coverage_material.resize(tile.get_w() * tile.get_h()); | ||||
| } | } | ||||
| if (kernel_data.film.cryptomatte_passes & CRYPT_ASSET) { | if (kernel_data.film.cryptomatte_passes & CRYPT_ASSET) { | ||||
| coverage_asset.clear(); | coverage_asset.clear(); | ||||
| coverage_asset.resize(tile.w * tile.h); | coverage_asset.resize(tile.get_w() * tile.get_h()); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| void Coverage::init_pixel(int x, int y) | void Coverage::init_pixel(int x, int y) | ||||
| { | { | ||||
| if (kernel_data.film.cryptomatte_passes & CRYPT_ACCURATE) { | if (kernel_data.film.cryptomatte_passes & CRYPT_ACCURATE) { | ||||
| const int pixel_index = tile.w * (y - tile.y) + x - tile.x; | const int pixel_index = tile.get_w() * (y - tile.get_y()) + x - tile.get_x(); | ||||
| if (kernel_data.film.cryptomatte_passes & CRYPT_OBJECT) { | if (kernel_data.film.cryptomatte_passes & CRYPT_OBJECT) { | ||||
| kg->coverage_object = &coverage_object[pixel_index]; | kg->coverage_object = &coverage_object[pixel_index]; | ||||
| } | } | ||||
| if (kernel_data.film.cryptomatte_passes & CRYPT_MATERIAL) { | if (kernel_data.film.cryptomatte_passes & CRYPT_MATERIAL) { | ||||
| kg->coverage_material = &coverage_material[pixel_index]; | kg->coverage_material = &coverage_material[pixel_index]; | ||||
| } | } | ||||
| if (kernel_data.film.cryptomatte_passes & CRYPT_ASSET) { | if (kernel_data.film.cryptomatte_passes & CRYPT_ASSET) { | ||||
| kg->coverage_asset = &coverage_asset[pixel_index]; | kg->coverage_asset = &coverage_asset[pixel_index]; | ||||
| Show All 10 Lines | else { | ||||
| sort_buffer(pass_offset); | sort_buffer(pass_offset); | ||||
| } | } | ||||
| } | } | ||||
| void Coverage::flatten_buffer(vector<CoverageMap> &coverage, const int pass_offset) | void Coverage::flatten_buffer(vector<CoverageMap> &coverage, const int pass_offset) | ||||
| { | { | ||||
| /* Sort the coverage map and write it to the output */ | /* Sort the coverage map and write it to the output */ | ||||
| int pixel_index = 0; | int pixel_index = 0; | ||||
| int pass_stride = tile.buffers->params.get_passes_size(); | int pass_stride = tile.get_buffers()->get_params().get_passes_size(); | ||||
| for (int y = 0; y < tile.h; ++y) { | for (int y = 0; y < tile.get_h(); ++y) { | ||||
| for (int x = 0; x < tile.w; ++x) { | for (int x = 0; x < tile.get_w(); ++x) { | ||||
| const CoverageMap &pixel = coverage[pixel_index]; | const CoverageMap &pixel = coverage[pixel_index]; | ||||
| if (!pixel.empty()) { | if (!pixel.empty()) { | ||||
| /* buffer offset */ | /* buffer offset */ | ||||
| int index = x + y * tile.stride; | int index = x + y * tile.get_stride(); | ||||
| float *buffer = (float *)tile.buffer + index * pass_stride; | float *buffer = (float *)tile.get_buffer() + index * pass_stride; | ||||
| /* sort the cryptomatte pixel */ | /* sort the cryptomatte pixel */ | ||||
| vector<pair<float, float>> sorted_pixel; | vector<pair<float, float>> sorted_pixel; | ||||
| for (CoverageMap::const_iterator it = pixel.begin(); it != pixel.end(); ++it) { | for (CoverageMap::const_iterator it = pixel.begin(); it != pixel.end(); ++it) { | ||||
| sorted_pixel.push_back(std::make_pair(it->second, it->first)); | sorted_pixel.push_back(std::make_pair(it->second, it->first)); | ||||
| } | } | ||||
| sort(sorted_pixel.begin(), sorted_pixel.end(), crypomatte_comp); | sort(sorted_pixel.begin(), sorted_pixel.end(), crypomatte_comp); | ||||
| int num_slots = 2 * (kernel_data.film.cryptomatte_depth); | int num_slots = 2 * (kernel_data.film.cryptomatte_depth); | ||||
| Show All 17 Lines | for (int x = 0; x < tile.get_w(); ++x) { | ||||
| ++pixel_index; | ++pixel_index; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| void Coverage::sort_buffer(const int pass_offset) | void Coverage::sort_buffer(const int pass_offset) | ||||
| { | { | ||||
| /* Sort the coverage map and write it to the output */ | /* Sort the coverage map and write it to the output */ | ||||
| int pass_stride = tile.buffers->params.get_passes_size(); | int pass_stride = tile.get_buffers()->get_params().get_passes_size(); | ||||
| for (int y = 0; y < tile.h; ++y) { | for (int y = 0; y < tile.get_h(); ++y) { | ||||
| for (int x = 0; x < tile.w; ++x) { | for (int x = 0; x < tile.get_w(); ++x) { | ||||
| /* buffer offset */ | /* buffer offset */ | ||||
| int index = x + y * tile.stride; | int index = x + y * tile.get_stride(); | ||||
| float *buffer = (float *)tile.buffer + index * pass_stride; | float *buffer = (float *)tile.get_buffer() + index * pass_stride; | ||||
| kernel_sort_id_slots(buffer + kernel_data.film.pass_cryptomatte + pass_offset, | kernel_sort_id_slots(buffer + kernel_data.film.pass_cryptomatte + pass_offset, | ||||
| 2 * (kernel_data.film.cryptomatte_depth)); | 2 * (kernel_data.film.cryptomatte_depth)); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| CCL_NAMESPACE_END | CCL_NAMESPACE_END | ||||