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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Change Log
* Fixed `OrientedBoundingBox.fromRectangle` for rectangles with width greater than 180 degrees. [#8475](https://github.com/AnalyticalGraphicsInc/cesium/pull/8475)
* Fixed globe picking so that it returns the closest intersecting triangle instead of the first intersecting triangle. [#8390](https://github.com/AnalyticalGraphicsInc/cesium/pull/8390)
* Fixed horizon culling issues with large root tiles. [#8487](https://github.com/AnalyticalGraphicsInc/cesium/pull/8487)
* Fixed a lighting bug affecting Macs with Intel integrated graphics where glTF 2.0 PBR models with double sided materials would have flipped normals. [#8494](https://github.com/AnalyticalGraphicsInc/cesium/pull/8494)

##### Additions :tada:
* Added `Globe.backFaceCulling` to support viewing terrain from below the surface. [#8470](https://github.com/AnalyticalGraphicsInc/cesium/pull/8470)
Expand Down
1 change: 1 addition & 0 deletions Source/Scene/processModelMaterialsCommon.js
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,7 @@ import ModelUtility from './ModelUtility.js';
if (hasNormals) {
fragmentShader += ' vec3 normal = normalize(v_normal);\n';
if (khrMaterialsCommon.doubleSided) {
// !gl_FrontFacing doesn't work as expected on Mac/Intel so use the more verbose form instead. See https://github.com/AnalyticalGraphicsInc/cesium/pull/8494.
fragmentShader += ' if (gl_FrontFacing == false)\n';
fragmentShader += ' {\n';
fragmentShader += ' normal = -normal;\n';
Expand Down
3 changes: 2 additions & 1 deletion Source/Scene/processPbrMaterials.js
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,8 @@ import ModelUtility from './ModelUtility.js';
fragmentShader += ' vec3 n = ng;\n';
}
if (material.doubleSided) {
fragmentShader += ' if (!gl_FrontFacing)\n';
// !gl_FrontFacing doesn't work as expected on Mac/Intel so use the more verbose form instead. See https://github.com/AnalyticalGraphicsInc/cesium/pull/8494.
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.

fragmentShader += ' {\n';
fragmentShader += ' n = -n;\n';
fragmentShader += ' }\n';
Expand Down