- Home /
How to i share material and texture
I have a scene that consist of many types of obstacle; mountain, flat floor, box(not move) and etc.
I use plane made by 3dsmax and import into Unity, this plane is used for every obstacle in the scene. I have made transparent texture with Photoshop , 1 material for 1 texture
For example, in the scene i have 5 kinds of obstacle so i have 5 material and 5 texture. i drag material into a game objects so my plane didn't has texture UV since i didn't textured in 3dsmax
now i want to combine all these texture into one texture atlas with 1 material in order to reduce draw call.
How do i share or scripting 1 material with 1 atlas since if we make that for 1 object, another obstacle's texture will effected as well??
How do i shared or scripting material and texture by still keeping texture for each obstacle object.
ps. i have looked other questions that similar to mine but still not get an idea or understanding how to implement it.
I have try testing using 1 texure atlas with 2 sub texture, but fail "Orz.........
i created 2 box and take one material to both so both of them shared the same material, now we have 1 draw call, 2 batched now i write script /////////////////// public float textureScaleX; private $$anonymous$$aterial test$$anonymous$$at1;
void Start () { renderer.material.SetTextureScale ("_$$anonymous$$ainTex", new Vector2(textureScaleX,1));
} ///////////////////
i have set textureScaleX for each both objects , the result is both of them can show different texture that come from shared material but it becomes 2 draw call and 0 batch intend of 1 draw call and 2 batch and each of them has word "(Instance)" follow the name of material.
Answer by 3D-Magic-VR · Sep 01, 2011 at 11:48 PM
Hi there, the problem here it's the material, you can´t use two objects with the same material and try to set different parameters on each one, because if you set just to say the offset x to 0.5 in object 1 it will be reflected in object 2 and vice verse, the better way it's to use separated materials (one per object) but you can use the same texture on all of them and then set different parameters on each one.
Hopes this helps.
Your answer
