oidn-webgpu 0.0.0-stage → 0.6.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.
Files changed (95) hide show
  1. package/CHANGELOG.md +182 -0
  2. package/LICENSE +21 -0
  3. package/README.md +89 -2
  4. package/dist/oidn.js +6140 -0
  5. package/dist/oidn.umd.cjs +1513 -0
  6. package/lib/UNet.d.ts +161 -0
  7. package/lib/UNet.js +536 -0
  8. package/lib/UNet.js.map +1 -0
  9. package/lib/WGPUComputePass.d.ts +62 -0
  10. package/lib/WGPUComputePass.js +278 -0
  11. package/lib/WGPUComputePass.js.map +1 -0
  12. package/lib/WGPUFullQuadPass.d.ts +50 -0
  13. package/lib/WGPUFullQuadPass.js +261 -0
  14. package/lib/WGPUFullQuadPass.js.map +1 -0
  15. package/lib/backend.d.ts +1 -0
  16. package/lib/backend.js +39 -0
  17. package/lib/backend.js.map +1 -0
  18. package/lib/finalRgbShader.d.ts +13 -0
  19. package/lib/finalRgbShader.js +160 -0
  20. package/lib/finalRgbShader.js.map +1 -0
  21. package/lib/gpuTypes.d.ts +158 -0
  22. package/lib/gpuTypes.js +27 -0
  23. package/lib/gpuTypes.js.map +1 -0
  24. package/lib/graphOptimizer.d.ts +54 -0
  25. package/lib/graphOptimizer.js +216 -0
  26. package/lib/graphOptimizer.js.map +1 -0
  27. package/lib/hdr.d.ts +31 -0
  28. package/lib/hdr.js +340 -0
  29. package/lib/hdr.js.map +1 -0
  30. package/lib/hdrTransfer.d.ts +22 -0
  31. package/lib/hdrTransfer.js +128 -0
  32. package/lib/hdrTransfer.js.map +1 -0
  33. package/lib/main.d.ts +57 -0
  34. package/lib/main.js +24 -0
  35. package/lib/main.js.map +1 -0
  36. package/lib/modelSpec.d.ts +80 -0
  37. package/lib/modelSpec.js +270 -0
  38. package/lib/modelSpec.js.map +1 -0
  39. package/lib/native/denoise.d.ts +25 -0
  40. package/lib/native/denoise.js +223 -0
  41. package/lib/native/denoise.js.map +1 -0
  42. package/lib/native/program.d.ts +53 -0
  43. package/lib/native/program.js +310 -0
  44. package/lib/native/program.js.map +1 -0
  45. package/lib/native/recordingDevice.d.ts +125 -0
  46. package/lib/native/recordingDevice.js +247 -0
  47. package/lib/native/recordingDevice.js.map +1 -0
  48. package/lib/nativeUNet.d.ts +25 -0
  49. package/lib/nativeUNet.js +184 -0
  50. package/lib/nativeUNet.js.map +1 -0
  51. package/lib/nativeUNetCore.d.ts +202 -0
  52. package/lib/nativeUNetCore.js +2945 -0
  53. package/lib/nativeUNetCore.js.map +1 -0
  54. package/lib/process.d.ts +37 -0
  55. package/lib/process.js +328 -0
  56. package/lib/process.js.map +1 -0
  57. package/lib/resourceTracker.d.ts +26 -0
  58. package/lib/resourceTracker.js +65 -0
  59. package/lib/resourceTracker.js.map +1 -0
  60. package/lib/sanitize.d.ts +15 -0
  61. package/lib/sanitize.js +28 -0
  62. package/lib/sanitize.js.map +1 -0
  63. package/lib/tileScheduler.d.ts +61 -0
  64. package/lib/tileScheduler.js +199 -0
  65. package/lib/tileScheduler.js.map +1 -0
  66. package/lib/tza.d.ts +15 -0
  67. package/lib/tza.js +114 -0
  68. package/lib/tza.js.map +1 -0
  69. package/lib/webnnUNet.d.ts +52 -0
  70. package/lib/webnnUNet.js +535 -0
  71. package/lib/webnnUNet.js.map +1 -0
  72. package/package.json +43 -4
  73. package/src/UNet.ts +861 -0
  74. package/src/WGPUComputePass.ts +382 -0
  75. package/src/WGPUFullQuadPass.ts +348 -0
  76. package/src/backend.ts +42 -0
  77. package/src/finalRgbShader.ts +186 -0
  78. package/src/gpuTypes.ts +179 -0
  79. package/src/graphOptimizer.ts +301 -0
  80. package/src/hdr.ts +398 -0
  81. package/src/hdrTransfer.ts +169 -0
  82. package/src/main.ts +126 -0
  83. package/src/modelSpec.ts +414 -0
  84. package/src/native/core-profile.json +40 -0
  85. package/src/native/denoise.ts +268 -0
  86. package/src/native/program.ts +326 -0
  87. package/src/native/recordingDevice.ts +341 -0
  88. package/src/nativeUNet.ts +269 -0
  89. package/src/nativeUNetCore.ts +3735 -0
  90. package/src/process.ts +368 -0
  91. package/src/resourceTracker.ts +94 -0
  92. package/src/sanitize.ts +29 -0
  93. package/src/tileScheduler.ts +330 -0
  94. package/src/tza.ts +136 -0
  95. package/src/webnnUNet.ts +812 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,182 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project are documented in this file.
