@driftengine/core 4.1.3 → 4.1.4
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/CHANGELOG.json +328 -297
- package/README.md +1 -1
- package/dist/index.js +12 -2
- package/dist/render/backend/webgpu/gpuDrivenPass.d.ts +46 -0
- package/dist/render/backend/webgpu/gpuDrivenPass.js +105 -0
- package/dist/render/backend/webgpu/renderer.js +10 -2
- package/dist/render/shaders/flat/main.d.ts +1 -1
- package/dist/render/shaders/flat/main.js +91 -5
- package/dist/render/shaders/flat/pointShadow.d.ts +1 -1
- package/dist/render/shaders/flat/pointShadow.js +42 -16
- package/dist/render/shaders/flat/preamble.js +44 -7
- package/dist/render/shaders/generated/flat.wgsl.js +16 -16
- package/dist/render/textLayout.d.ts +58 -0
- package/dist/render/textLayout.js +83 -0
- package/dist/render/textRenderer.js +7 -3
- package/package.json +6 -6
- package/src/index.ts +12 -2
- package/src/render/backend/webgpu/gpuDrivenPass.ts +105 -0
- package/src/render/backend/webgpu/renderer.ts +14 -2
- package/src/render/shaders/flat/main.ts +91 -5
- package/src/render/shaders/flat/pointShadow.ts +42 -16
- package/src/render/shaders/flat/preamble.ts +44 -7
- package/src/render/shaders/generated/flat.wgsl.ts +16 -16
- package/src/render/textLayout.ts +88 -0
- package/src/render/textRenderer.ts +22 -3
|
@@ -883,16 +883,53 @@ uniform float uLiveAreaShadowWeight[MAX_AREA_LIGHTS];
|
|
|
883
883
|
* where a bias means what it looks like it means.
|
|
884
884
|
*/
|
|
885
885
|
/**
|
|
886
|
-
*
|
|
887
|
-
*
|
|
888
|
-
*
|
|
886
|
+
* Twelve places on a disk across the light ray, for filtering an omnidirectional shadow.
|
|
887
|
+
*
|
|
888
|
+
* **These were eight, and the count is why a penumbra was stippled.** The list used to be the
|
|
889
|
+
* eight corners and six faces of a cube, carried as \`vec3\` from the era when a tap offset a
|
|
890
|
+
* direction by a 3D vector. Nothing has read the third component since the map became
|
|
891
|
+
* octahedral — both filters take \`.xy\` — and flattening a cube's corners onto a plane makes
|
|
892
|
+
* pairs of them coincide: \`(1, 1, 1)\` and \`(1, 1, -1)\` are one 2D offset, four times over. So
|
|
893
|
+
* twelve taps asked eight questions and answered four of them twice, and every one of the eight
|
|
894
|
+
* sat on the rim at radius 1 or 1.414 with nothing in between. A coverage estimate from a ring
|
|
895
|
+
* moves in steps of two twelfths as the penumbra's edge sweeps a doubled pair across it, which
|
|
896
|
+
* is the size of the speckle that was reported.
|
|
897
|
+
*
|
|
898
|
+
* **The replacement is the golden-angle disk this repository already uses for ambient
|
|
899
|
+
* occlusion** — angle \`i\` turns of 137.5 degrees, radius \`sqrt((k + 0.5) / 12)\` — so the taps
|
|
900
|
+
* are spread evenly over the area rather than crowded on the rim or at the centre, and no two
|
|
901
|
+
* coincide. The nearest pair is 0.355 apart where the old set had a pair at zero.
|
|
902
|
+
*
|
|
903
|
+
* **The radii are dealt round rather than taken in order, and that is what makes a short filter
|
|
904
|
+
* work.** \`shadowFilterTaps\` is 4, 8 or 12 and the loop below simply stops early, so every
|
|
905
|
+
* prefix of this list is a filter somebody ships: in spiral order the first four taps would be
|
|
906
|
+
* the four innermost and a low profile would quietly get a filter a third of the width it asked
|
|
907
|
+
* for. Interleaved, the first four already span 0.21 to 0.91 of the disk's reach and sit around
|
|
908
|
+
* its centre rather than to one side, which is a small filter rather than a narrow one.
|
|
909
|
+
*
|
|
910
|
+
* **What it gives up** is a little softness. The old set put two thirds of its taps at the
|
|
911
|
+
* outermost radius, so it read the penumbra's widest part twice as often as an even disk does
|
|
912
|
+
* and drew a shadow edge softer than the emitter's size calls for; an even disk is the honest
|
|
913
|
+
* estimate and is very slightly crisper. **What would make it wrong** is a caller wanting the
|
|
914
|
+
* filter's *reach* changed — that is \`MAX_FILTER_RADIUS\`, and the outermost tap here is 1.384
|
|
915
|
+
* against the old 1.414 precisely so this change does not move it.
|
|
889
916
|
*/
|
|
890
917
|
#if POINT_SHADOWS
|
|
891
|
-
const
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
918
|
+
const vec2 PCF_OFFSETS[${MAX_SHADOW_FILTER_TAPS}] = vec2[${MAX_SHADOW_FILTER_TAPS}](
|
|
919
|
+
vec2( 0.289, 0.000), vec2(-0.767, 0.703), vec2( 0.067, -0.761), vec2( 0.766, 0.999),
|
|
920
|
+
vec2(-0.492, -0.087), vec2( 0.943, -0.600), vec2(-0.225, 0.836), vec2(-0.610, -1.174),
|
|
921
|
+
vec2( 0.606, 0.221), vec2(-1.100, 0.454), vec2( 0.406, -0.867), vec2( 0.414, 1.321)
|
|
895
922
|
);
|
|
923
|
+
/**
|
|
924
|
+
* The angle between the two tap sets a pair of neighbouring pixels uses. See \`pointShadow\`.
|
|
925
|
+
*
|
|
926
|
+
* Half the golden angle, because the offsets above are a golden-angle spiral: turning the whole
|
|
927
|
+
* set by half a step drops the second pixel's taps between the first pixel's arms rather than
|
|
928
|
+
* on top of them. Measured on the pair, the closest two of the twenty-four are 0.305 apart,
|
|
929
|
+
* against 0.175 for a half turn and 0.233 for a whole golden angle — so this is the choice that
|
|
930
|
+
* makes the pair's combined filter as even as the twelve it is built from.
|
|
931
|
+
*/
|
|
932
|
+
const float PCF_PAIR_TURN = 1.19998161;
|
|
896
933
|
#endif
|
|
897
934
|
|
|
898
935
|
/** A finite point-light shadow loses strength with the light that casts it. */`;
|