On the following screenshot, the black region on the torus is controlled by the normal on the Principled BSDF. Now in Cycles rendering, I want the blue dots to only appear within the black region on the torus. So the blue dots should not appear on the red region. How can I achieve this please?
2 Answers
As taiyo describes in his answer, The "Color Ramp" always gets 0.5 value, for which it always outputs white color, which could be replaced with "Combine XYZ" node with $<1, 1, 1>$ values.
You are overriding all normals with $<1, 1, 1>$. This breaks the rendering for faces that have now normals pointing inwards:
This might be what you want, but probably it's just an effect achieved with trial-and error and you just like the black color going diagonally. If so, consider making an equivalent setup, that will work in Eevee and will not cause shading artifacts:
This is the same Dot Product taiyo uses in his answer, except I'm explicitly passing the $<1, 1, 1>$ vector for readability and I'm using it to simply control the color. Now it's easy to limit the blue ellipses to black area, just plug the logic into the black color:
And this is, I think, reproducing the exact look, but using a single shader and working in Eevee:
-
1$\begingroup$ Great addition! I was in a hurry and left my solution as an exercise xD $\endgroup$– taiyoJul 29 at 11:24
-
$\begingroup$ @Markus von Broady Thank you! For the first screenshot, how did you visualize the normals for each face on the torus please? Did you use any geometry nodes as the following method? blender.stackexchange.com/questions/255700/… $\endgroup$ Jul 29 at 21:46
-
$\begingroup$ @BlenderLake something like this, yes. $\endgroup$ Jul 29 at 22:33
-
$\begingroup$ @MarkusvonBroady Great! Your answer has fixed my shading artifacts! $\endgroup$ Jul 30 at 0:06
The key observation is that you plug (1,1,1) into the normals. This normal is spread across the donut and divides it into two parts: one where the normal is sticking out of the surface and one where not. Thus you can use the dot product with the face normals to detect which part you belong to. Get the face normals with the Geometry
node, calculate on which side of the border (dot = 0) you are and use that to noodle the rest together so it fits your desired goal. Setup:
-
1$\begingroup$ This is an elegant algorithm, which has blazed a trail through the darkness for others to follow. $\endgroup$ Jul 30 at 0:06