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

AlphaMode / alphaCutoff information is lost when re-exporting Project Polly in Blender 2.90 #1264

Open cx20 opened 3 years ago

cx20 commented 3 years ago

Describe the bug I have tried loading the Project Polly model in Blender 2.90 and outputting it in glTF format. However, some information seems to be missing. For example, the alphaMode / alphaCutoff.

To Reproduce Steps to reproduce the behavior:

  1. Download the following file. https://github.com/KhronosGroup/glTF-Blender-Exporter/blob/master/polly/project_polly.blend (Probably created in Blender 2.79)
  2. run Blender 2.90
  3. Open project_polly.blend
  4. Export to project_polly.gltf Format : [gltF Separate (.gltf + .bin + textures)] [x] Cameras
  5. Check the contents of project_polly.gltf. alphaMode / alphaCutoff is not output.
Material name glTF JSON
Location Transparent image
Polly Display image

Expected behavior

Material name glTF JSON
Location Transparent image
Polly Display image

The output results are expected to be similar to the glTF file below. https://github.com/KhronosGroup/glTF-Blender-Exporter/blob/master/polly/project_polly.gltf

Screenshots

Blender 2.79 glTF Export results Blender 2.90 glTF Export results
image image

.blend file/ .gltf https://github.com/KhronosGroup/glTF-Blender-Exporter/blob/master/polly/project_polly.blend

Version

scurest commented 3 years ago

This uses the old "glTF Metallic Roughness" group. The docs for how alpha are supposed to be determined are here.

cx20 commented 3 years ago

@scurest Thank you for your advice. I have seen that changing the default Blend Mode from Opaque to another value changes the alphaMode of glTF. However, the value of AlphaCutoff 0.5 is not output to the glTF file and seems to be 0. Is this the expected result?

default Blend Mode modified Blend Mode glTF alphaMode
Opaque Alpha Blend BLEND
Opaque Alpha Clip MASK
Material name Before After
Location Transparent image image
Polly Display image image
Material name Before After
Location Transparent image image
Polly Display image image
scurest commented 3 years ago

I was just diagnosing the problem, sorry if I was unclear.

The exporter currently always uses "Blend Mode" to set alphaMode and (when using Alpha Clip) "Clip Threshold" to set alphaCutoff. Some parts of the old "glTF Metallic Roughness" group are implemented, like doubledSided, but the alpha stuff is not.

You can use "Clip Threshold" to set the alphaCutoff for the moment.

cx20 commented 3 years ago

You can use "Clip Threshold" to set the alphaCutoff for the moment.

Yes. I set the "Clip Threshold" and made sure it is reflected in the glTF "alphaCutoff".

Blender glTF
image image
cx20 commented 3 years ago

I could see that there are compatibility issues with 2.79 and 2.90 so far.

BTW, I think it's another matter, but Polly exported in Blender 2.90 seems to pop its eyeballs. image

donmccurdy commented 3 years ago

Sounds like we should update the source .blend sample file to be compatible with 2.90? At least for the material settings portion of the question.

cx20 commented 3 years ago

@donmccurdy Yes, I think it would be nice to have a .blend file for Blender 2.90. The Project Polly glTF file in the old repository had a lot of validation errors, so I tried to re-export it with the latest version of Blender 2.90. But that didn't work either and I was having trouble with it.

cx20 commented 3 years ago

BTW, the reason for this in the first place was because I wanted to know what was correct, as each viewer had a different result for the Project Polly nameplate display.

While the results of Filament are apparently the desired result, I feel that Three.js and Babylon.js are more correct in terms of glTF output. However, I have not been able to make a decision because I don't know the correct answer.

image

emackey commented 3 years ago

Not to make things more complicated, but Polly has always abused alpha blending to look like glass, which was never the intention of alpha in glTF. Alpha is supposed to indicate the absence of a material, such as the edge of a leaf in a quad, or medical gauze wrap with lots of holes too small to see.

For glass, we recently ratified a new extension, KHR_materials_transmission. Among other things, this allows full specular reflections to take place on the clear parts of the glass (which alpha blending does not do). It also allows for frosted glass (via material roughness), and lets path tracers know they can trace reflections in the glass.

Blender support for this is documented in 2.91.

cx20 commented 3 years ago

@emackey Thank you for telling me.

I was wondering why the wooden part of the base of the nameplate was transparent, and then I realized it was because glass and wood are made of the same material. Perhaps it is better to separate this part of the material. (Why the wood isn't transparent in the case of Filament is a curious but different topic).

And, I thought it would be nice to have a Polly v2 that takes advantage of the new glTF extension.