Hello everyone I’m new to panda3d, so my question might be stupid. I create a model in Blender and try to light it with PointLight and face unexpected effects. Here is my code
The first unexpected thing for me is that the box is lit from the inside, although the light should not pass there. The second is that the sphere corresponding to the point source is only half illuminated. It seemed to me that point light should shine equally in all directions. The third thing is that the upper side of the box is almost black, although it has a white texture, that is, it is almost not lit.
Also the change of light color
self.plnp.setColor((0, 0, 10, 1))
has no effect.
I didn’t find any documentation describing my problems, so I would be grateful for any tips and materials!
Hm-m, at the first look I would say that your point light source is located under the sphere, but very-very close to it. So, your light lits only one side of the sphere. And ceiling is black because of a sphere shadow.
Firstly, I would recommend enabling per-pixel lighting, such as via self.render.setShaderAuto(). On models with low vertex count, it can make it easier to see what is going on, because by default the lighting is only calculated per vertex. Or, instead of setShaderAuto, I can recommend the use of simplepbr, which is designed to better match the shading in Blender.
Secondly, you should check the polygon normals. If the normals are inverted, then the lighting will look incorrect.
As for the lighting affecting the inside: by default, no shadow-mapping is performed (this is an expensive operation), so Panda does not prevent light from passing through objects. You can enable the light as a shadow caster if you do want this.
Setting the color of a light should definitely work. Are you using blend2bam? Perhaps it converted a light that was specified in Blender and your light in Panda is not actually having significant effect.
Setting the emission color of a material does not affect lighting.
Thank you for your quick response! Yes, I use blend2bam, but I specifically select only the model of interest and do not add the light source from Blender.
Adding self.render.setShaderAuto() made the whole model completely black.
I will check the normals, but it seems to me that if there were problems with them, the upper side of the box would be lit when the light source is located on at least one side, but it is not lit nor from above nor from below.
Please try calling self.room_box.ls() (before creating your PointLight), this will confirm on the command-line whether there is indeed no light in the model itself.
I do recommend that you try the simplepbr package. It is designed to work well with blend2bam and match the lighting behaviour of Blender much better than the built-in shaders.
ls() should print something. If it doesn’t, that suggests that the model doesn’t contain anything. That’s clearly not the case.
If the model is completely black, even with simplepbr (assuming you removed setShaderAuto, which would otherwise override simplepbr), then that suggests the light isn’t active or too weak. I would suggest ramping up the brightness of the light using self.ptlight.setColor((1000, 1000, 1000, 1)).
If you can’t get it to work, please share your bam file (privately if necessary) so I can take a look.