Cel Shading - How To: Border Detection

Hey all!

I’d like to make toon outlines in the BGE, but just don’t know where to start.
My plan is editing the rendering process, but I don’t know whether I need to implement it in the BGE itself, or if I can access it through scripting.

Btw, here is what I want to do: (separately for all objects)

  • first render the backfaces of the objects with thick (thicker than normal) black lines
  • then render the objects normally

Thank You for reading.

Just copy your mesh and scale it with Shift+S. Then apply a black material to it…

just returning to blender after a few years… but if im not mistaken there was a toon shader that actually did something like that?

Becase duplicating your mesh and scaling it seems a Little innecesary high poly…


this is the shader that BlenderRenderSky uses… and he’s super cool, so you know that it will work.

What license is it?

free. he posted it because someone asked. check out the original post.

Been playing around with those shaders you recommended.

Still, couldn’t effectively (I mean without raising GPU computing time greatly) get a nice smooth outline.

Still, I’d be glad, if someone could point me to the right direction to alter the rendering process.

short and sweet…no idea whos it is

 uniform sampler2D bgl_RenderedTexture;
    uniform sampler2D bgl_DepthTexture;

    void main()
       float depth = texture2D( bgl_DepthTexture, gl_TexCoord[0].xy).r;
       float depth2 = texture2D( bgl_DepthTexture, gl_TexCoord[0].xy + vec2(0,0.002)).r;
       float depth3 = texture2D( bgl_DepthTexture, gl_TexCoord[0].xy + vec2(0.002,0)).r;
       float fac = abs(depth-depth2) + abs(depth-depth3);
       float intensity = 9050;  

       vec4 sub = vec4(fac*intensity,fac*intensity,fac*intensity,0);
       gl_FragColor = texture2D( bgl_RenderedTexture, gl_TexCoord[0].xy ) - sub;
    #change float intensity