theanine3D / Blender-BAM-Exporter

Blender 3.0+ addon for exporting Panda3D "BAM" files
MIT License
4 stars 1 forks source link

Consider using gltf2bam or a minimized version of it #3

Closed rayanalysis closed 1 year ago

rayanalysis commented 1 year ago

The usage of blend2bam seems to incur the cost of using Blender 2.7x era texture packing during conversion, which drops certain textures from a contemporary BSDF texture node and causes incorrect renders. On the other hand, gltf2bam doesn't seem to have the same issue, at least based on my usage of the tool and testing with apples to apples model files with a minimized version of the tool.

So, perhaps we could use a two-pass procedure of 1. Exporting a .gltf with bpy.ops.export_scene.gltf() directly with Blender 3.x and 2. Running gltf2bam or a minimized version of it on that produced .gltf file ourselves.

I have attached my minimized gltf2bam test program here for reference.

gltf2bam_minimal.zip

theanine3D commented 1 year ago

Appreciate the suggestion! I do however feel that this is definitely a blend2bam issue, and as such, it should be addressed via an update to that. If Panda3D is to obtain more mainstream attention, its tools and pipelines are really going to need to move beyond Blender 2.7x. I personally don't know anyone who still uses anything under Blender 3.0. Blender 2.7x support in blend2bam should be deprecated if not outright dropped as it's just holding back proper support for the newer Blender versions. I recommend opening an issue for the GLTF texture packing problem on blend2bam's own issue tracker.

Bypassing blend2bam for GLTF exports in this Blender addon would also come with a major drawback: it would mean that blend2bam's support for automatic CollisionSolid generation (via Blender-assigned rigid bodies) would be skipped, and that's really one of the main benefits that .bam has over .gltf right now. See the bottom section in the article below:

https://github.com/Moguri/blend2bam/blob/master/docs/conversion-guide-gltf28.md Quote:

"However, blend2bam will convert Blender rigid body shapes and add them to the glTF data outputted from the exporter"

With your method described above, using a direct call to Blender's GLTF export operator would completely bypass the step above, leaving rigid bodies absent from the exported GLTF. I don't feel that this is a good tradeoff, especially if blend2bam is updated later on with a fix to the 2.7x era texture packing issue.

rayanalysis commented 1 year ago

For what it's worth, I did open such an issue on blend2bam's repo several days ago: https://github.com/Moguri/blend2bam/issues/78

It is unfortunate that you're not onboard with this change, as I have no idea how long it might take to get this update to blend2bam, perhaps years. As it stands, and although I appreciate your effort here, we have another half-working half-broken tool that will confuse new users when it doesn't work properly. It's another thing that I will have to explain away as a community member who supports new users.

It seems that in all of these cases, I have to take matters into my own hands in order to provide working solutions, and it's only a matter of time before this starts fragmenting the community. To some extent, this is already happening. Not your fault of course, but thought I'd mention the effects of not "making it work".

There's a chance Moguri will provide the update, but considering his own work probably relies on the outmoded 2.7x support, and very few other people even understand these issues, this chance might be rather slim.

theanine3D commented 1 year ago

I checked out the issue on blend2bam's tracker. Although support for non-ORM maps should definitely be a thing, ORM maps are also quite common and industry-standard, and it doesn't take much time or effort to make them. I'll add a note on this addon's readme noting that ORM maps are currently required by blend2bam, so that there's no confusion.

I completely understand where you're coming from, but I wouldn't go as far as calling it "half-broken" or "hard-working" - it technically works, it just has a strict requirement that isn't being made obvious or transparent to the user. The only reason we learned about the ORM requirement was because Moguri mentioned it on Discord. I don't think blend2bam itself makes the requirement obvious at all. But hopefully mentioning it in the readme for the Blender addon will help prevent confusion on this.

I have looked into ways to combine textures in Blender so that the ORM creation could at least be automatic. I'd be open to adding this to the addon if I can manage to find a solution that doesn't pull in a ton of dependencies.