-
-
Notifications
You must be signed in to change notification settings - Fork 35.5k
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
GLTFLoader: Specify color space of inputs #26534
GLTFLoader: Specify color space of inputs #26534
Conversation
if ( ColorManagement.workingColorSpace !== LinearSRGBColorSpace && 'COLOR_0' in attributes ) { | ||
|
||
console.warn( `THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${ColorManagement.workingColorSpace}" not supported.` ); | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like converting color attributes was lost in the new roadmap in #26479. We should plan to cover this case in the long term, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I do intend that to be part of step 2.4, just not ready to make those changes here yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or did you mean just handling sRGB vs Linear sRGB vertex colors in existing workflows, without this wide gamut work? Are we missing something there, if so?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see - I think I expect there to be more to this color vertex attribute issue than just updating the loaders. I think item 3.3 we added in #23614 captured what I imagine being needed more completely. For example if users are dynamically generating vertex colors for geometry they need a way to ensure it's converted to the working color space. Though I guess that's convenience more than anything at this point since users can use the Color
instance convert before constructing the vertex data array 🤔
Either way I think this is a good PR!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yeah. This is kind of verbose and unintuitive today:
const _color = new THREE.Color();
const color = geometry.attributes.color;
for (let i = 0; i < color.count; i++) {
_color.setRGB(color.getX(i), color.getY(i), color.getZ(i), inputColorSpace);
color.setXYZ(i, ..._color);
}
I don't know if I like the idea of a color-specific BufferAttribute subclass, but a cleaner way to do this would be nice.
Unfortunately, it seems like this PR broke
Now if |
Good catch! Would you like to fix this with a PR? |
I suppose I could do it later today |
Here's the PR |
In order to support wide-gamut working color spaces, loaders should declare the colorspace of source data when constructing THREE.Color instances, rather than (a) explicitly converting it to LinearSRGBColorSpace, or (b) implicitly assuming the working color space matches the input.
In GLTFLoader, that means...
Conversion of vertex colors is slightly more work (consider that morph targets contain deltas against the base vertex color) so I've simply logged a warning to alert us to that situation, if it comes up.
No user-facing differences are expected as a result of this PR; it takes effect only if/when we allow changing the working color space.