Skip to content

Commit ae84112

Browse files
woodroofgithub-actions[bot]
authored andcommitted
Removed lightmap rendering from BaseColor texture
GitOrigin-RevId: 10b6f646384cc554d639b661375f94b0d044173b
1 parent a25149c commit ae84112

16 files changed

Lines changed: 3 additions & 361 deletions

File tree

3d-style/render/draw_model.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,6 @@ const zeroCameraPos: [number, number, number] = [0, 0, 0];
8181
// on top of the per-tile cascade*tile cache. Lazily grown to the active cascade count.
8282
const shadowLightMatrices: Float64Array[] = [];
8383

84-
// Below this lightmap intensity the contribution is negligible, so we skip the
85-
// USE_LIGHTMAP shader path entirely instead of branching on the uniform at runtime.
86-
const LIGHTMAP_INTENSITY_THRESHOLD = 0.001;
87-
8884
type ModelParameters = {
8985
zScaleMatrix: mat4;
9086
negCameraPosMatrix: mat4;
@@ -1461,10 +1457,6 @@ function drawBatchedModels(painter: Painter, source: SourceCache, layer: ModelSt
14611457
programOptions.defines.push('DIFFUSE_SHADED');
14621458
}
14631459

1464-
if (layer.paint.get('model-lightmap-intensity') > LIGHTMAP_INTENSITY_THRESHOLD) {
1465-
programOptions.defines.push('USE_LIGHTMAP');
1466-
}
1467-
14681460
if (singleCascade) {
14691461
programOptions.defines.push('SHADOWS_SINGLE_CASCADE');
14701462
}
@@ -1548,10 +1540,8 @@ function drawBatchedModels(painter: Painter, source: SourceCache, layer: ModelSt
15481540
program.fixedDefines.includes('LIGHTING_3D_MODE')
15491541
);
15501542

1551-
// z-prepass is needed for landmark cutoff. Skipped for translucent parts —
1552-
// otherwise depth-write here breaks USE_LIGHTMAP in the color pass.
1553-
// Should check per-mesh, not per-node, to keep the prepass for opaque meshes of mixed nodes.
1554-
if (!isLight && sortedNode.opacity < 1.0 && !nodeInfo.hasTranslucentParts) {
1543+
if (!isLight && (nodeInfo.hasTranslucentParts || sortedNode.opacity < 1.0)) {
1544+
15551545
program.draw(painter, context.gl.TRIANGLES, depthModeRW, StencilMode.disabled, ColorMode.disabled, CullFaceMode.backCCW,
15561546
uniformValues, layer.id, mesh.vertexBuffer, mesh.indexBuffer, mesh.segments, layer.paint, painter.transform.zoom,
15571547
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument

3d-style/render/program/model_program.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,13 @@ export type ModelUniformsType = {
3939
['u_emissionTexture']: Uniform1i;
4040
['u_lutTexture']: Uniform1i;
4141
['u_color_mix']: Uniform4f;
42-
['u_lightmapIntensity']: Uniform1f;
4342
['u_aoIntensity']: Uniform1f;
4443
['u_emissive_strength']: Uniform1f;
4544
['u_occlusionTextureTransform']: Uniform4f;
4645
['u_dithered_discard_threshold']: Uniform1f;
4746
};
4847

49-
export type ModelDefinesType = 'DIFFUSE_SHADED' | 'SHADOWS_SINGLE_CASCADE' | 'OCCLUSION_TEXTURE_TRANSFORM' | 'DITHERED_DISCARD' | 'USE_LIGHTMAP';
48+
export type ModelDefinesType = 'DIFFUSE_SHADED' | 'SHADOWS_SINGLE_CASCADE' | 'OCCLUSION_TEXTURE_TRANSFORM' | 'DITHERED_DISCARD';
5049

5150
const modelUniforms = (context: Context): ModelUniformsType => ({
5251
'u_matrix': new UniformMatrix4f(context),
@@ -72,7 +71,6 @@ const modelUniforms = (context: Context): ModelUniformsType => ({
7271
'u_emissionTexture': new Uniform1i(context),
7372
'u_lutTexture': new Uniform1i(context),
7473
'u_color_mix': new Uniform4f(context),
75-
'u_lightmapIntensity': new Uniform1f(context),
7674
'u_aoIntensity': new Uniform1f(context),
7775
'u_emissive_strength': new Uniform1f(context),
7876
'u_occlusionTextureTransform': new Uniform4f(context),
@@ -127,7 +125,6 @@ const modelUniformValues = (
127125
const alphaMask = material.alphaMode === 'MASK';
128126

129127
const aoIntensity = layer.paint.get('model-ambient-occlusion-intensity');
130-
const lightmapIntensity = layer.paint.get('model-lightmap-intensity');
131128

132129
const colorMix = layer.paint.get('model-color').constantOr(Color.white).toNonPremultipliedRenderColor(null);
133130
colorMix.a = layer.paint.get('model-color-mix-intensity').constantOr(0.0);
@@ -172,7 +169,6 @@ const modelUniformValues = (
172169
'u_emissionTexture': TextureSlots.Emission,
173170
'u_lutTexture': TextureSlots.LUT,
174171
'u_color_mix': colorMix.toArray01(),
175-
'u_lightmapIntensity': lightmapIntensity,
176172
'u_aoIntensity': aoIntensity,
177173
'u_emissive_strength': emissiveStrength,
178174
'u_occlusionTextureTransform': occlusionTextureTransform ? occlusionTextureTransform : [0, 0, 0, 0] as [number, number, number, number],

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

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ uniform vec4 u_emissiveFactor;
1919
uniform float u_metallicFactor;
2020
uniform float u_roughnessFactor;
2121
uniform float u_emissive_strength;
22-
uniform float u_lightmapIntensity;
2322

2423

2524
in highp vec4 v_position_height;
@@ -36,10 +35,6 @@ in float v_depth_shadows;
3635
uniform vec4 u_occlusionTextureTransform;
3736
#endif
3837

39-
#ifdef USE_LIGHTMAP
40-
vec3 lightmapSample;
41-
#endif
42-
4338
#pragma mapbox: define-attribute highp vec3 normal_3f
4439
#pragma mapbox: define-attribute highp vec3 color_3f
4540
#pragma mapbox: define-attribute highp vec4 color_4f
@@ -133,20 +128,6 @@ vec3 sRGBToLinear(vec3 srgbIn) {
133128
return pow(srgbIn, vec3(2.2));
134129
}
135130

136-
// Luminance-preserving color blend
137-
vec3 mixColorFast(vec3 base, vec3 target, float factor) {
138-
float baseL = dot(base, vec3(0.2126, 0.7152, 0.0722));
139-
float targetL = dot(target, vec3(0.2126, 0.7152, 0.0722));
140-
141-
if (targetL < 1e-4) {
142-
return base;
143-
}
144-
145-
vec3 result = target * (baseL / targetL);
146-
147-
return mix(base, result, clamp(factor, 0.0, 1.0));
148-
}
149-
150131
float calculate_NdotL(vec3 normal, vec3 lightDir) {
151132
// Use slightly modified dot product for lambertian diffuse shading. This increase the range of NdotL to cover surfaces facing up to 45 degrees away from the light source.
152133
// This allows us to trade some realism for performance/usability as a single light source is enough to shade the scene.
@@ -195,9 +176,6 @@ vec4 getBaseColor() {
195176
// texture Color
196177
#if defined (HAS_TEXTURE_u_baseColorTexture) && defined (HAS_ATTRIBUTE_a_uv_2f)
197178
vec4 texColor = texture(u_baseColorTexture, uv_2f);
198-
#if defined(USE_LIGHTMAP) && !defined(OCCLUSION_TEXTURE_TRANSFORM)
199-
lightmapSample = texColor.rgb;
200-
#endif
201179
if(u_alphaMask) {
202180
if (texColor.w < u_alphaCutoff) {
203181
discard;
@@ -535,26 +513,6 @@ vec4 finalColor;
535513
ao = (texture(u_occlusionTexture, uv).x - 1.0) * u_aoIntensity + 1.0;
536514
color *= ao;
537515
#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-
558516
// Emission
559517
vec4 emissive = u_emissiveFactor;
560518

3d-style/style/style_layer/model_style_layer_properties.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ export type PaintProps = {
3535
"model-translation": DataDrivenProperty<[number, number, number]>;
3636
"model-color": DataDrivenProperty<Color>;
3737
"model-color-mix-intensity": DataDrivenProperty<number>;
38-
"model-lightmap-intensity": DataConstantProperty<number>;
3938
"model-type": DataConstantProperty<"common-3d" | "location-indicator">;
4039
"model-cast-shadows": DataConstantProperty<boolean>;
4140
"model-receive-shadows": DataConstantProperty<boolean>;
@@ -58,7 +57,6 @@ export const getPaintProperties = (): Properties<PaintProps> => paint || (paint
5857
"model-translation": new DataDrivenProperty(styleSpec["paint_model"]["model-translation"]),
5958
"model-color": new DataDrivenProperty(styleSpec["paint_model"]["model-color"]),
6059
"model-color-mix-intensity": new DataDrivenProperty(styleSpec["paint_model"]["model-color-mix-intensity"]),
61-
"model-lightmap-intensity": new DataConstantProperty(styleSpec["paint_model"]["model-lightmap-intensity"]),
6260
"model-type": new DataConstantProperty(styleSpec["paint_model"]["model-type"]),
6361
"model-cast-shadows": new DataConstantProperty(styleSpec["paint_model"]["model-cast-shadows"]),
6462
"model-receive-shadows": new DataConstantProperty(styleSpec["paint_model"]["model-receive-shadows"]),

src/style-spec/reference/v8.json

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11416,27 +11416,6 @@
1141611416
},
1141711417
"transition": true
1141811418
},
11419-
"model-lightmap-intensity": {
11420-
"type": "number",
11421-
"default": 0.0,
11422-
"minimum": 0,
11423-
"doc": "Controls the intensity of the model lightmap contribution. Values less than or equal to 0.001 are treated as off.",
11424-
"private": true,
11425-
"experimental": true,
11426-
"expression": {
11427-
"interpolated": true,
11428-
"parameters": ["zoom"]
11429-
},
11430-
"sdk-support": {
11431-
"basic functionality": {
11432-
"js": "3.25.0",
11433-
"android": "11.25.0",
11434-
"ios": "11.25.0"
11435-
}
11436-
},
11437-
"property-type": "data-constant",
11438-
"transition": true
11439-
},
1144011419
"model-type": {
1144111420
"type": "enum",
1144211421
"values": {

src/style-spec/types.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1405,11 +1405,6 @@ export type ModelLayerSpecification = {
14051405
"model-color-use-theme"?: PropertyValueSpecification<string>,
14061406
"model-color-mix-intensity"?: DataDrivenPropertyValueSpecification<number>,
14071407
"model-color-mix-intensity-transition"?: TransitionSpecification,
1408-
/**
1409-
* @experimental This property is experimental and subject to change in future versions.
1410-
*/
1411-
"model-lightmap-intensity"?: PropertyValueSpecification<number>,
1412-
"model-lightmap-intensity-transition"?: TransitionSpecification,
14131408
"model-type"?: "common-3d" | "location-indicator",
14141409
"model-cast-shadows"?: boolean,
14151410
"model-receive-shadows"?: boolean,
-514 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.

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

Lines changed: 0 additions & 65 deletions
This file was deleted.

0 commit comments

Comments
 (0)