Brush engine: Is it possible to have a pattern blending mode like this?

@Deif_Lou , that looks good, I’m afraid I can’t wrap my head around the code you used however… That’s my fault though. Possibly using your approach is a better idea, the result seems good.

On my end, I got something that I think works and only has one arbitrary magic variable! Let’s see if I can still explain what I did.
First, the results:
Here’s our pressure, with a good bit of both solid black and white so we can see what happens at full and 0 pressure:


And here are my results at different softness levels:



So we can see that changing the softness maintains the overall apparent value of the output pretty well. That’s good! And the whites and blacks remain clean without any major discontinuities at the transtion. At full softness there’s maybe a tiny edge where the pressure approaches 1?

This approach requires that we be able to do floating point math. The resulting output can and should be clamped between 0…1, but the calculations need values outside that range.

What I did:

we need to adjust the whitepoint and blackpoint of the pressure gradient as softness changes.

pressureWhitepoint = 1+(1-(softness^0.8))/2 using a hand-tuned exponent to avoid issues at softness=0.5

pressureBlackpoint=(softness-1)/2

pressure=(pressureIn-pressureBlackpoint) / (pressureWhitepoint - pressureBlackpoint) this is the range adjustment for our pressure

if pressure>0.5:
texture = 1-2 * (1-textureIn) * (1-pressure)
else:
texture = 2 * pressure * textureIn overlay blend of texture and pressure

Now we need to adjust the overall contrast using our softness value:

midpoint = 0.5 I believe we want all calculations centered on .5
whitepoint = midpoint+softness/2 final whitepoint adjustments
blackpoint = midpoint-softness/2 final blackpoint adjustments

output=(texture-blackpoint)/(whitepoint-blackpoint)

So, does that make sense to anyone? :stuck_out_tongue: It seems pretty robust to me. It might be best to limit softness to values above 0, as when it goes to 0 the values of the result go to infinity. It gets clamped of course, but I’m not sure what kind of problems that could result in.

2 Likes