Shiny material is not rendered in Panda3D

Hello !

I am a very new user of Panda3D (Python API) : I started a couple of days ago ! :smile:

It seems promising for what I want to do, but I have some issues doing what I want and understanding what are my mistakes !

Here is my render with Panda :

When I display the same model in gltf-viewer.donmccurdy.com, the car has the same material shininess as in Blender but not with Panda.

I can’t figure out why the shiny material is not rendered in Panda, Do you have any suggestions ?

Here are relevant parts of my code :

self.set_background_color(0.0, 0.0, 0.0)

self.ground = self.loader.loadModel(modelPath="content/models/grounds/noise.glb")
self.ground.reparentTo(self.render)

self.car = self.loader.loadModel(modelPath="content/models/cars/nissan_rs13_notexture.glb")
self.car.reparentTo(self.render)
self.car.setScale(300, 300, 300)
self.car.setPos((0, 0, -0.05))

self.light_on_camera = direct.showbase.ShowBase.PointLight("PointLightCamera")
self.light_on_camera.setColor((1, 1, 1, 1))
self.light_on_camera_node = self.render.attachNewNode(self.light_on_camera)
self.light_on_camera.setAttenuation((0, 0, 0.002))
self.render.setLight(self.light_on_camera_node)

self.light_bar_1_model = self.loader.loadModel(modelPath="content/models/objects/lightbar.glb")
self.light_bar_1_model.setPos(0, -4, 8)
self.light_bar_1_model.reparentTo(self.render)
self.light_bar_1_light = direct.showbase.ShowBase.PointLight("PointLight1")
self.light_bar_1_light.setColor((1, 1, 1, 1))
self.light_bar_1_light.setAttenuation((0, 0, 0.01))
self.light_bar_1_node = self.render.attachNewNode(self.light_bar_1_light)
self.light_bar_1_node.setPos((0, -4, 7))
self.render.setLight(self.light_bar_1_node)

self.render.setShaderAuto()

For information, I export Blender models as GLB files.

Thanks for your help ! :pray:

By default Panda3D does not support pbr materials, you need to install panda3d-simplepbr.

1 Like

Thanks for your reply !

I installed panda3d-simplepbr and imported the module in my project :

import simplepbr
import direct.showbase.ShowBase

class Main(direct.showbase.ShowBase.ShowBase):

    def __init__(self):

        super().__init__(self)
        simplepbr.init()

The background color has changed from black to light grey but still have no reflections on the object:

I have another piece of information if it helps: when I install panda3d-gltf, just install but no import in my project, I see the following result, which is kind of artistic but not what I expected :smile: :

At the moment there is another problem: simplepbr does not support the metallicity of the material parameter. Therefore, all surfaces will be black.

Although reading this thread, you can see that this has been implemented, but nowhere is it indicated how to install lighting based on the images. Logically, you can install a pre-rendered map. However, this question can be answered by @Moguri

It would be nice if you would create a minal example of the model for demonstration. Or additionally provided a screenshot of the nodes for the car body material.

IBL support is still new (master branch, no release with it yet), and I’d like to write some docs/examples for it. The gist of it is set env_map (e.g., as a keyword to init()) to a string or panda3d.core.Filename that is a path to a set of cubemap images as described here: Cube Maps — Panda3D Manual

Thanks to both of you for your replies ! :wink:

@serega-kkz: here is the model I use to do some test, textures are done quickly just in order to have something to display: nissan_rs13_notexture_light.glb (2.0 MB)

The shiny grey of this model is just a base color set to grey and roughness set to 0 in Blender, nothing fancy for now.

@Moguri: following your advice, I downloaded the latest version of panda3d-simplepbr on the master branch. After that, I installed the new dependency typing-extensions required for simplepbr.

I edited my code like so:

import simplepbr
import direct.showbase.ShowBase

class Main(direct.showbase.ShowBase.ShowBase):

    def __init__(self):

        super().__init__(self)
        simplepbr.init(env_map="content/models/objects/cubemap.env")

