KhronosGroup / glTF-Blender-IO

Blender glTF 2.0 importer and exporter
https://docs.blender.org/manual/en/latest/addons/import_export/scene_gltf2.html
Apache License 2.0
1.48k stars 317 forks source link

0 value Opacity not exported #2328

Open EdwHopper opened 1 month ago

EdwHopper commented 1 month ago

The value for Opacity in the principled shader is not working in exported glb if the value is exactly 0. If a full black texture is used then it's working. This might affect other parameters too. But I could not check.

To reproduce just set the opacity to 0 in the shader and export a plane with that material.

Expected behavior With blender 3.6.x setting Alpha=0 is working as expected on glb exports.

If applicable, add screenshots to help explain your problem.

Version

Additional context Add any other context about the problem here.

julienduroure commented 1 month ago

Hello,

Did you mean setting the Alpha value of the Principled Shader to 0.0? image

I can not reproduce.

The exported glb file seems to be OK : the material is exported, with a 0.0 alpha value in BaseColorFactor.

image

Please provide a test case and the exported glb or gltf file.

EdwHopper commented 1 month ago

@julienduroure Thanks for your time! I checked again with a few other viewers and it looks like the issue manifested only inhttps://sandbox.babylonjs.com/ so the glb from blender 3.6 is loading fine but not the one from 4.2. https://github.khronos.org/glTF-Sample-Viewer-Release/ shows this error for both files: TypeError: model.mainFile[1].bytes is not a function. Finally https://modelviewer.dev/editor/ and https://gltf-viewer.donmccurdy.com/ seem fine. I understand those viewers are unrelated projects but sometimes artists are required to check the assets in specific viewers and it is difficult to check for compatibility. I attached 2 versions of the glb containting a cube with Alpha=0 and blended opacity in the shader, exported with blender 3.6.9 and 4.2.1 just in case. alpha_glb.zip

julienduroure commented 1 month ago

Hello, Ok, so looks like the issue is in babylonjs.

The change between the 2 versions is the alphaMode used.

EdwHopper commented 1 month ago

I understand the issue now. So the Render method=Blended is ignored now if Alpha=0 and no texture used?

Screenshot 2024-08-26 163057

julienduroure commented 1 month ago

Hello,

You can read the discussion here: https://github.com/KhronosGroup/glTF-Blender-IO/issues/2111 More info about the exporter here: https://github.com/KhronosGroup/glTF-Blender-IO/pull/2152 Documentation here (on how to manage alpha now that Blender EEVEE-Next replaced EEVEE legacy) : https://docs.blender.org/manual/en/latest/addons/import_export/scene_gltf2.html#alpha-modes

lowpolycosmonaut commented 2 weeks ago

It needs to be that setting alpha blend to 0.0 means the material is set to alpha blend in the GLB

Currently, setting to Alpha Blend 0.0 or Hashed 0.0 sets the GLB exported material to be Alpha Clip