glTF Shaders Not Exporting?

I may be misunderstanding something about how glTF exporting works, but I thought a lot of the appeal was that you could shade your model in Blender and simply import it into Babylon with little hassle. No? Maybe I got that wrong.

Tl;dr is how do I approximate my shaders in Babylon manually, or do I have to?
Also, how do I adjust the default “void” color from purple to something else.

Here are three images showing the differences that I’m seeing:

Blender Render

I love the above shot. I want to keep the magenta reflection color and the fuchsia translucency on the icospheres. Also having this deep sky blue / cerulean void color would be nice. Icing on the cake would be some way to deactivate reactivity to light and shadow for emission material on a per-face basis.

glTF Sandbox

SceneLoader on Localhost
04%20PM

I want my shaders to be as close to 1:1 as possible. Can it be done? Where should I begin?
Thank you very much for all your kind support.

I have tried to export from Blender (Version 2.80 (2.80 2019-07-05)) to Babylon using the v6.1.1 add-on, but all it does is give me this error every time:

If the shaders would work using that, I can’t test that option.

So glTF only supports PBR so you have to design your models with that on my mind

Pinging @JCPalmer for the error you are seeing when exporting .babylon file

1 Like

Thank you @Deltakosh,

I will dig into the PBR related docs more thoroughly. I thought I was on the right track but I’m only just dipping my toes in the water when it comes to exporting scenes.

If it is any help to @JCPalmer, My emission materials are applied per face within meshes, mostly. The only meshes that have emission materials as their only coloration are the canopy tethers toward the back. These are very thin elongated cubes.

The exporter has been updated already to fix that. Version 6.1.2 or 6.1.3, I think.

1 Like

New error involving baked materials in 6.1.2, no baking present in scene.

EDIT: disregard, this is something involving a mixed shader I need to change in my scene.

Updated the shader and… back to same error as start of thread.
I’m stumped. I’ll have a go at troubleshooting the code later, I’m hungry so it’s a good time to take a break.

Full log follows:

