-
-
Notifications
You must be signed in to change notification settings - Fork 35.7k
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
Suggestion: add a bufferAttribute.convertGammaToLinear method #15678
Comments
From https://threejs.org/docs/#examples/loaders/GLTFLoader
|
Yes, the models are not spec compliant. But it seems like quite a few models are not spec compliant, which is why I'm suggesting this. Also, as far as I'm aware other model formats don't specify the color space for vertex colors. |
I'm not aware of any formats other than glTF that specify what the vertex colors should use. 😞 But yeah, it's not uncommon to find models with vertex colors using sRGB. I don't have a preference whether we add the method or not, but: (1) if so, perhaps I can help with the second, that's my mistake on the Parrot model. |
Agreed. I've been working on converting the Ro.me models. It seems like the blender 2.80 exporter correctly converts the vertex colors to linear, but unfortunately the file sizes are much bigger. Parrot.glb goes from 95k to 326kb, even with uvs and normals disabled. If you have any ideas on how to reduce that, let me know 😃
All of this linear workflow stuff is confusing for users, and it's not helped by the fact that the transition has been slow and is incomplete across the industry, meaning that many apps are stuck half way between a linear and gamma workflow, such as three.js with its backwards compatible Older models like this generally have colors or vertex colors specified in sRGB, probably always if they are any other format than glTF. Older formats and apps often don't even give any consideration to color space. Personally, I've been studying how three.js handles gamma for the last couple of days and I think I understand it well now, but it is tricky, and adding this method might make things easier for people.
Perhaps we would should add both to match the methods on |
I've done a bit more testing, and at least for the Ro.me models it should be That's what works for materials: renderer.gammaFactor = 2.2;
renderer.gammaOutput = true;
const material = new THREE.MeshBasicMaterial( {color: 0x800080} );
// testing the output of the material, this gives #800080
material.color.convertGammaToLinear( 2.2 );
// however, this outputs a material with color #880088
material.color.convertSRGBToLinear( 2.2 ); Likewise, when I apply the |
It's probably resampling the animations too aggressively. 🙃 I can fix the colors without bringing them through Blender I think; I have some scripts lying around heh.
I think that's a result of three.js having a
Also note that |
Ok, that would be cool. At least Parrot, Stork, Flamingo and Horse need this fixed. Not sure if other models in the repo have vertex colors.
I guess we'll have to wait for #11337 to be resolved for that. Yeah, this makes sense. So, that means that when I do However, because That also means we should use |
We have known we need to handle color space correctly for years. #6383. Changes to the library in this regard have been slow because there has been a lack of standardization or convention in the industry. I have also been waiting for sufficient demand in this project. In the past, only a few contributors have shown interest in this topic. Regarding gamma, stick to |
I think that because, in general, if you have a nearly correct workflow (such as converting to Gamma instead of sRGB) then errors will be minor and people don't notice there's a problem, as with my purple color example above that ends up outputting #880088 instead of #800080. Factor in lights and it's going to be basically impossible to notice something is wrong. However, I'm coming to believe that this is one of those things that subtly effects the overall quality of the scene and lighting in a very important way - that is, it's one of the things that makes people go from "hmm... another 3D scene" to "wow, that looks amazing! 😁". So count me interested, although unfortunately very short on time to contribute over the next while. |
I do not vote to introduce I think it's okay to ask the app/user to iterate over the color buffer attribute and convert it if required. I suggest to discuss other color management related topics in #19169. |
Vertex colors are usually specified in gamma space, at least on the models that I've come across.
This makes it hard to use a properly linear workflow, since setting
renderer.gammaOutput = true
will mess up the vertex colors on these models. The Parrot.glb model is one example of this.It's fairly simple method:
What do people think about adding
bufferAttribute.convertGammaToLinear
?The text was updated successfully, but these errors were encountered: