January 18, 2006

Exploring natural media graphics with Krita

Author: Nathan Willis

Traditionally, graphics applications have been divided into raster image and vector image editors, based on the primitives that each category uses. By that logic, the open source world needs only one of each, or it gets accused of wasting "resources" through duplication. But there's another way to look at graphics applications -- by usage. The painting program Krita takes a different approach to working with pixels, which can lead to a very different raster imaging experience.

Krita began life as KImageShop in 1999, essentially as an attempt to recreate the GIMP for KDE using the Qt toolkit. Initial development was rapid, but soon began to taper off. The name was changed to Krayon, a new maintainer selected, and a new direction taken in 2000, though development slowed down then as well. 2002 saw the adoption of the third maintainer (Patrick Julien) and the third project name (Krita). This time development stayed active, and the codebase got a drastic makeover and attracted additional programmers.

One of the new recruits was Boudewijn Rempt, who in the fall of 2003 was dissatisfied with the performance of his Wacom tablet under the GIMP, and was intrigued by the work others were doing in the field of natural media simulation. Julien eventually handed Krita's reins over to Rempt, who led the revitalized project to its first public release in June 2005.

The current release (1.4.2) is a full-featured raster editor, supporting advanced features like OpenEXR images, CMYK color, pressure-sensitivity for tablets, 16-bit depth files, and color management via LittleCMS.

Painting vs. image manipulation

Rempt's guidance has taken the project away from the "GIMP for KDE" philosophy towards what he describes as a painting model -- namely, simulating the tools, materials, and work flow of a real-world artist, who creates a picture out of physical "stuff" -- not pixels or shapes -- and puts "gunk on his paper or canvas and generally pushes that around."

For starters, this means drawing tools (pens, brushes, and paint) take center stage over the image adjustment tools (histograms, contrast controls, and masks) found in the GIMP. It also requires built-in pressure sensitivity and new ways to model color. The real difference, though, is conceptual. Eventually, Rempt wants Krita to simulate the experience of working with physical media, right down to mixing colors on the artist's palette.

Rempt and the other Krita developers are basing their natural media implementation on existing free software and on academic research. This includes Raph Levien's Wet Dream, an experiment in modeling wet paint pixels, how they interact with each other, and how their properties change as the paint dries.

Wet Dream simulates watercolor-like behavior by supplying each pixel with a water volume that alters the pixel's opacity and allows it to blend with neighboring pixels and subsequent brush strokes. "Drying" the picture is an iterative process that simulates the evaporation of the water and changes the image pixels to reflect the deposit of paint pigment.

Krita's watercolor simulation is under development now, headed up by Bart Coppens. Rempt hopes to have it finished for inclusion in Krita 1.5. In the meantime, you can download and compile Wet Dream (it depends on GTK) to try out the unusual effects at home.

Natural media in open source software

Other free software experiments into natural media include Gsumi, a pen-and-ink simulator written by Owen Taylor; some real-time paint simulation by Tom Van Laerhoven; and a set of proposals for enhancing the GIMP's brush system that went unimplemented by GIMP developers. Rempt maintains a list of related technologies on the Krita site, though it is unclear how much of this work will find its way directly into Krita.

To a degree, all these experiments attempt to do the same thing: model the behavior of liquid paint on canvas. For further down the line, Rempt is working on an implementation of Tunde Cockshott's Ph.D. dissertation "Wet and Sticky" (available as a PDF file from Bill Baxter's graphics research page); he's also working on a more thorough painting model that incorporates viscosity, surface tension, canvas and brush physics, and environmental factors. He hopes to incorporate Wet and Sticky directly into Krita, and to that end, convinced Cockshott to release some of his Wet and Sticky code under the GPL.

Rempt describes the work as an ongoing learning experience with many challenges stemming from trying to combine natural media simulation with the everyday features (such as adjustment layers) that users have come to expect from graphics applications.

To try some of Krita's in-development features, you can check out the module from anonymous SVN. Krita is part of KOffice, so you may need to check out the entire KOffice module to ensure you have all the required support libraries -- but you won't have to build all of KOffice just to use Krita.

Click Here!