Download

Hide Material Element / Slot / Subset

I’ve been searching all over for an answer to this question, and have found several attempts at the question, but with no solution other than using transparency.

I have a mesh (static/skeletal) that has multiple material elements. I simply want to stop rendering one or more of those material elements at run-time, via a blueprint. I know there are methods to make material elements transparent, but this would not be ideal for a case where many characters are wearing several parts of clothing and hiding 3-10 subsets of each outfit on each character. If the engine still needs to execute a draw call, this would get expensive very quickly.

This seems like a really simple action - to turn off a material element. Surely there is a way to do this? As far as I am aware, the engine must execute a specific draw call for every single material element (unless it optimizes when they share materials), so it would be as simple as not executing that draw call when the state is toggled.

If this is not possible, how do robust games hide parts of characters when those parts are covered by clothing or get cut off?

I am very new to Unreal, but have experience with raw C++ game developed. I created a custom game engine that used this effect for hiding parts under clothing. So I’m wondering how other devs are accomplishing this in games if this action is not available?

Thanks for any advice!

Instead of including all of the parts in one mesh, you would need them to be separate objects that are attached together, then you just remove that object entirely.
For example, the head of a character is a completely separate object than the body.

Okay, I see. Unfortunately, the characters I intended to use have a great deal of material elements. The skin mesh is split at the ankle, knees, thighs, waist, chest, shoulders, elbows, forearms, wrist, neck, and head. I may want to rethink this if I have to connect all of these parts as separate objects for every character. In my previous engine, the parts were all combined and rendered together as a single draw call whenever possible. But I doubt this will ever be possible if they are disconnected entirely into separate objects.

Does anyone know how difficult it would be to intercept the actual rendering calls for skin meshes and skip rendering certain material elements? Like I said, I’m very new to Unreal, so I don’t know much at all about mixing C++ with blueprints. Would something like this be possible? And if so, how difficult would it be? I am not yet looking for the solution - just knowing it can be done reasonably is enough for now. If not, I need to rethink my character setup. Probably condense it down into modern sections (shoes, pants, shirt, gloves, head).

Thanks!

You can’t do that in a single draw call, each separate material adds another draw call

In my custom engine, I rendered everything that existed in the vertex buffer together. And I tried to group vertices based on their connected polys. So the hands would be next to the forearms in the vertex buffer, for example. Then if clothing covered the forearms, the hands would be rendered in a separate draw call. If the forearms were not covered, the vertex buffer region would be expanded to include both the hands and forearms so they can both be rendered in a single call.

If something like this is not possible inside of Unreal (C++ or blueprints), how big of a performance hit will it be to have around 22 separate skin mesh parts/renders per characters? Obviously, they will be small sections, like a hand or a forearm. But one of the issues I ran into inside of my engine was having to upload ALL of the bones for every render. I eventually managed to set it up so that the bones were all uploaded to the shader on the first render and were kept intact until the character skin and clothing were all fully rendered. Any idea how Unreal will handle this?

The reason I’m asking is because I’m at the point where I’m setting up my character components, and I want to figure out how many areas to use. Fewer will obviously be better for performance and worse for flexibility. And I know how much flexibility I will lose as I remove section splits. I’m just wondering how much performance I will lose as I add them.

Thanks again for your help!

You can use “Show Material Section” function on Skeletal Meshes:

http://prntscr.com/of3m66

However as far as i am aware there is no such functionality for Static Meshes, sadly.

Even if for example you have a single mesh broken in to 5 material ID slots BUT all just using the same material.
Just for having the ability to selectively hide them to make them appear gone.
As just one material is being called in to memory, would it not instance them? or could it not be material instances ?

I ask because I am testing this method out right now with many other types of Gore / dismemberment setups and I find if you break the mesh up in to seperate parts it leaves obvious seams, Unless your clever about the placement.
But I found using material IDs EG: slots made the seams almost invisible

If you’re doing a character and you want to have interchangeable outfit parts, you need to split those into separate items and then attach them with sockets, so instead of hiding things you would be switching them out entirely.

I would think that using the same material in multiple slots would not add draw calls, but hiding parts of a mesh that way would still have that geometry in memory, so if you’re trying to hide parts of a mesh by material ID then those parts are still going to be in memory even if they aren’t visible since they’re part of a mesh that is visible.

If you’re concerned about seams on a mesh, you can either hide them (like the arm is inside a sleave) or you would need to set up you mesh normals in your 3D software so that they aren’t affected when the polygons are split. For example, in 3ds Max you can use Explicit Normals to where if you were to detach polygons from a rounded mesh it wouldn’t change the normals once those vertices aren’t connected, so it would still look like one mesh.