Rendering a scene created in Blender with Babylon.js without the Babylon.js default shiny material

1.8k views Asked by At

I've a really simple scene created in Blender with a plane, a cube, a sun (AKA directional light) and a camera: Blender scene

Rendered, it's looking like this: Blender's scene rendered

My problem is, when I export this scene to .babylon file format, and load it into Babylon, it does not look like this at all. It seems that Babylon sets a specular-shiny-weirdy material to all my meshes: Babylon's scene rendered

I'd like to have a "matte" (I mean, opaque and rough) material, like in Blender's render, in my Babylon scene as well, or at least suppress the specular thing, to make the meshes look like rough. Unfortunately I didn't encounter any case like mine on the internet yet.

Some informations about what I'm using:

  • Blender 2.74
  • Blender to Babylon exporter (downloaded two days ago, I think it's the latest, still I can't figure out what version it is)
  • Babylon.js v2.1
  • Google Chrome for MacOSX

I'm working on a python localhost server, so I can't provide a working example, but at least here's my .babylon scene and my html code:

<script>
    if (BABYLON.Engine.isSupported()) {
        var canvas = document.getElementById("renderCanvas");
        var engine = new BABYLON.Engine(canvas, true);

        BABYLON.SceneLoader.Load("", "Cube_and_plane.babylon", engine, function (newScene) {
            // Wait for textures and shaders to be ready
            newScene.executeWhenReady(function () {
                // Attach camera to canvas inputs
                newScene.activeCamera.attachControl(canvas);

                // Add shadows
                var shadowGenerator = new BABYLON.ShadowGenerator(2048, newScene.lights[0]);
                for (var i = 0; i < newScene.meshes.length; ++i) {
                    shadowGenerator.getShadowMap().renderList.push(newScene.meshes[i]);
                    newScene.meshes[i].receiveShadows = true;
                };

                // Once the scene is loaded, just register a render loop to render it
                engine.runRenderLoop(function() {
                    newScene.render();
                });
            });
        }, function (progress) {
            // To do: give progress feedback to user
        });
    }
</script>

Thanks in advance !

3

There are 3 answers

0
David Catuhe On

Hello just set your specular color to black.

1
A.J.Bauer On

The question might still be relevant to someone..

If you use the Babylon Blender Exporter 4.6.1 then the settings don't show up on the "Export page" (on the left side) as is the case for other exporters, but shows up under "Scene" (on the right side):

enter image description here

You want to check "Flat shade entire scene" otherwise smooth shading is used.

0
vishnuajan On

If you want load blender tool scene in babylonJS framework. follow this link (https://www.babylonjs-playground.com/#QWIJYE#24). This project needs to return at least an empty scene and default blender camera and lights.