A renderer material mask can't store more than 128 materials

I’m encountering A renderer material mask can’t store more than 128 materials. every time I try to build my game. What is causing this issue and how can I fix this or bypass the limit of materials?

Why do you have more than 128 materials on a single renderer?

2 Likes

Is it really that unheard of? I have a project where I was provided with a detailed Sketchup .skp file with 167 materials used to create an indoor space. This works fine in anything prior to Unity 6. In Unity 6 I get the error “A renderer material mask can’t store more than 128 materials”. Is there any way around this aside from paying for, downloading, and learning Sketchup (while sticking with Unity 6 for its improvements)? I hope so.

This was the case before Unity 6. Look at the dates on the post you’re replying to. And yes, it is pretty unheard of to have that many materials on a single renderer. 128 materials on a single renderer is so many that it’s effectively absurd for a game engine.

1 Like

I appreciate the reply. Admittedly, I am new to Unity. So my terminology here might be off, but here are my steps:

New Unity 2022.3 URP project:

  1. Drag Sketchup .skp into Assets.
  2. Check “Generate Colliders” apply, “Extract Textures”, “Extract Materials”
  3. Drag Imported Sketchup into my scene.
  4. Select imported object in scene, shows 167 materials used. No errors or alerts.
  5. Build, run. Runs perfectly fine.

New Unity 6 project:

  1. Drag Sketchup .skp into Assets.
  2. Check “Generate Colliders” apply, “Extract Textures”, “Extract Materials”
  3. Drag Imported Sketchup into my scene - Red alert: “A renderer material mask can’t store more than 128 materials”.
  4. Select imported object in scene, shows 167 materials used.
  5. Build, errors out as expected.

So, in my case, this was working perfectly fine before Unity 6. In fact, this is such an uncommon error that if you search Google for "A renderer material mask can’t store more than 128 materials.” there is one link - this thread. So it must be either very rare or new. I guess I’m not understanding what I am doing wrong then.

If you have any pointers or reading I can do for this issue, I’d love to read about them. If I need to divide this Sketchup into separate entities, then that is what I will do, but I can assure you this was working before.

It IS rare because people generally don’t put 128 materials on a single renderer. The renderer material mask is an 8 bit integer. Most people using multiple materials per renderer will have MAYBE a maximum of 3 materials in a single mask because past that point you’re better off finding a way to make that a single material through proper shader use.

Break your scene up into multiple objects with individual materials. A scene should not be a single object with a massive list of materials on it. This is the worst way to do things and even back as far as I remember, which is around Unity 4, you were recommended to use a single material per renderer unless it was absolutely necessary you did otherwise.

1 Like

Again, I appreciate the (rapid) response. I think your answer is what I was looking for. The model I was provided was basically one giant mesh, which is a giant pain to work with anyhow. I don’t really think they know any better. I guess its time to get my feet wet in Sketchup then and break this down. Why it was working in previous versions, I do not know, but at this point that doesn’t matter.

Cheers!