# Material optimization/organization

**URL:** https://discussions.unity.com/t/material-optimization-organization/119588
**Category:** Questions & Answers
**Created:** [October 16, 2014, 12:17am UTC](https://discussions.unity.com/t/material-optimization-organization/119588 "2014-10-16T00:17:07Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Siccity](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/siccity/32/503354_2.png) [@Siccity](https://discussions.unity.com/u/Siccity)
#### Post date: [October 16, 2014, 12:17am UTC](https://discussions.unity.com/t/material-optimization-organization/119588/1 "2014-10-16T00:17:07Z")

</div>

I have a lot (over 100) of models that the user can add to a scene. Most of these models share generic metal materials to reduce the amount of different materials I’d have to modify to change all of them. However, I want all my models to use different normal maps. The base materials for all of these models will still be the same, steel, brass, gold, iron etc… One way to do this would be copying the generic materials for each and every model and then assign the desired normal maps, but that’d result in a near endless amount of materials to modify if i want to make a small change in the overall iron shader.

Is there any way to make materials derive from another material, sort of like a hierarchy? I am targeting computers, so draw calls isn’t the biggest issue

![33749-example.png](https://europe1.discourse-cdn.com/unity/original/3X/6/b/6b9a3516216a68ac01b1a378602a1f4b472a47bb.png)

---

<div class="post-metadata">

### Author: ![KpjComp](https://avatars.discourse-cdn.com/v4/letter/k/85f322/32.png) [@KpjComp](https://discussions.unity.com/u/KpjComp)
#### Post date: [October 16, 2014, 1:28am UTC](https://discussions.unity.com/t/material-optimization-organization/119588/2 "2014-10-16T01:28:47Z")

</div>

Yes, I’ve knocked up a script to get you started.  
This currently allows you to alter the Textures, but you can modify to add other stuff you want to override. Basically set a Source Material that you want to descend from, and a destination material you want to save to, you can then override the textures for Diffuse, Normal and ReflectionCube.

Hopefully this will help, ps it also works in editor mode. Basically attach this script to an EmptyObject and maybe say called it MaterialBuilder or something like.

```
using UnityEngine;
using System.Collections;

[ExecuteInEditMode]
public class MaterialBuilder : MonoBehaviour {

	public Material Source;
	public Material Dest;

	public Texture DiffuseTexture;
	public Texture NormalMap;
	public Texture ReflectionCubemap;

	void updateMat() {
		if (Source == null) return;
		if (Dest == null) return;
		Dest.CopyPropertiesFromMaterial(Source);
		if (DiffuseTexture != null) {
			Dest.SetTexture("_MainTex", DiffuseTexture);
		}
		if (NormalMap != null) {
			Dest.SetTexture("_BumpMap", NormalMap);
		}
		if (ReflectionCubemap != null) {
			Dest.SetTexture("_Cube", ReflectionCubemap);
		}	
	}

	// Use this for initialization
	void Start () {
		updateMat();
	}
	
	// Update is called once per frame
    #if UNITY_EDITOR
	void Update () {
		if(Application.isEditor) {
			updateMat();
		}
	}
    #endif
}

```
