trollolloo Posted February 2, 2018 Share Posted February 2, 2018 I'm using BabylonJS V3 with Blender 2.79 to create product visualizations. Many times, it is necessary for me to define more complex shaders in the JS code. I'm using lines like scene.meshes[1].material.emissiveColor = new BABYLON.Color3(1, 0, 0); to define the shaders after export. Usually every mesh can get it's own shader this way. Unfortunately, I can't get it to work somehow. Even in small test scenes (one red icosphere, one green cube, a hemi lamp and a camera), both objects get the same material. When trying to change the appearance like shown above, both meshes change color. When I navigate the camera, so that one object isn't visible, the right material gets loaded (green, in my sample scene). Here is a small video of the strange behavior: https://imgur.com/a/zYlLT Both blender meshes have individual datablocks and individual materials. No duplication, instancing ... Do the mesh indices change, when a mesh gets unloaded? Where could I have made the mistake? In blender or in my .js? I am greatful for every hint! Quote Link to comment Share on other sites More sharing options...
brianzinn Posted February 2, 2018 Share Posted February 2, 2018 This probably won't get to the root of the problem, but did you try something like: scene.meshes[1].material = scene.meshes[1].material.clone() scene.meshes[1].emmissiveColor = ... Just to make sure they aren't the same material - otherwise they should change color independently. Possibly you have merged the meshes, in which case they would share the same material. Quote Link to comment Share on other sites More sharing options...
Guest Posted February 2, 2018 Share Posted February 2, 2018 Pinging @JCPalmer Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted February 2, 2018 Share Posted February 2, 2018 I not know. 2 things: Is this behavior happen if you make no changes to materials? This is a diagram of what blender properties are used to construct materials in export. Quote Link to comment Share on other sites More sharing options...
trollolloo Posted February 5, 2018 Author Share Posted February 5, 2018 Thank you all for your suggestions! Unfortunately, the problem still remains. @brianzinn, adding material.clone() only made changes to the initial state of the materials. But both materials get changed by one line of code, and also the "old" (blender defined) material is loaded, when the other object leaves the screen. @JCPalmer, it also happens without any changes to the material. Meshes seem to be "combined" (or materials linked) without any apparent reason. In my test scene this is true for both icospheres, in more complex scenes, several objects seem to be "combined". I really don't know what is going on there, the problem never occurred before. I attached the test scene as blender file and our current framework. For the upload, I stripped out all products (for legal reasons) and only left the testscene in our framework. The materials for the ico spheres can be changed in line 119 in the tx-cgi.js file. Right now, the changes in the .js file seem to have no effect on the spheres, for reasons I don't understand either. I am quite helpless right now, I hope you can make sense of the test scene. babylon.zip Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted February 5, 2018 Share Posted February 5, 2018 Your framework does not concern me. I looked at your .blend & .babylon. I also loaded your .babylon in sandbox & zoomed so the spheres disappear, but nothing turns green. Your .babylon is just 2 separate meshes, each referencing a separate standard material. I think this is a down stream problem. Kind of reminds me of the Firxfox "things turn green" bug. I have not been updating my FireFox in a while for that reason. Sorry. Quote Link to comment Share on other sites More sharing options...
Guest Posted February 6, 2018 Share Posted February 6, 2018 If it is the infamous Firefox 58 bug, you should switch to bjs 3.2 where we have a workaround Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.