Chaos Corona Forum

Chaos Corona for Cinema 4D => [C4D] I need help! => Topic started by: TeoRossi93 on 2024-04-16, 17:00:43

Title: Multishader multipass masks?
Post by: TeoRossi93 on 2024-04-16, 17:00:43
Hey guys, is it possible to have a black/white mask for different colors in multishader material?
Like, I need a mask for the diamonds attached here, and a separate one for the emeralds.
Title: Re: Multishader multipass masks?
Post by: Beanzvision on 2024-04-17, 16:08:32
Hi, would create 2 materials and give them each a material ID from the Advanced settings in the material. Scatter 2 objects and assign each a different mat. In the multipass settings, make 2 masks and enable Material ID and give them the same number as the materials. Render and you will have a different alpha for each. Here's an example.

(https://forum.corona-renderer.com/index.php?action=dlattach;topic=42480.0;attach=197602;image)
Title: Re: Multishader multipass masks?
Post by: TeoRossi93 on 2024-04-18, 10:55:44
Hi, would create 2 materials and give them each a material ID from the Advanced settings in the material. Scatter 2 objects and assign each a different mat. In the multipass settings, make 2 masks and enable Material ID and give them the same number as the materials. Render and you will have a different alpha for each. Here's an example.

(https://forum.corona-renderer.com/index.php?action=dlattach;topic=42480.0;attach=197602;image)

Hi Bengamin,

thanks for the answer but unlickily this is not gonna work with my current animation setup.
I'm attaching my scene here so you could have a look at it. I can't change the rig at the moment, the only chance I have is to make the multishader masks work properly.
Title: Re: Multishader multipass masks?
Post by: Beanzvision on 2024-04-19, 15:19:07
Hi there, this should work. Here's another sample scene. I have my objects in the cloner, each object has a comp tag with it's own object ID, a material using the mutli-shader (set to object ID) and then two masks in the multipass settings. Each mask also has Object ID enabled. If this works for you, maybe this can be applied to your scene as well?
Title: Re: Multishader multipass masks?
Post by: Stefan-L on 2024-04-22, 11:25:07
a multi material woudl be really great. similar tot he multi shader, or layered material. where one can add materials and use them similar as the multishader (assignment by different random or cpntroled menthods)
Title: Re: Multishader multipass masks?
Post by: TeoRossi93 on 2024-04-23, 10:02:52
Hi there, this should work. Here's another sample scene. I have my objects in the cloner, each object has a comp tag with it's own object ID, a material using the mutli-shader (set to object ID) and then two masks in the multipass settings. Each mask also has Object ID enabled. If this works for you, maybe this can be applied to your scene as well?
Hey Bengamin, unluckily I can't do like this. I must keep the animation setup as I did since in my scene there's a lot of stuff going on and I should keep the rig as you saw in my file...
What Stefan suggests would be great tbh
Title: Re: Multishader multipass masks?
Post by: bnji on 2024-04-30, 17:21:16
Hello there,


I'm sorry you had to deal with this. There's a nice solution for this...
If you're using a "Multishader", you can use the same shader for the Multipass to get a "Mask" according to the shader colors.
If you're only using 3 colors for the Multishader, you can copy the Multishader from your material, then use a "Texmap" in the Multipass window and paste it right there; last thing, set the Multishader colors to use R, G, and B colors respectively, this way you can get an RGB mask.
If you prefer, you can use several/different "Texmap" elements in the Multipass window, copy/paste the Multishader, and set colors to use B&W but only one at a time; I mean, If you're using 4 colors for the Multishader, you can set the first color from the first copy of the Multishader to white, and the rest set them to black color; then, use a new "texmap" Multipass and paste the same Multishader, but this time, set the second color to white, and the rest to black.
I know this is not perfect, but it will provide you with a solution that works.
I'm including the sample file (using your previously submitted file) to illustrate this.
Quick note: Don't forget to enable the "Ignore background" option for the "Texmap" Multipass.
I hope this helps.
Looking forward to hearing from you.
Have an amazing day/weekend.
Title: Re: Multishader multipass masks?
Post by: TeoRossi93 on 2024-05-03, 12:38:27
Hello there,


I'm sorry you had to deal with this. There's a nice solution for this...
If you're using a "Multishader", you can use the same shader for the Multipass to get a "Mask" according to the shader colors.
If you're only using 3 colors for the Multishader, you can copy the Multishader from your material, then use a "Texmap" in the Multipass window and paste it right there; last thing, set the Multishader colors to use R, G, and B colors respectively, this way you can get an RGB mask.
If you prefer, you can use several/different "Texmap" elements in the Multipass window, copy/paste the Multishader, and set colors to use B&W but only one at a time; I mean, If you're using 4 colors for the Multishader, you can set the first color from the first copy of the Multishader to white, and the rest set them to black color; then, use a new "texmap" Multipass and paste the same Multishader, but this time, set the second color to white, and the rest to black.
I know this is not perfect, but it will provide you with a solution that works.
I'm including the sample file (using your previously submitted file) to illustrate this.
Quick note: Don't forget to enable the "Ignore background" option for the "Texmap" Multipass.
I hope this helps.
Looking forward to hearing from you.
Have an amazing day/weekend.

Hey Benjamin! Unluckily I've rendered already the scene but I will try this workaround to see if it is working, didn't think about that.
Thank you
Title: Re: Multishader multipass masks?
Post by: bnji on 2024-05-14, 17:26:34
Hello Teo,

No worries; Please let me know if you have any further questions regarding this.
Have an amazing day/evening.