[SOLVED] SEVERE: Material instances cannot be shared when hardware skinning is used

HI Guys…

Im trying to migrate from jme3.0 to jme3.1 (built from master)… IT was going pretty well but im stuck with this log line

Mar 11, 2017 9:11:03 AM com.jme3.animation.SkeletonControl controlRenderHardware
SEVERE: Material instances cannot be shared when hardware skinning is used. Ensure all models use unique material instances.

I don’t actually use .clone and i don’t get an UnsupportedOperation exception like others have claimed in this forum…
I also cant see any problem in the ui as animations seem to render correctly… But the log line keeps printing several times a second and that is slowing down my game…

I do have several models using the same material file as per this video (which i really liked)

So i woudnt have thought that meant it was using the same material “instance” just because it was using the same material “file”

I remember having that same problem and needing to rebuild the .j3o of my skinned Blender model to fix it.

I had this problem when applying once instance of a material to multiple spatials.

See if you’re doing something like:

Material material = someMaterial;

Spatial s1 = someSpatial;
Spatial s2 = someSpatial;

s1.setMaterial(material);
s2.setMaterial(material);

HI Guys…
Unfortunately no luck…
if don’t do the material thing…

Material material = someMaterial;
Spatial s1 = someSpatial;
Spatial s2 = someSpatial;
s1.setMaterial(material);
s2.setMaterial(material);

I don’t load materials at all
i just do

(Node) assetManager.loadModel(model.getModelPath());

and i manually changed all the j3o files to use the same material file. Through the scene composer. I also tried re-importing all animated assets… But that does not seem to resolve the issue…

SkeletonControl skeletonControl = geometry.getControl(SkeletonControl.class);
skeletonControl.setHardwareSkinningPreferred(false);

does resolve the issue. And it also is not a issue in jme 3.0

1 Like

Yes, because hardware skinning was not the default in 3.0.

Normally, even if a model uses the same material file as some other model then it will be fine when loaded. You should put together a simple single-class test case that illustrates the issue… including a j3o file.

I’ve personally tested this many times and it works fine.

Oh, I suppose it is good to double check which version of the engine you are using. It’s confusing because you said you “built 3.1 from master”. But master is not 3.1.

right so…

i checkout
master branch of
git clone GitHub - jMonkeyEngine/sdk: The jMonkeyEngine3 SDK based on netbeans
and when i run
./gradlew run
it looks like 3.1

I did a single class test and its not giving this log message… SO must be something im going… What i men’t was
in 3.0 had enabled hardware skinning on my characters by doing

skeletonControl.setHardwareSkinningPreferred(true);

and i wasn’t getting this error. And now in 3.1 i am…
and when i set

skeletonControl.setHardwareSkinningPreferred(false);

on my characters i stop getting it… Ill continue my investigation…

The SDK is not the engine. I don’t know how it decides what the bundle but it might be whatever engine you’ve built before.

You can short circuit a lot of your own investigation if you post a simple single class test case the exhibits the issue. 9/10 times it will work fine and then you can figure out what’s different about your game/setup that makes it fail.

1 Like

SOrry guys… … Just when through where the error was comming from and i found a rouge .clone(false)… Just remove that and everything seem to be fine… And my game is running significantly faster…
Awesome work on 3.1 (which somehow i seem to be running)
Thanks once again for all your help!

1 Like