really tricky question about writing an art program

Fd80f81596aa1cf809ceb1c2077e190b
0
rouncer 103 May 27, 2013 at 18:01

Sure, you can write an art program by just effecting the screen with end rgb= brush rgb * opacity + screen rgb * (1.0f-opacity)
and thatll work… but… its NOT right!

Gimp 2.8 is doing it in a far superior way, like paintshop pro and photoshop.

What is the secret to getting the really lush effect on the screen with the brush that you get in professional programs?

(its very important to me, just flat averaging the colour (end rgb= brush rgb * opacity + screen rgb * (1.0f-opacity)) is NOT good enough!)

Does anyone have any idea, or am I just wasting my time cause not many people know this or think its important…

Its a method of opacity…

http://prosjekt.ffi….Basic.html#tag1

but this just says the exact way I do it, and its not the right way!

7 Replies

Please log in or register to post a reply.

Fd80f81596aa1cf809ceb1c2077e190b
0
rouncer 103 May 27, 2013 at 21:35

ah success. youve got to find the difference first! then subtract it, but there might be more to it than that just yet, but im definitely closer…
do you get what i mean? you multiply opacity by the difference!!! its not all in one line.

B5262118b588a5a420230bfbef4a2cdf
0
Stainless 151 May 28, 2013 at 08:38

Their are loads of blend equations. Dozens. They usually hang about with names like SRC_IN, SRC_OUT, DEST_IN, DEST_OUT.

http://en.wikipedia.org/wiki/Alpha_compositing

In an art package you should do all of them and let the artist decide.

Then you can start adding to the blend equations, gain, colour space conversion, the only limit is your imagination.

Fd80f81596aa1cf809ceb1c2077e190b
0
rouncer 103 May 28, 2013 at 13:10

very good stainless, but how one actually manages the brush… is a fool mystery.
I want gimp’s exact code.

A8433b04cb41dd57113740b779f61acb
0
Reedbeta 167 May 28, 2013 at 16:50

@rouncer

I want gimp’s exact code.

Fortunately, it’s open source, so you can have the exact code!

Of course, you have to track down where the code for brushes is amongst the (probably) millions of lines of code in the software.

http://www.gimp.org/source/

Dcdc1f8da93317d730963bffabbd78c3
0
TheHermit 101 Aug 13, 2013 at 07:18

There are some additional bits of artistry hidden in professional paint packages though. Blending is one such thing, but the details of the brush make a huge difference too (using a texture for a brush instead of a procedural dot, for example). Then there’s how the brush angles itself with respect to the stroke, whether or not the brush evolves over the course of the stroke, etc.

If you look at GIMP’s options for interacting with a tablet and stylus, you can tie angle, opacity, size, etc to all sorts of things like pressure, velocity, and stylus angle. The right combinations of these will cause the result to be more useful to the artist and better allow them to use the different levels of control they have physically to control the result. One thing I haven’t seen but I think would be neat is a control that basically thresholds the brush texture at an alpha value dependent on stylus pressure. So if you press lightly, you get a very spare, highly textured stroke. But if you press heavily, the stroke gets ‘filled in’ and becomes homogeneous except at the edges. This could be combined with a height-field of the underlying canvas to really get a painting texture going.

As far as blending modes go, you can also treat the edges of the stroke and its center differently in order to give the impression of actual material being deposited, sort of like automatically bump-mapping the result of each stroke. That will give you more of an oil-painting style effect. Or you could concentrate color around the edges, to get something like a watercolor bleed effect. Even if we’re just talking pigments, you can classify a pigment by a number of optical properties and simulate how light goes down through the pigment and back up to get a very physically-realistic model.

Treat each stroke like a layer with some concentration ‘w’. A given pigment might be described by absorption coefficients (Ar,Ag,Ab) and reflection coefficients (Rr,Rg,Rb). If you shine white light (1,1,1) on a patch of canvas where there’s a stroke of this pigment on top of the underlying color (Cr,Cg,Cb) then the color you get out (Or,Og,Ob) is:

Or = w*Rr+Cr*(1-w*Rr)*(1-w*Ar)\^2

with similar equations for Og and Ob. This is somewhat approximate since actually we should be considering second reflections, third reflections, etc inside of the multiple layers of paint, but this is probably good enough for many purposes. And of course, rather than using an underlying ‘canvas color’ you could actually store up all of the stacks of paint in each location as separate layers, but that would get computationally and memory intensive.

Fd80f81596aa1cf809ceb1c2077e190b
0
rouncer 103 Aug 13, 2013 at 10:32

hey thanks for the info! i wonder what yours looks like!
note ive had some success, what i had to do was multiply opacity by the difference of the colours, not multiply opacity separately and average them. COMPLETELY DIFFERENT RESULTS!

3c5be51fdeec526e1f232d6b68cc0954
0
Sol_HSA 119 Aug 15, 2013 at 11:24

You may want to look up porter-duff blend equations.