Hi, I’d like to know how to approach outlining in the Material Editor using a normal material (not post processed)
Most of the solutions for outlining objects that I’ve seen use post processing materials and these work well for in first-person views, but in third-person views the outline of a mesh highlighted in front of the character cuts right across the character’s mesh as well (I think this is because of the way custom depth buffer works although I’m far from an expert on this)
Another approach I’ve seen from the “Stylized Cartoon” sample project is a post processing material that works without the custom depth buffer but is applied globally, i.e all objects in the post processing volume are outlined indiscriminately. This is not what I want either as I want to control when a given mesh is to be outlined via blueprints (think interactive objects).
The material shown here is close to what I want but seems to work only on spheres. Any tutorials on practical usage of PixelNormalWS/Absolute World Position/Camera Position nodes will also help!
One way atleast for simple solid object with a centered origo, is to clone the mesh, scale it, turn the normals inward and apply a material with the color of the desired outline on the “inverted” mesh.
There are some issues with more complex meshs, since you need to scale it with a word i can’t remember right now, think “fatten”.
A sphere expanded will expand and still encapsule the entire volum of a smaller sphere, same with a cube, and a cylinder. But if you imagine a donut, when you scale it, you will scale the hole in the center as well, not encapsulating the volume.
Ah right!
You need to transform all verticies according to the normals and then flip them, them, thats it. The scale of the outer inverted mesh will controll the thickness of the outline.
The method TheSpaceMan described can be further “enhanced” by not scaling the mesh, but by using the “push modifier” in 3dsmax instead. Usually it works better for more complex meshes, but still you may run into some issues (the higher push value you use, the more issues will appear).
Thanks all. This seems to work, I was able to get an outlined mesh straight out of Blender to UE with this approach.
The edges are a bit too jagged for my liking but I think I should be able to fine-tune things from here, maybe add a pulsing glow to the outline in the material editor.
That said, is it safe to say that post processing materials provide better performance than this approach?
Not sure if doubling the poly count of each mesh in the scene is going to scale to a complete level.
Another method I think I saw elsewhere was to attach a small post processing volume to the player and use it to outline interactive objects when the player is in range, but I’m not sure if I understood that post correctly.