Custommaterial and importmesh

so erm, weird thing I found. I think its my codes but any help would be appreciated. When the scene has native bjs meshes and imported mesh, assigning custom material on all meshes works only on the native meshes. If I comment those out, the imported meshes get the custom material too.

PG repro here: https://www.babylonjs-playground.com/#UXCB15#59
comment out line 66 & 68 to see the difference. erm, what am I missing here ?

ok, i figured out that the rabbit has a skeleton, setting rabbit.skeleton = null works. So I tried it with the candle babylon mesh instead. And now I can’t get it to work at all.

https://www.babylonjs-playground.com/#UXCB15#60

Any ideas?

https://www.babylonjs-playground.com/#UXCB15#61

hey we don’t catch the error yet that is alternative plan for yet

1 Like

well, it works on the babylon logo when vertex colors are switched off, so I dunno why it sometimes works, sometimes does not…giveup

ok, I see what you did, is this gpu intensive ? I think its reloading textures per material assignment…

BABYLON.SceneLoader
that not work for mesh created with BABYLON.SceneLoader if you set it before to other mesh

that is absolutely heavy form one instance but texture is load one time a in GPU too (i guess)

ok, I don’t get it. What do you mean by ‘that not work for mesh created with BABYLON.SceneLoader if you set it before to other mesh’. I can’t assign custom materials to multiple meshes in sceneloader ?

like in this PG ? https://www.babylonjs-playground.com/#UXCB15#64

i see yes that is why i told we have problem with scene load
that not happen in shadermaterial
https://www.babylonjs-playground.com/#UXCB15#67

simple custommaterial is work well
https://www.babylonjs-playground.com/#UXCB15#68 (new Object don’t have Uv? )
https://www.babylonjs-playground.com/#UXCB15#69

i find bug :slight_smile:

when you use new Uniform that not set for all instance when you update that

https://www.babylonjs-playground.com/#UXCB15#70 ( make pos.xz uv)

https://www.babylonjs-playground.com/#UXCB15#71

i don’t know where we can fix it need someone have time and check why when we define new Uniform that not update for all mesh

1 Like

Awesome, @nasimiasl !!
So rabbit has skeleton, interferes with custommaterial
babylon logo has vertex colors, interferes with custommaterial
candle has no uvs, interferes with custommaterial (duh, lol)

And yh, the bug was what lead me to making pgs and testing them. tho i was using pbrcustommaterial. Now, I know why my textures weren’t loading for other meshes, hmm…

I need to go find a workaround, bleh…

Sharing ss of the problem. This is an early prototype of the low poly terrain I’m working on. The small white house is its own mesh with its own material which works fine. The terrain is 1 single mesh with 1 pbrcustommaterial. My problem is that the grey trees are from a separate mesh instanced and sharing the same pbrcustommaterial and therefore the leaves and bark are showing my splatmap colors instead of the textures. Sceneloader loads terrain and assigns pbrcustommaterial fine but when it comes time to load the tree and assign the same pbrcustommaterial, only the diffusetexture is loaded, the rest of uniforms don’t load.

It’s a pity but my current workaround is to let the trees/props avoid sharing the terrain’s pbrcustommaterial and use their own material instead. I don’t like it as it means more memory for textures for what is essentially static props. But I don’t have time to debug the source for now…tsk tsk.

2 Likes