@driftengine/core 4.8.1 → 4.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.json +86 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -0
- package/dist/input/actionMap.d.ts +6 -1
- package/dist/input/actionMap.js +20 -7
- package/dist/input/input.d.ts +28 -0
- package/dist/input/input.js +71 -9
- package/dist/input/inputHarness.d.ts +9 -0
- package/dist/input/inputHarness.js +34 -2
- package/dist/render/backend/webgl2/renderer.d.ts +52 -3
- package/dist/render/backend/webgl2/renderer.js +151 -5
- package/dist/render/backend/webgpu/buffers.d.ts +2 -0
- package/dist/render/backend/webgpu/buffers.js +2 -0
- package/dist/render/backend/webgpu/flatPass.js +16 -7
- package/dist/render/backend/webgpu/pipelineCache.d.ts +40 -8
- package/dist/render/backend/webgpu/pipelineCache.js +76 -9
- package/dist/render/backend/webgpu/renderer.d.ts +56 -1
- package/dist/render/backend/webgpu/renderer.js +151 -26
- package/dist/render/mapsWithoutUvs.d.ts +24 -0
- package/dist/render/mapsWithoutUvs.js +24 -0
- package/dist/render/mesh.d.ts +2 -0
- package/dist/render/mesh.js +3 -0
- package/dist/render/particlePool.d.ts +15 -0
- package/dist/render/particlePool.js +72 -37
- package/dist/render/pass.d.ts +12 -0
- package/dist/render/renderQuality.d.ts +7 -6
- package/dist/render/shaders/flat/glassTint.d.ts +28 -0
- package/dist/render/shaders/flat/glassTint.js +31 -0
- package/dist/render/shaders/flat/index.d.ts +12 -0
- package/dist/render/shaders/flat/index.js +7 -1
- package/dist/render/shaders/flat/main.d.ts +1 -1
- package/dist/render/shaders/flat/main.js +60 -25
- package/dist/render/shaders/flat/surfaceEffects.d.ts +1 -1
- package/dist/render/shaders/flat/surfaceEffects.js +6 -2
- package/dist/render/shaders/generated/flat.wgsl.d.ts +64 -0
- package/dist/render/shaders/generated/flat.wgsl.js +102 -38
- package/dist/render/surfaceTexture.d.ts +2 -0
- package/dist/render/surfaceTexture.js +4 -0
- package/dist/render/viewModel.d.ts +29 -0
- package/dist/render/viewModel.js +35 -0
- package/package.json +6 -6
- package/src/index.ts +9 -1
- package/src/input/actionMap.ts +23 -8
- package/src/input/input.ts +79 -9
- package/src/input/inputHarness.ts +27 -2
- package/src/render/backend/webgl2/renderer.ts +166 -13
- package/src/render/backend/webgpu/buffers.ts +5 -0
- package/src/render/backend/webgpu/flatPass.ts +41 -25
- package/src/render/backend/webgpu/pipelineCache.ts +82 -8
- package/src/render/backend/webgpu/renderer.ts +151 -26
- package/src/render/mapsWithoutUvs.ts +43 -0
- package/src/render/mesh.ts +3 -0
- package/src/render/particlePool.ts +101 -54
- package/src/render/pass.ts +12 -0
- package/src/render/renderQuality.ts +7 -6
- package/src/render/shaders/flat/glassTint.ts +48 -0
- package/src/render/shaders/flat/index.ts +19 -1
- package/src/render/shaders/flat/main.ts +60 -25
- package/src/render/shaders/flat/surfaceEffects.ts +6 -2
- package/src/render/shaders/generated/flat.wgsl.ts +102 -38
- package/src/render/surfaceTexture.ts +5 -0
- package/src/render/viewModel.ts +41 -0
|
@@ -335,6 +335,11 @@ export class SurfaceTexture {
|
|
|
335
335
|
}
|
|
336
336
|
|
|
337
337
|
/** Bind the effects table to `unit`, or `fallback` for a texture given none. */
|
|
338
|
+
/** Whether this texture carries an effects table, which the lit program reads only once one exists. */
|
|
339
|
+
get hasEffects(): boolean {
|
|
340
|
+
return this.effectsTable !== null;
|
|
341
|
+
}
|
|
342
|
+
|
|
338
343
|
bindEffects(gl: WebGL2RenderingContext, unit: number, fallback: WebGLTexture): void {
|
|
339
344
|
gl.activeTexture(gl.TEXTURE0 + unit);
|
|
340
345
|
gl.bindTexture(gl.TEXTURE_2D, this.effectsTable ?? fallback);
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The slice of depth a view model is drawn into: the nearest share of the range.
|
|
3
|
+
*
|
|
4
|
+
* **A first-person view model — arms and a held weapon — must never go into the wall it is pushed
|
|
5
|
+
* against**, and clearing depth to draw it on top costs every pass that reads depth afterwards:
|
|
6
|
+
* ambient occlusion, depth of field and the fog all see a hole where the world was. Squeezing the
|
|
7
|
+
* view model's depth into the nearest sliver of the range does neither. Anything past the near
|
|
8
|
+
* plane in the world lands behind it, the world's depth is kept, and the view model still sorts
|
|
9
|
+
* against itself, at a fraction of the precision.
|
|
10
|
+
*
|
|
11
|
+
* **The near end is where the convention says it is**: 1 under reversed depth and 0 under the
|
|
12
|
+
* conventional sense, which a WebGL2 context without `EXT_clip_control` runs. Taken from the
|
|
13
|
+
* renderer's own `reversedDepth`, never from the constant, for the reason `depthConvention.ts`
|
|
14
|
+
* gives at length.
|
|
15
|
+
*
|
|
16
|
+
* **What it gives up**: a view model is in front of everything, so it cannot be drawn reaching
|
|
17
|
+
* behind a world object in its own frame — which is what a view model is for. And under temporal
|
|
18
|
+
* reconstruction its pixels take no motion of their own, because the motion pass matches the frame's
|
|
19
|
+
* depth exactly and a squeezed draw matches nothing; draw a view model with multisampling.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/** The share of depth a view model is drawn into when the caller names none: the nearest 1%. */
|
|
23
|
+
export const VIEW_MODEL_DEPTH_SHARE = 0.01;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Fill `out` with the `[min, max]` window depth a view model's draws are squeezed into.
|
|
27
|
+
*
|
|
28
|
+
* `share` is clamped to `[1e-4, 1]`: zero would collapse every view-model fragment onto one depth
|
|
29
|
+
* and lose its own sorting, and more than the whole range is no squeeze.
|
|
30
|
+
*/
|
|
31
|
+
export function viewModelDepthRange(
|
|
32
|
+
reversed: boolean,
|
|
33
|
+
share: number,
|
|
34
|
+
out: [number, number] | Float32Array,
|
|
35
|
+
): void {
|
|
36
|
+
const width = Number.isFinite(share)
|
|
37
|
+
? Math.min(1, Math.max(1e-4, share))
|
|
38
|
+
: VIEW_MODEL_DEPTH_SHARE;
|
|
39
|
+
out[0] = reversed ? 1 - width : 0;
|
|
40
|
+
out[1] = reversed ? 1 : width;
|
|
41
|
+
}
|