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?

Hi, I puchased the plugin recently to simplify the lightmap baking process, which is quite tedious in Blender. I do lack some sort of basic usage tutorial or documentation though. For me as a novice it is very unclear what different settings actually do.

To try to understand I created a super simple scene with a cube and a plane.

Then selected the cube, selected “Lightmap” in bake settings with “Unwrap” checked. When clicking “Bake Textures” it freezes for a while (is there anywhere I can see progress for the operation?) and then I get this as a result:

I was kind of expecting the same material look, but lighted, but I don’t know what this is? Looks like some viewport projection of UVs and objects rendered onto the texture of the cube.

Maybe it’s just me, but a nice tutorial on the basics would certainly help. Perhaps starting with a simple scene like below and then adding more objects and how to bake them and what the results are of different settings and baking operations?

My use case is export to Babylon.js and I’m currently running Blender 3.5

Ok that doesn’t look right :grinning:

Did you buy on blendermarked? There is some documentation there and a link to the website explaining the properties. Also, I added some hints on hover, so just stay with the mouse on a button and wait for the tooltip to show up.

To your problem, I have no clou why this happens. If you check uv unwrap, the add-on generates a new UV called lightmap. Can you send the file to me?

If you want to see a progress bar just uncheck denoise. With denoise enabled, the threads can’t run simultaneously (cause i denoise after the baked image and therefore need to wait for the bake to finish) so blender blocks the hole interface with denoise enabled.

Yes, I bought it on blender market, and I did see the documentation there. It’s good but doesn’t really explain what happens behind the scenes, which order to do stuff etc. So I think a tutorial video would come in handy to understand the process from baking to running in browser.

But to the problem at hand, it seems like it was caused by a conflict with the BIM-addon, once I disabled that it worked more like I had expected it to. Just didn’t notice the error message.

So I’ll continue playing around until I get the hang of it!

Thanks for the speedy response and sorry for the false alarm.

Now that I was going to try this again I ended up with the same problem as before, but now with the plugin I thought was the offender turned off. I just don’t understand what is going on, so I tried the simplest case I could think of:

  1. Create a default 3d scene in blender
  2. Switched to cycles renderer to preview what the light should look like baked
  3. Open GLB Texture Tools and Bake lightmap on the default cube (with UV unwrap checked)
  4. And the result, as before, becomes a perspective render of the scene mapped onto the cube

Video_2023-04-24_171015.wmv (1.9 MB)

(Nothing really happens in the video between 0:09-0:37)

What can I possibly have done wrong in this scenario?