Skip to content

Commit

Permalink
[MAPS3D-1498] Add support for line-pattern emissive strength (interna…
Browse files Browse the repository at this point in the history
…l-1987)

* Add emissive strength support to line-pattern

* Add render test
  • Loading branch information
lasselammi authored and mourner committed Nov 12, 2024
1 parent 3558887 commit 4d9801e
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/render/program/line_program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export type LinePatternUniformsType = {
['u_tile_units_to_pixels']: Uniform1f;
['u_alpha_discard_threshold']: Uniform1f;
['u_trim_offset']: Uniform2f;
['u_emissive_strength']: Uniform1f;
['u_zbias_factor']: Uniform1f;
['u_tile_to_meter']: Uniform1f;
};
Expand Down Expand Up @@ -75,6 +76,7 @@ const linePatternUniforms = (context: Context): LinePatternUniformsType => ({
'u_tile_units_to_pixels': new Uniform1f(context),
'u_alpha_discard_threshold': new Uniform1f(context),
'u_trim_offset': new Uniform2f(context),
'u_emissive_strength': new Uniform1f(context),
'u_zbias_factor': new Uniform1f(context),
'u_tile_to_meter': new Uniform1f(context)
});
Expand Down Expand Up @@ -144,6 +146,7 @@ const linePatternUniformValues = (
],
'u_alpha_discard_threshold': 0.0,
'u_trim_offset': trimOffset,
'u_emissive_strength': layer.paint.get('line-emissive-strength'),
'u_zbias_factor': zbiasFactor,
'u_tile_to_meter': tileToMeter(tile.tileID.canonical, 0.0)
};
Expand Down
4 changes: 3 additions & 1 deletion src/shaders/line_pattern.fragment.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ in highp vec4 v_pos_light_view_1;
in highp float v_depth;
#endif

uniform float u_emissive_strength;

#pragma mapbox: define mediump vec4 pattern
#pragma mapbox: define mediump float pixel_ratio
#pragma mapbox: define mediump float blur
Expand Down Expand Up @@ -112,7 +114,7 @@ void main() {
#endif

#ifdef LIGHTING_3D_MODE
color = apply_lighting_ground(color);
color = apply_lighting_with_emission_ground(color, u_emissive_strength);
#ifdef RENDER_SHADOWS
float light = shadowed_light_factor(v_pos_light_view_0, v_pos_light_view_1, v_depth);
color.rgb *= mix(u_ground_shadow_factor, vec3(1.0), light);
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{
"version": 8,
"metadata": {
"test": {
"height": 256,
"allowed": 0.0008
}
},
"center": [
13.418056,
52.499167
],
"zoom": 14,
"lights": [
{
"type": "ambient",
"id": "test_ambient",
"properties": {
"color": "rgba(0, 0, 0, 1)",
"intensity": 0.4
}
},
{
"type": "directional",
"id": "test_directional",
"properties": {
"color": "rgba(0, 0, 0, 1)",
"intensity": 0.4
}
}
],
"sources": {
"mapbox": {
"type": "vector",
"maxzoom": 14,
"tiles": [
"local://tiles/{z}-{x}-{y}.mvt"
]
}
},
"sprite": "local://sprites/emerald",
"layers": [
{
"id": "background",
"type": "background",
"paint": {
"background-color": "blue"
}
},
{
"id": "road",
"type": "line",
"source": "mapbox",
"source-layer": "road",
"paint": {
"line-width": 6,
"line-pattern": "generic_icon",
"line-emissive-strength": 1
}
}
]
}

0 comments on commit 4d9801e

Please sign in to comment.