Cycle mixed output nodes materials

Dear All
I already posted this message on another forum :spin:, forgive me for “posting again”.

Ive looked on severall threads and Wiki.
It’s well documented for BI , not for cycle
http://wiki.blender.org/index.php/Doc:2.4/Tutorials/Materials/Nodes/Sectioning_a_mesh_with_nodes

To illustrate what I want to do, I post a composed image made with GIMP.
I “mixed” the blue node render image + orange node render image


If you check Cycle render after the multiply or the substract node you will see a dark image (the orange or Blue dissapear).
Please let me know whats wrong with these 2 nodes.


I can’t figure out how to mix the 2 nodes to obtain the final result (as the GIMP image).
I’ve attach the blend file
x-transparent Cross section.blend (267 KB)
thank you Again

You need to understand how Cycles works first. You cannot use shader outputs with common nodes such as Multiply or Subtract. Basically, colors of inputs and outputs should match (though in some cases automatic conversion between RGB (color), Vector (purple) and Value (gray) is performed).

With Cycles you have to approach this task a bit differently: you don’t need separate groups of shaders for both colors, you just need to control the color for Emission shader. This can be achieved with another mask. There are different ways to get that mask, but quick and dirty one is using yet another Mapping node (I’m doing that just to stay in theme with techniques you used for your shader). Next, you need to make sectioned part of your mesh transparent. This can be done by combining the two masks you get from checker textures with Multiply node.

I’m attaching your fixed .blend.

Attachments

x-transparent Cross section.blend (269 KB)

Dear MASTER Stan,

Many thanks for your answer.
It works like clockwork.
I was digging in the wrong direction (in fact I was sinking).
Master Stan May I…:rolleyes:
Why -55° in the 3rd mapping shader, as I tried different unfruitfull others values.

Lastly:cool: if you know another way to get the same result with different shader, I’m curious.

For all youv’e already done a big Thank you:yes:

Well now, I am no one’s master :slight_smile:

Why -55° in the 3rd mapping shader, as I tried different unfruitfull others values.

Plug the output of that checker texture to Emission shader and ultimately to Material Output to see why. Basically, black area is colored cyan, white area is colored orange.

Lastly:cool: if you know another way to get the same result with different shader, I’m curious.

Well, no, not really (though I didn’t give it much thought :slight_smile: ). Come to think of it, you can use somewhat easier to set-up third mask, instead of that -55 degrees one. Since your object is centered on screen (more or less), you can get Camera coordinates (from Texture Coordinate node), put that into Mapping node with (X:0,Y:0.5,Z:0) and 0 in all Rotation angles and finally to that Checker node.

For all youv’e already done a big Thank you:yes:

You’re welcome.

Stan, Are you still in ?
I added a Suzanne mesh in the center of the scene (and a solidified cylinder)
The result is Bad…
I tried changing some parmeter in the nodes but I did not find any solution to get a good cross section.
Just for your information the scene with the bolt was dowloaded on this forum (It is not mine).
Maybe something to do with a parameter I missed ?
Thank you AGAIN if you could give your help
Here is the new problem
Correct x-transparent Cycle Cross section1.blend (277 KB)

I won’t give you .blend this time (no Blender at hand right now), but I can offer you some advice:

  1. This is not universal shader, you’ll need to tweak it for different objects.
  2. Instead of checker texture, use your own texture. For example, you can generate one by combining Less Than node with Color Mix node. So it’ll be Texture Coordinate (Object) -> Mapping -> Separate RGB (pick one coordinate) -> Less Than (0.5) -> Mix (black, white). Thus you can rotate this “texture” using Mapping node to get a mask for each section plane, then combine these masks as before with Multiply node, and… well, you get the idea. Use Emission node to see your masks while you set them up.

Stan,
My skills for shaders node are not good enough to follow your information.
I’ve Tried and did not succeed.
Could you please give us a shader node screenshot
Thanks

Okay, Il again won’t give you the .blend with a full setup for Suzanne, otherwise where’s the learning fun? :slight_smile: Instead, I’ll give you a simple example .blend as well as some explanations.

First of all, to explain this little example: I want to make a material (or rather, a group of nodes) that will represent Suzanne being cut in half by a vertical plane (a section plane). I want to be able to rotate that section plane to change the angle of section.

The section is easily represented by a simple black-and-white mask, where black colors are on one side of the section plane and white colors on the other. If I can somehow color Suzanne this way, my problem will be solved and I’ll be able to use my mask to actually control how Suzanne is rendered (i.e. make “white” part transparent, change diffuse color of “black” part, etc.).

Look at this screenshot:


