Facets don't work correctly with skeleton animation

Hi. I’m running into a problem that facets are not behaving correctly when skeleton animation is enabled. Works correctly if you update the facets before play the animation

I will be glad to any help

1 Like

It’s not an issue related to skeleton animation but to transparency.
I guess splitting the model in subparts so it can be sorted back to front would help.
cc @PatrickRyan

I concluded that the problem is because of the skeleton animation, because if you disable it, everything works as expected

@Vladislav_Zhidko, one thing I will suggest for your materials is to separate out any materials that have transparency from those that are opaque. This means you will separate your meshes by transparency as well. You could use multimaterials to assign multiple materials to the same mesh, but I find it cleaner to just separate meshes by transparency if it’s for a character because you won’t have an explosion of draw calls since transparency is likely isolated to fewer triangles that opaque triangles. The reason is that depth sorting become much easier.

Consider this render:

On the left is one mesh, sphere and icosahedron combined using one transparent material. No matter what orientation you rotate the camera to, the icosahedron will always render over the sphere as they are in the same sort order being one mesh and material in all cases.

The center is two meshes both sharing the same transparent material. They will change sorting order depending on the angle of the camera because of rounding. Sometimes the icosahedron will be in front and other times the sphere will be in front. You can see here that the sort order changes at this rotation:

The meshes on the right of the original image are two separate meshes each with their own material. The icosahedron has an opaque material and the sphere has a transparent material. In this way, the sort order will always be correct as the opaque meshes are drawn first and then the transparent meshes are drawn. So this one is stable in terms of sort order in all rotations.

From an optimization stance, you will always want to separate meshes that are opaque from those that need alpha transparency from the standpoint of minimizing overdraw. If you have most of your character rendering with an alpha of 1.0, you are still drawing all of those pixels twice. This is because we will draw all opaque meshes first and then draw any meshes with alpha over the top of the opaque meshes. So the area that the boots of your character occupy on screen are always drawn twice. The ground will be drawn without the boot as opaque, then the boot will be drawn at full opacity over the ground. Had you separated the opaque parts of your character from the transparent parts, the boots and ground would be drawn at the same time and you would only draw pixels representing the boots once.

Let me know if you have questions about this.

2 Likes

Thank you for the detailed response. I also understand that the best solution is to separate materials into transparent and opaque. But the thing is, I’m developing a model previewer, and this model was made by an independent person, so I need a solution that can correctly display any model. IOT works for me as needed, but unfortunately, it doesn’t work on mobile devices, so I tried using facets and ran into this problem.

1 Like

@Vladislav_Zhidko, I appreciate the extra context. It’s always difficult to know how much detail to include on a response as there is usually some context we are not aware of. I tend to err on the side of giving more information about best practices knowing that others will read the thread and maybe the detail will help someone else even if it’s not applicable to the thread in cases like this.

1 Like

Facet sorting does not apply deformations from morph / skeletal animations, as this would tax the CPU even more. As a result, the facet order is that calculated without morph/skeletal animations, which explains why there are more artifacts when the latter exist on a mesh.

I can’t really think of a good way to correct this, except by subdividing the mesh into opaque/transparent sub-meshes as @PatrickRyan explained (and even then, you’ll probably still get artifacts)… There are lots of methods for OIT, but none of them are foolproof and they all have their drawbacks / failures depending on the complexity of the scene.

1 Like