Exact equivalent of "Texture each tip" in Krita brush pattern options

Texturing each tip is relatively straightforward. At some point in the stroke generation pipeline a new dab is produced and the texture is applied to it. Very localized in terms of code. Each dab is textured once.

Texturing the whole stroke needs a totally different approach. My intuition is that the untextured stroke needs to be maintained (think of a stroke as an image, “paint device” in krita code, with the current dabs painted on it). Then, every time a dab is added to it, a new stroke is made by copying the current untextured one and it is textured, and that new stroke is what is displayed when drawing and at the end painted on the layer. If a new dab needs to be added to the stroke, then this textured stroke is discarded and the dab is painted on the untextured stroke, which is then copied and the copy textured and so on. The process repeats until the user stops painting, which is when the textured stroke is painted on the layer.
That’s what I think it should do in general, but it is better ask dmitry in the irc channel.
Stroke painting is multithreaded, so you can imagine that the process I described will not look so straightforward in code and probably the changes will be more scattered.

Edit:
Then, there are possible optimizations like applying the process only on the part of the stroke that was updated (where the last dab was painted). The texturing is a pixel-wise operation so I think this optimization is easy and a must. It would improve performance a lot.
I would say the difficulty is in how to structure everything. It is not mathematical, since the code for the actual texturing of the stroke would be pretty much the same as in the texture each dab.

Edit 2:
Also things like dual brush may get in the way in texture per stroke, which you don’t have to even think about in the case of texturing a single dab.

5 Likes