Ariel Yust Posted February 25, 2014 Share Posted February 25, 2014 I'm trying to load an object that I'v created using Blender...saved it as a *.Bablyon file and added it's MimeType declaration in WebConfig. When I'm using this code to load the model the faces that look at the camera disappear (Screenshot Included)in the screenshot : left -> the inside of the object is visibleright -> the outside is invisibleBABYLON.SceneLoader.ImportMesh("", "models/", "CategoryBorder.babylon", scene, function (newMeshes, particleSystems) { var rabbit = newMeshes[1]; //rabbit.scaling = new BABYLON.Vector3(1, 1, 1); rabbit.scaling.x *= 50; rabbit.scaling.y *= 50; rabbit.scaling.z *= 50; rabbit.position = new BABYLON.Vector3(0, 0, 0); rabbit.material.diffuseTexture = new BABYLON.Texture("test.png", scene); rabbit.material.backFaceCulling = true; });*ignore the rabbit, it's from a tutorial Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted February 25, 2014 Share Posted February 25, 2014 What's happen when you drag/drop it into the sandbox? (www.babylonjs.com/sandbox) Quote Link to comment Share on other sites More sharing options...
Ariel Yust Posted February 26, 2014 Author Share Posted February 26, 2014 Didn't know a Sandbox exists how cool is that! =] any ways that's what I see I included the *.babylon as a *.txt file too just in case btw I got another model but it's flat like a normal plan and it doesn't show one of it's faces when I turn it back to the camera... Any Clue ? CategoryBorder.txt Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted February 26, 2014 Share Posted February 26, 2014 Using this line:rabbit.material.backFaceCulling = true; Means that you want to remove hidden faces (removes faces that are not facing the camera) Quote Link to comment Share on other sites More sharing options...
Ariel Yust Posted March 3, 2014 Author Share Posted March 3, 2014 Delta, This doesn't help... I know what backFaceCulling does when I create materials for meshes from within babylon's api,but It doesn't seem to do anything for meshes I load from a *.babylon file that is made in blender... perhaps I'm doing something wrong in any case: with this line and without it and even when it's false or true the outcome is the same - the face is still disappearing, help ? Quote Link to comment Share on other sites More sharing options...
gwenael Posted March 3, 2014 Share Posted March 3, 2014 It may be a stupid question but did you check your normals? Quote Link to comment Share on other sites More sharing options...
Dad72 Posted March 3, 2014 Share Posted March 3, 2014 I had a similar problem that I solved by adjusting 2 directional light. Quote Link to comment Share on other sites More sharing options...
Ariel Yust Posted March 4, 2014 Author Share Posted March 4, 2014 I might be wrong but ain't normals control shadows of the mesh's faces ? how would that make the disappear ? and if so how would I make such check ?and doesn't blender predetermine normals on it's own ? I don't think it's a problem of light, if there is no light at all then the mesh should be pitch black.and when you have one light then the over side of the face should be darker... what happens is the faces that face the camera are no visiblesimilar to the way backFaceCulling =true; effects's a normal babylon.plane but in the case of this mesh it has no effect at all, that made me wonder, perhaps I'v designed it badly ? that would be weird because it shows properly in blenderbut then again, I might miss something... Quote Link to comment Share on other sites More sharing options...
gwenael Posted March 4, 2014 Share Posted March 4, 2014 Normals are used to compute lighting. If the normals are inversed your front face becomes a back face... Unfortunately I don't know how to check normals in Blender but send me your babylon files and I'll try to find what it's wrong. (post processing can be used to display normals on objects) Quote Link to comment Share on other sites More sharing options...
Ariel Yust Posted March 4, 2014 Author Share Posted March 4, 2014 I uploaded the file, check my second comment it's a *.txt format, just change it to *.babylon Thanks Gwenael Quote Link to comment Share on other sites More sharing options...
gwenael Posted March 7, 2014 Share Posted March 7, 2014 Hi Ariel, Sorry, I've finally found time to test your file and here's my thought: your mesh is not double sided. In real world, everything is double sided since everything has a thickness but in 3D, for performance, meshes can be single sided. Double sided means you can have a face without thickness but still be visible from both side (you can be in front of it or behind it and still see it). A face is visible depending on the dot product between the camera vector (from the camera position to the target position: "Ray" on the picture) and the normal of the face ("N" on the picture). If it's negative (like on the picture), you see it, it's a front face, otherwise it's a back face and you don't see it. If you want to see the face not depending on you are in front of it or behind it, it means that the dot product must be negative in both cases and it's not possible with a single normal so you need a normal when you are in front of it and another one when you are behind it (it would be -N instead of N). When you are behind the face, Ray is -Ray so dot(-Ray, -N) = dot(Ray, N) < 0 and you see the back face . But it's not possible to have 2 normals for a face except if it's double sided. You can compare this to two single sided faces clued together. The two following screenshots show us that the normals of your faces go inside your mesh (I display the normal map; RGB corresponds to XYZ so when green means normal is up) so from this point of view all dot products with them are negative and we see the faces. In the second screenshot, we don't see some faces since now the dot product with their normal is positive. In conclusion, add thickness to your mesh and that should do the trick. Quote Link to comment Share on other sites More sharing options...
gwenael Posted March 7, 2014 Share Posted March 7, 2014 BTW you have an invisible mesh, is it on purpose? Quote Link to comment Share on other sites More sharing options...
gwenael Posted March 7, 2014 Share Posted March 7, 2014 Now I tested your file thanks to https://github.com/BabylonJS/Babylon.js/tree/master/Tools/BuildOurOwnBabylonJS and the following line fixed your issue:OURBABYLON.currentScene.meshes[1].material.backFaceCulling = false;It's what Deltakosh suggested you to do. This property is set to true by default. By setting it to false, you specify that you want to see back faces too, it's like for a double sided face but it's more efficient, no need to clue two faces together Ariel Yust 1 Quote Link to comment Share on other sites More sharing options...
Ariel Yust Posted March 11, 2014 Author Share Posted March 11, 2014 Okay you guys seem to be right about this, I found why when I put false it didn't work for me. it was a mistake in the mesh, i chose the wrong mesh when I did the backFaceCulling=false;I picked a mesh that wasn't displayed, so I didn't see the effect work... in any case now it works and I figured out how to work with imported meshes. and...Ye... Thank you guys =] gwenael 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.