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

Fix lighting on Mac/Intel #8494

Merged
merged 3 commits into from
Dec 30, 2019
Merged

Fix lighting on Mac/Intel #8494

merged 3 commits into from
Dec 30, 2019

Conversation

lilleyse
Copy link
Contributor

There's a bug on Macs with Intel integrated graphics where !gl_FrontFacing is not equivalent to gl_FrontFacing == false and this causes the glTF PBR shader to flip normals incorrectly and have the wrong lighting.

I discovered the fix thanks to https://makc3d.wordpress.com/2015/09/17/alternative-to-gl_frontfacing/ which goes into other approaches in case gl_FrontFacing == false doesn't work. We can explore those later if needed.

Local sandcastle

Broken lighting
Screen Shot 2019-12-24 at 8 44 09 PM
Fixed
Screen Shot 2019-12-24 at 8 44 33 PM

@cesium-concierge
Copy link

Thanks for the pull request @lilleyse!

  • ✔️ Signed CLA found.
  • CHANGES.md was not updated.
    • If this change updates the public API in any way, please add a bullet point to CHANGES.md.
  • ❔ Unit tests were not updated.
    • Make sure you've updated tests to reflect your changes, added tests for any new code, and ran the code coverage tool.

Reviewers, don't forget to make sure that:

  • Cesium Viewer works.
  • Works in 2D/CV.
  • Works (or fails gracefully) in IE11.

@@ -602,7 +602,7 @@ import ModelUtility from './ModelUtility.js';
fragmentShader += ' vec3 n = ng;\n';
}
if (material.doubleSided) {
fragmentShader += ' if (!gl_FrontFacing)\n';
fragmentShader += ' if (gl_FrontFacing == false)\n';
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe add a comment here explaining it works around an issue and link to this PR? Otherwise a developer might "clean up" the code here and accidentally go back to the simpler ! check.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah good suggestion, updated.

@IanLilleyT
Copy link
Contributor

Verified that this PR fixes the lighting bug. Thanks @lilleyse!

@IanLilleyT IanLilleyT merged commit dac67f9 into master Dec 30, 2019
@IanLilleyT IanLilleyT deleted the fix-mac-front-facing branch December 30, 2019 17:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants