-
-
Notifications
You must be signed in to change notification settings - Fork 4k
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
[renderer] Add color management option, replacing gammaOutput. #3757
Conversation
It looks good to me. What's pending? |
Some questions in #3509 (comment). This code is working, I'm just not sure if this is the right API to give users a colorspace option. I would probably like to create a new example rather than editing the anime-UI one, too. |
How about a material system because it only applies through the material component? e.g., |
@@ -7,9 +7,9 @@ | |||
<script src="../../../dist/aframe-master.js"></script> | |||
</head> | |||
<body> | |||
<a-scene> | |||
<a-scene renderer="gammaOutput: true;" color-space="sRGB"> |
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 should be camel case: colorSpace
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.
as is, it's an html attribute
Yep, probably a property of material makes more sense. |
@dmarcos just to clarify — are you OK with this being a material system? I think something at the scene level is preferable to including colorspace on every material component. |
@donmccurdy Yep, probably a system is better. |
This is ready for review. On the logo page, note that the result looks the same as before, with the exception of the (COLLADA) trees, which are washed out. That should be fixed with #3866, but this PR should be merged first. |
At some point I think three.js may deprecate the |
I'm thinking of reversing the names on this, actually. The current names indicate what your input values are considered, assuming
In the second case, all |
So the only concern is for previous scenes that had created their materials directly. But going forward, everything will default under
Can you describe a tiny bit more what it would do differently? Would it read the workflow and adjust the material colors? Just to understand. And is "workflow" a term used? Or does it describe "color space"? |
Right. I'm hoping this option will eventually shift up into three.js — then we can rely on that, and
Right, so for example: var workflow = sceneEl.systems.material.data.workflow;
if ( workflow === 'linear' ) {
colorPalette.forEach((color) => color.convertGammaToLinear( 2.2 ));
} The gist here is that using
I think either term could be used. C4D has a "Linear Workflow" checkbox. Unity calls it a workflow in their docs, but the checkbox says "Color Space: Linear". Maya requires you to set a bunch of colorspace and color profile settings, all of which together are documented as a "workflow". The important thing to know is that this is the colorspace in which renderer calculations are done, and not the color space textures and colors are input as (which is pretty much always sRGB), or the color space output from the renderer. Because that's easy to misunderstand, I think that |
I'll go through and do a bunch of before/after screenshots to compare here. |
Thanks, should be good to merge, just slowly absorbing the implications. What's behind the decision for linear vs gamma for default? |
Here's a comparison:
In these examples, I see three effects:
However, the difference when using other components — like |
Thanks for the rundown! So I think maybe it's ok to choose whatever is the more sensible default ( |
I think I'd rather stick a toe in the water first on this one, with an opt-in for 0.9. 😅 Linear is a better choice in the long-run, but it will affect existing components badly if they instantiate THREE.Color or THREE.Texture themselves. I'm hoping that we can test this out and get feedback to influence what three.js does in the future. If the same changes I'm making here could be done in three.js instead — treating colors as sRGB by default — there would be no need for components to add |
OK. Last thing then I guess is document the new properties/defaults in this table also: https://github.com/aframevr/aframe/pull/3757/files#diff-601edc1958f8dda05aaef2c8adf3cf0cL24 Then looks good! |
src/systems/renderer.js
Outdated
} | ||
} | ||
|
||
// TODO: Uncomment these lines and deprecate 'antialias' for v0.9.0. |
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.
Do we want to uncomment this now?
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.
Done. ✅
Ok, refactored this a bit. Also added some helpers so e.g. |
Looking again, looks scary |
docs/components/renderer.md
Outdated
@@ -26,28 +26,30 @@ The `renderer` component configures a scene's | |||
| Property | Description | Default Value | | |||
|-------------------------|---------------------------------------------------------------------------------|---------------| | |||
| antialias | Whether to perform antialiasing. If `auto`, antialiasing is disabled on mobile. | auto | | |||
| gammaOutput | Whether to pre-multiply gamma on textures and colors before rendering. | false | | |||
| workflow | Whether to use color-managed (`linear`) or legacy (`gamma`) workflow. | gamma | |
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.
Term workflow seems generic word. Does colorManagment
make more sense?
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 maybe colorSpace
?
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.
To note: prior explanation:
And is "workflow" a term used? Or does it describe "color space"?
I think either term could be used. C4D has a "Linear Workflow" checkbox. Unity calls it a workflow in their docs, but the checkbox says "Color Space: Linear". Maya requires you to set a bunch of colorspace and color profile settings, all of which together are documented as a "workflow".
The important thing to know is that this is the colorspace in which renderer calculations are done, and not the color space textures and colors are input as (which is pretty much always sRGB), or the color space output from the renderer. Because that's easy to misunderstand, I think that workflow is a bit clearer than colorSpace.
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.
^Per above I think "colorSpace" is too confusing. But colorManagement: true
might be easier to understand, I do like that...
Maybe. I'm not sure how large the change will be in threejs. I can take a look at that but also don't want to hold up 0.9.0... will try to get a rough estimation of the work involved tomorrow. |
@donmcurdy This is almost |
src/systems/renderer.js
Outdated
}, | ||
|
||
applyColorCorrection: function (colorOrTexture) { | ||
if (this.data.workflow !== 'linear' || !colorOrTexture) { |
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.
Maybe simpler:
if (this.data.workflow !== 'linear' || !colorOrTexture ||
(!colorOrTexture.isColor && !colorOrTexture.isTexture) { return; }
if (colorOrTexture.isColor) {
colorOrTexture.convertSRGBToLinear();
} else {
colorOrTexture.encoding = THREE.sRGBEncoding;
}
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.
tbh this seems harder to read to me 😇
glTF assumes sRGB (gamma) per standard. More and more experiences include glTF models. It makes sense to default to |
Note that the workflows are named for the space in which the renderer works, and 'linear' is actually what we want even for sRGB or gamma inputs. That's definitely confusing, so I think renaming to As for enabling this change by default, I'd prefer to wait on that until we have a way to automatically upgrade third-party components creating Are we OK with just adding the |
I'm good with |
Ok, sounds good. I've replaced |
For discussion and not ready to merge, see #3509.