Re: [Inkscape-user] Equivalent to Illustrator's Gradient Mesh?

On Sat, 2007-06-16 at 14:17 +0200, Chris Lilley wrote:
> I would be interested to see your results. What artefacts are you
> seeing - sharp edges (I would not have expected that from Gouraud)?

The source of the problem is second-order discontinuity at the edges of
the triangles (i.e. the color is continuous, but its rate of change is
not).  The general visual effect is of "rays" connecting the vertices of
the triangulation, making the triangles fairly evident:

So, unless we want to force the SVG author to manually create very
finely divided meshes (which bulia rightly vetoed), we will need to
select a different shading function which takes into account neighboring
triangles and can give us higher-order continuity.

The "friendlier" function can be then approximated in OpenGL or
Postscript by automatic subdivision.  [Actually, with OpenGL on modern
hardware, the shading function could probably even be implemented
directly as a fragment shader.]

Here's the current state of the test harness (shown above in the
screenshot); I'm not too proud of the code, but I may as well post it so
people can start playing with it.  The code is public domain.

Planned still are:

 - an "eyedropper tool" for picking node colors
 - the ability to load a background image
 - miscellaneous UI improvements
 - alternate gradient functions

[I do have a couple alternate functions buried in the code already, but
they're toys for testing rather than being useful artistically, and the
automatic subdivision code still needs work.]

I'll post newer archives periodically, but the very newest version will
always be available via git:


Patches are very welcome.  README follows at the end of the email.




"trymesh" has the following requirements:

 - a C compiler (gcc)
 - Ruby 1.8
 - Ruby/Gnome2
 - Ruby/OpenGL
 - Ruby/GtkGLExt
 - libgts
 - RubyGems
 - RubyInline
If you're on Ubuntu, these can be satisfied by installing
the following packages:


If you have a recent enough version of Ubuntu, you should
be able to install RubyGems via the 'rubygems' package; otherwise
you will need to download RubyGems from:

Unpack the archive, and run the following in the unpacked

 sudo ruby setup.rb

At that point, you can install RubyInline via:

 sudo gem install RubyInline


 ruby bin/trymesh


Left-click to select a vertex; drag it to reposition it.  Double-click
to create a new vertex with the color of the most recently selected
vertex.  Right-click to delete a vertex.  The sliders at the bottom
control the color of the currently selected vertex.

There are three toggles at the top of the window that control what is

 [G] - displays the color gradient
 [T] - displays the edges of the triangulation
 [V] - displays the vertices

Received on Saturday, 23 June 2007 02:29:38 UTC