4
+
5
+ ## [Unreleased]
6
+
7
+ ## [0.6.0] - 2026-10-25
8
+
9
+ oidn-webgpu 0.6.0 is the first release under the new package name. It adds experimental native Rust and C APIs, sanitizes inputs and outputs like OIDN, and lowers default FP16 latency in Chrome by up to 19% on the measured GPUs. The package name is the only breaking change.
10
+
11
+ ### Breaking changes
12
+
13
+ - The package is renamed from `oidn-web` to `oidn-webgpu`. Replace the dependency and imports (`import { initUNetFromURL } from 'oidn-webgpu'`); the API is unchanged.
14
+
15
+ ### Added
16
+
17
+ - Experimental native denoising through Rust and C APIs on Metal, Vulkan or Direct3D 12. Rust hosts can share GPU buffers; the C API accepts CPU images. See the [native guide](native/README.md).
18
+ - Native releases provide precompiled C packages and a Rust crate with SHA-256 verified cores for Windows x86_64 MSVC, Linux x86_64 GNU, macOS x86_64 and macOS ARM64. The bundled crate builds without Node, npm, Zig or build-time downloads from GitHub.
19
+ - Native packages include standalone Rust and Windows MSVC applications for output validation and timing. The Rust application's Git dependency is pinned to the package source revision.
20
+ - Experimental `kernel: 'subgroup-matrix'` and `subgroupMatrix` tuning options. Browsers need `chromium-experimental-subgroup-matrix`; native hosts need wgpu cooperative-matrix support.
21
+
22
+ ### Changed
23
+
24
+ - Default FP16 denoising in Chrome has 11–19% lower latency on Apple M4 Max and 0–16% on NVIDIA RTX 4060 Laptop than 0.5.0 ([Performance](#performance)); first initialization takes longer. Output differs slightly from 0.5.0; `gemm: { decoderSubPixel: false }` restores the 0.5.0 decoder calculation. FP32 is unchanged.
25
+ - `getLastExecutionProfile()` sums network time over all tiles of an image instead of reporting only the first tile. Preprocessing and output conversion are excluded.
26
+
27
+ ### Fixed
28
+
29
+ - Browser CPU input preserves normalized `Float32Array` albedo and normal values instead of dividing them by 255. `tileExecute` now accepts floating-point auxiliary images in its TypeScript API; 8-bit auxiliary images still use [0, 255].
30
+ - Windows native packages build and link with MSVC. C consumers use the DLL CRT (`/MD`).
31
+ - Native cooperative-matrix denoising produces finite, repeatable output with shader runtime checks disabled on the tested NVIDIA Vulkan device.
32
+ - Native distributions include the required runtime license notices, and the crate declares the bundled components' licenses alongside MIT.
33
+ - Inputs and network outputs are sanitized like OIDN: NaN becomes 0, and color, albedo and normals are clamped to their valid ranges. Previously NaN or out-of-range input could spread across the image, HDR output could be negative and GPU LDR output could exceed 1.
34
+ - `examples/aux.*` are renamed to `examples/auxiliary.*` so the repository can be checked out on Windows, where `AUX` is a reserved file name.
35
+
36
+ ### Performance
37
+
38
+ Measured on 2026-10-24 with the [Mac benchmark suite](docs/development.md#benchmarks-and-gpu-checks) protocol:
39
+
40
+ - Cells are median milliseconds per image over 21 executions after 5 warmups, with no outliers removed. Parentheses show the latency reduction relative to 0.5.0 in Chrome.
41
+ - Each execution denoises one whole HDR image with albedo and normals (`inputScale=1`) in GPU-resident RGBA32F buffers and synchronizes before the next. Timings include preprocessing, network execution and output conversion; they exclude device creation, model preparation, uploads and readback.
42
+ - oidn-webgpu uses FP16 with default accumulation; native runs with shader runtime checks disabled, the C API default. Official OIDN loads the same weights: Small `rt_hdr_alb_nrm_small.tza` at fast quality, Base `rt_hdr_alb_nrm.tza` at high quality, Large `rt_hdr_calb_cnrm_large.tza` at high quality with clean auxiliary images.
43
+ - 720p = 1280 x 720, 1080p = 1920 x 1080, 1440p = 2560 x 1440. Image quality is not compared.
44
+
45
+ #### Apple M4 Max
46
+
47
+ 40 GPU cores, macOS 27.0.1, Chrome 155.0.8059.85, OIDN 2.5.1 Metal, revision `fd0d816`. Chrome subgroup matrix needs `--enable-unsafe-webgpu`; native uses Metal cooperative matrices. Large 720p comes from a separate run because every column, OIDN included, was 8–17% slower in the main run.
48
+
49
+ | Model | Input | 0.5.0 Chrome | Chrome | Chrome subgroup matrix | Native Metal | OIDN Metal |
50
+ | --- | --- | ---: | ---: | ---: | ---: | ---: |
51
+ | Small | 720p | 15.60 | 13.60 (↓12.8%) | 11.90 (↓23.7%) | 8.51 (↓45.4%) | 8.78 (↓43.7%) |
52
+ | Small | 1080p | 35.00 | 30.40 (↓13.1%) | 26.50 (↓24.3%) | 18.48 (↓47.2%) | 19.19 (↓45.2%) |
53
+ | Small | 1440p | 61.60 | 53.50 (↓13.1%) | 46.40 (↓24.7%) | 32.26 (↓47.6%) | 33.48 (↓45.7%) |
54
+ | Base | 720p | 28.20 | 22.90 (↓18.8%) | 20.20 (↓28.4%) | 14.55 (↓48.4%) | 15.91 (↓43.6%) |
55
+ | Base | 1080p | 62.90 | 51.20 (↓18.6%) | 45.00 (↓28.5%) | 32.09 (↓49.0%) | 35.12 (↓44.2%) |
56
+ | Base | 1440p | 123.60 | 103.70 (↓16.1%) | 81.90 (↓33.7%) | 58.59 (↓52.6%) | 65.42 (↓47.1%) |
57
+ | Large | 720p | 64.90 | 54.20 (↓16.5%) | 50.50 (↓22.2%) | 36.29 (↓44.1%) | 34.85 (↓46.3%) |
58
+ | Large | 1080p | 161.20 | 143.00 (↓11.3%) | 127.10 (↓21.2%) | 93.94 (↓41.7%) | 89.79 (↓44.3%) |
59
+ | Large | 1440p | 295.10 | 259.30 (↓12.1%) | 224.70 (↓23.9%) | 171.30 (↓42.0%) | 159.14 (↓46.1%) |
60
+
61
+ #### NVIDIA RTX 4060 Laptop
62
+
63
+ 8 GiB, Intel Core i9-13900H, Windows 11 build 26200, driver 566.14, Chrome 156.0.8078.48, OIDN 2.5.1 CUDA, on AC power, revision `b30a515`. Native uses Vulkan cooperative matrices; its output was not checked for correctness on this device.
64
+
65
+ | Model | Input | 0.5.0 Chrome | Chrome | Native Vulkan | OIDN CUDA |
66
+ | --- | --- | ---: | ---: | ---: | ---: |
67
+ | Small | 720p | 30.10 | 30.10 (0.0%) | 9.44 (↓68.6%) | 10.27 (↓65.9%) |
68
+ | Small | 1080p | 66.20 | 62.50 (↓5.6%) | 20.49 (↓69.1%) | 22.92 (↓65.4%) |
69
+ | Small | 1440p | 113.70 | 105.40 (↓7.3%) | 32.98 (↓71.0%) | 39.76 (↓65.0%) |
70
+ | Base | 720p | 58.90 | 51.00 (↓13.4%) | 15.36 (↓73.9%) | 20.02 (↓66.0%) |
71
+ | Base | 1080p | 121.00 | 101.80 (↓15.9%) | 34.05 (↓71.9%) | 45.45 (↓62.4%) |
72
+ | Base | 1440p | 195.50 | 166.80 (↓14.7%) | 59.50 (↓69.6%) | 78.51 (↓59.8%) |
73
+ | Large | 720p | 125.50 | 108.30 (↓13.7%) | 37.58 (↓70.1%) | 40.41 (↓67.8%) |
74
+ | Large | 1080p | 262.70 | 229.50 (↓12.6%) | 75.10 (↓71.4%) | 92.42 (↓64.8%) |
75
+ | Large | 1440p | 453.30 | 406.50 (↓10.3%) | 130.59 (↓71.2%) | 163.50 (↓63.9%) |
76
+
77
+ ## [0.5.0] - 2026-10-09
78
+
79
+ oidn-web 0.5.0 simplifies device setup, makes tiled execution always settle, and switches FP16 convolutions to implicit GEMM. It contains breaking changes for TypeScript callers that pass `adapterInfo`, for code that constructs `UNet` directly, and for code that relies on square tiles or per-frame tile pacing.
80
+
81
+ ### Performance
82
+
83
+ Measured with `npm run benchmark -- --direct-gemm-only` in headless Chrome, using the Clean Aux Large model with FP16. Times are medians. Performance depends on the browser, GPU, model, and tile size. Devices without `shader-f16` use FP32, which already used implicit GEMM in 0.4.0, so their gains are expected to be smaller.
84
+
85
+ | GPU | Input | 0.4.0 | 0.5.0 | Speedup |
86
+ | --- | --- | ---: | ---: | ---: |
87
+ | Apple GPU (macOS) | 512 x 512, one tile | 27.2 ms | 19.1 ms | 1.42x |
88
+ | Apple GPU (macOS) | 1920 x 1080, 512 px tiles (12 tiles) | 742 ms | 369 ms | 2.01x |
89
+ | NVIDIA RTX 4060 Laptop (Windows 11, Chrome 153) | 512 x 512, one tile | 339 ms | 39.7 ms | 8.55x |
90
+ | NVIDIA RTX 4060 Laptop (Windows 11, Chrome 153) | 1920 x 1080, 512 px tiles (12 tiles) | 8844 ms | 555 ms | 15.94x |
91
+
92
+ - Implicit GEMM is now the default for FP16. The 0.4.0 direct FP16 kernel was especially slow on the tested NVIDIA GPU. Network GPU time for a 512 x 512 tile drops from 26.8 ms to 18.5 ms on the Apple GPU, and from 360 ms to 38.5 ms on the RTX 4060.
93
+ - Overlap only on shared tile edges reduces the input each tile computes. With the direct kernel alone, the 1920 x 1080 case is about 1.5x faster than 0.4.0 on both GPUs.
94
+
95
+ ### Breaking changes
96
+
97
+ - `initUNetFromURL` and `initUNetFromBuffer` take `{ device }` as the second argument. `adapterInfo` was only needed by the removed TensorFlow.js backend and is no longer accepted by the type. Extra properties are ignored at runtime, but TypeScript rejects an object literal that still contains `adapterInfo`.
98
+ - `new UNet(tensors, device, options)` takes a `GPUDevice` instead of a `{ device, adapterInfo }` object.
99
+ - `tileExecute` now continues on the event loop between tiles by default instead of waiting for `requestAnimationFrame`. Pass `scheduling: 'animation-frame'` to keep pacing tiles to display frames.
100
+ - Tiles are balanced rectangles with overlap only on edges shared with another tile, instead of fixed-size squares. Tile count, position, and size reported to `progress` differ from 0.4.0. The default `dynamicTile.initialTileSize` is now 432.
101
+ - `UNetExecutionStats` no longer has `tileWidth` and `tileHeight`. Use `tileColumns`, `tileRows`, `tileOverlap`, `inputPixelCount`, and `inputShapeCount` instead.
102
+ - FP16 convolutions use implicit GEMM by default. Output differs slightly from 0.4.0 because accumulation order changed. Set `kernel: 'direct'` to reproduce the 0.4.0 FP16 path.
103
+
104
+ ### Added
105
+
106
+ - `hdrTransfer: 'log'` for RTLightmap HDR models, alongside the default PU transfer.
107
+ - `error` callback on `tileExecute` for asynchronous failures, WebGPU device loss, and exceptions thrown by `progress` or `done`. `progress` and `done` may return promises.
108
+ - `scheduling: 'event-loop' | 'animation-frame'`, `tileOverlap`, and `wholeImage` options on `tileExecute`.
109
+ - `prepareForImage(width, height)` to create per-shape GPU resources before the first denoise.
110
+ - `planTileGrid` and its `TilePlan`, `PlannedTile`, and `TileRect` types.
111
+ - Experimental `gemm` tuning options. These are intended for benchmarking and are not covered by semver.
112
+ - `hdrTransfer` and `activeExecutionCount` in `getRuntimeInfo()`, and the active GEMM configuration under `kernel.gemm`.
113
+
114
+ ### Changed
115
+
116
+ - Implicit GEMM tiles are selected by output alignment and GPU limits, with optimized addressing, weight layout, register tiles, shared-memory layout, and pooling access.
117
+ - The final RGB convolution uses an adaptive shared-memory cache.
118
+ - Adaptive tile sizing uses the smoothed P75 tile GPU time, excludes the cold first tile, ignores cancelled and single-tile work, and buckets input shapes to at most two sizes.
119
+ - `animation-frame` scheduling falls back to a 100 ms timer so execution still completes in hidden tabs.
120
+
121
+ ### Fixed
122
+
123
+ - Tiled execution always settles with `done` or `error`, or stops silently after abort, including when `requestAnimationFrame` never fires or the device is lost.
124
+ - Completed executions release their device-loss listeners.
125
+ - Edge tiles whose size is not a multiple of 16 replicate edge pixels into the padded model input.
126
+ - The npm package no longer includes benchmark results, tests, and scripts.
127
+
128
+ ### Migration notes
129
+
130
+ - Replace `{ device, adapterInfo }` with `{ device }`.
131
+ - Replace `new UNet(tensors, { device, adapterInfo }, options)` with `new UNet(tensors, device, options)`.
132
+ - Interactive renderers that share the GPU with OIDN should pass `scheduling: 'animation-frame'`.
133
+ - Pass an `error` callback to handle failures. Without one, failures are logged to the console.
134
+
135
+ ## [0.4.0] - 2026-08-20
136
+
137
+ oidn-web 0.4.0 replaces the TensorFlow.js inference stack with a purpose-built, model-driven WebGPU runtime. Existing `initUNetFromURL` and `initUNetFromBuffer` integrations remain supported while gaining native FP16, adaptive scheduling, runtime diagnostics, and stronger model validation.
138
+
139
+ ### Highlights
140
+
141
+ - Removed TensorFlow.js and its WebGPU backend from the runtime dependencies.
142
+ - Added a custom WGSL U-Net executor with automatic FP16 selection and a deterministic FP32 fallback.
143
+ - Added built-in topology descriptors for the current OIDN small and large RT models, including clean auxiliary variants.
144
+ - Reduced the reference Vite ESM bundle from approximately 168.8 KB to 31.1 KB gzip compared with 0.3.5, a reduction of about 82%.
145
+ - Reached a 27.6 ms median for a 512 x 512 Clean Aux Large inference on the tested Apple GPU, versus 35.0 ms for the TensorFlow.js baseline (1.27x faster). Performance depends on the browser, GPU, model, and tile size.
146
+
147
+ ### Added
148
+
149
+ - Model-driven graph planning and lifetime-aware activation-buffer reuse.
150
+ - Versioned `UNetModelSpec` descriptors, topology detection, and validation of tensor names, layouts, data types, byte lengths, kernel shapes, bias shapes, and graph channel flow.
151
+ - `modelSpec` initialization option for future or custom OIDN model topologies.
152
+ - `npm run model:inspect` for model hashes, tensor signatures, and descriptor compatibility checks.
153
+ - Dynamic tile sizing with configurable minimum, initial, and maximum tile sizes and a target GPU time.
154
+ - GPU queue backpressure between tiles to keep cancellation and rendering interaction responsive.
155
+ - Runtime diagnostics through `getRuntimeInfo()`, including the selected engine, precision, model, kernel capabilities, tile state, and resource statistics.
156
+ - Per-layer GPU profiling through `profileNextExecution()` and `getLastExecutionProfile()` when `timestamp-query` is enabled.
157
+ - Cross-version browser benchmarks with queue-complete timings, sampled output validation, TFJS baseline comparison, and per-layer GPU profiles.
158
+ - Explicit, idempotent resource disposal and resource lifecycle accounting.
159
+ - Automated model, graph, scheduler, resource leak, allocation rollback, and late-async-cleanup tests.
160
+
161
+ ### Changed
162
+
163
+ - U-Net inference now runs directly in WGSL. The stable `auto` engine selects the native WGSL backend and no longer initializes TensorFlow.js.
164
+ - FP16-capable devices retain TZA half-float weights and use short FP16 FMA accumulation groups folded into FP32 accumulators. The final output remains FP32.
165
+ - Devices without `shader-f16` automatically use native FP32 inference.
166
+ - Convolution tensors and activations use a blocked four-channel layout with channel-specialized shaders.
167
+ - Decoder `upsample + concat + conv` patterns are fused, and all network passes for a tile are encoded into one command buffer.
168
+ - Shape-independent pipelines are compiled asynchronously before initialization resolves to avoid first-denoise shader compilation stalls.
169
+ - `maxTileSize` is now a hard upper bound for the adaptive tile controller.
170
+ - A shared `GPUDevice` uses FP16 only when `shader-f16` was requested during device creation; WebGPU features cannot be enabled afterward.
171
+
172
+ ### Migration notes
173
+
174
+ - No changes are required for basic `initUNetFromURL` or `initUNetFromBuffer` usage.
175
+ - Call `dispose()` when a U-Net instance is no longer needed.
176
+ - When supplying an existing `GPUDevice`, request `shader-f16` before creating the device if FP16 inference is desired.
177
+ - Set `dynamicTile: false` to restore fixed-size tiling.
178
+
179
+ [Unreleased]: https://github.com/pissang/oidn-webgpu/compare/v0.6.0...HEAD
180
+ [0.6.0]: https://github.com/pissang/oidn-webgpu/compare/v0.5.0...v0.6.0
181
+ [0.5.0]: https://github.com/pissang/oidn-webgpu/compare/v0.4.0...v0.5.0
182
+ [0.4.0]: https://github.com/pissang/oidn-webgpu/compare/v0.3.5...v0.4.0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 pissang
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,90 @@
1
- # Temporary Holding Version
1
+ # oidn-webgpu
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ [Open Image Denoise](https://github.com/RenderKit/oidn) (OIDN) on WebGPU. It denoises path-traced images on the GPU, in browsers and natively through [wgpu](https://wgpu.rs).
4
+
5
+ > Formerly published as `oidn-web`; versions up to 0.5.0 remain available under that name.
6
+
7
+ | 2000 samples | 3 samples | 3 samples + denoised |
8
+ | :-------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------: |
9
+ | ![](https://github.com/pissang/oidn-webgpu/blob/main/examples/test/ground-truth.png 'Ground Truth') | ![](https://github.com/pissang/oidn-webgpu/blob/main/examples/test/noisy.png 'Noisy') | ![](https://github.com/pissang/oidn-webgpu/blob/main/examples/test/denoised.png 'Denoised') |
10
+
11
+ ## Runtimes
12
+
13
+ | Runtime | Status | Distribution | Guide |
14
+ | --- | --- | --- | --- |
15
+ | Browser (WebGPU) | Released (0.x) | npm `oidn-webgpu` | [docs/web.md](docs/web.md) |
16
+ | Rust, sharing the host's wgpu device and buffers | Experimental | Cargo Git dependency or bundled release crate | [native/README.md](native/README.md#rust-api) |
17
+ | C, CPU images in and out | Experimental | GitHub Releases or build from source | [native/README.md](native/README.md#c-api) |
18
+
19
+ Every runtime executes the same WGSL kernels, planned by the same TypeScript core. The [native guide](native/README.md) records tested GPU configurations and output validation.
20
+
21
+ ## Quick start (browser)
22
+
23
+ ```shell
24
+ npm i oidn-webgpu
25
+ ```
26
+
27
+ Weights are not in the package. Copy a `.tza` file from [`weights/`](weights/) or [oidn-weights](https://github.com/RenderKit/oidn-weights) and serve it with your app.
28
+
29
+ ```ts
30
+ import { initUNetFromURL } from 'oidn-webgpu';
31
+
32
+ const unet = await initUNetFromURL('/weights/rt_ldr.tza');
33
+ const noisy = ctx.getImageData(0, 0, width, height);
34
+
35
+ const abort = unet.tileExecute({
36
+ color: noisy,
37
+ progress(_image, tileData, tile) {
38
+ ctx.putImageData(tileData!, tile.x, tile.y);
39
+ },
40
+ done(denoised) {
41
+ ctx.putImageData(denoised, 0, 0);
42
+ },
43
+ error(reason) {
44
+ console.error(reason);
45
+ }
46
+ });
47
+ ```
48
+
49
+ HDR input, auxiliary images, GPU buffers, tiling and performance options are in the [browser guide](docs/web.md).
50
+
51
+ ## Choose weights
52
+
53
+ Pick the weights from what your renderer produces. The same files work in every runtime.
54
+
55
+ | File | Color | Auxiliary inputs | Browser options |
56
+ | --- | --- | --- | --- |
57
+ | `rt_ldr.tza` | LDR | none | `{}` |
58
+ | `rt_ldr_alb_nrm.tza` | LDR | albedo + normal | `{ aux: true }` |
59
+ | `rt_hdr.tza` | HDR | none | `{ hdr: true }` |
60
+ | `rt_hdr_alb_nrm.tza` | HDR | albedo + normal | `{ hdr: true, aux: true }` |
61
+ | `rt_hdr_alb_nrm_small.tza` | HDR | albedo + normal; faster, lower quality | `{ hdr: true, aux: true }` |
62
+ | `rt_hdr_calb_cnrm.tza` | HDR | noise-free albedo + normal | `{ hdr: true, aux: true }` |
63
+ | `rt_hdr_calb_cnrm_large.tza` | HDR | noise-free albedo + normal; slower, higher quality | `{ hdr: true, aux: true }` |
64
+ | `rtlightmap_hdr.tza` ([oidn-weights](https://github.com/RenderKit/oidn-weights)) | HDR lightmap | none | `{ hdr: true, hdrTransfer: 'log' }` |
65
+
66
+ The model size (small, default, large) is chosen by the file alone; no option changes. Loading throws if `aux` does not match the file's inputs. An HDR/LDR mismatch cannot be detected from the file, so set `hdr` to match the weights.
67
+
68
+ ## Documentation
69
+
70
+ | Document | Covers |
71
+ | --- | --- |
72
+ | [docs/web.md](docs/web.md) | Browser API: loading, inputs, `tileExecute`, GPU pipelines, tiling, precision, profiling |
73
+ | [native/README.md](native/README.md) | Rust and C APIs, image contracts, builds and precompiled packages |
74
+ | [docs/development.md](docs/development.md) | Architecture, build/test/benchmark commands, updating OIDN models, CI |
75
+ | [AGENTS.md](AGENTS.md) | Repository map and working rules for coding agents and contributors |
76
+ | [llms.txt](llms.txt) | Doc index for LLM tools |
77
+ | [CHANGELOG.md](CHANGELOG.md) | Release notes and migration steps |
78
+
79
+ ## Examples and users
80
+
81
+ - [Basic example](https://oidn-web-example.vercel.app/) ([code](https://github.com/pissang/oidn-web-example/blob/main/src/main.js)), built on the earlier `oidn-web` 0.3 package
82
+ - Local examples in [`examples/`](examples/): run `npm run dev` and open `/examples/basic.html`, `hdr.html`, `auxiliary.html` or `gpu.html`.
83
+ - [three-gpu-pathtracer `OIDNDenoiser`](https://github.com/gkjohnson/three-gpu-pathtracer/blob/main/src/webgpu/API.md#oidndenoiser)
84
+ - [Vector to 3D](https://www.figma.com/community/plugin/1264600219316901594/) Figma plugin
85
+
86
+ ## Credits and license
87
+
88
+ Inspired by Max Liani's series [DNND: a deep neural network dive](https://maxliani.wordpress.com/2023/03/17/dnnd-1-a-deep-neural-network-dive/).
89
+
90
+ Code is MIT licensed ([LICENSE](LICENSE)). The OIDN weights in [`weights/`](weights/) are Apache 2.0 ([weights/LICENSE.txt](weights/LICENSE.txt)).