Getting correct textures in glb

I’m trying to export a glb file from Blender. In render preview, it looks like this.

…post continued in the comments as I can only add one file in a post.

However, when I upload it to online glb file viewer, the textures become flattened and dull.

Please suggest what should I do to solve this.
https://www.dropbox.com/s/ty4ftaqbwg1mxv5/CLUSTER%20QUESTION.blend?dl=0

The main difference I see between these two images is that the first is rendered with a path tracer, which automatically includes ambient occlusion for soft shadows in the corners and recessions. In order to get that effect in a realtime rasterizer like three.js you’ll usually want to bake ambient occlusion – the documentation for the Blender glTF addon includes some documentation about how to export an ambient occlusion texture with your model once you’ve baked it.

Additionally, the first image may have a “Filmic” view transform (also called tonemapping) applied in Blender’s Color Management settings. Switch between “Filmic” and “Standard” in Blender to see the difference. This is configurable in some viewers, but the web viewer above doesn’t offer tonemapping.

1 Like

I did not use Blender glTF addon. The option was coming by default in my export list of the file menu. Should I install an addon separately and then try again?

The first image is a screenshot when I turned on cycles rendering option in the viewport mode available by pressing the fourth button with circle.

The glTF addon is installed by default, that’s the right one to use.

I think the rest of my comments still apply – Cycles (a path-tracer) handles ambient occlusion by default. If you switch to Eevee (a rasterizer) with default settings you’ll likely see something much more like the result in web viewers. Similarly, you can try a few different View Transform methods, I think you’re on Filmic by default:

But these are all just ways of identifying why the model looks different in Blender than in the viewer, or which part of the difference you care about. Changing Blender’s renderer and View Transform will not affect the exported file.

If it’s the soft shadows shown in Cycles that you’re trying to achieve, baking ambient occlusion is probably the way to go.

1 Like

Sorry for replying late. Been caught up with other stuff. I’m trying to achieve authentic texture and occlusion as seen with cycles render. You’re right about filmic and Evee render giving the same look as the exported glb file.

There are lot of videos out there covering ambient occlusion. I found the process quite difficult to understand. I watched this video. https://www.youtube.com/watch?v=Px-oUVJZWsE

Is there an efficient and faster way to output glb files in which textures and ambient occlusion look closer to the cycles render?

Cycles is a more realistic (and slower) renderer than many realtime renderers. To get the same results in other viewers you have to bake things. You can bake the AO, or bake the entire base color texture with all lighting included. There are some addons that may help automate the baking (see GLB Texture Tools - Lightmapping, Batch Image Scale, Quick Export - #11 by LdelMar) but I haven’t used these to recommend one.

1 Like

Let me recommend SimpleBake

2 Likes

Thanks a lot for suggesting these plugins. I’ll surely check them out and post my results. :+1:t2::+1:t2:

Let me know if you have problems or get any errors with the glb texture tools.

Okay. So I tried glb export with simple bake.
The result looks like this.

I installed glb texture tools. When I press the ‘bake’ button, I get the error ‘No valid selected objects’ despite the fact that I have selected my entire geometry of whose textures and AO I want to bake.
Enclosing the screen recording as well.

glb texture tools issue.mkv (4.4 MB)

If I use the bake textures button from glb texture tools toolbar, I get the following errors. After seeing these errors, I ran Blender as administrator but I get the same errors.

If I turn off ‘selected to active’ mode, my geometry disappears after pressing the ‘bake textures’ button and I get these errors.

In the first image you chose pbr bake in the bake settings, try AO if you want an AO Map. Pbr does not bake a combined pass, just bakes all your custom nodes so you get a pbr material with just textures.
Can you share an image of the node tree of the material or the file itself?
What version of the add-on do you have?

1 Like

The simple bake image looks like it’s using the wrong uv’s

1 Like

File already shared in the original post.

I have latest version downloaded from the official plugin page.

Textures are missing, can you pack them in the blend file, save once more and reupload?

1 Like

Thanks for replying. Here’s the updated file with all the textures packed.

https://www.dropbox.com/s/ty4ftaqbwg1mxv5/CLUSTER%20QUESTION.blend?dl=0

I couldn’t figure out why it’s not working in your file yet but I just copied your model into a new blend file and there it worked. In AO try to disable denoise. I will have a look at the denoise related error.

If you use the govie tools to export your model, you have a preview button. In the Viewer turn down the cam light to see the lightmap better.


https://www.dropbox.com/t/9EZ2yxWnGwjGkywv

I had a look at your file once more, there is an image attached to the normal pass directly. That’s not gonna work, also the image is not a normal map.

Also, disable selected to active because you only have one object you want to bake.
image

Let me know if this helped you and if I can delete the file from the Dropbox now