@woosh/meep-engine 3.72.0 → 3.73.0
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/package.json +1 -1
- package/src/engine/graphics/ecs/text/Text.d.ts +21 -2
- package/src/engine/graphics/ecs/text/Text.d.ts.map +1 -1
- package/src/engine/graphics/ecs/text/Text.js +24 -3
- package/src/engine/graphics3/TextSystem.d.ts +9 -8
- package/src/engine/graphics3/TextSystem.d.ts.map +1 -1
- package/src/engine/graphics3/TextSystem.js +65 -134
- package/src/engine/physics/fluid/ecs/FluidObstacleSystem.d.ts +4 -4
- package/src/shade/device/pipeline/PipelineEnquiry.d.ts +11 -5
- package/src/shade/device/pipeline/PipelineEnquiry.d.ts.map +1 -1
- package/src/shade/device/pipeline/PipelineEnquiry.js +7 -0
- package/src/shade/playground/text/main.js +4 -1
- package/src/shade/renderer/Renderer.d.ts.map +1 -1
- package/src/shade/renderer/Renderer.js +10 -1
- package/src/shade/renderer/deferred/tonemap/TonemapDisplaySettings.d.ts +8 -0
- package/src/shade/renderer/deferred/tonemap/TonemapDisplaySettings.d.ts.map +1 -1
- package/src/shade/renderer/deferred/tonemap/TonemapDisplaySettings.js +18 -0
- package/src/shade/renderer/extension/PresentTarget.d.ts +10 -0
- package/src/shade/renderer/extension/PresentTarget.d.ts.map +1 -1
- package/src/shade/renderer/extension/PresentTarget.js +17 -0
- package/src/shade/renderer/fluid/GPUFluidCascade.d.ts +3 -3
- package/src/shade/renderer/fluid/GPUFluidCascadeStack.d.ts +1 -1
- package/src/shade/renderer/fluid/forcing/GPUFluidForcing.d.ts +7 -7
- package/src/shade/renderer/fluid/pressure/GPUFluidPressureSolve.d.ts +1 -1
- package/src/shade/renderer/fluid/query/GPUFluidQueries.d.ts +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/GPUProbeClipmapGI.d.ts +1 -1
- package/src/shade/renderer/loader/gltf/tiny-gltf.d.ts +1 -1
- package/src/shade/renderer/postprocess/nss/NSS.d.ts +1 -1
- package/src/shade/renderer/text/GPUTextAVBOITChannel.d.ts.map +1 -1
- package/src/shade/renderer/text/GPUTextAVBOITChannel.js +67 -37
- package/src/shade/renderer/text/GPUTextSystem.d.ts +7 -0
- package/src/shade/renderer/text/GPUTextSystem.d.ts.map +1 -1
- package/src/shade/renderer/text/GPUTextSystem.js +40 -0
- package/src/shade/renderer/text/data/TEXT_RECORD.d.ts +1 -1
- package/src/shade/renderer/text/data/TEXT_RECORD.d.ts.map +1 -1
- package/src/shade/renderer/text/data/TEXT_RECORD.js +9 -4
- package/src/shade/renderer/text/graph_text.d.ts +14 -94
- package/src/shade/renderer/text/graph_text.d.ts.map +1 -1
- package/src/shade/renderer/text/graph_text.js +83 -106
- package/src/shade/renderer/text/graph_text_avboit.d.ts +1 -1
- package/src/shade/renderer/text/graph_text_avboit.js +1 -1
- package/src/shade/renderer/text/runtime/TextParameters.d.ts +11 -0
- package/src/shade/renderer/text/runtime/TextParameters.d.ts.map +1 -1
- package/src/shade/renderer/text/runtime/TextParameters.js +23 -1
- package/src/shade/renderer/text/shaders/TEXT_VIEW_STRUCT.d.ts +3 -1
- package/src/shade/renderer/text/shaders/TEXT_VIEW_STRUCT.d.ts.map +1 -1
- package/src/shade/renderer/text/shaders/TEXT_VIEW_STRUCT.js +20 -2
- package/src/shade/renderer/text/shaders/chunk_text_canvas_color.d.ts +15 -0
- package/src/shade/renderer/text/shaders/chunk_text_canvas_color.d.ts.map +1 -0
- package/src/shade/renderer/text/shaders/chunk_text_canvas_color.js +29 -0
- package/src/shade/renderer/text/shaders/chunk_text_facing.d.ts +7 -2
- package/src/shade/renderer/text/shaders/chunk_text_facing.d.ts.map +1 -1
- package/src/shade/renderer/text/shaders/chunk_text_facing.js +19 -2
- package/src/shade/renderer/text/shaders/shader_text_count.d.ts +4 -4
- package/src/shade/renderer/text/shaders/shader_text_count.d.ts.map +1 -1
- package/src/shade/renderer/text/shaders/shader_text_count.js +15 -8
- package/src/shade/renderer/text/shaders/shader_text_count_scene.d.ts +2 -2
- package/src/shade/renderer/text/shaders/shader_text_count_scene.d.ts.map +1 -1
- package/src/shade/renderer/text/shaders/shader_text_count_scene.js +4 -5
- package/src/shade/renderer/text/shaders/shader_text_facing_draw.d.ts +2 -2
- package/src/shade/renderer/text/shaders/shader_text_facing_draw.d.ts.map +1 -1
- package/src/shade/renderer/text/shaders/shader_text_facing_draw.js +6 -3
- package/src/shade/renderer/text/shaders/shader_text_facing_draw_shadow.d.ts +19 -0
- package/src/shade/renderer/text/shaders/shader_text_facing_draw_shadow.d.ts.map +1 -0
- package/src/shade/renderer/text/shaders/shader_text_facing_draw_shadow.js +156 -0
- package/src/shade/renderer/text/shaders/shader_text_facing_draw_stroked.d.ts +2 -1
- package/src/shade/renderer/text/shaders/shader_text_facing_draw_stroked.d.ts.map +1 -1
- package/src/shade/renderer/text/shaders/shader_text_facing_draw_stroked.js +7 -3
- package/src/shade/renderer/water/query/GPUWaterQueries.d.ts +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { assert } from "../../../../core/assert.js";
|
|
2
|
-
import { f32, mat4x4f, vec2f } from "../../shader/type/WEBGPU_WGSL_PRIMITIVE_TYPES.js";
|
|
2
|
+
import { f32, mat4x4f, vec2f, vec3f } from "../../shader/type/WEBGPU_WGSL_PRIMITIVE_TYPES.js";
|
|
3
3
|
import { WebGPUStruct } from "../../shader/type/WebGPUStruct.js";
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -17,6 +17,14 @@ export const TEXT_VIEW_STRUCT = WebGPUStruct.from({
|
|
|
17
17
|
projection_scale: f32,
|
|
18
18
|
/** target pixels to a CSS pixel, the unit text sized in pixels is measured in */
|
|
19
19
|
pixels_per_css_pixel: f32,
|
|
20
|
+
/**
|
|
21
|
+
* The matrix from linear Rec. 709, the space a text's colour is in, to the target's linear primaries, a column
|
|
22
|
+
* a field: the identity for a target that holds the scene's colour. Three columns, not a `mat3x3f`, so that
|
|
23
|
+
* the struct's floats are where {@link text_view_write} puts them.
|
|
24
|
+
*/
|
|
25
|
+
target_from_rec709_c0: vec3f,
|
|
26
|
+
target_from_rec709_c1: vec3f,
|
|
27
|
+
target_from_rec709_c2: vec3f,
|
|
20
28
|
}, "TextView");
|
|
21
29
|
|
|
22
30
|
/**
|
|
@@ -34,12 +42,15 @@ export const TEXT_VIEW_FLOATS = TEXT_VIEW_STRUCT.size / 4;
|
|
|
34
42
|
* @param {number} viewport_height in target pixels
|
|
35
43
|
* @param {number} projection_scale element 5 of the column-major projection matrix
|
|
36
44
|
* @param {number} pixels_per_css_pixel
|
|
45
|
+
* @param {ArrayLike<number>} target_from_rec709 the matrix from linear Rec. 709 to the target's linear primaries,
|
|
46
|
+
* nine floats, a column after a column
|
|
37
47
|
*/
|
|
38
|
-
export function text_view_write(out, view_projection, viewport_width, viewport_height, projection_scale, pixels_per_css_pixel) {
|
|
48
|
+
export function text_view_write(out, view_projection, viewport_width, viewport_height, projection_scale, pixels_per_css_pixel, target_from_rec709) {
|
|
39
49
|
assert.greaterThanOrEqual(out.length, TEXT_VIEW_FLOATS, 'out.length');
|
|
40
50
|
assert.greaterThan(viewport_width, 0, 'viewport_width');
|
|
41
51
|
assert.greaterThan(viewport_height, 0, 'viewport_height');
|
|
42
52
|
assert.greaterThan(pixels_per_css_pixel, 0, 'pixels_per_css_pixel');
|
|
53
|
+
assert.greaterThanOrEqual(target_from_rec709.length, 9, 'target_from_rec709.length');
|
|
43
54
|
|
|
44
55
|
for (let i = 0; i < 16; i++) {
|
|
45
56
|
out[i] = view_projection[i];
|
|
@@ -49,4 +60,11 @@ export function text_view_write(out, view_projection, viewport_width, viewport_h
|
|
|
49
60
|
out[17] = viewport_height;
|
|
50
61
|
out[18] = projection_scale;
|
|
51
62
|
out[19] = pixels_per_css_pixel;
|
|
63
|
+
|
|
64
|
+
// a column to a vec3f, each at the start of four floats
|
|
65
|
+
for (let column = 0; column < 3; column++) {
|
|
66
|
+
out[20 + column * 4] = target_from_rec709[column * 3];
|
|
67
|
+
out[21 + column * 4] = target_from_rec709[column * 3 + 1];
|
|
68
|
+
out[22 + column * 4] = target_from_rec709[column * 3 + 2];
|
|
69
|
+
}
|
|
52
70
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `text_canvas_color(view, linear_rec709) -> vec3f`: a text's colour as the canvas holds it.
|
|
3
|
+
*
|
|
4
|
+
* The canvas holds display values: a colour in the canvas's own primaries, through the sRGB transfer function. A
|
|
5
|
+
* text's colour is linear Rec. 709, so it goes through the view's matrix to those primaries and then through the
|
|
6
|
+
* function. The same colour a stylesheet would write as an sRGB colour comes out as that colour on the canvas.
|
|
7
|
+
*
|
|
8
|
+
* A channel below zero is taken as zero. One above one is kept: a canvas of a wider range shows it brighter than
|
|
9
|
+
* white, and one that has no such range clamps it.
|
|
10
|
+
*
|
|
11
|
+
* @type {CodeChunk}
|
|
12
|
+
*/
|
|
13
|
+
export const chunk_text_canvas_color: CodeChunk;
|
|
14
|
+
import { CodeChunk } from "../../shader/compiler/CodeChunk.js";
|
|
15
|
+
//# sourceMappingURL=chunk_text_canvas_color.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunk_text_canvas_color.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/text/shaders/chunk_text_canvas_color.js"],"names":[],"mappings":"AAIA;;;;;;;;;;;GAWG;AACH,sCAFU,SAAS,CAcjB;0BA3BwB,oCAAoC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { chunk_sRGBTransferOETF } from "../../shader/chunk/color/sRGB/chunk_sRGBTransferOETF.js";
|
|
2
|
+
import { CodeChunk } from "../../shader/compiler/CodeChunk.js";
|
|
3
|
+
import { TEXT_VIEW_STRUCT } from "./TEXT_VIEW_STRUCT.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* `text_canvas_color(view, linear_rec709) -> vec3f`: a text's colour as the canvas holds it.
|
|
7
|
+
*
|
|
8
|
+
* The canvas holds display values: a colour in the canvas's own primaries, through the sRGB transfer function. A
|
|
9
|
+
* text's colour is linear Rec. 709, so it goes through the view's matrix to those primaries and then through the
|
|
10
|
+
* function. The same colour a stylesheet would write as an sRGB colour comes out as that colour on the canvas.
|
|
11
|
+
*
|
|
12
|
+
* A channel below zero is taken as zero. One above one is kept: a canvas of a wider range shows it brighter than
|
|
13
|
+
* white, and one that has no such range clamps it.
|
|
14
|
+
*
|
|
15
|
+
* @type {CodeChunk}
|
|
16
|
+
*/
|
|
17
|
+
export const chunk_text_canvas_color = CodeChunk.from(
|
|
18
|
+
//language=WGSL
|
|
19
|
+
`
|
|
20
|
+
fn text_canvas_color(view : ${TEXT_VIEW_STRUCT.wgsl_ref}, linear_rec709 : vec3<f32>) -> vec3<f32> {
|
|
21
|
+
let target_from_rec709 = mat3x3<f32>(view.target_from_rec709_c0, view.target_from_rec709_c1, view.target_from_rec709_c2);
|
|
22
|
+
|
|
23
|
+
return sRGBTransferOETF(max(target_from_rec709 * linear_rec709, vec3<f32>(0.0)));
|
|
24
|
+
}
|
|
25
|
+
`, [
|
|
26
|
+
TEXT_VIEW_STRUCT.declaration_chunk,
|
|
27
|
+
chunk_sRGBTransferOETF,
|
|
28
|
+
]
|
|
29
|
+
);
|
|
@@ -9,8 +9,13 @@
|
|
|
9
9
|
* in target pixels from the top left with y down, and how many pixels the em is. A text sized in pixels has
|
|
10
10
|
* `size` CSS pixels to the em at any distance. One sized in world units has `size` units, scaled by its
|
|
11
11
|
* transform's y axis, as they appear at the depth of its transform's position. Its offset is in the same unit as
|
|
12
|
-
* its size and is measured the same way: right along the target, and up. `
|
|
13
|
-
* whose position is outside the view's near and far planes; the other
|
|
12
|
+
* its size and is measured the same way: right along the target, and up. `unit` is how many pixels one of those
|
|
13
|
+
* units is. `ahead` is false for a transform whose position is outside the view's near and far planes; the other
|
|
14
|
+
* fields then mean nothing.
|
|
15
|
+
* - `text_facing_shadow_shows(text) -> bool`: whether the text has a shadow that is drawn: one of some offset and
|
|
16
|
+
* some opacity, under a text with no stroke.
|
|
17
|
+
* - `text_facing_shadow(anchor, text) -> vec2f`: how far the text's shadow is from the text on the target, in
|
|
18
|
+
* pixels with y down. The shadow's offset is in the unit the text's size is in, right and up.
|
|
14
19
|
* - `text_facing_visible(anchor, bounds, viewport) -> bool`: whether a text whose outlines reach `bounds` (ems
|
|
15
20
|
* from the origin, y up: lowest corner then highest) has a pixel on the target. Half a pixel around the bounds
|
|
16
21
|
* counts, since a glyph's quad reaches that far.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chunk_text_facing.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/text/shaders/chunk_text_facing.js"],"names":[],"mappings":"AAIA
|
|
1
|
+
{"version":3,"file":"chunk_text_facing.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/text/shaders/chunk_text_facing.js"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,gCAFU,SAAS,CA+EjB;0BA5GwB,oCAAoC"}
|
|
@@ -13,8 +13,13 @@ import { TEXT_VIEW_STRUCT } from "./TEXT_VIEW_STRUCT.js";
|
|
|
13
13
|
* in target pixels from the top left with y down, and how many pixels the em is. A text sized in pixels has
|
|
14
14
|
* `size` CSS pixels to the em at any distance. One sized in world units has `size` units, scaled by its
|
|
15
15
|
* transform's y axis, as they appear at the depth of its transform's position. Its offset is in the same unit as
|
|
16
|
-
* its size and is measured the same way: right along the target, and up. `
|
|
17
|
-
* whose position is outside the view's near and far planes; the other
|
|
16
|
+
* its size and is measured the same way: right along the target, and up. `unit` is how many pixels one of those
|
|
17
|
+
* units is. `ahead` is false for a transform whose position is outside the view's near and far planes; the other
|
|
18
|
+
* fields then mean nothing.
|
|
19
|
+
* - `text_facing_shadow_shows(text) -> bool`: whether the text has a shadow that is drawn: one of some offset and
|
|
20
|
+
* some opacity, under a text with no stroke.
|
|
21
|
+
* - `text_facing_shadow(anchor, text) -> vec2f`: how far the text's shadow is from the text on the target, in
|
|
22
|
+
* pixels with y down. The shadow's offset is in the unit the text's size is in, right and up.
|
|
18
23
|
* - `text_facing_visible(anchor, bounds, viewport) -> bool`: whether a text whose outlines reach `bounds` (ems
|
|
19
24
|
* from the origin, y up: lowest corner then highest) has a pixel on the target. Half a pixel around the bounds
|
|
20
25
|
* counts, since a glyph's quad reaches that far.
|
|
@@ -30,6 +35,7 @@ export const chunk_text_facing = CodeChunk.from(
|
|
|
30
35
|
struct TextFacingAnchor {
|
|
31
36
|
pixel : vec2<f32>,
|
|
32
37
|
em : f32,
|
|
38
|
+
unit : f32,
|
|
33
39
|
ahead : bool,
|
|
34
40
|
}
|
|
35
41
|
|
|
@@ -56,6 +62,7 @@ fn text_facing_anchor(view : ${TEXT_VIEW_STRUCT.wgsl_ref}, global : mat4x4<f32>,
|
|
|
56
62
|
}
|
|
57
63
|
|
|
58
64
|
anchor.em = text.size * unit;
|
|
65
|
+
anchor.unit = unit;
|
|
59
66
|
|
|
60
67
|
// y is up in the text and down on the target
|
|
61
68
|
anchor.pixel = vec2<f32>(ndc.x * 0.5 + 0.5, 0.5 - ndc.y * 0.5) * view.viewport
|
|
@@ -64,6 +71,16 @@ fn text_facing_anchor(view : ${TEXT_VIEW_STRUCT.wgsl_ref}, global : mat4x4<f32>,
|
|
|
64
71
|
return anchor;
|
|
65
72
|
}
|
|
66
73
|
|
|
74
|
+
fn text_facing_shadow_shows(text : ${TEXT_STRUCT.wgsl_ref}) -> bool {
|
|
75
|
+
// a stroked text's draw classes are the odd ones
|
|
76
|
+
return text.shadow_color.a > 0.0 && any(text.shadow_offset != vec2<f32>(0.0)) && (text.draw_class & 1u) == 0u;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
fn text_facing_shadow(anchor : TextFacingAnchor, text : ${TEXT_STRUCT.wgsl_ref}) -> vec2<f32> {
|
|
80
|
+
// y is up in the text and down on the target
|
|
81
|
+
return vec2<f32>(text.shadow_offset.x, -text.shadow_offset.y) * anchor.unit;
|
|
82
|
+
}
|
|
83
|
+
|
|
67
84
|
fn text_facing_visible(anchor : TextFacingAnchor, bounds : vec4<f32>, viewport : vec2<f32>) -> bool {
|
|
68
85
|
if (!anchor.ahead || !(anchor.em > 0.0)) {
|
|
69
86
|
return false;
|
|
@@ -5,13 +5,13 @@
|
|
|
5
5
|
export const TEXT_COUNT_WORKGROUP_SIZE: number;
|
|
6
6
|
export const TEXT_COUNT_SETTINGS: WebGPUStruct;
|
|
7
7
|
/**
|
|
8
|
-
* How many glyphs of each text
|
|
9
|
-
* page iterator, writing the text's glyph count or zero into `counts`, the list the scan sums.
|
|
8
|
+
* How many glyphs of each text the view shows over the finished frame: a thread per row of the text table, through
|
|
9
|
+
* the table's page iterator, writing the text's glyph count or zero into `counts`, the list the scan sums.
|
|
10
10
|
*
|
|
11
11
|
* A text counts none of its glyphs when it is at another site, has no glyphs, is wholly transparent, or has no
|
|
12
12
|
* pixel on the target: its origin outside the view's near and far planes, or its bounds and its stroke off the
|
|
13
|
-
* target's edges.
|
|
14
|
-
* Only texts that face the camera are counted: this is the count of the site
|
|
13
|
+
* target's edges, and its shadow too if it has one.
|
|
14
|
+
* Only texts that face the camera are counted: this is the count of the site over the finished frame, where a text along
|
|
15
15
|
* its transform is not drawn. Texts inside the frame are counted by `shader_text_count_scene` and
|
|
16
16
|
* `shader_text_count_avboit`.
|
|
17
17
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shader_text_count.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/text/shaders/shader_text_count.js"],"names":[],"mappings":"AAaA;;;GAGG;AACH,wCAFU,MAAM,CAE4B;AAI5C,+
|
|
1
|
+
{"version":3,"file":"shader_text_count.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/text/shaders/shader_text_count.js"],"names":[],"mappings":"AAaA;;;GAGG;AACH,wCAFU,MAAM,CAE4B;AAI5C,+CAGwB;AAyExB;;;;;;;;;;;;GAYG;AACH,gCAFU,aAAa,CAMpB;6BA3G0B,mCAAmC;8BAJlC,+BAA+B"}
|
|
@@ -7,7 +7,7 @@ import { u32 } from "../../shader/type/WEBGPU_WGSL_PRIMITIVE_TYPES.js";
|
|
|
7
7
|
import { WebGPUBufferType } from "../../shader/type/WebGPUBufferType.js";
|
|
8
8
|
import { WebGPUStruct } from "../../shader/type/WebGPUStruct.js";
|
|
9
9
|
import { TEXT_DESCRIPTOR } from "../data/TEXT_DATABASE_SPEC.js";
|
|
10
|
-
import { TextPlacement } from "../data/TEXT_RECORD.js";
|
|
10
|
+
import { TextPlacement, TextSite } from "../data/TEXT_RECORD.js";
|
|
11
11
|
import { chunk_text_facing } from "./chunk_text_facing.js";
|
|
12
12
|
import { TEXT_VIEW_STRUCT } from "./TEXT_VIEW_STRUCT.js";
|
|
13
13
|
|
|
@@ -20,8 +20,6 @@ export const TEXT_COUNT_WORKGROUP_SIZE = 64;
|
|
|
20
20
|
const PG = TEXT_DESCRIPTOR.page_iterator_symbol_prefix(TEXT_COUNT_WORKGROUP_SIZE, false);
|
|
21
21
|
|
|
22
22
|
export const TEXT_COUNT_SETTINGS = WebGPUStruct.from({
|
|
23
|
-
/** the {@link TextSite} whose texts are counted */
|
|
24
|
-
site: u32,
|
|
25
23
|
/** element capacity of the text table: the length of the counts list the scan reads */
|
|
26
24
|
capacity: u32,
|
|
27
25
|
}, "TextCountSettings");
|
|
@@ -66,7 +64,7 @@ fn main(
|
|
|
66
64
|
var glyphs = 0u;
|
|
67
65
|
|
|
68
66
|
// a site has four draw classes: two placements, each with a stroke and without
|
|
69
|
-
if (record.glyph_count > 0u && record.draw_class / 4u ==
|
|
67
|
+
if (record.glyph_count > 0u && record.draw_class / 4u == ${TextSite.Overlay}u && record.color.a > 0.0) {
|
|
70
68
|
if (record.placement == ${TextPlacement.FacingCamera}u) {
|
|
71
69
|
let global = scene_read_node(&scene_database, record.node).global;
|
|
72
70
|
let anchor = text_facing_anchor(text_view, global, record);
|
|
@@ -76,6 +74,15 @@ fn main(
|
|
|
76
74
|
|
|
77
75
|
if (text_facing_visible(anchor, record.bounds + reach, text_view.viewport)) {
|
|
78
76
|
glyphs = record.glyph_count;
|
|
77
|
+
} else if (text_facing_shadow_shows(record)) {
|
|
78
|
+
// off the target itself, it is still drawn while its shadow is on it
|
|
79
|
+
var shadow = anchor;
|
|
80
|
+
|
|
81
|
+
shadow.pixel += text_facing_shadow(anchor, record);
|
|
82
|
+
|
|
83
|
+
if (text_facing_visible(shadow, record.bounds, text_view.viewport)) {
|
|
84
|
+
glyphs = record.glyph_count;
|
|
85
|
+
}
|
|
79
86
|
}
|
|
80
87
|
}
|
|
81
88
|
}
|
|
@@ -89,13 +96,13 @@ fn main(
|
|
|
89
96
|
]);
|
|
90
97
|
|
|
91
98
|
/**
|
|
92
|
-
* How many glyphs of each text
|
|
93
|
-
* page iterator, writing the text's glyph count or zero into `counts`, the list the scan sums.
|
|
99
|
+
* How many glyphs of each text the view shows over the finished frame: a thread per row of the text table, through
|
|
100
|
+
* the table's page iterator, writing the text's glyph count or zero into `counts`, the list the scan sums.
|
|
94
101
|
*
|
|
95
102
|
* A text counts none of its glyphs when it is at another site, has no glyphs, is wholly transparent, or has no
|
|
96
103
|
* pixel on the target: its origin outside the view's near and far planes, or its bounds and its stroke off the
|
|
97
|
-
* target's edges.
|
|
98
|
-
* Only texts that face the camera are counted: this is the count of the site
|
|
104
|
+
* target's edges, and its shadow too if it has one.
|
|
105
|
+
* Only texts that face the camera are counted: this is the count of the site over the finished frame, where a text along
|
|
99
106
|
* its transform is not drawn. Texts inside the frame are counted by `shader_text_count_scene` and
|
|
100
107
|
* `shader_text_count_avboit`.
|
|
101
108
|
*
|
|
@@ -5,12 +5,12 @@
|
|
|
5
5
|
export const TEXT_COUNT_SCENE_WORKGROUP_SIZE: number;
|
|
6
6
|
export const TEXT_COUNT_SCENE_SETTINGS: WebGPUStruct;
|
|
7
7
|
/**
|
|
8
|
-
* How many glyphs of each text the frame's camera shows
|
|
8
|
+
* How many glyphs of each text stamped at the G-buffer the frame's camera shows: a thread per row of the text
|
|
9
9
|
* table, through the table's page iterator, writing the text's glyph count or zero into `counts`, the list the
|
|
10
10
|
* scan sums.
|
|
11
11
|
*
|
|
12
12
|
* A text counts none of its glyphs when it is at another site, has no glyphs, is wholly transparent, or the box of
|
|
13
|
-
* its bounds in the world (`text_scene_box`) misses the camera's frustum.
|
|
13
|
+
* its bounds in the world (`text_scene_box`) misses the camera's frustum.
|
|
14
14
|
*
|
|
15
15
|
* @type {ComputeShader}
|
|
16
16
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shader_text_count_scene.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/text/shaders/shader_text_count_scene.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"shader_text_count_scene.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/text/shaders/shader_text_count_scene.js"],"names":[],"mappings":"AAeA;;;GAGG;AACH,8CAFU,MAAM,CAEkC;AAIlD,qDAG6B;AA6D7B;;;;;;;;;GASG;AACH,sCAFU,aAAa,CAMpB;6BA5F0B,mCAAmC;8BAJlC,+BAA+B"}
|
|
@@ -9,6 +9,7 @@ import { u32 } from "../../shader/type/WEBGPU_WGSL_PRIMITIVE_TYPES.js";
|
|
|
9
9
|
import { WebGPUBufferType } from "../../shader/type/WebGPUBufferType.js";
|
|
10
10
|
import { WebGPUStruct } from "../../shader/type/WebGPUStruct.js";
|
|
11
11
|
import { TEXT_DESCRIPTOR } from "../data/TEXT_DATABASE_SPEC.js";
|
|
12
|
+
import { TextSite } from "../data/TEXT_RECORD.js";
|
|
12
13
|
import { chunk_text_scene } from "./chunk_text_scene.js";
|
|
13
14
|
import { TEXT_VIEW_STRUCT } from "./TEXT_VIEW_STRUCT.js";
|
|
14
15
|
|
|
@@ -21,8 +22,6 @@ export const TEXT_COUNT_SCENE_WORKGROUP_SIZE = 64;
|
|
|
21
22
|
const PG = TEXT_DESCRIPTOR.page_iterator_symbol_prefix(TEXT_COUNT_SCENE_WORKGROUP_SIZE, false);
|
|
22
23
|
|
|
23
24
|
export const TEXT_COUNT_SCENE_SETTINGS = WebGPUStruct.from({
|
|
24
|
-
/** the {@link TextSite} whose texts are counted */
|
|
25
|
-
site: u32,
|
|
26
25
|
/** element capacity of the text table: the length of the counts list the scan reads */
|
|
27
26
|
capacity: u32,
|
|
28
27
|
}, "TextCountSceneSettings");
|
|
@@ -68,7 +67,7 @@ fn main(
|
|
|
68
67
|
var glyphs = 0u;
|
|
69
68
|
|
|
70
69
|
// a site has four draw classes: two placements, each with a stroke and without
|
|
71
|
-
if (record.glyph_count > 0u && record.draw_class / 4u ==
|
|
70
|
+
if (record.glyph_count > 0u && record.draw_class / 4u == ${TextSite.GBuffer}u && record.color.a > 0.0) {
|
|
72
71
|
let global = scene_read_node(&scene_database, record.node).global;
|
|
73
72
|
let plane = text_scene_plane(camera, text_view, global, record);
|
|
74
73
|
|
|
@@ -87,12 +86,12 @@ fn main(
|
|
|
87
86
|
]);
|
|
88
87
|
|
|
89
88
|
/**
|
|
90
|
-
* How many glyphs of each text the frame's camera shows
|
|
89
|
+
* How many glyphs of each text stamped at the G-buffer the frame's camera shows: a thread per row of the text
|
|
91
90
|
* table, through the table's page iterator, writing the text's glyph count or zero into `counts`, the list the
|
|
92
91
|
* scan sums.
|
|
93
92
|
*
|
|
94
93
|
* A text counts none of its glyphs when it is at another site, has no glyphs, is wholly transparent, or the box of
|
|
95
|
-
* its bounds in the world (`text_scene_box`) misses the camera's frustum.
|
|
94
|
+
* its bounds in the world (`text_scene_box`) misses the camera's frustum.
|
|
96
95
|
*
|
|
97
96
|
* @type {ComputeShader}
|
|
98
97
|
*/
|
|
@@ -13,8 +13,8 @@ export const TEXT_FACING_DRAW_RESOURCES: ShaderResourceSetDescriptor;
|
|
|
13
13
|
* far outside is still partly covered. The fragment stage finds how much of its pixel the outline covers. The
|
|
14
14
|
* quads are square to the target, so two pixels on a ray share it (`contour_fill_coverage_quad`).
|
|
15
15
|
*
|
|
16
|
-
* Out comes the text's colour, straight, with its opacity scaled by
|
|
17
|
-
* what it holds.
|
|
16
|
+
* Out comes the text's colour as the canvas holds it (`text_canvas_color`), straight, with its opacity scaled by
|
|
17
|
+
* the coverage, for the canvas to blend over what it holds.
|
|
18
18
|
*
|
|
19
19
|
* @type {ShaderDescriptor}
|
|
20
20
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shader_text_facing_draw.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/text/shaders/shader_text_facing_draw.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"shader_text_facing_draw.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/text/shaders/shader_text_facing_draw.js"],"names":[],"mappings":"AAkJA;;;GAGG;AACH,qEAFa,wBAAwB,CAwBpC;AA5JD,qEAA4E;AAU5E;;;;;;;;;;;;;GAaG;AACH,sCAFU,gBAAgB,CAoFvB;yCAzHsC,iEAAiE;4CAI9D,sDAAsD;iCACjE,kCAAkC"}
|
|
@@ -10,6 +10,7 @@ import { WebGPUArray } from "../../shader/type/WebGPUArray.js";
|
|
|
10
10
|
import { WebGPUBufferType } from "../../shader/type/WebGPUBufferType.js";
|
|
11
11
|
import { TEXT_DESCRIPTOR } from "../data/TEXT_DATABASE_SPEC.js";
|
|
12
12
|
import { chunk_text_glyph_read } from "../data/TEXT_GLYPH.js";
|
|
13
|
+
import { chunk_text_canvas_color } from "./chunk_text_canvas_color.js";
|
|
13
14
|
import { chunk_text_facing } from "./chunk_text_facing.js";
|
|
14
15
|
import { TEXT_VIEW_STRUCT } from "./TEXT_VIEW_STRUCT.js";
|
|
15
16
|
|
|
@@ -32,8 +33,8 @@ TEXT_FACING_DRAW_RESOURCES.createGroup()
|
|
|
32
33
|
* far outside is still partly covered. The fragment stage finds how much of its pixel the outline covers. The
|
|
33
34
|
* quads are square to the target, so two pixels on a ray share it (`contour_fill_coverage_quad`).
|
|
34
35
|
*
|
|
35
|
-
* Out comes the text's colour, straight, with its opacity scaled by
|
|
36
|
-
* what it holds.
|
|
36
|
+
* Out comes the text's colour as the canvas holds it (`text_canvas_color`), straight, with its opacity scaled by
|
|
37
|
+
* the coverage, for the canvas to blend over what it holds.
|
|
37
38
|
*
|
|
38
39
|
* @type {ShaderDescriptor}
|
|
39
40
|
*/
|
|
@@ -51,6 +52,7 @@ struct TextGlyphVertex {
|
|
|
51
52
|
@location(2) @interpolate(flat) band_count : vec2<u32>,
|
|
52
53
|
@location(3) @interpolate(flat) band_scale : vec2<f32>,
|
|
53
54
|
@location(4) @interpolate(flat) band_offset : vec2<f32>,
|
|
55
|
+
// as the canvas holds it
|
|
54
56
|
@location(5) @interpolate(flat) color : vec4<f32>,
|
|
55
57
|
}
|
|
56
58
|
|
|
@@ -92,7 +94,7 @@ fn vs_main(@builtin(vertex_index) vertex_index : u32, @builtin(instance_index) i
|
|
|
92
94
|
out.band_count = shape.band_count;
|
|
93
95
|
out.band_scale = shape.band_scale;
|
|
94
96
|
out.band_offset = shape.band_offset;
|
|
95
|
-
out.color = record.color;
|
|
97
|
+
out.color = vec4<f32>(text_canvas_color(text_view, record.color.rgb), record.color.a);
|
|
96
98
|
|
|
97
99
|
return out;
|
|
98
100
|
}
|
|
@@ -114,6 +116,7 @@ fn fs_main(in : TextGlyphVertex) -> @location(0) vec4<f32> {
|
|
|
114
116
|
chunk_text_glyph_read,
|
|
115
117
|
chunk_scene_database_access,
|
|
116
118
|
chunk_text_facing,
|
|
119
|
+
chunk_text_canvas_color,
|
|
117
120
|
chunk_contour_fill_coverage_quad,
|
|
118
121
|
]
|
|
119
122
|
),
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {GPUTextureFormat} format of the colour target
|
|
3
|
+
* @returns {RenderPipelineDescriptor} the same one for the same format
|
|
4
|
+
*/
|
|
5
|
+
export function text_facing_draw_shadow_pipeline(format: GPUTextureFormat): RenderPipelineDescriptor;
|
|
6
|
+
/**
|
|
7
|
+
* The shadows of texts that face the camera: the glyphs of each text that has one, drawn as `shader_text_facing_draw`
|
|
8
|
+
* draws them, moved by the text's shadow offset and in its shadow colour. An instance is a glyph of the view's
|
|
9
|
+
* glyph list; a glyph of a text with no shadow to show (`text_facing_shadow_shows`) is given no area.
|
|
10
|
+
*
|
|
11
|
+
* The shadow is as sharp as the text. Its opacity is its colour's scaled by the text's, so a text that fades takes
|
|
12
|
+
* its shadow with it.
|
|
13
|
+
*
|
|
14
|
+
* @type {ShaderDescriptor}
|
|
15
|
+
*/
|
|
16
|
+
export const shader_text_facing_draw_shadow: ShaderDescriptor;
|
|
17
|
+
import { RenderPipelineDescriptor } from "../../../descriptor/pipeline/render/RenderPipelineDescriptor.js";
|
|
18
|
+
import { ShaderDescriptor } from "../../shader/ShaderDescriptor.js";
|
|
19
|
+
//# sourceMappingURL=shader_text_facing_draw_shadow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shader_text_facing_draw_shadow.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/text/shaders/shader_text_facing_draw_shadow.js"],"names":[],"mappings":"AAiIA;;;GAGG;AACH,4EAFa,wBAAwB,CAwBpC;AA/ID;;;;;;;;;GASG;AACH,6CAFU,gBAAgB,CAqFvB;yCAxGsC,iEAAiE;iCAIzE,kCAAkC"}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { ColorTargetState } from "../../../descriptor/pipeline/render/ColorTargetState.js";
|
|
2
|
+
import { RenderPipelineDescriptor } from "../../../descriptor/pipeline/render/RenderPipelineDescriptor.js";
|
|
3
|
+
import { chunk_contour_fill_coverage_quad } from "../../contour_fill/chunk_contour_fill_coverage_quad.js";
|
|
4
|
+
import { chunk_scene_database_access } from "../../scene/chunk_scene_database_access.js";
|
|
5
|
+
import { CodeChunk } from "../../shader/compiler/CodeChunk.js";
|
|
6
|
+
import { ShaderDescriptor } from "../../shader/ShaderDescriptor.js";
|
|
7
|
+
import { TEXT_DESCRIPTOR } from "../data/TEXT_DATABASE_SPEC.js";
|
|
8
|
+
import { chunk_text_glyph_read } from "../data/TEXT_GLYPH.js";
|
|
9
|
+
import { chunk_text_canvas_color } from "./chunk_text_canvas_color.js";
|
|
10
|
+
import { chunk_text_facing } from "./chunk_text_facing.js";
|
|
11
|
+
import { TEXT_FACING_DRAW_RESOURCES } from "./shader_text_facing_draw.js";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* The shadows of texts that face the camera: the glyphs of each text that has one, drawn as `shader_text_facing_draw`
|
|
15
|
+
* draws them, moved by the text's shadow offset and in its shadow colour. An instance is a glyph of the view's
|
|
16
|
+
* glyph list; a glyph of a text with no shadow to show (`text_facing_shadow_shows`) is given no area.
|
|
17
|
+
*
|
|
18
|
+
* The shadow is as sharp as the text. Its opacity is its colour's scaled by the text's, so a text that fades takes
|
|
19
|
+
* its shadow with it.
|
|
20
|
+
*
|
|
21
|
+
* @type {ShaderDescriptor}
|
|
22
|
+
*/
|
|
23
|
+
export const shader_text_facing_draw_shadow = ShaderDescriptor.from({
|
|
24
|
+
label: "Text Facing Draw / shadow",
|
|
25
|
+
resources: TEXT_FACING_DRAW_RESOURCES,
|
|
26
|
+
body: CodeChunk.from(
|
|
27
|
+
//language=WGSL
|
|
28
|
+
`
|
|
29
|
+
struct TextShadowGlyphVertex {
|
|
30
|
+
@builtin(position) clip : vec4<f32>,
|
|
31
|
+
// in the shape's units, y up
|
|
32
|
+
@location(0) position : vec2<f32>,
|
|
33
|
+
@location(1) @interpolate(flat) shape : u32,
|
|
34
|
+
@location(2) @interpolate(flat) band_count : vec2<u32>,
|
|
35
|
+
@location(3) @interpolate(flat) band_scale : vec2<f32>,
|
|
36
|
+
@location(4) @interpolate(flat) band_offset : vec2<f32>,
|
|
37
|
+
// the shadow's colour as the canvas holds it, its opacity scaled by the text's
|
|
38
|
+
@location(5) @interpolate(flat) color : vec4<f32>,
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const TEXT_SHADOW_GLYPH_QUAD_CORNERS = array<vec2<f32>, 6>(
|
|
42
|
+
vec2<f32>(0.0, 0.0), vec2<f32>(1.0, 0.0), vec2<f32>(1.0, 1.0),
|
|
43
|
+
vec2<f32>(0.0, 0.0), vec2<f32>(1.0, 1.0), vec2<f32>(0.0, 1.0),
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
@vertex
|
|
47
|
+
fn vs_main(@builtin(vertex_index) vertex_index : u32, @builtin(instance_index) instance_index : u32) -> TextShadowGlyphVertex {
|
|
48
|
+
let glyph = text_glyph_read(glyph_list[instance_index]);
|
|
49
|
+
let record = ${TEXT_DESCRIPTOR.marshalling_method_read}(&text_database, glyph.text);
|
|
50
|
+
|
|
51
|
+
if (!text_facing_shadow_shows(record)) {
|
|
52
|
+
// a glyph of a text with no shadow: here it is a quad of no area
|
|
53
|
+
var none : TextShadowGlyphVertex;
|
|
54
|
+
|
|
55
|
+
none.clip = vec4<f32>(0.0, 0.0, 0.0, 1.0);
|
|
56
|
+
|
|
57
|
+
return none;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
let global = scene_read_node(&scene_database, record.node).global;
|
|
61
|
+
|
|
62
|
+
let anchor = text_facing_anchor(text_view, global, record);
|
|
63
|
+
let shape = contour_fill_read_shape(&shapes, glyph.shape);
|
|
64
|
+
|
|
65
|
+
// half a pixel, in the shape's units
|
|
66
|
+
let margin = vec2<f32>(0.5 / (anchor.em * record.ems_per_shape_unit));
|
|
67
|
+
let position = mix(shape.bounds_min - margin, shape.bounds_max + margin, TEXT_SHADOW_GLYPH_QUAD_CORNERS[vertex_index]);
|
|
68
|
+
|
|
69
|
+
let pixel = text_facing_point(anchor, vec2<f32>(glyph.x, glyph.y), position, record.ems_per_shape_unit)
|
|
70
|
+
+ text_facing_shadow(anchor, record);
|
|
71
|
+
|
|
72
|
+
var out : TextShadowGlyphVertex;
|
|
73
|
+
|
|
74
|
+
out.clip = text_pixel_to_clip(pixel, text_view.viewport);
|
|
75
|
+
out.position = position;
|
|
76
|
+
out.shape = glyph.shape;
|
|
77
|
+
out.band_count = shape.band_count;
|
|
78
|
+
out.band_scale = shape.band_scale;
|
|
79
|
+
out.band_offset = shape.band_offset;
|
|
80
|
+
out.color = vec4<f32>(text_canvas_color(text_view, record.shadow_color.rgb), record.shadow_color.a * record.color.a);
|
|
81
|
+
|
|
82
|
+
return out;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
@fragment
|
|
86
|
+
fn fs_main(in : TextShadowGlyphVertex) -> @location(0) vec4<f32> {
|
|
87
|
+
let pixels_per_unit = 1.0 / fwidth(in.position);
|
|
88
|
+
|
|
89
|
+
let cover = contour_fill_coverage_quad(
|
|
90
|
+
&shapes, in.shape,
|
|
91
|
+
in.band_count, in.band_scale, in.band_offset,
|
|
92
|
+
in.position, pixels_per_unit
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
return vec4<f32>(in.color.rgb, in.color.a * cover);
|
|
96
|
+
}
|
|
97
|
+
`, [
|
|
98
|
+
TEXT_DESCRIPTOR.chunk_read,
|
|
99
|
+
chunk_text_glyph_read,
|
|
100
|
+
chunk_scene_database_access,
|
|
101
|
+
chunk_text_facing,
|
|
102
|
+
chunk_text_canvas_color,
|
|
103
|
+
chunk_contour_fill_coverage_quad,
|
|
104
|
+
]
|
|
105
|
+
),
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Over what the target holds, by the fragment's opacity; the target's own alpha is left as it is.
|
|
110
|
+
*/
|
|
111
|
+
const BLEND = {
|
|
112
|
+
color: {
|
|
113
|
+
srcFactor: "src-alpha",
|
|
114
|
+
dstFactor: "one-minus-src-alpha",
|
|
115
|
+
operation: "add",
|
|
116
|
+
},
|
|
117
|
+
alpha: {
|
|
118
|
+
srcFactor: "zero",
|
|
119
|
+
dstFactor: "one",
|
|
120
|
+
operation: "add",
|
|
121
|
+
},
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Pipelines by the format of the target they draw into.
|
|
126
|
+
* @type {Map<GPUTextureFormat, RenderPipelineDescriptor>}
|
|
127
|
+
*/
|
|
128
|
+
const pipelines = new Map();
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* @param {GPUTextureFormat} format of the colour target
|
|
132
|
+
* @returns {RenderPipelineDescriptor} the same one for the same format
|
|
133
|
+
*/
|
|
134
|
+
export function text_facing_draw_shadow_pipeline(format) {
|
|
135
|
+
let pipeline = pipelines.get(format);
|
|
136
|
+
|
|
137
|
+
if (pipeline === undefined) {
|
|
138
|
+
const code = shader_text_facing_draw_shadow.source;
|
|
139
|
+
|
|
140
|
+
pipeline = RenderPipelineDescriptor.from({
|
|
141
|
+
label: `${shader_text_facing_draw_shadow.label} / ${format}`,
|
|
142
|
+
layout: TEXT_FACING_DRAW_RESOURCES.generatePipelineLayout(GPUShaderStage.VERTEX | GPUShaderStage.FRAGMENT),
|
|
143
|
+
vertex: { module: { code }, entryPoint: "vs_main" },
|
|
144
|
+
fragment: {
|
|
145
|
+
module: { code },
|
|
146
|
+
entryPoint: "fs_main",
|
|
147
|
+
targets: [ColorTargetState.from({ format, blend: BLEND })],
|
|
148
|
+
},
|
|
149
|
+
primitive: { topology: "triangle-list", cullMode: "none" },
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
pipelines.set(format, pipeline);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
return pipeline;
|
|
156
|
+
}
|
|
@@ -11,7 +11,8 @@ export function text_facing_draw_stroked_pipeline(format: GPUTextureFormat): Ren
|
|
|
11
11
|
* fragment stage finds how much of its pixel the outline covers and how much the stroke along it does
|
|
12
12
|
* (`contour_fill_coverage_stroked`).
|
|
13
13
|
*
|
|
14
|
-
* Out comes the fill over the stroke as one layer,
|
|
14
|
+
* Out comes the fill over the stroke as one layer, in the two colours as the canvas holds them
|
|
15
|
+
* (`text_canvas_color`), the layer's colour straight and its opacity scaled by the text's: a
|
|
15
16
|
* fill that is not opaque shows the target through it, not the stroke under it, and a text that fades takes its
|
|
16
17
|
* stroke with it.
|
|
17
18
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shader_text_facing_draw_stroked.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/text/shaders/shader_text_facing_draw_stroked.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"shader_text_facing_draw_stroked.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/text/shaders/shader_text_facing_draw_stroked.js"],"names":[],"mappings":"AAqJA;;;GAGG;AACH,6EAFa,wBAAwB,CAwBpC;AAnKD;;;;;;;;;;;;;;GAcG;AACH,8CAFU,gBAAgB,CAoGvB;yCA5HsC,iEAAiE;iCAIzE,kCAAkC"}
|
|
@@ -6,6 +6,7 @@ import { CodeChunk } from "../../shader/compiler/CodeChunk.js";
|
|
|
6
6
|
import { ShaderDescriptor } from "../../shader/ShaderDescriptor.js";
|
|
7
7
|
import { TEXT_DESCRIPTOR } from "../data/TEXT_DATABASE_SPEC.js";
|
|
8
8
|
import { chunk_text_glyph_read } from "../data/TEXT_GLYPH.js";
|
|
9
|
+
import { chunk_text_canvas_color } from "./chunk_text_canvas_color.js";
|
|
9
10
|
import { chunk_text_facing } from "./chunk_text_facing.js";
|
|
10
11
|
import { TEXT_FACING_DRAW_RESOURCES } from "./shader_text_facing_draw.js";
|
|
11
12
|
|
|
@@ -17,7 +18,8 @@ import { TEXT_FACING_DRAW_RESOURCES } from "./shader_text_facing_draw.js";
|
|
|
17
18
|
* fragment stage finds how much of its pixel the outline covers and how much the stroke along it does
|
|
18
19
|
* (`contour_fill_coverage_stroked`).
|
|
19
20
|
*
|
|
20
|
-
* Out comes the fill over the stroke as one layer,
|
|
21
|
+
* Out comes the fill over the stroke as one layer, in the two colours as the canvas holds them
|
|
22
|
+
* (`text_canvas_color`), the layer's colour straight and its opacity scaled by the text's: a
|
|
21
23
|
* fill that is not opaque shows the target through it, not the stroke under it, and a text that fades takes its
|
|
22
24
|
* stroke with it.
|
|
23
25
|
*
|
|
@@ -37,6 +39,7 @@ struct TextStrokedGlyphVertex {
|
|
|
37
39
|
@location(2) @interpolate(flat) band_count : vec2<u32>,
|
|
38
40
|
@location(3) @interpolate(flat) band_scale : vec2<f32>,
|
|
39
41
|
@location(4) @interpolate(flat) band_offset : vec2<f32>,
|
|
42
|
+
// both as the canvas holds them
|
|
40
43
|
@location(5) @interpolate(flat) color : vec4<f32>,
|
|
41
44
|
@location(6) @interpolate(flat) stroke_color : vec4<f32>,
|
|
42
45
|
// how far the stroke shows past the outline, in the shape's units
|
|
@@ -83,8 +86,8 @@ fn vs_main(@builtin(vertex_index) vertex_index : u32, @builtin(instance_index) i
|
|
|
83
86
|
out.band_count = shape.band_count;
|
|
84
87
|
out.band_scale = shape.band_scale;
|
|
85
88
|
out.band_offset = shape.band_offset;
|
|
86
|
-
out.color = record.color;
|
|
87
|
-
out.stroke_color = record.stroke_color;
|
|
89
|
+
out.color = vec4<f32>(text_canvas_color(text_view, record.color.rgb), record.color.a);
|
|
90
|
+
out.stroke_color = vec4<f32>(text_canvas_color(text_view, record.stroke_color.rgb), record.stroke_color.a);
|
|
88
91
|
out.stroke_width = stroke_width;
|
|
89
92
|
|
|
90
93
|
return out;
|
|
@@ -116,6 +119,7 @@ fn fs_main(in : TextStrokedGlyphVertex) -> @location(0) vec4<f32> {
|
|
|
116
119
|
chunk_text_glyph_read,
|
|
117
120
|
chunk_scene_database_access,
|
|
118
121
|
chunk_text_facing,
|
|
122
|
+
chunk_text_canvas_color,
|
|
119
123
|
chunk_contour_fill_coverage_stroked,
|
|
120
124
|
]
|
|
121
125
|
),
|
|
@@ -24,7 +24,7 @@ export class GPUWaterQueries {
|
|
|
24
24
|
* @param {PipelineEnquiry} enquiry
|
|
25
25
|
*/
|
|
26
26
|
static enquirePipelines(enquiry: PipelineEnquiry): void;
|
|
27
|
-
static "__#
|
|
27
|
+
static "__#283@#execute"(pass: any, resources: any, context: any): void;
|
|
28
28
|
/**
|
|
29
29
|
* @param {object} options
|
|
30
30
|
* @param {GPUDevice} options.device
|