Jump to content

Mesh faces don't display properly...


Ariel Yust
 Share

Recommended Posts

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 visible

right -> the outside is invisible

BABYLON.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  :lol:

post-5734-0-05704700-1393338898_thumb.pn

Link to comment
Share on other sites

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 :P

 

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 ?

Link to comment
Share on other sites

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 visible

similar 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 blender

but then again, I might miss something...

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

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.

 

 

l009-frontback.png

 

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.

 

4vms6h.jpg

 

 

 

 

2q1coiw.jpg

 

In conclusion, add thickness to your mesh and that should do the trick.

Link to comment
Share on other sites

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 ;)

 

zjw8co.jpg

Link to comment
Share on other sites

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 =]

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...