Cartoon outline shader

Hi,
there are a few outline techniques on the forum but none of them really work that well for what I need.

  1. Duplicate model, set to black and scale technique - Doesn’t really work for complex models and uses too many tris.
  2. Normal based shaders - Nice outline but varies with objects shape and can’t be used for ground and flat stuff.
  3. Depth based shaders - Give a great outline, the problem is that intersections between models don’t get the outline, like characters feet in my game.

If you know how to write shaders please let me know !

Sdfgeoff had a thread about a node shader - it made a outline from a mesh, I am not sure if it could be used to make a tune shader but maybe, I will have to dig, but I have some stuff to do brb.

Why are you even making a post if you don’t have anything to add to the topic?

He did have something to add - he might have a solution, but he has to look for it.

As for the outline, if you use a depth shader, you could also outline objects based on difference of color, along with difference of depth. That way, unless the object your player’s standing on has a similar color as the player itself, the outline would be created.

@Solar
I want to compare vertex colors only, no depth.

Sent from my LG-H440n using Tapatalk

This?



/**
 * Toon Lines shader by Jose I. Romero (cyborg_ar)
 *
 * Based on blender's built-in "prewitt" filter which is free software
 * released under the terms of the GNU General Public License version 2
 * 
 * The original code is (c) Blender Foundation.
 */
uniform sampler2D bgl_RenderedTexture;
uniform vec2 bgl_TextureCoordinateOffset[9];

void main(void)
{
    vec4 sample[9];
    vec4 border;
    vec4 texcol = texture2D(bgl_RenderedTexture, gl_TexCoord[0].st);

    for (int i = 0; i < 9; i++)
    {
        sample<i> = texture2D(bgl_RenderedTexture, 
                              gl_TexCoord[0].st + bgl_TextureCoordinateOffset[i]);
    }

    vec4 horizEdge = sample[2] + sample[5] + sample[8] -
                     (sample[0] + sample[3] + sample[6]);

    vec4 vertEdge = sample[0] + sample[1] + sample[2] -
                    (sample[6] + sample[7] + sample[8]);

    border.rgb = sqrt((horizEdge.rgb * horizEdge.rgb) + 
                            (vertEdge.rgb * vertEdge.rgb));

       if (border.r &gt; 0.4||border.g &gt; 0.4||border.b &gt; 0.4){
        gl_FragColor.rgb = 0.0;
        gl_FragColor.a = 1.0;
    }else{
        gl_FragColor.rgb = texcol.rgb;
        gl_FragColor.a = 1.0;
    } 
}


[I]If it doesn’t work there are modified versions also

here is a simple node setup for toon outline, probably want to change the base material too

and an example from bge

For some reason this code doesnt work well under windows 10. it colors the whole screen to black… but on windows 7 its fine o.o do u know the reason?

That is exactly what I was talking about

bro, calm yourself. he’s just trying to help.

what was that node “Dot product”?

nvm: is vector math