JohnK Posted August 18, 2016 Share Posted August 18, 2016 In trying to create a PG to solve another topic I came across the strange phenomenon (well it might not be strange just not what I expected) Having used MeshBuilder to create some small boxes and big box to fit them in I decided to make the box lidless by making the top transparent. Did this by setting a faceColor for the top face as faceColors[4] = new BABYLON.Color4(0,0,0,0); and realised that I then needed to set hasVertexAlpha to be true for the bigbox. http://www.babylonjs-playground.com/#1KH9RY#6 but the the rear and side faces disappear depending on camera angle. Ahah a moment of inspiration, I needed to make the sideOrientation DOUBLESIDE but then the front side disappeared. To check what was happening I made the rear face red faceColors[0] = new BABYLON.Color4(1,0,0,1); As you rotate the box so that you can view towards the rear red face, the red face disappears but the redness is applied to the inner small boxes (or so it appears) STRANGE http://www.babylonjs-playground.com/#1KH9RY#4 Any explanations, corrections, advice very welcome perhaps one for @jerome Quote Link to comment Share on other sites More sharing options...
jerome Posted August 18, 2016 Share Posted August 18, 2016 Well, when a mesh is declared as having VertexAlpha, it is fully considered as a transparent mesh, even if its alpha value is 1. The alpha blending is computed for an entire mesh and is compared to the other ones. It's not computed, for performance reasons, per mesh face. I guess that's why you have these unexpected behavior : the transparent faces (even with alpha = 1) aren't sorted the way you would expect. AFAIK, this is a usual compromise accepted in the 3D engines. Maybe a workaround would be then to have 2 boxes, one embedded in the other, so 2 different meshes... and a better alpha blending This documentation is worth it : http://doc.babylonjs.com/tutorials/Transparency_and_How_Meshes_Are_Rendered or try the trick from the last part of this doc JohnK 1 Quote Link to comment Share on other sites More sharing options...
Wingnut Posted August 18, 2016 Share Posted August 18, 2016 Hi guys! There's also the indices chainsaw. http://www.babylonjs-playground.com/#1KH9RY#7 What fun, and oh so brutal. heh JohnK 1 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.