G'kar Posted November 21, 2015 Share Posted November 21, 2015 I was checking around the latest code of icosphere and find out that the normal are corrupted when radiusX/radiusY/radiusZ are used.More over the BABYLON.MeshBuilder.CreateSphere seems to have the same issue if diameterX/Y/Z are used.Both spheres use the normal define as line between vertex position to sphere center line.Fine, but if the sphere is scaled to a flat ellipsoid with radiusY or diameterY for instance, then the (center --> ellipse point) is not the normal anymore.I setup a basic playground to illustrate the issue (added blue line matching normal for several vertices):flat sphere: http://www.babylonjs-playground.com/#24XHJP#2flat icosphere: http://www.babylonjs-playground.com/#24XHJP#3This can be fix "easily" in BJS code:I have a tentative fix commit in my fork:https://github.com/regis-c/Babylon.js/commit/f7d6b0159e8498943a689744cd5d019692e70191(normals and shading seems much better when I run the playground code with the fix in my local setup) Let me know if you think it is done in the right way (I didn't check much so side effect still possible).Then I can send a PR if OK. Wingnut and jerome 2 Quote Link to comment Share on other sites More sharing options...
jerome Posted November 21, 2015 Share Posted November 21, 2015 http://www.babylonjs-playground.com/#24XHJP#4 I used our little showNormals() function instead. You're right, the normals weren't recomputed rightly when changing X,Y, or Z diameter values.Could you check your fix with showNormals() ? you'll see at a glance if it's OK. Wingnut 1 Quote Link to comment Share on other sites More sharing options...
G'kar Posted November 21, 2015 Author Share Posted November 21, 2015 Thanks for the showNormals() code : gives nice visual check for normal. I play around with sphere, icosphere (flat=true), icosphere (flat=false), changing the radius scaling to see what happen.(using my local BJS recompiled with the fix : https://github.com/r...d5d019692e70191)The fix seems ok for me. The normals looks as I expect now. jerome 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.