Shading and Outline OpenGL GLSL Cel Algorithm

I have successfully implemented a cel shader using glsl. But my problem is to outline everything, and every opengl example on the Internet is pretty old, does not match the current technology, so slow methods, etc. So I could not find anyway to do this in glsl. I thought of some ideas, such as coloring the least intense areas of black, but there isnโ€™t even enough explanation about gl_Vertex, gl_Position and eye positions. So, since each method is too old, I finally decided to ask someone about this problem.

+7
source share
2 answers

I would use some kind of edge detection filter on zbuffer (could potentially be combined with edge detection in the color buffer) and then modulate the framebuffer with the result (inverted). One of the most common border detection filters is the sobel operator:

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

EDIT: Another cheap way to do this is before you make a regular grid, draw a black copy of the grid with the flip reversed, and the vertices move slightly in the normal direction. This is probably what they did in XIII, I'm also sure that it was done that way in Jet Set Radio.

EDIT2: If you want the thickness of the outline to be constant regardless of the distance to the viewer, you must scale the amount by which you move the vertices with that distance.

+9
source

Have you looked at glPolygonOffset?

I used it to draw outlines on top of filled polygons.

http://www.khronos.org/opengles/sdk/docs/man/xhtml/glPolygonOffset.xml

+1
source

All Articles