Skip to content

Commit 5223560

Browse files
authored
fix: ibl shader logic (#37)
1 parent 34f8404 commit 5223560

File tree

4 files changed

+23
-27
lines changed

4 files changed

+23
-27
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@
9595
"@typescript-eslint/eslint-plugin": "7.2.0",
9696
"@typescript-eslint/parser": "7.2.0",
9797
"@vitejs/plugin-react": "4.2.1",
98-
"cesium": "1.116.0",
98+
"cesium": "1.118.0",
9999
"eslint": "8.57.0",
100100
"eslint-config-reearth": "0.3.0",
101101
"eslint-plugin-react-hooks": "4.6.0",

src/engines/Cesium/Shaders/OverriddenShaders/GlobeFS/IBL.glsl

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
// https://github.com/CesiumGS/cesium/blob/1.106/packages/engine/Source/Shaders/Model/ImageBasedLightingStageFS.glsl
77
// Specular term was removed, as I never apply it on terrain.
88
vec3 reearth_imageBasedLightingStage(vec3 positionEC, vec3 normalEC,
9-
vec3 lightDirectionEC, vec3 lightColorHdr,
10-
czm_pbrParameters pbrParameters) {
9+
vec3 lightDirectionEC, czm_modelMaterial material) {
1110
vec3 v = -positionEC;
1211
vec3 n = normalEC;
1312
vec3 l = normalize(lightDirectionEC);
@@ -24,21 +23,18 @@ vec3 reearth_imageBasedLightingStage(vec3 positionEC, vec3 normalEC,
2423
vec3 diffuseIrradiance =
2524
czm_sphericalHarmonics(cubeDir, u_reearth_sphericalHarmonicCoefficients);
2625

27-
return pbrParameters.diffuseColor * diffuseIrradiance;
26+
return material.diffuse * diffuseIrradiance;
2827
}
2928

3029
vec4 reearth_computeImageBasedLightingColor(vec4 color) {
3130
if (u_reearth_globeImageBasedLighting) {
32-
czm_pbrParameters pbrParameters;
33-
pbrParameters.diffuseColor = color.rgb;
31+
czm_modelMaterial material;
32+
material.diffuse = color.rgb;
3433

3534
vec3 normalEC = normalize(v_normalEC);
3635
vec3 lighting =
37-
czm_pbrLighting(v_positionEC, normalEC, czm_lightDirectionEC,
38-
czm_lightColorHdr, pbrParameters);
39-
lighting += reearth_imageBasedLightingStage(
40-
v_positionEC, normalEC, czm_lightDirectionEC,
41-
czm_lightColorHdr, pbrParameters) *
36+
czm_pbrLighting(v_positionEC, normalEC, czm_lightDirectionEC, material) * czm_lightColorHdr;
37+
lighting += reearth_imageBasedLightingStage(v_positionEC, normalEC, czm_lightDirectionEC, material) *
4238
u_vertexShadowDarkness;
4339

4440
#ifndef HDR

src/engines/Cesium/useOverrideGlobeShader.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ const useTerrainHeatmap = ({
141141
[
142142
"#ifdef APPLY_COLOR_TO_ALPHA",
143143
"vec3 colorDiff = abs(color.rgb - colorToAlpha.rgb);",
144-
"colorDiff.r = max(max(colorDiff.r, colorDiff.g), colorDiff.b);",
144+
"colorDiff.r = czm_maximumComponent(colorDiff);",
145145
"alpha = czm_branchFreeTernary(colorDiff.r < colorToAlpha.a, 0.0, alpha);",
146146
"#endif",
147147
],

yarn.lock

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,10 +1076,10 @@
10761076
resolved "https://registry.yarnpkg.com/@base2/pretty-print-object/-/pretty-print-object-1.0.1.tgz#371ba8be66d556812dc7fb169ebc3c08378f69d4"
10771077
integrity sha512-4iri8i1AqYHJE2DstZYkyEprg6Pq6sKx3xn5FpySk9sNhH7qN2LLlHJCfDTZRILNwQNPD7mATWM0TBui7uC1pA==
10781078

1079-
"@cesium/engine@^9.0.0":
1080-
version "9.0.0"
1081-
resolved "https://registry.yarnpkg.com/@cesium/engine/-/engine-9.0.0.tgz#74573f52100ef84ba5fcde9cd1084c07f7fe2fa7"
1082-
integrity sha512-GIeBitHo1t6OwgWnxAsCoHuCcJEfdki2G0hbKfaP87r2EapbnDLBmfxZziscl1ksv7kQiQ6x2FOOSPuV9QFvhA==
1079+
"@cesium/engine@^9.2.0":
1080+
version "9.2.0"
1081+
resolved "https://registry.yarnpkg.com/@cesium/engine/-/engine-9.2.0.tgz#6b92d422bf8fc9498e3f7a54851f6c4ebe7ff04f"
1082+
integrity sha512-vFVITo7UwIY1H8zK53etljv1w0CVaFSzOcLyItrM88r47zyPL7/RgooVKqZXnM5V8prs33S5TO/JSqJmvpyMTQ==
10831083
dependencies:
10841084
"@tweenjs/tween.js" "^23.1.1"
10851085
"@zip.js/zip.js" "^2.7.34"
@@ -1101,12 +1101,12 @@
11011101
topojson-client "^3.1.0"
11021102
urijs "^1.19.7"
11031103

1104-
"@cesium/widgets@^6.0.0":
1105-
version "6.0.0"
1106-
resolved "https://registry.yarnpkg.com/@cesium/widgets/-/widgets-6.0.0.tgz#be68f2b696bd6239cd37d63abd429e0608a9a0cb"
1107-
integrity sha512-zq0UqHji4PgPWTVdUB2hNb/FXe60eNDB11oW35/Z3REQfE4LBOkeR/RGck7hBOfYaubMiqwuwOw2lbl54OXzIA==
1104+
"@cesium/widgets@^6.1.0":
1105+
version "6.1.2"
1106+
resolved "https://registry.yarnpkg.com/@cesium/widgets/-/widgets-6.1.2.tgz#3eab3d8bf298b863d78a60c0ca5eaa177bffdab7"
1107+
integrity sha512-RNgogbRqlzjZxxG7icAUIDFZ0rm4OpHJ9b9lS/TGVm44PVVNG0Umhp4Tlf9U6r4ggwayKUkGV5dDIDa+pJGcVQ==
11081108
dependencies:
1109-
"@cesium/engine" "^9.0.0"
1109+
"@cesium/engine" "^9.2.0"
11101110
nosleep.js "^0.12.0"
11111111

11121112
"@chromatic-com/storybook@^1.3.3":
@@ -5246,13 +5246,13 @@ cesium-dnd@1.1.0:
52465246
resolved "https://registry.yarnpkg.com/cesium-dnd/-/cesium-dnd-1.1.0.tgz#30c7232eec9f84ad0d4f2c959cbd61ac29028086"
52475247
integrity sha512-Peo0bGIg5eOO/BrVDCovkPhQnWW3GBAjVnghh5NVmavDZjqS+A5R4Yj3IOG9tmYNSdtunsDqj5yxnMxQWx/KAA==
52485248

5249-
cesium@1.116.0:
5250-
version "1.116.0"
5251-
resolved "https://registry.yarnpkg.com/cesium/-/cesium-1.116.0.tgz#34c025babb49dfc4eeb98f9c83c37094a2083388"
5252-
integrity sha512-RZOOMePztCVb74JU/DTCTfuha7xTsJtEm3FRZeMUXyZABeRhbYjT1GwtAtoaPPJ5/IoqNjLvZnTNJdnU3LVE5g==
5249+
cesium@1.118.0:
5250+
version "1.118.0"
5251+
resolved "https://registry.yarnpkg.com/cesium/-/cesium-1.118.0.tgz#2c553131346799d3d3d1aec0a80b631b983ce224"
5252+
integrity sha512-au+WQ67bDZUw25kFFod/qtWfpxNoQPg2VQXU1XMr/64Gj1ZdvDSmuxO8sbum8tHieKDt9ER7JssSbefH/C3YSg==
52535253
dependencies:
5254-
"@cesium/engine" "^9.0.0"
5255-
"@cesium/widgets" "^6.0.0"
5254+
"@cesium/engine" "^9.2.0"
5255+
"@cesium/widgets" "^6.1.0"
52565256

52575257
chai@^4.3.10, chai@^4.4.1:
52585258
version "4.4.1"

0 commit comments

Comments
 (0)