Numa Posted February 18, 2017 Share Posted February 18, 2017 Hi there, If you load an obj with the flag OPTIMIZE_WITH_UV=true then recompute the normals, you lose the smoothing. playground: (switch line 14 from true to false hehe) http://www.babylonjs-playground.com/#1U5GPV#50 Right now I have to pick between broken texture (flag set to false) or broken normals (flag set to true) any ideas? Thanks Quote Link to comment Share on other sites More sharing options...
adam Posted February 18, 2017 Share Posted February 18, 2017 This looks like the same issue you had in the other thread. Quote Link to comment Share on other sites More sharing options...
Numa Posted February 18, 2017 Author Share Posted February 18, 2017 yes but I edited the other post and started this new one, as the problem is not at all what I thought it was it has nothing to do with me moving verts. It's just that the "optimization" flag in the obj loader causes the normals to not recalculate correctly. Quote Link to comment Share on other sites More sharing options...
adam Posted February 18, 2017 Share Posted February 18, 2017 I don't think you need to set the vertices after recomputing the normals. If you have to, VertexData.applyToMesh seems to work: http://www.babylonjs-playground.com/#1U5GPV#52 Quote Link to comment Share on other sites More sharing options...
Numa Posted February 18, 2017 Author Share Posted February 18, 2017 Yes it looks like the change only takes effect if you reapply the vertex data (I can see it on another model where it affects the lighting) I'm wondering how this even runs in the playground, there is a typo line 31, "inices" instead of "indices". If you fix the typo, it doesn't smooth I got excited for a moment Quote Link to comment Share on other sites More sharing options...
adam Posted February 18, 2017 Share Posted February 18, 2017 18 minutes ago, Numa said: there is a typo line 31, "inices" instead of "indices". Quote Link to comment Share on other sites More sharing options...
adam Posted February 18, 2017 Share Posted February 18, 2017 Here is the OPTIMIZE_WITH_UV code: https://github.com/BabylonJS/Babylon.js/blob/ba0e165c15a9520ace97c585d30c0dd692cda058/loaders/src/OBJ/babylon.objFileLoader.ts#L335 and the computeNormals code: https://github.com/BabylonJS/Babylon.js/blob/372050675a052c3aa55a0a3e6b77186f51cf2114/src/Mesh/babylon.mesh.vertexData.ts#L2065 Maybe you can see something there that will give you an idea what is causing the issue. Quote Link to comment Share on other sites More sharing options...
Numa Posted February 18, 2017 Author Share Posted February 18, 2017 thanks, I had a look and from what I can tell it only affect this function, which to be honest looks like minified code var isInArrayUV = (arr: Array<{ normals: Array<number>; idx: Array<number>; uv: Array<number> }>, obj: Array<number>) => { if (!arr[obj[0]]) arr[obj[0]] = { normals: [], idx: [], uv: [] }; var idx = arr[obj[0]].normals.indexOf(obj[1]); if (idx != 1 && (obj[2] == arr[obj[0]].uv[idx])) { return arr[obj[0]].idx[idx]; } return -1; }; Do we know who wrote the obj loader? I'd love to understand what this does Quote Link to comment Share on other sites More sharing options...
adam Posted February 18, 2017 Share Posted February 18, 2017 This does look like a bug. I tried a different approach and I get the same results: http://www.babylonjs-playground.com/#1U5GPV#58 Numa 1 Quote Link to comment Share on other sites More sharing options...
Numa Posted February 18, 2017 Author Share Posted February 18, 2017 yep I agree Should I log it in the "bug" thread? Quote Link to comment Share on other sites More sharing options...
NasimiAsl Posted February 19, 2017 Share Posted February 19, 2017 this is not a bug recompute calculate new normal with face points when we import .obj (with last uv ) with SceneLoader algorithm make separated face so recomputed method create flat normal the best way to have correct normal is import that normal from obj and recalculate always have some part of data i work on new importer but i just can correct non edge(uv edge) part of mesh left : last uv + recompute center : raw object + recompute right : scene loader http://www.babylonjs-playground.com/#D6IPT#5 bird : http://www.babylonjs-playground.com/#D6IPT#7 textured : http://www.babylonjs-playground.com/#D6IPT#6 solution : 1.import raw obj 2.recompute normals 3. correct last uv problem + append new normal to created face i need time to fix some bug and import this stuff Numa 1 Quote Link to comment Share on other sites More sharing options...
Numa Posted February 20, 2017 Author Share Posted February 20, 2017 This looks great @NasimiAsl, let me know when I can start using this Quote Link to comment Share on other sites More sharing options...
Numa Posted May 7, 2017 Author Share Posted May 7, 2017 Hi @NasimiAsl, any progress on this? Quote Link to comment Share on other sites More sharing options...
NasimiAsl Posted May 7, 2017 Share Posted May 7, 2017 @Numa hi i have 3 small problem for that but i can't work in this week (hope start some stuff about babylonjs in next week ) Numa 1 Quote Link to comment Share on other sites More sharing options...
Dad72 Posted May 7, 2017 Share Posted May 7, 2017 1 hour ago, NasimiAsl said: (hope start some stuff about babylonjs in next week You think also finish with the fusion of standardMaterial and ShaderBuilder? Quote Link to comment Share on other sites More sharing options...
NasimiAsl Posted May 7, 2017 Share Posted May 7, 2017 @Dad72 yes "start some stuff " mean start working about standardmaterial and some others Dad72 1 Quote Link to comment Share on other sites More sharing options...
Dad72 Posted May 7, 2017 Share Posted May 7, 2017 Cool, thanks. 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.