Skip to content

Commit 225ed5d

Browse files
committed
Add czm_backFacing
1 parent c73929d commit 225ed5d

File tree

4 files changed

+16
-4
lines changed

4 files changed

+16
-4
lines changed

Source/Scene/processModelMaterialsCommon.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,7 @@ function generateTechnique(
643643
fragmentShader += " vec3 normal = normalize(v_normal);\n";
644644
if (khrMaterialsCommon.doubleSided) {
645645
// !gl_FrontFacing doesn't work as expected on Mac/Intel so use the more verbose form instead. See https://github.com/CesiumGS/cesium/pull/8494.
646-
fragmentShader += " if (gl_FrontFacing == false)\n";
646+
fragmentShader += " if (czm_backFacing())\n";
647647
fragmentShader += " {\n";
648648
fragmentShader += " normal = -normal;\n";
649649
fragmentShader += " }\n";

Source/Scene/processPbrMaterials.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,7 @@ function generateTechnique(
768768
}
769769
if (material.doubleSided) {
770770
// !gl_FrontFacing doesn't work as expected on Mac/Intel so use the more verbose form instead. See https://github.com/CesiumGS/cesium/pull/8494.
771-
fragmentShader += " if (gl_FrontFacing == false)\n";
771+
fragmentShader += " if (czm_backFacing())\n";
772772
fragmentShader += " {\n";
773773
fragmentShader += " n = -n;\n";
774774
fragmentShader += " }\n";
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/**
2+
* Determines if the fragment is back facing
3+
*
4+
* @name czm_backFacing
5+
* @glslFunction
6+
*
7+
* @returns {bool} <code>true</code> if the fragment is back facing; otherwise, <code>false</code>.
8+
*/
9+
bool czm_backFacing()
10+
{
11+
// !gl_FrontFacing doesn't work as expected on Mac/Intel so use the more verbose form instead. See https://github.com/CesiumGS/cesium/pull/8494.
12+
return gl_FrontFacing == false;
13+
}

Source/Shaders/GlobeFS.glsl

+1-2
Original file line numberDiff line numberDiff line change
@@ -453,8 +453,7 @@ void main()
453453
#endif
454454

455455
#ifdef UNDERGROUND_COLOR
456-
// !gl_FrontFacing doesn't work as expected on Mac/Intel so use the more verbose form instead. See https://github.com/CesiumGS/cesium/pull/8494.
457-
if (gl_FrontFacing == false)
456+
if (czm_backFacing())
458457
{
459458
float distanceFromEllipsoid = max(czm_cameraHeight, 0.0);
460459
float distance = max(v_distance - distanceFromEllipsoid, 0.0);

0 commit comments

Comments
 (0)