Toon shader decal?

Since I’m no good at writing shaders, is anyone willing to modify the existing Toon-Lighted shader to allow for a decal to be placed over it? I want to be able to instantiate multiple objects using the same material (better performance) but change the color at runtime.

At the same time, there are parts of the texture that I want keep color persistence, like facial features. Aaargh I’m over my head! Any help would be GREAT!

What exactly do you mean by “decal”? A second texture? Color? I was never sure what people actually mean by saying “decal”, that’s why I’m asking :slight_smile:

By the way, if you have multiple objects using the same material, it’s not going to be much faster than if they use different material. The largest bottleneck is the object (or object subset - for objects with multiple materials) count.

Even if you do use the same material but change colors of each object, Unity is going to instantiate material copies for each object. Because if one material has different color from the other one, then it’s a different material (which happens to use the same shader etc.)

To directly answer your question, I’m referring to a texture for a decal.

I guess I should explain what I’m trying to do. I want to be able to instantiate multiple parts of a creature called a Neko. There will be a dispenser for each part, and if the user clicks the dispenser, the color of the instantiated part will change. E.g. the default color will be blue, but they can click it to change it to green, red, yellow, pink, brown, etc. At the same time, the parts need to have textures that don’t change with the rest of the color, like the facial features.

I know there are performance benefits to having multiple objects share materials, so I was trying to imagine a way to have all objects share a material, but adjust the color of the material. However, if you say that this method will hinder performance by creating lots of different materials, than maybe I need to reconsider how I approach it.

I suppose I could make different initial materials for each color, and swap between materials on the mouseclicks. Then at the most there are only the number of materials I created anyway, and all objects will share them.

Any other advice/guidance?

Both approaches are similar in terms of performance. Either you modify materials on the fly (which instantiates material on the fly), or you change materials from a set of premade ones. In both cases, the objects will be using different materials.

Even if they would use the same material, it’s different objects, and the performance would be similar to using different materials.

But if you need to have different objects (as in your case, where you want to change their colors), then do what you have to do. Optimize for performance in places where you can do it.

To sum it up: wouldn’t just changing the color of existing toon shaders be enough for your needs? :slight_smile:

I guess I don’t need the decal after all :slight_smile: