Tweak cryptomatte channels naming to improve interoperability
Use lowercase rgba channel names which still by-passes lossy nature of DWA compression and which also keeps external compositing tools happy. Thanks Steffen Dünner for testing this patch! Differential Revision: https://developer.blender.org/D15834
This commit is contained in:
parent
cb771dbe76
commit
06005b0870
Notes:
blender-bot
2023-02-14 03:34:17 +01:00
Referenced by issue #100749, Blender LTS: Maintenance Task 3.3 Referenced by issue #96933, Cryptomatte layers saved incorrectly with EXR DWA compression
|
@ -682,16 +682,16 @@ void BlenderSync::sync_render_passes(BL::RenderLayer &b_rlay, BL::ViewLayer &b_v
|
|||
/* Cryptomatte stores two ID/weight pairs per RGBA layer.
|
||||
* User facing parameter is the number of pairs.
|
||||
*
|
||||
* NOTE: Name channels lowercase xyzw so that compression rules check in OpenEXR DWA code uses
|
||||
* loseless compression. It is important to use lowercase since the capital Y uses lossy
|
||||
* compression in DWA. */
|
||||
* NOTE: Name channels lowercase rgba so that compression rules check in OpenEXR DWA code uses
|
||||
* loseless compression. Reportedly this naming is the only one which works good from the
|
||||
* interoperability point of view. Using xyzw naming is not portable. */
|
||||
int crypto_depth = divide_up(min(16, b_view_layer.pass_cryptomatte_depth()), 2);
|
||||
scene->film->set_cryptomatte_depth(crypto_depth);
|
||||
CryptomatteType cryptomatte_passes = CRYPT_NONE;
|
||||
if (b_view_layer.use_pass_cryptomatte_object()) {
|
||||
for (int i = 0; i < crypto_depth; i++) {
|
||||
string passname = cryptomatte_prefix + string_printf("Object%02d", i);
|
||||
b_engine.add_pass(passname.c_str(), 4, "xyzw", b_view_layer.name().c_str());
|
||||
b_engine.add_pass(passname.c_str(), 4, "rgba", b_view_layer.name().c_str());
|
||||
pass_add(scene, PASS_CRYPTOMATTE, passname.c_str());
|
||||
}
|
||||
cryptomatte_passes = (CryptomatteType)(cryptomatte_passes | CRYPT_OBJECT);
|
||||
|
@ -699,7 +699,7 @@ void BlenderSync::sync_render_passes(BL::RenderLayer &b_rlay, BL::ViewLayer &b_v
|
|||
if (b_view_layer.use_pass_cryptomatte_material()) {
|
||||
for (int i = 0; i < crypto_depth; i++) {
|
||||
string passname = cryptomatte_prefix + string_printf("Material%02d", i);
|
||||
b_engine.add_pass(passname.c_str(), 4, "xyzw", b_view_layer.name().c_str());
|
||||
b_engine.add_pass(passname.c_str(), 4, "rgba", b_view_layer.name().c_str());
|
||||
pass_add(scene, PASS_CRYPTOMATTE, passname.c_str());
|
||||
}
|
||||
cryptomatte_passes = (CryptomatteType)(cryptomatte_passes | CRYPT_MATERIAL);
|
||||
|
@ -707,7 +707,7 @@ void BlenderSync::sync_render_passes(BL::RenderLayer &b_rlay, BL::ViewLayer &b_v
|
|||
if (b_view_layer.use_pass_cryptomatte_asset()) {
|
||||
for (int i = 0; i < crypto_depth; i++) {
|
||||
string passname = cryptomatte_prefix + string_printf("Asset%02d", i);
|
||||
b_engine.add_pass(passname.c_str(), 4, "xyzw", b_view_layer.name().c_str());
|
||||
b_engine.add_pass(passname.c_str(), 4, "rgba", b_view_layer.name().c_str());
|
||||
pass_add(scene, PASS_CRYPTOMATTE, passname.c_str());
|
||||
}
|
||||
cryptomatte_passes = (CryptomatteType)(cryptomatte_passes | CRYPT_ASSET);
|
||||
|
|
|
@ -421,9 +421,9 @@ void EEVEE_cryptomatte_output_accumulate(EEVEE_ViewLayerData *UNUSED(sldata), EE
|
|||
|
||||
void EEVEE_cryptomatte_update_passes(RenderEngine *engine, Scene *scene, ViewLayer *view_layer)
|
||||
{
|
||||
/* NOTE: Name channels lowercase xyzw so that compression rules check in OpenEXR DWA code uses
|
||||
* loseless compression. It is important to use lowercase since the capital Y uses lossy
|
||||
* compression in DWA. */
|
||||
/* NOTE: Name channels lowercase rgba so that compression rules check in OpenEXR DWA code uses
|
||||
* loseless compression. Reportedly this naming is the only one which works good from the
|
||||
* interoperability point of view. Using xyzw naming is not portable. */
|
||||
|
||||
char cryptomatte_pass_name[MAX_NAME];
|
||||
const short num_passes = eevee_cryptomatte_passes_per_layer(view_layer);
|
||||
|
@ -431,21 +431,21 @@ void EEVEE_cryptomatte_update_passes(RenderEngine *engine, Scene *scene, ViewLay
|
|||
for (short pass = 0; pass < num_passes; pass++) {
|
||||
BLI_snprintf_rlen(cryptomatte_pass_name, MAX_NAME, "CryptoObject%02d", pass);
|
||||
RE_engine_register_pass(
|
||||
engine, scene, view_layer, cryptomatte_pass_name, 4, "xyzw", SOCK_RGBA);
|
||||
engine, scene, view_layer, cryptomatte_pass_name, 4, "rgba", SOCK_RGBA);
|
||||
}
|
||||
}
|
||||
if ((view_layer->cryptomatte_flag & VIEW_LAYER_CRYPTOMATTE_MATERIAL) != 0) {
|
||||
for (short pass = 0; pass < num_passes; pass++) {
|
||||
BLI_snprintf_rlen(cryptomatte_pass_name, MAX_NAME, "CryptoMaterial%02d", pass);
|
||||
RE_engine_register_pass(
|
||||
engine, scene, view_layer, cryptomatte_pass_name, 4, "xyzw", SOCK_RGBA);
|
||||
engine, scene, view_layer, cryptomatte_pass_name, 4, "rgba", SOCK_RGBA);
|
||||
}
|
||||
}
|
||||
if ((view_layer->cryptomatte_flag & VIEW_LAYER_CRYPTOMATTE_ASSET) != 0) {
|
||||
for (short pass = 0; pass < num_passes; pass++) {
|
||||
BLI_snprintf_rlen(cryptomatte_pass_name, MAX_NAME, "CryptoAsset%02d", pass);
|
||||
RE_engine_register_pass(
|
||||
engine, scene, view_layer, cryptomatte_pass_name, 4, "xyzw", SOCK_RGBA);
|
||||
engine, scene, view_layer, cryptomatte_pass_name, 4, "rgba", SOCK_RGBA);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue