GLB Texture Tools - Lightmapping, Batch Image Scale, Quick Export

Blockquote Another thing that i noticed and i am not sure why is happening, is that after switching back and forth betwen original and baked texture, sometimes some indexes loose their material, they become empty.

The mapping is done simply by checking the names of the materials. Once you bake, it will add a new material named after your original material + _bake. If the material slot is empty, it won’t be able to match the names.

Have you checked before if there are any empty material slots in your original file? Some scenes (e.g., imported from fbx) sometimes have empty material slots. To get rid of them, click the clean materials button before you start.

Can you send me the file or just a part of it so I can try to find out why it is deleting the materials? That should not happen!

Hello

I just recreated the issue again and i can send you the meshes with the problem.
It happens when I change one of the materials and try to do a bake again by selecting multiple objects. Only one of them had the material changed by me, the other ones should have kept their materials but instead its loosing them.
The material is still on the list, but its not assigned anymore.
This does not happend when I do the first baking after first time applying all original materials
In fact i noticed not even that python error happens when I bake the first time with all original materials.
The problems appear when I change one of the materials and do the bake again.

Does it automatically override materials that have already being baked or does it do the baking for every material again?

The scene and all the objects were modeled by me

Later edit :

Could it be because I have appened some already baked materials from another file so it didnt have the original ones anymore?

The scene does always have to have both the original and the baked one right? Still not sure if this is how it started or its something else.

Second Edit

I also noticed, as a side thing that if you select multiple objects where some have baked and others have original materials, it does`nt do anything. Maybe it could be nice to know which one needs the reversal and which one not.

So, for anyone having the same issue.

The error happens because, for the rebaking, I delete the bake material and create a new one. If you have object a with the original material but object b still has the bake material it will delete the material on object b if you just select object a for baking!

To avoid this but still being able to set the bake / original materials individually how you want, I introduced a new default affect mode called linked materials. When you switch between original and bake material, it will search for all objects in the scene that share the same materials that you have on your selected object. This way we make sure there isn’t an object with the baked material and one with the original.
image

To get the update download it on blendermarked (v0.1.3) or from the git repo.

Best regards, Lorenz

1 Like

Did you manage to get the right uv tiling?

This is great! Thanks alot !

Is it correct to assume that the combined use of this addon and GovieTools generates a 3D asset that works for WebGL online viewer as well as on Unity UE and Godot if it is imported into these game engines? And do the live preview function and/or the Govie Online Viewer also show the animations included in the 3D asset, and if so, can you select them to see how each one behaves? And finally, is there an option to customise the LUT/colour profile?
These questions stem from the need to stop installing 30GB of Unity + 30GB of Unreal Engine just to see if the assets behaves well in the aforementioned game engines.

Yes, this add-on helps speeding up the process of generating a glb file, which is commonly used for webGL. But other engines, like unity, can import glb files and convert them into their internal format (standard unity ubershader).

Yes and yes

The preview mimics our web viewer Govie. You will see your model like you would see it online, but without needing to upload it to our platform. The color profile is set to cinematic. Internally I can switch it in the preview quite easy via code but there is no gui element for this yet. If you really need it I could add it to the gui but because unity and ue use different shader im not sure the results will be the same.

1 Like

Nevermind! Now that I think about it more thoroughly there’s already the Blender 3Dview itself that can match the Unreal Engine “color” by using the appropriate settings (I remember to have bookmarked a tutorial about that subject three years ago) , so the govie preview (internal and web version) is good as it is, it just need to show the user that textures and animations and asset axys orientation are properly setup before the final export :slight_smile:

Screenshot_1831

I don’t know if you already registered but once you do you can also generate a link of the asset and present it to your customer before bringing it into Unity. This way they can check if textures and animations are okay and if they have an account they can also add notifications for things that need to be changed.

Hey there !
Your addon looks really great, but like the first thing i wondered is wether you support ktx2 / basis texture compression or if it’s on your roadmap? For me that’s a big requirement because it speeds up loading times on mobile devices massively and also can improve visuals in some cases.
Another big thing would be to have an usdz exporter as well for Apples’ Quicklook and with that an option to export specific normal maps as 16 bit. As far as i know ktx2 / basis isn’t supported for usdz and i’ve encountered normal map bit depth issues with usdz quicklook models that just weren’t there with glb models because gltf supported export with normal map intensity while i had to bake that into the normal map textures for usdz.
On that note do you support normal map intensity for glb models ?
Anyways i am pretty excited for this addon because it could make my life a lot easier in the future, congratulations for such great work :slight_smile:

I suspect that KTX2 support would need to land in OpenImageIO (and then in Blender) before we can use it in Blender addons. It’s generally not so easy to bring native libraries into python addons, and KTX2 would require native libraries. You can upvote the request here: https://github.com/OpenImageIO/oiio/issues/2329

In the meantime there are lots of tools for converting the textures in your GLB file from PNG or JPEG to KTX2 after exporting from Blender.

As far as i know ktx2 / basis isn’t supported for usdz

Unfortunately correct. :+1:

On that note do you support normal map intensity for glb models ?

Blender itself can export the “strength” factor on a normal map node (see https://docs.blender.org/manual/en/latest/addons/import_export/scene_gltf2.html#normal-map), though I’m not sure how/if that interacts with the addon here.

Thanks for the quick answer Don! Die Add-on uses Blenders regular GLTF Exporter, so the nomalmap intensity is taken into account.

For compression and optimization we use the meshoptimzer

Use -tc for ktx2

You could also use Dons GLTF transform if you don’t need to reduce triangle count.

Hi @LdelMar ! I’ve just bought the asset, to get me out of troubles (setup lightmap with a .gltf) aaaaaaaaaand, it is not working. Aaaaaaaaand, I might know why : is the asset compatible with an ACES workflow ? I’ve rencently switch blender to the ACES color space, removing the vanilla one, and according to that error message, the addon can’t find the Linear color profile.

Do you have any workaround to this, that would not require to me switch back to the blender vanilla color management configuration ?

Beside that, great work !
I am pretty sure your addon will help me get throught my initial issue (once this is, somehow, fixed).

[EDIT]

**I’ve restored the vanilla color management presets, and the lightmap bake worked. **
But then I am confuse again, what should I do to get a gltf export of my model, with both its PBR textures and the lightmap ?

This might sound silly, but I am still a new guy to blender.

The gltf format doesn’t support lightmaps out of the box. You could try to insert the baked lightmap into the emission input and see if the result is what you want. If you use the govie tools to export and then preview your exported file, the lightmap is multiplyed and should look ok. But I would need to know what you want to do with the model after the export. You could also send me a personal message and we have a little zoom talk.

Hey !
If it’s OK, we can continue here, so that my issue(s) can (maybe) help someone else checking this thread.

So, I’ve made a post few days ago here : the goal is to get a well optimized 3D object, for a ThreeJS experience.

I’ve made several tests, and when mixing together the PBR textures and the Lightmap (within the emission shader), I am getting a VERY bright texture. So it appear that my lightmap is wrong.

I am confusing myself a bit more, with both 3D and 2D on the matter of “how things work”.

My current shader :

How bright the scene is (at ,5 factor) :

How I want it to be (but maybe that is not possible and I am going in the wrong direction) :

So as Don wrote in the other thread, there is no real concept of a lightmap in gltf. Also using extra node like the curve you use will not be exported. Therefore, I made the pbr bake which will generate a new material with all your changes baked into new images. If you use the glb texture tools to create a lightmap afterwards (having a standard principled shader with just images attached) that lightmap gets exported and in three.js I manually but it into the lightmap as Don suggested. Did you try that workflow?