I'm trying to create an inner glow effect for a triangle fan primitive using GLSL ES 2.0 - though only the outer edges are to be subject to the effect at hand. I guess there are many ways to do this, but haven't found any description so far.
There is the technique described in Make the edges of a textured polygon glow in OpenGL ES 2.0, however, this doesn't work for me as I'm working purely with primitive at this stage.
My initial thought was to somehow calculate the distance to the nearest edge in the fragment shader, and then set the color according to wether or not the distance falls within the bounds of some threshold value or not. (Of course, the color and alpha is to be a function of the distance from the nearest edge - the exact gradient profile is not important at this point.)
This approach poses two problems:
1) How do I calculate the distance from a fragment to the nearest edge? 2) How do I exclude common edges in this process, i.e. edges that are common to two (or more) triangles?
Is this a sensible approach, and if so: how do I resolve my two issues? Suggestions for alternative approaches are also greatly appreciated. (For instance, I've been reading that texture data need not be an image, and that it may be utilized for custom purposes. Could a non-image texture be part of the solution?) :)
To answer your two questions, I don't think there is any glsl magic that will do this for you. By the time you get to the fragment shader, there is no longer any information available about edges, especially trying to segregate true edges from internal edges.
What I recommend is to add more vertices to your fan, and use a new custom attribute to define the 'glow level'. See image for example, I would put a row of vertices around the edge, define these (and the center of the fan) to have maximum glow, and then define the edges to have zero glow, and then you can get an interpolated glow value between the edge and the new vertices.