@antv/l7-layers 2.16.0 → 2.16.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (218) hide show
  1. package/es/core/BaseLayer.d.ts +3 -0
  2. package/es/core/BaseLayer.js +76 -80
  3. package/es/core/BaseModel.d.ts +9 -71
  4. package/es/core/BaseModel.js +75 -357
  5. package/es/core/CommonStyleAttribute.d.ts +2 -0
  6. package/es/core/CommonStyleAttribute.js +66 -0
  7. package/es/core/interface.d.ts +13 -3
  8. package/es/core/shape/extrude.js +18 -6
  9. package/es/core/triangulation.d.ts +12 -0
  10. package/es/core/triangulation.js +70 -0
  11. package/es/heatmap/models/grid.js +1 -1
  12. package/es/heatmap/models/grid3d.js +1 -1
  13. package/es/heatmap/models/heatmap.d.ts +1 -0
  14. package/es/heatmap/models/heatmap.js +17 -13
  15. package/es/heatmap/models/hexagon.js +1 -1
  16. package/es/heatmap/shaders/grid_vert.glsl +2 -2
  17. package/es/heatmap/shaders/hexagon_3d_vert.glsl +2 -2
  18. package/es/heatmap/shaders/hexagon_vert.glsl +2 -2
  19. package/es/line/index.d.ts +1 -0
  20. package/es/line/index.js +3 -2
  21. package/es/line/models/arc.js +9 -45
  22. package/es/line/models/arc_3d.js +12 -45
  23. package/es/line/models/earthArc_3d.js +6 -40
  24. package/es/line/models/{half.d.ts → flow.d.ts} +1 -11
  25. package/es/line/models/flow.js +167 -0
  26. package/es/line/models/great_circle.js +4 -38
  27. package/es/line/models/index.d.ts +1 -1
  28. package/es/line/models/index.js +3 -3
  29. package/es/line/models/line.js +7 -41
  30. package/es/line/models/linearline.js +4 -38
  31. package/es/line/models/simpleLine.d.ts +0 -1
  32. package/es/line/models/simpleLine.js +4 -43
  33. package/es/line/shaders/dash/arc_dash_frag.glsl +3 -6
  34. package/es/line/shaders/dash/arc_dash_vert.glsl +6 -46
  35. package/es/line/shaders/dash/line_dash_frag.glsl +4 -7
  36. package/es/line/shaders/dash/line_dash_vert.glsl +3 -33
  37. package/es/line/shaders/flow/flow_line_frag.glsl +13 -0
  38. package/es/line/shaders/flow/flow_line_vert.glsl +83 -0
  39. package/es/line/shaders/line_arc_3d_frag.glsl +6 -6
  40. package/es/line/shaders/line_arc_3d_vert.glsl +4 -34
  41. package/es/line/shaders/line_arc_frag.glsl +7 -11
  42. package/es/line/shaders/line_arc_great_circle_frag.glsl +5 -6
  43. package/es/line/shaders/line_arc_great_circle_vert.glsl +4 -32
  44. package/es/line/shaders/line_arc_vert.glsl +9 -45
  45. package/es/line/shaders/line_frag.glsl +15 -17
  46. package/es/line/shaders/line_vert.glsl +3 -34
  47. package/es/line/shaders/linear/arc3d_linear_frag.glsl +5 -19
  48. package/es/line/shaders/linear/arc3d_linear_vert.glsl +9 -48
  49. package/es/line/shaders/linear/arc_linear_frag.glsl +2 -30
  50. package/es/line/shaders/linear/arc_linear_vert.glsl +9 -45
  51. package/es/line/shaders/linear/line_linear_frag.glsl +5 -6
  52. package/es/line/shaders/linearLine/line_linear_frag.glsl +2 -14
  53. package/es/line/shaders/linearLine/line_linear_vert.glsl +14 -32
  54. package/es/line/shaders/simple/simpleline_frag.glsl +1 -5
  55. package/es/line/shaders/simple/simpleline_linear_frag.glsl +2 -6
  56. package/es/line/shaders/simple/simpleline_vert.glsl +7 -33
  57. package/es/plugins/DataMappingPlugin.js +20 -34
  58. package/es/plugins/LayerModelPlugin.js +13 -1
  59. package/es/plugins/ShaderUniformPlugin.js +3 -3
  60. package/es/point/index.d.ts +1 -0
  61. package/es/point/index.js +1 -0
  62. package/es/point/models/earthExtrude.d.ts +0 -3
  63. package/es/point/models/earthExtrude.js +2 -40
  64. package/es/point/models/earthFill.d.ts +0 -1
  65. package/es/point/models/earthFill.js +9 -60
  66. package/es/point/models/extrude.d.ts +0 -3
  67. package/es/point/models/extrude.js +3 -42
  68. package/es/point/models/fill.d.ts +0 -1
  69. package/es/point/models/fill.js +15 -76
  70. package/es/point/models/fillmage.js +6 -43
  71. package/es/point/models/image.js +7 -41
  72. package/es/point/models/normal.js +2 -2
  73. package/es/point/models/radar.d.ts +0 -1
  74. package/es/point/models/radar.js +4 -13
  75. package/es/point/models/simplePoint.d.ts +0 -1
  76. package/es/point/models/simplePoint.js +8 -49
  77. package/es/point/models/text.js +17 -47
  78. package/es/point/shaders/animate/wave_frag.glsl +1 -11
  79. package/es/point/shaders/earth/extrude_frag.glsl +5 -17
  80. package/es/point/shaders/earth/extrude_vert.glsl +14 -29
  81. package/es/point/shaders/earth/fill_frag.glsl +5 -14
  82. package/es/point/shaders/earth/fill_vert.glsl +1 -75
  83. package/es/point/shaders/extrude/extrude_frag.glsl +3 -29
  84. package/es/point/shaders/extrude/extrude_vert.glsl +27 -35
  85. package/es/point/shaders/fill_frag.glsl +9 -20
  86. package/es/point/shaders/fill_vert.glsl +16 -101
  87. package/es/point/shaders/image/fillImage_frag.glsl +2 -5
  88. package/es/point/shaders/image/fillImage_vert.glsl +4 -47
  89. package/es/point/shaders/image_frag.glsl +1 -5
  90. package/es/point/shaders/image_vert.glsl +1 -44
  91. package/es/point/shaders/normal_frag.glsl +0 -2
  92. package/es/point/shaders/normal_vert.glsl +2 -1
  93. package/es/point/shaders/radar/radar_vert.glsl +2 -2
  94. package/es/point/shaders/simplePoint_frag.glsl +0 -7
  95. package/es/point/shaders/simplePoint_vert.glsl +3 -45
  96. package/es/point/shaders/text_frag.glsl +6 -19
  97. package/es/point/shaders/text_vert.glsl +5 -66
  98. package/es/polygon/index.d.ts +1 -0
  99. package/es/polygon/index.js +1 -0
  100. package/es/polygon/models/extrude.d.ts +0 -3
  101. package/es/polygon/models/extrude.js +86 -82
  102. package/es/polygon/models/fill.d.ts +0 -4
  103. package/es/polygon/models/fill.js +8 -47
  104. package/es/polygon/shaders/extrude/polygon_extrude_frag.glsl +2 -23
  105. package/es/polygon/shaders/extrude/polygon_extrude_picklight_frag.glsl +7 -5
  106. package/es/polygon/shaders/extrude/polygon_extrude_picklight_vert.glsl +7 -32
  107. package/es/polygon/shaders/extrude/polygon_extrude_vert.glsl +33 -38
  108. package/es/polygon/shaders/extrude/polygon_extrudetex_frag.glsl +12 -9
  109. package/es/polygon/shaders/extrude/polygon_extrudetex_vert.glsl +16 -44
  110. package/es/polygon/shaders/polygon_frag.glsl +0 -5
  111. package/es/polygon/shaders/polygon_linear_frag.glsl +0 -8
  112. package/es/polygon/shaders/polygon_linear_vert.glsl +0 -32
  113. package/es/polygon/shaders/polygon_vert.glsl +1 -27
  114. package/es/utils/layerData.js +2 -2
  115. package/lib/core/BaseLayer.js +74 -78
  116. package/lib/core/BaseModel.js +74 -356
  117. package/lib/core/CommonStyleAttribute.js +72 -0
  118. package/lib/core/shape/extrude.js +18 -6
  119. package/lib/core/triangulation.js +72 -0
  120. package/lib/heatmap/models/grid.js +1 -1
  121. package/lib/heatmap/models/grid3d.js +1 -1
  122. package/lib/heatmap/models/heatmap.js +17 -13
  123. package/lib/heatmap/models/hexagon.js +1 -1
  124. package/lib/heatmap/shaders/grid_vert.glsl +2 -2
  125. package/lib/heatmap/shaders/hexagon_3d_vert.glsl +2 -2
  126. package/lib/heatmap/shaders/hexagon_vert.glsl +2 -2
  127. package/lib/line/index.js +3 -2
  128. package/lib/line/models/arc.js +9 -45
  129. package/lib/line/models/arc_3d.js +12 -45
  130. package/lib/line/models/earthArc_3d.js +6 -40
  131. package/lib/line/models/flow.js +174 -0
  132. package/lib/line/models/great_circle.js +4 -38
  133. package/lib/line/models/index.js +3 -3
  134. package/lib/line/models/line.js +7 -41
  135. package/lib/line/models/linearline.js +4 -38
  136. package/lib/line/models/simpleLine.js +4 -43
  137. package/lib/line/shaders/dash/arc_dash_frag.glsl +3 -6
  138. package/lib/line/shaders/dash/arc_dash_vert.glsl +6 -46
  139. package/lib/line/shaders/dash/line_dash_frag.glsl +4 -7
  140. package/lib/line/shaders/dash/line_dash_vert.glsl +3 -33
  141. package/lib/line/shaders/flow/flow_line_frag.glsl +13 -0
  142. package/lib/line/shaders/flow/flow_line_vert.glsl +83 -0
  143. package/lib/line/shaders/line_arc_3d_frag.glsl +6 -6
  144. package/lib/line/shaders/line_arc_3d_vert.glsl +4 -34
  145. package/lib/line/shaders/line_arc_frag.glsl +7 -11
  146. package/lib/line/shaders/line_arc_great_circle_frag.glsl +5 -6
  147. package/lib/line/shaders/line_arc_great_circle_vert.glsl +4 -32
  148. package/lib/line/shaders/line_arc_vert.glsl +9 -45
  149. package/lib/line/shaders/line_frag.glsl +15 -17
  150. package/lib/line/shaders/line_vert.glsl +3 -34
  151. package/lib/line/shaders/linear/arc3d_linear_frag.glsl +5 -19
  152. package/lib/line/shaders/linear/arc3d_linear_vert.glsl +9 -48
  153. package/lib/line/shaders/linear/arc_linear_frag.glsl +2 -30
  154. package/lib/line/shaders/linear/arc_linear_vert.glsl +9 -45
  155. package/lib/line/shaders/linear/line_linear_frag.glsl +5 -6
  156. package/lib/line/shaders/linearLine/line_linear_frag.glsl +2 -14
  157. package/lib/line/shaders/linearLine/line_linear_vert.glsl +14 -32
  158. package/lib/line/shaders/simple/simpleline_frag.glsl +1 -5
  159. package/lib/line/shaders/simple/simpleline_linear_frag.glsl +2 -6
  160. package/lib/line/shaders/simple/simpleline_vert.glsl +7 -33
  161. package/lib/plugins/DataMappingPlugin.js +20 -34
  162. package/lib/plugins/LayerModelPlugin.js +13 -1
  163. package/lib/plugins/ShaderUniformPlugin.js +3 -3
  164. package/lib/point/index.js +1 -0
  165. package/lib/point/models/earthExtrude.js +2 -40
  166. package/lib/point/models/earthFill.js +9 -60
  167. package/lib/point/models/extrude.js +3 -42
  168. package/lib/point/models/fill.js +15 -76
  169. package/lib/point/models/fillmage.js +6 -43
  170. package/lib/point/models/image.js +7 -41
  171. package/lib/point/models/normal.js +2 -2
  172. package/lib/point/models/radar.js +4 -13
  173. package/lib/point/models/simplePoint.js +8 -49
  174. package/lib/point/models/text.js +15 -45
  175. package/lib/point/shaders/animate/wave_frag.glsl +1 -11
  176. package/lib/point/shaders/earth/extrude_frag.glsl +5 -17
  177. package/lib/point/shaders/earth/extrude_vert.glsl +14 -29
  178. package/lib/point/shaders/earth/fill_frag.glsl +5 -14
  179. package/lib/point/shaders/earth/fill_vert.glsl +1 -75
  180. package/lib/point/shaders/extrude/extrude_frag.glsl +3 -29
  181. package/lib/point/shaders/extrude/extrude_vert.glsl +27 -35
  182. package/lib/point/shaders/fill_frag.glsl +9 -20
  183. package/lib/point/shaders/fill_vert.glsl +16 -101
  184. package/lib/point/shaders/image/fillImage_frag.glsl +2 -5
  185. package/lib/point/shaders/image/fillImage_vert.glsl +4 -47
  186. package/lib/point/shaders/image_frag.glsl +1 -5
  187. package/lib/point/shaders/image_vert.glsl +1 -44
  188. package/lib/point/shaders/normal_frag.glsl +0 -2
  189. package/lib/point/shaders/normal_vert.glsl +2 -1
  190. package/lib/point/shaders/radar/radar_vert.glsl +2 -2
  191. package/lib/point/shaders/simplePoint_frag.glsl +0 -7
  192. package/lib/point/shaders/simplePoint_vert.glsl +3 -45
  193. package/lib/point/shaders/text_frag.glsl +6 -19
  194. package/lib/point/shaders/text_vert.glsl +5 -66
  195. package/lib/polygon/index.js +1 -0
  196. package/lib/polygon/models/extrude.js +86 -82
  197. package/lib/polygon/models/fill.js +8 -47
  198. package/lib/polygon/shaders/extrude/polygon_extrude_frag.glsl +2 -23
  199. package/lib/polygon/shaders/extrude/polygon_extrude_picklight_frag.glsl +7 -5
  200. package/lib/polygon/shaders/extrude/polygon_extrude_picklight_vert.glsl +7 -32
  201. package/lib/polygon/shaders/extrude/polygon_extrude_vert.glsl +33 -38
  202. package/lib/polygon/shaders/extrude/polygon_extrudetex_frag.glsl +12 -9
  203. package/lib/polygon/shaders/extrude/polygon_extrudetex_vert.glsl +16 -44
  204. package/lib/polygon/shaders/polygon_frag.glsl +0 -5
  205. package/lib/polygon/shaders/polygon_linear_frag.glsl +0 -8
  206. package/lib/polygon/shaders/polygon_linear_vert.glsl +0 -32
  207. package/lib/polygon/shaders/polygon_vert.glsl +1 -27
  208. package/lib/utils/layerData.js +2 -2
  209. package/package.json +7 -7
  210. package/es/line/models/half.js +0 -267
  211. package/es/line/shaders/half/line_half_frag.glsl +0 -53
  212. package/es/line/shaders/half/line_half_vert.glsl +0 -169
  213. package/es/utils/dataMappingStyle.d.ts +0 -31
  214. package/es/utils/dataMappingStyle.js +0 -137
  215. package/lib/line/models/half.js +0 -274
  216. package/lib/line/shaders/half/line_half_frag.glsl +0 -53
  217. package/lib/line/shaders/half/line_half_vert.glsl +0 -169
  218. package/lib/utils/dataMappingStyle.js +0 -140
