Using CC3 LODs with strand-based hair in UE4

Aug 19, 2021 at 06:00 am by nemirc

Last week I discussed how to use LODs from Character Creator 3 into Unreal Engine. That time I covered different alternatives depending on your setup, and I also mentioned you may need two separate meshes if you are using strands-based hair for your characters (which is my case). I continued working on my project and now I have a setup that swaps between those two models (the hairless model and the polygon-hair model). I also have a setup that detects the size of your character on your screen, so you can swap between one or the other.

Swapping the model requires a special consideration. If you just swap the model according to the distance, the model’s animation will reset. In the case of my enemy, his idle animation makes him look left and right, but when I walked away to make the LOD switch, I noticed the idle animation reset. If he was looking to the side, the switch would cause to look at the front and restart the animation.

To solve this, I am using a base skeletal mesh to drive the actual gameplay mesh (in this case, the base skeletal mesh is the same as the high-resolution character). In the Unreal Blueprint’s construction script, I did this:

The “Actual Mesh” is a Skeletal Mesh component I created as a children to the Mesh(CharacterMesh Inherited) component of my pawn. The “ActualSkeletalMesh” is a variable that holds a reference to the Skeletal Mesh that is displayed in the game (in this case, this variable will control which mesh to display, the hairless or LOD version). Then, the Set Master Pose Component node is a node that tells the ActualSkeletalMesh (Target) to copy the animation of the other Mesh.

Then, in the Event Graph, I created this other network. Basically, the Branch node is checking a condition to know which model to use (the hairless model or LOD model), as well as setting the strands-based hair visibility (visible when using the hairless high-resolution model when close to camera, but hidden when using the LOD model which has polygon-based hair). As you can see, the Set Skeletal Mesh node is pointing at the “ActualSkeletalMesh” variable, and the NewMesh setting points to the specific mesh to be used. Supposedly, if we set the “Reinit Pose” checkbox to False, the animation shouldn’t reset (the issue I mentioned above). However, I don’t want to take any chances.

And this is the Branch setup that defines which model to use. You can see I am performing a comparison between a variable called LODChange, which has the value I have defined for the change (in this case, 0.3), and a variable called MeshScreenSize, which is a value I get from a setup. What I am doing is getting an approximate value of the object’s size on the screen, and then comparing it to a value I set (again, 0.3 in this case) to cause the switch.

Getting that MeshScreenSize is a little more complicated. First, I need to get the distance between my character’s camera and the enemy (you can also get the distance between your character and the enemy, but the other method is more accurate). To do it, you can use the setup below.

Then, you need to calculate the Sin (in degrees) of your camera’s FOV.

Then, you multiply the distance, the Sind(FOV) and 0.5 (the 0.5 is a value I found through testing).

Then you divide your SkeletalMesh bounds radius by the result of the operation above, and save that as your MeshScreenSize variable. This still has a small margin of error, but it gives you a pretty good result so you can know when the LOD is going to switch.

And this is a video of the LOD swapping in actioni!

I hope you find this useful.


Sections: Tips + Tutorials

This website uses cookies to ensure you get the best experience possible More Info
Got it!