Replacing glTF materials

Hi,

I’ve switched from exporting .egg in Blender 2.7x (using YABEE) to .gltf in Blender 2.8, but I’ve noticed the material definition that is being read by Panda3D is quite different:

Material a(0 0 0 1) d(0.119275 0.119275 0.119275 1) s(0.252942 0.252942 0.252942 1) e(0 0 0 1) s0.25 l0 t0

has now changed to:

    Material body
      base_color = 1 1 1 1
      refractive_index = 1
      emission = 0 0 0 0
      roughness = 1
      metallic = 1
      local = 0
      twoside = 1

If I understand correctly, the glTF file format needs something called a PBR render pipeline, but it also seems to me that exporting to glTF takes away much of the possibilities to programmatically alter materials using the Material() class (using replaceMaterial/setMaterial).

Before I used something like:

material = Material()
material.setSpecular((0, 0, 0, 1))
material.setDiffuse((1, 1, 1, 1))
self.node.setMaterial(material, True)

But this doesn’t have the same effect as it does with my older .egg models. Using findAllMaterials() shows me the material has been set correctly, but the model remains practically black when the same material on an .egg model gives the expected result.

Is there an easy way of working with both model formats the same (without switching to panda3d-simplepbr)? I’d really like to use Blender 2.8, but YABEE is not available for it… I read Panda3D might switch to glTF as its primary format in the future, so I’d really like to use it right away. Yet, the Material() class doesn’t seem to give me the tools I need to modify my model’s materials.

Thanks,

Jeroen

For completeness: I have tried using simplepbr (import + .init()), and at that point, colors seem somewhat better. However, I still feel control over the look and feel through Material() is limited. Also, I notice some odd behaviour that only appears when initializing simplepbr. In my case, those are base.setBackgroundColor no longer working (background color is always light gray) and my custom fog of war (a texture over render) painting a lot of stuff (models) black that were fine before.

Blender 2.8 only supports PBR material properties. Specifically, on glTF export, it supports metal-rough properties. You could write a script that goes over all of the materials, read the PBR properties (base color, metallic, roughness, etc.), and create a new material with the “legacy” properties you’re used to (diffuse, specular, etc.). I would even be open to adding such an option to panda3d-gltf since it comes up often enough.

However, you should be able to modify materials in a similar way, just using the PBR properties:

material = Material()
material.setBaseColor((1, 1, 1, 1))
self.node.setMateria(material, True)

Panda tries to do some magic behind the scenes with legacy vs PBR material properties (e.g, being able to call material.getDiffuse() even though you’ve been using PBR properties), but I have found it best to stick to using one set or the other.

There is this fork of YABEE that supports Blender 2.8, but I suspect it also outputs PBR materials.

Hi Moguri,

Thank you, was hoping you’d check in to take a look at my question. I think I understand better now, and - like you said - it is Blender 2.8 that switched to the PBR properties. Exporting to another format (or even using blend2bam) still gives me the PBR properties.

I know now what my options are. First I’ll try to switch to PBR everywhere, that seems like the most logical and maintainable approach. I’ll just have to replace some of my older models, but that’s okay.

Any thoughts on why base.setBackgroundColor() doesn’t work anymore? If I activate simplepbr in my app, the clear color goes to a light gray… before I was able to set it effortlessly with setBackgroundColor.

Thanks again,

Jeroen

The background color issue is a quirk/bug I have noticed with FilterManger, which panda3d-simplepbr uses. If you set the background color before initializing simplepbr/FilterManager, it should work. However, this work-around only works if you are setting the background color once at startup and don’t need to change it dynamically.

That worked, moving down the simplepbr.init() fixes the background color. Thank you