I am writing an application which displays 2d polygons. My application is in Java and uses jme3 / LWJGL at the higher levels but I don't think that changes much, my question is at the GL level.

The 2d polygons have dozens of vertices and the shape of the polygon, including the number and position of vertices, changes a little with each rendered frame. The polygons cannot be assumed to be convex, but they are contiguous, don't have holes, and the path defining each polygon does not ever cross itself.

Each frame, I'm breaking each polygon down to a set of triangles using a 3rd party java library. Then I'm sending these triangles to OpenGL to be rendered.

Currently I'm displaying each polygon with just one unshaded color.

What I want is to smoothly darken that color towards the edge of the polygon. That is, the closer a pixel is to the nearest point on the boundary of the polygon, the darker it should be, according to some formula relating the distance with the darkness.

I don't know what this kind of effect is called so I've struggled to find any design ideas on the web. I'm looking for any pointers or links to achieving this effect, in general terms. Even "this is known as the XYZ problem". Or any general ideas as to how I would achieve this.

Thanks