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

add support for setting the encoding of the main map #3547

Closed
wants to merge 1 commit into from

Conversation

ncoder
Copy link

@ncoder ncoder commented Apr 20, 2018

Description:
Allow specifying the encoding of the main map on the material. This is important for correct linear/gamma settings.

Looks like:
<a-entity id="sky" geometry="primitive:sphere; radius:30; phiLength:360; phiStart:0; thetaLength:180" material="src:#skymap; encoding:sRGB" rotation="30 0 0">

Changes proposed:
I don't think this change is merge able as-is. But I wanted to get this out there to see if there was interest in doing something similar, or if there are plans to solve this some other way.

else {
texture.encoding = newEncoding;
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will need to use ES5 var and match the if/else style of the code above here.

@donmccurdy
Copy link
Member

+1 from me for providing a way of setting sRGB here. It should apply to map and emissiveMap but not other textures. See also: #3509. The alternative to this approach would be setting sRGB on map and emissiveMap by default, as well as gammaOutput=true, but that would make a lot of breaking color changes for 0.9.0. That sounds like too much pain, IMO.

Despite the three.js terminology, I would suggest naming this option colorSpace rather than encoding, and using sRGB and linear as the values.

@@ -30,7 +30,8 @@ module.exports.Component = registerComponent('material', {
side: {default: 'front', oneOf: ['front', 'back', 'double']},
transparent: {default: false},
vertexColors: {type: 'string', default: 'none', oneOf: ['face', 'vertex']},
visible: {default: true}
visible: {default: true},
encoding: {type: 'string', oneOf: ['sRGB', 'Linear']}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It needs a default value

if( data.encoding) {
let newEncoding = THREE[ data.encoding] || THREE[ data.encoding + "Encoding"];
if(newEncoding === undefined) {
error("Unrecognized encoding: " + data.encoding);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably better a warning than an error.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would do. warning + fallback to existing encoding if it's not valid

@@ -346,6 +346,16 @@ function setTextureProperties (texture, data) {
if (offset.x !== 0 || offset.y !== 0) {
texture.offset.set(offset.x, offset.y);
}

if( data.encoding) {
let newEncoding = THREE[ data.encoding] || THREE[ data.encoding + "Encoding"];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

var encoding define at top of function

@dmarcos
Copy link
Member

dmarcos commented Apr 23, 2018

Thank you. @ncode congrats for your first PR. A few changes and this is ready to go.

@ngokevin
Copy link
Member

ngokevin commented Jun 19, 2018

Hey @ncode, want to make a few changes? Thanks! The linter is also throwing some errors.

@ngokevin
Copy link
Member

@donmccurdy does this approach still look good? i don't have much experience with colorspace and encodings.

@donmccurdy
Copy link
Member

donmccurdy commented Sep 25, 2018

This is still correct, but I think i'd prefer to do something at the scene level (like #3757) rather than putting a setting on every component in the scene. If we merge the other PR we should be able to close this.

@ngokevin
Copy link
Member

Thanks @ncoder, we're going to go with a scene-level solution.

@ngokevin ngokevin closed this Sep 26, 2018
@ncoder
Copy link
Author

ncoder commented Sep 27, 2018

Sweet! Thanks, guys.

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

Successfully merging this pull request may close these issues.

4 participants