• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

visgl / deck.gl / 29648040731

18 Jul 2026 02:26PM UTC coverage: 83.034%. First build
29648040731

Pull #10450

github

web-flow
Merge bb1e6794d into 95f6e3e7e
Pull Request #10450: feat(layers): extend WebGPU layer support

8144 of 10311 branches covered (78.98%)

Branch coverage included in aggregate %.

63 of 120 new or added lines in 23 files covered. (52.5%)

14525 of 16990 relevant lines covered (85.49%)

18926.57 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/modules/layers/src/solid-polygon-layer/solid-polygon-layer.wgsl.ts
1
// deck.gl
2
// SPDX-License-Identifier: MIT
3
// Copyright (c) vis.gl contributors
4

5
type SolidPolygonShaderType = 'top' | 'side';
6

7
function getSolidPolygonVertexHelpers() {
NEW
8
  return /* wgsl */ `\
×
9
struct SolidPolygonUniforms {
10
  extruded: f32,
11
  isWireframe: f32,
12
  elevationScale: f32,
13
};
14

15
@group(0) @binding(0) var<uniform> solidPolygon: SolidPolygonUniforms;
16

17
fn project_offset_normal(vector: vec3<f32>) -> vec3<f32> {
18
  if (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT ||
19
      project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSETS) {
20
    return normalize(vector * project.commonUnitsPerWorldUnit);
21
  }
22
  return project_normal(vector);
23
}
24

25
fn apply_polygon_color(
26
  colors: vec4<f32>,
27
  normal: vec3<f32>,
28
  position: vec4<f32>
29
) -> vec4<f32> {
30
  if (solidPolygon.extruded > 0.5) {
31
    let lightColor = lighting_getLightColor2(
32
      colors.rgb,
33
      project.cameraPosition,
34
      position.xyz,
35
      normal
36
    );
37
    return vec4<f32>(lightColor, colors.a * layer.opacity);
38
  }
39
  return vec4<f32>(colors.rgb, colors.a * layer.opacity);
40
}
41
`;
42
}
43

44
function getSolidPolygonFragmentMain() {
NEW
45
  return /* wgsl */ `\
×
46
@fragment
47
fn fragmentMain(inp: Varyings) -> @location(0) vec4<f32> {
48
  geometry.uv = vec2<f32>(0.0, 0.0);
49

50
  if (picking.isActive > 0.5) {
51
    if (!picking_isColorValid(inp.pickingColor)) {
52
      discard;
53
    }
54
    return vec4<f32>(inp.pickingColor, 1.0);
55
  }
56

57
  var fragColor = inp.vColor;
58

59
  if (picking.isHighlightActive > 0.5) {
60
    let highlightedObjectColor = picking_normalizeColor(picking.highlightedObjectColor);
61
    if (picking_isColorZero(abs(inp.pickingColor - highlightedObjectColor))) {
62
      let highLightAlpha = picking.highlightColor.a;
63
      let blendedAlpha = highLightAlpha + fragColor.a * (1.0 - highLightAlpha);
64
      if (blendedAlpha > 0.0) {
65
        let highLightRatio = highLightAlpha / blendedAlpha;
66
        fragColor = vec4<f32>(
67
          mix(fragColor.rgb, picking.highlightColor.rgb, highLightRatio),
68
          blendedAlpha
69
        );
70
      } else {
71
        fragColor = vec4<f32>(fragColor.rgb, 0.0);
72
      }
73
    }
74
  }
75

76
  return deckgl_premultiplied_alpha(fragColor);
77
}
78
`;
79
}
80

81
function getTopShaderWGSL() {
NEW
82
  return /* wgsl */ `\
×
83
${getSolidPolygonVertexHelpers()}
84

85
struct Attributes {
86
  @location(0) vertexPositions: vec3<f32>,
87
  @location(1) vertexPositions64Low: vec3<f32>,
88
  @location(2) elevations: f32,
89
  @location(3) fillColors: vec4<f32>,
90
  @location(4) lineColors: vec4<f32>,
91
  @location(5) rowIndexes: u32,
92
};
93

94
struct Varyings {
95
  @builtin(position) position: vec4<f32>,
96
  @location(0) vColor: vec4<f32>,
97
  @location(1) pickingColor: vec3<f32>,
98
};
99

100
@vertex
101
fn vertexMain(attributes: Attributes) -> Varyings {
102
  var outp: Varyings;
103

104
  var pos = attributes.vertexPositions;
105
  if (solidPolygon.extruded > 0.5) {
106
    pos.z += attributes.elevations * solidPolygon.elevationScale;
107
  }
108

109
  geometry.worldPosition = attributes.vertexPositions;
110
  geometry.pickingColor = picking_getPickingColorFromIndex(attributes.rowIndexes);
111

112
  let projectedPosition = project_position_to_clipspace_and_commonspace(
113
    pos,
114
    attributes.vertexPositions64Low,
115
    vec3<f32>(0.0)
116
  );
117
  geometry.position = projectedPosition.commonPosition;
118
  outp.position = projectedPosition.clipPosition;
119

120
  let normal = project_normal(vec3<f32>(0.0, 0.0, 1.0));
121
  geometry.normal = normal;
122

123
  let colors = select(
124
    attributes.fillColors,
125
    attributes.lineColors,
126
    solidPolygon.isWireframe > 0.5
127
  );
128
  outp.vColor = apply_polygon_color(colors, normal, geometry.position);
129
  outp.pickingColor = geometry.pickingColor;
130

131
  return outp;
132
}
133

134
${getSolidPolygonFragmentMain()}
135
`;
136
}
137

