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

I’ve been messing around with patterns in the brush engine and find I’d like to have a way to control the pattern’s contribution to the brush with pen pressure. So that at 0 pressure, no pattern would be applied to the stroke, only the brush tip as defined in the brush.

Also, I’d like the pattern to be dithered in rather than blended with multiply or subtract, since those don’t look very nice on their own IMO. I’ve made a mockup of what I mean, including my proposal for how the math could work, if it’s possible:

So we calculate [ strength ] - [ pattern ] and then increase the contrast of the result considerably. One way to do this would be to just multiply the result by e.g. 1000, assuming the result is clipped to 8-bit color range. (a bit ugly, I know.)

Then we subtract the result from the alpha of the brush tip.

My question is, can we do this kind of contrast adjustment after the pattern strength curve is applied?

3 Likes

I’m not an expert for brush creation but from the top of my head it should be possible with the mask brush settings.

I’ve tried to do this with masked brush but haven’t been successful so far. The masked brush affects parts of the stroke outside the brush stamp, which has kind of stumped me. But I did just realize this can be done with a couple of layers:

The main problem there is that you’re stuck painting with this style on the layer, and have to have other layers if you don’t want this kind of brush effect.

What about this? Help creating pencil brush - #4 by tiar

1 Like

The workaround with a ‘masked brush’ on the top that darken the stroke for the final pressure is what I used for the default preset h)_Charcoal_Pencil_Medium ; but difficult to cover a complex brush or fill the holes of a very contrasted texture (eg.with substract) this way.

I don’t know if it will help; but I wrote that in 2013 to feature request textured brush strokes. It might contains some of the logic behind the way the texture is applied.

I would be very happy to also be able to get this 100% plain stroke at the end of the max-pressure. I’ll follow with attention your researches.

1 Like

@deevad: at the end of that article, it looks like the example from Krita 2.5 is pretty much what I’m looking for here. Am I missing something, or have newer versions of Krita lost this feature?

This picture?

The full darkening might have been obtained by layering multiple stroke. I’m not sure full pressure ever made opaque stroke. (and that’s a wish, for sure).

I made a bundle with a single preset in it that try to reproduce a dry textured stroke at low pressure and a plain and opaque stroke at high pressure. Most of the work happened with the Contrast/Brightness and Neutral point to distribute the effect along the pressure of the stroke.

Bundle: https://www.peppercarrot.com/extras/resources/2021-03-11_Textured_test.bundle

3 Likes

Do you need something like “Height” (or “HardMix”) mode ?:

I finally made a couple brush with “Superflat” tip that mimics “Height” mode (The essence like was mention before is to use mask brush tip). Still creation and, especially, editing those brushes is truly a headache.
“Fat” brushes is much simpler. There is already examples in “DA” pack and in the default pack e.g. “h)_Chalk_Soft” (similar like @Deevad shows)

And, yes, Krita definitely need some more textures modes.

1 Like

“Height” would be what I’m looking for. Essentially I think it can be expressed as a conditional statement, something like “if StampAlpha > Pattern, StrokeAlpha = 1, else StrokeAlpha = 0”

This would be pretty harsh, but it can be finessed with a slightly more complex formula.

1 Like

Oh wow; thank you for pointing this thread. Yes.

I wonder if Height is a blending mode at all? I was trying to reverse engineer the blending mode based on what @I9S gave me in that thread but I wasn’t successful… it looks already dithered.

Hmm… Since there is no “Height” blending mode in layers interaction in Photoshop, CSP or Paintstorm but have in brush texture settings, it seems this term relates only to interaction between brush pattern (texture) and tip. In that case the logic formula @hulmanen suggests can be not far away from the essence.

I would like it as a sensor-based option, too…

1 Like

I didn’t use PS in like 15 years but from the description I always assumed it works a bit like a height map in 3D texturing. It kind would make sense and the name would fit.

1 Like

If not knowing what kind of compositing operation is needed to achieve the result here is a hurdle, I’m pretty sure I can provide a description of the logic. I just don’t know what limitations we’re dealing with in the brush engine - can we use logic operations, conditionals etc. or are we limited to arithmetic.

1 Like

So, I have to admit that I’m not very familiar with brush engine code at all, but it looks like we have everything we want to use. Seepd is achieved by aggressive caching than sobie magic. Looks like the code is here: plugins/paintops/libpaintop/kis_texture_option.cpp · master · Graphics / Krita · GitLab

There is quite a lot of options and discussions here and in other threads, so tbh I would prefer if you guys achieve some kind of agreement which option would be best to try, and I can try to implement it if I get permission to spend time on that (at least for some of the options here, it shouldn’t take much time to get a quick proof-of-concept). If it turn out to be some bigger project, it might need to wait a bit since we want to finish resource rewrite and I’m one of the people working on that. But when there are specific ideas to try, someone else might want to step in and implement, too.

Yeah, I think I’m getting to understand what was David asking for, I mean I kind of thought it was already implemented… @deevad how many other great feature requests do you have that nobody implemented? How can you still be so supportive? I think I must stop telling people how good feature request looks like if it’s so much of a non-guarantee… :stuck_out_tongue:

3 Likes

@tiar : :smiley: Oh, I’m really happy with what the texture request blog-post made on Krita 2.5 and 2.7 (and also Blender, but that’s another story)… But I admit the feature has this tiny “missing something”, I never could define until participating in the thread here (big thanks). The picture posted by @I9S on a comment above (with Krita vs Clip/Ps stroke) pins exactly an issue I always felt without be able to tell.

1 Like

I was thinking the same thing. The texture is just height map information no?

For what I can understand the pressure tells the texture untill what grey it can paint. At max pressure everything is selected. Seems to have a bit of a long stamp distance over it.

1 Like

In the halftone filter I made, the 2 images (layer + texture) are mixed using a custom algorithm that is kind of in the middle of an overlay blending mode and a simple add. It may be relevant to find how the height mode works. The thing is that in the halftone filter for the effect to be the most pleasant the texture has to be similar to a height map. Not that the filter uses the concept of height for anything, but the texture should have the full range of values for better results.
Since the filter allows to be applied to the alpha channel here is an example I’ve made:


The part of the video where the texture changes I was selecting different patterns in the filter mask options (OBS didn’t record that dialog).
And this is the sample file.

2 Likes