Property [emissive] not included in blender export

Hi there,

I noticed ( “emissive”:[1,1,1] ) property is not included in the .babylon file when I export my scene in blender, currently using (ver 2.80.1). I have confirmed the issue by manually adding the property and the emissive texture worked as expected. Need help as I’m using emissive textures in my scene and it would be a pain to go through each mesh that requires it.

Adding @JCPalmer who is the creator of the Blender exporter.

I am assuming that you actually meant emissiveColor. In the 2.80 exporter, you need to have the emission Node twice. Once for the color, & again for the texture. It was an oversight not to put in white in when only a texture was found, in the case of emissive. The default for Albedo is white, while emissive is black.

The 2.93 exporter is starting dev very soon. This will be rectified there, as well as:

  • reading emissive from the principled node type
  • providing for overloading, so that the same node field can be used for both a color & a texture, though Blender itself will not actually perform it that way.

See, Enhancements for Blender 2.93 LTS for more.

What I would do for now is just execute a loop one time after all your loads have occurred, rather than edit JSON files by hand. Assuming you are doing SceneLoader.Append(s), you can do it in an executeWhenReady()

const canvas = document.getElementById("renderCanvas");
const engine = new BABYLON.Engine(canvas, true);
const scene = new BABYLON.Scene(engine);

BABYLON.SceneLoader.Append("./", "fileA.babylon", scene);
BABYLON.SceneLoader.Append("./", "fileB.babylon", scene);
scene.executeWhenReady(function () {
    for (const mat of scene.materials) {
        if (mat instanceof BABYLON.PBRMaterial || mat instanceof BABYLON.StandardMaterial) {
            if (mat.emissiveTexture && !mat.emissiveColor) mat.emissiveColor = BABYLON.Color3.White();
        } else if (mat instanceof BABYLON.MultiMaterial) {
            for (const sub of mat.subMaterials) {
                if (sub.emissiveTexture && !sub.emissiveColor) sub.emissiveColor = BABYLON.Color3.White();
            }
        }
    }
});
2 Likes

Thanks for getting back to me, I will give this a go and keep you posted!. :slight_smile:

Setting [ mat.emissiveColor ] property to white resolves the issue, thanks. I will check out the next exporter build once it’s out. :slight_smile: