Cryptomatte Metadata Missing in 2.8

In Blender 2.8 we don’t get any Cryptomatte Metadata in the EXR File. Because of this you cannot use the cryptomatte passes in an external compositing software like Nuke.

Blender 2.79 doesn’t have the problem.

Is there a way to get the metadata also in 2.8?

3 Likes

Side note: The 2.79 version we use - mentioned in the post here - has build hash 763b5c87617 (2.79.6).

Fixed now:
https://developer.blender.org/rB1bbe770

4 Likes

Wow, thanks for the super quick fix!

It is working now, but there would be one more thing to make it perfect…

Right now the naming of the cryptomatte layers in the metadata is “xxxxx.CryptoObject”.
The cryptomatte image layer in the EXR is “xxxx_CryptoObject”. For the Cryptomatte Plugin in Nuke, the naming of both the metadata and the layer, has to be the same.
So to make the plugin work correctly, one has to change the metadata inside of Nuke.

Would it be possible to change the format of the naming in the metadata to “xxxx_CryptoObject”?

This would be relevant for both 2.79 and 2.8

thanks in advance,
Joe

@brecht We internally tested this by simply replacing the '.' with an underscore '_' in the source code. For Nuke, this works just fine and is exactly what we need. We cannot tell however if by doing that we break other stuff (like Blenders own compositor). Do you see a risk in making that change?

Changed code (lines 416 - 428) in blender_session.cpp:

	/* Write cryptomatte metadata. */
if(scene->film->cryptomatte_passes & CRYPT_OBJECT) {
	add_cryptomatte_layer(b_rr, view_layer_name + "_CryptoObject",
						  scene->object_manager->get_cryptomatte_objects(scene));
}
if(scene->film->cryptomatte_passes & CRYPT_MATERIAL) {
	add_cryptomatte_layer(b_rr, view_layer_name + "_CryptoMaterial",
						  scene->shader_manager->get_cryptomatte_materials(scene));
}
if(scene->film->cryptomatte_passes & CRYPT_ASSET) {
	add_cryptomatte_layer(b_rr, view_layer_name + "_CryptoAsset",
						  scene->object_manager->get_cryptomatte_assets(scene));
}

The EXR layers have a . in then, they are consistent and following the OpenEXR specification.

Unfortunately Nuke and a lot of other software does not follow the specification, and renames the layers when loading. Some day we might follow and use the more common convention over the original specification, but this is not something we can change easily.

This could be considered to be a bug on the Nuke side, if it’s going to rename the EXR layers it should take that into account for the metadata as well.

Hello, as discussed in https://blenderartists.org/t/cryptomatte-is-here-amazing/1132013/63
the cryptomattes rendered in Blender Cycles aren’t working in external compositing softwares like After Effects, Nuke and Fusion. Why can’t Blender follow the Cryptomatte specification from Psyop? The sample files from Psyops githup page work fine and have the correct medadata. Please make it work, maybe Lukas Stockner can help? I will also make a bugreport, but it is hard for you Blender developers to reproduce, if you have no copy of After Effects, Nuke and Fusion. But if you follow the Psyop specification it should work!

I can confirm when using ProEXR Cryptomatte in after effects the cryptomatte manifest is empty.

@brecht if all is needed to make it work inside an external compositing software is to change those (".") dots for ("_") underscores, we may have an option in the cryptomatte settings like “External Compositing” that changes this.

This will help users to be able to use Cryptomatte in external compositing software, something that is pretty common.

What do you think?

Feel free to contribute a patch that makes using underscores instead of dots possible. You’d also need to change the layer and pass names since those are what the Cryptomatte metadata needs to match.

Ok, maybe this is at my level of knowledge :slight_smile:

Cheers!

Would someone mind telling me how to incorporate the fix? I just see lots of a code and don’t know how to use it!

Athing regarding this, the layer names / pass names may not need to be changed, because I think other packages lets you pick what layers to apply to cryptomatte like in Blender, so maybe just the underscore option could be enough.

@RainerTrummer have you found the need to change the layer names / pass names or you just needed the underscore option?

If you know how to build blender you have the change what is marked in the upper post in the blender_session.cpp file, but if you don’t know how to build Blender and don’t know a bit of programming you may have trouble trying to do this.

For us the underscore changes we did in the post above were sufficient as far as I recall. But this is due to the fact that Nuke, as Brecht pointed out, changes the pass names on import automatically, and the metadata names then don’t match any longer. For a clean fix, I suspect both should be changed, otherwise this might become a Nuke only fix.

I’ve started working on a patch for this, but am facing some (what I thought trivial) issue: The View Layer could contain characters that are not allowed by external applications like Nuke. In fact, spaces are also converted on import to underscores for the metadata. An obvious fix for this would be to swap out spaces with underscores for the metadata, but that could yield unwanted results: What if a user had a view layer called “View Layer” and at the same time a view layer called “View_Layer” in the scene? Just blindly swapping characters could generate larger turmoil in the long run here.

Needless to say, this problem only affects Nuke (and maybe AfterEffects via ProEXR, I don’t have that so can not test). Fusion reads the EXRs Blender produces today just fine, how to get to the metadata there is beyond me, but I don’t see that this would be necessary either in Fusion.

Regardless of the issue above, does Blender already have a C++ function somewhere in the source code to replace characters in a string by passing a list of invalid characters to it? One that I could re-use in the code?

You’re doing gods work! Would you mind explaining how to change the metadata in Nuke? I used an editMetadata node or whatever it’s called but my technical knowledge isn’t great and blindly changing dots to underscores didn’t do the job for me! What did you do to get it working?

Nothing generic that I know of. Invalid characters very much depends on the specific file format or conventions.

Basically you change the name in the Cryptomatte Metadata that it matches the Layer Name in Nuke.

Lets say the layer name is “RenderLayer_CryptoMaterial00”.
The Metadata name is “RenderLayer.CryptoMaterial”

So you lookup the Metadata in the readnode of the file to see what value of the Metadata you have to change. (Eg.: “exr/cryptomatte/131765d/name”)

Then you create a “ModifyMetaData” Node, use as action “set” choose the right key (“exr/cryptomatte/131765d/name”) and set as value “RenderLayer_CryptoMaterial”.

I thought that was the case. That’s what I did originally. I’ve just tried it again following everything in your screenshot and it’s still not working. I can see the crypto channels with the yellow and green colours but the crpytomatte node doesn’t detect any layers. Any ideas?