Exporter version: 6.1.2, Blender version: 2.80 (sub 74)
========= 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
texture directory : /Users/allen-woods/Development/Portfolio/
Python World class constructor completed
WARNING: No active camera has been assigned, or is not in a currently selected Blender layer
processing begun of mesh: ShipParentObj
WARNING: No materials have been assigned:
num positions : 29
num normals : 29
num tangents : 0
num uvs : 58
num uvs2 : 0
num colors : 0
num indices : 36
processing begun of mesh: Cube.001
WARNING: No materials have been assigned:
num positions : 29
num normals : 29
num tangents : 0
num uvs : 58
num uvs2 : 0
num colors : 0
num indices : 36
processing begun of mesh: Cube
WARNING: No materials have been assigned:
num positions : 29
num normals : 29
num tangents : 0
num uvs : 58
num uvs2 : 0
num colors : 0
num indices : 36
processing begun of mesh: Cube.002
WARNING: No materials have been assigned:
num positions : 29
num normals : 29
num tangents : 0
num uvs : 58
num uvs2 : 0
num colors : 0
num indices : 36
processing begun of mesh: AntennaGlassChild1
processing begun of material: SensorGlassShader
num positions : 51
num normals : 51
num tangents : 0
num uvs : 102
num uvs2 : 0
num colors : 0
num indices : 75
processing begun of mesh: AntennaGlassChild2
mesh is an instance of : AntennaGlassChild1. Processing halted.
processing begun of mesh: AntennaGlassParent
mesh is an instance of : AntennaGlassChild1. Processing halted.
processing begun of mesh: AntennaSensorChild1
processing begun of material: HullLightShader
processing begun of material: HullDarkShader
processing begun of multimaterial: spaceship_official_pbr_fix.Multimaterial#0
num positions : 349
num normals : 349
num tangents : 0
num uvs : 698
num uvs2 : 0
num colors : 0
num indices : 396
processing begun of mesh: AntennaSensorChild2
mesh is an instance of : AntennaSensorChild1. Processing halted.
processing begun of mesh: AntennaSensorParent
mesh is an instance of : AntennaSensorChild1. Processing halted.
processing begun of mesh: AntennaGlassChild1.001
mesh is an instance of : AntennaGlassChild1. Processing halted.
processing begun of mesh: AntennaGlassChild2.001
mesh is an instance of : AntennaGlassChild1. Processing halted.
processing begun of mesh: AntennaGlassParent.001
mesh is an instance of : AntennaGlassChild1. Processing halted.
processing begun of mesh: AntennaSensorChild1.001
mesh is an instance of : AntennaSensorChild1. Processing halted.
processing begun of mesh: AntennaSensorChild2.001
mesh is an instance of : AntennaSensorChild1. Processing halted.
processing begun of mesh: AntennaSensorParent.001
mesh is an instance of : AntennaSensorChild1. Processing halted.
processing begun of mesh: AntennaGlassChild1.002
mesh is an instance of : AntennaGlassChild1. Processing halted.
processing begun of mesh: AntennaGlassChild2.002
mesh is an instance of : AntennaGlassChild1. Processing halted.
processing begun of mesh: AntennaGlassParent.002
mesh is an instance of : AntennaGlassChild1. Processing halted.
processing begun of mesh: AntennaSensorChild1.002
mesh is an instance of : AntennaSensorChild1. Processing halted.
processing begun of mesh: AntennaSensorChild2.002
mesh is an instance of : AntennaSensorChild1. Processing halted.
processing begun of mesh: AntennaSensorParent.002
mesh is an instance of : AntennaSensorChild1. Processing halted.
processing begun of mesh: Bulkhead
processing begun of material: HullLightShader
processing begun of material: OrangeEnergyShader
processing begun of material: FuchsiaEnergyShader
processing begun of material: HullDarkShader
registered as also a user of material: HullDarkShader
processing begun of multimaterial: spaceship_official_pbr_fix.Multimaterial#1
num positions : 769
num normals : 769
num tangents : 0
num uvs : 1538
num uvs2 : 0
num colors : 0
num indices : 828
processing begun of mesh: Bulkhead.001
mesh is an instance of : Bulkhead. Processing halted.
processing begun of mesh: Bulkhead.002
mesh is an instance of : Bulkhead. Processing halted.
processing begun of mesh: AntennaHousing
processing begun of material: HullDarkShader
processing begun of material: OrangeEnergyShader
registered as also a user of material: OrangeEnergyShader
processing begun of multimaterial: spaceship_official_pbr_fix.Multimaterial#2
num positions : 1361
num normals : 1361
num tangents : 0
num uvs : 2722
num uvs2 : 0
num colors : 5444
num indices : 1542
WARNING: # of 0 area faces found: 138
processing begun of mesh: Bridge
processing begun of material: HullLightShader
processing begun of material: HullDarkShader
processing begun of material: OrangeEnergyShader
processing begun of material: CockpitGlassShader
registered as also a user of material: HullDarkShader
registered as also a user of material: OrangeEnergyShader
processing begun of multimaterial: spaceship_official_pbr_fix.Multimaterial#3
num positions : 1234
num normals : 1234
num tangents : 0
num uvs : 2468
num uvs2 : 0
num colors : 0
num indices : 1374
processing begun of mesh: CockpitFlange
processing begun of material: HullLightShader
processing begun of material: HullDarkShader
registered as also a user of material: HullDarkShader
processing begun of multimaterial: spaceship_official_pbr_fix.Multimaterial#4
num positions : 170
num normals : 170
num tangents : 0
num uvs : 340
num uvs2 : 0
num colors : 0
num indices : 174
WARNING: # of 0 area faces found: 2
processing begun of mesh: Canopy
processing begun of material: CanopyMaterialShader
processing begun of material: OrangeEnergyShader
registered as also a user of material: OrangeEnergyShader
processing begun of multimaterial: spaceship_official_pbr_fix.Multimaterial#5
num positions : 189
num normals : 189
num tangents : 0
num uvs : 0
num uvs2 : 0
num colors : 0
num indices : 204
processing begun of mesh: Tether
processing begun of material: OrangeEnergyShader
registered as also a user of material: OrangeEnergyShader
num positions : 29
num normals : 29
num tangents : 0
num uvs : 58
num uvs2 : 0
num colors : 0
num indices : 36
processing begun of mesh: Tether.001
mesh is an instance of : Tether. Processing halted.
processing begun of mesh: Tether.002
mesh is an instance of : Tether. Processing halted.
processing begun of mesh: Tether.003
processing begun of material: OrangeEnergyShader
registered as also a user of material: OrangeEnergyShader
num positions : 29
num normals : 29
num tangents : 0
num uvs : 58
num uvs2 : 0
num colors : 0
num indices : 36
processing begun of mesh: Tether.004
processing begun of material: OrangeEnergyShader
registered as also a user of material: OrangeEnergyShader
num positions : 29
num normals : 29
num tangents : 0
num uvs : 58
num uvs2 : 0
num colors : 0
num indices : 36
processing begun of mesh: Tether.005
processing begun of material: OrangeEnergyShader
registered as also a user of material: OrangeEnergyShader
num positions : 29
num normals : 29
num tangents : 0
num uvs : 58
num uvs2 : 0
num colors : 0
num indices : 36
processing begun of mesh: CanopyAnchor
processing begun of material: HullDarkShader
processing begun of material: FuchsiaEnergyShader
registered as also a user of material: FuchsiaEnergyShader
processing begun of multimaterial: spaceship_official_pbr_fix.Multimaterial#6
num positions : 546
num normals : 546
num tangents : 0
num uvs : 1092
num uvs2 : 0
num colors : 2184
num indices : 648
processing begun of mesh: Keel
processing begun of material: HullLightShader
processing begun of material: OrangeEnergyShader
processing begun of material: FuchsiaEnergyShader
registered as also a user of material: OrangeEnergyShader
registered as also a user of material: FuchsiaEnergyShader
processing begun of multimaterial: spaceship_official_pbr_fix.Multimaterial#7
num positions : 553
num normals : 553
num tangents : 0
num uvs : 1106
num uvs2 : 0
num colors : 0
num indices : 582
processing begun of mesh: Conduit
processing begun of material: HullDarkShader
processing begun of material: OrangeEnergyShader
registered as also a user of material: OrangeEnergyShader
processing begun of multimaterial: spaceship_official_pbr_fix.Multimaterial#8
num positions : 235
num normals : 235
num tangents : 0
num uvs : 470
num uvs2 : 0
num colors : 0
num indices : 252
WARNING: # of 0 area faces found: 8
processing begun of mesh: Tail
processing begun of material: HullLightShader
processing begun of material: OrangeEnergyShader
processing begun of material: FuchsiaEnergyShader
registered as also a user of material: OrangeEnergyShader
registered as also a user of material: FuchsiaEnergyShader
processing begun of multimaterial: spaceship_official_pbr_fix.Multimaterial#9
num positions : 1374
num normals : 1374
num tangents : 0
num uvs : 2748
num uvs2 : 0
num colors : 0
num indices : 1530
processing begun of mesh: CorridorLeft
processing begun of material: HullDarkShader
processing begun of material: OrangeEnergyShader
registered as also a user of material: OrangeEnergyShader
processing begun of multimaterial: spaceship_official_pbr_fix.Multimaterial#10
num positions : 6676
num normals : 6676
num tangents : 0
num uvs : 0
num uvs2 : 0
num colors : 0
num indices : 7704
processing begun of mesh: NavigationMesh
WARNING: No materials have been assigned:
num positions : 173
num normals : 173
num tangents : 0
num uvs : 0
num uvs2 : 0
num colors : 0
num indices : 228
processing begun of light (POINT): Point.001
processing begun of light (HEMI FROM AREA): Light
processing begun of light (POINT): Point
========= Writing of JSON file started =========
========= An error was encountered =========
File “/Users/allen-woods/Library/Application Support/Blender/2.80/scripts/addons/babylon_js/json_exporter.py”, line 154, in execute
self.to_json_file()
File “/Users/allen-woods/Library/Application Support/Blender/2.80/scripts/addons/babylon_js/json_exporter.py”, line 183, in to_json_file
material.to_json_file(file_handler)
File “/Users/allen-woods/Library/Application Support/Blender/2.80/scripts/addons/babylon_js/materials/material.py”, line 281, in to_json_file
write_float(file_handler, ‘emissiveIntensity’, self.bjsNodeTree.emissiveIntensity)
File “/Users/allen-woods/Library/Application Support/Blender/2.80/scripts/addons/babylon_js/package_level.py”, line 279, in write_color
file_handler.write(‘,"’ + name + ‘":[’ + format_color(color, precision) + ‘]’)
File “/Users/allen-woods/Library/Application Support/Blender/2.80/scripts/addons/babylon_js/package_level.py”, line 159, in format_color
return format_float(color[0], fmt) + ‘,’ + format_float(color[1], fmt) + ‘,’ + format_float(color[2], fmt)
ERROR: ‘float’ object is not subscriptable
========= end of processing =========
elapsed time: 0 min, 0.4128 secs

EDIT: It’s a problem described here, it goes a bit over my head when looking at format_color.