First of all, look at the left viewport. I intentionally enabled edit mode and switched 3D manipulator mode to Local. This way I can see where Suzanne’s coordinates are going. I see that her Y axis is directed up, her X axis goes from her right to her left, and her Z axis goes from her back to her front. Thus now I know that my section plane will rotate around Y axis.

Now let’s dissect my node setup.

Lets skip Texture Coordinates and Mapping nodes for now. Look at two green nodes (Separate and Less Than). Separate node takes a vector and separates it to its three components. Though technically this is a “Separate RGB” node, think of it a a “Separate XYZ” node. So R is X, G is Y, B is Z. Now Less Than node will take one of the coordinates, compare it’s value to 0.5, and whenever the coordinate is less than 0.5, it will output 1. Otherwise, it will ouput 0. So this Less Than node is what’ll give me my black-and-white mask.

Now for the coordinates themselves. As in your previous problem, I’ll be using Texture coordinates (see end of post for other possibility). Looking again at my viewport I want to start by cutting Suzanne along her XY plane. So I take Object coodrinates and put them through Mapping node. Now, in this Mapping node I set Location to (0.5,0.5,0.5), so that the section plane goes right through the middle of Suzanne. I then proceed to select a coordinate that will actually represent my section plane. In this case, I choose Z (because I wanted XY as initial section plane, remember?). Now I can simply rotate my section plane around Y axis (Y Rotation input in Mapping node) to get the angle of section that I need. Problem solved. Now I can create several of these section planes and combine them in any way I want: it’s only a matter of duplicating those four nodes, selecting coordinates and changing values.

Remember what I said about this not being universal shader? Well now you can see why: it’s tied to Suzanne’s transform, i.e. to the direction of her orientation axii. Instead of using Texture Coordinates, you can use Position output of the Geometry node. Then you’ll need to tweak your setup accordingly (i.e. different axii will be used). But that still won’t make this approach universal, because objects may be transformed in space (translated, rotated…), so that initial Location values of the Mapping node would differ for different objects.

I’m attaching .blend with which I made the screenshot. Feel free to ask any questions, I’ll try to explain to the limit of language barrier (I sometimes am not very good at explaining things since English is not my native language).

Attachments

monkey_section.blend (558 KB)

Thanks for your instruction. Your shader is helpfull to understand
in Mapping node location is set to 0.5, If I scale Suzanne to 2 mapping location shoud be is 1, Ive notice it does not work this way.

Why 0.5 in less Than node, I change this value and it acts like the “Mapping node location”.
You showed how to select the coordinate for the 2 planes.
Then I don’t know how to set a proper "mixing of these 2 planes
I read wiki and got this for BI. and try to apply it to Cycle


Still on the rails
Correct x-transparent Cycle Cross section2.blend (269 KB)
Not an easy task

Thank you again

It will if you scale her in edit mode. If you scale her in object mode, her “physical” (i.e. local) dimensions are not changed.

Why 0.5 in less Than node, I change this value and it acts like the “Mapping node location”.

0.5 is just because I like having the notion of “middle”. You can get away with leaving it at 0, as well as leaving Mapping node location at 0 as well :slight_smile:

You showed how to select the coordinate for the 2 planes.
Then I don’t know how to set a proper "mixing of these 2 planes

Look through the first .blend that I fixed (the one with the bolt): in order to make part of the object transparent, we need to intersect two section planes and determine which area of the mesh is “inside” both sections (i.e. cross section). In that case, we used the notion that whatever is 1 (i.e. white part of the mask) should be transparent (so that “insides” of object are visible). Our masks have only two values: 0 for black and 1 for white. So, multiplying them together we’ll only get 1 (white) where both masks are 1 (white). This gives us our cross section mask. So we then use this new mask as a factor to Mix Shader node: whichever is black in the mask will be colored, while whichever is white will be transparent (so we see inside parts).

I read wiki and got this for BI. and try to apply it to Cycle

I know :slight_smile: See, in that 2.49 BI tutorial the author also uses simple black-and-white blend texture, which we replace with Less-Than node in Cycles. We also use Multiply. But you have to understand that in Cycles you cannot mix shader outputs using math nodes. The only way you can mix shaders is with Mix Shader or Add Shader nodes. For your purposes, only Mix Shader node is useful. So it all boils down in determining factors for those Mix Shader nodes, and these factors are nothing more than combinations of masks.

I got it
cross section3.blend (326 KB)

…still a misterious area.
To get good results I need to play with the scale in edit mode for every mesh.
I created a new suzanne.002.
If it not scaled in Edit mode I get a wrong mapping.
I believe there is something to do with the mapping scale parameters.

No, you don’t need to play with scale. You need to replace that last Checker texture with our Less Than texture. And map it so that it splits Suzanne in two right along the line where section planes intersect: this is needed for proper coloring of sections. Right now you get a mess mostly because you’re using Checker texture.

Thanks Stan,