Unique optimization capabilities added by the Simplygon UE4 plugin
Disclaimer: The code in this post is written on version 9.1 of Simplygon. If you encounter this post at a later stage, some of the API calls might have changed. However, the core concepts should still remain valid.
|Basic overview of what is included in the UE4 plugin|
We get a lot of questions about our new UE4 plugin and what it provides for the user? So what exactly does our plugin provide that UE4 doesn't already have? That is exactly what this blog post is about, to make it a bit more clear what unique capabilities our UE4 plugin has to offer your project.
Goodbye to engine source code modifications
This plugin does not modify any engine source code and that makes the plugin compatible with both Installed UE4 and source code UE4 out of the box. It is nothing alike our old Advanced Integration (Simplygon 8.3) where you had to merge integration code into your engine code and deal with potential conflicts. Like all other engine plugins this plugin is contained in its own plugin folder, so adding and updating the plugin in your code base is much smoother compared to the old integration.
Unreal's native simplification interfaces
We need to have an understanding of how the native simplification interfaces works and what they actually are. If we look at it from a developer's point of view there are two types of interfaces:
- Reduction interface for skeletal and static mesh LODs (IMeshReduction)
- Mesh merging interface for HLOD, Level LODs and Actor Merging (IMeshMerging)
|Native simplification interfaces which can be implemented in a plugin or custom engine module|
…and from the editor point of view the interfaces translates into these three Simplification interfaces:
- Mesh Simplification (Static Mesh LODs)
- Skeletal Mesh Simplification (Skeletal Mesh LODs)
- Hierarchical LOD Mesh Simplification (HLOD, Level LODs and Actor Merging)
|Simplification interfaces can be switched from the project settings in the editor|
The neat part of these interfaces is that they can be implemented by anyone through a plugin or by adding a custom engine module. Simplygon does indeed implement these interfaces, so why have we decided to extend our plugin with additional features or even redundant features one might think? Below are five major reasons why we decided to extend the plugin:
Accessible settings - For those that are familiar with Simplygon you probably already know that there are a lot of settings that can be tweaked and also several processors to choose between. Due to the nature of the native interfaces there is no way for us to expose more tools and settings to the user. Hence by extending the plugin beside the native interfaces we can access the full potential of Simplygon.
|Left: Native reduction settings for static meshes Right: Simplygon reduction pipeline settings|
Distribution - The native interfaces are not designed for distribution (apart from HLOD) and Simplygon has a vast support for distribution (Simplygon Grid, IncrediBuild and FASTBuild) which is supported in the plugin as well.
|Access distribution settings from editor Project Settings / Plugins / Simplygon Plugin|
Maintain the same feature set as the old Advanced Integration (Simplygon 8.3) - The old integration was developed as a mix between a plugin and modified engine code. We really wanted to keep as much as possible of the capabilities in there, so we chose to extend the plugin to match the feature set.
API for custom workflows - We also wanted to have an API around the plugin features to enable users to create custom workflows and/or to be able to adapt the plugin to custom engines.
Settings Recognition - Settings will look very similar when jumping between different plugins and integrations. Using Simplygon from Blender and then shift over to UE is more seamless.
If we put it all together we ended up developing features like LOD Recipe and Standin.
What is a LOD Recipe?
A LOD Recipe is an alternative to the native simplification interface, but also our recommended way of generating static- and skeletal mesh LODs when using the Simplygon plugin. Mainly because it integrates all highlighted features mentioned in the previous section, while adding features on top of that. It is important to know that you either use the native tool or LOD Recipe. So for example if you have a LOD chain setup with the native simplification and instead using a LOD Recipe, the settings for the native will be reset to default. The reason is that we want to avoid the LOD to be regenerated with the native simplification when cooking and instead use the LODs generated by the LOD Recipe.
Let's move forward and look into what LOD Recipe really is.
First of all LOD Recipe exist as an asset in the content browser, found under Simplygon in the context menu. It can contain both Static- and Skeletal meshes. As mentioned before this is a tool to generate mesh LODs. You can create as many recipes as you want. If we elaborate a bit on that, we can make use of it by creating LOD Groups. For example create one recipe for Large Props and another for Characters and so on.
|Overview of LOD Recipe features|
LOD Recipes uses Simplygon Pipelines (new concept in Simplygon 9) for settings and processing. This is common denominator through all Simplygon's plugins. Distribution is one of the driving features that we wanted to be supported for recipes. So each mesh and each LOD can be processed at the same time (if number of agents allows it that is), improving iteration times when regenerating LODs for your project.
Speaking of regenerating LODs, we also added a commandlet which makes it possible to build all LOD recipes from the commandline. This is important if you, for example, want to regenerate each LOD for you nightly builds. The Native tools handles this automatically during cook, but since LOD Recipes is its own tool and there is no way to hook it into the cooking without modifying engine source we need to handle it through a commandlet instead. So in a nutshell, if you wish to regenerate LODs for each cook then execute the commandlet before running the cook. Yes there is this little extra step that you need to handle, but on the other hand you can be more flexible by specifying exactly when to regenerate the LODs. To save iteration time you could, for instance, regenerate them every second night?
|LOD Recipe commandlet executed with -Help|
What is Standin?
Standin is mainly used for replacing groups/cluster of actors in your level with a Standin actor rendered with one draw call (if you choose to merge meshes and bake materials). There is no switching at a distance, instead the source actors are replaced at cook-time. The Standin tool can also be used as a kitbashing tool by saving each Standin to a standalone package. For example, to have more control over the kitbashing workflow you can create a separate level where all the kitbashed contents are setup, which makes it easier to do modifications and fixes to the content.
|Overview of Standin features|
The plugin provides you with two types of Standins: Far and Near, where Far is based on Remeshing Pipeline and Near Aggregation Pipeline. What it basically means is that Remeshing generates a new mesh while Aggregation combines source meshes. As a rule of thumb you can use Far for background geometry and Near for cases where you want optimizations closer to the camera. But of course it is up to you when to use it or not, I encourage you to play around with it. Like LOD Recipe, Standin is also based on Simplygon Pipelines so here you'll notice that settings are the same compared to LOD Recipe settings. I mentioned distribution had an important role for the plugin so Standin does of course support distribution as well.
Quick facts - Far Standin
- Pipeline: Remeshing Pipeline
- Static Mesh: Generates a new static mesh
- Materials: Always baked materials
- Other: Clipping geometry, clipping planes, NavMesh Visibility culling
Quick facts - Near Standin
- Pipeline: Aggregation Pipeline
- Static Mesh: Combines existing static meshes into one static mesh
- Materials: Decide whether to remap original materials or bake materials
- Hollow shell: Remove intersecting and unnecessary triangles that are not visible when viewed from the outside
- Other: Clipping geometry, clipping planes, NavMesh Visibility culling
|Top left: Original actors Top right: Near standin using default settings, results in 1 static mesh component and unique set of materials Bottom left: Near standin using hollow shell settings, removes hidden geometry that is not visible from the outside Bottom right: Far standin using default settings, generates a new static mesh component and bakes materials|
Lastly I want to briefly mention the API we are using when building plugin tools and I'm not referring to Simplygon API by it self but rather a Plugin API. The Plugin API can be thought of as a collection of LOD Recipe, Standin, Data Converter and Simplygon APIs. Every tool that we provide maybe doesn't fit into your project all the way, or you perhaps want to build a custom asset workflow. That is where the API comes in, to provide you with the right tools to be able to adapt to the project you are creating. A good starting point is to see how we have developed LOD Recipe and Standin. On top of this we are also working on adding Python support to the plugin which will make the plugin accessible and open for custom tooling directly from the editor (we don't have an ETA yet though).
|Code snippet from Standin showing the API(s) in action|