Introduction
Outlines are a great way to add visual interest to your designs, but creating them in Unreal Engine can be a challenge. In this blog post, we’ll explore an alternative way to create outlines without the need for a postprocess material.
You can check the Unreal Plugin page for more informations.
Outlining with post process
Postprocess materials are still the most efficient way to create outlines in Unreal Engine. They offer a variety of options, such as adjusting the thickness and color of the outline. Additionally, postprocess materials provide a more consistent look, as they are applied to the entire scene, rather than just individual meshes. Postprocess materials also have the advantage of being more flexible, as they can be easily adjusted and tweaked to get the desired effect. Ultimately, postprocess materials are the best way to achieve outlines in Unreal Engine.
Why not to use a post process
When a post process cannot be an option because too expensive (speaking of performance), or because not supported (some mobile devices). Then we need another option that will obviously have some drawbacks compared to using a postprocess.
Outlining with a mesh with inverted normals and scaled
Another way to create outlines in Unreal Engine is to use a second mesh with inverted normals and scale it a little bit bigger. This method allows you to create outlines without the need for a postprocess material. However, it is important to note that this method can introduce artifacts, such as jagged edges, and it may not always be the best approach for creating outlines.
When using the mesh with inverted normals and scaled approach to creating outlines, one of the major drawbacks is that the outlines will be offset based on the pivot of the mesh.
Outlining with a mesh with inverted normals and vertex offset
Another approach to creating outlines without the need for a postprocess material is to use a second mesh with inverted normals, and then apply a vertex offset with multiplied vertex normals. This method can be used to create more organic-looking outlines, as it is able to create more subtle details and shapes.
This method of creating outlines can sometimes result in a fragmented outline.
Outlining using average vertex normal
A vertex normal is the normal of a face that is adjacent to the vertex. In a 3D mesh, each vertex has a number of vertex normals corresponding to the faces connected to it. These vertex normals can be used to calculate an average vertex normal for the vertex, which can then be used as vertex offset instead of the vertex normal.
Unfortunately, it is not possible to calculate an average vertex normal in a shader. This means that the vertex offset approach cannot be used to generate outlines in real time. However, it is possible to pre-compute the average vertex normals and store them somewhere, which can then be used as an offset in the shader. This approach can be used to create outlines in real time.
One solution to store the average vertex normal is to use vertex colors. Vertex colors can be used to store data that can then be accessed in the shader. By computing and storing the average vertex normal in the vertex colors, it can be used as an offset in the shader to generate outlines in real time.