GLSL - Advanced Cartoon Shader

I'm making a port of a GLSL routine to QC - an "advanced cartoon shader"- available in my Box downloads; "Advanced Cartoon Shader.qtz"/

It does a kind of color averaging that gives a mellow cartoonized look, and also, by virtue of a skew horizontal/vertical routine working alongside the color routine, has the side effect of giving a kind of edge emphasis as well. Note the nice, prominent, edge outline on the neck of my Telecaster.

On my GPU (nVidia 9600), it is pretty ridiculously speedy (60+fps). Any bottleneck is the video object, more likely than the imaging routine (speculation). 60+fps is fairly comfortable performance wise, though.

I picked the basic routine up off of a graphics mailing list a year or so ago. The attachment has been adjusted so that texturing happens correctly in QC, instead of the "flipped" texture that would result from the default routine as originally posted.

Note - Removing the abs from the fragment shader will result in some looks similar to the CI Edge Work, but turn your source black and white first. Anyone who has used CI Edge Work knows how ridiculously slow it can be. This result isn't exactly the same, but similar enough to be very useful. It has the visual result of intensifying the disparity between dark and light pixels, in a really heavy handed way.

So, in the fragment program, replace:

float d1=dot(abs(c00-c22),dt);
float d2=dot(abs(c20-c02),dt);
float hl=dot(abs(c01-c21),dt);
float vl=dot(abs(c10-c12),dt);


float d1=dot((c00-c22),dt);
float d2=dot((c20-c02),dt);
float hl=dot((c01-c21),dt);
float vl=dot((c10-c12),dt);

The black/white picture at the top was created by removing abs, turning source to black and white, and inverting, before sending to GLSL. Note that because of the x/y offset nature of the GLSL program, it turned one side of my face and body the exact color invert of the other. This premise can be useful for certain types of image analysis that require id'ing locales in an image, when taken further.