Hello.
I’m trying to use models loaded from different sources on the same scene.
For example, I want to place a built-in model (“models/environment”) and a simple model created in blender on the same scene.
The model created in blender is white and has no material.
If I use simplepbr.init() with no arguments, the model renders correctly, but the inline model turns black.
If I specify the node of my model created in blender as the render_node argument, then I get the best option at the moment (simplepbr.init(render_node=self.figure)). But the built-in model becomes, as it were, excessively bright, and the brightness of the background color also changes. While it seems like the changes should have only affected the specified node…
I also want to note that it doesn’t matter if I use .bam or .glb files, the result is the same.
I’d be grateful if someone could shed some light on this.)
In the screenshot in the center is a model loaded from blender
I think that this is because simplepbr applies one or more post-process effects, which, by their nature, affect the entire scene. Thus even if a given object isn’t itself rendered via simplepbr, the resultant image of the scene will nevertheless be run through simplepbr’s post-processing.
If you want to work around this, you could perhaps re-implement PBR rendering in a shader of your own, replacing simplepbr, and thus allowing you to omit post-processing, or perhaps exert control over what is and isn’t post-processed.
(It’s possible that there’s a way to disable (or effectively disable) the post-processing in simplepbr–but I don’t see it in an admittedly-quick look over the readme.)
Set the format of all textures on the regular models to Texture.F_srgb or Texture.F_srgb_alpha. (In the Egg file you can do this with <Scalar> format { srgb } in the <Texture> entry.)
I want to note that Texture.F_srgb works well with “simple” textures, but distorts “complex” ones (I used textures in .png). For the “complex” ones, I used Texture.F_srgb_alpha.
But, when I tried to apply Texture.F_srgb_alpha to “simple” textures, the following error occurred: AssertionError: image_ptr >= orig_image_ptr && image_ptr + view_size <= orig_image_ptr + tex->get_ram_mipmap_image_size(n) at line 13700 of panda/src/glstuff/glGraphicsStateGuardian_src .cxx
In order to use Texture, you first need to include: from panda3d.core import Texture
Also, maybe someone knows how to return the brightness to the background color) Although this is not such an important issue.
You need to use F_srgb_alpha on textures with alpha channel, F_srgb on ones without. You can check it with tex.num_components, if it’s 4, it has an alpha channel.