@antv/l7-layers 2.20.13 → 2.20.15
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.
- package/es/core/BaseLayer.d.ts +0 -1
- package/es/core/BaseLayer.js +8 -5
- package/es/core/LayerPickService.d.ts +1 -1
- package/es/core/LayerPickService.js +28 -10
- package/es/core/TextureService.js +2 -1
- package/es/geometry/models/sprite.js +2 -2
- package/es/heatmap/models/grid.js +2 -2
- package/es/heatmap/models/grid3d.js +4 -4
- package/es/heatmap/models/heatmap.js +10 -6
- package/es/heatmap/shaders/grid/grid_frag.glsl +1 -0
- package/es/heatmap/shaders/grid3d/grid_3d_frag.glsl +9 -0
- package/es/heatmap/shaders/grid3d/grid_3d_vert.glsl +4 -8
- package/es/heatmap/shaders/heatmap/heatmap_framebuffer_frag.glsl +2 -1
- package/es/heatmap/shaders/heatmap/heatmap_framebuffer_vert.glsl +3 -1
- package/es/heatmap/shaders/heatmap/heatmap_vert.glsl +3 -0
- package/es/image/models/image.js +6 -8
- package/es/line/models/arc.js +1 -1
- package/es/line/models/line.js +10 -45
- package/es/line/shaders/arc/line_arc_frag.glsl +2 -1
- package/es/line/shaders/line/line_frag.glsl +2 -2
- package/es/line/shaders/line/line_vert.glsl +10 -7
- package/es/plugins/ShaderUniformPlugin.js +16 -11
- package/es/point/models/extrude.js +2 -2
- package/es/point/models/fill.js +1 -1
- package/es/point/models/fillImage.js +3 -5
- package/es/point/models/text.js +2 -2
- package/es/point/shaders/extrude/extrude_frag.glsl +1 -0
- package/es/point/shaders/extrude/extrude_vert.glsl +0 -1
- package/es/point/shaders/fill/fill_frag.glsl +1 -1
- package/es/point/shaders/fillImage/fillImage_frag.glsl +1 -2
- package/es/point/shaders/text/text_frag.glsl +3 -2
- package/es/point/shaders/text/text_vert.glsl +0 -2
- package/es/polygon/models/extrude.js +30 -39
- package/es/polygon/models/extrusion.js +1 -1
- package/es/polygon/models/fill.js +3 -3
- package/es/polygon/models/water.js +6 -4
- package/es/polygon/shaders/extrude/polygon_extrude_frag.glsl +1 -0
- package/es/polygon/shaders/extrude/polygon_extrude_picklight_frag.glsl +1 -0
- package/es/polygon/shaders/extrude/polygon_extrude_picklight_vert.glsl +2 -3
- package/es/polygon/shaders/extrude/polygon_extrudetex_frag.glsl +7 -9
- package/es/polygon/shaders/extrude/polygon_extrudetex_vert.glsl +1 -2
- package/es/polygon/shaders/extrusion/polygon_extrusion_frag.glsl +1 -0
- package/es/polygon/shaders/fill/fill_frag.glsl +1 -0
- package/es/polygon/shaders/fill/fill_linear_frag.glsl +4 -3
- package/es/polygon/shaders/fill/fill_linear_vert.glsl +5 -8
- package/es/raster/models/raster.js +6 -5
- package/es/raster/models/rasterRgb.js +3 -2
- package/es/raster/models/rasterTerrainRgb.d.ts +8 -2
- package/es/raster/models/rasterTerrainRgb.js +20 -14
- package/es/raster/shaders/raster/raster_2d_frag.glsl +3 -3
- package/es/raster/shaders/raster/raster_2d_vert.glsl +2 -2
- package/es/raster/shaders/rgb/raster_rgb_frag.glsl +1 -0
- package/es/raster/shaders/terrain/terrain_rgb_frag.glsl +19 -17
- package/es/raster/shaders/terrain/terrain_rgb_vert.glsl +12 -5
- package/es/tile/core/BaseLayer.js +7 -7
- package/es/tile/service/TilePickService.d.ts +1 -1
- package/es/tile/service/TilePickService.js +36 -13
- package/es/tile/tile/Tile.js +4 -3
- package/es/utils/load-image.d.ts +1 -0
- package/es/utils/load-image.js +46 -0
- package/lib/core/BaseLayer.js +8 -5
- package/lib/core/LayerPickService.js +28 -10
- package/lib/core/TextureService.js +2 -1
- package/lib/geometry/models/sprite.js +2 -2
- package/lib/heatmap/models/grid.js +2 -2
- package/lib/heatmap/models/grid3d.js +4 -4
- package/lib/heatmap/models/heatmap.js +10 -6
- package/lib/heatmap/shaders/grid/grid_frag.glsl +1 -0
- package/lib/heatmap/shaders/grid3d/grid_3d_frag.glsl +9 -0
- package/lib/heatmap/shaders/grid3d/grid_3d_vert.glsl +4 -8
- package/lib/heatmap/shaders/heatmap/heatmap_framebuffer_frag.glsl +2 -1
- package/lib/heatmap/shaders/heatmap/heatmap_framebuffer_vert.glsl +3 -1
- package/lib/heatmap/shaders/heatmap/heatmap_vert.glsl +3 -0
- package/lib/image/models/image.js +6 -8
- package/lib/line/models/arc.js +1 -1
- package/lib/line/models/line.js +10 -45
- package/lib/line/shaders/arc/line_arc_frag.glsl +2 -1
- package/lib/line/shaders/line/line_frag.glsl +2 -2
- package/lib/line/shaders/line/line_vert.glsl +10 -7
- package/lib/plugins/ShaderUniformPlugin.js +16 -11
- package/lib/point/models/extrude.js +2 -2
- package/lib/point/models/fill.js +1 -1
- package/lib/point/models/fillImage.js +3 -5
- package/lib/point/models/text.js +2 -2
- package/lib/point/shaders/extrude/extrude_frag.glsl +1 -0
- package/lib/point/shaders/extrude/extrude_vert.glsl +0 -1
- package/lib/point/shaders/fill/fill_frag.glsl +1 -1
- package/lib/point/shaders/fillImage/fillImage_frag.glsl +1 -2
- package/lib/point/shaders/text/text_frag.glsl +3 -2
- package/lib/point/shaders/text/text_vert.glsl +0 -2
- package/lib/polygon/models/extrude.js +29 -38
- package/lib/polygon/models/extrusion.js +1 -1
- package/lib/polygon/models/fill.js +3 -3
- package/lib/polygon/models/water.js +6 -4
- package/lib/polygon/shaders/extrude/polygon_extrude_frag.glsl +1 -0
- package/lib/polygon/shaders/extrude/polygon_extrude_picklight_frag.glsl +1 -0
- package/lib/polygon/shaders/extrude/polygon_extrude_picklight_vert.glsl +2 -3
- package/lib/polygon/shaders/extrude/polygon_extrudetex_frag.glsl +7 -9
- package/lib/polygon/shaders/extrude/polygon_extrudetex_vert.glsl +1 -2
- package/lib/polygon/shaders/extrusion/polygon_extrusion_frag.glsl +1 -0
- package/lib/polygon/shaders/fill/fill_frag.glsl +1 -0
- package/lib/polygon/shaders/fill/fill_linear_frag.glsl +4 -3
- package/lib/polygon/shaders/fill/fill_linear_vert.glsl +5 -8
- package/lib/raster/models/raster.js +6 -5
- package/lib/raster/models/rasterRgb.js +3 -2
- package/lib/raster/models/rasterTerrainRgb.js +20 -14
- package/lib/raster/shaders/raster/raster_2d_frag.glsl +3 -3
- package/lib/raster/shaders/raster/raster_2d_vert.glsl +2 -2
- package/lib/raster/shaders/rgb/raster_rgb_frag.glsl +1 -0
- package/lib/raster/shaders/terrain/terrain_rgb_frag.glsl +19 -17
- package/lib/raster/shaders/terrain/terrain_rgb_vert.glsl +12 -5
- package/lib/tile/core/BaseLayer.js +7 -7
- package/lib/tile/service/TilePickService.js +36 -13
- package/lib/tile/tile/Tile.js +4 -3
- package/lib/utils/load-image.js +53 -0
- package/package.json +7 -7
|
@@ -3,11 +3,9 @@
|
|
|
3
3
|
|
|
4
4
|
layout(location = 0) in vec3 a_Position;
|
|
5
5
|
layout(location = 1) in vec4 a_Color;
|
|
6
|
-
layout(location = 10) in vec2 a_DistanceAndIndex;
|
|
7
6
|
layout(location = 9) in vec2 a_Size;
|
|
8
|
-
layout(location =
|
|
9
|
-
layout(location = 13) in
|
|
10
|
-
layout(location = 15) in float a_Miter;
|
|
7
|
+
layout(location = 10) in vec3 a_DistanceAndIndexAndMiter;
|
|
8
|
+
layout(location = 13) in vec4 a_Normal_Total_Distance;
|
|
11
9
|
layout(location = 14) in vec2 a_iconMapUV;
|
|
12
10
|
|
|
13
11
|
layout(std140) uniform commonUniorm {
|
|
@@ -28,20 +26,25 @@ layout(std140) uniform commonUniorm {
|
|
|
28
26
|
float u_linearColor: 0;
|
|
29
27
|
float u_time;
|
|
30
28
|
};
|
|
31
|
-
|
|
32
|
-
#pragma include "picking"
|
|
29
|
+
|
|
33
30
|
|
|
34
31
|
out vec4 v_color;
|
|
35
32
|
out vec4 v_stroke;
|
|
36
33
|
//dash
|
|
37
34
|
out vec4 v_dash_array;
|
|
38
35
|
out float v_d_distance_ratio;
|
|
39
|
-
|
|
40
36
|
// texV 线图层 - 贴图部分的 v 坐标(线的宽度方向)
|
|
41
37
|
out vec2 v_iconMapUV;
|
|
42
38
|
out vec4 v_texture_data;
|
|
43
39
|
|
|
40
|
+
#pragma include "projection"
|
|
41
|
+
#pragma include "picking"
|
|
42
|
+
|
|
44
43
|
void main() {
|
|
44
|
+
vec2 a_DistanceAndIndex = a_DistanceAndIndexAndMiter.xy;
|
|
45
|
+
float a_Miter = a_DistanceAndIndexAndMiter.z;
|
|
46
|
+
vec3 a_Normal = a_Normal_Total_Distance.xyz;
|
|
47
|
+
float a_Total_Distance = a_Normal_Total_Distance.w;
|
|
45
48
|
//dash输出
|
|
46
49
|
v_dash_array = pow(2.0, 20.0 - u_Zoom) * u_dash_array / a_Total_Distance;
|
|
47
50
|
v_d_distance_ratio = a_DistanceAndIndex.x / a_Total_Distance;
|
|
@@ -67,22 +67,27 @@ var ShaderUniformPlugin = (_dec = injectable(), _dec2 = inject(TYPES.ICameraServ
|
|
|
67
67
|
var _this$generateUBO = _this.generateUBO(mvp, sceneCenterMercator, width, height),
|
|
68
68
|
data = _this$generateUBO.data,
|
|
69
69
|
uniforms = _this$generateUBO.uniforms;
|
|
70
|
-
if (_this.layerService.alreadyInRendering &&
|
|
70
|
+
if (_this.layerService.alreadyInRendering && _this.rendererService.uniformBuffers[0]) {
|
|
71
|
+
var renderUniformBuffer = _this.rendererService.uniformBuffers[0];
|
|
71
72
|
// Update only once since all models can share one UBO.
|
|
72
|
-
|
|
73
|
+
renderUniformBuffer.subData({
|
|
73
74
|
offset: 0,
|
|
74
75
|
data: data
|
|
75
76
|
});
|
|
76
77
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
78
|
+
|
|
79
|
+
// For WebGL1. regl
|
|
80
|
+
var platformString = _this.rendererService.queryVerdorInfo();
|
|
81
|
+
if (platformString === 'WebGL1') {
|
|
82
|
+
layer.models.forEach(function (model) {
|
|
83
|
+
model.addUniforms(_objectSpread(_objectSpread({}, uniforms), {}, {
|
|
84
|
+
// TODO: move these 2 uniforms to PixelPickingPlugin
|
|
85
|
+
u_PickingBuffer: layer.getLayerConfig().pickingBuffer || 0,
|
|
86
|
+
// Tip: 当前地图是否在拖动
|
|
87
|
+
u_shaderPick: Number(layer.getShaderPickStat())
|
|
88
|
+
}));
|
|
89
|
+
});
|
|
90
|
+
}
|
|
86
91
|
});
|
|
87
92
|
}
|
|
88
93
|
|
|
@@ -15,9 +15,9 @@ import BaseModel from "../../core/BaseModel";
|
|
|
15
15
|
import { ShaderLocation } from "../../core/CommonStyleAttribute";
|
|
16
16
|
import { PointExtrudeTriangulation } from "../../core/triangulation";
|
|
17
17
|
/* babel-plugin-inline-import '../shaders/extrude/extrude_frag.glsl' */
|
|
18
|
-
var pointExtrudeFrag = "\nin vec4 v_color;\nin float v_lightWeight;\nout vec4 outputColor;\n\nlayout(std140) uniform commonUniforms {\n float u_pickLight;\n float u_heightfixed;\n float u_r;\n float u_linearColor;\n vec4 u_sourceColor;\n vec4 u_targetColor;\n float u_opacitylinear;\n float u_opacitylinear_dir;\n float u_lightEnable;\n};\n\n#pragma include \"picking\"\n\nvoid main() {\n\n outputColor = v_color;\n // \u5F00\u542F\u900F\u660E\u5EA6\u6E10\u53D8\n // picking\n if(u_pickLight > 0.0) {\n outputColor = filterColorAlpha(outputColor, v_lightWeight);\n } else {\n outputColor = filterColor(outputColor);\n }\n}\n";
|
|
18
|
+
var pointExtrudeFrag = "\nin vec4 v_color;\nin float v_lightWeight;\nout vec4 outputColor;\n\nlayout(std140) uniform commonUniforms {\n float u_pickLight;\n float u_heightfixed;\n float u_r;\n float u_linearColor;\n vec4 u_sourceColor;\n vec4 u_targetColor;\n float u_opacitylinear;\n float u_opacitylinear_dir;\n float u_lightEnable;\n};\n\n#pragma include \"scene_uniforms\"\n#pragma include \"picking\"\n\nvoid main() {\n\n outputColor = v_color;\n // \u5F00\u542F\u900F\u660E\u5EA6\u6E10\u53D8\n // picking\n if(u_pickLight > 0.0) {\n outputColor = filterColorAlpha(outputColor, v_lightWeight);\n } else {\n outputColor = filterColor(outputColor);\n }\n}\n";
|
|
19
19
|
/* babel-plugin-inline-import '../shaders/extrude/extrude_vert.glsl' */
|
|
20
|
-
var pointExtrudeVert = "#define pi 3.1415926535\n\nlayout(location = 0) in vec3 a_Position;\nlayout(location = 1) in vec4 a_Color;\nlayout(location = 9) in vec3 a_Size;\nlayout(location = 11) in vec3 a_Extrude;\nlayout(location = 13) in vec3 a_Normal;\n\nlayout(std140) uniform commonUniforms {\n float u_pickLight;\n float u_heightfixed;\n float u_r;\n float u_linearColor;\n vec4 u_sourceColor;\n vec4 u_targetColor;\n float u_opacitylinear;\n float u_opacitylinear_dir;\n float u_lightEnable;\n};\nout vec4 v_color;\nout float v_lightWeight;\
|
|
20
|
+
var pointExtrudeVert = "#define pi 3.1415926535\n\nlayout(location = 0) in vec3 a_Position;\nlayout(location = 1) in vec4 a_Color;\nlayout(location = 9) in vec3 a_Size;\nlayout(location = 11) in vec3 a_Extrude;\nlayout(location = 13) in vec3 a_Normal;\n\nlayout(std140) uniform commonUniforms {\n float u_pickLight;\n float u_heightfixed;\n float u_r;\n float u_linearColor;\n vec4 u_sourceColor;\n vec4 u_targetColor;\n float u_opacitylinear;\n float u_opacitylinear_dir;\n float u_lightEnable;\n};\nout vec4 v_color;\nout float v_lightWeight;\n\n#pragma include \"projection\"\n#pragma include \"light\"\n#pragma include \"picking\"\n\nfloat getYRadian(float x, float z) {\n if(x > 0.0 && z > 0.0) {\n return atan(x/z);\n } else if(x > 0.0 && z <= 0.0){\n return atan(-z/x) + pi/2.0;\n } else if(x <= 0.0 && z <= 0.0) {\n return pi + atan(x/z); //atan(x/z) + \n } else {\n return atan(z/-x) + pi*3.0/2.0;\n }\n}\n\nfloat getXRadian(float y, float r) {\n return atan(y/r);\n}\n\nvoid main() {\n\n\n vec3 size = a_Size * a_Position;\n\n vec3 offset = size; // \u63A7\u5236\u5706\u67F1\u4F53\u7684\u5927\u5C0F - \u4ECE\u6807\u51C6\u5355\u4F4D\u5706\u67F1\u4F53\u8FDB\u884C\u504F\u79FB\n\n if(u_heightfixed < 1.0) { // \u5706\u67F1\u4F53\u4E0D\u56FA\u5B9A\u9AD8\u5EA6\n \n if (u_CoordinateSystem == COORDINATE_SYSTEM_P20 || u_CoordinateSystem == COORDINATE_SYSTEM_P20_OFFSET) {\n // P20 \u5750\u6807\u7CFB\u4E0B\uFF0C\u4E3A\u4E86\u548C Web \u58A8\u5361\u6258\u5750\u6807\u7CFB\u7EDF\u4E00\uFF0Czoom \u9ED8\u8BA4\u51CF1\n offset = offset * pow(2.0, (19.0 - u_Zoom));\n }\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) {\n // P20_2 \u5750\u6807\u7CFB\u4E0B\uFF0C\u4E3A\u4E86\u548C Web \u58A8\u5361\u6258\u5750\u6807\u7CFB\u7EDF\u4E00\uFF0Czoom \u9ED8\u8BA4\u51CF3\n offset = offset * pow(2.0, (19.0 - 3.0 - u_Zoom));\n }\n } else {// \u5706\u67F1\u4F53\u56FA\u5B9A\u9AD8\u5EA6 \uFF08 \u5904\u7406 mapbox \uFF09\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n offset *= 4.0/pow(2.0, 21.0 - u_Zoom);\n }\n }\n\n\n vec4 project_pos = project_position(vec4(a_Extrude.xy, 0., 1.0));\n\n // u_r \u63A7\u5236\u5706\u67F1\u7684\u751F\u957F\n vec4 pos = vec4(project_pos.xy + offset.xy, offset.z * u_r, 1.0);\n\n // // \u5706\u67F1\u5149\u7167\u6548\u679C\n float lightWeight = 1.0;\n\n if(u_lightEnable > 0.0) { // \u53D6\u6D88\u4E09\u5143\u8868\u8FBE\u5F0F\uFF0C\u589E\u5F3A\u5065\u58EE\u6027\n lightWeight = calc_lighting(pos);\n }\n\n v_lightWeight = lightWeight;\n\n v_color = a_Color;\n\n // \u8BBE\u7F6E\u5706\u67F1\u7684\u5E95\u8272\n if(u_linearColor == 1.0) { // \u4F7F\u7528\u6E10\u53D8\u989C\u8272\n v_color = mix(u_sourceColor, u_targetColor, a_Position.z);\n v_color.a = v_color.a * opacity;\n } else {\n v_color = vec4(a_Color.rgb * lightWeight, a_Color.w * opacity);\n }\n\n if(u_opacitylinear > 0.0) {\n v_color.a *= u_opacitylinear_dir > 0.0 ? (1.0 - a_Position.z): a_Position.z;\n }\n\n\n gl_Position = project_common_position_to_clipspace_v2(pos);\n\n setPickingColor(a_PickingColor);\n}\n";
|
|
21
21
|
var ExtrudeModel = /*#__PURE__*/function (_BaseModel) {
|
|
22
22
|
_inherits(ExtrudeModel, _BaseModel);
|
|
23
23
|
var _super = _createSuper(ExtrudeModel);
|
package/es/point/models/fill.js
CHANGED
|
@@ -12,7 +12,7 @@ import { PointFillTriangulation } from '@antv/l7-utils';
|
|
|
12
12
|
import BaseModel from "../../core/BaseModel";
|
|
13
13
|
import { ShaderLocation } from "../../core/CommonStyleAttribute";
|
|
14
14
|
/* babel-plugin-inline-import '../shaders/fill/fill_frag.glsl' */
|
|
15
|
-
var pointFillFrag = "
|
|
15
|
+
var pointFillFrag = "\nlayout(std140) uniform commonUniforms {\n vec3 u_blur_height_fixed;\n float u_stroke_width;\n float u_additive;\n float u_stroke_opacity;\n float u_size_unit;\n float u_time;\n vec4 u_animate;\n};\n\nin vec4 v_color;\nin vec4 v_stroke;\nin vec4 v_data;\nin float v_radius;\n\n#pragma include \"scene_uniforms\"\n#pragma include \"sdf_2d\"\n#pragma include \"picking\"\n\nout vec4 outputColor;\n\nvoid main() {\n int shape = int(floor(v_data.w + 0.5));\n lowp float antialiasblur = v_data.z;\n float r = v_radius / (v_radius + u_stroke_width);\n\n float outer_df;\n float inner_df;\n // 'circle', 'triangle', 'square', 'pentagon', 'hexagon', 'octogon', 'hexagram', 'rhombus', 'vesica'\n if (shape == 0) {\n outer_df = sdCircle(v_data.xy, 1.0);\n inner_df = sdCircle(v_data.xy, r);\n } else if (shape == 1) {\n outer_df = sdEquilateralTriangle(1.1 * v_data.xy);\n inner_df = sdEquilateralTriangle(1.1 / r * v_data.xy);\n } else if (shape == 2) {\n outer_df = sdBox(v_data.xy, vec2(1.));\n inner_df = sdBox(v_data.xy, vec2(r));\n } else if (shape == 3) {\n outer_df = sdPentagon(v_data.xy, 0.8);\n inner_df = sdPentagon(v_data.xy, r * 0.8);\n } else if (shape == 4) {\n outer_df = sdHexagon(v_data.xy, 0.8);\n inner_df = sdHexagon(v_data.xy, r * 0.8);\n } else if (shape == 5) {\n outer_df = sdOctogon(v_data.xy, 1.0);\n inner_df = sdOctogon(v_data.xy, r);\n } else if (shape == 6) {\n outer_df = sdHexagram(v_data.xy, 0.52);\n inner_df = sdHexagram(v_data.xy, r * 0.52);\n } else if (shape == 7) {\n outer_df = sdRhombus(v_data.xy, vec2(1.0));\n inner_df = sdRhombus(v_data.xy, vec2(r));\n } else if (shape == 8) {\n outer_df = sdVesica(v_data.xy, 1.1, 0.8);\n inner_df = sdVesica(v_data.xy, r * 1.1, r * 0.8);\n }\n\n float opacity_t = smoothstep(0.0, antialiasblur, outer_df);\n\n float color_t = u_stroke_width < 0.01 ? 0.0 : smoothstep(\n antialiasblur,\n 0.0,\n inner_df\n );\n\n float PI = 3.14159;\n float N_RINGS = 3.0;\n float FREQ = 1.0;\n\n if(u_stroke_width < 0.01) {\n outputColor = v_color;\n } else {\n outputColor = mix(v_color, v_stroke * u_stroke_opacity, color_t);\n }\n float intensity = 1.0;\n if(u_time!=-1.0){\n //wave\u76F8\u5173\u903B\u8F91\n float d = length(v_data.xy);\n if(d > 0.5) {\n discard;\n }\n intensity = clamp(cos(d * PI), 0.0, 1.0) * clamp(cos(2.0 * PI * (d * 2.0 * u_animate.z - u_animate.y * u_time)), 0.0, 1.0);\n }\n\n if(u_additive > 0.0) {\n outputColor *= opacity_t;\n outputColor *= intensity;//wave\n outputColor = filterColorAlpha(outputColor, outputColor.a);\n } else {\n outputColor.a *= opacity_t;\n outputColor.a *= intensity;//wave \n outputColor = filterColor(outputColor);\n }\n // \u4F5C\u4E3A mask \u6A21\u677F\u65F6\u9700\u8981\u4E22\u5F03\u900F\u660E\u7684\u50CF\u7D20\n if(outputColor.a < 0.01) {\n discard;\n } \n}\n";
|
|
16
16
|
/* babel-plugin-inline-import '../shaders/fill/fill_vert.glsl' */
|
|
17
17
|
var pointFillVert = "layout(location = 0) in vec3 a_Position;\nlayout(location = 1) in vec4 a_Color;\nlayout(location = 9) in float a_Size;\nlayout(location = 10) in float a_Shape;\nlayout(location = 11) in vec3 a_Extrude;\n\nlayout(std140) uniform commonUniforms {\n vec3 u_blur_height_fixed;\n float u_stroke_width;\n float u_additive;\n float u_stroke_opacity;\n float u_size_unit;\n float u_time;\n vec4 u_animate; \n};\n\nout vec4 v_color;\nout vec4 v_stroke;\nout vec4 v_data;\nout float v_radius;\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n#pragma include \"rotation_2d\"\n\nvoid main() {\n // \u900F\u660E\u5EA6\u8BA1\u7B97\n v_stroke = stroke; \n vec3 extrude = a_Extrude;\n float shape_type = a_Shape;\n /*\n * setPickingSize \u8BBE\u7F6E\u62FE\u53D6\u5927\u5C0F\n * u_meter2coord \u5728\u7B49\u9762\u79EF\u5927\u5C0F\u7684\u65F6\u5019\u8BBE\u7F6E\u5355\u4F4D\n */\n float newSize = setPickingSize(a_Size);\n // float newSize = setPickingSize(a_Size) * 0.00001038445708445579;\n\n\n\n // unpack color(vec2)\n v_color = vec4(a_Color.xyz, a_Color.w * opacity);\n\n if(u_size_unit == 1.0) {\n newSize = newSize * u_PixelsPerMeter.z;\n }\n\n v_radius = newSize;\n\n // anti-alias\n // float antialiased_blur = -max(u_blur, antialiasblur);\n float antialiasblur = -max(2.0 / u_DevicePixelRatio / newSize, u_blur_height_fixed.x);\n\n vec2 offset = (extrude.xy * (newSize + u_stroke_width) + u_offsets);\n vec3 aPosition = a_Position;\n\n offset = project_pixel(offset);\n offset = rotate_matrix(offset,rotation);\n \n // TODP: /abs(extrude.x) \u662F\u4E3A\u4E86\u517C\u5BB9\u5730\u7403\u6A21\u5F0F\n v_data = vec4(extrude.x/abs(extrude.x), extrude.y/abs(extrude.y), antialiasblur,shape_type);\n\n\n // vec4 project_pos = project_position(vec4(a_Position.xy, 0.0, 1.0));\n vec4 project_pos = project_position(vec4(aPosition.xy, 0.0, 1.0));\n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, project_pixel(setPickingOrder(0.0)), 1.0));\n\n float raisingHeight = u_blur_height_fixed.y;\n\n if(u_blur_height_fixed.z < 1.0) { // false\n raisingHeight = project_pixel(u_blur_height_fixed.y);\n } else {\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n raisingHeight = u_blur_height_fixed.y * mapboxZoomScale;\n }\n }\n \n gl_Position = project_common_position_to_clipspace_v2(vec4(project_pos.xy + offset, raisingHeight, 1.0));\n\n setPickingColor(a_PickingColor);\n}\n";
|
|
18
18
|
import { SizeUnitType } from "../../core/interface";
|
|
@@ -17,7 +17,7 @@ import { PointFillTriangulation } from "../../core/triangulation";
|
|
|
17
17
|
// static pointLayer shader - not support animate
|
|
18
18
|
import { ShaderLocation } from "../../core/CommonStyleAttribute";
|
|
19
19
|
/* babel-plugin-inline-import '../shaders/fillImage/fillImage_frag.glsl' */
|
|
20
|
-
var pointFillFrag = "in
|
|
20
|
+
var pointFillFrag = "in vec2 v_uv;// \u672C\u8EAB\u7684 uv \u5750\u6807\nin vec2 v_Iconuv;\nin float v_opacity;\nout vec4 outputColor;\n\nuniform sampler2D u_texture;\nlayout(std140) uniform commonUniform {\n vec2 u_textSize;\n float u_heightfixed: 0.0;\n float u_raisingHeight: 0.0;\n float u_size_unit;\n};\n\n#pragma include \"scene_uniforms\"\n#pragma include \"sdf_2d\"\n#pragma include \"picking\"\n\nvoid main() {\n vec2 pos = v_Iconuv / u_textSize + v_uv / u_textSize * 64.;\n outputColor = texture(SAMPLER_2D(u_texture), pos);\n outputColor.a *= v_opacity;\n outputColor = filterColor(outputColor);\n}\n";
|
|
21
21
|
/* babel-plugin-inline-import '../shaders/fillImage/fillImage_vert.glsl' */
|
|
22
22
|
var pointFillVert = "layout(location = 0) in vec3 a_Position;\nlayout(location = 1) in vec4 a_Color;\nlayout(location = 9) in float a_Size;\nlayout(location = 11) in vec3 a_Extrude;\nlayout(location = 14) in vec2 a_Uv;\n\nlayout(std140) uniform commonUniform {\n vec2 u_textSize;\n float u_heightfixed: 0.0;\n float u_raisingHeight: 0.0;\n float u_size_unit;\n};\n\nout vec2 v_uv;\nout vec2 v_Iconuv;\nout float v_opacity;\n\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n#pragma include \"rotation_2d\"\n\nvoid main() {\n vec3 extrude = a_Extrude;\n v_uv = (a_Extrude.xy + 1.0)/2.0;\n v_uv.y = 1.0 - v_uv.y;\n v_Iconuv = a_Uv;\n v_opacity = opacity;\n float newSize = a_Size;\n if(u_size_unit == 1.0) {\n newSize = newSize * u_PixelsPerMeter.z;\n }\n \n // vec2 offset = (u_RotateMatrix * extrude.xy * (a_Size) + textrueOffsets);\n vec2 offset = (extrude.xy * (newSize) + offsets);\n\n offset = rotate_matrix(offset,rotation);\n\n vec3 aPosition = a_Position;\n\n offset = project_pixel(offset);\n\n vec4 project_pos = project_position(vec4(aPosition.xy, 0.0, 1.0));\n float raisingHeight = u_raisingHeight;\n if(u_heightfixed < 1.0) { // height fixed\n raisingHeight = project_pixel(u_raisingHeight);\n } else {\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n raisingHeight = u_raisingHeight * mapboxZoomScale;\n }\n }\n\n gl_Position = project_common_position_to_clipspace_v2(vec4(project_pos.xy + offset, 0.0, 1.0));\n\n setPickingColor(a_PickingColor);\n}\n";
|
|
23
23
|
var FillImageModel = /*#__PURE__*/function (_BaseModel) {
|
|
@@ -86,10 +86,8 @@ var FillImageModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
86
86
|
u_textSize: [1024, this.iconService.canvasHeight || 128],
|
|
87
87
|
u_heightfixed: Number(heightfixed),
|
|
88
88
|
u_raisingHeight: Number(raisingHeight),
|
|
89
|
-
u_size_unit: SizeUnitType[unit]
|
|
90
|
-
|
|
91
|
-
};
|
|
92
|
-
this.textures = [this.texture];
|
|
89
|
+
u_size_unit: SizeUnitType[unit]
|
|
90
|
+
}; //2+1+1+1
|
|
93
91
|
var commonBufferInfo = this.getUniformsBufferInfo(commonOptions);
|
|
94
92
|
return commonBufferInfo;
|
|
95
93
|
}
|
package/es/point/models/text.js
CHANGED
|
@@ -20,9 +20,9 @@ import BaseModel from "../../core/BaseModel";
|
|
|
20
20
|
import CollisionIndex from "../../utils/collision-index";
|
|
21
21
|
import { getGlyphQuads, shapeText } from "../../utils/symbol-layout";
|
|
22
22
|
/* babel-plugin-inline-import '../shaders/text/text_frag.glsl' */
|
|
23
|
-
var textFrag = "#define SDF_PX 8.0\n#define EDGE_GAMMA 0.105\n#define FONT_SIZE 48.0\n\nuniform sampler2D u_sdf_map;\nlayout(std140) uniform commonUniforms {\n vec4 u_stroke_color : [0.0, 0.0, 0.0, 0.0];\n vec2 u_sdf_map_size;\n float u_raisingHeight: 0.0;\n float u_stroke_width : 2;\n float u_gamma_scale : 0.5;\n float u_halo_blur : 0.5;\n};\n\nin
|
|
23
|
+
var textFrag = "#define SDF_PX 8.0\n#define EDGE_GAMMA 0.105\n#define FONT_SIZE 48.0\n\nuniform sampler2D u_sdf_map;\nlayout(std140) uniform commonUniforms {\n vec4 u_stroke_color : [0.0, 0.0, 0.0, 0.0];\n vec2 u_sdf_map_size;\n float u_raisingHeight: 0.0;\n float u_stroke_width : 2;\n float u_gamma_scale : 0.5;\n float u_halo_blur : 0.5;\n};\n\nin vec2 v_uv;\nin float v_gamma_scale;\nin vec4 v_color;\nin vec4 v_stroke_color;\nin float v_fontScale;\n\nout vec4 outputColor;\n\n#pragma include \"picking\"\nvoid main() {\n // get style data mapping\n\n // get sdf from atlas\n float dist = texture(SAMPLER_2D(u_sdf_map), v_uv).a;\n\n lowp float buff = (6.0 - u_stroke_width / v_fontScale) / SDF_PX;\n highp float gamma = (u_halo_blur * 1.19 / SDF_PX + EDGE_GAMMA) / (v_fontScale * u_gamma_scale) / 1.0;\n\n highp float gamma_scaled = gamma * v_gamma_scale;\n\n highp float alpha = smoothstep(buff - gamma_scaled, buff + gamma_scaled, dist);\n\n outputColor = mix(v_color, v_stroke_color, smoothstep(0., 0.5, 1.- dist));\n\n outputColor.a *= alpha;\n // \u4F5C\u4E3A mask \u6A21\u677F\u65F6\u9700\u8981\u4E22\u5F03\u900F\u660E\u7684\u50CF\u7D20\n if (outputColor.a < 0.01) {\n discard;\n }\n outputColor = filterColor(outputColor);\n}\n";
|
|
24
24
|
/* babel-plugin-inline-import '../shaders/text/text_vert.glsl' */
|
|
25
|
-
var textVert = "#define SDF_PX 8.0\n#define EDGE_GAMMA 0.105\n#define FONT_SIZE 24.0\n\nlayout(location = 0) in vec3 a_Position;\nlayout(location = 1) in vec4 a_Color;\nlayout(location = 9) in float a_Size;\nlayout(location = 10) in vec2 a_textOffsets;\nlayout(location = 14) in vec2 a_tex;\n\nlayout(std140) uniform commonUniforms {\n vec4 u_stroke_color : [0.0, 0.0, 0.0, 0.0];\n vec2 u_sdf_map_size;\n float u_raisingHeight: 0.0;\n float u_stroke_width : 2;\n float u_gamma_scale : 0.5;\n float u_halo_blur : 0.5;\n};\n\nout vec2 v_uv;\nout float v_gamma_scale;\nout vec4 v_color;\nout vec4 v_stroke_color;\nout float v_fontScale;\n\n
|
|
25
|
+
var textVert = "#define SDF_PX 8.0\n#define EDGE_GAMMA 0.105\n#define FONT_SIZE 24.0\n\nlayout(location = 0) in vec3 a_Position;\nlayout(location = 1) in vec4 a_Color;\nlayout(location = 9) in float a_Size;\nlayout(location = 10) in vec2 a_textOffsets;\nlayout(location = 14) in vec2 a_tex;\n\nlayout(std140) uniform commonUniforms {\n vec4 u_stroke_color : [0.0, 0.0, 0.0, 0.0];\n vec2 u_sdf_map_size;\n float u_raisingHeight: 0.0;\n float u_stroke_width : 2;\n float u_gamma_scale : 0.5;\n float u_halo_blur : 0.5;\n};\n\nout vec2 v_uv;\nout float v_gamma_scale;\nout vec4 v_color;\nout vec4 v_stroke_color;\nout float v_fontScale;\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n#pragma include \"rotation_2d\"\n\nvoid main() {\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n \n v_uv = a_tex / u_sdf_map_size;\n\n\n\n v_color = vec4(a_Color.xyz, a_Color.w * opacity);\n v_stroke_color = vec4(u_stroke_color.xyz, u_stroke_color.w * opacity);\n\n // \u6587\u672C\u7F29\u653E\u6BD4\u4F8B\n float fontScale = a_Size / FONT_SIZE;\n v_fontScale = fontScale;\n\n vec4 project_pos = project_position(vec4(a_Position, 1.0));\n // vec4 projected_position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n\n vec2 offset = rotate_matrix(a_textOffsets,rotation);\n \n // gl_Position = vec4(projected_position.xy / projected_position.w + rotation_matrix * a_textOffsets * fontScale / u_ViewportSize * 2.0 * u_DevicePixelRatio, 0.0, 1.0);\n\n float raiseHeight = u_raisingHeight;\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n raiseHeight = u_raisingHeight * mapboxZoomScale;\n }\n\n vec4 projected_position = project_common_position_to_clipspace_v2(vec4(project_pos.xyz + vec3(0.0, 0.0, raiseHeight), 1.0));\n\n gl_Position = vec4(\n projected_position.xy / projected_position.w + offset * fontScale / u_ViewportSize * 2.0 * u_DevicePixelRatio, 0.0, 1.0);\n v_gamma_scale = gl_Position.w;\n setPickingColor(a_PickingColor);\n\n}\n";
|
|
26
26
|
import { ShaderLocation } from "../../core/CommonStyleAttribute";
|
|
27
27
|
var isEqual = lodashUtil.isEqual;
|
|
28
28
|
export function TextTrianglation(feature) {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
in vec4 v_color;
|
|
2
1
|
in vec2 v_uv;// 本身的 uv 坐标
|
|
3
2
|
in vec2 v_Iconuv;
|
|
4
3
|
in float v_opacity;
|
|
@@ -12,10 +11,10 @@ layout(std140) uniform commonUniform {
|
|
|
12
11
|
float u_size_unit;
|
|
13
12
|
};
|
|
14
13
|
|
|
14
|
+
#pragma include "scene_uniforms"
|
|
15
15
|
#pragma include "sdf_2d"
|
|
16
16
|
#pragma include "picking"
|
|
17
17
|
|
|
18
|
-
|
|
19
18
|
void main() {
|
|
20
19
|
vec2 pos = v_Iconuv / u_textSize + v_uv / u_textSize * 64.;
|
|
21
20
|
outputColor = texture(SAMPLER_2D(u_texture), pos);
|
|
@@ -12,11 +12,12 @@ layout(std140) uniform commonUniforms {
|
|
|
12
12
|
float u_halo_blur : 0.5;
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
-
in vec4 v_color;
|
|
16
|
-
in vec4 v_stroke_color;
|
|
17
15
|
in vec2 v_uv;
|
|
18
16
|
in float v_gamma_scale;
|
|
17
|
+
in vec4 v_color;
|
|
18
|
+
in vec4 v_stroke_color;
|
|
19
19
|
in float v_fontScale;
|
|
20
|
+
|
|
20
21
|
out vec4 outputColor;
|
|
21
22
|
|
|
22
23
|
#pragma include "picking"
|
|
@@ -14,18 +14,19 @@ import { rgb2arr } from '@antv/l7-utils';
|
|
|
14
14
|
import BaseModel from "../../core/BaseModel";
|
|
15
15
|
import { PolygonExtrudeTriangulation } from "../../core/triangulation";
|
|
16
16
|
/* babel-plugin-inline-import '../shaders/extrude/polygon_extrude_frag.glsl' */
|
|
17
|
-
var polygonExtrudeFrag = "layout(std140) uniform commonUniforms {\n vec4 u_sourceColor;\n vec4 u_targetColor;\n float u_linearColor;\n float u_topsurface;\n float u_sidesurface;\n float u_heightfixed; // \u9ED8\u8BA4\u4E0D\u56FA\u5B9A\n float u_raisingHeight;\n};\n\nin vec4 v_Color;\n#pragma include \"picking\"\nout vec4 outputColor;\nvoid main() {\n\n // top face\n if(u_topsurface < 1.0) {\n discard;\n }\n\n outputColor = v_Color;\n \n outputColor = filterColor(outputColor);\n}\n";
|
|
17
|
+
var polygonExtrudeFrag = "layout(std140) uniform commonUniforms {\n vec4 u_sourceColor;\n vec4 u_targetColor;\n float u_linearColor;\n float u_topsurface;\n float u_sidesurface;\n float u_heightfixed; // \u9ED8\u8BA4\u4E0D\u56FA\u5B9A\n float u_raisingHeight;\n};\n\nin vec4 v_Color;\n#pragma include \"scene_uniforms\"\n#pragma include \"picking\"\nout vec4 outputColor;\nvoid main() {\n\n // top face\n if(u_topsurface < 1.0) {\n discard;\n }\n\n outputColor = v_Color;\n \n outputColor = filterColor(outputColor);\n}\n";
|
|
18
18
|
/* babel-plugin-inline-import '../shaders/extrude/polygon_extrude_vert.glsl' */
|
|
19
19
|
var polygonExtrudeVert = "layout(location = 0) in vec3 a_Position;\nlayout(location = 1) in vec4 a_Color;\nlayout(location = 9) in float a_Size;\nlayout(location = 13) in vec3 a_Normal;\nlayout(location = 14) in vec3 a_uvs;\n\nlayout(std140) uniform commonUniforms {\n vec4 u_sourceColor;\n vec4 u_targetColor;\n float u_linearColor;\n float u_topsurface;\n float u_sidesurface;\n float u_heightfixed; // \u9ED8\u8BA4\u4E0D\u56FA\u5B9A\n float u_raisingHeight;\n};\n\nout vec4 v_Color;\n\n#pragma include \"projection\"\n#pragma include \"light\"\n#pragma include \"picking\"\n\nvoid main() {\n \nfloat isSide = a_Position.z;\n float topU = a_uvs[0];\n float topV = 1.0 - a_uvs[1];\n float sidey = a_uvs[2];\n\n vec4 pos = vec4(a_Position.xy, a_Position.z * a_Size, 1.0);\n float lightWeight = calc_lighting(pos);\n\n vec4 project_pos = project_position(pos);\n\n if(u_heightfixed > 0.0) { // \u5224\u65AD\u51E0\u4F55\u4F53\u662F\u5426\u56FA\u5B9A\u9AD8\u5EA6\n project_pos.z = a_Position.z * a_Size;\n project_pos.z += u_raisingHeight;\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n project_pos.z *= mapboxZoomScale;\n project_pos.z += u_raisingHeight * mapboxZoomScale;\n }\n }\n\n\n gl_Position = project_common_position_to_clipspace_v2(vec4(project_pos.xyz, 1.0));\n\n // Tip: \u90E8\u5206\u673A\u578B GPU \u8BA1\u7B97\u7CBE\u5EA6\u517C\u5BB9\n if(isSide < 0.999) {\n // side face\n // if(u_sidesurface < 1.0) {\n // discard;\n // }\n\n if(u_linearColor == 1.0) {\n vec4 linearColor = mix(u_targetColor, u_sourceColor, sidey);\n linearColor.rgb *= lightWeight;\n v_Color = linearColor;\n } else {\n v_Color = a_Color;\n }\n\n } else {\n v_Color = a_Color;\n }\n\n v_Color = vec4(v_Color.rgb * lightWeight, v_Color.w * opacity);\n\n\n setPickingColor(a_PickingColor);\n}\n"; // extrude
|
|
20
20
|
/* babel-plugin-inline-import '../shaders/extrude/polygon_extrudetex_frag.glsl' */
|
|
21
|
-
var polygonExtrudeTexFrag = "uniform sampler2D u_texture;\n\nlayout(std140) uniform commonUniforms {\n vec4 u_sourceColor;\n vec4 u_targetColor;\n float u_linearColor;\n float u_topsurface;\n float u_sidesurface;\n float u_heightfixed; // \u9ED8\u8BA4\u4E0D\u56FA\u5B9A\n float u_raisingHeight;\n};\n\nin vec4 v_Color;\nin vec3 v_uvs;\nin vec2 v_texture_data;\n\n\n#pragma include \"picking\"\n\nout vec4 outputColor;\n\nvoid main() {\n float opacity = u_opacity;\n float isSide = v_texture_data.x;\n float lightWeight = v_texture_data.y;\n float topU = v_uvs[0];\n float topV = 1.0 - v_uvs[1];\n float sidey = v_uvs[2];\n // Tip: \u90E8\u5206\u673A\u578B GPU \u8BA1\u7B97\u7CBE\u5EA6\u517C\u5BB9\n if(isSide < 0.999) {// \u662F\u5426\u662F\u8FB9\u7F18\n // side face\n if(u_sidesurface < 1.0) {\n discard;\n }\n\n if(u_linearColor == 1.0) {\n vec4 linearColor = mix(u_targetColor, u_sourceColor, sidey);\n linearColor.rgb *= lightWeight;\n outputColor = linearColor;\n } else {\n outputColor = v_Color;\n }\n } else {\n
|
|
21
|
+
var polygonExtrudeTexFrag = "uniform sampler2D u_texture;\n\nlayout(std140) uniform commonUniforms {\n vec4 u_sourceColor;\n vec4 u_targetColor;\n float u_linearColor;\n float u_topsurface;\n float u_sidesurface;\n float u_heightfixed; // \u9ED8\u8BA4\u4E0D\u56FA\u5B9A\n float u_raisingHeight;\n};\n\nin vec4 v_Color;\nin vec3 v_uvs;\nin vec2 v_texture_data;\n\n#pragma include \"scene_uniforms\"\n#pragma include \"picking\"\n\nout vec4 outputColor;\n\nvoid main() {\n float opacity = u_opacity;\n float isSide = v_texture_data.x;\n float lightWeight = v_texture_data.y;\n float topU = v_uvs[0];\n float topV = 1.0 - v_uvs[1];\n float sidey = v_uvs[2];\n\n outputColor = texture(SAMPLER_2D(u_texture), vec2(topU, topV));\n // Tip: \u90E8\u5206\u673A\u578B GPU \u8BA1\u7B97\u7CBE\u5EA6\u517C\u5BB9\n if (isSide < 0.999) {// \u662F\u5426\u662F\u8FB9\u7F18\n // side face\n if (u_sidesurface < 1.0) {\n discard;\n }\n\n if (u_linearColor == 1.0) {\n vec4 linearColor = mix(u_targetColor, u_sourceColor, sidey);\n linearColor.rgb *= lightWeight;\n outputColor = linearColor;\n } else {\n outputColor = v_Color;\n }\n } else {\n // top face\n if (u_topsurface < 1.0) {\n discard;\n }\n }\n \n outputColor.a *= opacity;\n outputColor = filterColor(outputColor);\n}\n"; // texture
|
|
22
22
|
/* babel-plugin-inline-import '../shaders/extrude/polygon_extrudetex_vert.glsl' */
|
|
23
|
-
var polygonExtrudeTexVert = "layout(location = 0) in vec3 a_Position;\nlayout(location = 1) in vec4 a_Color;\nlayout(location = 9) in float a_Size;\nlayout(location = 13) in vec3 a_Normal;\nlayout(location = 14) in vec3 a_uvs;\n\n\nlayout(std140) uniform commonUniforms {\n vec4 u_sourceColor;\n vec4 u_targetColor;\n float u_linearColor;\n float u_topsurface;\n float u_sidesurface;\n float u_heightfixed; // \u9ED8\u8BA4\u4E0D\u56FA\u5B9A\n float u_raisingHeight;\n};\n\nout vec4 v_Color;\
|
|
23
|
+
var polygonExtrudeTexVert = "layout(location = 0) in vec3 a_Position;\nlayout(location = 1) in vec4 a_Color;\nlayout(location = 9) in float a_Size;\nlayout(location = 13) in vec3 a_Normal;\nlayout(location = 14) in vec3 a_uvs;\n\n\nlayout(std140) uniform commonUniforms {\n vec4 u_sourceColor;\n vec4 u_targetColor;\n float u_linearColor;\n float u_topsurface;\n float u_sidesurface;\n float u_heightfixed; // \u9ED8\u8BA4\u4E0D\u56FA\u5B9A\n float u_raisingHeight;\n};\n\nout vec4 v_Color;\nout vec3 v_uvs;\nout vec2 v_texture_data;\n\n#pragma include \"projection\"\n#pragma include \"light\"\n#pragma include \"picking\"\n\nvoid main() {\n \n vec4 pos = vec4(a_Position.xy, a_Position.z * a_Size, 1.0);\n float lightWeight = calc_lighting(pos);\n vec4 project_pos = project_position(pos);\n v_uvs = a_uvs;\n v_Color = a_Color;\n v_Color.a *= opacity;\n \n v_texture_data = vec2(a_Position.z, lightWeight);\n\n if(u_heightfixed > 0.0) { // \u5224\u65AD\u51E0\u4F55\u4F53\u662F\u5426\u56FA\u5B9A\u9AD8\u5EA6\n project_pos.z = a_Position.z * a_Size;\n project_pos.z += u_raisingHeight;\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n project_pos.z *= mapboxZoomScale;\n project_pos.z += u_raisingHeight * mapboxZoomScale;\n }\n }\n\n\n gl_Position = project_common_position_to_clipspace_v2(vec4(project_pos.xyz, 1.0));\n\n\n\n setPickingColor(a_PickingColor);\n}\n"; // extrude picking
|
|
24
|
+
import { ShaderLocation } from "../../core/CommonStyleAttribute";
|
|
25
|
+
import { loadImage } from "../../utils/load-image";
|
|
24
26
|
/* babel-plugin-inline-import '../shaders/extrude/polygon_extrude_picklight_frag.glsl' */
|
|
25
|
-
var polygonExtrudePickLightFrag = "\nlayout(std140) uniform commonUniforms {\n vec4 u_sourceColor;\n vec4 u_targetColor;\n float u_linearColor;\n float u_topsurface;\n float u_sidesurface;\n float u_heightfixed; // \u9ED8\u8BA4\u4E0D\u56FA\u5B9A\n float u_raisingHeight;\n};\n\nin vec4 v_Color;\nin vec3 v_uvs;\nin vec2 v_texture_data;\nout vec4 outputColor;\n\n#pragma include \"picking\"\n\nvoid main() {\n float isSide = v_texture_data.x;\n float sidey = v_uvs[2];\n float lightWeight = v_texture_data.y;\n\n // Tip: \u90E8\u5206\u673A\u578B GPU \u8BA1\u7B97\u7CBE\u5EA6\u517C\u5BB9\n if(isSide < 0.999) {\n // side face\n if(u_sidesurface < 1.0) {\n discard;\n }\n \n if( u_linearColor == 1.0) {\n // side use linear\n vec4 linearColor = mix(u_targetColor, u_sourceColor, sidey);\n linearColor.rgb *= lightWeight;\n outputColor = linearColor;\n } else {\n // side notuse linear\n outputColor = v_Color;\n }\n } else {\n // top face\n if(u_topsurface < 1.0) {\n discard;\n }\n outputColor = v_Color;\n }\n\n outputColor = filterColorAlpha(outputColor, lightWeight);\n}\n";
|
|
27
|
+
var polygonExtrudePickLightFrag = "\nlayout(std140) uniform commonUniforms {\n vec4 u_sourceColor;\n vec4 u_targetColor;\n float u_linearColor;\n float u_topsurface;\n float u_sidesurface;\n float u_heightfixed; // \u9ED8\u8BA4\u4E0D\u56FA\u5B9A\n float u_raisingHeight;\n};\n\nin vec4 v_Color;\nin vec3 v_uvs;\nin vec2 v_texture_data;\nout vec4 outputColor;\n\n#pragma include \"scene_uniforms\"\n#pragma include \"picking\"\n\nvoid main() {\n float isSide = v_texture_data.x;\n float sidey = v_uvs[2];\n float lightWeight = v_texture_data.y;\n\n // Tip: \u90E8\u5206\u673A\u578B GPU \u8BA1\u7B97\u7CBE\u5EA6\u517C\u5BB9\n if(isSide < 0.999) {\n // side face\n if(u_sidesurface < 1.0) {\n discard;\n }\n \n if( u_linearColor == 1.0) {\n // side use linear\n vec4 linearColor = mix(u_targetColor, u_sourceColor, sidey);\n linearColor.rgb *= lightWeight;\n outputColor = linearColor;\n } else {\n // side notuse linear\n outputColor = v_Color;\n }\n } else {\n // top face\n if(u_topsurface < 1.0) {\n discard;\n }\n outputColor = v_Color;\n }\n\n outputColor = filterColorAlpha(outputColor, lightWeight);\n}\n";
|
|
26
28
|
/* babel-plugin-inline-import '../shaders/extrude/polygon_extrude_picklight_vert.glsl' */
|
|
27
|
-
var polygonExtrudePickLightVert = "layout(location = 0) in vec3 a_Position;\nlayout(location = 1) in vec4 a_Color;\nlayout(location = 9) in float a_Size;\nlayout(location = 13) in vec3 a_Normal;\nlayout(location = 14) in vec3 a_uvs;\n\n\nlayout(std140) uniform commonUniforms {\n vec4 u_sourceColor;\n vec4 u_targetColor;\n float u_linearColor;\n float u_topsurface;\n float u_sidesurface;\n float u_heightfixed; // \u9ED8\u8BA4\u4E0D\u56FA\u5B9A\n float u_raisingHeight;\n};\n\nout
|
|
28
|
-
import { ShaderLocation } from "../../core/CommonStyleAttribute";
|
|
29
|
+
var polygonExtrudePickLightVert = "layout(location = 0) in vec3 a_Position;\nlayout(location = 1) in vec4 a_Color;\nlayout(location = 9) in float a_Size;\nlayout(location = 13) in vec3 a_Normal;\nlayout(location = 14) in vec3 a_uvs;\n\n\nlayout(std140) uniform commonUniforms {\n vec4 u_sourceColor;\n vec4 u_targetColor;\n float u_linearColor;\n float u_topsurface;\n float u_sidesurface;\n float u_heightfixed; // \u9ED8\u8BA4\u4E0D\u56FA\u5B9A\n float u_raisingHeight;\n};\n\nout vec4 v_Color;\nout vec3 v_uvs;\nout vec2 v_texture_data;\n\n#pragma include \"projection\"\n#pragma include \"light\"\n#pragma include \"picking\"\n\nvoid main() {\n\n\n v_uvs = a_uvs;\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n vec4 pos = vec4(a_Position.xy, a_Position.z * a_Size, 1.0);\n vec4 project_pos = project_position(pos);\n\n if(u_heightfixed > 0.0) { // \u5224\u65AD\u51E0\u4F55\u4F53\u662F\u5426\u56FA\u5B9A\u9AD8\u5EA6\n project_pos.z = a_Position.z * a_Size;\n project_pos.z += u_raisingHeight;\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n project_pos.z *= mapboxZoomScale;\n project_pos.z += u_raisingHeight * mapboxZoomScale;\n }\n }\n\n gl_Position = project_common_position_to_clipspace_v2(vec4(project_pos.xyz, 1.0));\n float lightWeight = calc_lighting(pos);\n v_texture_data = vec2(a_Position.z,lightWeight);\n\n v_Color = vec4(a_Color.rgb * lightWeight, a_Color.w * opacity);\n\n setPickingColor(a_PickingColor);\n}\n";
|
|
29
30
|
var ExtrudeModel = /*#__PURE__*/function (_BaseModel) {
|
|
30
31
|
_inherits(ExtrudeModel, _BaseModel);
|
|
31
32
|
var _super = _createSuper(ExtrudeModel);
|
|
@@ -45,6 +46,7 @@ var ExtrudeModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
45
46
|
key: "getCommonUniformsInfo",
|
|
46
47
|
value: function getCommonUniformsInfo() {
|
|
47
48
|
var _ref = this.layer.getLayerConfig(),
|
|
49
|
+
mapTexture = _ref.mapTexture,
|
|
48
50
|
_ref$heightfixed = _ref.heightfixed,
|
|
49
51
|
heightfixed = _ref$heightfixed === void 0 ? false : _ref$heightfixed,
|
|
50
52
|
_ref$raisingHeight = _ref.raisingHeight,
|
|
@@ -73,12 +75,11 @@ var ExtrudeModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
73
75
|
u_topsurface: Number(topsurface),
|
|
74
76
|
u_sidesurface: Number(sidesurface),
|
|
75
77
|
u_heightfixed: Number(heightfixed),
|
|
76
|
-
u_raisingHeight: Number(raisingHeight)
|
|
77
|
-
// 渐变色支持参数
|
|
78
|
-
u_texture: this.texture // 纹理
|
|
78
|
+
u_raisingHeight: Number(raisingHeight)
|
|
79
79
|
};
|
|
80
|
-
|
|
81
|
-
|
|
80
|
+
if (mapTexture && this.texture) {
|
|
81
|
+
// @ts-ignore
|
|
82
|
+
commonOptions.u_texture = this.texture;
|
|
82
83
|
this.textures = [this.texture];
|
|
83
84
|
}
|
|
84
85
|
var commonBufferInfo = this.getUniformsBufferInfo(commonOptions);
|
|
@@ -262,44 +263,34 @@ var ExtrudeModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
262
263
|
key: "loadTexture",
|
|
263
264
|
value: function () {
|
|
264
265
|
var _loadTexture = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
265
|
-
var
|
|
266
|
-
var _ref3, mapTexture, createTexture2D;
|
|
266
|
+
var _ref3, mapTexture, createTexture2D, image;
|
|
267
267
|
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
268
268
|
while (1) switch (_context3.prev = _context3.next) {
|
|
269
269
|
case 0:
|
|
270
270
|
_ref3 = this.layer.getLayerConfig(), mapTexture = _ref3.mapTexture;
|
|
271
271
|
createTexture2D = this.rendererService.createTexture2D;
|
|
272
272
|
this.texture = createTexture2D({
|
|
273
|
-
height:
|
|
274
|
-
width:
|
|
273
|
+
height: 1,
|
|
274
|
+
width: 1
|
|
275
275
|
});
|
|
276
276
|
if (!mapTexture) {
|
|
277
|
-
_context3.next =
|
|
277
|
+
_context3.next = 8;
|
|
278
278
|
break;
|
|
279
279
|
}
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
return resolve(null);
|
|
295
|
-
// this.layerService.reRender();
|
|
296
|
-
};
|
|
297
|
-
|
|
298
|
-
image.onerror = function () {
|
|
299
|
-
reject(new Error('image load error'));
|
|
300
|
-
};
|
|
301
|
-
}));
|
|
302
|
-
case 5:
|
|
280
|
+
_context3.next = 6;
|
|
281
|
+
return loadImage(mapTexture);
|
|
282
|
+
case 6:
|
|
283
|
+
image = _context3.sent;
|
|
284
|
+
this.texture = createTexture2D({
|
|
285
|
+
data: image,
|
|
286
|
+
width: image.width,
|
|
287
|
+
height: image.height,
|
|
288
|
+
wrapS: gl.CLAMP_TO_EDGE,
|
|
289
|
+
wrapT: gl.CLAMP_TO_EDGE,
|
|
290
|
+
min: gl.LINEAR,
|
|
291
|
+
mag: gl.LINEAR
|
|
292
|
+
});
|
|
293
|
+
case 8:
|
|
303
294
|
case "end":
|
|
304
295
|
return _context3.stop();
|
|
305
296
|
}
|
|
@@ -12,7 +12,7 @@ import { AttributeType, gl } from '@antv/l7-core';
|
|
|
12
12
|
import BaseModel from "../../core/BaseModel";
|
|
13
13
|
import { PolygonExtrudeTriangulation } from "../../core/triangulation";
|
|
14
14
|
/* babel-plugin-inline-import '../shaders/extrusion/polygon_extrusion_frag.glsl' */
|
|
15
|
-
var polygonExtrudeFrag = "\nin vec4 v_Color;\n#pragma include \"picking\"\nout vec4 outputColor;\nvoid main() {\n\n outputColor = v_Color;\n outputColor = filterColor(outputColor);\n}\n";
|
|
15
|
+
var polygonExtrudeFrag = "\nin vec4 v_Color;\n#pragma include \"scene_uniforms\"\n#pragma include \"picking\"\nout vec4 outputColor;\nvoid main() {\n\n outputColor = v_Color;\n outputColor = filterColor(outputColor);\n}\n";
|
|
16
16
|
/* babel-plugin-inline-import '../shaders/extrusion/polygon_extrusion_vert.glsl' */
|
|
17
17
|
var polygonExtrudeVert = "layout(location = 0) in vec3 a_Position;\nlayout(location = 1) in vec4 a_Color;\nlayout(location = 9) in float a_Size;\nlayout(location = 13) in vec3 a_Normal;\n\nout vec4 v_Color;\n\n#pragma include \"projection\"\n#pragma include \"light\"\n#pragma include \"picking\"\n\nvoid main() {\n \n vec4 pos = vec4(a_Position.xy, a_Position.z * a_Size + (1.0 - a_Position.z) * extrusionBase, 1.0);\n\n vec4 project_pos = project_position(pos);\n float lightWeight = calc_lighting(project_pos);\n v_Color = a_Color;\n v_Color = vec4(v_Color.rgb * lightWeight, v_Color.w * opacity);\n\n gl_Position = project_common_position_to_clipspace_v2(vec4(project_pos.xyz, 1.0));\n\n setPickingColor(a_PickingColor);\n}\n";
|
|
18
18
|
import { ShaderLocation } from "../../core/CommonStyleAttribute";
|
|
@@ -13,11 +13,11 @@ import { polygonFillTriangulation } from '@antv/l7-utils';
|
|
|
13
13
|
import BaseModel from "../../core/BaseModel";
|
|
14
14
|
import { polygonTriangulationWithCenter } from "../../core/triangulation";
|
|
15
15
|
/* babel-plugin-inline-import '../shaders/fill/fill_frag.glsl' */
|
|
16
|
-
var polygon_frag = "in vec4 v_color;\n#pragma include \"picking\"\nout vec4 outputColor;\nvoid main() {\n outputColor = v_color;\n outputColor = filterColor(outputColor);\n}\n";
|
|
16
|
+
var polygon_frag = "in vec4 v_color;\n#pragma include \"scene_uniforms\"\n#pragma include \"picking\"\nout vec4 outputColor;\nvoid main() {\n outputColor = v_color;\n outputColor = filterColor(outputColor);\n}\n";
|
|
17
17
|
/* babel-plugin-inline-import '../shaders/fill/fill_linear_frag.glsl' */
|
|
18
|
-
var polygon_linear_frag = "\nlayout(std140) uniform commonUniforms {\n float u_raisingHeight;\n float u_opacitylinear;\n float u_dir;\n};\n\nin vec3 v_linear;\nin vec2 v_pos;\
|
|
18
|
+
var polygon_linear_frag = "\nlayout(std140) uniform commonUniforms {\n float u_raisingHeight;\n float u_opacitylinear;\n float u_dir;\n};\n\nin vec4 v_color;\nin vec3 v_linear;\nin vec2 v_pos;\nout vec4 outputColor;\n#pragma include \"scene_uniforms\"\n#pragma include \"picking\"\n\nvoid main() {\n outputColor = v_color;\n if (u_opacitylinear > 0.0) {\n outputColor.a *= u_dir == 1.0 ? 1.0 - length(v_pos - v_linear.xy)/v_linear.z : length(v_pos - v_linear.xy)/v_linear.z;\n }\n outputColor = filterColor(outputColor);\n}\n";
|
|
19
19
|
/* babel-plugin-inline-import '../shaders/fill/fill_linear_vert.glsl' */
|
|
20
|
-
var polygon_linear_vert = "layout(location = 0) in vec3 a_Position;\nlayout(location = 1) in vec4 a_Color;\nlayout(location = 15) in vec3 a_linear;\n\
|
|
20
|
+
var polygon_linear_vert = "layout(location = 0) in vec3 a_Position;\nlayout(location = 1) in vec4 a_Color;\nlayout(location = 15) in vec3 a_linear;\n\nlayout(std140) uniform commonUniforms {\n float u_raisingHeight;\n float u_opacitylinear;\n float u_dir;\n};\n\nout vec4 v_color;\nout vec3 v_linear;\nout vec2 v_pos;\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvoid main() {\n if (u_opacitylinear > 0.0) {\n v_linear = a_linear;\n v_pos = a_Position.xy;\n }\n v_color = vec4(a_Color.xyz, a_Color.w * opacity);\n vec4 project_pos = project_position(vec4(a_Position, 1.0));\n project_pos.z += u_raisingHeight;\n\n if (u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n project_pos.z *= mapboxZoomScale;\n project_pos.z += u_raisingHeight * mapboxZoomScale;\n }\n\n gl_Position = project_common_position_to_clipspace_v2(vec4(project_pos.xyz, 1.0));\n setPickingColor(a_PickingColor);\n}";
|
|
21
21
|
/* babel-plugin-inline-import '../shaders/fill/fill_vert.glsl' */
|
|
22
22
|
var polygon_vert = "layout(location = 0) in vec3 a_Position;\nlayout(location = 1) in vec4 a_Color;\n\nlayout(std140) uniform commonUniforms {\n float u_raisingHeight;\n};\n\n\nout vec4 v_color;\n\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvoid main() {\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n\n v_color = vec4(a_Color.xyz, a_Color.w * opacity);\n vec4 project_pos = project_position(vec4(a_Position, 1.0));\n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n\n project_pos.z += u_raisingHeight;\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n project_pos.z *= mapboxZoomScale;\n project_pos.z += u_raisingHeight * mapboxZoomScale;\n }\n\n \n gl_Position = project_common_position_to_clipspace_v2(vec4(project_pos.xyz, 1.0));\n\n setPickingColor(a_PickingColor);\n}\n\n";
|
|
23
23
|
import { ShaderLocation } from "../../core/CommonStyleAttribute";
|
|
@@ -12,12 +12,12 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
|
|
|
12
12
|
import { AttributeType, gl } from '@antv/l7-core';
|
|
13
13
|
import { lodashUtil } from '@antv/l7-utils';
|
|
14
14
|
import BaseModel from "../../core/BaseModel";
|
|
15
|
+
import { ShaderLocation } from "../../core/CommonStyleAttribute";
|
|
15
16
|
import { polygonTriangulation } from "../../core/triangulation";
|
|
16
17
|
/* babel-plugin-inline-import '../shaders/water/polygon_water_frag.glsl' */
|
|
17
18
|
var water_frag = "uniform sampler2D u_texture;\nlayout(std140) uniform commonUniforms {\n float u_speed;\n float u_time;\n};\n\nout vec4 outputColor;\n\n\nin vec4 v_Color;\nin vec2 v_uv;\n\nfloat rand(vec2 n) { return 0.5 + 0.5 * fract(sin(dot(n.xy, vec2(12.9898, 78.233)))* 43758.5453); }\n\nfloat water(vec3 p) {\n float t = u_time * u_speed;\n p.z += t * 2.; p.x += t * 2.;\n vec3 c1 = texture(SAMPLER_2D(u_texture), p.xz / 30.).xyz;\n p.z += t * 3.; p.x += t * 0.52;\n vec3 c2 = texture(SAMPLER_2D(u_texture), p.xz / 30.).xyz;\n p.z += t * 4.; p.x += t * 0.8;\n vec3 c3 = texture(SAMPLER_2D(u_texture), p.xz / 30.).xyz;\n c1 += c2 - c3;\n float z = (c1.x + c1.y + c1.z) / 3.;\n return p.y + z / 4.;\n}\n\nfloat map(vec3 p) {\n float d = 100.0;\n d = water(p);\n return d;\n}\n\nfloat intersect(vec3 ro, vec3 rd) {\n float d = 0.0;\n for (int i = 0; i <= 100; i++) {\n float h = map(ro + rd * d);\n if (h < 0.1) return d;\n d += h;\n }\n return 0.0;\n}\n\nvec3 norm(vec3 p) {\n float eps = .1;\n return normalize(vec3(\n map(p + vec3(eps, 0, 0)) - map(p + vec3(-eps, 0, 0)),\n map(p + vec3(0, eps, 0)) - map(p + vec3(0, -eps, 0)),\n map(p + vec3(0, 0, eps)) - map(p + vec3(0, 0, -eps))\n ));\n} \n\nfloat calSpc() {\n vec3 l1 = normalize(vec3(1, 1, 1));\n vec3 ro = vec3(-3, 20, -8);\n vec3 rc = vec3(0, 0, 0);\n vec3 ww = normalize(rc - ro);\n vec3 uu = normalize(cross(vec3(0,1,0), ww));\n vec3 vv = normalize(cross(rc - ro, uu));\n vec3 rd = normalize(uu * v_uv.x + vv * v_uv.y + ww);\n float d = intersect(ro, rd);\n vec3 p = ro + rd * d;\n vec3 n = norm(p);\n float spc = pow(max(0.0, dot(reflect(l1, n), rd)), 30.0);\n return spc;\n}\n\nvoid main() {\n\n outputColor = v_Color;\n float spc = calSpc();\n outputColor += spc * 0.4;\n}\n";
|
|
18
19
|
/* babel-plugin-inline-import '../shaders/water/polygon_water_vert.glsl' */
|
|
19
20
|
var water_vert = "layout(location = 0) in vec3 a_Position;\nlayout(location = 1) in vec4 a_Color;\nlayout(location = 14) in vec2 a_uv;\nlayout(std140) uniform commonUniforms {\n float u_speed;\n float u_time;\n};\nout vec4 v_Color;\nout vec2 v_uv;\n\n\n#pragma include \"projection\"\n\nvoid main() {\n v_uv = a_uv;\n v_Color = a_Color;\n v_Color.a *= opacity;\n vec4 project_pos = project_position(vec4(a_Position, 1.0));\n\n gl_Position = project_common_position_to_clipspace_v2(vec4(project_pos.xyz, 1.0));\n}\n\n";
|
|
20
|
-
import { ShaderLocation } from "../../core/CommonStyleAttribute";
|
|
21
21
|
var isNumber = lodashUtil.isNumber;
|
|
22
22
|
var WaterModel = /*#__PURE__*/function (_BaseModel) {
|
|
23
23
|
_inherits(WaterModel, _BaseModel);
|
|
@@ -97,7 +97,9 @@ var WaterModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
97
97
|
primitive: gl.TRIANGLES,
|
|
98
98
|
depth: {
|
|
99
99
|
enable: false
|
|
100
|
-
}
|
|
100
|
+
},
|
|
101
|
+
pickingEnabled: false,
|
|
102
|
+
diagnosticDerivativeUniformityEnabled: false
|
|
101
103
|
});
|
|
102
104
|
case 3:
|
|
103
105
|
model = _context2.sent;
|
|
@@ -161,8 +163,8 @@ var WaterModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
161
163
|
waterTexture = _ref2.waterTexture;
|
|
162
164
|
var createTexture2D = this.rendererService.createTexture2D;
|
|
163
165
|
this.texture = createTexture2D({
|
|
164
|
-
height:
|
|
165
|
-
width:
|
|
166
|
+
height: 1,
|
|
167
|
+
width: 1
|
|
166
168
|
});
|
|
167
169
|
var image = new Image();
|
|
168
170
|
image.crossOrigin = '';
|
|
@@ -15,10 +15,9 @@ layout(std140) uniform commonUniforms {
|
|
|
15
15
|
float u_raisingHeight;
|
|
16
16
|
};
|
|
17
17
|
|
|
18
|
-
out vec2 v_texture_data;
|
|
19
|
-
out vec3 v_uvs;
|
|
20
18
|
out vec4 v_Color;
|
|
21
|
-
|
|
19
|
+
out vec3 v_uvs;
|
|
20
|
+
out vec2 v_texture_data;
|
|
22
21
|
|
|
23
22
|
#pragma include "projection"
|
|
24
23
|
#pragma include "light"
|
|
@@ -14,7 +14,7 @@ in vec4 v_Color;
|
|
|
14
14
|
in vec3 v_uvs;
|
|
15
15
|
in vec2 v_texture_data;
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
#pragma include "scene_uniforms"
|
|
18
18
|
#pragma include "picking"
|
|
19
19
|
|
|
20
20
|
out vec4 outputColor;
|
|
@@ -26,14 +26,16 @@ void main() {
|
|
|
26
26
|
float topU = v_uvs[0];
|
|
27
27
|
float topV = 1.0 - v_uvs[1];
|
|
28
28
|
float sidey = v_uvs[2];
|
|
29
|
+
|
|
30
|
+
outputColor = texture(SAMPLER_2D(u_texture), vec2(topU, topV));
|
|
29
31
|
// Tip: 部分机型 GPU 计算精度兼容
|
|
30
|
-
if(isSide < 0.999) {// 是否是边缘
|
|
32
|
+
if (isSide < 0.999) {// 是否是边缘
|
|
31
33
|
// side face
|
|
32
|
-
if(u_sidesurface < 1.0) {
|
|
34
|
+
if (u_sidesurface < 1.0) {
|
|
33
35
|
discard;
|
|
34
36
|
}
|
|
35
37
|
|
|
36
|
-
if(u_linearColor == 1.0) {
|
|
38
|
+
if (u_linearColor == 1.0) {
|
|
37
39
|
vec4 linearColor = mix(u_targetColor, u_sourceColor, sidey);
|
|
38
40
|
linearColor.rgb *= lightWeight;
|
|
39
41
|
outputColor = linearColor;
|
|
@@ -41,16 +43,12 @@ void main() {
|
|
|
41
43
|
outputColor = v_Color;
|
|
42
44
|
}
|
|
43
45
|
} else {
|
|
44
|
-
|
|
45
46
|
// top face
|
|
46
|
-
if(u_topsurface < 1.0) {
|
|
47
|
+
if (u_topsurface < 1.0) {
|
|
47
48
|
discard;
|
|
48
49
|
}
|
|
49
|
-
|
|
50
|
-
outputColor = texture(SAMPLER_2D(u_texture), vec2(topU, topV));
|
|
51
50
|
}
|
|
52
51
|
|
|
53
|
-
|
|
54
52
|
outputColor.a *= opacity;
|
|
55
53
|
outputColor = filterColor(outputColor);
|
|
56
54
|
}
|
|
@@ -5,15 +5,16 @@ layout(std140) uniform commonUniforms {
|
|
|
5
5
|
float u_dir;
|
|
6
6
|
};
|
|
7
7
|
|
|
8
|
+
in vec4 v_color;
|
|
8
9
|
in vec3 v_linear;
|
|
9
10
|
in vec2 v_pos;
|
|
10
|
-
in vec4 v_color;
|
|
11
11
|
out vec4 outputColor;
|
|
12
|
+
#pragma include "scene_uniforms"
|
|
12
13
|
#pragma include "picking"
|
|
13
14
|
|
|
14
15
|
void main() {
|
|
15
|
-
|
|
16
|
-
if(u_opacitylinear > 0.0) {
|
|
16
|
+
outputColor = v_color;
|
|
17
|
+
if (u_opacitylinear > 0.0) {
|
|
17
18
|
outputColor.a *= u_dir == 1.0 ? 1.0 - length(v_pos - v_linear.xy)/v_linear.z : length(v_pos - v_linear.xy)/v_linear.z;
|
|
18
19
|
}
|
|
19
20
|
outputColor = filterColor(outputColor);
|