Skip to content

Commit a25149c

Browse files
woodroofgithub-actions[bot]
authored andcommitted
Removed fix for lightmap energy dependency on shadows
GitOrigin-RevId: 9c6157df315425b0c66618a47a041595218f98d2
1 parent baa024b commit a25149c

13 files changed

Lines changed: 119 additions & 26 deletions

File tree

3d-style/shaders/model.fragment.glsl

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -418,15 +418,6 @@ vec3 computeIndirectLightContribution(Material mat, float NdotV, vec3 normal)
418418
#ifdef LIGHTING_3D_MODE
419419
float ambient_factor = calculate_ambient_directional_factor(normal);
420420
env_light = u_lighting_ambient_color * ambient_factor;
421-
#endif
422-
#if defined(USE_LIGHTMAP) && defined(HAS_TEXTURE_u_baseColorTexture) && defined(HAS_ATTRIBUTE_a_uv_2f)
423-
#ifdef OCCLUSION_TEXTURE_TRANSFORM
424-
vec2 lightmapUv = uv_2f.xy * u_occlusionTextureTransform.zw + u_occlusionTextureTransform.xy;
425-
lightmapSample = texture(u_baseColorTexture, lightmapUv).rgb;
426-
#endif
427-
428-
vec3 tintedSurfaceColor = mixColorFast(mat.baseColor.rgb, u_lighting_ambient_color, 0.2);
429-
env_light += tintedSurfaceColor * lightmapSample * u_lightmapIntensity;
430421
#endif
431422
vec3 envBRDF = EnvBRDFApprox(mat.specularColor, mat.perceptualRoughness, NdotV);
432423
vec3 indirectSpecular = envBRDF * env_light;
@@ -544,6 +535,26 @@ vec4 finalColor;
544535
ao = (texture(u_occlusionTexture, uv).x - 1.0) * u_aoIntensity + 1.0;
545536
color *= ao;
546537
#endif
538+
539+
#if defined(USE_LIGHTMAP) && defined(HAS_TEXTURE_u_baseColorTexture) && defined(HAS_ATTRIBUTE_a_uv_2f)
540+
#ifdef OCCLUSION_TEXTURE_TRANSFORM
541+
vec2 lightmapUv = uv_2f.xy * u_occlusionTextureTransform.zw + u_occlusionTextureTransform.xy;
542+
lightmapSample = texture(u_baseColorTexture, lightmapUv).rgb;
543+
#endif
544+
545+
float lightmapBrightness = max(lightmapSample.r, max(lightmapSample.g, lightmapSample.b));
546+
float lightmapEnergy = lightmapBrightness * u_lightmapIntensity;
547+
float lightmapMixFactor = 0.6 * min(1.0, lightmapBrightness);
548+
549+
color *= max(1.0, lightmapEnergy);
550+
color = mixColorFast(color, lightmapSample, lightmapMixFactor);
551+
552+
if (mat.baseColor.a < 0.99) {
553+
float maxFactor = max(1.0, u_lightmapIntensity);
554+
mat.baseColor.a = clamp(lightmapEnergy / maxFactor, 0.0, 1.0);
555+
}
556+
#endif
557+
547558
// Emission
548559
vec4 emissive = u_emissiveFactor;
549560

514 KB
Binary file not shown.
-400 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
117 KB
Loading

test/integration/render-tests/model-layer/model-lightmap-intensity-off/style.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@
3636
]
3737
}
3838
},
39-
"pitch": 54,
40-
"zoom": 16.9,
41-
"bearing": -24,
39+
"pitch": 51,
40+
"zoom": 17.3,
41+
"bearing": -16.6,
4242
"center": [
43-
-84.400968,
44-
33.75536
43+
-122.39008,
44+
37.778474
4545
],
4646
"layers": [
4747
{
@@ -57,6 +57,7 @@
5757
"source": "file-system-tiles",
5858
"id": "landmarks",
5959
"paint": {
60+
"model-opacity": 1.0,
6061
"model-lightmap-intensity": 0
6162
}
6263
}
48.1 KB
Loading

test/integration/render-tests/model-layer/model-lightmap-intensity-on-without-texture/style.json

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@
3636
]
3737
}
3838
},
39-
"pitch": 54,
40-
"zoom": 16.9,
41-
"bearing": -24,
39+
"pitch": 51,
40+
"zoom": 17.3,
41+
"bearing": -16.6,
4242
"center": [
43-
-84.400968,
44-
33.75536
43+
-122.39008,
44+
37.778474
4545
],
4646
"layers": [
4747
{
@@ -57,7 +57,8 @@
5757
"source": "file-system-tiles",
5858
"id": "landmarks",
5959
"paint": {
60-
"model-lightmap-intensity": 0.7
60+
"model-opacity": 1.0,
61+
"model-lightmap-intensity": 10
6162
}
6263
}
6364
]
527 KB
Loading

0 commit comments

Comments
 (0)