Sharing geometry accross meshes with different materials

Recommended Posts

Hi everyone,

I know it's possible and advised to use InstancedMesh when several meshes share the same geometry and the same material.

Is there some recommended optimization to do when two meshes share the same geometry but have different materials

For example with this case :

(here VertexData object is already loaded)

Is there something better than two calls to "applyToMesh" ? Like obj1.geometry = obj2.geometry, this kind of thing...

(my question is based on the fact that Unity explicitly share the same geometry across objects, even when Materials are different. But perhaps it's only done to optimize data packing / loading and has no impact at runtime...)

(I'm fairly sure I have already found this question somewhere, but can't remember the answer nor find where it was...)

Thanks a lot for your inputs ! Have a nice day,

Share this post

Link to post
Share on other sites

clones share the geo, but can have different materials.  Clone does deep copy most elements, but not animations.  Elements (+children) included are:

Tools.DeepCopy(source, this, 
["name", "material", "skeleton", "instances", "parent", "uniqueId", "source", "metadata"], ["_poseMatrix", "_source"]);

Do something like:

var original = whatever;
var clone = original.clone( + "01");
clone.material = someThingElse;


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.