0
$\begingroup$

I have a cylinder and I want the curved outside to have one simple diffuse shader, and the two flat sides to have a different diffuse shader. How would I do that?

I was stuck on believing that this is connected to the "Auto Smooth" (including the angle limit) function that already comes with Blender. I thought the basics are there because, the way I understand it, Auto Smooth almost does the thing I want: It shades faces differently, depending on their outer vertices' normals. enter image description here

I tried playing around with the normals Input: enter image description here

But this is dependant on the rotation of the object. The lower flat face, the one that's not visible in this screenshot, is still blue. And if I rotate the object, everything is messed up.


EDIT: Possible solution

Okay so I asked elsewhere, and I got a promising response. Now I'll be honest, I just barely passed linear algebra back in university, more than 10 years ago by sheer dumb luck, so I don't know exactly what these nodes do. But using vector absolute and vector dot product nodes seems like it might be the solution to my problem. This is the current node setup: enter image description here

And this is the result. I have to verify if it works like I want it to more thoroughly, but maybe this is the solution!

enter image description here

Also, I updated the title. It's more fitting to what I'm actually trying to find out here now.

$\endgroup$
10
  • $\begingroup$ The smoothing is working on the edges, not the faces... the effect is only looking as if a smooth surface extends from one face to the other because the edge inbetween is smoothed. Which means, it is not like the side of the cylinder is shaded smooth, and the top and bottom are shaded flat so that you have a criterion to switch from one to the other... $\endgroup$ Commented Aug 24, 2023 at 8:43
  • $\begingroup$ Thank you for the answer! So, would you say what I'm trying to do is basically impossible? $\endgroup$
    – RichardM90
    Commented Aug 24, 2023 at 8:57
  • $\begingroup$ I guess so, because the criterion which you are looking for to decide which face gets which shader does not exist. As long as you have planar faces, each face of the cylinder (or other meshes) by itself is flat, the top and bottom ones as well as the side faces. It's the edge angle the Auto Smooth function is looking for (and which you set as Angle in the options). So it is not possible in general as a recreation of the Auto Smooth function. In your special case of course you could differentiate between face normals pointing up or down and the others pointing to the sides... $\endgroup$ Commented Aug 24, 2023 at 9:14
  • $\begingroup$ ...but if you are looking for something that works only in this special case, it would be much easier to simply apply different shaders to different faces manually. $\endgroup$ Commented Aug 24, 2023 at 9:15
  • $\begingroup$ en.wikipedia.org/wiki/XY_problem - why do you want to avoid using geometry nodes? The example is fine, but can you also explain what you're actually trying to do? $\endgroup$ Commented Aug 24, 2023 at 12:47

2 Answers 2

2
$\begingroup$

I think you're confused about how "auto smooth" works. It doesn't make some parts smooth and some parts flat. Everything is smoothed, but the effect (as Gordon already said) is limited across the edges above the "Auto smooth angle" threshold. This is why one alternative to Auto smooth is using "Split Edges" modifier, and that's how you should think about it.

Take a look at this cylinder with poked flat faces (just for explicit triangulation, not related to the issue) and then bent so now there are still 3 separate surfaces: top, side, bottom, you can still see the top and side, and they are still separated - both are smooth, but (visually) separated:

Now, a shader is run for each point separately. The point somewhere in the middle of an area couldn't possible know, that somewhere there is an edge, and this edge makes a full "circle" on the surface of the mesh, therefore separating the area of this point, out of the rest of the mesh, and the shader of this area should be some specific shader… Consider the case below - the threshold has been increased, so now a few edges no longer stop the flow of the normal:

So are the areas above still separate areas or now they are one area? Assuming the latter, you can use geometry nodes to physically split the edge using the angle threshold, and then assign materials based on island index:

How did I know which material will go where? I didn't. I first named them Top, Side, Bottom, in that order, then I tested, saw it's wrong, and renamed them to be correct. You could improve the geometry nodes setup to somehow sort the mesh islands…

$\endgroup$
3
  • $\begingroup$ Thank you so much for your response! I'll try this for sure, but in the meantime, I updated my OP again with a possible solution. I have to verify it still. $\endgroup$
    – RichardM90
    Commented Aug 25, 2023 at 5:28
  • $\begingroup$ Sorry. Markus.. when I fire up in the morning to review posts, some answers don't show up... I must remember to refresh. $\endgroup$
    – Robin Betts
    Commented Aug 25, 2023 at 8:18
  • $\begingroup$ @RobinBetts no problem :D $\endgroup$ Commented Aug 25, 2023 at 8:40
2
$\begingroup$

Very similar to Markus' answer .. again..

For a more general definition of what constitutes a 'flat' region .. (all the faces are flat), you could reach for something like 3DS 's 'Smoothing Groups'

This GN modifier splits a copy of the mesh by edge angle, and stores the normalized index of the resulting mesh-islands on face-corners of the original:

enter image description here

The resulting 0-1 attribute could be used in a material:

enter image description here

Separating islands:

enter image description here

Unlike the 3DS case, where groups are manually defined using faces, this is vulnerable to islands not being completely bounded by sharp edges, so won't be the same, but could still have its uses.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .