Hi there,
I’ve made my first steps in Blender (2.8) and wanted to create a small VR-scene. I found babylon to be perfect in respect to distributability do different devices and to programming effort necessary.
However, I’m already struggeling upon the basic steps.
I’ve made a simple scene with suzanne. To make it more interesting i set the principled shader to metallic=1 and applied a noise-Texture as input for the roughness.
Here is how it looks in Blender (somehow the node-links are not shown in blender, so I redrew them)
However, using the Babylon Exporter 6.2.2 I receive warnings in the log:
###########
Exporter version: 6.2.2, Blender version: 2.80 (sub 75)
========= 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 : XXXXXXX (crossed out for privacy - had an acutal path in it)
Python World class constructor completed
processing begun of camera (UniversalCamera): Camera
processing begun of mesh: Suzanne
processing begun of material: Material.001
WARNING: unsupported node type(ShaderNodeTexNoise) will trigger baking
WARNING: Roughness channel baking required, but not possible, ignored
bake time: 0 min, 0.009 secs
num positions : 635
num normals : 635
num tangents : 0
num uvs : 1270
num uvs2 : 0
num colors : 0
num indices : 2904
processing begun of light (POINT): Light
========= Writing of JSON file started =========
writing mesh: Suzanne
========= Writing of JSON file completed =========
========= end of processing =========
elapsed time: 0 min, 0.766 secs
#########
So noise Texture is unknown and Roughness-Baking is not possible. What am I doing wrong?
As expected, the babylon scene looks boring with a uniform reflection on it.
Can someone please guide me trough the basics of blender node-material exporting?
Thanks
Timo
PS: Sorry for the missing formatting - couldn’t figure this out in the topic editor-window.
Keep in mind that you’re not in precomputed 3D workflow, but in realtime. They differs on some points, here it’s because you’re using a procedural node (noise).
The exporter seems to notify that by the way:
WARNING: unsupported node type(ShaderNodeTexNoise) will trigger baking
WARNING: Roughness channel baking required, but not possible, ignored
The cleaner way is to save your procedural texture into a bitmap yourself, then apply it on your realtime material.
Thanks for your suggestion vinc3r. I made an image from noise texture and replaced the procedual with an image texture (Btw. is there a more defined way than projecting the noise on a plane, spot the camera on it and do a rendering?).
Blender looks “okay”. Not so much detail but you can see rough spots and shiny ones. (can only post one pic on a reply)
However babylon Editor doesn’t - like checkerboard - looks like on baking the UV-Map wasn’t applied:
##########
Exporter version: 6.2.2, Blender version: 2.80 (sub 75)
========= 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 : XXX (path removed)
Python World class constructor completed
processing begun of camera (UniversalCamera): Camera
processing begun of mesh: Suzanne
processing begun of material: Material.001
processing texture noise
texture type: value not meaningful 2, mapped using: “UVMap”
num positions : 1648
num normals : 1648
num tangents : 0
num uvs : 3296
num uvs2 : 0
num colors : 0
num indices : 2904
processing begun of light (POINT): Light
========= Writing of JSON file started =========
writing mesh: Suzanne
========= Writing of JSON file completed =========
========= end of processing =========
elapsed time: 0 min, 0.277 secs
##########
Textures for Metal, roughness, ambient occlusion are pretty tricky. I must admit I never had a .blend to really test this.
Big thing is, all three are on the same texture in BJS’s implementation of PBR & maybe everybodies since glTF is the same way. Metal on red, roughness on green, & AC on blue. You need a texture with levels of green. Not really easy. that’s why I never tested it.
More for my own notes, here is where I am writing the JSON of this area, in case want to look it up again.
Thanks for pointing that out. So this color coding is something I have to take care of? How can I achieve this?
Obviously a lot of knowledge is needed in order to convert from blender to babylon with comparable results. Are there any good recources (for beginners) how to create advanced exportable material (e.g. more than colored diffuse)?
I also tried to apply a normal-map node on the noise texture. But the exporter doesn’t “know” that node.
I’m completely lost on what is possible and what not.
Here is a screen inside the repo, showing the mapping for Principled when exporting in PBR.
That’s all I did. There is pre Blender 2.80 / standard material stuff in the BJS doc site. I did not do it, and pretty obsolete with 2.80 & PBR.
A dirty way to find the types of nodes supported is to just look down this code. If the node type does not match by the time of the bottom, then it is assigned the UnsupportedNode wrapper class, A.K.A. bake city assuming Blender can even bake that.
FYI, ignore the gltfNode. It is just a specific class wrapping legacy glTF nodes to say it is going to bake.
As far as how to make textures for these three. I think asking on BlendStack or other Blender user site is really where to go. Just say you are exporting for glTF, not Babylon JSON. It is the exact same in this regard. Mentioning BJS would probably not get as good results. Then link it back to here, please!
JCPalmer thanks a lot for the screen link on how the color is encoded. Also thanks a lot for pointing out that glTF and .babylon format are internally the same.
I did not post a new topic on blendStack but did a lot of reading through baking tipps and so forth. I managed to bake a metal roughness encoded procedual texture and export it as glb. However the babylon export somehow breaks - see pics.
And here is my workflow on baking metal/roughness information to texture. Unfortunately I can’t name “THE” source to this as I figured it out from many info-snippets:
Basically I’m adding two “Emission Shaders”. The metal-one with a blue base-color (as the whole model should be metal) and the roughness-one from a procedual texture trough a colorramp from G:0 to G:1.
Then I assign it to the model and bake it as “Emit-Texture” - and there it is:
So to sum it up, here is what I learned from all of your input:
Blender and Babylon behave different on rendering (realtime vs. precomputed workflow)
you have to bake your (pbr) materials to textures, where there is certain color-encoding to represent the principled-shader data
The Babylon-Exporter does a great job on converting and automatization during export process but the designer still has to do some work in order to get comparable results
The exporter format is basically a glTF format (so for future reference a more generic search term)
All right, I looked into this. The .babylon file looks as I think it should be. I noticed that if I removed the light though, when loading in Sandbox I get a something is null error. Will not reproduce just now .
When I also tried exporting as a GLB, I sort of get something that shows the texture effect, but with an odd emmisive tint. In inspector, I turn it off and get something better (below). Do not know where that tint is coming from, but this is just a reference check.
When I view side - by - side (GLB left, JSON right) I really cannot see anything of importance that is different about the material, other than the tint.
meaning you try to pick it from both green and alpha where it should only be green.
Please add “useRoughnessFromMetallicTextureAlpha”:false in your babylon material export to ensure it picks it up from the right channel. (this one defaults to true otherwise)