The cubemap is the one given in the package of simplepbr.

Here is the result:

What am I doing wrong ?

Thanks.

Let me check: Are you still enabling the auto-shader on the scene (i.e. calling “render.setShaderAuto”), as seems to be the case in the first post?

If so, you might try removing that–I’m not sure, but I have the impression that it may interfere with simplepbr.

@Thaumaturge: no, the autoshader is not activated like in the first post.

But if I activate it, the result is this:

For information, here are the traces of execution:

“C:\Program Files\Panda3D-1.10.13-x64\python\python.exe” D:\Workspace\Python\200SX\main.py
Known pipe types:
wglGraphicsPipe
(all display modules loaded.)
AL lib: (EE) ALCwasapiPlayback_resetProxy: Audio client returned buffer_len < period*2; expect break up
:display:gsg:glgsg(error): An error occurred while compiling GLSL fragment shader pbr:
pbr(205) : error C7616: global function shadow2DProj is removed after version 140
pbr(240) : error C7616: global function textureCubeLod is removed after version 140
pbr(261) : warning C7533: global variable gl_FragColor is deprecated after version 120
tonemap(40) : warning C7533: global variable gl_FragColor is deprecated after version 120
:display:gsg:glgsg(warning): Shader tonemap produced the following warnings:
Fragment info

0(40) : warning C7533: global variable gl_FragColor is deprecated after version 120

Process finished with exit code 0

Ah, that looks useful!

Okay, it looks like there’s a version-mismatch: version 140 is being used, but the shader-code is built for an earlier version.

And indeed, looking at the simplepbr GitHub page, it does look like the shaders there specificy version 120.

So, do you have something requesting a specific GLSL version somewhere? Perhaps you’re setting the gl-version config-variable, either in a PRC file or via code…?

[edit] I do note that in the “readme” file for simplepbr, there is a parameter to the “init” function called “use_330”–what happens if you set that to “True”?

(That looks like it might be intended for cases in which a later version of GLSL is desired, you see.)

1 Like

That was the issue! Thank you very much for pointing that out! :pray:

Here is the piece of code:

import simplepbr
import direct.showbase.ShowBase

class Main(direct.showbase.ShowBase.ShowBase):

    def __init__(self):
        super().__init__(self)
        simplepbr.init(use_330=True, env_map="content/models/objects/cubemap.env")
2 Likes

I have three more questions, again, I know: :smile:

  1. Why does a pure mate material still have reflections on it?
  2. How to generate a CubeMap that can be used as env_map for simplepbr?
  3. If I want a black background what are you advice? Should I use a black box to cover the whole scene?

Regarding question #1

I created a simple example with two spheres: one pure shiny red, the other pure mate black.
Here is the preview with https://gltf-viewer.donmccurdy.com/

Here is the render I have in P3D and simplepbr:

Why does the black sphere still have some reflections on it? This is the same for the car’s tyres. I played a lot with Blender materials parameters (roughness to 1, specular to 0, …) but did not succeed in getting the pure mate material, any ideas?

Regarding question #2

I tried passing 5 PNG images to simplepbr as suggested in the manual (Cube Maps):

simplepbr.init(use_330=True, env_map="content/models/objects/cubemap_#.png")

But for some reason the same image is used for all the face of the cube, you can see it on the spheres: 5 of 6 face of the cube map should be black bit it is not the case here.

Many thanks for your help!

I think so that there are no reflections, you additionally need to set the metallic parameter to 0

@serega-kkz: thanks for your reply! The metallic parameter is already to 0. I will try tomorrow to work on this subject to find out what is happening.

I am starting to like what I am seeing ! :smile:

This post got me to do some digging into the IBL code for simplepbr, and found some errors that I cleaned up and pushed to the master branch. A fully metallic and fully rough material still doesn’t look quite right (the reflection is still too visible for a fully rough material).

2 Likes