captainleighwalker Posted April 25, 2018 Share Posted April 25, 2018 Dear friends I am pulling my hair out with a model imported from 3Ds max. When I use csg subtract the lighting on the new mesh looks different as if the vertices are in a different position to the original mesh. Or is it the normals. I have reproduced it here https://www.babylonjs-playground.com/#EFXZ8U The difference is a lot worse on the mesh I am working with. It is a lot darker after the operation. Any help? Thanks in advance Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted April 25, 2018 Share Posted April 25, 2018 https://www.babylonjs-playground.com/#EFXZ8U#1 I do not see anything noticeable. Quote Link to comment Share on other sites More sharing options...
captainleighwalker Posted April 25, 2018 Author Share Posted April 25, 2018 On my playground you can easily compare the original mesh and subtracted mesh and the lighting is looking different Quote Link to comment Share on other sites More sharing options...
Arte Posted April 25, 2018 Share Posted April 25, 2018 Hi from me, After 2 sec... https://www.babylonjs-playground.com/#EFXZ8U#2 Quote Link to comment Share on other sites More sharing options...
captainleighwalker Posted April 25, 2018 Author Share Posted April 25, 2018 The problem is something to do with normal are different after subtract. If I do convertToFlatShadedMesh then it looks like same. The problem is my mesh has curved surfaces. How can I get around this problem? Quote Link to comment Share on other sites More sharing options...
Guest Posted April 25, 2018 Share Posted April 25, 2018 Can you try to recreate the normals with mesh.createNormals(true) ? Quote Link to comment Share on other sites More sharing options...
captainleighwalker Posted April 25, 2018 Author Share Posted April 25, 2018 Hi @Deltakosh It does sort the lighting out but its making the curves faceted (the bottom is the original mesh) This is how it looks after using subtract I don't get how this works or if it would have any affect but when drawing normal positions they seem to be in different position and rotation on https://www.babylonjs-playground.com/#EFXZ8U#3 Quote Link to comment Share on other sites More sharing options...
Guest Posted April 25, 2018 Share Posted April 25, 2018 Unfortunately this is not an easy one and the CSG algorithm does not help a lot. can you share a repro on the playground with only your mesh? I'll try to see how we can make sure the createNormals does not lose the smoothing Quote Link to comment Share on other sites More sharing options...
captainleighwalker Posted April 26, 2018 Author Share Posted April 26, 2018 Hi @Deltakosh Please see https://www.babylonjs-playground.com/#EFXZ8U#5 You have to replace var data with below as the file was too big. Thanks. _________________________ I've realised you get a different set of normals if you are using intersect depending on which mesh you intersect from. See https://www.babylonjs-playground.com/#EFXZ8U#4 If you swap bCSG.intersect(aCSG);for aCSG.intersect(bCSG); The normal are ok Quote Link to comment Share on other sites More sharing options...
Guest Posted April 26, 2018 Share Posted April 26, 2018 Ok unfortunately this is because of the CSG it will separate the face and thus losing the smoothness I have no solution for you this time (unless than digging into CSG to try to fix this behavior) Quote Link to comment Share on other sites More sharing options...
captainleighwalker Posted April 26, 2018 Author Share Posted April 26, 2018 Could there be a way to recalculate normals and join vertices back together based on a threshold angle between the faces? Quote Link to comment Share on other sites More sharing options...
Guest Posted April 26, 2018 Share Posted April 26, 2018 There is an hope here: http://doc.babylonjs.com/snippets/minimise_vertices If you do that and then run createNormals again it could work (not tested but worth the try) Quote Link to comment Share on other sites More sharing options...
captainleighwalker Posted April 26, 2018 Author Share Posted April 26, 2018 nope! haha Quote Link to comment Share on other sites More sharing options...
Guest Posted April 27, 2018 Share Posted April 27, 2018 Erf:( 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.