138
function getSideShaderWGSL(ringWindingOrderCW: boolean) {
NEW
139
  return /* wgsl */ `\
×
140
const RING_WINDING_ORDER_CW: bool = ${ringWindingOrderCW ? 'true' : 'false'};
×
141

142
${getSolidPolygonVertexHelpers()}
143

144
struct Attributes {
145
  @location(0) positions: vec2<f32>,
146
  @location(1) vertexPositions: vec3<f32>,
147
  @location(2) vertexPositions64Low: vec3<f32>,
148
  @location(3) nextVertexPositions: vec3<f32>,
149
  @location(4) nextVertexPositions64Low: vec3<f32>,
150
  @location(5) instanceVertexValid: f32,
151
  @location(6) elevations: f32,
152
  @location(7) fillColors: vec4<f32>,
153
  @location(8) lineColors: vec4<f32>,
154
  @location(9) rowIndexes: u32,
155
};
156

157
struct Varyings {
158
  @builtin(position) position: vec4<f32>,
159
  @location(0) vColor: vec4<f32>,
160
  @location(1) pickingColor: vec3<f32>,
161
};
162

163
@vertex
164
fn vertexMain(attributes: Attributes) -> Varyings {
165
  var outp: Varyings;
166
  outp.position = vec4<f32>(0.0);
167
  outp.vColor = vec4<f32>(0.0);
168
  outp.pickingColor = picking_getPickingColorFromIndex(attributes.rowIndexes);
169

170
  if (attributes.instanceVertexValid < 0.5) {
171
    return outp;
172
  }
173

174
  let pos = select(attributes.nextVertexPositions, attributes.vertexPositions, RING_WINDING_ORDER_CW);
175
  let pos64Low = select(
176
    attributes.nextVertexPositions64Low,
177
    attributes.vertexPositions64Low,
178
    RING_WINDING_ORDER_CW
179
  );
180
  let nextPos = select(attributes.vertexPositions, attributes.nextVertexPositions, RING_WINDING_ORDER_CW);
181
  let nextPos64Low = select(
182
    attributes.vertexPositions64Low,
183
    attributes.nextVertexPositions64Low,
184
    RING_WINDING_ORDER_CW
185
  );
186

187
  let position = mix(pos, nextPos, attributes.positions.x);
188
  let position64Low = mix(pos64Low, nextPos64Low, attributes.positions.x);
189

190
  var worldPosition = position;
191
  if (solidPolygon.extruded > 0.5) {
192
    worldPosition.z += attributes.elevations * attributes.positions.y * solidPolygon.elevationScale;
193
  }
194

195
  geometry.worldPosition = position;
196
  geometry.pickingColor = picking_getPickingColorFromIndex(attributes.rowIndexes);
197

198
  let projectedPosition = project_position_to_clipspace_and_commonspace(
199
    worldPosition,
200
    position64Low,
201
    vec3<f32>(0.0)
202
  );
203
  geometry.position = projectedPosition.commonPosition;
204
  outp.position = projectedPosition.clipPosition;
205

206
  let normal = project_offset_normal(vec3<f32>(
207
    pos.y - nextPos.y + (pos64Low.y - nextPos64Low.y),
208
    nextPos.x - pos.x + (nextPos64Low.x - pos64Low.x),
209
    0.0
210
  ));
211
  geometry.normal = normal;
212

213
  let colors = select(
214
    attributes.fillColors,
215
    attributes.lineColors,
216
    solidPolygon.isWireframe > 0.5
217
  );
218
  outp.vColor = apply_polygon_color(colors, normal, geometry.position);
219
  outp.pickingColor = geometry.pickingColor;
220

221
  return outp;
222
}
223

224
${getSolidPolygonFragmentMain()}
225
`;
226
}
227

228
export function getSolidPolygonShaderWGSL(
229
  type: SolidPolygonShaderType,
230
  ringWindingOrderCW: boolean
231
): string {
NEW
232
  return type === 'top' ? getTopShaderWGSL() : getSideShaderWGSL(ringWindingOrderCW);
×
233
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc