31 static bool crypomatte_comp(
const pair<float, float> &i,
const pair<float, float> j)
33 return i.first > j.first;
40 finalize_buffer(coverage_object, pass_offset);
41 pass_offset +=
kernel_data.film.cryptomatte_depth * 4;
44 finalize_buffer(coverage_material, pass_offset);
45 pass_offset +=
kernel_data.film.cryptomatte_depth * 4;
48 finalize_buffer(coverage_asset, pass_offset);
54 kg->coverage_object = kg->coverage_material = kg->coverage_asset =
NULL;
58 coverage_object.clear();
59 coverage_object.resize(tile.
w * tile.
h);
62 coverage_material.clear();
63 coverage_material.resize(tile.
w * tile.
h);
66 coverage_asset.clear();
67 coverage_asset.resize(tile.
w * tile.
h);
75 const int pixel_index = tile.
w * (
y - tile.
y) +
x - tile.
x;
77 kg->coverage_object = &coverage_object[pixel_index];
80 kg->coverage_material = &coverage_material[pixel_index];
83 kg->coverage_asset = &coverage_asset[pixel_index];
91 flatten_buffer(coverage, pass_offset);
94 sort_buffer(pass_offset);
103 for (
int y = 0;
y < tile.
h; ++
y) {
104 for (
int x = 0;
x < tile.
w; ++
x) {
106 if (!pixel.empty()) {
109 float *
buffer = (
float *)tile.
buffer + index * pass_stride;
112 vector<pair<float, float>> sorted_pixel;
113 for (CoverageMap::const_iterator it = pixel.begin(); it != pixel.end(); ++it) {
114 sorted_pixel.push_back(std::make_pair(it->second, it->first));
117 int num_slots = 2 * (
kernel_data.film.cryptomatte_depth);
118 if (sorted_pixel.size() > num_slots) {
119 float leftover = 0.0f;
120 for (
vector<pair<float, float>>::iterator it = sorted_pixel.begin() + num_slots;
121 it != sorted_pixel.end();
123 leftover += it->first;
125 sorted_pixel[num_slots - 1].first += leftover;
127 int limit =
min(num_slots, sorted_pixel.size());
128 for (
int i = 0; i < limit; ++i) {
131 sorted_pixel[i].second,
132 sorted_pixel[i].first);
140 void Coverage::sort_buffer(
const int pass_offset)
144 for (
int y = 0;
y < tile.
h; ++
y) {
145 for (
int x = 0;
x < tile.
w; ++
x) {
148 float *
buffer = (
float *)tile.
buffer + index * pass_stride;
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
void sort(btMatrix3x3 &U, btVector3 &sigma, btMatrix3x3 &V, int t)
Helper function of 3X3 SVD for sorting singular values.
void init_pixel(int x, int y)
static CCL_NAMESPACE_BEGIN bool crypomatte_comp(const pair< float, float > &i, const pair< float, float > j)
unordered_map< float, float > CoverageMap
#define CCL_NAMESPACE_END
ccl_device_inline void kernel_sort_id_slots(ccl_global float *buffer, int num_slots)
CCL_NAMESPACE_BEGIN ccl_device_inline void kernel_write_id_slots(ccl_global float *buffer, int num_slots, float id, float weight)
__kernel void ccl_constant KernelData ccl_global void ccl_global char ccl_global int ccl_global char ccl_global unsigned int ccl_global float * buffer