@@ -1,25 +1,22 @@
1
1
  #define LineTypeSolid 0.0
2
- uniform float u_opacity : 1.0;
3
-
4
2
  varying vec4 v_color;
5
3
 
6
4
  // dash
7
5
  varying vec4 v_dash_array;
6
+ varying float v_d_distance_ratio;
8
7
 
9
8
  #pragma include "picking"
10
9
 
11
10
  uniform float u_time;
12
11
  uniform vec4 u_animate: [ 1., 2., 1.0, 0.2 ]; // 控制运动
13
12
 
14
- varying mat4 styleMappingMat;
15
13
  // [animate, duration, interval, trailLength],
16
14
  void main() {
17
- float opacity = styleMappingMat[0][0];
18
- float d_distance_ratio = styleMappingMat[3].r; // 当前点位距离占线总长的比例
15
+
19
16
  gl_FragColor = v_color;
20
- gl_FragColor.a *= opacity; // 全局透明度
17
+
21
18
 
22
- float dashLength = mod(d_distance_ratio, v_dash_array.x + v_dash_array.y + v_dash_array.z + v_dash_array.w);
19
+ float dashLength = mod(v_d_distance_ratio, v_dash_array.x + v_dash_array.y + v_dash_array.z + v_dash_array.w);
23
20
  if(dashLength < v_dash_array.x || (dashLength > (v_dash_array.x + v_dash_array.y) && dashLength < v_dash_array.x + v_dash_array.y + v_dash_array.z)) {
24
21
  // 实线部分
25
22
  } else {
@@ -25,49 +25,19 @@ uniform float u_vertexScale: 1.0;
25
25
 
26
26
  varying vec4 v_color;
27
27
  varying vec4 v_dash_array;
28
+ varying float v_d_distance_ratio;
28
29
 
29
30
  uniform float u_opacity: 1.0;
30
- varying mat4 styleMappingMat; // 用于将在顶点着色器中计算好的样式值传递给片元
31
-
32
- #pragma include "styleMapping"
33
- #pragma include "styleMappingCalOpacity"
34
31
 
35
32
  void main() {
36
- // cal style mapping - 数据纹理映射部分的计算
37
- styleMappingMat = mat4(
38
- 0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - empty
39
- 0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA
40
- 0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]
41
- 0.0, 0.0, 0.0, 0.0 // distance_ratio/distance/pixelLen/texV
42
- );
43
-
44
- float rowCount = u_cellTypeLayout[0][0]; // 当前的数据纹理有几行
45
- float columnCount = u_cellTypeLayout[0][1]; // 当看到数据纹理有几列
46
- float columnWidth = 1.0/columnCount; // 列宽
47
- float rowHeight = 1.0/rowCount; // 行高
48
- float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets
49
- float id = a_vertexId; // 第n个顶点
50
- float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // 起始点在第几行
51
- float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // 起始点在第几列
52
-
53
- // cell 固定顺序 opacity -> strokeOpacity -> strokeWidth -> stroke ...
54
- // 按顺序从 cell 中取值、若没有则自动往下取值
55
- float textureOffset = 0.0; // 在 cell 中取值的偏移量
56
-
57
- vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);
58
- styleMappingMat[0][0] = opacityAndOffset.r;
59
- textureOffset = opacityAndOffset.g;
60
- // cal style mapping - 数据纹理映射部分的计算
61
33
 
62
34
  v_dash_array = pow(2.0, 20.0 - u_Zoom) * u_dash_array / a_Total_Distance;
63
- v_color = a_Color;
35
+ v_color = vec4(a_Color.xyz, a_Color.w * u_opacity);
64
36
 
65
37
  vec3 size = a_Miter * setPickingSize(a_Size.x) * reverse_offset_normal(a_Normal);
66
38
  vec2 offset = project_pixel(size.xy);
39
+ v_d_distance_ratio = a_DistanceAndIndex.x / a_Total_Distance;
67
40
 
68
- // 设置数据集的参数
69
- styleMappingMat[3][0] = a_DistanceAndIndex.x / a_Total_Distance; // 当前点位距离占线总长的比例
70
- styleMappingMat[3][1] = a_DistanceAndIndex.x; // 当前顶点的距离
71
41
 
72
42
  vec4 project_pos = project_position(vec4(a_Position.xy, 0, 1.0));
73
43
 
@@ -0,0 +1,13 @@
1
+ #extension GL_OES_standard_derivatives : enable
2
+
3
+ varying vec4 v_color;
4
+
5
+
6
+ // line texture
7
+
8
+ #pragma include "picking"
9
+
10
+ void main() {
11
+ gl_FragColor = v_color;
12
+ gl_FragColor = filterColor(gl_FragColor);
13
+ }
@@ -0,0 +1,83 @@
1
+ attribute vec4 a_Color;
2
+ attribute vec2 a_Size;
3
+ attribute vec4 a_Instance;
4
+ attribute vec3 a_Normal;
5
+ attribute vec3 a_Position;
6
+
7
+ uniform mat4 u_ModelMatrix;
8
+ uniform mat4 u_Mvp;
9
+
10
+ #pragma include "projection"
11
+ #pragma include "picking"
12
+ varying vec4 v_color;
13
+ uniform float u_gap_width: 1.0;
14
+ uniform float u_stroke_width: 1.0;
15
+ uniform float u_stroke_opacity: 1.0;
16
+
17
+
18
+ void main() {
19
+
20
+ // #ifdef USE_ATTRIBUTE_OPACITY
21
+ // float opacity = a_Opacity;
22
+ // #else
23
+ // float opacity = u_opacity;
24
+ // #endif
25
+
26
+
27
+ // #ifdef USE_ATTRIBUTE_OFFSETS
28
+ // vec2 offsets = a_Offsets;
29
+ // #else
30
+ // vec2 offsets = u_offsets;
31
+ // #endif
32
+
33
+ // float opacity = u_opacity;
34
+ // 透明度计算
35
+ vec2 source = a_Instance.rg; // 起始点
36
+ vec2 target = a_Instance.ba; // 终点
37
+ vec2 flowlineDir = normalize(target - source);
38
+ vec2 perpendicularDir = vec2(-flowlineDir.y, flowlineDir.x);
39
+
40
+
41
+ vec2 position = mix(source, target, a_Position.x);
42
+
43
+ float lengthCommon = length(target - source);
44
+ vec2 offsetDistances = a_Size.x * project_pixel(a_Position.yz);
45
+ vec2 limitedOffsetDistances = clamp(
46
+ offsetDistances,
47
+ -lengthCommon*.8, lengthCommon*.8
48
+ );
49
+
50
+ float startOffsetCommon = project_pixel(offsets[0]);
51
+ float endOffsetCommon = project_pixel(offsets[1]);
52
+ float endpointOffset = mix(
53
+ clamp(startOffsetCommon, 0.0, lengthCommon*.2),
54
+ -clamp(endOffsetCommon, 0.0, lengthCommon*.2),
55
+ a_Position.x
56
+ );
57
+
58
+ vec2 normalsCommon = u_stroke_width * project_pixel(a_Normal.xy);
59
+
60
+ float gapCommon = project_pixel(u_gap_width);
61
+ vec3 offsetCommon = vec3(
62
+ flowlineDir * (limitedOffsetDistances[1] + normalsCommon.y + endpointOffset * 1.05) -
63
+ perpendicularDir * (limitedOffsetDistances[0] + gapCommon + normalsCommon.x),
64
+ 0.0
65
+ );
66
+
67
+
68
+ vec4 project_pos = project_position(vec4(position.xy, 0, 1.0));
69
+
70
+ vec4 fillColor = vec4(a_Color.rgb, a_Color.a * opacity);
71
+ v_color = mix(fillColor, vec4(u_stroke.xyz, u_stroke.w * fillColor.w * u_stroke_opacity), a_Normal.z);
72
+
73
+
74
+ if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x
75
+ gl_Position = u_Mvp * vec4(project_pos.xy + offsetCommon.xy, 0., 1.0);
76
+ } else {
77
+ gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offsetCommon.xy, 0., 1.0));
78
+ }
79
+
80
+
81
+
82
+ setPickingColor(a_PickingColor);
83
+ }
@@ -3,33 +3,33 @@
3
3
  #define Animate 0.0
