Closed sebavan closed 6 years ago
Ping @NasimiAsl who maintains the custom material
hi thanks for starting this
let i say what i am thinking about this problem ( may be wrong) i think this problem in standardMaterial update uniform when we have some mesh if this is true custom material is inherited this bug too
check it and make one special uniform in standard material and change it by Mat.getEffect().setFloat() (in scene with 2 mesh) if you see this problem this is standard material bug if dont it is custommaterial bug
thanks (i am so excited to find solution for this )
and i think this is babylon bug (not babylon extension )
ping @sebavan
Actually you can not update uniform directly in standard material by design as there is a cache mecanism in place and you need to use the property to not break the cache consistency (this is the case for all the pushMaterial). to support this in your case you need to refresh the cache after setting the value or associated ubo will not be updated.
1.so why this work for single mesh ?
any way i can mark all custommaterial as dirty :D
so i cant remove any cache
There is a way. I'll be back this tuesday and tell you how to proceed
everything is possible with deltakosh
Every mesh can have his own version of the effect so you can go through all meshes and check material properties. Then if the mesh material is the one that you want, iterate through all submeshes and call submesh.getEffect().setXXXX
Does it make sense?
hi look this sample https://www.babylonjs-playground.com/#3WN9C6#4
when we have one mesh (no any submesh) sphere update uniform correctly when i add other mesh ( after some time in this sample ) sphere .getEffect frizzed and don't be update mesh material uniform
this is base problem
The problem is about timing. You cannot change the value ahead of time as the effect is shared between multiple meshes. You have to use the onBindObservable of the material for that: https://www.babylonjs-playground.com/#3WN9C6#5
I also had to fix an issue with the custom material here: https://github.com/BabylonJS/Babylon.js/commit/4e89757d696252bda902968f719d7e32961647a4#diff-638e8dcec06012300f357b139bada80bR5939
Hope this helps ;)
Playground: https://www.babylonjs-playground.com/#3WN9C6#4
I asked related questions here: http://www.html5gamedevs.com/topic/32203-custommaterial-updating-custom-uniforms-custom-alpha-and-precision/
Is it considered a bug or not supported? Is there any plan for it? Is there any way I can work around it, if I really need to update uniforms values for my shader?
Thank you very much!