Roughness not taken into account to render objects with panda3d-simplepbr

Hello,

I investigated a little further on why the roughness of my objects is not taken into account in the rendering with panda3d-simplepbr.

I did a little test with the following piece of code:

sphere = self.loader.loadModel(modelPath="content/objects/test/sphere.glb")
print(f"findAllMaterials = \n{sphere.findAllMaterials()[0]}")
print(f"getMetallic = {sphere.findAllMaterials()[0].getMetallic()}")
print(f"getRefractiveIndex = {sphere.findAllMaterials()[0].getRefractiveIndex()}")
print(f"getRoughness = {sphere.findAllMaterials()[0].getRoughness()}")
print(f"getShininess = {sphere.findAllMaterials()[0].getShininess()}")
print(f"getSpecular = {sphere.findAllMaterials()[0].getSpecular()}")

Which gives the following prints:

findAllMaterials =
Material Concrete
  base_color = 1 1 1 1
  refractive_index = 1.45
  emission = 0 0 0 0
  roughness = 1
  metallic = 0
  local = 0
  twoside = 1

getMetallic = 0.0
getRefractiveIndex = 1.4500000476837158
getRoughness = 1.0
getShininess = 0.0
getSpecular = LVecBase4f(0.0337359, 0.0337359, 0.0337359, 0)

No big surprise, I can see that my material has the parameters values I expected in terms of roughness, metallic and shininess.

So I tried, to downgrade to the version of panda3d-simplepbr available on pip, and here is the comparison:

Could it be possible that a regression has been introduced in the current version of panda3d-simplepbr or am I missing something out?

Thanks for your feedback !

Perhaps the problem is that there is no roughness map in the material. By default, four render stages are used: M_modulate, M_normal, M_selector, M_emission.

If there is no texture, then the roughness will be 0. To fix this, you need a roughness map.

https://discourse.panda3d.org/uploads/default/original/2X/0/0c48ec4115c2a5a7cc20f32d3c379f8f43ea9f92.png

Roughness map is part of the “selector” slot, which contains both metallic and roughness in separate channels.

Thanks for your reply ! :pray:

I did exactly the same texture in Blender as you showed in the screenshot, but I got the same result as displayed in my previous screenshot.

If I set a full black map for roughness, the material will be completely shiny (expected).
If I set a full white map for roughness, the material will be shiny (as showed in my previous post).

It feels like there is a maximum roughness value (let’s say 0,5) and every value above that will be ceiled to 0,5.

I also tried using the cube map and got an unexpected result, in the form of static reflection in screen coordinates, with the presence of artifacts. The problem is directly related to the cube map.

As an experiment, try disabling the selection stage. Perhaps then the values specified in the material will be acceptable, and not the values from the texture used as a stub.

You can do this using my gltf format correction module for a standard shader generator.

module.zip (741 Bytes)

model = loader.load_model("untitled.gltf")
render_stage_convert(model, modulate = True, selector = False, normal = True, emission = True)
model.reparent_to(render)

This is bad advice, there are clearly problems with the cubic map. Perhaps the answer is simple, this simplepbr ibl branch is not ready for use.

@rdb: what does it mean? What should I try? I am a total beginner with P3D, I started one week ago :smile:

@serega-kkz: I used the master branch, so the potential problem is not only on the ibl branch. I agree with you: the cube map seems to always have an effect on the material even with roughness set to 1.

@Moguri: could you shed some light on this matter? Am I doing something wrong?

Could you please re-try with the latest master? I pushed some fixes to the IBL logic.

Thanks! This is way better:

As you mentioned, there are still some reflections even with a fully rough material, but the result definitively looks better! :wink:

There is a side effect introduced by the changes, the level of reflections are now reduced:

I can’t get the nice and shiny look like before!

Is that not simply because it’s not only fully rough, but also fully metallic? Might the reflections not vanish if the metallicity were reduced?

(After all, you mentioned using a white texture here, which I imagine corresponds to both “fully rough” and “fully metallic”, as those values are drawn from separate channels in the same texture.

I am, admittedly, assuming that those values both take a channel-value of zero to correspond to a property-value of zero–and so a value of one in the channel used for metallicity produces full metallicity.)

(I will confess though, that as I’m not greatly experienced with PBR I’m really not sure of what the result should be for a material that is both fully rough and fully metallic…)

This is the scene and reference image I have been using: https://github.com/KhronosGroup/glTF-Sample-Models/tree/master/2.0/MetalRoughSpheres

It helps give you and idea what various roughness and metallic values look like.

Thanks for you replies, this is very interesting. I need to do further testings!