4
4
  #define LineTexture 1.0
5
5
 
6
- uniform float u_opacity;
7
6
  uniform float u_textureBlend;
8
7
  uniform float u_blur : 0.9;
9
8
  uniform float u_line_type: 0.0;
10
9
  // varying vec2 v_normal;
11
10
  varying vec4 v_dash_array;
12
11
  varying vec4 v_color;
12
+ varying vec4 v_line_data;
13
13
 
14
14
  uniform float u_line_texture: 0.0;
15
15
  uniform sampler2D u_texture;
16
16
  uniform vec2 u_textSize;
17
17
  varying float v_segmentIndex;
18
18
  uniform float segmentNumber;
19
+ uniform float u_opacity;
19
20
 
20
21
  varying vec2 v_iconMapUV;
21
22
 
22
23
  uniform float u_time;
23
24
  uniform vec4 u_animate: [ 1., 2., 1.0, 0.2 ];
24
25
 
25
- varying mat4 styleMappingMat;
26
26
 
27
27
  #pragma include "picking"
28
28
 
29
29
  void main() {
30
- float opacity = styleMappingMat[0][0];
30
+ float opacity = u_opacity;
31
31
  float animateSpeed = 0.0; // 运动速度
32
- float d_distance_ratio = styleMappingMat[3].g; // 当前点位距离占线总长的比例
32
+ float d_distance_ratio = v_line_data.g; // 当前点位距离占线总长的比例
33
33
  gl_FragColor = v_color;
34
34
 
35
35
  gl_FragColor.a *= opacity;
@@ -61,7 +61,7 @@ void main() {
61
61
  if(u_line_texture == LineTexture && u_line_type != LineTypeDash) { // while load texture
62
62
  // float arcRadio = smoothstep( 0.0, 1.0, (v_segmentIndex / segmentNumber));
63
63
  float arcRadio = v_segmentIndex / (segmentNumber - 1.0);
64
- float count = styleMappingMat[3].b; // // 贴图在弧线上重复的数量
64
+ float count = v_line_data.b; // // 贴图在弧线上重复的数量
65
65
 
66
66
  float time = 0.0;
67
67
  if(u_animate.x == Animate) {
@@ -71,7 +71,7 @@ void main() {
71
71
 
72
72
  float u = fract(redioCount - time);
73
73
 
74
- float v = styleMappingMat[3].a; // 线图层贴图部分的 v 坐标值
74
+ float v = v_line_data.a; // 线图层贴图部分的 v 坐标值
75
75
  vec2 uv= v_iconMapUV / u_textSize + vec2(u, v) / u_textSize * 64.;
76
76
  vec4 pattern = texture2D(u_texture, uv);
77
77
 
@@ -26,12 +26,7 @@ varying float v_segmentIndex;
26
26
 
27
27
  attribute vec2 a_iconMapUV;
28
28
  varying vec2 v_iconMapUV;
29
-
30
- uniform float u_opacity: 1.0;
31
- varying mat4 styleMappingMat; // 用于将在顶点着色器中计算好的样式值传递给片元
32
-
33
- #pragma include "styleMapping"
34
- #pragma include "styleMappingCalOpacity"
29
+ varying vec4 v_line_data;
35
30
 
36
31
  #pragma include "projection"
37
32
  #pragma include "project"
@@ -99,31 +94,6 @@ vec3 lglt2xyz(vec2 lnglat) {
99
94
  }
100
95
 
101
96
  void main() {
102
- // cal style mapping - 数据纹理映射部分的计算
103
- styleMappingMat = mat4(
104
- 0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - empty
105
- 0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA
106
- 0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]
107
- 0.0, 0.0, 0.0, 0.0 // dataset 数据集
108
- );
109
-
110
- float rowCount = u_cellTypeLayout[0][0]; // 当前的数据纹理有几行
111
- float columnCount = u_cellTypeLayout[0][1]; // 当看到数据纹理有几列
112
- float columnWidth = 1.0/columnCount; // 列宽
113
- float rowHeight = 1.0/rowCount; // 行高
114
- float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets
115
- float id = a_vertexId; // 第n个顶点
116
- float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // 起始点在第几行
117
- float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // 起始点在第几列
118
-
119
- // cell 固定顺序 opacity -> strokeOpacity -> strokeWidth -> stroke ...
120
- // 按顺序从 cell 中取值、若没有则自动往下取值
121
- float textureOffset = 0.0; // 在 cell 中取值的偏移量
122
-
123
- vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);
124
- styleMappingMat[0][0] = opacityAndOffset.r;
125
- textureOffset = opacityAndOffset.g;
126
- // cal style mapping - 数据纹理映射部分的计算
127
97
 
128
98
  v_color = a_Color;
129
99
  vec2 source = project_position(vec4(a_Instance.rg, 0, 0)).xy;
@@ -148,7 +118,7 @@ void main() {
148
118
  if(u_animate.x == Animate) {
149
119
  d_distance_ratio = segmentIndex / segmentNumber;
150
120
  }
151
- styleMappingMat[3].g = d_distance_ratio; // 当前点位距离占线总长的比例
121
+ v_line_data.g = d_distance_ratio; // 当前点位距离占线总长的比例
152
122
 
153
123
  float nextSegmentRatio = getSegmentRatio(segmentIndex + indexDir);
154
124
  vec3 curr = getPos(source, target, segmentRatio);
@@ -162,12 +132,12 @@ void main() {
162
132
 
163
133
  float arcDistrance = length(source - target);
164
134
  float pixelLen = project_pixel_texture(u_icon_step);
165
- styleMappingMat[3].b = floor(arcDistrance/pixelLen); // 贴图在弧线上重复的数量
135
+ v_line_data.b = floor(arcDistrance/pixelLen); // 贴图在弧线上重复的数量
166
136
 
167
137
  vec2 projectOffset = project_pixel(offset);
168
138
  float lineOffsetWidth = length(projectOffset + projectOffset * sign(a_Position.y)); // 线横向偏移的距离
169
139
  float linePixelSize = project_pixel(a_Size); // 定点位置偏移,按地图等级缩放后的距离
170
- styleMappingMat[3].a = lineOffsetWidth/linePixelSize; // 线图层贴图部分的 v 坐标值
140
+ v_line_data.a = lineOffsetWidth/linePixelSize; // 线图层贴图部分的 v 坐标值
171
141
 
172
142
  v_iconMapUV = a_iconMapUV;
173
143
  }
@@ -19,24 +19,20 @@ uniform vec2 u_textSize;
19
19
 
20
20
  uniform float segmentNumber;
21
21
  varying vec2 v_iconMapUV;
22
+ varying vec4 v_lineData;
22
23
 
23
- varying mat4 styleMappingMat; // 传递从片元中传递的映射数据
24
24
 
25
25
  #pragma include "picking"
26
26
 
27
27
  void main() {
28
- float opacity = styleMappingMat[0][0];
29
28
  float animateSpeed = 0.0; // 运动速度
30
- float d_segmentIndex = styleMappingMat[3].r; // 当前顶点在弧线中所处的分段位置
31
- float d_distance_ratio = styleMappingMat[3].b; // 当前顶点在弧线中所处的分段比例
32
-
33
29
  gl_FragColor = v_color;
34
30
 
35
- gl_FragColor.a *= opacity;
31
+ gl_FragColor.a *= u_opacity;
36
32
 
37
33
  if(u_animate.x == Animate && u_line_texture != LineTexture) {
38
34
  animateSpeed = u_time / u_animate.y;
39
- float alpha =1.0 - fract( mod(1.0- d_distance_ratio, u_animate.z)* (1.0/ u_animate.z) + u_time / u_animate.y);
35
+ float alpha =1.0 - fract( mod(1.0- v_lineData.b, u_animate.z)* (1.0/ u_animate.z) + u_time / u_animate.y);
40
36
  alpha = (alpha + u_animate.w -1.0) / u_animate.w;
41
37
  // alpha = smoothstep(0., 1., alpha);
42
38
  alpha = clamp(alpha, 0.0, 1.0);
@@ -45,10 +41,10 @@ void main() {
45
41
 
46
42
  // 当存在贴图时在底色上贴上贴图
47
43
  if(u_line_texture == LineTexture) { // while load texture
48
- float arcRadio = smoothstep( 0.0, 1.0, (d_segmentIndex / segmentNumber));
44
+ float arcRadio = smoothstep( 0.0, 1.0, (v_lineData.r / segmentNumber));
49
45
  // float arcRadio = smoothstep( 0.0, 1.0, d_distance_ratio);
50
46
 
51
- float count = styleMappingMat[3].g; // 贴图在弧线上重复的数量
47
+ float count = v_lineData.g; // 贴图在弧线上重复的数量
52
48
 
53
49
  float time = 0.0;
54
50
  if(u_animate.x == Animate) {
@@ -57,7 +53,7 @@ void main() {
57
53
  float redioCount = arcRadio * count;
58
54
 
59
55
  float u = fract(redioCount - time);
60
- float v = styleMappingMat[3].a; // 横向 v
56
+ float v = v_lineData.a; // 横向 v
61
57
  vec2 uv= v_iconMapUV / u_textSize + vec2(u, v) / u_textSize * 64.;
62
58
 
63
59
  vec4 pattern = texture2D(u_texture, uv);
@@ -75,7 +71,7 @@ void main() {
75
71
  pattern.a = 0.0;
76
72
  gl_FragColor = filterColor(gl_FragColor + pattern);
77
73
  } else { // replace
78
- pattern.a *= opacity;
74
+ pattern.a *= u_opacity;
79
75
  if(gl_FragColor.a <= 0.0) {
80
76
  pattern.a = 0.0;
81
77
  }
@@ -25,17 +25,16 @@ varying vec2 v_iconMapUV;
25
25
  uniform float u_linearColor: 0;
26
26
  uniform vec4 u_sourceColor;
27
27
  uniform vec4 u_targetColor;
28
-
29
- varying mat4 styleMappingMat;
28
+ varying vec4 v_line_data;
30
29
 
31
30
  #pragma include "picking"
32
31
  #pragma include "project"
33
32
  #pragma include "projection"
34
33
 
35
34
  void main() {
36
- float opacity = styleMappingMat[0][0];
35
+ float opacity = u_opacity;
37
36
  float animateSpeed = 0.0;
38
- float d_segmentIndex = styleMappingMat[3].g;
37
+ float d_segmentIndex = v_line_data.g;
39
38
 
40
39
  // 设置弧线的底色
41
40
  if(u_linearColor == 1.0) { // 使用渐变颜色
@@ -70,14 +69,14 @@ void main() {
70
69
  if(LineTexture == u_line_texture && u_line_type != LineTypeDash) {
71
70
  float arcRadio = smoothstep( 0.0, 1.0, (d_segmentIndex / (segmentNumber - 1.0)));
72
71
  // float arcRadio = d_segmentIndex / (segmentNumber - 1.0);
73
- float count = styleMappingMat[3].b; // 贴图在弧线上重复的数量
72
+ float count = v_line_data.b; // 贴图在弧线上重复的数量
74
73
  float u = fract(arcRadio * count - animateSpeed * count);
75
74
  // float u = fract(arcRadio * count - animateSpeed);
76
75
  if(u_animate.x == Animate) {
77
76
  u = gl_FragColor.a/opacity;
78
77
  }
79
78
 
80
- float v = styleMappingMat[3].a; // 线图层贴图部分的 v 坐标值
79
+ float v = v_line_data.a; // 线图层贴图部分的 v 坐标值
81
80
 
82
81
  vec2 uv= v_iconMapUV / u_textSize + vec2(u, v) / u_textSize * 64.;
83
82
  vec4 pattern = texture2D(u_texture, uv);
@@ -23,12 +23,8 @@ uniform float u_line_texture: 0.0;
23
23
 
24
24
  attribute vec2 a_iconMapUV;
25
25
  varying vec2 v_iconMapUV;
26
+ varying vec4 v_line_data;
26
27
 
27
- uniform float u_opacity: 1.0;
28
- varying mat4 styleMappingMat; // 用于将在顶点着色器中计算好的样式值传递给片元
29
-
30
- #pragma include "styleMapping"
31
- #pragma include "styleMappingCalOpacity"
32
28
 
33
29
  #pragma include "projection"
34
30
  #pragma include "project"
@@ -123,31 +119,7 @@ vec2 interpolate (vec2 source, vec2 target, float angularDist, float t) {
123
119
  }
124
120
 
125
121
  void main() {
126
- // cal style mapping - 数据纹理映射部分的计算
127
- styleMappingMat = mat4(
128
- 0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - empty
129
- 0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA
130
- 0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]
131
- 0.0, 0.0, 0.0, 0.0 // dataset 数据集
132
- );
133
-
134
- float rowCount = u_cellTypeLayout[0][0]; // 当前的数据纹理有几行
135
- float columnCount = u_cellTypeLayout[0][1]; // 当看到数据纹理有几列
136
- float columnWidth = 1.0/columnCount; // 列宽
137
- float rowHeight = 1.0/rowCount; // 行高
138
- float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets
139
- float id = a_vertexId; // 第n个顶点
140
- float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // 起始点在第几行
141
- float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // 起始点在第几列
142
122
 
143
- // cell 固定顺序 opacity -> strokeOpacity -> strokeWidth -> stroke ...
144
- // 按顺序从 cell 中取值、若没有则自动往下取值
145
- float textureOffset = 0.0; // 在 cell 中取值的偏移量
146
-
147
- vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);
148
- styleMappingMat[0][0] = opacityAndOffset.r;
149
- textureOffset = opacityAndOffset.g;
150
- // cal style mapping - 数据纹理映射部分的计算
151
123
 
152
124
  v_color = a_Color;
153
125
  vec2 source = radians(a_Instance.rg);
@@ -184,7 +156,7 @@ void main() {
184
156
  // vec4 project_pos = project_position(vec4(curr.xy, 0, 1.0));
185
157
  // gl_Position = project_common_position_to_clipspace(vec4(curr.xy + offset, curr.z, 1.0));
186
158
 
187
- styleMappingMat[3].g = a_Position.x; // 该顶点在弧线上的分段排序
159
+ v_line_data.g = a_Position.x; // 该顶点在弧线上的分段排序
188
160
  if(LineTexture == u_line_texture) { // 开启贴图模式
189
161
  // float mapZoomScale = u_CoordinateSystem !== COORDINATE_SYSTEM_P20_2?10000000.0:1.0;
190
162
  float d_arcDistrance = length(source - target);
@@ -195,11 +167,11 @@ void main() {
195
167
  d_arcDistrance = project_pixel_allmap(d_arcDistrance);
196
168
  }
197
169
  float d_pixelLen = project_pixel(u_icon_step)/8.0;
198
- styleMappingMat[3].b = floor(d_arcDistrance/d_pixelLen); // 贴图在弧线上重复的数量
170
+ v_line_data.b = floor(d_arcDistrance/d_pixelLen); // 贴图在弧线上重复的数量
199
171
 
200
172
  float lineOffsetWidth = length(offset + offset * sign(a_Position.y)); // 线横向偏移的距离
201
173
  float linePixelSize = project_pixel(a_Size); // 定点位置偏移,按地图等级缩放后的距离
202
- styleMappingMat[3].a = lineOffsetWidth/linePixelSize; // 线图层贴图部分的 v 坐标值
174
+ v_line_data.a = lineOffsetWidth/linePixelSize; // 线图层贴图部分的 v 坐标值
203
175
 
204
176
  v_iconMapUV = a_iconMapUV;
205
177
  }
@@ -18,13 +18,11 @@ uniform float u_icon_step: 100;
18
18
  uniform float u_line_texture: 0.0;
19
19
  attribute vec2 a_iconMapUV;
20
20
  varying vec2 v_iconMapUV;
21
+ varying vec4 v_lineData;
22
+ varying vec2 v_distance_ratio;
21
23
 
22
24
  uniform float u_opacity: 1.0;
23
- varying mat4 styleMappingMat; // 用于将在顶点着色器中计算好的样式值传递给片元
24
25
 
25
- #pragma include "styleMapping"
26
- #pragma include "styleMappingCalOpacity"
27
- #pragma include "styleMappingCalThetaOffset"
28
26
 
29
27
  #pragma include "projection"
30
28
  #pragma include "project"
@@ -83,37 +81,6 @@ vec2 getNormal(vec2 line_clipspace, float offset_direction) {
83
81
  void main() {
84
82
  v_color = a_Color;
85
83
 
86
- // cal style mapping - 数据纹理映射部分的计算
87
- styleMappingMat = mat4(
88
- 0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - empty
89
- 0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA
90
- 0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]
91
- 0.0, 0.0, 0.0, 0.0 // dataset 数据集
92
- );
93
-
94
- float rowCount = u_cellTypeLayout[0][0]; // 当前的数据纹理有几行
95
- float columnCount = u_cellTypeLayout[0][1]; // 当看到数据纹理有几列
96
- float columnWidth = 1.0/columnCount; // 列宽
97
- float rowHeight = 1.0/rowCount; // 行高
98
- float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets
99
- float id = a_vertexId; // 第n个顶点
100
- float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // 起始点在第几行
101
- float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // 起始点在第几列
102
-
103
- // cell 固定顺序 opacity -> strokeOpacity -> strokeWidth -> stroke -> thetaOffset...
104
- // 按顺序从 cell 中取值、若没有则自动往下取值
105
- float textureOffset = 0.0; // 在 cell 中取值的偏移量
106
-
107
- vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);
108
- styleMappingMat[0][0] = opacityAndOffset.r;
109
- textureOffset = opacityAndOffset.g;
110
-
111
- vec2 thetaOffsetAndOffset = calThetaOffsetAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);
112
- styleMappingMat[0][1] = thetaOffsetAndOffset.r;
113
- textureOffset = thetaOffsetAndOffset.g;
114
- // cal style mapping - 数据纹理映射部分的计算
115
-
116
-
117
84
  vec2 source = a_Instance.rg; // 起始点
118
85
  vec2 target = a_Instance.ba; // 终点
119
86
  float segmentIndex = a_Position.x;
@@ -130,20 +97,17 @@ void main() {
130
97
  }
131
98
  }
132
99
 
133
- styleMappingMat[3].b = d_distance_ratio;
100
+ v_lineData.b = d_distance_ratio;
101
+
102
+ vec4 curr = project_position(vec4(interpolate(source, target, segmentRatio, u_thetaOffset), 0.0, 1.0));
103
+ vec4 next = project_position(vec4(interpolate(source, target, nextSegmentRatio, u_thetaOffset), 0.0, 1.0));
134
104
 
135
- // styleMappingMat[0][1] - arcThetaOffset
136
- float arcThetaOffset = styleMappingMat[0][1];
137
- vec4 curr = project_position(vec4(interpolate(source, target, segmentRatio, arcThetaOffset), 0.0, 1.0));
138
- vec4 next = project_position(vec4(interpolate(source, target, nextSegmentRatio, arcThetaOffset), 0.0, 1.0));
139
- // v_normal = getNormal((next.xy - curr.xy) * indexDir, a_Position.y);
140
- //unProjCustomCoord
141
105
 
142
106
  vec2 offset = project_pixel(getExtrusionOffset((next.xy - curr.xy) * indexDir, a_Position.y));
143
107
 
144
108
 
145
109
  float d_segmentIndex = a_Position.x + 1.0; // 当前顶点在弧线中所处的分段位置
146
- styleMappingMat[3].r = d_segmentIndex;
110
+ v_lineData.r = d_segmentIndex;
147
111
 
148
112
  if(LineTexture == u_line_texture) { // 开启贴图模式
149
113
 
@@ -159,11 +123,11 @@ void main() {
159
123
 
160
124
  float pixelLen = project_pixel_texture(u_icon_step); // 贴图沿弧线方向的长度 - 随地图缩放改变
161
125
  float texCount = floor(arcDistrance/pixelLen); // 贴图在弧线上重复的数量
162
- styleMappingMat[3].g = texCount;
126
+ v_lineData.g = texCount;
163
127
 
164
128
  float lineOffsetWidth = length(offset + offset * sign(a_Position.y)); // 线横向偏移的距离
165
129
  float linePixelSize = project_pixel(a_Size); // 定点位置偏移
166
- styleMappingMat[3].a = lineOffsetWidth/linePixelSize; // 线图层贴图部分的 v 坐标值
130
+ v_lineData.a = lineOffsetWidth/linePixelSize; // 线图层贴图部分的 v 坐标值
167
131
  }
168
132
 
169
133
 
@@ -1,3 +1,4 @@
1
+ #extension GL_OES_standard_derivatives : enable
1
2
  #define Animate 0.0
2
3
  #define LineTexture 1.0
3
4
  uniform float u_opacity : 1.0;
@@ -13,24 +14,22 @@ varying vec4 v_color;
13
14
  uniform float u_line_texture;
14
15
  uniform sampler2D u_texture;
15
16
  uniform vec2 u_textSize;
16
-
17
17
  varying vec2 v_iconMapUV;
18
+ varying vec4 v_texture_data;
19
+
18
20
 
19
21
  #pragma include "picking"
20
22
 
21
23
  uniform float u_time;
22
24
  uniform vec4 u_animate: [ 1, 2., 1.0, 0.2 ]; // 控制运动
23
-
24
- varying mat4 styleMappingMat;
25
25
  // [animate, duration, interval, trailLength],
26
26
  void main() {
27
- float opacity = styleMappingMat[0][0];
28
27
  float animateSpeed = 0.0; // 运动速度
29
- float d_distance_ratio = styleMappingMat[3].r; // 当前点位距离占线总长的比例
28
+ float d_distance_ratio = v_texture_data.r; // 当前点位距离占线总长的比例
30
29
  gl_FragColor = v_color;
31
30
  // anti-alias
32
31
  // float blur = 1.0 - smoothstep(u_blur, 1., length(v_normal.xy));
33
- gl_FragColor.a *= opacity; // 全局透明度
32
+ gl_FragColor.a *= u_opacity; // 全局透明度
34
33
  if(u_animate.x == Animate) {
35
34
  animateSpeed = u_time / u_animate.y;
36
35
  float alpha =1.0 - fract( mod(1.0- d_distance_ratio, u_animate.z)* (1.0/ u_animate.z) + animateSpeed);
@@ -40,23 +39,20 @@ void main() {
40
39
  }
41
40
 
42
41
  if(u_line_texture == LineTexture) { // while load texture
43
- float aDistance = styleMappingMat[3].g; // 当前顶点的距离
44
- float d_texPixelLen = styleMappingMat[3].b; // 贴图的像素长度,根据地图层级缩放
42
+ float aDistance = v_texture_data.g; // 当前顶点的距离
43
+ float d_texPixelLen = v_texture_data.b; // 贴图的像素长度,根据地图层级缩放
45
44
  float u = fract(mod(aDistance, d_texPixelLen)/d_texPixelLen - animateSpeed);
46
- float v = styleMappingMat[3].a; // 线图层贴图部分的 v 坐标值
45
+ float v = v_texture_data.a; // 线图层贴图部分的 v 坐标值
47
46
 
48
47
  // v = max(smoothstep(0.95, 1.0, v), v);
49
48
  vec2 uv= v_iconMapUV / u_textSize + vec2(u, v) / u_textSize * 64.;
50
-
51
- // gl_FragColor = filterColor(gl_FragColor + texture2D(u_texture, vec2(u, v)));
52
- // gl_FragColor = filterColor(gl_FragColor + texture2D(u_texture, uv));
53
49
  vec4 pattern = texture2D(u_texture, uv);
54
50
 
55
51
  if(u_textureBlend == 0.0) { // normal
56
52
  pattern.a = 0.0;
57
53
  gl_FragColor += pattern;
58
54
  } else { // replace
59
- pattern.a *= opacity;
55
+ pattern.a *= u_opacity;
60
56
  if(gl_FragColor.a <= 0.0) {
61
57
  pattern.a = 0.0;
62
58
  }
@@ -64,15 +60,17 @@ void main() {
64
60
  }
65
61
  }
66
62
 
67
- float v = styleMappingMat[3].a;
63
+ float v = v_texture_data.a;
68
64
  float borderWidth = min(0.5, u_borderWidth);
69
65
  // 绘制 border
70
66
  if(borderWidth > 0.01) {
71
- float borderOuterWidth = borderWidth/2.0;
67
+ float borderOuterWidth = borderWidth / 2.0;
68
+
72
69
 
73
70
  if(v >= 1.0 - borderWidth || v <= borderWidth) {
74
- if(v > borderWidth) {
71
+ if(v > borderWidth) { // 外侧
75
72
  float linear = smoothstep(0.0, 1.0, (v - (1.0 - borderWidth))/borderWidth);
73
+ // float linear = step(0.0, (v - (1.0 - borderWidth))/borderWidth);
76
74
  gl_FragColor.rgb = mix(gl_FragColor.rgb, u_borderColor.rgb, linear);
77
75
  } else if(v <= borderWidth) {
78
76
  float linear = smoothstep(0.0, 1.0, v/borderWidth);
@@ -88,7 +86,7 @@ void main() {
88
86
  }
89
87
 
90
88
  // blur
91
- float blurV = styleMappingMat[3][3];
89
+ float blurV = v_texture_data.a;
92
90
  if(blurV < 0.5) {
93
91
  gl_FragColor.a *= mix(u_blur.r, u_blur.g, blurV/0.5);
94
92
  } else {