From reading article about cryptomatte it seems like matte should be better from what I get here.
Any advice what can make result more accurate? Or is it a limit for this technique?
Doesn’t matter if I use Mix node or AplhaOver.
Thank you for help.
Color values of background and foreground are mixed (baked together) in edge areas and this can’t be fixed with simple matte based color correction, however accurate the matte is. Partially because matte has only partial effect in these areas. This is similar problem to despill in chroma keying where background color contaminates fg and must be treated with different methods.
Sorry for late reaction and thanks for your attention. Yes, I agrre, problem of a contamination, but in meanwhile I tried the same in Fusion that I felt in similar issue, but …
… in Fusion guy /Kristof) from WSL solved it by some node group (unMerge in screen) that I had no time to try understand what is the magic behind yet, it completely vanished the issue I had.
Can’t look into the group but it probably tries to deduce fg colors by extending core edges and from that creates a better representation of fg element. So it falls into the “treated with different methods” area.
For someone that will find it as usefull - here is the node for Fusion 9.
Hopefully readable for someone from text editor.
unMerge_1_1.setting (10.6 KB)
I would like to share some of my experiences here with the intention of knowing more tricks to circumvent this issue in Blender.
I got Boundary Artifacts while using Cryptomatte.
Rendering was done at 2560x1440 and layered the image using an Alpha Over node that takes the Matte output of the Cryptomatte node as a factor.
Even when working at high resolutions, the 1px Boundary Artifacts are still noticeable, and the more distant the object from the camera, the more vulnerable it appears.
How to use Cryptomatte correctly?
I’ve attached images and blend file to help you understand.
ⅰ) comparison of the original and processed images
ⅱ) Compositor node tree
ⅲ) processed image with 2560x1440 resolution (Click for larger screen please.)
ⅳ) blend file
Open the file and render it in F12 and you will immediately see the artifact. You can check the raw and processed images by turning on/off the Switch node in the raw/fx frame.
Cryptomatte Boundary Artifacts.blend (1.6 MB)
I watched the introduction to Cryptomatte from Blender Developer. And I saw connecting the Matte output of Cryptomatte to the factor of the Color FX Node instead of the Alpha Node.
I mocked this and created a new node tree.
However, Cryptomatte also seems to have limitations.
You tried to change the red petals to blue, but Cryptomatte doesn’t mask the petals completely, so you can see the red color remaining on the border of the leaves.
(Please click on the image to see the edges of the blue petals at larger size.)
I tried a technique to adjust the mask area using the Dilate / Erode or Bilateral Blur and Colorramp nodes, but there were limitations.
After testing up to this point, I think there’s an appropriate range for changing colors with Cryptomatte. If excessive color changes are required, re-rendering the 3D data seems to be the correct way to do it.
If matte has value of, lets say 0.5 for a pixel that is only half-covered witht the geometry you are interested in, any mask or color grade is applied only with half the strength AND these pixels have mixed colors from both your focus object and other stuff. So it is not a cryptomatte problem but general issue with mask based operations. It happens the exact same way with roto masks, keys etc.
i See. After all, it seems like the right way to re-render 3D data or use View Layers in the first place.
Perhaps, do you know of other ways to solve half-covered problems?
In comping the usual solution is to do edge extensions to recover the original colors as best as possible, apply your changes on separated elements and merge them back together as if doing a composite. For color corrections you might be able to get it easier one option isto simply extend the mask outwards and see if it gives a visually better result.
Is there a term that refers to a border area where two objects overlap each other back and forth and have half of their color mixed together?
I’ve been searching by edge alpha, boundary artifacts, spills, etc. but didn’t find satisfactory results.
I’m not aware of any specific word for that area in image itself, but for mattes this is called “fringe”, this is the semitransparent area between solid alpha and zero alpha. Nuke for example has a checkbox for all mask inputs to apply mask only for fringe area, usually it is for grading exactly this kind of problem areas separately.
You can construct fringe yourself easily by following simple math: alpha * (1-alpha) * 4. Reasoning is that alpha multiplied with inverted alpha produces zero for everything outside the fringe area and scaling with 4 is to normalize halftransparent areas to value 1.0 again (0.5*0.5=0.25, so multing with 4 gets back to 1.0)
Aren’t these pixels in Cryptomatte 002, 004, … channels?
Cryptomatte does not store masks in traditional sense, so there aren’t pixels in any of the channels. It stores id-coverage pairs as binary data dumped to image channels where specific id is given an alpha value for specific pixel. Ids with highest coverage are ranked and stored, number of stored ids per pixel depends on implementation.
And no, cryptomatte does not help separate fused colors from fg and bg, one must store separate unmerged elements/layers to get that.
I was clueless why even Cryptomatte could not always give me flawless edges from a single scene until I saw this incredible CG Cookie video: Working with Alpha Edges for Compositing in Blender. Kesonmis is right. It is not a matte issue; it is a background and foreground color mix issue, and the video shows a solid way around that. I suspect that the Fusion node setup that fixed your issues did the same kind of approach that is shown in the video. Blender’s compositing nodes like “Inpaint” node can do wonders. Render layers and collections are best, but using the Inpaint node compositing techniques shown in the video can do wonders for MANY situations where background and foreground are merged and you have to decontaminate color mix on edges; these techniques are complimented extremely well by Cryptomatte. Here’s a basic node setup example. Note that the ColorRamp nodes each have a black stop and a white stop, they’re just VERY close together but they don’t necessarily have to be if your edges look clean. I hope this makes your life easier like it did for me:
It would be amazing to have an automated way to render separate layers based upon the Cryptomatte (would probably only work at object level, not material level), or maybe get some kind of deep compositing method like this video shows: Skill Up With Nuke | An Introduction To Deep Compositing In 11.2.
Oh … THANKS a lot, that is something I can work with. Not such one click as Fusion seems to, but I give it a try.
Across BSE question I finally got to try your solution. I had to adjust Color Ramps, because your values prodused artefacts in shade.
It is still not as good as Fusion version, but I way better than default Thank you
Closed into Node Group to reuse …
test_Cryptomatte_Anim.blend (161.4 KB)
A few weeks ago I struggled with Cryptomatte. Then tried it later and had no issues. Seems you better use the image output instead of the matte output like in screenshot below. I suggest to try it.
That trick with inverse paint and using the matte output doesn’t give good result.
Do you have some example? When I try that, it is the same edge issue as with one cryptomatte. More of that I cant imagine to use this compositing in a scene with a lot of objects … separate all objects arround just for adjustment of one object. Sorry didnt work for me. If I missed something let me know. Thank you
Also with a high defocus the result is awesome (in this case).
Refined Edge (with InPaint node)