Hello everyone,
I’m wondering is it possible that I can make meshes with same shader but different uniforms using same shaderMaterial? I have to produce thousands of meshes at the same time, it will stuck for a long time when creating the meshes.
Or is there any other ways to make the buildings’top in the pic with single material(maybe change uvs, but I just cant imagine how to do this)? I want to make it looks like outline
You can update a uniform in the shadermaterial.onBindObservable
observable:
shadermaterial.onBindObservable.add((mesh) => {
if (mesh.name === "xxx") {
shadermaterial.setFloat("myuniform", 1.2);
} else if (mesh.name === "yyy") {
shadermaterial.setFloat("myuniform", 1.7);
}
});
It seems that the shader uses the last update of uniform, could you please point me out where is wrong?
https://www.babylonjs-playground.com/#2IFRKC#249
My mistake, in the onBindObservable
you must directly update the value on the effect, not on the base class:
It works! Thank you so much for helping me out!!