Help with Cel Shader with Outlines


I’m trying to create a shader in order to render my scene with cel shading and with styled outlines.
I know how to make the shader for cel shading but I don’t understand how to make outlines like in blender with the freestyle option activated.

Render on Blender on a simple cube :

And on a more complicated scene :

If someone have know any way to do a similar render…

Thanks a lot,


Am I the only one confused by what the intent here is? aside from the cel shading…

Hum sorry if I wasn’t clear enough.
On first and last picture you can see the black outlines on edges (not all) of 3D objects. The same on the second picture are yellow for good understanding.
The render is made with blender when you tick the freestyle option.
As you know, we can’t export render or materials as a hlsl shader usable with Monogame, also I must develop my own shader.
This shader is composed with a cel shader and those black outlines. I know how cel shader work but I don’t understand how I can do the black lines.
If someone know how to do that or know a good website where I can find some more explanations …


How to implement the outlines depends on what outlines you want to show exactly. Blenders freestyle option let’s you select any edges? Is that what you want?
One way to get the outline of the cube as shown is to run a filter to detect depth buffer or shading normal differences and black out matching pixels.
I’m not sure how edges are picked in the second image. Is that done by hand?

I can think of a easily way to draw all the edge lines just wireframe draw to a clear rendertarget with backface culling on. Then shader that to the scene with some thick drawing shader.

Ya that is pretty weird outlining, wonder what the rules are for it.

This might help :

I used that approach and it works pretty well:

PS: that screenshot is without the saturation attenuation discussed in the paper…

Sorry for my late reply, I was working on the physics of my game.
Thanks all for your help.
I will give you news if I can make a good effect :slight_smile:

I think there is no solution for now. I think without geometric shader, I can’t do what I want.
For now I’m just using a shader for cell shading and I use a postprocessing shader in order to draw outlines.
It isn’t the result I expected for but It do the job…

There is shader and code somewhere for lines on net.

You can flip your face culling mode and offset along the normal in shader if the mesh is continuous. Much easier than the other toon related problems like sliding mouths off to the side.