@antv/l7-layers 2.22.4 → 2.22.6
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 +19 -0
- package/es/core/BaseLayer.js +56 -0
- package/es/core/interface.d.ts +4 -3
- package/es/earth/models/atmosphere.js +1 -1
- package/es/earth/models/base.js +1 -1
- package/es/earth/models/bloomsphere.js +1 -1
- package/es/earth/shaders/atmosphere/atmosphere_frag.glsl +6 -9
- package/es/earth/shaders/base/base_frag.glsl +3 -3
- package/es/earth/shaders/bloomshpere/bloomsphere_frag.glsl +5 -6
- package/es/geometry/models/billboard.js +1 -1
- package/es/geometry/models/sprite.js +1 -1
- package/es/geometry/shaders/billboard_frag.glsl +4 -4
- package/es/geometry/shaders/sprite_frag.glsl +2 -4
- package/es/heatmap/models/heatmap.js +3 -3
- package/es/heatmap/shaders/heatmap/heatmap_3d_frag.glsl +6 -7
- package/es/heatmap/shaders/heatmap/heatmap_frag.glsl +24 -36
- package/es/heatmap/shaders/heatmap/heatmap_framebuffer_frag.glsl +5 -5
- package/es/line/models/flow.js +1 -1
- package/es/line/shaders/flow/flow_line_frag.glsl +0 -1
- package/es/plugins/LayerMaskPlugin.js +1 -1
- package/es/plugins/ShaderUniformPlugin.js +26 -8
- package/es/point/models/billboard_point.js +1 -1
- package/es/point/models/extrude.js +1 -1
- package/es/point/models/fill.js +1 -1
- package/es/point/models/image.js +1 -1
- package/es/point/models/normal.js +1 -1
- package/es/point/shaders/billboard/billboard_point_frag.glsl +6 -8
- package/es/point/shaders/extrude/extrude_frag.glsl +1 -3
- package/es/point/shaders/fill/fill_frag.glsl +14 -17
- package/es/point/shaders/image/image_frag.glsl +15 -12
- package/es/point/shaders/normal/normal_frag.glsl +1 -1
- package/es/polygon/models/extrude.js +3 -3
- package/es/polygon/models/extrusion.js +1 -1
- package/es/polygon/models/fill.js +1 -1
- package/es/polygon/models/ocean.js +1 -1
- package/es/polygon/models/water.js +1 -1
- package/es/polygon/shaders/extrude/polygon_extrude_frag.glsl +5 -6
- package/es/polygon/shaders/extrude/polygon_extrude_picklight_frag.glsl +7 -8
- package/es/polygon/shaders/extrude/polygon_extrudetex_frag.glsl +4 -3
- package/es/polygon/shaders/extrusion/polygon_extrusion_frag.glsl +0 -2
- package/es/polygon/shaders/fill/fill_linear_frag.glsl +4 -2
- package/es/polygon/shaders/ocean/ocean_frag.glsl +212 -182
- package/es/polygon/shaders/water/polygon_water_frag.glsl +25 -20
- package/es/raster/index.js +2 -1
- package/es/raster/models/raster.js +1 -1
- package/es/raster/models/rasterRgb.js +1 -1
- package/es/raster/models/rasterTerrainRgb.js +1 -1
- package/es/raster/shaders/raster/raster_2d_frag.glsl +10 -7
- package/es/raster/shaders/rgb/raster_rgb_frag.glsl +16 -13
- package/es/raster/shaders/terrain/terrain_rgb_frag.glsl +18 -21
- package/lib/core/BaseLayer.d.ts +19 -0
- package/lib/core/BaseLayer.js +56 -0
- package/lib/core/interface.d.ts +4 -3
- package/lib/earth/models/atmosphere.js +1 -1
- package/lib/earth/models/base.js +1 -1
- package/lib/earth/models/bloomsphere.js +1 -1
- package/lib/earth/shaders/atmosphere/atmosphere_frag.glsl +6 -9
- package/lib/earth/shaders/base/base_frag.glsl +3 -3
- package/lib/earth/shaders/bloomshpere/bloomsphere_frag.glsl +5 -6
- package/lib/geometry/models/billboard.js +1 -1
- package/lib/geometry/models/sprite.js +1 -1
- package/lib/geometry/shaders/billboard_frag.glsl +4 -4
- package/lib/geometry/shaders/sprite_frag.glsl +2 -4
- package/lib/heatmap/models/heatmap.js +3 -3
- package/lib/heatmap/shaders/heatmap/heatmap_3d_frag.glsl +6 -7
- package/lib/heatmap/shaders/heatmap/heatmap_frag.glsl +24 -36
- package/lib/heatmap/shaders/heatmap/heatmap_framebuffer_frag.glsl +5 -5
- package/lib/line/models/flow.js +1 -1
- package/lib/line/shaders/flow/flow_line_frag.glsl +0 -1
- package/lib/plugins/LayerMaskPlugin.js +1 -1
- package/lib/plugins/ShaderUniformPlugin.js +26 -8
- package/lib/point/models/billboard_point.js +1 -1
- package/lib/point/models/extrude.js +1 -1
- package/lib/point/models/fill.js +1 -1
- package/lib/point/models/image.js +1 -1
- package/lib/point/models/normal.js +1 -1
- package/lib/point/shaders/billboard/billboard_point_frag.glsl +6 -8
- package/lib/point/shaders/extrude/extrude_frag.glsl +1 -3
- package/lib/point/shaders/fill/fill_frag.glsl +14 -17
- package/lib/point/shaders/image/image_frag.glsl +15 -12
- package/lib/point/shaders/normal/normal_frag.glsl +1 -1
- package/lib/polygon/models/extrude.js +3 -3
- package/lib/polygon/models/extrusion.js +1 -1
- package/lib/polygon/models/fill.js +1 -1
- package/lib/polygon/models/ocean.js +1 -1
- package/lib/polygon/models/water.js +1 -1
- package/lib/polygon/shaders/extrude/polygon_extrude_frag.glsl +5 -6
- package/lib/polygon/shaders/extrude/polygon_extrude_picklight_frag.glsl +7 -8
- package/lib/polygon/shaders/extrude/polygon_extrudetex_frag.glsl +4 -3
- package/lib/polygon/shaders/extrusion/polygon_extrusion_frag.glsl +0 -2
- package/lib/polygon/shaders/fill/fill_linear_frag.glsl +4 -2
- package/lib/polygon/shaders/ocean/ocean_frag.glsl +212 -182
- package/lib/polygon/shaders/water/polygon_water_frag.glsl +25 -20
- package/lib/raster/index.js +2 -1
- package/lib/raster/models/raster.js +1 -1
- package/lib/raster/models/rasterRgb.js +1 -1
- package/lib/raster/models/rasterTerrainRgb.js +1 -1
- package/lib/raster/shaders/raster/raster_2d_frag.glsl +10 -7
- package/lib/raster/shaders/rgb/raster_rgb_frag.glsl +16 -13
- package/lib/raster/shaders/terrain/terrain_rgb_frag.glsl +18 -21
- package/package.json +6 -6
package/es/point/models/fill.js
CHANGED
|
@@ -3,7 +3,7 @@ import { AttributeType, gl } from '@antv/l7-core';
|
|
|
3
3
|
import BaseModel from "../../core/BaseModel";
|
|
4
4
|
import { PointFillTriangulation } from "../../core/triangulation";
|
|
5
5
|
/* babel-plugin-inline-import '../shaders/fill/fill_frag.glsl' */
|
|
6
|
-
const pointFillFrag = "
|
|
6
|
+
const pointFillFrag = "layout(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.0));\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(antialiasblur, 0.0, inner_df);\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 =\n clamp(cos(d * PI), 0.0, 1.0) *\n 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";
|
|
7
7
|
/* babel-plugin-inline-import '../shaders/fill/fill_vert.glsl' */
|
|
8
8
|
const pointFillVert = "layout(location = ATTRIBUTE_LOCATION_POSITION) in vec3 a_Position;\nlayout(location = ATTRIBUTE_LOCATION_POSITION_64LOW) in vec2 a_Position64Low;\nlayout(location = ATTRIBUTE_LOCATION_COLOR) in vec4 a_Color;\nlayout(location = ATTRIBUTE_LOCATION_SIZE) in float a_Size;\nlayout(location = ATTRIBUTE_LOCATION_SHAPE) in float a_Shape;\nlayout(location = ATTRIBUTE_LOCATION_EXTRUDE) 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\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 vec4 project_pos = project_position(vec4(a_Position.xy, 0.0, 1.0), a_Position64Low);\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(vec4(project_pos.xy + offset, raisingHeight, 1.0));\n\n setPickingColor(a_PickingColor);\n}\n";
|
|
9
9
|
import { SizeUnitType } from "../../core/interface";
|
package/es/point/models/image.js
CHANGED
|
@@ -5,7 +5,7 @@ import { AttributeType, gl } from '@antv/l7-core';
|
|
|
5
5
|
import BaseModel from "../../core/BaseModel";
|
|
6
6
|
import { PointImageTriangulation } from "../../core/triangulation";
|
|
7
7
|
/* babel-plugin-inline-import '../shaders/image/image_frag.glsl' */
|
|
8
|
-
const pointImageFrag = "layout(std140) uniform commonUniforms {\n vec2 u_textSize;\n float u_raisingHeight;\n float u_heightfixed;\n};\n\nuniform sampler2D u_texture;\n\nin vec4 v_color;\nin vec2 v_uv;\nin float v_opacity;\n\n#pragma include \"picking\"\n\nout vec4 outputColor;\n\nvoid main(){\n vec2 pos = v_uv / u_textSize + gl_PointCoord / u_textSize * 64
|
|
8
|
+
const pointImageFrag = "layout(std140) uniform commonUniforms {\n vec2 u_textSize;\n float u_raisingHeight;\n float u_heightfixed;\n};\n\nuniform sampler2D u_texture;\n\nin vec4 v_color;\nin vec2 v_uv;\nin float v_opacity;\n\n#pragma include \"picking\"\n\nout vec4 outputColor;\n\nvoid main() {\n vec2 pos = v_uv / u_textSize + gl_PointCoord / u_textSize * 64.0;\n vec4 textureColor;\n\n // Y = 0.299R + 0.587G + 0.114B // \u4EAE\u5EA6\u63D0\u53D6\n\n textureColor = texture(SAMPLER_2D(u_texture), pos);\n\n // Tip: \u53BB\u9664\u8FB9\u7F18\u90E8\u5206 mipmap \u5BFC\u81F4\u7684\u6DF7\u5408\u53D8\u6697\n float fragmengTocenter = distance(vec2(0.5), gl_PointCoord);\n if (fragmengTocenter >= 0.5) {\n float luma = 0.299 * textureColor.r + 0.587 * textureColor.g + 0.114 * textureColor.b;\n textureColor.a *= luma;\n }\n\n if (\n all(lessThan(v_color, vec4(1.0 + 0.00001))) && all(greaterThan(v_color, vec4(1.0 - 0.00001))) ||\n v_color == vec4(1.0)\n ) {\n outputColor = textureColor;\n } else {\n outputColor = step(0.01, textureColor.z) * v_color;\n }\n outputColor.a *= v_opacity;\n if (outputColor.a < 0.01) {\n discard;\n }\n outputColor = filterColor(outputColor);\n}\n";
|
|
9
9
|
/* babel-plugin-inline-import '../shaders/image/image_vert.glsl' */
|
|
10
10
|
const pointImageVert = "layout(location = ATTRIBUTE_LOCATION_POSITION) in vec3 a_Position;\nlayout(location = ATTRIBUTE_LOCATION_POSITION_64LOW) in vec2 a_Position64Low;\nlayout(location = ATTRIBUTE_LOCATION_COLOR) in vec4 a_Color;\nlayout(location = ATTRIBUTE_LOCATION_SIZE) in float a_Size;\nlayout(location = ATTRIBUTE_LOCATION_UV) in vec2 a_Uv;\n\nlayout(std140) uniform commonUniforms {\n vec2 u_textSize;\n float u_raisingHeight;\n float u_heightfixed;\n};\n\nout vec4 v_color;\nout vec2 v_uv;\nout float v_opacity;\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 v_color = a_Color;\n v_opacity = opacity;\n v_uv = a_Uv;\n vec4 project_pos = project_position(vec4(a_Position, 1.0), a_Position64Low);\n\n vec2 offset = project_pixel(offsets);\n\n float raisingHeight = u_raisingHeight;\n if (u_heightfixed < 1.0) {\n // false\n raisingHeight = project_pixel(u_raisingHeight);\n } else {\n if (\n u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT ||\n u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET\n ) {\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(vec4(project_pos.xy + offset, raisingHeight, 1.0));\n\n gl_PointSize = a_Size * 2.0 * u_DevicePixelRatio;\n setPickingColor(a_PickingColor);\n}\n";
|
|
11
11
|
export default class ImageModel extends BaseModel {
|
|
@@ -2,7 +2,7 @@ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
|
2
2
|
import { AttributeType, gl } from '@antv/l7-core';
|
|
3
3
|
import BaseModel from "../../core/BaseModel";
|
|
4
4
|
/* babel-plugin-inline-import '../shaders/normal/normal_frag.glsl' */
|
|
5
|
-
const normalFrag = "in vec4 v_color;\nout vec4 outputColor;\nvoid main() {\n outputColor = v_color;\n}";
|
|
5
|
+
const normalFrag = "in vec4 v_color;\nout vec4 outputColor;\nvoid main() {\n outputColor = v_color;\n}\n";
|
|
6
6
|
/* babel-plugin-inline-import '../shaders/normal/normal_vert.glsl' */
|
|
7
7
|
const normalVert = "layout(location = ATTRIBUTE_LOCATION_POSITION) in vec3 a_Position;\nlayout(location = ATTRIBUTE_LOCATION_POSITION_64LOW) in vec2 a_Position64Low;\nlayout(location = ATTRIBUTE_LOCATION_COLOR) in vec4 a_Color;\nlayout(location = ATTRIBUTE_LOCATION_SIZE) in float a_Size;\n\nlayout(std140) uniform u_Common {\n float u_size_scale;\n};\n\nout vec4 v_color;\n\n#pragma include \"projection\"\n#pragma include \"project\"\n\nvoid main() {\n v_color = vec4(a_Color.xyz, a_Color.w * opacity);\n\n vec4 project_pos = project_position(vec4(a_Position, 1.0), a_Position64Low);\n gl_Position = project_common_position_to_clipspace(project_pos);\n\n gl_PointSize = a_Size * u_size_scale * 2.0 * u_DevicePixelRatio;\n}\n";
|
|
8
8
|
export function PointTriangulation(feature) {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
layout(std140) uniform commonUniorm {
|
|
3
2
|
vec4 u_stroke_color;
|
|
4
3
|
float u_additive;
|
|
@@ -21,14 +20,13 @@ void main() {
|
|
|
21
20
|
// Tip: 片元的剪切成圆形
|
|
22
21
|
float circleClipOpacity = 1.0 - smoothstep(v_blur, 1.0, fragmengTocenter);
|
|
23
22
|
|
|
24
|
-
|
|
25
|
-
if(v_innerRadius < 0.99) {
|
|
23
|
+
if (v_innerRadius < 0.99) {
|
|
26
24
|
// 当存在 stroke 且 stroke > 0.01
|
|
27
|
-
float blurWidth = (1.0 - v_blur)/2.0;
|
|
25
|
+
float blurWidth = (1.0 - v_blur) / 2.0;
|
|
28
26
|
vec4 stroke = vec4(u_stroke_color.rgb, u_stroke_opacity);
|
|
29
|
-
if(fragmengTocenter > v_innerRadius + blurWidth) {
|
|
27
|
+
if (fragmengTocenter > v_innerRadius + blurWidth) {
|
|
30
28
|
outputColor = stroke;
|
|
31
|
-
} else if(fragmengTocenter > v_innerRadius - blurWidth){
|
|
29
|
+
} else if (fragmengTocenter > v_innerRadius - blurWidth) {
|
|
32
30
|
float mixR = (fragmengTocenter - (v_innerRadius - blurWidth)) / (blurWidth * 2.0);
|
|
33
31
|
outputColor = mix(v_color, stroke, mixR);
|
|
34
32
|
} else {
|
|
@@ -40,8 +38,8 @@ void main() {
|
|
|
40
38
|
}
|
|
41
39
|
|
|
42
40
|
outputColor = filterColor(outputColor);
|
|
43
|
-
|
|
44
|
-
if(u_additive > 0.0) {
|
|
41
|
+
|
|
42
|
+
if (u_additive > 0.0) {
|
|
45
43
|
outputColor *= circleClipOpacity;
|
|
46
44
|
} else {
|
|
47
45
|
outputColor.a *= circleClipOpacity;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
in vec4 v_color;
|
|
3
2
|
in float v_lightWeight;
|
|
4
3
|
out vec4 outputColor;
|
|
@@ -19,11 +18,10 @@ layout(std140) uniform commonUniforms {
|
|
|
19
18
|
#pragma include "picking"
|
|
20
19
|
|
|
21
20
|
void main() {
|
|
22
|
-
|
|
23
21
|
outputColor = v_color;
|
|
24
22
|
// 开启透明度渐变
|
|
25
23
|
// picking
|
|
26
|
-
if(u_pickLight > 0.0) {
|
|
24
|
+
if (u_pickLight > 0.0) {
|
|
27
25
|
outputColor = filterColorAlpha(outputColor, v_lightWeight);
|
|
28
26
|
} else {
|
|
29
27
|
outputColor = filterColor(outputColor);
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
layout(std140) uniform commonUniforms {
|
|
3
2
|
vec3 u_blur_height_fixed;
|
|
4
3
|
float u_stroke_width;
|
|
@@ -35,7 +34,7 @@ void main() {
|
|
|
35
34
|
outer_df = sdEquilateralTriangle(1.1 * v_data.xy);
|
|
36
35
|
inner_df = sdEquilateralTriangle(1.1 / r * v_data.xy);
|
|
37
36
|
} else if (shape == 2) {
|
|
38
|
-
outer_df = sdBox(v_data.xy, vec2(1.));
|
|
37
|
+
outer_df = sdBox(v_data.xy, vec2(1.0));
|
|
39
38
|
inner_df = sdBox(v_data.xy, vec2(r));
|
|
40
39
|
} else if (shape == 3) {
|
|
41
40
|
outer_df = sdPentagon(v_data.xy, 0.8);
|
|
@@ -59,42 +58,40 @@ void main() {
|
|
|
59
58
|
|
|
60
59
|
float opacity_t = smoothstep(0.0, antialiasblur, outer_df);
|
|
61
60
|
|
|
62
|
-
float color_t = u_stroke_width < 0.01 ? 0.0 : smoothstep(
|
|
63
|
-
antialiasblur,
|
|
64
|
-
0.0,
|
|
65
|
-
inner_df
|
|
66
|
-
);
|
|
61
|
+
float color_t = u_stroke_width < 0.01 ? 0.0 : smoothstep(antialiasblur, 0.0, inner_df);
|
|
67
62
|
|
|
68
63
|
float PI = 3.14159;
|
|
69
64
|
float N_RINGS = 3.0;
|
|
70
65
|
float FREQ = 1.0;
|
|
71
66
|
|
|
72
|
-
if(u_stroke_width < 0.01) {
|
|
67
|
+
if (u_stroke_width < 0.01) {
|
|
73
68
|
outputColor = v_color;
|
|
74
69
|
} else {
|
|
75
70
|
outputColor = mix(v_color, v_stroke * u_stroke_opacity, color_t);
|
|
76
71
|
}
|
|
77
72
|
float intensity = 1.0;
|
|
78
|
-
if(u_time
|
|
73
|
+
if (u_time != -1.0) {
|
|
79
74
|
//wave相关逻辑
|
|
80
75
|
float d = length(v_data.xy);
|
|
81
|
-
if(d > 0.5) {
|
|
76
|
+
if (d > 0.5) {
|
|
82
77
|
discard;
|
|
83
78
|
}
|
|
84
|
-
intensity =
|
|
79
|
+
intensity =
|
|
80
|
+
clamp(cos(d * PI), 0.0, 1.0) *
|
|
81
|
+
clamp(cos(2.0 * PI * (d * 2.0 * u_animate.z - u_animate.y * u_time)), 0.0, 1.0);
|
|
85
82
|
}
|
|
86
83
|
|
|
87
|
-
if(u_additive > 0.0) {
|
|
84
|
+
if (u_additive > 0.0) {
|
|
88
85
|
outputColor *= opacity_t;
|
|
89
|
-
outputColor *= intensity
|
|
86
|
+
outputColor *= intensity; //wave
|
|
90
87
|
outputColor = filterColorAlpha(outputColor, outputColor.a);
|
|
91
88
|
} else {
|
|
92
89
|
outputColor.a *= opacity_t;
|
|
93
|
-
outputColor.a *= intensity
|
|
90
|
+
outputColor.a *= intensity; //wave
|
|
94
91
|
outputColor = filterColor(outputColor);
|
|
95
92
|
}
|
|
96
|
-
|
|
97
|
-
if(outputColor.a < 0.01) {
|
|
93
|
+
// 作为 mask 模板时需要丢弃透明的像素
|
|
94
|
+
if (outputColor.a < 0.01) {
|
|
98
95
|
discard;
|
|
99
|
-
}
|
|
96
|
+
}
|
|
100
97
|
}
|
|
@@ -14,29 +14,32 @@ in float v_opacity;
|
|
|
14
14
|
|
|
15
15
|
out vec4 outputColor;
|
|
16
16
|
|
|
17
|
-
void main(){
|
|
18
|
-
vec2 pos = v_uv / u_textSize + gl_PointCoord / u_textSize * 64
|
|
17
|
+
void main() {
|
|
18
|
+
vec2 pos = v_uv / u_textSize + gl_PointCoord / u_textSize * 64.0;
|
|
19
19
|
vec4 textureColor;
|
|
20
20
|
|
|
21
21
|
// Y = 0.299R + 0.587G + 0.114B // 亮度提取
|
|
22
|
-
|
|
22
|
+
|
|
23
23
|
textureColor = texture(SAMPLER_2D(u_texture), pos);
|
|
24
24
|
|
|
25
25
|
// Tip: 去除边缘部分 mipmap 导致的混合变暗
|
|
26
26
|
float fragmengTocenter = distance(vec2(0.5), gl_PointCoord);
|
|
27
|
-
if(fragmengTocenter >= 0.5) {
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
if (fragmengTocenter >= 0.5) {
|
|
28
|
+
float luma = 0.299 * textureColor.r + 0.587 * textureColor.g + 0.114 * textureColor.b;
|
|
29
|
+
textureColor.a *= luma;
|
|
30
30
|
}
|
|
31
|
-
|
|
32
|
-
if
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
31
|
+
|
|
32
|
+
if (
|
|
33
|
+
all(lessThan(v_color, vec4(1.0 + 0.00001))) && all(greaterThan(v_color, vec4(1.0 - 0.00001))) ||
|
|
34
|
+
v_color == vec4(1.0)
|
|
35
|
+
) {
|
|
36
|
+
outputColor = textureColor;
|
|
37
|
+
} else {
|
|
38
|
+
outputColor = step(0.01, textureColor.z) * v_color;
|
|
36
39
|
}
|
|
37
40
|
outputColor.a *= v_opacity;
|
|
38
41
|
if (outputColor.a < 0.01) {
|
|
39
|
-
|
|
42
|
+
discard;
|
|
40
43
|
}
|
|
41
44
|
outputColor = filterColor(outputColor);
|
|
42
45
|
}
|
|
@@ -7,15 +7,15 @@ import BaseModel from "../../core/BaseModel";
|
|
|
7
7
|
import { PolygonExtrudeTriangulation } from "../../core/triangulation";
|
|
8
8
|
import { loadImage } from "../../utils/load-image";
|
|
9
9
|
/* babel-plugin-inline-import '../shaders/extrude/polygon_extrude_frag.glsl' */
|
|
10
|
-
const 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
|
|
10
|
+
const 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 // top face\n if (u_topsurface < 1.0) {\n discard;\n }\n\n outputColor = v_Color;\n\n outputColor = filterColor(outputColor);\n}\n";
|
|
11
11
|
/* babel-plugin-inline-import '../shaders/extrude/polygon_extrude_picklight_frag.glsl' */
|
|
12
|
-
const polygonExtrudePickLightFrag = "
|
|
12
|
+
const polygonExtrudePickLightFrag = "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;\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";
|
|
13
13
|
/* babel-plugin-inline-import '../shaders/extrude/polygon_extrude_picklight_vert.glsl' */
|
|
14
14
|
const polygonExtrudePickLightVert = "layout(location = ATTRIBUTE_LOCATION_POSITION) in vec3 a_Position;\nlayout(location = ATTRIBUTE_LOCATION_POSITION_64LOW) in vec2 a_Position64Low;\nlayout(location = ATTRIBUTE_LOCATION_COLOR) in vec4 a_Color;\nlayout(location = ATTRIBUTE_LOCATION_SIZE) in float a_Size;\nlayout(location = ATTRIBUTE_LOCATION_NORMAL) in vec3 a_Normal;\nlayout(location = ATTRIBUTE_LOCATION_UV) 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;\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 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, a_Position64Low);\n\n if (u_heightfixed > 0.0) {\n // \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 (\n u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT ||\n u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET\n ) {\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(vec4(project_pos.xyz, 1.0));\n float lightWeight = calc_lighting(project_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";
|
|
15
15
|
/* babel-plugin-inline-import '../shaders/extrude/polygon_extrude_vert.glsl' */
|
|
16
16
|
const polygonExtrudeVert = "layout(location = ATTRIBUTE_LOCATION_POSITION) in vec3 a_Position;\nlayout(location = ATTRIBUTE_LOCATION_POSITION_64LOW) in vec2 a_Position64Low;\nlayout(location = ATTRIBUTE_LOCATION_COLOR) in vec4 a_Color;\nlayout(location = ATTRIBUTE_LOCATION_SIZE) in float a_Size;\nlayout(location = ATTRIBUTE_LOCATION_NORMAL) in vec3 a_Normal;\nlayout(location = ATTRIBUTE_LOCATION_UV) 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 float 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\n vec4 project_pos = project_position(pos, a_Position64Low);\n float lightWeight = calc_lighting(project_pos);\n\n if (u_heightfixed > 0.0) {\n // \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 (\n u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT ||\n u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET\n ) {\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(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 setPickingColor(a_PickingColor);\n}\n";
|
|
17
17
|
/* babel-plugin-inline-import '../shaders/extrude/polygon_extrudetex_frag.glsl' */
|
|
18
|
-
const 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
|
|
18
|
+
const 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) {\n // \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";
|
|
19
19
|
/* babel-plugin-inline-import '../shaders/extrude/polygon_extrudetex_vert.glsl' */
|
|
20
20
|
const polygonExtrudeTexVert = "layout(location = ATTRIBUTE_LOCATION_POSITION) in vec3 a_Position;\nlayout(location = ATTRIBUTE_LOCATION_POSITION_64LOW) in vec2 a_Position64Low;\nlayout(location = ATTRIBUTE_LOCATION_COLOR) in vec4 a_Color;\nlayout(location = ATTRIBUTE_LOCATION_SIZE) in float a_Size;\nlayout(location = ATTRIBUTE_LOCATION_NORMAL) in vec3 a_Normal;\nlayout(location = ATTRIBUTE_LOCATION_UV) 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;\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 vec4 pos = vec4(a_Position.xy, a_Position.z * a_Size, 1.0);\n vec4 project_pos = project_position(pos, a_Position64Low);\n float lightWeight = calc_lighting(project_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) {\n // \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 (\n u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT ||\n u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET\n ) {\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(vec4(project_pos.xyz, 1.0));\n\n setPickingColor(a_PickingColor);\n}\n";
|
|
21
21
|
export default class ExtrudeModel extends BaseModel {
|
|
@@ -5,7 +5,7 @@ import { AttributeType, gl } from '@antv/l7-core';
|
|
|
5
5
|
import BaseModel from "../../core/BaseModel";
|
|
6
6
|
import { PolygonExtrudeTriangulation } from "../../core/triangulation";
|
|
7
7
|
/* babel-plugin-inline-import '../shaders/extrusion/polygon_extrusion_frag.glsl' */
|
|
8
|
-
const polygonExtrudeFrag = "
|
|
8
|
+
const polygonExtrudeFrag = "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";
|
|
9
9
|
/* babel-plugin-inline-import '../shaders/extrusion/polygon_extrusion_vert.glsl' */
|
|
10
10
|
const polygonExtrudeVert = "layout(location = ATTRIBUTE_LOCATION_POSITION) in vec3 a_Position;\nlayout(location = ATTRIBUTE_LOCATION_POSITION_64LOW) in vec2 a_Position64Low;\nlayout(location = ATTRIBUTE_LOCATION_COLOR) in vec4 a_Color;\nlayout(location = ATTRIBUTE_LOCATION_SIZE) in float a_Size;\nlayout(location = ATTRIBUTE_LOCATION_NORMAL) 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 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, a_Position64Low);\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(vec4(project_pos.xyz, 1.0));\n\n setPickingColor(a_PickingColor);\n}\n";
|
|
11
11
|
export default class ExtrusionModel extends BaseModel {
|
|
@@ -6,7 +6,7 @@ import { polygonTriangulation, polygonTriangulationWithCenter } from "../../core
|
|
|
6
6
|
/* babel-plugin-inline-import '../shaders/fill/fill_frag.glsl' */
|
|
7
7
|
const 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";
|
|
8
8
|
/* babel-plugin-inline-import '../shaders/fill/fill_linear_frag.glsl' */
|
|
9
|
-
const polygon_linear_frag = "
|
|
9
|
+
const polygon_linear_frag = "layout(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 *=\n u_dir == 1.0\n ? 1.0 - length(v_pos - v_linear.xy) / v_linear.z\n : length(v_pos - v_linear.xy) / v_linear.z;\n }\n outputColor = filterColor(outputColor);\n}\n";
|
|
10
10
|
/* babel-plugin-inline-import '../shaders/fill/fill_linear_vert.glsl' */
|
|
11
11
|
const polygon_linear_vert = "layout(location = ATTRIBUTE_LOCATION_POSITION) in vec3 a_Position;\nlayout(location = ATTRIBUTE_LOCATION_POSITION_64LOW) in vec2 a_Position64Low;\nlayout(location = ATTRIBUTE_LOCATION_COLOR) in vec4 a_Color;\nlayout(location = ATTRIBUTE_LOCATION_LINEAR) 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), a_Position64Low);\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(vec4(project_pos.xyz, 1.0));\n setPickingColor(a_PickingColor);\n}\n";
|
|
12
12
|
/* babel-plugin-inline-import '../shaders/fill/fill_vert.glsl' */
|
|
@@ -6,7 +6,7 @@ import { rgb2arr } from '@antv/l7-utils';
|
|
|
6
6
|
import BaseModel from "../../core/BaseModel";
|
|
7
7
|
import { polygonTriangulation } from "../../core/triangulation";
|
|
8
8
|
/* babel-plugin-inline-import '../shaders/ocean/ocean_frag.glsl' */
|
|
9
|
-
const ocean_frag = "
|
|
9
|
+
const ocean_frag = "layout(std140) uniform commonUniforms {\n vec4 u_watercolor;\n vec4 u_watercolor2;\n float u_time;\n};\n\nin vec2 v_uv;\nin float v_opacity;\nout vec4 outputColor;\n\nfloat coast2water_fadedepth = 0.1;\nfloat large_waveheight = 0.75; // change to adjust the \"heavy\" waves\nfloat large_wavesize = 3.4; // factor to adjust the large wave size\nfloat small_waveheight = 0.6; // change to adjust the small random waves\nfloat small_wavesize = 0.5; // factor to ajust the small wave size\nfloat water_softlight_fact = 15.0; // range [1..200] (should be << smaller than glossy-fact)\nfloat water_glossylight_fact = 120.0; // range [1..200]\nfloat particle_amount = 70.0;\n\nvec3 water_specularcolor = vec3(1.3, 1.3, 0.9); // specular Color (RGB) of the water-highlights\n#define light (vec3(-0.0, sin(u_time * 0.5) * 0.5 + 0.35, 2.8)) // position of the sun\n\nuniform sampler2D u_texture1;\nuniform sampler2D u_texture2;\nuniform sampler2D u_texture3;\n\nfloat hash(float n) {\n return fract(sin(n) * 43758.5453123);\n}\n\n// 2d noise function\nfloat noise1(vec2 x) {\n vec2 p = floor(x);\n vec2 f = smoothstep(0.0, 1.0, fract(x));\n float n = p.x + p.y * 57.0;\n return mix(mix(hash(n + 0.0), hash(n + 1.0), f.x), mix(hash(n + 57.0), hash(n + 58.0), f.x), f.y);\n}\n\nfloat noise(vec2 p) {\n return texture(SAMPLER_2D(u_texture2), p * vec2(1.0 / 256.0)).x;\n}\n\nvec4 highness(vec2 p) {\n vec4 t = texture(SAMPLER_2D(u_texture1), fract(p));\n float clipped =\n -2.0 -\n smoothstep(3.0, 10.0, t.a) * 6.9 -\n smoothstep(10.0, 100.0, t.a) * 89.9 -\n smoothstep(0.0, 10000.0, t.a) * 10000.0;\n return clamp(t, 0.0, 3.0) + clamp(t / 3.0 - 1.0, 0.0, 1.0) + clamp(t / 16.0 - 1.0, 0.0, 1.0);\n}\n\nfloat height_map(vec2 p) {\n vec4 height = highness(p);\n /*\n height = -0.5+\n 0.5*smoothstep(-100.,0.,-height)+\n 2.75*smoothstep(0.,2.,height)+\n 1.75*smoothstep(2.,4.,height)+\n 2.75*smoothstep(4.,16.,height)+\n 1.5*smoothstep(16.,1000.,height);\n */\n\n mat2 m = mat2(0.9563 * 1.4, -0.2924 * 1.4, 0.2924 * 1.4, 0.9563 * 1.4);\n //p = p*6.;\n float f = 0.6 * noise1(p);\n p = m * p * 1.1 * 6.0;\n f += 0.25 * noise(p);\n p = m * p * 1.32;\n f += 0.1666 * noise(p);\n p = m * p * 1.11;\n f += 0.0834 * noise(p);\n p = m * p * 1.12;\n f += 0.0634 * noise(p);\n p = m * p * 1.13;\n f += 0.0444 * noise(p);\n p = m * p * 1.14;\n f += 0.0274 * noise(p);\n p = m * p * 1.15;\n f += 0.0134 * noise(p);\n p = m * p * 1.16;\n f += 0.0104 * noise(p);\n p = m * p * 1.17;\n f += 0.0084 * noise(p);\n f = 0.25 * f + dot(height, vec4(-0.03125, -0.125, 0.25, 0.25)) * 0.5;\n const float FLAT_LEVEL = 0.92525;\n //f = f*0.25+height*0.75;\n if (f < FLAT_LEVEL) f = f;\n else f = pow((f - FLAT_LEVEL) / (1.0 - FLAT_LEVEL), 2.0) * (1.0 - FLAT_LEVEL) * 2.0 + FLAT_LEVEL; // makes a smooth coast-increase\n return clamp(f, 0.0, 10.0);\n}\n\nvec3 plasma_quintic(float x) {\n x = clamp(x, 0.0, 1.0);\n vec4 x1 = vec4(1.0, x, x * x, x * x * x); // 1 x x2 x3\n vec4 x2 = x1 * x1.w * x; // x4 x5 x6 x7\n return vec3(\n dot(x1.xyzw, vec4(+0.063861086, +1.992659096, -1.023901152, -0.490832805)) +\n dot(x2.xy, vec2(+1.308442123, -0.914547012)),\n dot(x1.xyzw, vec4(+0.04971859, -0.791144343, +2.892305078, +0.811726816)) +\n dot(x2.xy, vec2(-4.686502417, +2.717794514)),\n dot(x1.xyzw, vec4(+0.513275779, +1.58025506, -5.164414457, +4.559573646)) +\n dot(x2.xy, vec2(-1.916810682, +0.570638854))\n );\n}\n\nvec4 color(vec2 p) {\n vec4 c1 = vec4(1.7, 1.6, 0.9, 1);\n vec4 c2 = vec4(0.2, 0.94, 0.1, 1);\n vec4 c3 = vec4(0.3, 0.2, 0.0, 1);\n vec4 c4 = vec4(0.99, 0.99, 1.6, 1);\n vec4 v = highness(p);\n float los = smoothstep(0.1, 1.1, v.b);\n float his = smoothstep(3.5, 6.5, v.b);\n float ces = smoothstep(1.0, 5.0, v.a);\n vec4 lo = mix(c1, c2, los);\n vec4 hi = mix(c3, c4, his);\n vec4 ce = mix(lo, hi, ces);\n\n return vec4(plasma_quintic(ces), 1).ragb;\n}\n\nvec3 terrain_map(vec2 p) {\n return color(p).rgb * 0.75 +\n 0.25 * vec3(0.7, 0.55, 0.4) +\n texture(SAMPLER_2D(u_texture3), fract(p * 5.0)).rgb * 0.5; // test-terrain is simply 'sandstone'\n}\n\nconst mat2 m = mat2(\n 0.72, -1.6 ,\n 1.6 , 0.72\n);\n\nfloat water_map(vec2 p, float height) {\n vec2 p2 = p * large_wavesize;\n vec2 shift1 = 0.001 * vec2(u_time * 160.0 * 2.0, u_time * 120.0 * 2.0);\n vec2 shift2 = 0.001 * vec2(u_time * 190.0 * 2.0, -u_time * 130.0 * 2.0);\n\n // coarse crossing 'ocean' waves...\n float f = 0.6 * noise(p);\n f += 0.25 * noise(p * m);\n f += 0.1666 * noise(p * m * m);\n float wave =\n sin(p2.x * 0.622 + p2.y * 0.622 + shift2.x * 4.269) * large_waveheight * f * height * height;\n\n p *= small_wavesize;\n f = 0.0;\n float amp = 1.0,\n s = 0.5;\n for (int i = 0; i < 9; i++) {\n p = m * p * 0.947;\n f -= amp * abs(sin((noise(p + shift1 * s) - 0.5) * 2.0));\n amp = amp * 0.59;\n s *= -1.329;\n }\n\n return wave + f * small_waveheight;\n}\n\nfloat nautic(vec2 p) {\n p *= 18.0;\n float f = 0.0;\n float amp = 1.0,\n s = 0.5;\n for (int i = 0; i < 3; i++) {\n p = m * p * 1.2;\n f += amp * abs(smoothstep(0.0, 1.0, noise(p + u_time * s)) - 0.5);\n amp = amp * 0.5;\n s *= -1.227;\n }\n return pow(1.0 - f, 5.0);\n}\n\nfloat particles(vec2 p) {\n p *= 200.0;\n float f = 0.0;\n float amp = 1.0,\n s = 1.5;\n for (int i = 0; i < 3; i++) {\n p = m * p * 1.2;\n f += amp * noise(p + u_time * s);\n amp = amp * 0.5;\n s *= -1.227;\n }\n return pow(f * 0.35, 7.0) * particle_amount;\n}\n\nfloat test_shadow(vec2 xy, float height) {\n vec3 r0 = vec3(xy, height);\n vec3 rd = normalize(light - r0);\n\n float hit = 1.0;\n float t = 0.001;\n for (int j = 1; j < 25; j++) {\n vec3 p = r0 + t * rd;\n float h = height_map(p.xy);\n float height_diff = p.z - h;\n if (height_diff < 0.0) {\n return 0.0;\n }\n t += 0.01 + height_diff * 0.02;\n hit = min(hit, 2.0 * height_diff / t); // soft shaddow\n }\n return hit;\n}\n\nvec3 CalcTerrain(vec2 uv, float height) {\n vec3 col = terrain_map(uv);\n vec2 iResolution = vec2(512.0);\n float h1 = height_map(uv - vec2(0.0, 0.5) / iResolution.xy);\n float h2 = height_map(uv + vec2(0.0, 0.5) / iResolution.xy);\n float h3 = height_map(uv - vec2(0.5, 0.0) / iResolution.xy);\n float h4 = height_map(uv + vec2(0.5, 0.0) / iResolution.xy);\n vec3 norm = normalize(vec3(h3 - h4, h1 - h2, 1.0));\n vec3 r0 = vec3(uv, height);\n vec3 rd = normalize(light - r0);\n float grad = dot(norm, rd);\n col *= grad + pow(grad, 8.0);\n float terrainshade = test_shadow(uv, height);\n col = mix(col * 0.25, col, terrainshade);\n return col;\n}\n\nvoid main() {\n vec3 watercolor = u_watercolor.rgb;\n vec3 watercolor2 = u_watercolor2.rgb;\n vec2 uv = v_uv;\n float WATER_LEVEL = 0.84; // Water level (range: 0.0 - 2.0)\n float deepwater_fadedepth = 0.4 + coast2water_fadedepth;\n float height = height_map(uv);\n vec3 col;\n\n float waveheight = clamp(WATER_LEVEL * 3.0 - 1.5, 0.0, 1.0);\n float level = WATER_LEVEL + 0.2 * water_map(uv * 15.0 + vec2(u_time * 0.1), waveheight);\n if (height > level) {\n col = CalcTerrain(uv, height);\n }\n if (height <= level) {\n vec2 dif = vec2(0.0, 0.01);\n vec2 pos = uv * 15.0 + vec2(u_time * 0.01);\n float h1 = water_map(pos - dif, waveheight);\n float h2 = water_map(pos + dif, waveheight);\n float h3 = water_map(pos - dif.yx, waveheight);\n float h4 = water_map(pos + dif.yx, waveheight);\n vec3 normwater = normalize(vec3(h3 - h4, h1 - h2, 0.125)); // norm-vector of the 'bumpy' water-plane\n uv += normwater.xy * 0.002 * (level - height);\n\n col = CalcTerrain(uv, height);\n\n float coastfade = clamp((level - height) / coast2water_fadedepth, 0.0, 1.0);\n float coastfade2 = clamp((level - height) / deepwater_fadedepth, 0.0, 1.0);\n float intensity = col.r * 0.2126 + col.g * 0.7152 + col.b * 0.0722;\n watercolor = mix(watercolor * intensity, watercolor2, smoothstep(0.0, 1.0, coastfade2));\n\n vec3 r0 = vec3(uv, WATER_LEVEL);\n vec3 rd = normalize(light - r0); // ray-direction to the light from water-position\n float grad = dot(normwater, rd); // dot-product of norm-vector and light-direction\n float specular = pow(grad, water_softlight_fact); // used for soft highlights\n float specular2 = pow(grad, water_glossylight_fact); // used for glossy highlights\n float gradpos = dot(vec3(0.0, 0.0, 1.0), rd);\n float specular1 = smoothstep(0.0, 1.0, pow(gradpos, 5.0)); // used for diffusity (some darker corona around light's specular reflections...)\n float watershade = test_shadow(uv, level);\n watercolor *= 2.2 + watershade;\n watercolor += (0.2 + 0.8 * watershade) * ((grad - 1.0) * 0.5 + specular) * 0.25;\n watercolor /= 1.0 + specular1 * 1.25;\n watercolor += watershade * specular2 * water_specularcolor;\n watercolor +=\n watershade *\n coastfade *\n (1.0 - coastfade2) *\n (vec3(0.5, 0.6, 0.7) * nautic(uv) + vec3(1.0, 1.0, 1.0) * particles(uv));\n\n col = mix(col, watercolor, coastfade);\n }\n\n outputColor = vec4(col, v_opacity);\n}\n";
|
|
10
10
|
/* babel-plugin-inline-import '../shaders/ocean/ocean_vert.glsl' */
|
|
11
11
|
const ocean_vert = "layout(location = ATTRIBUTE_LOCATION_POSITION) in vec3 a_Position;\nlayout(location = ATTRIBUTE_LOCATION_UV) in vec2 a_uv;\n\nlayout(std140) uniform commonUniforms {\n vec4 u_watercolor;\n vec4 u_watercolor2;\n float u_time;\n};\n\nout vec2 v_uv;\nout float v_opacity;\n\n#pragma include \"projection\"\n\nvoid main() {\n v_uv = a_uv;\n v_opacity = 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\n";
|
|
12
12
|
export default class OceanModel extends BaseModel {
|
|
@@ -5,7 +5,7 @@ import { AttributeType, gl } from '@antv/l7-core';
|
|
|
5
5
|
import BaseModel from "../../core/BaseModel";
|
|
6
6
|
import { polygonTriangulation } from "../../core/triangulation";
|
|
7
7
|
/* babel-plugin-inline-import '../shaders/water/polygon_water_frag.glsl' */
|
|
8
|
-
const water_frag = "uniform sampler2D u_texture;\nlayout(std140) uniform commonUniforms {\n float u_speed;\n float u_time;\n};\n\nout vec4 outputColor;\n\
|
|
8
|
+
const water_frag = "uniform sampler2D u_texture;\nlayout(std140) uniform commonUniforms {\n float u_speed;\n float u_time;\n};\n\nout vec4 outputColor;\n\nin vec4 v_Color;\nin vec2 v_uv;\n\nfloat rand(vec2 n) {\n return 0.5 + 0.5 * fract(sin(dot(n.xy, vec2(12.9898, 78.233))) * 43758.5453);\n}\n\nfloat water(vec3 p) {\n float t = u_time * u_speed;\n p.z += t * 2.0;\n p.x += t * 2.0;\n vec3 c1 = texture(SAMPLER_2D(u_texture), p.xz / 30.0).xyz;\n p.z += t * 3.0;\n p.x += t * 0.52;\n vec3 c2 = texture(SAMPLER_2D(u_texture), p.xz / 30.0).xyz;\n p.z += t * 4.0;\n p.x += t * 0.8;\n vec3 c3 = texture(SAMPLER_2D(u_texture), p.xz / 30.0).xyz;\n c1 += c2 - c3;\n float z = (c1.x + c1.y + c1.z) / 3.0;\n return p.y + z / 4.0;\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 = 0.1;\n return normalize(\n 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}\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 outputColor = v_Color;\n float spc = calSpc();\n outputColor += spc * 0.4;\n}\n";
|
|
9
9
|
/* babel-plugin-inline-import '../shaders/water/polygon_water_vert.glsl' */
|
|
10
10
|
const water_vert = "layout(location = ATTRIBUTE_LOCATION_POSITION) in vec3 a_Position;\nlayout(location = ATTRIBUTE_LOCATION_COLOR) in vec4 a_Color;\nlayout(location = ATTRIBUTE_LOCATION_UV) in vec2 a_uv;\n\nlayout(std140) uniform commonUniforms {\n float u_speed;\n float u_time;\n};\nout vec4 v_Color;\nout vec2 v_uv;\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(vec4(project_pos.xyz, 1.0));\n}\n\n";
|
|
11
11
|
export default class WaterModel extends BaseModel {
|
|
@@ -13,13 +13,12 @@ in vec4 v_Color;
|
|
|
13
13
|
#pragma include "picking"
|
|
14
14
|
out vec4 outputColor;
|
|
15
15
|
void main() {
|
|
16
|
+
// top face
|
|
17
|
+
if (u_topsurface < 1.0) {
|
|
18
|
+
discard;
|
|
19
|
+
}
|
|
16
20
|
|
|
17
|
-
|
|
18
|
-
if(u_topsurface < 1.0) {
|
|
19
|
-
discard;
|
|
20
|
-
}
|
|
21
|
+
outputColor = v_Color;
|
|
21
22
|
|
|
22
|
-
outputColor = v_Color;
|
|
23
|
-
|
|
24
23
|
outputColor = filterColor(outputColor);
|
|
25
24
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
layout(std140) uniform commonUniforms {
|
|
3
2
|
vec4 u_sourceColor;
|
|
4
3
|
vec4 u_targetColor;
|
|
@@ -18,29 +17,29 @@ out vec4 outputColor;
|
|
|
18
17
|
#pragma include "picking"
|
|
19
18
|
|
|
20
19
|
void main() {
|
|
21
|
-
float isSide =
|
|
20
|
+
float isSide = v_texture_data.x;
|
|
22
21
|
float sidey = v_uvs[2];
|
|
23
22
|
float lightWeight = v_texture_data.y;
|
|
24
23
|
|
|
25
24
|
// Tip: 部分机型 GPU 计算精度兼容
|
|
26
|
-
if(isSide < 0.999) {
|
|
25
|
+
if (isSide < 0.999) {
|
|
27
26
|
// side face
|
|
28
|
-
if(u_sidesurface < 1.0) {
|
|
27
|
+
if (u_sidesurface < 1.0) {
|
|
29
28
|
discard;
|
|
30
29
|
}
|
|
31
|
-
|
|
32
|
-
if(
|
|
30
|
+
|
|
31
|
+
if (u_linearColor == 1.0) {
|
|
33
32
|
// side use linear
|
|
34
33
|
vec4 linearColor = mix(u_targetColor, u_sourceColor, sidey);
|
|
35
34
|
linearColor.rgb *= lightWeight;
|
|
36
35
|
outputColor = linearColor;
|
|
37
36
|
} else {
|
|
38
37
|
// side notuse linear
|
|
39
|
-
|
|
38
|
+
outputColor = v_Color;
|
|
40
39
|
}
|
|
41
40
|
} else {
|
|
42
41
|
// top face
|
|
43
|
-
if(u_topsurface < 1.0) {
|
|
42
|
+
if (u_topsurface < 1.0) {
|
|
44
43
|
discard;
|
|
45
44
|
}
|
|
46
45
|
outputColor = v_Color;
|
|
@@ -29,7 +29,8 @@ void main() {
|
|
|
29
29
|
|
|
30
30
|
outputColor = texture(SAMPLER_2D(u_texture), vec2(topU, topV));
|
|
31
31
|
// Tip: 部分机型 GPU 计算精度兼容
|
|
32
|
-
if (isSide < 0.999) {
|
|
32
|
+
if (isSide < 0.999) {
|
|
33
|
+
// 是否是边缘
|
|
33
34
|
// side face
|
|
34
35
|
if (u_sidesurface < 1.0) {
|
|
35
36
|
discard;
|
|
@@ -43,12 +44,12 @@ void main() {
|
|
|
43
44
|
outputColor = v_Color;
|
|
44
45
|
}
|
|
45
46
|
} else {
|
|
46
|
-
|
|
47
|
+
// top face
|
|
47
48
|
if (u_topsurface < 1.0) {
|
|
48
49
|
discard;
|
|
49
50
|
}
|
|
50
51
|
}
|
|
51
|
-
|
|
52
|
+
|
|
52
53
|
outputColor.a *= opacity;
|
|
53
54
|
outputColor = filterColor(outputColor);
|
|
54
55
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
layout(std140) uniform commonUniforms {
|
|
3
2
|
float u_raisingHeight;
|
|
4
3
|
float u_opacitylinear;
|
|
@@ -15,7 +14,10 @@ out vec4 outputColor;
|
|
|
15
14
|
void main() {
|
|
16
15
|
outputColor = v_color;
|
|
17
16
|
if (u_opacitylinear > 0.0) {
|
|
18
|
-
outputColor.a *=
|
|
17
|
+
outputColor.a *=
|
|
18
|
+
u_dir == 1.0
|
|
19
|
+
? 1.0 - length(v_pos - v_linear.xy) / v_linear.z
|
|
20
|
+
: length(v_pos - v_linear.xy) / v_linear.z;
|
|
19
21
|
}
|
|
20
22
|
outputColor = filterColor(outputColor);
|
|
21
23
|
}
|