diff options
author | Sergey Sharybin <sergey@blender.org> | 2022-08-31 17:10:51 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey@blender.org> | 2022-09-01 11:37:39 +0300 |
commit | df751516e1f64bbc78b02582c631c3cdd0bc032d (patch) | |
tree | 579fad335bb991b8433069d16b6ec5b56d731ff4 /intern | |
parent | 17501c146edc4af8a5e04565dc4d0b30ed5c5323 (diff) |
Fix cryptomatte passes saved lossy into multilayer EXR
The DWA compression code in OpenEXR has hardcoded rules which decides
which channels are lossy or lossless. There is no control over these
rules via API.
This change makes it so channel names of xyzw is used for cryptomatte
passes in Cycles. This works around the hardcoded rules in the DWA code
making it so lossless compression is used. It is important to use lower
case y channel name as the upper case Y uses lossy compression.
The change in the channel naming also makes it so the write code uses
32bit for the cryptomatte even when saving half-float EXR.
Fixes T96933: Cryptomatte layers saved incorrectly with EXR DWA compression
Fixes T88049: Cryptomatte EXR Output Bit Depth should always be 32bit
Differential Revision: https://developer.blender.org/D15823
Diffstat (limited to 'intern')
-rw-r--r-- | intern/cycles/blender/sync.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/intern/cycles/blender/sync.cpp b/intern/cycles/blender/sync.cpp index bf8c4bc6203..9bd0abe2773 100644 --- a/intern/cycles/blender/sync.cpp +++ b/intern/cycles/blender/sync.cpp @@ -680,14 +680,18 @@ 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. */ + * 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. */ 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, "RGBA", b_view_layer.name().c_str()); + b_engine.add_pass(passname.c_str(), 4, "xyzw", b_view_layer.name().c_str()); pass_add(scene, PASS_CRYPTOMATTE, passname.c_str()); } cryptomatte_passes = (CryptomatteType)(cryptomatte_passes | CRYPT_OBJECT); @@ -695,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, "RGBA", b_view_layer.name().c_str()); + b_engine.add_pass(passname.c_str(), 4, "xyzw", b_view_layer.name().c_str()); pass_add(scene, PASS_CRYPTOMATTE, passname.c_str()); } cryptomatte_passes = (CryptomatteType)(cryptomatte_passes | CRYPT_MATERIAL); @@ -703,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, "RGBA", b_view_layer.name().c_str()); + b_engine.add_pass(passname.c_str(), 4, "xyzw", b_view_layer.name().c_str()); pass_add(scene, PASS_CRYPTOMATTE, passname.c_str()); } cryptomatte_passes = (CryptomatteType)(cryptomatte_passes | CRYPT_ASSET); |