Protecting selected materials
Written by Samuel Rantaeskola, Product Expert, Simplygon
Disclaimer: This post is written using version 10.3.6400.0 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.
Introduction
In this blog post, we will guide you through the art of safeguarding specific materials during mesh reduction. Imagine scenarios where preserving intricate details, such as character faces or dynamic materials like cloth, is crucial to maintaining the overall visual appeal of your 3D models.
While excluding entire sub-meshes with a single material is a straightforward approach, the real challenge arises when you need to protect specific materials within a mesh containing a mix of both protected and reducible elements. We will explore the intricacies of vertex locking — an invaluable tool that empowers you to selectively preserve the essence of your 3D creations.
Many concepts we will use in this blog has already been explored in Protecting features using vertex locks and weights.
Problem to solve
For this blog we will use Unity Chan as an example. It's a rather low poly asset and we are going to reduce it to 50%. In order to maintain fidelity where it's most important we are going to protect the face and eyes. Here it is before reduction.
Solution
The face and eyes are using these materials:
- unitychan:chan:m_face
- unitychan:chan:M_eye_L
- unitychan:chan:M_eye_R
We will device a script that finds the material ids for them and then loops through the verts, locking the ones that are assigned to any of these materials.
Material name to material ID
First we are going to create this little function. It finds the ids of the materials you want to protect and returns a list of protected material ids.
Protecting verts
We will be using code that is very similar to the blog linked in the introduction. The only real modification is this little code snippet:
Results
Now we have everything we need to run the process on our test model. Here are the results: