Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: GLB to GLTF preserving bitmap file names? #201

Open
echadwick-artist opened this issue Dec 30, 2020 · 9 comments
Open

Feature request: GLB to GLTF preserving bitmap file names? #201

echadwick-artist opened this issue Dec 30, 2020 · 9 comments

Comments

@echadwick-artist
Copy link

echadwick-artist commented Dec 30, 2020

Could the GLB to GLTF converter preserve original bitmap file names?

When I convert a GLB into GLTF, the embedded bitmaps are renamed as glb-filename_img#.ext. The original bitmap filenames are preserved in the "textures": "name": strings, just not in the actual image filenames.

It would be helpful to retain the original names, as they're often easier to debug with since they're often descriptive names.

(BTW, this extension is amazing! Thanks Ed and everyone working on this!!)

For example, a snippet of the generated GLTF:

"textures": [
{
"sampler": 0,
"source": 0,
"name": "FDLV3095_resin-grill_normal.png"
},
{
"sampler": 0,
"source": 1,
"name": "FDLV3095_resin-grill_occlusion.png"
},
{
"sampler": 0,
"source": 2,
"name": "FDLV3095_resin-grill_emissive.png"
},
{
"sampler": 0,
"source": 3,
"name": "FDLV3095_resin-grill_basecolor_FDLV3095_resin-grill_opacity_alpha_Map__2138624033.png"
},
{
"sampler": 0,
"source": 4,
"name": "FDLV3095_steel_occlusion.png"
},
{
"sampler": 0,
"source": 5,
"name": "FDLV3095_resin-hardware_normal.png"
},
{
"sampler": 0,
"source": 6,
"name": "FDLV3095_resin-hardware_occlusionFDLV3095_resin-hardware_rough0.png"
},
{
"sampler": 0,
"source": 7,
"name": "FDLV3095_resin-hardware_emissive.png"
},
{
"sampler": 0,
"source": 8,
"name": "FDLV3095_resin-hardware_basecolor.png"
},
{
"sampler": 0,
"source": 9,
"name": "FDLV3095_resin-base_normal.png"
},
{
"sampler": 0,
"source": 10,
"name": "FDLV3095_resin-base_occlusionFDLV3095_resin-base_rough0.png"
},
{
"sampler": 0,
"source": 11,
"name": "FDLV3095_resin-base_emissive.png"
},
{
"sampler": 0,
"source": 12,
"name": "FDLV3095_resin-base_basecolor.png"
},
{
"sampler": 0,
"source": 13,
"name": "FDLV3095_glass_normal.png"
},
{
"sampler": 0,
"source": 14,
"name": "FDLV3095_glass_occlusionFDLV3095_glass_rough0.png"
},
{
"sampler": 0,
"source": 15,
"name": "FDLV3095_glass_emissive.png"
},
{
"sampler": 0,
"source": 16,
"name": "FDLV3095_glass_basecolor_FDLV3095_glass_alphatest_alpha_Map__2138624051.png"
},
{
"sampler": 0,
"source": 17,
"name": "FDLV3095_bulbs_occlusion.png"
}
],
"images": [
{
"uri": "FleurdeLysCredleTableLamp_ON_img0.png"
},
{
"uri": "FleurdeLysCredleTableLamp_ON_img1.png"
},
{
"uri": "FleurdeLysCredleTableLamp_ON_img2.png"
},
{
"uri": "FleurdeLysCredleTableLamp_ON_img3.png"
},
{
"uri": "FleurdeLysCredleTableLamp_ON_img4.png"
},
{
"uri": "FleurdeLysCredleTableLamp_ON_img5.png"
},
{
"uri": "FleurdeLysCredleTableLamp_ON_img6.png"
},
{
"uri": "FleurdeLysCredleTableLamp_ON_img7.png"
},
{
"uri": "FleurdeLysCredleTableLamp_ON_img8.png"
},
{
"uri": "FleurdeLysCredleTableLamp_ON_img9.png"
},
{
"uri": "FleurdeLysCredleTableLamp_ON_img10.png"
},
{
"uri": "FleurdeLysCredleTableLamp_ON_img11.png"
},
{
"uri": "FleurdeLysCredleTableLamp_ON_img12.png"
},
{
"uri": "FleurdeLysCredleTableLamp_ON_img13.png"
},
{
"uri": "FleurdeLysCredleTableLamp_ON_img14.png"
},
{
"uri": "FleurdeLysCredleTableLamp_ON_img15.png"
},
{
"uri": "FleurdeLysCredleTableLamp_ON_img16.png"
},
{
"uri": "FleurdeLysCredleTableLamp_ON_img17.png"
}
],

@emackey
Copy link
Member

emackey commented Jan 4, 2021

I've thought about this on occasion. One concern is security, if you "import" a GLB to glTF, it could end up overwriting a lot of images in the same folder. With the current system, all of the images written are known to fit a certain pattern of names starting with the user's selected base name. But with this suggestion, all sorts of names in the same folder could potentially be overwritten.

I can see the potential usefulness, but I'm hesitant because of the implications. And for my cases, the final shipped product is usually the GLB, so the filenames aren't needed there.

@bghgary
Copy link
Contributor

bghgary commented Jan 4, 2021

I think when we update the GLB format someday (perhaps due to this), we should ensure that glTF to GLB and back will always round trip perfectly, including the file names and should take any external reference (even from extensions) into account. The file names can be stripped from a GLB if necessary for optimal size. If we did that, then this will be a non-issue.

@echadwick-artist
Copy link
Author

When I don't want to overwrite existing files, I direct the VSCode to a new folder. It would be nice to add a warning message asking if we want to overwrite or cancel.

@echadwick-artist
Copy link
Author

If you stripped names, that makes sense from an efficiency standpoint.

However it makes editing much more difficult, if textures are just named as numbers.

For example if I'm editing a glTF with variants, and I discover a roughness texture is rendering incorrectly, I need to edit find the rough texture for that material so I can edit the pixels. But the extracted textures are named with integers, not descriptive names.

I can't go back to the source model in my DCC, since it doesn't support variants. Re-exporting would overwrite the variants editing I did in the glTF file. So instead, now the glTF and its textures are my source files that I need to edit.

Perhaps when you extract the GLB into glTF + BIN + textures, you could name the textures using a pattern: materialname_texturename.ext

For example if we look at AlphaBlendModeTest sample model, an extracted texture could be named MatBed_normalTexture.jpg
(Line 987 for the material name, line 988 for the texture name, line 973 for the extension)

Then just strip those back down into incremental integers when you write out the GLB?

@bghgary
Copy link
Contributor

bghgary commented Jan 8, 2021

Perhaps when you extract the GLB into glTF + BIN + textures, you could name the textures using a pattern: materialname_texturename.ext

This isn't as simple as it sounds. Multiple materials can point to the same texture and then the naming is hard to determine. I ran into this in my tool.

@echadwick-artist
Copy link
Author

How about just naming based on the first instance you encounter then?

Art teams rely heavily on asset naming conventions. Ditching them for compression makes sense, but they're still really important for authoring.

@bghgary
Copy link
Contributor

bghgary commented Jan 11, 2021

It's certainly possible, though it is probably more complicated since it would require traversal of the glTF scene graph. This is non-trivial especially with extensions. If the images had a name associated with it in the glTF, I suppose it is possible to use that?

Perhaps people should be using loose glTFs instead of GLBs if it's not the final form?

@echadwick-artist
Copy link
Author

Usually glTFs are distributed in binary form, it's just easier. I keep telling people it's meant to be a compressed display format, not a source format, you shouldn't treat it like a source file. Even if they're compressed/lossy, people will still want to use them as a translation format, and thus want to edit GLBs.

Anyhow, if it's too difficult, it's not really a big problem. Just an annoyance when editing to have the names go a bit "anonymous".

@bghgary
Copy link
Contributor

bghgary commented Jan 12, 2021

GLBs aren't compressed by itself. It's a way to contain the loose files into a binary form. It doesn't even have to be one file. GLBs can also point to external files but almost no one does this.

That said, yeah, people use GLB to distribute since it's almost always one file and it's easier.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants