guanglei Posted April 8, 2018 Share Posted April 8, 2018 So I loaded a STL model using STLFileLoader in to scene. The model seems flat-shaded, and I want it to be smooth-shaded. I know I can call `Mesh#convertToFlatShadedMesh()` to convert a mesh from smooth-shaded to flat-shaded, but what I want is the opposite method. Is there any solutions? Thanks for helping ... Quote Link to comment Share on other sites More sharing options...
Rodrix3 Posted April 8, 2018 Share Posted April 8, 2018 Did you apply lights to our scene? What material are you using? Quote Link to comment Share on other sites More sharing options...
guanglei Posted April 8, 2018 Author Share Posted April 8, 2018 5 minutes ago, Rodrix3 said: Did you apply lights to our scene? What material are you using? Yes, I apply `DirectionalLight` and use `PBRMetallicRoughnessMaterial`. Actually my code is like: var scene = new BABYLON.Scene(engine); var camera = new BABYLON.ArcRotateCamera("Camera", Math.PI / 2, Math.PI / 2, 2, BABYLON.Vector3.Zero(), scene); camera.attachControl(canvas, true); camera.radius = 80; var light = new BABYLON.DirectionalLight("light", new BABYLON.Vector3(0, 0, -20), scene); var pbr = new BABYLON.PBRMetallicRoughnessMaterial("pbr", scene); pbr.baseColor = new BABYLON.Color3(1.000, 0.766, 0.336); pbr.metallic = 1.0; pbr.roughness = 0.2; pbr.environmentTexture = BABYLON.CubeTexture.CreateFromPrefilteredData("/assets/textures/environment.dds", scene); var pbr2 = new BABYLON.PBRMetallicRoughnessMaterial("pbr2", scene); pbr2.baseColor = new BABYLON.Color3(1.000, 1.000, 1.000); pbr2.metallic = 1.0; pbr2.roughness = 0.2; pbr2.environmentTexture = BABYLON.CubeTexture.CreateFromPrefilteredData("/assets/textures/environment.dds", scene); const importMesh = function (name, callback) { BABYLON.SceneLoader.ImportMesh( name, '/assets/stl/', name + '.stl', scene, function (meshes) { const m = meshes[0]; m.position.y = 20; m.rotation.y = Math.PI; m.rotation.x = -Math.PI/2; callback(m); } ); } importMesh('something', function (m) { m.material = pbr; }); Thanks Quote Link to comment Share on other sites More sharing options...
Rodrix3 Posted April 8, 2018 Share Posted April 8, 2018 Could you please link it into a Playground? Thanks Quote Link to comment Share on other sites More sharing options...
guanglei Posted April 8, 2018 Author Share Posted April 8, 2018 35 minutes ago, Rodrix3 said: Could you please link it into a Playground? Thanks Here it is: http://www.babylonjs-playground.com/#9R44J5#2 Quote Link to comment Share on other sites More sharing options...
Rodrix3 Posted April 8, 2018 Share Posted April 8, 2018 Your problem is "smoothing groups". On 3ds Studio Max apply "Smooth modifier" or "HSDS" and export again. This should solve it, I am quite sure. guanglei 1 Quote Link to comment Share on other sites More sharing options...
guanglei Posted April 8, 2018 Author Share Posted April 8, 2018 1 minute ago, Rodrix3 said: Your problem is "smoothing groups". On 3ds Studio Max apply "Smooth modifier" or "HSDS" and export again. This should solve it, I am quite sure. So the only way is exporting the model again in modeling applications, there's no solution inside babylon itself, is it right? Quote Link to comment Share on other sites More sharing options...
JohnK Posted April 8, 2018 Share Posted April 8, 2018 Hi @guanglei and welcome to the forum. You can try this http://doc.babylonjs.com/samples/minimise_vertices but note it warns there may be seaming problems. See also the 'materials and facets' link on that page. guanglei 1 Quote Link to comment Share on other sites More sharing options...
guanglei Posted April 8, 2018 Author Share Posted April 8, 2018 16 minutes ago, JohnK said: Hi @guanglei and welcome to the forum. You can try this http://doc.babylonjs.com/samples/minimise_vertices but note it warns there may be seaming problems. See also the 'materials and facets' link on that page. Thanks, the snippet just solved my problem. You're great help, 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.