Punn Posted September 20, 2015 Share Posted September 20, 2015 http://www.babylonjs-playground.com/#TPE3U Why is there a strange reflection on a plane pyramid side? Quote Link to comment Share on other sites More sharing options...
Ahiru Posted September 20, 2015 Share Posted September 20, 2015 I think Jerome had a good explanation for it lately: http://www.html5gamedevs.com/topic/17040-the-mystery-of-computenormals/?p=95871 Quote Link to comment Share on other sites More sharing options...
adam Posted September 20, 2015 Share Posted September 20, 2015 To fix it, make the subdivision 1. http://www.babylonjs-playground.com/#TPE3U#1 Quote Link to comment Share on other sites More sharing options...
jerome Posted September 20, 2015 Share Posted September 20, 2015 subdivision = 1 http://www.babylonjs-playground.com/#TPE3U#3 Quote Link to comment Share on other sites More sharing options...
jerome Posted September 20, 2015 Share Posted September 20, 2015 However it should work with the mast version of the cylinder implementation, even with many subdivisions now.I don't know if it's been pushed in the PG engine Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted September 20, 2015 Share Posted September 20, 2015 I think so Quote Link to comment Share on other sites More sharing options...
jerome Posted September 20, 2015 Share Posted September 20, 2015 mmmh.. the distorded reflection is typically the problem encountered with computeNormals() on vertices belonging to exacly 3 coplanar faces : http://www.babylonjs-playground.com/#TPE3U#4 However the new cylinder re-implementation doesn't use computeNormal() any longer but dedicated computed normals from the cylinder geometry itself.I tested it, there were no artifact, even with many subdivisions (I didn't test tessellation = 4 ...) . Quote Link to comment Share on other sites More sharing options...
jerome Posted September 21, 2015 Share Posted September 21, 2015 Ok, got it : http://www.babylonjs-playground.com/#TPE3U#5 Well, it's rightly the same problem than encountered with computeNormals() about 2 coplanar facets having vertices with different normals due to their but ... without computeNormals() !Because there is only a quad per face and many subdivisions, we create here this specific case : 2 coplanar triangles, but different normalson each, so the quad plane has no 4 similar normals => visual artifact. I'm afraid, in this very case, the solutions are to set the subdivisions to 1 OR to set your normals afterwards with a computation dedicated to the specific geometry. NOTE : this means computeNormals() is not magic, but dedicated computed computed are neither Quote Link to comment Share on other sites More sharing options...
jerome Posted September 23, 2015 Share Posted September 23, 2015 If you really need to keep many cylinder subdivisions (instead of 1 to avoid the artifact), you could convert your mesh to a flat shaded one : http://www.babylonjs-playground.com/#TPE3U#6 Each mesh face will then have its own normals not depending from the other side vertices. This is a really simple way to deal with artifacts on meshes which have edge angles lower than 120° Ahiru and Punn 2 Quote Link to comment Share on other sites More sharing options...
Punn Posted September 27, 2015 Author Share Posted September 27, 2015 To fix it, make the subdivision 1. http://www.babylonjs-playground.com/#TPE3U#1 Still some artefact? And why is the tip of the pyramid cut now? Quote Link to comment Share on other sites More sharing options...
jerome Posted September 27, 2015 Share Posted September 27, 2015 oopsI need to check thisIt seems the 0 top diameter isn't taken in account now, I don't understand why ...I'll check tomorrow (I have a lead in vertexdata.createcylinder default parameter handling) In this case, the artifact is due to this not zero top diameter : http://www.babylonjs-playground.com/#TPE3U#7 Quote Link to comment Share on other sites More sharing options...
jerome Posted September 28, 2015 Share Posted September 28, 2015 gotcha : https://github.com/BabylonJS/Babylon.js/blob/master/src/Mesh/babylon.mesh.vertexData.ts#L790 JS lazy evaluation :diameterTop = diameterTop || options.diameterTop || 1;if diameterTop is falsy then options.diameterTop else 1 ...But 0 is falsy in JS !I'm fixing this right now. @DK : I think we've got the same problem on each sideOrientation evaluation :sideOrientation = sideOrientation || options.sideOrientation || Mesh.DEFAULTSIDE;This will work only as long as the constant DEFAULTSIDE is set to zero.If we change it some day, the lazy evaluation might come to strange results.ex : if DEFAULT is set to 1 and we call the method by requesting sideOrientation: FRONTSIDE, what is zero => we'll get DEFAULT (== 1) instead Maybe something like this would be better : if (sideOrientation === 0 || options.sideOrientation === 0) { sideOrientation = 0; } else { sideOrientation = sideOrientation || options.sideOrientation || Mesh.DEFAULTSIDE; } Quote Link to comment Share on other sites More sharing options...
jerome Posted September 28, 2015 Share Posted September 28, 2015 fixed and PRed. and the subdivisions parameter of CreateCylinder is optional again 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.