Is there a shader to only add an outline?

The toon shaders have outlines, but also change the shading of the object. I'd like to show an outline without affecting the rest of the shading. Also if possible, only show outline around the perimeter of the object and not on edges in the middle.

I have no idea how to program shaders, so if anyone knows how to do this or can point me in the direction of a shader that already exists, I would appreciate it greatly. Thanks!

Peter, I'm not sure what you mean by those options in comparison to each other. I just want a model to look normal (such as the standard diffuse or diffuse bump shader, except with an outline around the whole thing. You see this kind of effect in a lot of games, such as when the mouse is pointing at the object being outlined.

Old post, but also highest ranked on google for this topic. I just spent several hours writing a geometry shader that's much improved compared to a toon or silhouette shader by taking every edge in the mesh and turning those edges into quads rendered facing the camera. This means that it works on cubes in a satisfying manner. Be aware that this is not a mobile-friendly shader, due to using the stencil buffer and rendering the object twice, and requires forward lighting. It also does not render the object itself, just the outline (due to my own needs) but should be easily modifiable to render the original mesh as well.

Note that because verts are supplied going clockwise around the surface normal, single sided quads will only render 3 edges (the other two are facing away from the camera). Similarly, at hard corners, the corners will be noticeably thinner than other areas, but this is only a problem at very high thickness values (greater than 10, which is pretty darn thick). This has to do with the quad's corners not being fused with the neighboring triangle's quads.

Both of these problems are technically solvable, but wasn't worth the effort for my use, due to only being apparent in edge-cases I wasn't going to be using. The former can be solved by rendering the front and back face of each quad (and correspondingly increasing maxvertexcount by double). The latter might be solved by using triangleadj in the geometry shader portion, instead of triangle, and calculating intersection points. See: https://msdn.microsoft.com/en-us/library/windows/desktop/bb509609%28v=vs.85%29.aspx

If there's an issue with it rendering strangely, swap float4 parallel = end.pos-start.pos; for float4 parallel = start.pos-end.pos; which I had to do when I merged this shader into another for use as a replacement shader that handles particular special rendering effects. Why? No idea.

@$$anonymous$$raco18s this shader is great. Seems to be the best solution I've found so far, but unfortunately in Unity 5.4 beta, it doesn't render correctly in Game view. As @$$anonymous$$eonalchemist found, Legacy Deferred is the only render mode that works. Do you have any ideas about how to get it working again in Forward mode?

Yeah the strange thing is it also seems to be doing something in forward rendering mode. Not 100% sure, just basing this suspicion on the fact that it won't work in forward mode, but will work in deferred mode standard shader without the deferred pass.

Took me a couple of days to write it, having to learn several things about HLSL. Hope you make good use of it, as far as I know it's the only freely available outline shader out there that isn't a simple scalar (which is precisely why I wrote it).