Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

glTF 2.0 models appear dark #6412

Closed
lilleyse opened this issue Apr 3, 2018 · 10 comments
Closed

glTF 2.0 models appear dark #6412

lilleyse opened this issue Apr 3, 2018 · 10 comments

Comments

@lilleyse
Copy link
Contributor

lilleyse commented Apr 3, 2018

Compared to other glTF viewers out there our models usually appear darker. We should experiment with either:

@pjcozzi
Copy link
Contributor

pjcozzi commented Apr 3, 2018

I also think IBL will help here.

Cesium does look much darker, so I am keen on a quick workaround in the meantime.

For example, compare Cesium to the other engines here: KhronosGroup/glTF-Sample-Models#154 (comment)

Perhaps @emackey has a few minutes to spare to work on this? 😄

@cx20
Copy link

cx20 commented Apr 3, 2018

I tried displaying Polly.gltf in the following version. It seems that it is dark when it is the latest version (v1.44).

Cesium.js v1.43 + Polly.gltf result:
image

Cesium.js v1.44 + Polly.gltf result:
image

@pjcozzi
Copy link
Contributor

pjcozzi commented Apr 3, 2018

@lilleyse @cx20 perhaps related to #3737 as well?

@emackey
Copy link
Contributor

emackey commented Apr 3, 2018

The Polly model there (the dog alone) isn't just dark, it's pitch black, even the emissive green lights on the dog have gone out.

git bisect blames my tangent vector fix, 2990c50. It's possible that tangent vectors and skinned animations aren't compatible in Cesium's current implementation, newly broken by adding support for tangent vectors. I'll dig into this.

Other (non-skinned) models look the same as they have before, so I think the Polly/skinned model bug is separate from the general lighting concerns.

EDIT: Cesium (and gltf-pipeline) use a single hasTangents Boolean, that gets set to true if any primitive inside a glTF has tangents. This is a bad assumption for Polly. Polly supplies tangents for everything except the dog (ie the floor, the box, the sign, etc). The dog itself supplies no tangents, and relies on auto-computed tangents for lighting. Cesium won't auto-compute them, now that in 1.44 the supplied tangents are respected, because it sees other tangents elsewhere in the model. Cesium ends up normalizing a zero vector in GLSL, and the fragments turn black.

In addition to hasTangents, Cesium also has a hasMorphTargets Boolean flag, that is likewise globally true for any glTF that contains any morph targets.

It also has a hasNormals flag that is simply hard-coded to true. It is tested several times, but there is no code path that would ever set it to anything other than its initial value of true.

@emackey
Copy link
Contributor

emackey commented Apr 3, 2018

Turns out, Polly actually has a material (named "Head" at index 0) that is used for the eyes, which supply tangents, and the rest of the head, which does not supply tangents. As such, a single shader must handle both cases, or we need to move to per-primitive materials. Or, we use the supplied tangents only when ALL of the affected meshes supply tangents, and ignore supplied tangents otherwise. That last option is the least destructive change, I'll try it first.

@lilleyse
Copy link
Contributor Author

lilleyse commented Apr 3, 2018

We already split materials used by multiple primitives by skinning/vertex colors, so it shouldn't be too bad to also split by tangents.

@JackD83
Copy link

JackD83 commented Jan 24, 2023

It seems that this bug has returned between 1.96 and 1.97 till the current 1.101. I have multiple 3DTiles sets that are now completely black.

Polly now looks like this:
Polly 1 101

@cx20
Copy link

cx20 commented Jan 24, 2023

@JackD83 Perhaps the reason why it looks dark is that the time of the area displayed by Cesium.js was night.
Below is an online demo using Cesium.js.
https://cx20.github.io/gltf-test/examples/cesium/index.html?url=https://rawcdn.githack.com/KhronosGroup/glTF-Blender-Exporter/dd7a3dbd8f43a79d572e7c45f4215f770bb92a37/polly/project_polly.gltf

image

BTW, I think the antenna-like things coming out of Polly's ears are artifacts.

@ggetz
Copy link
Contributor

ggetz commented Jan 24, 2023

@JackD83 Would you be able to include a Sandcastle example that replicates the issue? That would help us give us more context to determine the issue. Thanks!

@JackD83
Copy link

JackD83 commented Jan 25, 2023

@JackD83 Perhaps the reason why it looks dark is that the time of the area displayed by Cesium.js was night.

You where right (and I feel stupid) . That means polly is fine and its only my own gltf models that are black. I dug a little deeper and the models in question where converted from gltf 1.0 to 2.0 using a custom script. The script set the single texture as emissiveTexture:

"emissiveTexture": { "index": 0, "texCoord": 0 }

This worked up to Cesium 1.96 and results now in a black model.

Using
"baseColorTexture":{ "index": 0, "texCoord": 0 },

inside pbrMetallicRoughness is working.

emissiveTexture probably was wrong from the beginning, but should work nonetheless. The windows gltf viewer and others have no problem with it. We have large datasets and I would rather not have them repacked and redistributed.

You can find a sandcastle with the models here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants