Cycles - Problem with two shaders mixing with help of image mask

Hello. I have two glossy shaders and i need to mix them using mask (which is just *.png image) so that white shader completely above red shader in certain places. Everything seems to work normal, but at сloser look one edge of model is not affected by mask. It is semi-black, while it should be completely white.


I checked everything from normals direction to mask color, and even world color - nothing is wrong, but problem persists. May be someone knows solution?

Attachments


If you need just a different color but the same shader use a Mix Color node instead of a Mix Shader, it’ll be faster and cleaner.

As for the black spots, they seem to have something to do with the geometry, not the shaders. But it’ll be easier to know if you share your blend file. :slight_smile:

Those black “cracks” are a long-standing Cycles issue: They only seem to occur in the rendered viewport (not the final render) when set to orthographic mode. That’s why they don’t happen in camera view, because you will normally rather use a perspective camera.

So, if you really need an orthographic rendered viewport, you will have to “fake” it with a perspective view/camera with a very wide FOV. I’ve seen reports about this issue also being resolved by playing with the viewport clipping and/or the object scale, but was never able to find a reliable combination of settings for this way of solving it.

Other than that: Please ALWAYS supply an example .blend file with any support question. Remember to pack the textures.

Thank you, @julperado

you mean MixRGB node? How do i do that? When i simply mix two shaders by mask everything work as expected
stc=1
but when i try to mix them via MixRGB node
stc=1
I have grey material instead of two colors mixed by mask
stc=1

Thank you for answer, @IkariShinji
I know about black spots problem, but in my case blackish line persists even in renderd image. I think it is not geometry problem also, because i checked geometry normals and they point in proper direction.

I can not post original file. but here is *.blend file example, where i try to mix two different colors by mask. I hope it will give example of what i’m trying to achieve now.
mask-shader-problem.blend (551 KB)

I managed to mix colors via mask, by changind mode in MixRGB node to “Add”, instead of “Mix”, but colors are ruined. I have just tints of gray, not original colors

Attachments


May be it is geometry problem after all. Or rendering problem may be. I baked texture, and there is no sign of black stripe on certain edge. I apply this texture to model, and when i look at model in preview mode, or render scene, even with simpliest glossy shader for each color - black line exists. It seem that geometry may be too dense, or something. But since when geometry density afects diffuse or glossy color? Very strange.

Mind the color coding!
You’re trying to mix two shaders (green output connector) with a mix node made for colors (yellow input connectors). So, you need to either mix the two shaders with a Mix Shader node (A) or mix the two colors (Shift-A > Input > RGB) with a MixRGB node before even feeding into the glossy shader (B).

A:
https://dl.dropboxusercontent.com/u/27650383/AO_01-04-2016%2008-22-40_A.png

B:
https://dl.dropboxusercontent.com/u/27650383/AO_01-04-2016%2008-24-05_B.png

Whoa! Thank you @IkariShinji Never knew that i can mix two colors like that. Always used MixShader node. If your approach allow to mix two colors by mask and feed them to one glossy shader, it will greatly help. I wil try it tomorrow and post about results here.

I found that your approach works fine, even without RGB node. Just by selecting desired color in MixRGB node. The only problem is that i was using LayerWeight node in combination with RGBCurves node, to define both color and refection of material.

Now i find no better solution that create setup like this


using pure black glossy as “blank” shader just to have an option to connect RGBCurves node output with MixShader factor.
I wonder, if RGBCurves node in combination with LayerWeight node, like this

define only color, or both color and reflections? If it defines not only color, but also reflectivity of material, then i have a problem.

UPD: Yes. LayerWeight node pluged in RGBCurves node define not only color but also reflectivity of material. So, at first i need:

  1. Recieve color value from RGBCurves node, somehow.
  2. Define this color in MixRGB node.
  3. Keep proper reflections by plugging LayerWeight and RGBCurves node setup in MixShader factor.

Attachments




It seems that i need nodes setup like this
stc=1
Please correct me if i’m wrong

UPD: I only find this solution


I plug RGBCurves output to MixRGB shader and mix their colors by mask. Then i create another RGBCurves node in which i combine in one all curves from two RGBCurves which define color, and plug it into MixShader Factor.

Attachments