1
$\begingroup$

I have a (procedurally generated) greyscale map/mask that I use as the factor for mixing two shaders.

The scratches are much more prominent when I have the scratches in glossy white, then when they when I have them in diffuse black. There is probably an obvious reason for this, but it eludes me :-(

enter image description here

I tried nodes like the Color Ramp, but it does not make a difference?


How can I make the scratches more prominent, when I have them in diffuse black?



$\endgroup$
6
  • $\begingroup$ what about making the HDRI brighter? You won't see the black scratches if your object reflects a dark image $\endgroup$
    – moonboots
    Commented Jul 24, 2023 at 20:52
  • $\begingroup$ First thing to try is to pass the "Fac" input through a color ramp, constant mode, to make it binary either 0 or 1. Not only this eliminates the possibility of the value being outside of 0..1 range (unlikely the culprit here), but also makes sure there's no gradient. If there is a gradient, it's possible it works in fabor of the glossy BSDF: imagine that the glossy shader highlights the surface so much, that you only need Fac > 0.1 to make it bright. This would mean that 90% of the gradient is dominated by Gloss, regardless of orientation of the gradient… $\endgroup$ Commented Jul 24, 2023 at 20:56
  • $\begingroup$ @MarkusvonBroady I tried adjusting it with a Color Ramp[constant] but it doesn't make one bit of difference, even if I bring it back to like 0.001 $\endgroup$
    – Jacco
    Commented Jul 24, 2023 at 21:00
  • $\begingroup$ This is the same procedural scratch setup which I had answered previously right? The distance to edge voronoi one $\endgroup$ Commented Jul 24, 2023 at 21:10
  • 1
    $\begingroup$ If you are not clamping operations the map may have negative values in the black regions. I'm not sure how Invert handles operations outside of 0-1 $\endgroup$ Commented Jul 25, 2023 at 15:26

2 Answers 2

2
$\begingroup$

The reason why the scratches are more prominent when they are glossed is the scene lighting. I replicated your Mix Shader setup with some simple noise scratches. When you disable scene lighting and compare the two inverse variations you can see that they are inverted as one might expect.

Activating light now shows that the glossy parts overshoot the borders of the diffuse parts and this works only in one direction, towards the diffuse areas. Thus the scratches are indeed less dominant when diffuse black, as they get outshone. For the same reason, when the scratches are glossy, they are indeed shining more prominently. If its not that visible from the left side of the image, i added some red reference dots on the right side to visualize the glossy overshooting towards the diffuse black (tried with Eevee and Cycles showing the same behaviour).

enter image description here

With Eevee there is an Shader to RGB node with which one could abuse the inverse glossy overshoot as a mask and strengthen the scratches to their old expanse, see this setup:

enter image description here

To me, this feels a bit awkward and with Cycles you are out of luck. Thus you need to find a way to thicken the scratches' expanses before sending the fac. This of course depends on your setup to create the scratches.

Side note: The glossy overshooting is stronger when the surface is directed closer to the light, in more perpendicular areas the scratches have almost the same prominance (at least to me), this may help to understand your comparison renderings better.

$\endgroup$
6
  • 2
    $\begingroup$ It's nice that you replicated the problem and showed clearly it's not some kind of optical illusion (which was one of my considerations). However, the "the glossy parts overshoot […]only in one direction" is only a description of the problem, not an explanation; why does it happen? If you tested with samples=1, and binary 0/1 Fac (if not, then I'd like to see if the problem remains then), perhaps it has something to do with shader sampling, where a black Diffuse BSDF will sample neighboring areas and even if it's supposed to be black, if nearby there's a bright color, it still can… $\endgroup$ Commented Jul 25, 2023 at 9:25
  • 2
    $\begingroup$ … Become bright. Or maybe the magic doesn't happen in the Diffuse BSDF but in the Mix Shader, which either does exactly the same stuff, or… I don't know, gives precedence to Glossy BSDF in some way… $\endgroup$ Commented Jul 25, 2023 at 9:27
  • $\begingroup$ Thank you for the detailed answer! $\endgroup$
    – Jacco
    Commented Jul 25, 2023 at 15:33
  • $\begingroup$ @MarkusvonBroady thx for the input. I tried the binary Fac and the effect indeed vanishes. Changing sampling rates doesnt change much, thus i think this can be taken out of the equation. Also i think the Mix Shader only does what he should do, just lerp the inputs. But you're right, its not an explanation why it happens. To find this out, it may be necessary to look into the source code of Blender which in turn my be too much for the question (although interesting to know). $\endgroup$
    – taiyo
    Commented Jul 25, 2023 at 20:39
  • $\begingroup$ @taiyo oh if the effect vanishes with binary Fac, then the issue is probably just not normalized Fac on the input? As for reading the source code it's hard, because it's often C (or C++ written like C), a lot of memory manipulation, unhelpful variable naming, and usually few comments to fill the gaps… It's not enough to localize the code responsible for something, often you need to jump through multiple files, passing data around, and sometimes you get lost doing so, with the editor unable to recognize where to jump next, through some kind of a raw buffer… $\endgroup$ Commented Jul 25, 2023 at 21:38
3
$\begingroup$

For the technical part, make sure the scratches are visible more by simply increasing their size. And as Markus pointed out in the comments, use the color ramp set to constant mode.

The relative values of colors with each other can highly change the final appearence of something. Look at the pictures that I have given below.

In the first one, the background is light, and the two spheres,one has a dark color and the other a light color. You can observe that the scratches are more prominent on the light. This is because the contrast is much more.

enter image description here

In the second one I have simply increased the size of my scratches and thus making them more visible (increase the value in the less than node) enter image description here Now compare this 3rd image with the first one. You may have understood what I am trying to say by relative values of the colours. enter image description here

Basically what I think is that the glossy shader, since it's a bit greyish, is not giving you enough contrast. You don't have to change the glossy shader to something else though. Things like lighting can provide you more contrast very easily. Just be careful about the fact that the reflections are a bit clear since it's glossy and your light may appear.

Another thing, if you mix a some texture containing some grey values, and use multiply to combine the both, your beautiful, no gradient, sharp edges(scratches) will dim out according to the texture you are mixing with. Use different color blending modes for proper results.

$\endgroup$

You must log in to answer this question.

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