Textures not loading properly

blend2bam 0.25.0
blender 4.1.1

command: blend2bam --no-srgb --textures copy model.blend model.bam

I have a cube with an image texture. When loaded into panda3d ShowBase (or even just using pview model.bam) it doesn’t show the whole texture image, some is cut off.

As it shows in blender, each face of the cube has a 16x16 pixel texture, a sixth of the texture image. However, in panda3d I only count about 10.5 pixels squared. I’m wondering if there is some options set wrong or some other reason why p3d isn’t mapping the texture correctly to the model, even though it appears fine in blender?

Edit: When using blend2bam, I do recieve this message, even though there is only a single texture image applied to the single material applied to the cube:

Auto-detected Blender installed at /Applications/Blender.app
Blender 4.1.1 (hash e1743a0317bc built 2024-04-16 00:06:22)
Read prefs: "/Users/username/Library/Application Support/Blender/4.1/config/userpref.blend"
Read blend: "/Users/username/Desktop/pycraft/assets/raw/blocks/grass/model.blend"
07:06:30 | WARNING: More than one shader node tex image used for a texture. The resulting glTF sampler will behave like the first shader node tex image.

Edit 2: I am now “levelled up”, so here are the files without an external link:
texture.png (617 B)
texture template.png (496 B)
model.blend (929.7 KB)
model.blend.bam (3 KB)

Edit 3: When manually exporting from blender to glb, it works perfectly (other than the colors being off, which I assume is related to b2b’s --no-srgb option. But adding simplebpr.init() to my ShowBase-inheriting class’s __init__ seemed to fix it.)

I am still curious on what exactly was breaking though, and it may be helpful in case others come accross this issue as well.

Hmm… This is just a guess until someone more familiar with blend2bam arrives, but I note that the texture is non-power-of-two in its x-dimension, while conversely 10.5 * 6 closely approximates a power-of-two value. (Specifically: 10.66… * 6 = 64)

I wonder then whether there’s some conversion going on, either the texture being padded or the model being converted, or some such thing…

1 Like

Thats a really good spot.

I assume most people use 2^2n size texture images; if someone used a common base-10 size like 1000x1000 I assume it would have the same trouble. Since blender allows you to put in any number for the dimensions, I’m surprised I couldn’t find much about this issue on the internet.

As you said, it must be a problem with conversions inside blend2bam. I would have assumed --textures copy would just copy the actual texture image file(s); I’m not sure why there would be conversions or processing on them? For images packed into the blender file I would understand they need unpacking, but it would make sense to me that external images aren’t touched.

I think it will be useful to study it.
https://docs.panda3d.org/1.10/python/programming/texturing/choosing-a-texture-size
Add the following line to the etc/Config.prc configuration file: textures-power-2 none

2 Likes

Interesting read, thank you. Since using simplepbr it has fixed a couple of issues so I will stick with the textures I have already made for now. In the future, I can revisit this topic if the startup time becomes an issue.

This is explained by this line.

2 Likes