I’ve just spent many hours trying to get a simple one off glow tween working using a material’s emissive channel. When I press a button, an item glows. It all works great, but when I take it out of the test environment I can see when when I run the glow, ALL objects in the scene with this material are affected.
How do I temporarily modify the material of just one object?
How are you updating the material emissive? If you’re changing the material property directly then all objects sharing the material will get updated.
To update just a single model, you need to either clone and use a separate material or set the parameter directly on the mesh instance:
// for example changing the emissive intensity
this.entity.render.meshInstances.forEach(meshInstance => {
meshInstance.setParameter("emissiveIntensity", 0.5);
});
There are several forum posts on this method, try searching on how setParameter works.
Thanks. I had a looks at setParameter on some other forum topics and in the api but I tried it and it does nothing.
-Does setParameter change a material only on one instance of an object? Nothing seems to actually mention if it does.
Either way, I dont see any effect when using this code…
this.entity.render.meshInstances.forEach(meshInstance => {
meshInstance.setParameter("emissiveIntensity", data.intensity);
console.log("Intensity >> "+data.intensity ); //this prints fine!! :)
this.entity.render.material.update();//I also tried material.update()...doesnt work
});
No need to call material.update(), most likely you need to change the default value on the material for emissive intensity. Check this discussion here:
If you continue having trouble, feel free to share a sample project so we can help you out in context.
However, I have no idea if the parameter names are correct. There are no errors if I type in something random and there is no list of parameter names anywhere.
EDIT: I downloaded the json for the shader and found that i should be using the following. However, it still doesnt work…