hi Micael

On Sun, Dec 02, 2012 at 06:59:40PM +0000, Micael wrote:
> Hello
> 
> I have made an attempt at enable sub-pixel painting with brushlib,

Took me a while to figure out what you mean with this.
I think you mean dabs that are smaller than one pixel, right?

Because MyPaint already does sub-pixel dab placement.  I think you are in
fact trying to do anti-aliasing, but using a different approach than my
current aaa (anti-aliasing-attempt, which only works for large dabs).  The
two approaches seem to interact somehow - in a good way or in a bad way?

A picture before and after would help the discussion here. It's unlikely
that I have tried the same brushes as you, we may even be talking about two
different things.

> and as far as I've tested (not extensively), it seems to give good
> results.  The repository containing the changes is:
> https://gitorious.org/~mdias/mypaint/mdiass-mypaint

I didn't understand the code by reading it. I haven't tried very hard yet. 
But a short text (or visual) explanation what your are attempting to
achieve, and how, would be good.  Have you found this one already? 
http://wiki.mypaint.info/Brushlib#Dab_shape_.28mask.29

> I'd appreciate some input on the sub-pixel painting. I'm not sure I can do
> better with my current math skills, but it looks good to me.

I don't think there is a mathematically sound approach to fix this problem
(without extreme performance penalty, or switching to an entirely different
stroke concept).  A "correct" anti-aliasing would produce the same result
that you get when you render the stroke at, say, 16x resolution, and then
scale down (preferably in linear light, but let's ignore that for now).

This simply is impossible to do 100% correct inside the dab mask rendering. 
If you have a very hard and fully opaque dab with 0.01 pixel radius, and you
place it 30 times at the same location, it should look exactly the same as
when you place it only one time.  This is impossible to achieve, because the
dab mask cannot prevent that multiple dabs are blended over each other.  (It
would work if MyPaint used the "alpha-darken" approach in a temporary layer
like other programs, but we apply dabs only directly to the canvas.)

Thus, everything we do here will be an approximation or workaround.  There
is no point of trying to make it correct, it's enough if it looks good (e.g. 
not gappy). If possible it should be simple and fast.

A big problem with your solution is that it is a rather complex piece of
code (it even uses a division, I think) inside the performance-critical "for
each pixel" loop.  I have run the "brushengine_paint_hires" benchmark, and
in your branch it's about 35% slower than master.  Jon Nordby has just done
a lot of optimizations, which got about that much performance gain (on my
system, and with the currently active-by-default code).  You can measure
with "tests/test_performance.py brushengine_paint_hires".

My feeling is that there must be some simpler and more efficient approach to
get good-enough results...

> There's also another change included, which is splitting the brush stroke
> (for undo purposed) when the brush stroke ends. This apparently was
> deliberately chosen to be time-based to prevent cluttering undo history
> when shading, however it gets confusing to the end user. I purpose an
> option somewhere to enable/disable time-based undo events.

This was discussed several times already. The default is not going to
change, for now.  But a patch that makes this configurable would be very
welcome.  It will probably require a new translatable string to be added to
the GUI, which we can't do right now.  But we could push it in about 3
weeks, after 1.1 is released.

> With the current time-based undo system, it becomes confusing for a user to
> release the click, press Z and nothing happening unless the cursor is moved
> X time after the last stroke.

That certainly sounds like a bug and not an intentional feature. I cannot
reproduce it here.  I guess you are testing with the mouse?  Please fill a
bug report for this one with step-by-step how to reproduce, what you do,
which input device you use, what happens, what you expect to happen.

Pressing Z should always undo something. If you have a bad tablet stylus,
maybe it can happen that you make a very faint line even after you lifted
it, because it doesn't release pressure fully?  If so, you can workaround:
http://wiki.mypaint.info/File:Pressure_workaround.png

> Maybe the undo function should split he current brush stroke if any?

It does. Or did, at least. Maybe it was broken by some recent change. But it
seems to work fine for me...

-- 
Martin Renold

_______________________________________________
Mypaint-discuss mailing list
[email protected]
https://mail.gna.org/listinfo/mypaint-discuss

Reply via email to