@hology/webgpu-renderer 0.1.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/LICENSE.md +32 -0
- package/README.md +428 -0
- package/dist/index.d.ts +1262 -0
- package/dist/index.js +1 -0
- package/package.json +43 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,1262 @@
|
|
|
1
|
+
import * as three from 'three';
|
|
2
|
+
import { Color, Vector2, Vector3, Vector4, Matrix3, Matrix4, Material, Texture, MaterialParameters, Object3D, PerspectiveCamera, OrthographicCamera, Scene, DirectionalLight } from 'three';
|
|
3
|
+
export { AmbientLight, BackSide, BatchedMesh, Bone, BoxGeometry, BufferAttribute, BufferGeometry, CanvasTexture, Color, CompressedArrayTexture, CompressedCubeTexture, CompressedTexture, CompressedArrayTexture as CompressedTextureArray, CubeTexture, Data3DTexture, DataArrayTexture, DataTexture, DepthTexture, DirectionalLight, DoubleSide, FrontSide, Group, HemisphereLight, InstancedMesh, MathUtils, Matrix4, Mesh, Object3D, OrthographicCamera, PerspectiveCamera, PlaneGeometry, PointLight, RepeatWrapping, Scene, Skeleton, SkinnedMesh, SphereGeometry, SpotLight, Texture, Vector2, Vector3, Vector4 } from 'three';
|
|
4
|
+
|
|
5
|
+
interface ComputeKernelDescriptor {
|
|
6
|
+
label?: string;
|
|
7
|
+
code: string;
|
|
8
|
+
entryPoint?: string;
|
|
9
|
+
bindGroupLayoutEntries: GPUBindGroupLayoutEntry[];
|
|
10
|
+
}
|
|
11
|
+
declare class ComputeKernel {
|
|
12
|
+
readonly layout: GPUBindGroupLayout;
|
|
13
|
+
readonly pipeline: GPUComputePipeline;
|
|
14
|
+
constructor(device: GPUDevice, descriptor: ComputeKernelDescriptor);
|
|
15
|
+
createBindGroup(device: GPUDevice, entries: GPUBindGroupEntry[], label?: string): GPUBindGroup;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
type ShaderDefineValue = string | number | boolean;
|
|
19
|
+
type ShaderDefines = Record<string, ShaderDefineValue | null | undefined>;
|
|
20
|
+
|
|
21
|
+
type UniformType = "f32" | "i32" | "u32" | "vec2<f32>" | "vec3<f32>" | "vec4<f32>" | "mat3x3<f32>" | "mat4x4<f32>";
|
|
22
|
+
type UniformValue = number | boolean | readonly number[] | Color | Vector2 | Vector3 | Vector4 | Matrix3 | Matrix4;
|
|
23
|
+
interface UniformDefinition {
|
|
24
|
+
type: UniformType;
|
|
25
|
+
value: UniformValue;
|
|
26
|
+
}
|
|
27
|
+
interface UniformLayoutEntry {
|
|
28
|
+
name: string;
|
|
29
|
+
offset: number;
|
|
30
|
+
type: UniformType;
|
|
31
|
+
}
|
|
32
|
+
interface UniformLayout {
|
|
33
|
+
byteLength: number;
|
|
34
|
+
entries: UniformLayoutEntry[];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
type WGSLStorageBufferVisibility = "vertex" | "fragment" | "vertex-fragment";
|
|
38
|
+
type WGSLSupportedVertexFormat = "float32" | "float32x2" | "float32x3" | "float32x4" | "uint32" | "uint32x2" | "uint32x3" | "uint32x4" | "sint32" | "sint32x2" | "sint32x3" | "sint32x4";
|
|
39
|
+
interface WGSLVertexAttributeBinding {
|
|
40
|
+
name: string;
|
|
41
|
+
shaderLocation: number;
|
|
42
|
+
format: WGSLSupportedVertexFormat;
|
|
43
|
+
stepMode?: GPUVertexStepMode;
|
|
44
|
+
defaultValue?: readonly number[];
|
|
45
|
+
}
|
|
46
|
+
declare const DEFAULT_WGSL_VERTEX_ATTRIBUTES: readonly WGSLVertexAttributeBinding[];
|
|
47
|
+
interface WGSLStorageBufferBinding {
|
|
48
|
+
buffer: GPUBuffer;
|
|
49
|
+
type: string;
|
|
50
|
+
visibility?: WGSLStorageBufferVisibility;
|
|
51
|
+
}
|
|
52
|
+
type WGSLSceneTextureSemantic = "sceneColor" | "sceneDepth";
|
|
53
|
+
type WGSLGraphTextureDimension = "2d" | "depth-2d" | "3d";
|
|
54
|
+
interface WGSLGraphTextureInput {
|
|
55
|
+
resource: string;
|
|
56
|
+
dimension: WGSLGraphTextureDimension;
|
|
57
|
+
sampleType?: "float" | "unfilterable-float" | "depth";
|
|
58
|
+
sampler?: "filtering" | "non-filtering" | "comparison";
|
|
59
|
+
requiresLatePass?: boolean;
|
|
60
|
+
}
|
|
61
|
+
interface WGSLShaderMaterialUniform {
|
|
62
|
+
type?: UniformType;
|
|
63
|
+
value: UniformValue | Texture;
|
|
64
|
+
}
|
|
65
|
+
type WGSLShaderMaterialUniformInput = UniformDefinition | WGSLShaderMaterialUniform | UniformValue | Texture;
|
|
66
|
+
interface WGSLShaderMaterialParameters extends MaterialParameters {
|
|
67
|
+
vertexShader: string;
|
|
68
|
+
fragmentShader: string;
|
|
69
|
+
depthVertexShader?: string | null;
|
|
70
|
+
depthFragmentShader?: string | null;
|
|
71
|
+
pointShadowVertexShader?: string | null;
|
|
72
|
+
pointShadowFragmentShader?: string | null;
|
|
73
|
+
defines?: ShaderDefines;
|
|
74
|
+
uniforms?: Record<string, WGSLShaderMaterialUniformInput>;
|
|
75
|
+
textures?: Record<string, Texture>;
|
|
76
|
+
sceneTextures?: Record<string, WGSLSceneTextureSemantic>;
|
|
77
|
+
graphTextures?: Record<string, WGSLGraphTextureInput>;
|
|
78
|
+
storageBuffers?: Record<string, WGSLStorageBufferBinding>;
|
|
79
|
+
vertexAttributes?: readonly WGSLVertexAttributeBinding[];
|
|
80
|
+
primitiveTopology?: GPUPrimitiveTopology;
|
|
81
|
+
/** Render triangle meshes as one-pixel triangle edges, matching Three.js wireframe materials. */
|
|
82
|
+
wireframe?: boolean;
|
|
83
|
+
}
|
|
84
|
+
declare class WGSLShaderMaterial extends Material {
|
|
85
|
+
readonly isWGSLShaderMaterial = true;
|
|
86
|
+
type: "WGSLShaderMaterial";
|
|
87
|
+
vertexShader: string;
|
|
88
|
+
fragmentShader: string;
|
|
89
|
+
depthVertexShader: string | null;
|
|
90
|
+
depthFragmentShader: string | null;
|
|
91
|
+
pointShadowVertexShader: string | null;
|
|
92
|
+
pointShadowFragmentShader: string | null;
|
|
93
|
+
defines: ShaderDefines;
|
|
94
|
+
uniforms: Record<string, UniformDefinition>;
|
|
95
|
+
textures: Record<string, Texture>;
|
|
96
|
+
sceneTextures: Record<string, WGSLSceneTextureSemantic>;
|
|
97
|
+
graphTextures: Record<string, WGSLGraphTextureInput>;
|
|
98
|
+
storageBuffers: Record<string, WGSLStorageBufferBinding>;
|
|
99
|
+
vertexAttributes: WGSLVertexAttributeBinding[];
|
|
100
|
+
primitiveTopology: GPUPrimitiveTopology;
|
|
101
|
+
wireframe: boolean;
|
|
102
|
+
private uniformLayoutCache;
|
|
103
|
+
private programCacheKeyCache;
|
|
104
|
+
private textureListCache;
|
|
105
|
+
private textureVersionsCache;
|
|
106
|
+
private textureVersionHashCache;
|
|
107
|
+
private storageBufferBindingListCache;
|
|
108
|
+
private storageBufferListCache;
|
|
109
|
+
private textureLayoutKeyDeviceCache;
|
|
110
|
+
private textureLayoutKeyCache;
|
|
111
|
+
constructor(parameters: WGSLShaderMaterialParameters);
|
|
112
|
+
getUniformLayout(): UniformLayout;
|
|
113
|
+
setUniform(name: string, definition: WGSLShaderMaterialUniformInput): this;
|
|
114
|
+
setDefine(name: string, value?: string | number | boolean): this;
|
|
115
|
+
deleteDefine(name: string): this;
|
|
116
|
+
setTexture(name: string, texture: Texture): this;
|
|
117
|
+
setStorageBuffer(name: string, binding: WGSLStorageBufferBinding): this;
|
|
118
|
+
setVertexAttributes(attributes: readonly WGSLVertexAttributeBinding[]): this;
|
|
119
|
+
copy(source: this): this;
|
|
120
|
+
/** Three's default clone path cannot call this material's required constructor. */
|
|
121
|
+
clone(): this;
|
|
122
|
+
customProgramCacheKey(): string;
|
|
123
|
+
getTexturesList(): readonly Texture[];
|
|
124
|
+
usesSceneTextures(): boolean;
|
|
125
|
+
getGraphTextureInputs(): Record<string, WGSLGraphTextureInput>;
|
|
126
|
+
requiresLatePass(): boolean;
|
|
127
|
+
getUniformValueHash(): number;
|
|
128
|
+
getTextureVersionsList(): readonly number[];
|
|
129
|
+
getTextureVersionHash(): number;
|
|
130
|
+
getStorageBufferBindingList(): readonly WGSLStorageBufferBinding[];
|
|
131
|
+
getStorageBufferList(): readonly GPUBuffer[];
|
|
132
|
+
getTextureLayoutKey(device: GPUDevice): string;
|
|
133
|
+
private invalidateProgramStructureCache;
|
|
134
|
+
private invalidateBindingCache;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
interface RenderGraphContext {
|
|
138
|
+
readonly device: GPUDevice;
|
|
139
|
+
readonly encoder: GPUCommandEncoder;
|
|
140
|
+
}
|
|
141
|
+
interface RenderGraphExecutionObserver {
|
|
142
|
+
begin?(passes: readonly RenderGraphPass[], context: RenderGraphContext): void;
|
|
143
|
+
beforePass?(pass: RenderGraphPass, index: number, context: RenderGraphContext): void;
|
|
144
|
+
afterPass?(pass: RenderGraphPass, index: number, cpuTimeMs: number, context: RenderGraphContext): void;
|
|
145
|
+
end?(passes: readonly RenderGraphPass[], totalCpuTimeMs: number, context: RenderGraphContext): void;
|
|
146
|
+
}
|
|
147
|
+
interface RenderGraphPass {
|
|
148
|
+
readonly name: string;
|
|
149
|
+
readonly reads?: readonly string[];
|
|
150
|
+
readonly writes?: readonly string[];
|
|
151
|
+
readonly dependsOn?: readonly string[];
|
|
152
|
+
prepare?(context: RenderGraphContext): Promise<void> | void;
|
|
153
|
+
execute(context: RenderGraphContext): void;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
declare class RenderGraph {
|
|
157
|
+
private readonly passes;
|
|
158
|
+
addPass(pass: RenderGraphPass): void;
|
|
159
|
+
executeAsync(context: RenderGraphContext, observer?: RenderGraphExecutionObserver): Promise<void>;
|
|
160
|
+
execute(context: RenderGraphContext, observer?: RenderGraphExecutionObserver): void;
|
|
161
|
+
reset(): void;
|
|
162
|
+
private resolveExecutionOrder;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Resolves a scene-authored Three material to a renderer-native WGSL material
|
|
167
|
+
* without mutating the scene's material slots. Return `undefined` to use the
|
|
168
|
+
* renderer fallback material, or `null` to intentionally skip the draw.
|
|
169
|
+
*/
|
|
170
|
+
type RendererMaterialResolver = (material: Material, pass?: 'opaque' | 'late') => WGSLShaderMaterial | null | undefined;
|
|
171
|
+
interface RendererOptions {
|
|
172
|
+
canvas: HTMLCanvasElement;
|
|
173
|
+
/** Linear-sRGB clear color. Presentation converts it to display sRGB. */
|
|
174
|
+
clearColor?: readonly [number, number, number, number];
|
|
175
|
+
powerPreference?: GPUPowerPreference;
|
|
176
|
+
shadowMapSize?: number;
|
|
177
|
+
pointShadowMapSize?: number;
|
|
178
|
+
sampleCount?: number;
|
|
179
|
+
hiZOcclusionCulling?: boolean;
|
|
180
|
+
/**
|
|
181
|
+
* Uses Chromium's experimental multi-draw-indirect command for GPU-culled
|
|
182
|
+
* static draw sets when the adapter supports it. Defaults to true.
|
|
183
|
+
*/
|
|
184
|
+
multiDrawIndirect?: boolean;
|
|
185
|
+
/** Merge compatible ordinary meshes into instanced draws each frame. Defaults to true. */
|
|
186
|
+
dynamicBatching?: boolean;
|
|
187
|
+
renderGraphProfiling?: boolean;
|
|
188
|
+
/** Internal scene resolution relative to the presentation resolution. Defaults to 1. */
|
|
189
|
+
renderScale?: number;
|
|
190
|
+
/** Material used when a mesh does not already use WGSLShaderMaterial. */
|
|
191
|
+
fallbackMaterial?: WGSLShaderMaterial;
|
|
192
|
+
/** Optional bridge for graph/material systems layered on top of Three. */
|
|
193
|
+
materialResolver?: RendererMaterialResolver;
|
|
194
|
+
/**
|
|
195
|
+
* Material used for a SkinnedMesh whose source material is not skin-aware.
|
|
196
|
+
* Defaults to the renderer's built-in lit skinned fallback.
|
|
197
|
+
*/
|
|
198
|
+
fallbackSkinnedMaterial?: WGSLShaderMaterial;
|
|
199
|
+
/** Defaults to true. Disable when callbacks expect THREE.WebGLRenderer. */
|
|
200
|
+
invokeObjectRenderCallbacks?: boolean;
|
|
201
|
+
}
|
|
202
|
+
interface StaticDrawSetOptions {
|
|
203
|
+
label?: string;
|
|
204
|
+
onUnsupported?: "throw" | "skip";
|
|
205
|
+
}
|
|
206
|
+
interface StaticDrawSet {
|
|
207
|
+
readonly label: string;
|
|
208
|
+
readonly drawCount: number;
|
|
209
|
+
readonly instanceCount: number;
|
|
210
|
+
enabled: boolean;
|
|
211
|
+
dispose(): void;
|
|
212
|
+
}
|
|
213
|
+
interface RendererGraphBuilderContext {
|
|
214
|
+
addDirectionalShadowPass(): void;
|
|
215
|
+
addPointShadowPass(): void;
|
|
216
|
+
addSpotShadowPass(): void;
|
|
217
|
+
addDepthPrepass(): void;
|
|
218
|
+
addHiZPasses(): void;
|
|
219
|
+
addVisibilityPass(): void;
|
|
220
|
+
defineColorTarget(name: string, descriptor?: RendererColorTargetDescriptor): void;
|
|
221
|
+
defineTextureTarget(name: string, descriptor?: RendererTextureTargetDescriptor): void;
|
|
222
|
+
addForwardPass(output?: string): void;
|
|
223
|
+
addOpaquePass(output?: string): void;
|
|
224
|
+
addSceneTextureCopyPass(source?: string): void;
|
|
225
|
+
addLatePass(output?: string): void;
|
|
226
|
+
addHiZHistoryPass(dependsOn?: string): void;
|
|
227
|
+
addMaterialPass(descriptor?: RendererMaterialPassDescriptor): void;
|
|
228
|
+
addCustomPass(descriptor: RendererCustomPassDescriptor): void;
|
|
229
|
+
addPresentPass(source?: string): void;
|
|
230
|
+
}
|
|
231
|
+
type RendererGraphBuilder = (graph: RenderGraph, context: RendererGraphBuilderContext) => void;
|
|
232
|
+
interface RendererColorTargetDescriptor {
|
|
233
|
+
readonly format?: GPUTextureFormat;
|
|
234
|
+
readonly scale?: number;
|
|
235
|
+
/** Base dimensions used by `scale`. Defaults to the internal render resolution. */
|
|
236
|
+
readonly resolution?: "render" | "presentation";
|
|
237
|
+
}
|
|
238
|
+
interface RendererTextureTargetDescriptor extends RendererColorTargetDescriptor {
|
|
239
|
+
readonly dimension?: "2d" | "3d";
|
|
240
|
+
readonly depthOrArrayLayers?: number;
|
|
241
|
+
readonly usage?: GPUTextureUsageFlags;
|
|
242
|
+
}
|
|
243
|
+
interface RendererMaterialPassDescriptor {
|
|
244
|
+
readonly name?: string;
|
|
245
|
+
readonly outputs?: string | readonly string[];
|
|
246
|
+
/** Selects which extracted scene draws are submitted. Defaults to all draws. */
|
|
247
|
+
readonly drawStage?: "all" | "opaque" | "late";
|
|
248
|
+
/** Preserve existing attachment contents instead of clearing them. */
|
|
249
|
+
readonly loadColor?: boolean;
|
|
250
|
+
/** Preserve depth written by an earlier pass. Defaults to clear. */
|
|
251
|
+
readonly loadDepth?: boolean;
|
|
252
|
+
/** Draw only objects accepted by this predicate. Intended for selection/mask passes. */
|
|
253
|
+
readonly objectFilter?: (object: Object3D | null) => boolean;
|
|
254
|
+
/** Replace each accepted draw's material while preserving its geometry and instance data. */
|
|
255
|
+
readonly overrideMaterial?: WGSLShaderMaterial | ((source: WGSLShaderMaterial, skinned: boolean) => WGSLShaderMaterial);
|
|
256
|
+
}
|
|
257
|
+
interface RendererShadowMapDebugTextureInfo {
|
|
258
|
+
readonly view: GPUTextureView | null;
|
|
259
|
+
readonly size: number;
|
|
260
|
+
readonly layerCount: number;
|
|
261
|
+
readonly activeLightCount: number;
|
|
262
|
+
readonly activeLayerCount: number;
|
|
263
|
+
}
|
|
264
|
+
interface RendererShadowMapDebugInfo {
|
|
265
|
+
readonly directional: RendererShadowMapDebugTextureInfo;
|
|
266
|
+
readonly point: RendererShadowMapDebugTextureInfo;
|
|
267
|
+
readonly spot: RendererShadowMapDebugTextureInfo;
|
|
268
|
+
}
|
|
269
|
+
interface RendererCustomPassContext {
|
|
270
|
+
readonly device: GPUDevice;
|
|
271
|
+
readonly camera: PerspectiveCamera | OrthographicCamera;
|
|
272
|
+
readonly encoder: GPUCommandEncoder;
|
|
273
|
+
readonly sceneColorView: GPUTextureView;
|
|
274
|
+
readonly postProcessColorView: GPUTextureView;
|
|
275
|
+
readonly presentationColorView: GPUTextureView;
|
|
276
|
+
readonly depthView: GPUTextureView | null;
|
|
277
|
+
readonly colorFormat: GPUTextureFormat;
|
|
278
|
+
readonly width: number;
|
|
279
|
+
readonly height: number;
|
|
280
|
+
readonly presentationWidth: number;
|
|
281
|
+
readonly presentationHeight: number;
|
|
282
|
+
readonly linearClampSampler: GPUSampler;
|
|
283
|
+
readonly nearestClampSampler: GPUSampler;
|
|
284
|
+
readonly comparisonSampler: GPUSampler;
|
|
285
|
+
getColorView(name: string): GPUTextureView;
|
|
286
|
+
getTextureView(name: string): GPUTextureView;
|
|
287
|
+
/** Uploads (or retrieves) a Three texture through the renderer texture cache. */
|
|
288
|
+
getExternalTexture(texture: Texture): {
|
|
289
|
+
view: GPUTextureView;
|
|
290
|
+
sampler: GPUSampler;
|
|
291
|
+
};
|
|
292
|
+
getColorFormat(name: string): GPUTextureFormat;
|
|
293
|
+
getShadowMapDebugInfo(): RendererShadowMapDebugInfo;
|
|
294
|
+
/** Shared light uniforms and shadow arrays used by the forward renderer. */
|
|
295
|
+
getSceneLightingResources(): RendererSceneLightingResources;
|
|
296
|
+
}
|
|
297
|
+
interface RendererSceneLightingResources {
|
|
298
|
+
readonly lightBuffer: GPUBuffer;
|
|
299
|
+
readonly directionalShadowView: GPUTextureView;
|
|
300
|
+
readonly pointShadowView: GPUTextureView;
|
|
301
|
+
readonly spotShadowView: GPUTextureView;
|
|
302
|
+
}
|
|
303
|
+
interface RendererCustomPassDescriptor {
|
|
304
|
+
readonly name: string;
|
|
305
|
+
readonly reads?: readonly string[];
|
|
306
|
+
readonly writes?: readonly string[];
|
|
307
|
+
readonly dependsOn?: readonly string[];
|
|
308
|
+
execute(context: RendererCustomPassContext): void;
|
|
309
|
+
}
|
|
310
|
+
interface RendererPassProfile {
|
|
311
|
+
name: string;
|
|
312
|
+
cpuTimeMs: number;
|
|
313
|
+
gpuTimeMs: number | null;
|
|
314
|
+
}
|
|
315
|
+
interface RendererVisibilityProfile {
|
|
316
|
+
totalInstances: number;
|
|
317
|
+
visibleInstances: number;
|
|
318
|
+
culledInstances: number;
|
|
319
|
+
dynamicTotalInstances: number;
|
|
320
|
+
dynamicVisibleInstances: number;
|
|
321
|
+
staticTotalInstances: number;
|
|
322
|
+
staticVisibleInstances: number;
|
|
323
|
+
}
|
|
324
|
+
interface RendererFrameProfile {
|
|
325
|
+
frameIndex: number;
|
|
326
|
+
cpuTimeMs: number;
|
|
327
|
+
gpuTimeMs: number | null;
|
|
328
|
+
drawCallCount: number;
|
|
329
|
+
triangleCount: number;
|
|
330
|
+
cpuPhases: {
|
|
331
|
+
extractSceneMs: number;
|
|
332
|
+
uploadMs: number;
|
|
333
|
+
renderGraphMs: number;
|
|
334
|
+
};
|
|
335
|
+
passes: RendererPassProfile[];
|
|
336
|
+
timestampQuerySupported: boolean;
|
|
337
|
+
timestampQueryActive: boolean;
|
|
338
|
+
gpuProfilingReason: string | null;
|
|
339
|
+
hiZOcclusionCullingEnabled: boolean;
|
|
340
|
+
hiZOcclusionCullingActive: boolean;
|
|
341
|
+
/** Delayed GPU readback of the indirect instance counts produced by visibility culling. */
|
|
342
|
+
visibility: RendererVisibilityProfile | null;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
type FrameGraphTextureHandle = string;
|
|
346
|
+
interface FrameGraphPassDescriptor {
|
|
347
|
+
readonly name: string;
|
|
348
|
+
readonly inputs?: Record<string, FrameGraphTextureHandle>;
|
|
349
|
+
readonly outputs?: FrameGraphTextureHandle | readonly FrameGraphTextureHandle[];
|
|
350
|
+
readonly dependsOn?: readonly string[];
|
|
351
|
+
execute(context: RendererCustomPassContext): void;
|
|
352
|
+
}
|
|
353
|
+
interface FrameGraphFullscreenPassDescriptor {
|
|
354
|
+
readonly name: string;
|
|
355
|
+
readonly inputs: Record<string, FrameGraphTextureHandle>;
|
|
356
|
+
/** Dimensionality override for non-2D graph inputs such as froxel volumes. */
|
|
357
|
+
readonly inputDimensions?: Record<string, "2d" | "3d">;
|
|
358
|
+
readonly outputs: FrameGraphTextureHandle | readonly FrameGraphTextureHandle[];
|
|
359
|
+
readonly fragmentShader: string;
|
|
360
|
+
/**
|
|
361
|
+
* Standalone Three textures bound as `<name>Texture` and `<name>Sampler`.
|
|
362
|
+
* Use this for lookup/noise/LUT textures that are not frame-graph targets.
|
|
363
|
+
*/
|
|
364
|
+
readonly textures?: Record<string, Texture>;
|
|
365
|
+
readonly sampler?: "linear" | "nearest";
|
|
366
|
+
readonly uniformBufferSize?: number;
|
|
367
|
+
readonly updateUniforms?: (context: RendererCustomPassContext) => ArrayBufferView | null;
|
|
368
|
+
}
|
|
369
|
+
/** Structural contract returned by three-shader-graph's fullscreen compiler. */
|
|
370
|
+
interface CompiledNodeFullscreenShader {
|
|
371
|
+
readonly fragmentShader: string;
|
|
372
|
+
readonly uniforms: Record<string, UniformDefinition>;
|
|
373
|
+
/** Standalone Three textures collected from nodes such as textureSampler2d(). */
|
|
374
|
+
readonly textures?: Record<string, Texture>;
|
|
375
|
+
readonly graphTextures: Record<string, WGSLGraphTextureInput>;
|
|
376
|
+
/** Legacy semantic bindings emitted by existing node-material adapters. */
|
|
377
|
+
readonly sceneTextures?: Record<string, "sceneColor" | "sceneDepth">;
|
|
378
|
+
syncLiveUniforms(uniforms: Record<string, {
|
|
379
|
+
value: UniformValue;
|
|
380
|
+
}>): void;
|
|
381
|
+
}
|
|
382
|
+
interface FrameGraphNodeFullscreenPassDescriptor {
|
|
383
|
+
readonly name: string;
|
|
384
|
+
readonly shader: CompiledNodeFullscreenShader;
|
|
385
|
+
/** Overrides frame-graph resources for named compiled graph/scene texture bindings. */
|
|
386
|
+
readonly inputOverrides?: Record<string, FrameGraphTextureHandle>;
|
|
387
|
+
readonly outputs: FrameGraphTextureHandle | readonly FrameGraphTextureHandle[];
|
|
388
|
+
}
|
|
389
|
+
interface FrameGraphMaterialPassDescriptor {
|
|
390
|
+
readonly name?: string;
|
|
391
|
+
readonly outputs?: FrameGraphTextureHandle | readonly FrameGraphTextureHandle[];
|
|
392
|
+
readonly drawStage?: "all" | "opaque" | "late";
|
|
393
|
+
readonly loadColor?: boolean;
|
|
394
|
+
readonly loadDepth?: boolean;
|
|
395
|
+
readonly objectFilter?: (object: Object3D | null) => boolean;
|
|
396
|
+
readonly overrideMaterial?: WGSLShaderMaterial | ((source: WGSLShaderMaterial, skinned: boolean) => WGSLShaderMaterial);
|
|
397
|
+
}
|
|
398
|
+
declare class FrameGraphBuilder {
|
|
399
|
+
private readonly context;
|
|
400
|
+
readonly sceneColor = "sceneColor";
|
|
401
|
+
readonly mainDepth = "mainDepth";
|
|
402
|
+
readonly postProcessColor = "postProcessColor";
|
|
403
|
+
constructor(context: RendererGraphBuilderContext);
|
|
404
|
+
createColorTarget(name: string, descriptor?: RendererColorTargetDescriptor): FrameGraphTextureHandle;
|
|
405
|
+
createTextureTarget(name: string, descriptor?: RendererTextureTargetDescriptor): FrameGraphTextureHandle;
|
|
406
|
+
addStandardScenePasses(forwardOutput?: FrameGraphTextureHandle): void;
|
|
407
|
+
addDirectionalShadowPass(): void;
|
|
408
|
+
addPointShadowPass(): void;
|
|
409
|
+
addSpotShadowPass(): void;
|
|
410
|
+
addDepthPrepass(): void;
|
|
411
|
+
addHiZPasses(): void;
|
|
412
|
+
addVisibilityPass(): void;
|
|
413
|
+
addForwardPass(output?: FrameGraphTextureHandle): void;
|
|
414
|
+
addOpaquePass(output?: FrameGraphTextureHandle): void;
|
|
415
|
+
addSceneTextureCopyPass(source?: FrameGraphTextureHandle): void;
|
|
416
|
+
addLatePass(output?: FrameGraphTextureHandle): void;
|
|
417
|
+
addHiZHistoryPass(dependsOn?: string): void;
|
|
418
|
+
addMaterialPass(descriptor?: FrameGraphMaterialPassDescriptor): void;
|
|
419
|
+
addPass(descriptor: FrameGraphPassDescriptor): void;
|
|
420
|
+
addFullscreenPass(descriptor: FrameGraphFullscreenPassDescriptor): void;
|
|
421
|
+
addNodeFullscreenPass(descriptor: FrameGraphNodeFullscreenPassDescriptor): void;
|
|
422
|
+
present(source?: FrameGraphTextureHandle): void;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
type VolumetricFogScatteringMode = "volumetric" | "lightShaft";
|
|
426
|
+
/** Kept structurally compatible with Hology's legacy FogVolumeSettings. */
|
|
427
|
+
interface VolumetricFogVolumeSettings {
|
|
428
|
+
readonly object: Object3D;
|
|
429
|
+
baseDensity: number;
|
|
430
|
+
heightFalloff: number;
|
|
431
|
+
heightOffset: number;
|
|
432
|
+
startDistance?: number;
|
|
433
|
+
scatteringDistribution: number;
|
|
434
|
+
albedo: Color;
|
|
435
|
+
emissive: Color;
|
|
436
|
+
ambientIntensity?: number;
|
|
437
|
+
scatteringMode: VolumetricFogScatteringMode;
|
|
438
|
+
}
|
|
439
|
+
/** Scene marker compatible with legacy objects through `isFogVolumeObject`. */
|
|
440
|
+
declare class VolumetricFogVolumeObject extends Object3D {
|
|
441
|
+
readonly volume: VolumetricFogVolumeSettings;
|
|
442
|
+
readonly isFogVolumeObject = true;
|
|
443
|
+
constructor(volume: VolumetricFogVolumeSettings);
|
|
444
|
+
}
|
|
445
|
+
interface VolumetricFogOptions {
|
|
446
|
+
/** Froxel width/height in pixels. 8 is a good desktop default. */
|
|
447
|
+
readonly froxelPixelSize?: number;
|
|
448
|
+
/** Logarithmically distributed depth slices. */
|
|
449
|
+
readonly depthSlices?: number;
|
|
450
|
+
/** Deterministic integration samples within each depth slice. */
|
|
451
|
+
readonly integrationSubsteps?: 1 | 2 | 4;
|
|
452
|
+
readonly maxDistance?: number;
|
|
453
|
+
readonly targetPrefix?: string;
|
|
454
|
+
readonly maxVolumes?: number;
|
|
455
|
+
readonly maxDirectionalLights?: number;
|
|
456
|
+
readonly maxPointLights?: number;
|
|
457
|
+
readonly maxSpotLights?: number;
|
|
458
|
+
/** Used when the scene has no ambient or hemisphere light. */
|
|
459
|
+
readonly ambientColor?: Color;
|
|
460
|
+
/** Rotating shadow taps per froxel. 4 removes block patterns at modest cost. */
|
|
461
|
+
readonly shadowFilterTaps?: 1 | 4;
|
|
462
|
+
/** Temporal sub-froxel jitter, intended to be accumulated by TAA. */
|
|
463
|
+
readonly temporalJitter?: boolean;
|
|
464
|
+
/** Stable per-ray depth jitter. Breaks slice bands without animated noise. */
|
|
465
|
+
readonly spatialJitter?: boolean;
|
|
466
|
+
/** Final fog-gradient dithering in approximate 8-bit code values. */
|
|
467
|
+
readonly fogDitherStrength?: number;
|
|
468
|
+
/** Artistic multiplier for direct in-scattering. Does not change extinction. */
|
|
469
|
+
readonly scatteringIntensity?: number;
|
|
470
|
+
/** Optional separable, depth-aware blur of the resolved fog buffer. */
|
|
471
|
+
readonly blur?: false | VolumetricFogBlurOptions;
|
|
472
|
+
}
|
|
473
|
+
interface VolumetricFogBlurOptions {
|
|
474
|
+
/** Resolution relative to the render target. Defaults to 0.5. */
|
|
475
|
+
readonly scale?: number;
|
|
476
|
+
/** Kernel radius per direction, from 1 to 12. Defaults to 5. */
|
|
477
|
+
readonly radius?: number;
|
|
478
|
+
/** Log-depth rejection sigma. 0.05 allows about 5% relative depth variation. */
|
|
479
|
+
readonly depthSigma?: number;
|
|
480
|
+
/** Gaussian spatial sigma in fog-buffer pixels. */
|
|
481
|
+
readonly spatialSigma?: number;
|
|
482
|
+
/** Preserve depth discontinuities during the final upsample. Costs extra depth reads. Defaults to true. */
|
|
483
|
+
readonly depthAwareUpsample?: boolean;
|
|
484
|
+
}
|
|
485
|
+
interface VolumetricFogInputs {
|
|
486
|
+
readonly sceneColor: FrameGraphTextureHandle;
|
|
487
|
+
readonly depth: FrameGraphTextureHandle;
|
|
488
|
+
/** Explicit volumes can be mixed with compatible scene marker objects. */
|
|
489
|
+
readonly volumes?: readonly VolumetricFogVolumeSettings[];
|
|
490
|
+
}
|
|
491
|
+
/**
|
|
492
|
+
* Compute-driven froxel fog. Add it after opaque rendering and before the late
|
|
493
|
+
* transparent pass. Existing content can use the composite output; transparent
|
|
494
|
+
* materials can sample `integratedVolume` with configureVolumetricFogMaterial.
|
|
495
|
+
*/
|
|
496
|
+
declare class VolumetricFogEffect {
|
|
497
|
+
private scene;
|
|
498
|
+
readonly integratedVolume: FrameGraphTextureHandle;
|
|
499
|
+
readonly columnDepthBounds: FrameGraphTextureHandle;
|
|
500
|
+
private readonly options;
|
|
501
|
+
private readonly resources;
|
|
502
|
+
private readonly uniformStorage;
|
|
503
|
+
private readonly uniforms;
|
|
504
|
+
private readonly uniformIntegers;
|
|
505
|
+
private readonly volumeData;
|
|
506
|
+
private readonly lightData;
|
|
507
|
+
private readonly projectionInverse;
|
|
508
|
+
private readonly viewProjectionInverse;
|
|
509
|
+
private explicitVolumes;
|
|
510
|
+
private cascadeDirectionalLights;
|
|
511
|
+
private compositePass;
|
|
512
|
+
private readonly blurPassCache;
|
|
513
|
+
private frameIndex;
|
|
514
|
+
constructor(scene?: Scene, options?: VolumetricFogOptions);
|
|
515
|
+
/** Updates the scene traversed for compatible volumes and lights. */
|
|
516
|
+
setScene(scene: Scene): void;
|
|
517
|
+
/** Keeps CSM light data in the same near-to-far order as shadow-array layers. */
|
|
518
|
+
setCascadedDirectionalLights(lights: readonly DirectionalLight[]): void;
|
|
519
|
+
addPasses(graph: FrameGraphBuilder, inputs: VolumetricFogInputs): FrameGraphTextureHandle;
|
|
520
|
+
private addBlurredComposite;
|
|
521
|
+
dispose(): void;
|
|
522
|
+
private executeFroxels;
|
|
523
|
+
private collectSceneData;
|
|
524
|
+
private writeVolume;
|
|
525
|
+
private lightColor;
|
|
526
|
+
private writeDirectional;
|
|
527
|
+
private writePoint;
|
|
528
|
+
private writeSpot;
|
|
529
|
+
private getResources;
|
|
530
|
+
}
|
|
531
|
+
/** WGSL appended to a material that calls rendererApplyVolumetricFog(). */
|
|
532
|
+
declare const VOLUMETRIC_FOG_MATERIAL_WGSL = "\nfn rendererSampleIntegratedFog(uv: vec2<f32>, normalizedDepth: f32) -> vec4<f32> {\n let sliceCount = f32(textureDimensions(volumetricFogTexture).z);\n let slicePosition = clamp(normalizedDepth, 0.0, 1.0) * sliceCount;\n let textureZ = clamp((slicePosition - 0.5) / sliceCount, 0.0, 1.0);\n let integrated = textureSampleLevel(volumetricFogTexture, volumetricFogSampler, vec3<f32>(uv, textureZ), 0.0);\n // The volume stores slice endpoints but has no texel for the near-plane\n // identity value. Reconstruct that missing endpoint for the first slice.\n return mix(vec4<f32>(0.0, 0.0, 0.0, 1.0), integrated, min(slicePosition, 1.0));\n}\nfn rendererApplyVolumetricFog(color: vec4<f32>, worldPosition: vec3<f32>) -> vec4<f32> {\n let clip = rendererCamera.viewProj * vec4<f32>(worldPosition, 1.0);\n let uv = clip.xy / clip.w * vec2<f32>(0.5, -0.5) + vec2<f32>(0.5);\n let distance = length(worldPosition - rendererCamera.cameraPosition.xyz);\n let bounds = textureSampleLevel(volumetricFogBoundsTexture, volumetricFogBoundsSampler, uv, 0.0).rg;\n let z = clamp((distance - bounds.x) / max(bounds.y - bounds.x, 0.001), 0.0, 1.0);\n let fog = rendererSampleIntegratedFog(uv, z);\n return vec4<f32>(fog.rgb + color.rgb * fog.a, color.a);\n}";
|
|
533
|
+
/** Adds the froxel input; append VOLUMETRIC_FOG_MATERIAL_WGSL and call its helper in fsMain. */
|
|
534
|
+
declare function configureVolumetricFogMaterial(material: WGSLShaderMaterial, resource?: string, boundsResource?: string): WGSLShaderMaterial;
|
|
535
|
+
|
|
536
|
+
interface TextureResource {
|
|
537
|
+
version: number;
|
|
538
|
+
width: number;
|
|
539
|
+
height: number;
|
|
540
|
+
depthOrArrayLayers: number;
|
|
541
|
+
format: GPUTextureFormat;
|
|
542
|
+
textureDimension: GPUTextureDimension;
|
|
543
|
+
viewDimension: GPUTextureViewDimension;
|
|
544
|
+
sampleType: GPUTextureSampleType;
|
|
545
|
+
samplerBindingType: GPUSamplerBindingType;
|
|
546
|
+
mipLevelCount: number;
|
|
547
|
+
texture: GPUTexture;
|
|
548
|
+
view: GPUTextureView;
|
|
549
|
+
sampler: GPUSampler;
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
interface WebGpuPMREMGeneratorContext {
|
|
553
|
+
device: GPUDevice;
|
|
554
|
+
getTextureResource(texture: Texture): TextureResource;
|
|
555
|
+
registerTextureResource(texture: Texture, resource: TextureResource): void;
|
|
556
|
+
}
|
|
557
|
+
/** Native WebGPU implementation of Three's equirectangular CubeUV PMREM path. */
|
|
558
|
+
declare class WebGpuPMREMGenerator {
|
|
559
|
+
private readonly context;
|
|
560
|
+
private readonly equirectPipeline;
|
|
561
|
+
private readonly blurPipeline;
|
|
562
|
+
private readonly equirectBindGroupLayout;
|
|
563
|
+
private readonly blurBindGroupLayout;
|
|
564
|
+
private readonly maxBlurSamples;
|
|
565
|
+
constructor(context: WebGpuPMREMGeneratorContext, maxBlurSamples?: number);
|
|
566
|
+
fromEquirectangular(source: Texture): {
|
|
567
|
+
texture: Texture;
|
|
568
|
+
dispose(): void;
|
|
569
|
+
};
|
|
570
|
+
private encodeBlurPass;
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
/** Compatible with the legacy OutlineEffect material.userData contract. */
|
|
574
|
+
type ToonOutlineParameters = {
|
|
575
|
+
/** View-distance-scaled normal extrusion. Defaults to 0.003. */
|
|
576
|
+
thickness?: number;
|
|
577
|
+
/** Linear RGB outline color. Defaults to black. */
|
|
578
|
+
color?: readonly [number, number, number] | readonly number[];
|
|
579
|
+
/** Defaults to the source material's opacity. */
|
|
580
|
+
alpha?: number;
|
|
581
|
+
/** Set to false to suppress the otherwise enabled outline. */
|
|
582
|
+
visible?: boolean;
|
|
583
|
+
};
|
|
584
|
+
declare class WebGpuRenderer {
|
|
585
|
+
readonly canvas: HTMLCanvasElement;
|
|
586
|
+
private readonly clearColor;
|
|
587
|
+
private readonly powerPreference;
|
|
588
|
+
private readonly shadowMapSize;
|
|
589
|
+
private readonly pointShadowMapSize;
|
|
590
|
+
private readonly fallbackMaterial;
|
|
591
|
+
private readonly materialResolver;
|
|
592
|
+
private readonly toonOutlineMaterialCache;
|
|
593
|
+
private readonly fallbackSkinnedMaterial;
|
|
594
|
+
private readonly invokeObjectRenderCallbacks;
|
|
595
|
+
private sampleCount;
|
|
596
|
+
private renderScale;
|
|
597
|
+
private hiZOcclusionCullingEnabled;
|
|
598
|
+
private multiDrawIndirectEnabled;
|
|
599
|
+
private dynamicBatchingEnabled;
|
|
600
|
+
private multiDrawIndirectSupported;
|
|
601
|
+
private renderGraphProfilingEnabled;
|
|
602
|
+
private indirectFirstInstanceSupported;
|
|
603
|
+
private timestampQuerySupported;
|
|
604
|
+
private readonly geometryCache;
|
|
605
|
+
private readonly skinnedGeometryCache;
|
|
606
|
+
private readonly skinPaletteCache;
|
|
607
|
+
private readonly skinPaletteResources;
|
|
608
|
+
private readonly meshExtractionCache;
|
|
609
|
+
/**
|
|
610
|
+
* Material resolvers may synchronise live graph uniforms or replace the
|
|
611
|
+
* generated WGSL material. Resolve each source material once per extraction
|
|
612
|
+
* so regular meshes see that change without paying resolver work per mesh.
|
|
613
|
+
*/
|
|
614
|
+
private readonly resolvedMaterialFrameCache;
|
|
615
|
+
private readonly instancedMeshExtractionCache;
|
|
616
|
+
private readonly batchedMeshExtractionCache;
|
|
617
|
+
private readonly materialCache;
|
|
618
|
+
private readonly skinnedMaterialCache;
|
|
619
|
+
private readonly materialCacheVisible;
|
|
620
|
+
private readonly materialCacheDirect;
|
|
621
|
+
private readonly materialNoReceiveShadowCache;
|
|
622
|
+
private readonly skinnedMaterialNoReceiveShadowCache;
|
|
623
|
+
private readonly materialNoReceiveShadowCacheVisible;
|
|
624
|
+
private readonly materialNoReceiveShadowCacheDirect;
|
|
625
|
+
private readonly depthPrepassMaterialCache;
|
|
626
|
+
private readonly directionalShadowMaterialCache;
|
|
627
|
+
private readonly skinnedDirectionalShadowMaterialCache;
|
|
628
|
+
private readonly directionalShadowMaterialCacheDirect;
|
|
629
|
+
private readonly lineMaterialCache;
|
|
630
|
+
private readonly lineBasicMaterialCache;
|
|
631
|
+
private readonly lineProxyCache;
|
|
632
|
+
private readonly spriteProxyCache;
|
|
633
|
+
private readonly depthMaterialFrameCache;
|
|
634
|
+
/**
|
|
635
|
+
* Common scene/depth variants can be resolved without rebuilding their full
|
|
636
|
+
* shader cache key. Material.version and the texture-version hash provide
|
|
637
|
+
* the same cheap validity gate already used by draw-local resource caching.
|
|
638
|
+
*/
|
|
639
|
+
private readonly forwardMaterialFastCache;
|
|
640
|
+
/** Fast variants for MRT/non-default target format combinations. */
|
|
641
|
+
private readonly forwardMaterialTargetFastCache;
|
|
642
|
+
private readonly forwardMaterialFrameCache;
|
|
643
|
+
private readonly depthMaterialFastCache;
|
|
644
|
+
private readonly sharedForwardPipelineCache;
|
|
645
|
+
private readonly sharedForwardPipelinePromiseCache;
|
|
646
|
+
private readonly sharedDepthPipelineCache;
|
|
647
|
+
private readonly sharedDepthPipelinePromiseCache;
|
|
648
|
+
private readonly state;
|
|
649
|
+
private readonly textureCache;
|
|
650
|
+
private readonly graphTextureBindGroupCache;
|
|
651
|
+
private readonly materialGraphTextureReadCache;
|
|
652
|
+
/**
|
|
653
|
+
* A custom instanced attribute is indexed by WebGPU's global
|
|
654
|
+
* `instance_index`. Keep shared default buffers large enough for the packed
|
|
655
|
+
* renderer instance range instead of binding one value at index zero.
|
|
656
|
+
*/
|
|
657
|
+
private readonly defaultInstanceAttributeBuffers;
|
|
658
|
+
private readonly textureManager;
|
|
659
|
+
private readonly renderGraph;
|
|
660
|
+
private readonly directionalShadowCameras;
|
|
661
|
+
private readonly pointShadowCameras;
|
|
662
|
+
private readonly spotShadowCameras;
|
|
663
|
+
private readonly colorTargetCache;
|
|
664
|
+
private readonly msaaColorTargetCache;
|
|
665
|
+
private readonly msaaDepthTargetCache;
|
|
666
|
+
private readonly sourceInstanceDataScratch;
|
|
667
|
+
private readonly opaqueInstanceDataScratch;
|
|
668
|
+
private readonly finalInstanceDataScratch;
|
|
669
|
+
private readonly residentInstanceUploadsScratch;
|
|
670
|
+
private readonly gpuOpaqueDrawsScratch;
|
|
671
|
+
private readonly directOpaqueDrawsScratch;
|
|
672
|
+
private readonly stagedOpaqueDrawsScratch;
|
|
673
|
+
private readonly residentOpaqueDrawsScratch;
|
|
674
|
+
private readonly retiredGeometryResources;
|
|
675
|
+
private readonly retiredGeometryBuffers;
|
|
676
|
+
private readonly vertexAttributeBufferKeyCache;
|
|
677
|
+
private readonly standardVertexAttributeCache;
|
|
678
|
+
private readonly geometryVertexBufferFastCache;
|
|
679
|
+
private readonly vertexAttributeGroupCache;
|
|
680
|
+
private readonly vertexAttributeGroupBufferKeyCache;
|
|
681
|
+
private readonly compileDrawScratch;
|
|
682
|
+
private readonly indirectSubmissionStreamsScratch;
|
|
683
|
+
private readonly renderBundleScratch;
|
|
684
|
+
private readonly directBundleDrawStatsScratch;
|
|
685
|
+
private readonly sortedOpaqueBatchesScratch;
|
|
686
|
+
private readonly opaqueBatchPool;
|
|
687
|
+
private opaqueBatchPoolCount;
|
|
688
|
+
private readonly drawCallPool;
|
|
689
|
+
private drawCallPoolCount;
|
|
690
|
+
private readonly staticDrawSets;
|
|
691
|
+
private materialPassStaticBundleCache;
|
|
692
|
+
private readonly staticDrawSetManager;
|
|
693
|
+
private staticFrameToken;
|
|
694
|
+
private hizResourceVersion;
|
|
695
|
+
private graphTextureResourceVersion;
|
|
696
|
+
private readonly visibilityParamsUpload;
|
|
697
|
+
private drawMetadataUpload;
|
|
698
|
+
private indirectDrawUpload;
|
|
699
|
+
private readonly extractedAmbientScratch;
|
|
700
|
+
private readonly extractedHemisphereScratch;
|
|
701
|
+
private readonly extractedBoundsMinScratch;
|
|
702
|
+
private readonly extractedBoundsMaxScratch;
|
|
703
|
+
private readonly extractedDirectionalLightsScratch;
|
|
704
|
+
private readonly extractedPointLightsScratch;
|
|
705
|
+
private readonly extractedSpotLightsScratch;
|
|
706
|
+
private readonly activeDirectionalLightsScratch;
|
|
707
|
+
private readonly activePointLightsScratch;
|
|
708
|
+
private readonly activeSpotLightsScratch;
|
|
709
|
+
private readonly resolvedMeshMaterialsScratch;
|
|
710
|
+
private readonly extractedLightsScratch;
|
|
711
|
+
private readonly extractedFrameScratch;
|
|
712
|
+
private readonly cameraUniformScratch;
|
|
713
|
+
private readonly temporalVisibilityUniformScratch;
|
|
714
|
+
private readonly lightUniformScratch;
|
|
715
|
+
private readonly csmCascadeRanges;
|
|
716
|
+
private csmCascadeCount;
|
|
717
|
+
private csmCascadeLights;
|
|
718
|
+
private readonly shadowCameraUniformScratch;
|
|
719
|
+
private readonly cameraViewProjScratch;
|
|
720
|
+
private readonly cameraProjectionScratch;
|
|
721
|
+
private readonly projectionJitterPixels;
|
|
722
|
+
private readonly temporalVisibilityCurrentViewProj;
|
|
723
|
+
private readonly temporalVisibilityPreviousViewProj;
|
|
724
|
+
private readonly cameraFrustumPlanesScratch;
|
|
725
|
+
private readonly objectTraversalStackScratch;
|
|
726
|
+
private readonly isSphereVisibleScratch;
|
|
727
|
+
private readonly updateExtractedBoundsFromMatrixScratch;
|
|
728
|
+
private readonly transparentSortCameraPositionScratch;
|
|
729
|
+
private readonly transparentSortCameraForwardScratch;
|
|
730
|
+
private readonly temporalVisibilityCurrentCameraPosition;
|
|
731
|
+
private readonly temporalVisibilityPreviousCameraPosition;
|
|
732
|
+
private readonly shadowViewProjScratch;
|
|
733
|
+
private extractionVersion;
|
|
734
|
+
private graphBuilder;
|
|
735
|
+
private createExtractedDirectionalLightScratch;
|
|
736
|
+
private createExtractedHemisphereLightScratch;
|
|
737
|
+
private createExtractedPointLightScratch;
|
|
738
|
+
private createExtractedSpotLightScratch;
|
|
739
|
+
constructor(options: RendererOptions);
|
|
740
|
+
private resolveMaterial;
|
|
741
|
+
private resolveLineMaterial;
|
|
742
|
+
private resolveLineBasicMaterial;
|
|
743
|
+
private resolveSkinnedMaterial;
|
|
744
|
+
private hasRenderCallbacks;
|
|
745
|
+
initialize(): Promise<void>;
|
|
746
|
+
createComputeKernel(descriptor: ComputeKernelDescriptor): ComputeKernel;
|
|
747
|
+
setRenderGraphBuilder(builder: RendererGraphBuilder): void;
|
|
748
|
+
/**
|
|
749
|
+
* Associates the first directional shadow layers with cascaded-shadow-map
|
|
750
|
+
* depth intervals. Submit the same normalized pairs returned by Hology's
|
|
751
|
+
* CSM#getExtendedBreaks(); the matching directional lights remain ordinary
|
|
752
|
+
* scene lights and are rendered through the existing shadow passes.
|
|
753
|
+
*/
|
|
754
|
+
setCascadedShadowRanges(ranges: readonly {
|
|
755
|
+
readonly x: number;
|
|
756
|
+
readonly y: number;
|
|
757
|
+
}[], lights?: readonly DirectionalLight[]): void;
|
|
758
|
+
setRenderGraphProfilingEnabled(enabled: boolean): void;
|
|
759
|
+
getRenderGraphProfilingEnabled(): boolean;
|
|
760
|
+
getTimestampQuerySupported(): boolean;
|
|
761
|
+
getSampleCount(): number;
|
|
762
|
+
setSampleCount(sampleCount: number): void;
|
|
763
|
+
/** Sets the internal scene resolution while preserving presentation size. */
|
|
764
|
+
setRenderScale(renderScale: number): void;
|
|
765
|
+
getRenderScale(): number;
|
|
766
|
+
/**
|
|
767
|
+
* Offsets the GPU raster projection in internal-render-resolution pixels.
|
|
768
|
+
* The authored camera remains unchanged, so controls, culling, and raycasts
|
|
769
|
+
* continue to use its stable projection.
|
|
770
|
+
*/
|
|
771
|
+
setProjectionJitter(x: number, y: number): void;
|
|
772
|
+
clearProjectionJitter(): void;
|
|
773
|
+
getLastFrameProfile(): RendererFrameProfile | null;
|
|
774
|
+
setHiZOcclusionCullingEnabled(enabled: boolean): void;
|
|
775
|
+
getHiZOcclusionCullingEnabled(): boolean;
|
|
776
|
+
getHiZOcclusionCullingActive(): boolean;
|
|
777
|
+
setMultiDrawIndirectEnabled(enabled: boolean): void;
|
|
778
|
+
getMultiDrawIndirectEnabled(): boolean;
|
|
779
|
+
setDynamicBatchingEnabled(enabled: boolean): void;
|
|
780
|
+
getDynamicBatchingEnabled(): boolean;
|
|
781
|
+
getMultiDrawIndirectSupported(): boolean;
|
|
782
|
+
getMultiDrawIndirectActive(): boolean;
|
|
783
|
+
setSize(width: number, height: number, pixelRatio?: number): void;
|
|
784
|
+
setClearColor(color: readonly [number, number, number, number]): void;
|
|
785
|
+
render(scene: Scene, camera: PerspectiveCamera | OrthographicCamera, timeSeconds?: number): void;
|
|
786
|
+
renderAsync(scene: Scene, camera: PerspectiveCamera | OrthographicCamera, timeSeconds?: number): Promise<void>;
|
|
787
|
+
compile(scene: Scene, camera: PerspectiveCamera | OrthographicCamera): void;
|
|
788
|
+
compileAsync(scene: Scene, camera: PerspectiveCamera | OrthographicCamera): Promise<void>;
|
|
789
|
+
/**
|
|
790
|
+
* Creates a Three-compatible CubeUV PMREM generator. Its output is a
|
|
791
|
+
* HalfFloat Texture and can be assigned directly to a graph material's
|
|
792
|
+
* `envMap` uniform or to `scene.environment` before material resolution.
|
|
793
|
+
*/
|
|
794
|
+
createPMREMGenerator(maxBlurSamples?: number): WebGpuPMREMGenerator;
|
|
795
|
+
/**
|
|
796
|
+
* Creates and uploads a texture resource immediately instead of waiting for
|
|
797
|
+
* the texture to be encountered while building a material bind group.
|
|
798
|
+
*
|
|
799
|
+
* Repeated calls reuse the cached resource while the Three.js texture
|
|
800
|
+
* version and GPU binding descriptor are unchanged.
|
|
801
|
+
*/
|
|
802
|
+
initTexture(texture: Texture): void;
|
|
803
|
+
createStaticDrawSet(root: Object3D, options?: StaticDrawSetOptions): StaticDrawSet;
|
|
804
|
+
private disposeStaticDrawSetResource;
|
|
805
|
+
private renderFrame;
|
|
806
|
+
destroy(): void;
|
|
807
|
+
private createStaticPipelines;
|
|
808
|
+
private recreateShadowResources;
|
|
809
|
+
private ensureShadowTextureSizes;
|
|
810
|
+
private ensureColorTarget;
|
|
811
|
+
private ensureMsaaColorTarget;
|
|
812
|
+
private ensureMsaaDepthTarget;
|
|
813
|
+
private destroyMsaaResources;
|
|
814
|
+
private getColorTargetView;
|
|
815
|
+
private ensureTextureTarget;
|
|
816
|
+
private getColorTargetTexture;
|
|
817
|
+
private getColorTargetDimensions;
|
|
818
|
+
private getColorTargetFormat;
|
|
819
|
+
private getMaterialGraphTextureReads;
|
|
820
|
+
private createGraphBuilderContext;
|
|
821
|
+
private transparentDraws;
|
|
822
|
+
private opaqueBatches;
|
|
823
|
+
private acquireDrawCall;
|
|
824
|
+
private acquireOpaqueBatchBuilder;
|
|
825
|
+
private populateDrawCall;
|
|
826
|
+
private populateDynamicDrawCall;
|
|
827
|
+
private pushOpaqueDrawTemplate;
|
|
828
|
+
private pushDraw;
|
|
829
|
+
private getToonOutlineParameters;
|
|
830
|
+
private getToonOutlineMaterial;
|
|
831
|
+
private pushToonOutlineDraw;
|
|
832
|
+
private updateTransparentDrawSortDepths;
|
|
833
|
+
private extractScene;
|
|
834
|
+
private collectLine;
|
|
835
|
+
/**
|
|
836
|
+
* Three.js sprites carry a shared quad geometry but are Object3Ds rather
|
|
837
|
+
* than Meshes. Adapt them to the ordinary draw path; the material's vertex
|
|
838
|
+
* shader is responsible for billboard orientation. Sprite.center is an
|
|
839
|
+
* object property, so bake its offset into a private quad instead of putting
|
|
840
|
+
* it on the (potentially shared) material.
|
|
841
|
+
*/
|
|
842
|
+
private collectSprite;
|
|
843
|
+
private hasExtractedDirectionalLight;
|
|
844
|
+
private collectMesh;
|
|
845
|
+
private prepareSceneForCompilation;
|
|
846
|
+
private collectInstancedMesh;
|
|
847
|
+
private collectSkinnedMesh;
|
|
848
|
+
private collectBatchedMesh;
|
|
849
|
+
private uploadInstanceData;
|
|
850
|
+
private uploadResidentInstanceData;
|
|
851
|
+
private clearIndirectBundleCache;
|
|
852
|
+
private clearStaticDrawSetBundleCaches;
|
|
853
|
+
/**
|
|
854
|
+
* Three addon objects (notably Line2/LineSegments2) query this from their
|
|
855
|
+
* onBeforeRender hook to keep their source material's resolution current.
|
|
856
|
+
* The renderer's line shader uses the same physical-pixel dimensions.
|
|
857
|
+
*/
|
|
858
|
+
getViewport(target: Vector4): Vector4;
|
|
859
|
+
private getSharedSceneBindGroup;
|
|
860
|
+
private getSharedShadowBindGroup;
|
|
861
|
+
private getShadowCameraBuffer;
|
|
862
|
+
private getSharedShadowBindGroupForCameraBuffer;
|
|
863
|
+
private buildIndirectSubmissionStreams;
|
|
864
|
+
private getOrCreateStaticIndirectSubmissionStreams;
|
|
865
|
+
private getOrCreateIndirectForwardBundle;
|
|
866
|
+
private getDirectForwardBundleKey;
|
|
867
|
+
private getOrCreateDirectForwardBundle;
|
|
868
|
+
private getOrCreateStaticMaterialBundle;
|
|
869
|
+
private resolveSceneBindGroupForDraw;
|
|
870
|
+
private resolveShadowBindGroupForDraw;
|
|
871
|
+
private uploadDrawMetadata;
|
|
872
|
+
private recordDraw;
|
|
873
|
+
private executeVisibilityPass;
|
|
874
|
+
private executeStaticVisibilityPasses;
|
|
875
|
+
private getOrCreateStaticVisibilityBindGroup;
|
|
876
|
+
private executeDirectionalShadowPass;
|
|
877
|
+
private executePointShadowPass;
|
|
878
|
+
private executeSpotShadowPass;
|
|
879
|
+
private executeDepthPrepass;
|
|
880
|
+
private executeStaticDepthPrepass;
|
|
881
|
+
private executeStaticTemporalDepthResolvePass;
|
|
882
|
+
private getOrCreateStaticDepthPrepassBundle;
|
|
883
|
+
private executeHiZPasses;
|
|
884
|
+
private getOrCreateStaticVisibleSceneBindGroup;
|
|
885
|
+
private getOrCreateStaticVisibleDepthSceneBindGroup;
|
|
886
|
+
private executeMaterialPass;
|
|
887
|
+
private executeForwardPass;
|
|
888
|
+
private executeStaticForwardPass;
|
|
889
|
+
private getOrCreateStaticDirectForwardBundle;
|
|
890
|
+
private refreshStaticDrawMaterialResources;
|
|
891
|
+
private syncStaticVisibleMaterialBindingCaches;
|
|
892
|
+
private recordStaticDrawStats;
|
|
893
|
+
private hasEnabledStaticDrawSets;
|
|
894
|
+
private executePresentPass;
|
|
895
|
+
private clearDirectionalShadow;
|
|
896
|
+
private clearPointShadow;
|
|
897
|
+
private clearSpotShadow;
|
|
898
|
+
private drawDepthLike;
|
|
899
|
+
private getGeometryResource;
|
|
900
|
+
private getSkinnedGeometryResource;
|
|
901
|
+
private getSkinningPalette;
|
|
902
|
+
private refreshSkinningPalette;
|
|
903
|
+
private refreshSkinningBindMatrices;
|
|
904
|
+
private uploadSkinningResources;
|
|
905
|
+
private createSkinningBoneBounds;
|
|
906
|
+
private updateSkinnedBounds;
|
|
907
|
+
private createGeometryBuffers;
|
|
908
|
+
private createVertexBufferLayouts;
|
|
909
|
+
/**
|
|
910
|
+
* A shader location is not a GPU vertex-buffer slot. Keep the simple
|
|
911
|
+
* one-attribute-per-buffer path while it fits, then interleave attributes
|
|
912
|
+
* with the same step mode so optional material attributes cannot exceed the
|
|
913
|
+
* device's vertex-buffer limit.
|
|
914
|
+
*/
|
|
915
|
+
private getVertexAttributeGroups;
|
|
916
|
+
private getGeometryAttributeBufferKey;
|
|
917
|
+
private getGeometryAttributeGroupBufferKey;
|
|
918
|
+
private getMaterialVertexAttributes;
|
|
919
|
+
private getGeometryVertexBuffer;
|
|
920
|
+
private cacheGeometryVertexBufferFast;
|
|
921
|
+
private getInterleavedGeometryVertexBuffer;
|
|
922
|
+
private ensureWireframeIndex;
|
|
923
|
+
private bindGeometryVertexBuffers;
|
|
924
|
+
private getDefaultInstanceAttributeBuffer;
|
|
925
|
+
private getMeshExtractionCacheEntry;
|
|
926
|
+
private getInstancedMeshExtractionCacheEntry;
|
|
927
|
+
private getBatchedMeshExtractionCacheEntry;
|
|
928
|
+
private batchedGeometryIdsMatchSnapshot;
|
|
929
|
+
private destroyGeometryResource;
|
|
930
|
+
private retireGeometryResource;
|
|
931
|
+
private releaseRetiredGeometryResourcesAfterSubmit;
|
|
932
|
+
private destroyTextureResource;
|
|
933
|
+
private createTextureSampler;
|
|
934
|
+
private uploadDataTextureResource;
|
|
935
|
+
private uploadCompressedTextureResource;
|
|
936
|
+
private uploadExternalTextureResource;
|
|
937
|
+
private uploadTextureResource;
|
|
938
|
+
private getTextureResource;
|
|
939
|
+
private updateMaterialUniformBuffer;
|
|
940
|
+
private materialResourceMatches;
|
|
941
|
+
private destroyMaterialResource;
|
|
942
|
+
private createMaterialBindGroupData;
|
|
943
|
+
private createGraphTextureBindGroupLayout;
|
|
944
|
+
private createGraphTextureBindGroup;
|
|
945
|
+
private getGraphTextureView;
|
|
946
|
+
private compileDrawMaterials;
|
|
947
|
+
private compileDrawMaterialsAsync;
|
|
948
|
+
private compileStaticDrawMaterialsAsync;
|
|
949
|
+
private getDepthPassMaterialKey;
|
|
950
|
+
private getForwardMaterialKey;
|
|
951
|
+
private getInstanceAccessModeIndex;
|
|
952
|
+
private getForwardMaterialFastCacheIndex;
|
|
953
|
+
private getDepthMaterialFastCacheIndex;
|
|
954
|
+
private fastMaterialResourceMatches;
|
|
955
|
+
private setForwardMaterialFastCache;
|
|
956
|
+
private getForwardMaterialTargetFastCacheKey;
|
|
957
|
+
private setForwardMaterialTargetFastCache;
|
|
958
|
+
private setForwardMaterialFrameCache;
|
|
959
|
+
private setDepthMaterialFastCache;
|
|
960
|
+
private getDrawInstanceAccessMode;
|
|
961
|
+
private drawUsesBatching;
|
|
962
|
+
private buildMaterialShaderCode;
|
|
963
|
+
private createMaterialPreprocessorDefines;
|
|
964
|
+
private createTexturePreprocessorDefines;
|
|
965
|
+
private shouldInvalidateDrawMaterialResource;
|
|
966
|
+
private cachedDrawMaterialResourceMatches;
|
|
967
|
+
private getMaterialResourceForDraw;
|
|
968
|
+
private getMaterialResourceAsyncForDraw;
|
|
969
|
+
private resolveForwardMaterialResources;
|
|
970
|
+
private getDepthPassMaterialResourceForDraw;
|
|
971
|
+
private getDepthPassMaterialResourceAsyncForDraw;
|
|
972
|
+
private getOrCreateSharedDepthPipeline;
|
|
973
|
+
private getOrCreateSharedDepthPipelineAsync;
|
|
974
|
+
private getOrCreateSharedForwardPipeline;
|
|
975
|
+
private getOrCreateSharedForwardPipelineAsync;
|
|
976
|
+
private getDepthPassMaterialResource;
|
|
977
|
+
private setDepthMaterialFrameCache;
|
|
978
|
+
private getDepthPassMaterialResourceAsync;
|
|
979
|
+
private getMaterialResource;
|
|
980
|
+
private getMaterialResourceAsync;
|
|
981
|
+
private updateCameraUniforms;
|
|
982
|
+
private updateTemporalVisibilityUniforms;
|
|
983
|
+
private commitTemporalHiZHistory;
|
|
984
|
+
private updateLightUniforms;
|
|
985
|
+
private writeShadowCameraBuffer;
|
|
986
|
+
}
|
|
987
|
+
|
|
988
|
+
interface GTAODenoiseOptions {
|
|
989
|
+
readonly radius?: number;
|
|
990
|
+
readonly depthPhi?: number;
|
|
991
|
+
readonly normalPhi?: number;
|
|
992
|
+
readonly lumaPhi?: number;
|
|
993
|
+
}
|
|
994
|
+
interface GTAOOptions {
|
|
995
|
+
/** Resolution relative to the render target. Defaults to 1. */
|
|
996
|
+
readonly resolutionScale?: number;
|
|
997
|
+
readonly radius?: number;
|
|
998
|
+
readonly thickness?: number;
|
|
999
|
+
readonly distanceExponent?: number;
|
|
1000
|
+
readonly distanceFalloff?: number;
|
|
1001
|
+
readonly directions?: number;
|
|
1002
|
+
readonly steps?: number;
|
|
1003
|
+
/** Space used by the encoded normal input. Defaults to world. */
|
|
1004
|
+
readonly normalSpace?: "world" | "view";
|
|
1005
|
+
readonly denoise?: false | GTAODenoiseOptions;
|
|
1006
|
+
readonly targetPrefix?: string;
|
|
1007
|
+
}
|
|
1008
|
+
interface GTAOInputs {
|
|
1009
|
+
readonly depth: FrameGraphTextureHandle;
|
|
1010
|
+
readonly normal: FrameGraphTextureHandle;
|
|
1011
|
+
}
|
|
1012
|
+
interface GTAOCompositeOptions {
|
|
1013
|
+
readonly intensity?: number;
|
|
1014
|
+
readonly power?: number;
|
|
1015
|
+
readonly output?: FrameGraphTextureHandle;
|
|
1016
|
+
}
|
|
1017
|
+
/** Reusable GTAO pass pair. The caller controls where AO is composited. */
|
|
1018
|
+
declare class GTAOEffect {
|
|
1019
|
+
private readonly options;
|
|
1020
|
+
private readonly noiseTexture;
|
|
1021
|
+
private readonly gtaoPasses;
|
|
1022
|
+
private readonly denoisePasses;
|
|
1023
|
+
private readonly compositePasses;
|
|
1024
|
+
constructor(options?: GTAOOptions);
|
|
1025
|
+
addPasses(graph: FrameGraphBuilder, inputs: GTAOInputs): FrameGraphTextureHandle;
|
|
1026
|
+
addCompositePass(graph: FrameGraphBuilder, sceneColor: FrameGraphTextureHandle, ambientOcclusion: FrameGraphTextureHandle, options?: GTAOCompositeOptions): FrameGraphTextureHandle;
|
|
1027
|
+
dispose(): void;
|
|
1028
|
+
}
|
|
1029
|
+
|
|
1030
|
+
interface SSROptions {
|
|
1031
|
+
/** Resolution relative to the main render target. Defaults to 0.5. */
|
|
1032
|
+
readonly resolutionScale?: number;
|
|
1033
|
+
/** Maximum ray length in view-space units. */
|
|
1034
|
+
readonly maxDistance?: number;
|
|
1035
|
+
/** Maximum separation between the ray and the depth buffer at a hit. */
|
|
1036
|
+
readonly thickness?: number;
|
|
1037
|
+
readonly intensity?: number;
|
|
1038
|
+
/** Fade reflections with ray distance. Uses a squared falloff by default. */
|
|
1039
|
+
readonly distanceAttenuation?: boolean;
|
|
1040
|
+
/** Surfaces at or above this roughness do not receive SSR. */
|
|
1041
|
+
readonly maxRoughness?: number;
|
|
1042
|
+
readonly steps?: number;
|
|
1043
|
+
/** Screen pixels advanced per ray step. One preserves reference quality. */
|
|
1044
|
+
readonly pixelStride?: number;
|
|
1045
|
+
/** Space used by the encoded normal input. Defaults to world. */
|
|
1046
|
+
readonly normalSpace?: "world" | "view";
|
|
1047
|
+
readonly blur?: boolean;
|
|
1048
|
+
/** Maximum rough-reflection blur radius in reflection-target pixels. */
|
|
1049
|
+
readonly blurRadius?: number;
|
|
1050
|
+
readonly targetPrefix?: string;
|
|
1051
|
+
}
|
|
1052
|
+
interface SSRInputs {
|
|
1053
|
+
readonly sceneColor: FrameGraphTextureHandle;
|
|
1054
|
+
readonly depth: FrameGraphTextureHandle;
|
|
1055
|
+
/** RGB contains an encoded normal, alpha contains perceptual roughness. */
|
|
1056
|
+
readonly normalRoughness: FrameGraphTextureHandle;
|
|
1057
|
+
}
|
|
1058
|
+
/** Screen-space reflections with an edge-aware spatial resolve. */
|
|
1059
|
+
declare class SSREffect {
|
|
1060
|
+
private readonly options;
|
|
1061
|
+
private readonly passes;
|
|
1062
|
+
constructor(options?: SSROptions);
|
|
1063
|
+
addPasses(graph: FrameGraphBuilder, inputs: SSRInputs): FrameGraphTextureHandle;
|
|
1064
|
+
}
|
|
1065
|
+
|
|
1066
|
+
interface TemporalAAOptions {
|
|
1067
|
+
/** Internal render resolution relative to presentation. Defaults to 1. */
|
|
1068
|
+
readonly renderScale?: number;
|
|
1069
|
+
/** Number of Halton samples before the sequence repeats. Defaults to 32. */
|
|
1070
|
+
readonly sampleCount?: number;
|
|
1071
|
+
/** Current-frame contribution for static pixels. Defaults to 0.06. */
|
|
1072
|
+
readonly minCurrentWeight?: number;
|
|
1073
|
+
/** Motion in pixels that reaches full current-frame weight. Defaults to 24. */
|
|
1074
|
+
readonly motionWeightScale?: number;
|
|
1075
|
+
/** Absolute depth rejection threshold. Defaults to 0.001. */
|
|
1076
|
+
readonly depthThreshold?: number;
|
|
1077
|
+
/** Relative depth rejection threshold. Defaults to 0.002. */
|
|
1078
|
+
readonly relativeDepthThreshold?: number;
|
|
1079
|
+
readonly targetPrefix?: string;
|
|
1080
|
+
}
|
|
1081
|
+
declare class TemporalAAEffect {
|
|
1082
|
+
readonly renderScale: number;
|
|
1083
|
+
private readonly sampleCount;
|
|
1084
|
+
private readonly minCurrentWeight;
|
|
1085
|
+
private readonly motionWeightScale;
|
|
1086
|
+
private readonly depthThreshold;
|
|
1087
|
+
private readonly relativeDepthThreshold;
|
|
1088
|
+
private readonly targetPrefix;
|
|
1089
|
+
private writeIndex;
|
|
1090
|
+
private historyValid;
|
|
1091
|
+
private frameIndex;
|
|
1092
|
+
private renderWidth;
|
|
1093
|
+
private renderHeight;
|
|
1094
|
+
private outputWidth;
|
|
1095
|
+
private outputHeight;
|
|
1096
|
+
private readonly jitter;
|
|
1097
|
+
private readonly unjitteredProjection;
|
|
1098
|
+
private readonly previousJitterUv;
|
|
1099
|
+
readonly currentJitterUv: Vector2;
|
|
1100
|
+
readonly previousViewProjection: Matrix4;
|
|
1101
|
+
private readonly resolvePasses;
|
|
1102
|
+
constructor(options?: TemporalAAOptions);
|
|
1103
|
+
/** Apply one non-accumulating sub-pixel jitter immediately before rendering. */
|
|
1104
|
+
prepareCamera(camera: {
|
|
1105
|
+
projectionMatrix: Matrix4;
|
|
1106
|
+
projectionMatrixInverse?: Matrix4;
|
|
1107
|
+
updateProjectionMatrix(): void;
|
|
1108
|
+
}, presentationWidth: number, presentationHeight: number): void;
|
|
1109
|
+
/** Restore the unjittered projection after rendering for non-render systems. */
|
|
1110
|
+
finishCamera(camera: {
|
|
1111
|
+
projectionMatrix: Matrix4;
|
|
1112
|
+
projectionMatrixInverse?: Matrix4;
|
|
1113
|
+
}): void;
|
|
1114
|
+
addPass(graph: FrameGraphBuilder, currentColor: FrameGraphTextureHandle, currentDepth?: FrameGraphTextureHandle): FrameGraphTextureHandle;
|
|
1115
|
+
reset(): void;
|
|
1116
|
+
private setSize;
|
|
1117
|
+
updateResolveUniforms(uniforms: Float32Array, currentViewProjection: Matrix4, currentViewProjectionInverse: Matrix4, context: RendererCustomPassContext): void;
|
|
1118
|
+
}
|
|
1119
|
+
|
|
1120
|
+
interface FXAAOptions {
|
|
1121
|
+
/** Minimum local luminance contrast treated as an edge. Defaults to 0.0312. */
|
|
1122
|
+
readonly contrastThreshold?: number;
|
|
1123
|
+
/** Edge threshold relative to the brightest local sample. Defaults to 0.063. */
|
|
1124
|
+
readonly relativeThreshold?: number;
|
|
1125
|
+
/** Low-contrast subpixel aliasing removal strength, from 0 to 1. Defaults to 0.75. */
|
|
1126
|
+
readonly subpixelBlending?: number;
|
|
1127
|
+
readonly targetPrefix?: string;
|
|
1128
|
+
}
|
|
1129
|
+
interface FXAACompositeOptions {
|
|
1130
|
+
readonly output?: FrameGraphTextureHandle;
|
|
1131
|
+
}
|
|
1132
|
+
/** Fast, single-pass post-process antialiasing based on NVIDIA FXAA 3.11. */
|
|
1133
|
+
declare class FXAAEffect {
|
|
1134
|
+
contrastThreshold: number;
|
|
1135
|
+
relativeThreshold: number;
|
|
1136
|
+
subpixelBlending: number;
|
|
1137
|
+
private readonly targetPrefix;
|
|
1138
|
+
private readonly passes;
|
|
1139
|
+
constructor(options?: FXAAOptions);
|
|
1140
|
+
addPass(graph: FrameGraphBuilder, source: FrameGraphTextureHandle, options?: FXAACompositeOptions): FrameGraphTextureHandle;
|
|
1141
|
+
}
|
|
1142
|
+
|
|
1143
|
+
interface BloomOptions {
|
|
1144
|
+
/** Overall bloom contribution. Defaults to 0.9. */
|
|
1145
|
+
readonly strength?: number;
|
|
1146
|
+
/** Bright-pass threshold in linear HDR units. Defaults to 1. */
|
|
1147
|
+
readonly threshold?: number;
|
|
1148
|
+
/** Width of the soft transition around the threshold. Defaults to 0.1. */
|
|
1149
|
+
readonly knee?: number;
|
|
1150
|
+
/** Bias toward wider mip levels, from 0 to 1. Defaults to 0.2. */
|
|
1151
|
+
readonly radius?: number;
|
|
1152
|
+
/** Number of progressively downsampled blur levels. Defaults to 5. */
|
|
1153
|
+
readonly levels?: number;
|
|
1154
|
+
readonly targetPrefix?: string;
|
|
1155
|
+
}
|
|
1156
|
+
interface BloomCompositeOptions {
|
|
1157
|
+
readonly output?: FrameGraphTextureHandle;
|
|
1158
|
+
}
|
|
1159
|
+
/** HDR bloom using a soft bright pass and a progressively downsampled Gaussian pyramid. */
|
|
1160
|
+
declare class BloomEffect {
|
|
1161
|
+
strength: number;
|
|
1162
|
+
threshold: number;
|
|
1163
|
+
knee: number;
|
|
1164
|
+
radius: number;
|
|
1165
|
+
private readonly levels;
|
|
1166
|
+
private readonly targetPrefix;
|
|
1167
|
+
private readonly passes;
|
|
1168
|
+
constructor(options?: BloomOptions);
|
|
1169
|
+
addPass(graph: FrameGraphBuilder, source: FrameGraphTextureHandle, options?: BloomCompositeOptions): FrameGraphTextureHandle;
|
|
1170
|
+
}
|
|
1171
|
+
|
|
1172
|
+
type ColorGradingVector = readonly [number, number, number];
|
|
1173
|
+
type ToneMappingMode = "none" | "linear" | "reinhard" | "cineon" | "aces" | "agx" | "neutral";
|
|
1174
|
+
interface ColorGradingRange {
|
|
1175
|
+
saturation?: ColorGradingVector;
|
|
1176
|
+
contrast?: ColorGradingVector;
|
|
1177
|
+
gamma?: ColorGradingVector;
|
|
1178
|
+
gain?: ColorGradingVector;
|
|
1179
|
+
offset?: ColorGradingVector;
|
|
1180
|
+
}
|
|
1181
|
+
interface ColorGradingOptions extends ColorGradingRange {
|
|
1182
|
+
enabled?: boolean;
|
|
1183
|
+
exposure?: number;
|
|
1184
|
+
toneMapping?: ToneMappingMode;
|
|
1185
|
+
vignetteIntensity?: number;
|
|
1186
|
+
whiteBalance?: ColorGradingVector;
|
|
1187
|
+
tint?: ColorGradingVector;
|
|
1188
|
+
tintIntensity?: number;
|
|
1189
|
+
shadows?: ColorGradingRange;
|
|
1190
|
+
midtones?: ColorGradingRange;
|
|
1191
|
+
highlights?: ColorGradingRange;
|
|
1192
|
+
shadowsMax?: number;
|
|
1193
|
+
highlightsMin?: number;
|
|
1194
|
+
targetPrefix?: string;
|
|
1195
|
+
}
|
|
1196
|
+
/** HDR color correction, three-way grading, vignette, and final display tone mapping. */
|
|
1197
|
+
declare class ColorGradingEffect {
|
|
1198
|
+
readonly options: ColorGradingOptions;
|
|
1199
|
+
private readonly passes;
|
|
1200
|
+
private readonly targetPrefix;
|
|
1201
|
+
constructor(options?: ColorGradingOptions);
|
|
1202
|
+
addPass(graph: FrameGraphBuilder, source: FrameGraphTextureHandle): FrameGraphTextureHandle;
|
|
1203
|
+
}
|
|
1204
|
+
|
|
1205
|
+
interface DepthOfFieldOptions {
|
|
1206
|
+
enabled?: boolean;
|
|
1207
|
+
focus?: number;
|
|
1208
|
+
aperture?: number;
|
|
1209
|
+
maxBlur?: number;
|
|
1210
|
+
targetPrefix?: string;
|
|
1211
|
+
}
|
|
1212
|
+
/** Depth-aware lens blur. Values follow Three's BokehPass focus/aperture/maxblur convention. */
|
|
1213
|
+
declare class DepthOfFieldEffect {
|
|
1214
|
+
readonly options: DepthOfFieldOptions;
|
|
1215
|
+
private readonly passes;
|
|
1216
|
+
private readonly targetPrefix;
|
|
1217
|
+
constructor(options?: DepthOfFieldOptions);
|
|
1218
|
+
addPass(graph: FrameGraphBuilder, source: FrameGraphTextureHandle, depth: FrameGraphTextureHandle): FrameGraphTextureHandle;
|
|
1219
|
+
}
|
|
1220
|
+
|
|
1221
|
+
interface OutlineOptions {
|
|
1222
|
+
readonly enabled?: boolean;
|
|
1223
|
+
readonly visibleEdgeColor?: readonly [number, number, number];
|
|
1224
|
+
readonly edgeStrength?: number;
|
|
1225
|
+
/** Outline radius in physical render pixels. */
|
|
1226
|
+
readonly edgeThickness?: number;
|
|
1227
|
+
readonly targetPrefix?: string;
|
|
1228
|
+
}
|
|
1229
|
+
interface OutlineInputs {
|
|
1230
|
+
readonly sceneColor: FrameGraphTextureHandle;
|
|
1231
|
+
/** Selected roots. Descendants are selected automatically. */
|
|
1232
|
+
readonly selectedObjects: ReadonlySet<Object3D>;
|
|
1233
|
+
}
|
|
1234
|
+
interface OutlineInstanceSelection {
|
|
1235
|
+
readonly object: Object3D;
|
|
1236
|
+
/** InstancedMesh instance index or BatchedMesh geometry/batching id. */
|
|
1237
|
+
readonly instanceIndex: number;
|
|
1238
|
+
}
|
|
1239
|
+
/**
|
|
1240
|
+
* Selection outline for the frame graph. The mask is rendered with the same
|
|
1241
|
+
* geometry, skinning, instancing and batching paths as the main scene.
|
|
1242
|
+
*/
|
|
1243
|
+
declare class OutlineEffect {
|
|
1244
|
+
enabled: boolean;
|
|
1245
|
+
visibleEdgeColor: [number, number, number];
|
|
1246
|
+
edgeStrength: number;
|
|
1247
|
+
edgeThickness: number;
|
|
1248
|
+
readonly selectedObjects: Set<Object3D<three.Object3DEventMap>>;
|
|
1249
|
+
readonly selectedInstances: OutlineInstanceSelection[];
|
|
1250
|
+
private readonly targetPrefix;
|
|
1251
|
+
private readonly maskMaterial;
|
|
1252
|
+
private readonly skinnedMaskMaterial;
|
|
1253
|
+
private readonly instanceMaskMaterials;
|
|
1254
|
+
private readonly passes;
|
|
1255
|
+
constructor(options?: OutlineOptions);
|
|
1256
|
+
setSelectedObjects(objects: Iterable<Object3D>): void;
|
|
1257
|
+
setSelectedInstances(selections: Iterable<OutlineInstanceSelection>): void;
|
|
1258
|
+
addPass(graph: FrameGraphBuilder, source: FrameGraphTextureHandle): FrameGraphTextureHandle;
|
|
1259
|
+
dispose(): void;
|
|
1260
|
+
}
|
|
1261
|
+
|
|
1262
|
+
export { type BloomCompositeOptions, BloomEffect, type BloomOptions, ColorGradingEffect, type ColorGradingOptions, type ColorGradingRange, type ColorGradingVector, type CompiledNodeFullscreenShader, ComputeKernel, type ComputeKernelDescriptor, DEFAULT_WGSL_VERTEX_ATTRIBUTES, DepthOfFieldEffect, type DepthOfFieldOptions, type FXAACompositeOptions, FXAAEffect, type FXAAOptions, FrameGraphBuilder, type FrameGraphFullscreenPassDescriptor, type FrameGraphMaterialPassDescriptor, type FrameGraphNodeFullscreenPassDescriptor, type FrameGraphPassDescriptor, type FrameGraphTextureHandle, type GTAOCompositeOptions, type GTAODenoiseOptions, GTAOEffect, type GTAOInputs, type GTAOOptions, OutlineEffect, type OutlineInputs, type OutlineInstanceSelection, type OutlineOptions, RenderGraph, type RenderGraphContext, type RenderGraphExecutionObserver, type RenderGraphPass, type RendererColorTargetDescriptor, type RendererCustomPassContext, type RendererCustomPassDescriptor, type RendererFrameProfile, type RendererGraphBuilder, type RendererGraphBuilderContext, type RendererMaterialPassDescriptor, type RendererMaterialResolver, type RendererOptions, type RendererPassProfile, type RendererShadowMapDebugInfo, type RendererShadowMapDebugTextureInfo, type RendererTextureTargetDescriptor, type RendererVisibilityProfile, SSREffect, type SSRInputs, type SSROptions, type ShaderDefineValue, type ShaderDefines, type StaticDrawSet, type StaticDrawSetOptions, TemporalAAEffect, type TemporalAAOptions, type ToneMappingMode, type ToonOutlineParameters, type UniformDefinition, type UniformType, type UniformValue, VOLUMETRIC_FOG_MATERIAL_WGSL, type VolumetricFogBlurOptions, VolumetricFogEffect, type VolumetricFogInputs, type VolumetricFogOptions, type VolumetricFogScatteringMode, VolumetricFogVolumeObject, type VolumetricFogVolumeSettings, type WGSLGraphTextureDimension, type WGSLGraphTextureInput, type WGSLSceneTextureSemantic, WGSLShaderMaterial, type WGSLShaderMaterialParameters, type WGSLShaderMaterialUniform, type WGSLShaderMaterialUniformInput, type WGSLStorageBufferBinding, type WGSLStorageBufferVisibility, type WGSLSupportedVertexFormat, type WGSLVertexAttributeBinding, WebGpuPMREMGenerator, WebGpuRenderer, configureVolumetricFogMaterial };
|