it seems like the GLTF Exporter loses the opacity texture of the corresponding material while exporting.
Just open this
.babylon file in the sandbox and create a GLTF export from it.
.babylon export seems to work though.
Is this a bug or on purpose?
Is there a way to work around this?
Hi! I will take a look at this
Hmmm the only textures that seem to be exported are bump, ambient, occlusion and emissive @bghgary are those the ones that GLTF supports?
Opacity textures are not supported in the glTF exporter at the moment. It will take some work to do it as glTF doesn’t support opacity textures as separate textures. The exporter will have to process the textures to include it as part of the alpha channel of the base color texture (albedo texture in Babylon.js).
If anyone wants to contribute the implementation, that would be great.
@bghgary thx for the response.
As a work around we can also try to set the opacity texture in the alpha channel of the albedo texture before the export. In this way the exporter doesn’t have to take care of it.
Is there already a way to do this with BabylonJS code? (smth like
mat.albedoTexture.alphaChannel = ...)
I haven’t really found anything yet.
not really, you would either need a custom shader and a render target to combine both textures on GPU or call readPixels on both textures (assuming they are the same size) to combine the data on CPU in order to create a new raw texture.
Are you asking about how to combine the opacity texture into the albedo texture or if there is a setting to use the alpha channel of the albedo texture for opacity? If it’s the latter, set
We have a like a bunch of albedo textures (n) and a bunch of opacity textures (m), all with the same size.
The resulting texture should be a combination of these two texture types.
Therefore we can’t integrate the opacity in the albedo texture right away, since we would have to create a lot of albedo textures (n * m).
Instead we want to merge the textures on demand.
Anyway I’ll take a look at the suggestions from @sebavan concerning custom shader and render targets, this sounds very promising.
Thx for your help.