projectcs Posted March 11, 2018 Share Posted March 11, 2018 I was unable to transform mesh instance if the original mesh had a shader material. Is this a bug? I have created a playground example using box mesh. If you open the debug -> mesh panel, you realize there are 6 meshes, but only 5 are displayed. This is because one of the instances in the second row was not transformed properly. On the other hand, clones of meshes with shader material can be transformed properly. https://playground.babylonjs.com/#B2NZ1M#1 Quote Link to comment Share on other sites More sharing options...
Guest Posted March 13, 2018 Share Posted March 13, 2018 Instances cannot have a different material than the original mesh. This is per design. THey must share everything but their position Something like that: https://playground.babylonjs.com/#B2NZ1M#11 Quote Link to comment Share on other sites More sharing options...
projectcs Posted March 13, 2018 Author Share Posted March 13, 2018 Thank you @Deltakosh, you solved my problem but explained it wrong. It's actually not because I was using a different material than the original mesh, but rather I did not know that in order to render transformed mesh instance with custom shader: 1. You need to use #include<instanceDeclaration> and #include<instanceVertex> in the custom shader. 2. You need to use ”viewprojection” and ”finalworld” instead of ”worldviewprojection” in the custom shader. However the above variables are not documented in the custom shader session. Wondering if there is any more hidden variables that we need to know when working with custom shader? Anyway thanks a lot for your solution! Quote Link to comment Share on other sites More sharing options...
Guest Posted March 13, 2018 Share Posted March 13, 2018 Would you be kind enough to add your learnings to the doc? This could help us a lot https://github.com/BabylonJS/Documentation/blob/bb69005377058f1e60872bfdbfaefe2b0432fd92/content/How_To/shaders/Shader_Material.md 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.