Blender Babylon Exporter - ERROR: name 'defaultDiffuse' is not defined

Hello :wink: :wave:
I try export blender model from Blender to .babylon using Babylon exporter (Link for model ) but i got error:

Exporter version: 2.93.0, Blender version: 2.93.0
========= Conversion from Blender to Babylon.js =========
Scene settings used :
Inline textures : false
Material Type : PBR
Positions Precision : 4
Normals Precision : 3
UVs Precision : 3
Vert Color Precision: 3
Mat Weight Precision: 2
Keep Z-up r-handed : no
Texture directory : C:\Users\adam\Desktop\New Folder
processing texture dry_field_4k
Python World class constructor completed
processing begun of mesh: Cube.020
processing begun of material: Material.002
WARNING: unsupported node type(ShaderNodeLightPath) will trigger baking
WARNING: unsupported node type(ShaderNodeLightPath) will trigger baking
WARNING: unsupported node type(ShaderNodeMath) will trigger baking
WARNING: unsupported node type(ShaderNodeLightPath) will trigger baking
WARNING: unsupported node type(ShaderNodeMath) will trigger baking
bake time: 0 min, 0.004 secs
num positions : 8
num normals : 8
num tangents : 0
num uvs : 16
num uvs2 : 0
num colors : 0
num triangles : 4
processing begun of mesh: Cylinder.001
processing begun of material: Material.014
========= An error was encountered =========
File “C:\Users\adam\AppData\Roaming\Blender Foundation\Blender\2.93\scripts\addons\babylon_js\json_exporter.py”, line 116, in execute
mesh = Mesh(object, scene, self)
File “C:\Users\adam\AppData\Roaming\Blender Foundation\Blender\2.93\scripts\addons\babylon_js\mesh.py”, line 150, in init
recipe = BakingRecipe(bpyMesh, exporter)
File “C:\Users\adam\AppData\Roaming\Blender Foundation\Blender\2.93\scripts\addons\babylon_js\materials\baking_recipe.py”, line 43, in init
bjsMaterial = BJSMaterial(bpyMaterial, exporter)
File “C:\Users\adam\AppData\Roaming\Blender Foundation\Blender\2.93\scripts\addons\babylon_js\materials\material.py”, line 100, in init
self.bjsNodeTree = AbstractBJSNode.readMaterialNodeTree(bpyMaterial.node_tree, self.overloadChannels)
File “C:\Users\adam\AppData\Roaming\Blender Foundation\Blender\2.93\scripts\addons\babylon_js\materials\nodes\abstract.py”, line 265, in readMaterialNodeTree
return AbstractBJSNode.readNodeTree(node_tree, ‘ShaderNodeOutputMaterial’, overloadChannels)
File “C:\Users\adam\AppData\Roaming\Blender Foundation\Blender\2.93\scripts\addons\babylon_js\materials\nodes\abstract.py”, line 285, in readNodeTree
return AbstractBJSNode(output, topLevelId, overloadChannels)
File “C:\Users\adam\AppData\Roaming\Blender Foundation\Blender\2.93\scripts\addons\babylon_js\materials\nodes\abstract.py”, line 84, in init
bjsWrapperNode = AbstractBJSNode.GetBJSWrapperNode(nodeSocket.links[0].from_node, nodeSocket.name, overloadChannels)
File “C:\Users\adam\AppData\Roaming\Blender Foundation\Blender\2.93\scripts\addons\babylon_js\materials\nodes\abstract.py”, line 332, in GetBJSWrapperNode
return PassThruBJSNode(bpyNode, socketName, overloadChannels)
File “C:\Users\adam\AppData\Roaming\Blender Foundation\Blender\2.93\scripts\addons\babylon_js\materials\nodes\passthru.py”, line 8, in init
super().init(bpyNode, socketName, overloadChannels)
File “C:\Users\adam\AppData\Roaming\Blender Foundation\Blender\2.93\scripts\addons\babylon_js\materials\nodes\abstract.py”, line 84, in init
bjsWrapperNode = AbstractBJSNode.GetBJSWrapperNode(nodeSocket.links[0].from_node, nodeSocket.name, overloadChannels)
File “C:\Users\adam\AppData\Roaming\Blender Foundation\Blender\2.93\scripts\addons\babylon_js\materials\nodes\abstract.py”, line 314, in GetBJSWrapperNode
return DiffuseBJSNode(bpyNode, socketName, overloadChannels)
File “C:\Users\adam\AppData\Roaming\Blender Foundation\Blender\2.93\scripts\addons\babylon_js\materials\nodes\diffuse.py”, line 21, in init
self.diffuseAlpha = defaultDiffuse[3]
ERROR: name ‘defaultDiffuse’ is not defined
========= end of processing =========
elapsed time: 0 min, 1.8049 secs

Adding @JCPalmer

Are you using any materials that aren’t Principled BSDF? If so, I’d try exporting a version of the file with those materials deleted or at least not attached to any mesh.

1 Like

Ok, there was a bug in exporter. Updated to exporter version 2.93.1, just pushed up.

A couple of notes with Blend. It looks very old, still using theCycles renderer. As @Matt_Poindexter pointed out these are not friendly materials for export. Many needed to be baked.

I could not get the environment texture to load in Sandbox. I do not know what the problem was. I deleted the hdr image node for the world material & re-exported and got this.

Notice the glass is white. You cannot see partially inside while reflecting the environment texture as shows in Blender. These tricks really cannot be done with materials which get baked Alpha cannot really be baked.

Even when switching to EEVE render, these materials did not work. You see the reflection of the glass, but inside.

It does export now though.

2 Likes