rayzee 10.0.0 → 11.0.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/README.md +252 -44
- package/dist/ActiveColor-YvuQq44O.js +13 -0
- package/dist/ArchiveImporter-BRQvLggb.js +4300 -0
- package/dist/AssetConfig-DSEntE65.js +30 -0
- package/dist/BidirectionalIntegrator-9lZQxFVH.js +934 -0
- package/dist/BufferLayout-D_IBo2ci.js +150 -0
- package/dist/ColorManagement-oeEk7oSu.js +1488 -0
- package/dist/EngineEvents-Ci8dVWCP.js +73 -0
- package/dist/EngineIssues-CIZnXHsF.js +72 -0
- package/dist/FileFormats-sPGJeCRc.js +102 -0
- package/dist/Logger-dDDGj9Av.js +97 -0
- package/dist/{NeuralRetouch-CYgkQY8Z.js → NeuralRetouch-BCXylThH.js} +8 -6
- package/dist/{NeuralSuperRes-PkgDLQcD.js → NeuralSuperRes-sZAeS142.js} +55 -120
- package/dist/PathTracer-CQPW06Mm.js +29971 -0
- package/dist/PhysicalSky-BvqCw_dy.js +1219 -0
- package/dist/RayzeeRenderer-COpwotpU.js +3551 -0
- package/dist/SolarLimb-CPaeZVwz.js +721 -0
- package/dist/ToneMapGPU-CjU3osDd.js +177 -0
- package/dist/ViewTransforms-CYN7bq2w.js +255 -0
- package/dist/WorkingMatrix-C6y233hT.js +27 -0
- package/dist/ZipReader-gDSWr0I5.js +98 -0
- package/dist/addons/archives.es.js +3 -0
- package/dist/addons/bidirectional.es.js +2 -0
- package/dist/addons/color.es.js +3 -0
- package/dist/addons/formats.es.js +2 -0
- package/dist/addons/physical-sky.es.js +2 -0
- package/dist/addons/storage.es.js +3 -0
- package/dist/archiveFormats-BZw7TiDp.js +75 -0
- package/dist/identity-DrQsGT2o.js +39 -0
- package/dist/openStorage-DwcBRUj7.js +820 -0
- package/dist/rayzee-core.es.js +12 -0
- package/dist/rayzee.es.js +2551 -44024
- package/dist/rayzee.umd.js +528 -487
- package/dist/sceneCachePolicy-BSSsKY98.js +443 -0
- package/dist/shared-BGBcSxBQ.js +17 -0
- package/package.json +23 -2
- package/src/Color/ActiveColor.js +34 -0
- package/src/Color/BasicColor.js +147 -0
- package/src/Color/ColorManagement.js +7 -31
- package/src/Color/ViewTransforms.js +5 -1
- package/src/EngineDefaults.js +62 -1029
- package/src/EngineEvents.js +2 -0
- package/src/EngineIssues.js +2 -0
- package/src/Headless.js +6 -5
- package/src/Passes/AIUpscaler.js +58 -141
- package/src/Passes/OIDNDenoiser.js +92 -65
- package/src/Passes/OIDNTemporalHistory.js +1 -1
- package/src/PathTracerApp.js +620 -4026
- package/src/Pipeline/PipelineContext.js +0 -4
- package/src/Platform.js +36 -0
- package/src/Processor/ArchiveCache.js +1 -1
- package/src/Processor/ArchiveImporter.js +1259 -0
- package/src/Processor/AssetLoader.js +327 -1763
- package/src/Processor/AtmosphereModel.js +1 -2
- package/src/Processor/BVHBuilder.js +14 -126
- package/src/Processor/BVHLeafFold.js +4 -6
- package/src/Processor/BVHRefitter.js +67 -46
- package/src/Processor/BufferLayout.js +291 -0
- package/src/Processor/EmissiveTriangleBuilder.js +1 -1
- package/src/Processor/EnvironmentExactTable.js +187 -0
- package/src/Processor/EquirectHDRInfo.js +30 -223
- package/src/Processor/FileFormats.js +116 -0
- package/src/Processor/GLTFDecoders.js +85 -0
- package/src/Processor/GLTFDiffuseTransmission.js +63 -0
- package/src/Processor/GeometryExtractor.js +15 -5
- package/src/Processor/HostMemory.js +7 -1
- package/src/Processor/IESParser.js +47 -35
- package/src/Processor/InstanceTable.js +1 -1
- package/src/Processor/KernelManager.js +35 -2
- package/src/Processor/MaterialPacking.js +10 -8
- package/src/Processor/PBRT/PBRTMaterials.js +129 -41
- package/src/Processor/PBRT/PBRTParser.js +30 -17
- package/src/Processor/PBRT/PBRTSceneBuilder.js +548 -37
- package/src/Processor/PBRT/PBRTTextureBake.js +154 -0
- package/src/Processor/PBRT/PFM.js +59 -0
- package/src/Processor/PackedRayBuffer.js +116 -9
- package/src/Processor/ParallelBVHBuilder.js +3 -6
- package/src/Processor/PhysicalSky.js +5 -4
- package/src/Processor/PlatformImageLoader.js +50 -6
- package/src/Processor/QueueManager.js +39 -5
- package/src/Processor/ReinsertionOptimizer.js +2 -2
- package/src/Processor/SceneProcessor.js +53 -62
- package/src/Processor/ShaderBuilder.js +6 -16
- package/src/Processor/SimpleSky.js +1 -62
- package/src/Processor/SolarLimb.js +3 -0
- package/src/Processor/SplitBLAS.js +1 -1
- package/src/Processor/StorageTexturePool.js +22 -1
- package/src/Processor/TLASBuilder.js +1 -3
- package/src/Processor/TextureBuckets.js +237 -0
- package/src/Processor/TextureCreator.js +181 -8
- package/src/Processor/ToneMapGPU.js +64 -15
- package/src/Processor/Workers/BVHRefitWorker.js +5 -2
- package/src/Processor/Workers/BVHSubtreeWorker.js +1 -34
- package/src/Processor/Workers/BVHWorker.js +5 -18
- package/src/Processor/Workers/CDFWorker.js +6 -183
- package/src/Processor/Workers/TexturesWorker.js +103 -18
- package/src/Processor/archiveFormats.js +7 -0
- package/src/Processor/utils.js +2 -1
- package/src/RayzeeRenderer.js +3899 -0
- package/src/RenderSettings.js +68 -62
- package/src/Stages/ASVGF.js +13 -14
- package/src/Stages/AutoExposure.js +17 -17
- package/src/Stages/BilateralFilter.js +2 -1
- package/src/Stages/Compositor.js +8 -23
- package/src/Stages/DenoiserSettings.js +182 -0
- package/src/Stages/EdgeFilter.js +2 -1
- package/src/Stages/MotionVector.js +1 -1
- package/src/Stages/NRD.js +11 -5
- package/src/Stages/NormalDepth.js +12 -8
- package/src/Stages/PathTracer.js +338 -43
- package/src/Stages/PathTracerStage.js +69 -66
- package/src/Stages/Variance.js +1 -1
- package/src/Storage/BLASCache.js +1 -1
- package/src/Storage/CDFCache.js +18 -17
- package/src/Storage/DownloadCache.js +1 -1
- package/src/Storage/SceneGraphCodec.js +46 -3
- package/src/Storage/SpillStore.js +1 -1
- package/src/Storage/StorageManager.js +45 -9
- package/src/Storage/areas.js +4 -0
- package/src/TSL/BVHTraversal.js +50 -25
- package/src/TSL/Bidirectional.js +204 -0
- package/src/TSL/BidirectionalLamps.js +132 -0
- package/src/TSL/Clearcoat.js +15 -6
- package/src/TSL/Common.js +20 -15
- package/src/TSL/ConnectKernel.js +147 -0
- package/src/TSL/Debugger.js +1 -1
- package/src/TSL/Displacement.js +4 -3
- package/src/TSL/EmissiveSampling.js +65 -18
- package/src/TSL/Environment.js +77 -106
- package/src/TSL/EnvironmentCDF.js +85 -39
- package/src/TSL/ExtendKernel.js +8 -3
- package/src/TSL/FinalWriteKernel.js +4 -4
- package/src/TSL/GenerateKernel.js +18 -4
- package/src/TSL/HitFacet.js +35 -5
- package/src/TSL/LightBVHSampling.js +40 -9
- package/src/TSL/LightGenerateKernel.js +293 -0
- package/src/TSL/LightGuide.js +198 -0
- package/src/TSL/LightSplatKernel.js +165 -0
- package/src/TSL/LightVisibility.js +111 -0
- package/src/TSL/LightsCore.js +13 -38
- package/src/TSL/LightsDirect.js +28 -29
- package/src/TSL/LightsIndirect.js +3 -1
- package/src/TSL/LightsSampling.js +239 -51
- package/src/TSL/MaterialEvaluation.js +113 -31
- package/src/TSL/MaterialProperties.js +44 -17
- package/src/TSL/MaterialTransmission.js +52 -47
- package/src/TSL/MergeKernel.js +218 -0
- package/src/TSL/PathTracerCore.js +65 -29
- package/src/TSL/Random.js +5 -1
- package/src/TSL/SceneResources.js +51 -0
- package/src/TSL/ShadeKernel.js +964 -101
- package/src/TSL/Struct.js +10 -0
- package/src/TSL/Sun.js +1 -1
- package/src/TSL/TextureSampling.js +66 -61
- package/src/addons/archives.js +14 -0
- package/src/addons/bidirectional.js +13 -0
- package/src/addons/color.js +32 -0
- package/src/addons/formats.js +16 -0
- package/src/addons/physicalSky.js +14 -0
- package/src/addons/storage.js +19 -0
- package/src/core.js +31 -0
- package/src/index.js +13 -23
- package/src/integrators/BidirectionalIntegrator.js +833 -0
- package/src/managers/AnimationManager.js +88 -6
- package/src/managers/CameraManager.js +103 -46
- package/src/managers/DenoisingManager.js +14 -10
- package/src/managers/EnvironmentManager.js +125 -103
- package/src/managers/GoboManager.js +9 -0
- package/src/managers/MaterialDataManager.js +48 -37
- package/src/managers/UniformManager.js +32 -10
- package/dist/ToneMapGPU-B6XIe3DU.js +0 -544
- package/dist/rolldown-runtime-CAFD8bLK.js +0 -11
- package/src/Processor/TreeletOptimizer.js +0 -574
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
|
|
2
|
+
// Ray distance NormalDepth writes on a miss. Max finite half-float, so miss−miss diffs stay 0
|
|
3
|
+
// rather than Inf−Inf=NaN.
|
|
4
|
+
export const GBUFFER_MISS_DEPTH = 65504.0;
|
|
5
|
+
export const GBUFFER_MISS_THRESHOLD = 6e4;
|
|
6
|
+
|
|
7
|
+
// Albedo demodulation safety floor. ASVGF and BilateralFilter MUST use the
|
|
8
|
+
// same value — demod (`color / safeAlbedo`) and remod (`lighting * safeAlbedo`)
|
|
9
|
+
// only round-trip exactly when both sides agree.
|
|
10
|
+
export const ALBEDO_EPS = 0.01;
|
|
11
|
+
|
|
12
|
+
export const ASVGF_QUALITY_PRESETS = {
|
|
13
|
+
// phiColor / phiDepth are RELATIVE tolerances (fractions). Bigger = more
|
|
14
|
+
// permissive. The adaptive temporal gradient (gradientStrength > 0) is always
|
|
15
|
+
// on: it measures real change in units of noise σ (gradientSigmaScale), so a
|
|
16
|
+
// static scene reads ~0 (no convergence penalty) and only moving lights / anim
|
|
17
|
+
// / disocclusion drop history. See ASVGF._buildGradientCompute.
|
|
18
|
+
low: {
|
|
19
|
+
temporalAlpha: 0.1,
|
|
20
|
+
gradientStrength: 0.8,
|
|
21
|
+
gradientSigmaScale: 2.5,
|
|
22
|
+
gradientNoiseFloor: 0.05,
|
|
23
|
+
atrousIterations: 3,
|
|
24
|
+
phiColor: 1.0,
|
|
25
|
+
phiNormal: 64.0,
|
|
26
|
+
phiDepth: 0.1,
|
|
27
|
+
phiLuminance: 6.0,
|
|
28
|
+
maxAccumFrames: 16,
|
|
29
|
+
varianceBoost: 0.5
|
|
30
|
+
},
|
|
31
|
+
medium: {
|
|
32
|
+
temporalAlpha: 0.03,
|
|
33
|
+
gradientStrength: 1.0,
|
|
34
|
+
gradientSigmaScale: 2.5,
|
|
35
|
+
gradientNoiseFloor: 0.05,
|
|
36
|
+
atrousIterations: 4,
|
|
37
|
+
phiColor: 0.5,
|
|
38
|
+
phiNormal: 128.0,
|
|
39
|
+
phiDepth: 0.05,
|
|
40
|
+
phiLuminance: 4.0,
|
|
41
|
+
maxAccumFrames: 64,
|
|
42
|
+
varianceBoost: 1.0
|
|
43
|
+
},
|
|
44
|
+
high: {
|
|
45
|
+
temporalAlpha: 0.0,
|
|
46
|
+
gradientStrength: 1.0,
|
|
47
|
+
gradientSigmaScale: 2.5,
|
|
48
|
+
gradientNoiseFloor: 0.05,
|
|
49
|
+
atrousIterations: 6,
|
|
50
|
+
phiColor: 0.3,
|
|
51
|
+
phiNormal: 256.0,
|
|
52
|
+
phiDepth: 0.02,
|
|
53
|
+
phiLuminance: 2.0,
|
|
54
|
+
maxAccumFrames: 128,
|
|
55
|
+
varianceBoost: 1.5
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
// normHitDist = hitDist / (A + B·viewZ). A constant, not a uniform: the Shade write and the NRD
|
|
60
|
+
// decode must agree, and the normalization is a pure round trip.
|
|
61
|
+
export const NRD_HIT_DIST_A = 3.0;
|
|
62
|
+
export const NRD_HIT_DIST_B = 0.1;
|
|
63
|
+
|
|
64
|
+
// NRD ReBLUR port (Stages/NRD.js). Names follow nrd::ReblurSettings so NVIDIA's tuning notes apply.
|
|
65
|
+
export const NRD_DEFAULTS = {
|
|
66
|
+
maxAccumulatedFrameNum: 30,
|
|
67
|
+
maxFastAccumulatedFrameNum: 6,
|
|
68
|
+
maxStabilizedFrameNum: 63,
|
|
69
|
+
historyFixFrameNum: 3,
|
|
70
|
+
historyFixBasePixelStride: 14,
|
|
71
|
+
prepassBlurRadius: 30,
|
|
72
|
+
minBlurRadius: 1,
|
|
73
|
+
maxBlurRadius: 30,
|
|
74
|
+
lobeAngleFraction: 0.15,
|
|
75
|
+
roughnessFraction: 0.15,
|
|
76
|
+
planeDistanceSensitivity: 0.02,
|
|
77
|
+
minHitDistanceWeight: 0.1,
|
|
78
|
+
fastHistoryClampingSigmaScale: 2.0,
|
|
79
|
+
fireflySuppressorMinRelativeScale: 2.0,
|
|
80
|
+
enableAntiFirefly: true,
|
|
81
|
+
antilagLuminanceSigmaScale: 2.0,
|
|
82
|
+
antilagLuminanceSensitivity: 3.0,
|
|
83
|
+
disocclusionThreshold: 0.01,
|
|
84
|
+
convergenceS: 1.0,
|
|
85
|
+
convergenceB: 0.2,
|
|
86
|
+
convergenceP: 0.8,
|
|
87
|
+
// Share of the lobe the normal weight accepts before any history exists. NRD's own constant is
|
|
88
|
+
// 0.75, which its source flags as probably too much; at that width it smears curved surfaces.
|
|
89
|
+
lobeVolumePercent: 0.1,
|
|
90
|
+
// Progressive handover: input sample count at which the denoiser passes the render through untouched.
|
|
91
|
+
// 0 = 2 · maxAccumulatedFrameNum.
|
|
92
|
+
handoverFrames: 0,
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
// Keys a preset may override. Applying one resets every key to its default first, so a preset only
|
|
96
|
+
// states its deltas and `medium` can be empty.
|
|
97
|
+
export const NRD_PRESET_KEYS = [
|
|
98
|
+
'maxAccumulatedFrameNum', 'maxFastAccumulatedFrameNum', 'maxStabilizedFrameNum',
|
|
99
|
+
'historyFixFrameNum', 'prepassBlurRadius', 'maxBlurRadius', 'enableAntiFirefly',
|
|
100
|
+
];
|
|
101
|
+
|
|
102
|
+
export const NRD_QUALITY_PRESETS = {
|
|
103
|
+
// Short history + no pre-pass: most responsive, noisiest.
|
|
104
|
+
low: {
|
|
105
|
+
maxAccumulatedFrameNum: 16,
|
|
106
|
+
maxFastAccumulatedFrameNum: 4,
|
|
107
|
+
maxStabilizedFrameNum: 16,
|
|
108
|
+
historyFixFrameNum: 2,
|
|
109
|
+
prepassBlurRadius: 0,
|
|
110
|
+
maxBlurRadius: 20,
|
|
111
|
+
enableAntiFirefly: false,
|
|
112
|
+
},
|
|
113
|
+
// nrd::ReblurSettings defaults.
|
|
114
|
+
medium: {},
|
|
115
|
+
// Longer history and wider kernels: smoother, more lag on lighting change.
|
|
116
|
+
high: {
|
|
117
|
+
maxAccumulatedFrameNum: 45,
|
|
118
|
+
maxFastAccumulatedFrameNum: 8,
|
|
119
|
+
historyFixFrameNum: 4,
|
|
120
|
+
prepassBlurRadius: 40,
|
|
121
|
+
maxBlurRadius: 40,
|
|
122
|
+
},
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
const ASVGF_MEDIUM = ASVGF_QUALITY_PRESETS.medium;
|
|
126
|
+
|
|
127
|
+
// What the live denoisers, the final OIDN pass and the AI upscaler start with; a host's own state seeds from these.
|
|
128
|
+
export const DENOISER_DEFAULTS = {
|
|
129
|
+
denoiserStrategy: 'none', // the live view's denoiser: 'none' | 'edgeaware' | 'asvgf' | 'nrd' | 'oidn'
|
|
130
|
+
|
|
131
|
+
// EdgeAware denoiser (spatial-only SVGF à-trous). filterStrength: final blend
|
|
132
|
+
// (0 = raw, 1 = filtered). edgeAtrousIterations: à-trous passes (step 1,2,4,8,16).
|
|
133
|
+
// edgePhiLuminance: variance-scaled luminance edge-stop. edgePhiNormal: normal cone
|
|
134
|
+
// exponent. edgePhiDepth: RELATIVE depth tolerance (fraction of ray distance).
|
|
135
|
+
filterStrength: 1.0,
|
|
136
|
+
edgeAtrousIterations: 5,
|
|
137
|
+
edgePhiLuminance: 4.0,
|
|
138
|
+
edgePhiNormal: 64.0,
|
|
139
|
+
edgePhiDepth: 0.1,
|
|
140
|
+
|
|
141
|
+
enableOIDN: false,
|
|
142
|
+
oidnQuality: 'fast',
|
|
143
|
+
// OIDN as the live-view denoiser, refreshing the accumulating image. Set by choosing 'oidn' in
|
|
144
|
+
// the real-time denoiser list, so that only ever one thing denoises the live view — not by
|
|
145
|
+
// `enableOIDN`, which is the separate question of whether the finished image gets a pass.
|
|
146
|
+
continuousDenoise: false,
|
|
147
|
+
// Lower bound on the gap between cadence denoises. DenoisingManager also floors that gap at a
|
|
148
|
+
// multiple of what the last denoise actually cost, and above ~1024² that is what binds — this
|
|
149
|
+
// value only governs where a denoise is cheap. 8 ms measured 31 refreshes/sec at 512² at an
|
|
150
|
+
// unchanged sample rate; 50 ms measured 18/sec for nothing in return.
|
|
151
|
+
continuousDenoiseInterval: 8,
|
|
152
|
+
// While the view moves, feed OIDN the reprojected history of restarted frames, not one sample.
|
|
153
|
+
oidnTemporalHistory: true,
|
|
154
|
+
|
|
155
|
+
enableUpscaler: false,
|
|
156
|
+
upscalerScale: 2,
|
|
157
|
+
upscalerQuality: 'fast',
|
|
158
|
+
upscalerHdr: true,
|
|
159
|
+
|
|
160
|
+
// ASVGF runs its quality preset whenever it is switched on, so its values are that preset's.
|
|
161
|
+
enableASVGF: false,
|
|
162
|
+
asvgfQualityPreset: 'medium',
|
|
163
|
+
asvgfTemporalAlpha: ASVGF_MEDIUM.temporalAlpha,
|
|
164
|
+
asvgfAtrousIterations: ASVGF_MEDIUM.atrousIterations,
|
|
165
|
+
asvgfPhiColor: ASVGF_MEDIUM.phiColor,
|
|
166
|
+
asvgfPhiNormal: ASVGF_MEDIUM.phiNormal,
|
|
167
|
+
asvgfPhiDepth: ASVGF_MEDIUM.phiDepth,
|
|
168
|
+
asvgfPhiLuminance: ASVGF_MEDIUM.phiLuminance,
|
|
169
|
+
asvgfVarianceBoost: ASVGF_MEDIUM.varianceBoost,
|
|
170
|
+
asvgfMaxAccumFrames: ASVGF_MEDIUM.maxAccumFrames,
|
|
171
|
+
// Must be > 0: the gradient also rejects fireflies before the EMA smears them across
|
|
172
|
+
// ~1/alpha frames. At 0 the denoiser measures ~3x worse than no denoiser at 1 spp.
|
|
173
|
+
asvgfGradientStrength: ASVGF_MEDIUM.gradientStrength,
|
|
174
|
+
asvgfGradientSigmaScale: ASVGF_MEDIUM.gradientSigmaScale,
|
|
175
|
+
asvgfGradientNoiseFloor: ASVGF_MEDIUM.gradientNoiseFloor,
|
|
176
|
+
asvgfDebugMode: 0,
|
|
177
|
+
showAsvgfHeatmap: false,
|
|
178
|
+
|
|
179
|
+
// NRD (ReBLUR port) real-time denoiser — see NRD_DEFAULTS / NRD_QUALITY_PRESETS.
|
|
180
|
+
nrdQualityPreset: 'medium',
|
|
181
|
+
nrdDebugMode: 0,
|
|
182
|
+
};
|
package/src/Stages/EdgeFilter.js
CHANGED
|
@@ -5,7 +5,8 @@ import { RenderTarget, TextureNode, StorageTexture } from 'three/webgpu';
|
|
|
5
5
|
import { FloatType, RGBAFormat, LinearFilter, Box2, Vector2 } from 'three';
|
|
6
6
|
import { RenderStage, StageExecutionMode } from '../Pipeline/RenderStage.js';
|
|
7
7
|
import { luminance } from '../TSL/Common.js';
|
|
8
|
-
import {
|
|
8
|
+
import { MAX_STORAGE_TEXTURE_SIZE } from '../Processor/StorageTexturePool.js';
|
|
9
|
+
import { ALBEDO_EPS } from './DenoiserSettings.js';
|
|
9
10
|
|
|
10
11
|
// NormalDepth writes depth ≈ 65504 for miss (env/background) rays. This sits below
|
|
11
12
|
// the sentinel and above any real ray distance, so it's a clean hit/miss flag.
|
|
@@ -3,7 +3,7 @@ import { Fn, vec2, vec3, vec4, float, int, uint, ivec2, uvec2, uniform, If,
|
|
|
3
3
|
import { RenderTarget, TextureNode, StorageTexture } from 'three/webgpu';
|
|
4
4
|
import { HalfFloatType, RGBAFormat, NearestFilter, Matrix4, Box2, Vector2 } from 'three';
|
|
5
5
|
import { RenderStage, StageExecutionMode } from '../Pipeline/RenderStage.js';
|
|
6
|
-
import { MAX_STORAGE_TEXTURE_SIZE } from '../
|
|
6
|
+
import { MAX_STORAGE_TEXTURE_SIZE } from '../Processor/StorageTexturePool.js';
|
|
7
7
|
import { cameraRayPoint, cameraRayUniforms } from '../TSL/CameraRay.js';
|
|
8
8
|
|
|
9
9
|
/**
|
package/src/Stages/NRD.js
CHANGED
|
@@ -8,9 +8,8 @@ import { createStorageTexture } from '../Processor/StorageTexturePool.js';
|
|
|
8
8
|
import { sanitizeRGB, sanitize1, FP16_MAX } from '../TSL/Common.js';
|
|
9
9
|
import { cameraRayPoint, cameraRayUniforms, isOrthographic } from '../TSL/CameraRay.js';
|
|
10
10
|
import {
|
|
11
|
-
ALBEDO_EPS, GBUFFER_MISS_THRESHOLD as MISS_THRESHOLD,
|
|
12
|
-
|
|
13
|
-
} from '../EngineDefaults.js';
|
|
11
|
+
NRD_DEFAULTS, NRD_HIT_DIST_A, NRD_HIT_DIST_B, ALBEDO_EPS, GBUFFER_MISS_THRESHOLD as MISS_THRESHOLD,
|
|
12
|
+
} from './DenoiserSettings.js';
|
|
14
13
|
|
|
15
14
|
const NRD_EPS = 1e-6;
|
|
16
15
|
const NORMAL_ENCODING_ERROR = 1.5 / 255.0;
|
|
@@ -133,7 +132,7 @@ function hash01( n ) {
|
|
|
133
132
|
* Reads: pathtracer:color, pathtracer:albedo (.w = normHitDist), pathtracer:normalDepth,
|
|
134
133
|
* pathtracer:shadingNormal (.w = roughness), motionVector:screenSpace
|
|
135
134
|
* Publishes: nrd:output
|
|
136
|
-
* Events:
|
|
135
|
+
* Events: pipeline:historyReset
|
|
137
136
|
*/
|
|
138
137
|
export class NRD extends RenderStage {
|
|
139
138
|
|
|
@@ -148,6 +147,11 @@ export class NRD extends RenderStage {
|
|
|
148
147
|
this.pathTracer = options.pathTracer || null;
|
|
149
148
|
this.settings = { ...NRD_DEFAULTS, ...( options.settings || {} ) };
|
|
150
149
|
|
|
150
|
+
// The path tracer's hit distance, normalised by view depth as ReBLUR reads it (pathtracer:albedo.w).
|
|
151
|
+
this._releaseHitDistance = this.pathTracer?.requestOutput?.( 'hitDistance', {
|
|
152
|
+
encode: ( distance, viewZ ) => distance.div( max( viewZ.mul( NRD_HIT_DIST_B ).add( NRD_HIT_DIST_A ), float( 1e-4 ) ) ).clamp( 0.0, 1.0 ),
|
|
153
|
+
} ) ?? null;
|
|
154
|
+
|
|
151
155
|
const w = options.width || 1;
|
|
152
156
|
const h = options.height || 1;
|
|
153
157
|
|
|
@@ -1185,7 +1189,7 @@ export class NRD extends RenderStage {
|
|
|
1185
1189
|
|
|
1186
1190
|
setupEventListeners() {
|
|
1187
1191
|
|
|
1188
|
-
this.on( '
|
|
1192
|
+
this.on( 'pipeline:historyReset', () => this.resetHistory() );
|
|
1189
1193
|
|
|
1190
1194
|
}
|
|
1191
1195
|
|
|
@@ -1383,6 +1387,8 @@ export class NRD extends RenderStage {
|
|
|
1383
1387
|
|
|
1384
1388
|
dispose() {
|
|
1385
1389
|
|
|
1390
|
+
this._releaseHitDistance?.();
|
|
1391
|
+
this._releaseHitDistance = null;
|
|
1386
1392
|
this._disposeKernels();
|
|
1387
1393
|
this._disposeStorage();
|
|
1388
1394
|
this.outputTarget?.dispose();
|
|
@@ -3,12 +3,14 @@ import { Fn, vec2, vec4, float, int, uint, uvec2, uvec4, uniform, min, storage,
|
|
|
3
3
|
import { RenderTarget, StorageTexture } from 'three/webgpu';
|
|
4
4
|
import { HalfFloatType, RGBAFormat, RedIntegerFormat, UnsignedIntType, NearestFilter, Matrix4, Box2, Vector2 } from 'three';
|
|
5
5
|
import { RenderStage, StageExecutionMode } from '../Pipeline/RenderStage.js';
|
|
6
|
-
import { MAX_STORAGE_TEXTURE_SIZE } from '../
|
|
6
|
+
import { MAX_STORAGE_TEXTURE_SIZE } from '../Processor/StorageTexturePool.js';
|
|
7
|
+
import { GBUFFER_MISS_DEPTH } from './DenoiserSettings.js';
|
|
7
8
|
import { Ray, HitInfo, RayTracingMaterial, UVCache } from '../TSL/Struct.js';
|
|
8
9
|
import { traverseBVH } from '../TSL/BVHTraversal.js';
|
|
9
10
|
import { cameraRayOf, cameraRayUniforms } from '../TSL/CameraRay.js';
|
|
10
11
|
import { getMaterial } from '../TSL/Common.js';
|
|
11
|
-
import { computeUVCache, processNormal, processBump, processMetalnessRoughness, triangleUVTangent, buildBucketTextureNodes, refreshBucketTextureNodes
|
|
12
|
+
import { computeUVCache, processNormal, processBump, processMetalnessRoughness, triangleUVTangent, buildBucketTextureNodes, refreshBucketTextureNodes } from '../TSL/TextureSampling.js';
|
|
13
|
+
import { withSceneResources } from '../TSL/SceneResources.js';
|
|
12
14
|
|
|
13
15
|
/**
|
|
14
16
|
* NormalDepth — primary-ray G-buffer for SVGF gates.
|
|
@@ -207,11 +209,13 @@ export class NormalDepth extends RenderStage {
|
|
|
207
209
|
const triStorage = this._triStorageNode;
|
|
208
210
|
const bvhStorage = this._bvhStorageNode;
|
|
209
211
|
const matStorage = this._matStorageNode;
|
|
210
|
-
// Independent linear-pool bucket nodes for this pipeline (normal + bump)
|
|
211
|
-
// is never sampled here, so it gets placeholders.
|
|
212
|
-
// the graph is built so processNormal/processBump bake in THESE (per-pipeline) nodes.
|
|
212
|
+
// Independent linear-pool bucket nodes for this pipeline (normal + bump), in its kernel's build
|
|
213
|
+
// context (SceneResources.js). The sRGB pool is never sampled here, so it gets placeholders.
|
|
213
214
|
this._linearBuckets = buildBucketTextureNodes( this.pathTracer?.materialData?.linearBuckets );
|
|
214
|
-
|
|
215
|
+
const resources = {
|
|
216
|
+
srgbBuckets: buildBucketTextureNodes( null ), linearBuckets: this._linearBuckets,
|
|
217
|
+
shadowAlbedoMaps: null, goboMaps: null, iesProfiles: null, alphaShadows: null,
|
|
218
|
+
};
|
|
215
219
|
const camWorld = this.cameraWorldMatrix;
|
|
216
220
|
const camProjInv = this.cameraProjectionMatrixInverse;
|
|
217
221
|
const resW = this.resolutionWidth;
|
|
@@ -245,7 +249,7 @@ export class NormalDepth extends RenderStage {
|
|
|
245
249
|
|
|
246
250
|
const result = hit.didHit.select(
|
|
247
251
|
vec4( encodedNormal, depth ),
|
|
248
|
-
vec4( 0.0, 0.0, 0.0, float(
|
|
252
|
+
vec4( 0.0, 0.0, 0.0, float( GBUFFER_MISS_DEPTH ) )
|
|
249
253
|
);
|
|
250
254
|
|
|
251
255
|
textureStore(
|
|
@@ -308,7 +312,7 @@ export class NormalDepth extends RenderStage {
|
|
|
308
312
|
|
|
309
313
|
} );
|
|
310
314
|
|
|
311
|
-
this._computeNode = computeFn( camWorld, camProjInv ).compute(
|
|
315
|
+
this._computeNode = withSceneResources( computeFn( camWorld, camProjInv ), resources ).compute(
|
|
312
316
|
[ this._dispatchX, this._dispatchY, 1 ],
|
|
313
317
|
[ WG_SIZE, WG_SIZE, 1 ]
|
|
314
318
|
);
|