Is there a way to programmatically export a single materials "diffuse" and all "indirect light passes" into an alpha channel. The resulting alpha is all the locations in the image where the materials color exists?

In theory you would then be able to adjust this color in post with this alpha.

In the example i would then want only the green reflection + green cube as one image and only cyan in the other image (possible manually in this example, but imagine the same with hundreds of materials).

Example: enter image description here
Downlod example blender file

My problems:

  • Using material index pass isn't feasible as the reflections are not on the material.
  • Different render layers works, but requires a lot of manual work. Maybe programmatically (script)?

This existing answer is getting close to what i want, but doesn't address rendering for each material:
Cycles: Export each light into separate files

This is how to do it manually for one material: material index behind refractive material

  • $\begingroup$ Hello! Have you looked into cryptomatte passes ? $\endgroup$
    – Gorgious
    Jan 4, 2023 at 7:47
  • $\begingroup$ Doesn’t cryptomatte have the same problem as material index with not including indirect reflections? $\endgroup$ Jan 4, 2023 at 13:05
  • $\begingroup$ Oh yeah I guess so. I think you'll have to resort to view layers. It looks like it's doable with scripting but you'll have to add bit more information about your specific setup since there are a bunch of different ways to go about it $\endgroup$
    – Gorgious
    Jan 4, 2023 at 13:09
  • $\begingroup$ Don't have a specific setup in mind. Looking for any way to accomplish this. Only requirement would be cycles renderer. $\endgroup$ Jan 4, 2023 at 13:21
  • $\begingroup$ I don't think there is an other way than your second link (that I was able to think of too). On shader level you can work with Light Path node to affect specific parts ... to operation pass level it doesn't sound like a good option since you will change material reflection, indirects or what ever at the same time, but since these pixels are contaminated a result would looks weird. $\endgroup$
    – vklidu
    Jan 8, 2023 at 12:06


You must log in to answer this question.