Jump to content

How to : Convert from flat-shaded to smooth-shaded


Recommended Posts

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 ...

Link to comment
Share on other sites

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) {
            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;


    importMesh('something', function (m) {
        m.material = pbr;


Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...