@hology/webgpu-renderer 0.1.6 → 0.1.7

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/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as three from 'three';
2
- import { Color, Vector2, Vector3, Vector4, Matrix3, Matrix4, Material, Texture, MaterialParameters, DirectionalLight, Object3D, PerspectiveCamera, OrthographicCamera, Scene } from 'three';
2
+ import { Color, Vector2, Vector3, Vector4, Matrix3, Matrix4, Material, Texture, MaterialParameters, DirectionalLight, PointLight, SpotLight, Object3D, PerspectiveCamera, OrthographicCamera, Scene } from 'three';
3
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
4
 
5
5
  interface ComputeKernelDescriptor {
@@ -137,6 +137,8 @@ declare class WGSLShaderMaterial extends Material {
137
137
  customProgramCacheKey(): string;
138
138
  getTexturesList(): readonly Texture[];
139
139
  usesSceneTextures(): boolean;
140
+ usesSceneColor(): boolean;
141
+ usesSceneDepth(): boolean;
140
142
  getGraphTextureInputs(): Record<string, WGSLGraphTextureInput>;
141
143
  requiresLatePass(): boolean;
142
144
  getUniformValueHash(): number;
@@ -177,6 +179,9 @@ declare class RenderGraph {
177
179
  private resolveExecutionOrder;
178
180
  }
179
181
 
182
+ /** Shared renderer lighting ABI for procedural particle geometry. */
183
+ declare function buildParticleLightingShaderHeader(receiveShadow?: boolean, modelMatrixBody?: string): string;
184
+
180
185
  interface TextureResource {
181
186
  version: number;
182
187
  width: number;
@@ -230,10 +235,12 @@ interface ExtractedDirectionalLight {
230
235
  shadowCameraFar: number;
231
236
  }
232
237
  interface ExtractedPointLight {
238
+ sourceLight: PointLight;
233
239
  position: Vector3;
234
240
  color: Vector3;
235
241
  intensity: number;
236
242
  volumetricIntensity: number;
243
+ distance: number;
237
244
  range: number;
238
245
  decay: number;
239
246
  castShadow: boolean;
@@ -246,6 +253,7 @@ interface ExtractedPointLight {
246
253
  shadowCameraFar: number;
247
254
  }
248
255
  interface ExtractedSpotLight {
256
+ sourceLight: SpotLight;
249
257
  position: Vector3;
250
258
  direction: Vector3;
251
259
  color: Vector3;
@@ -308,6 +316,12 @@ interface RendererOptions {
308
316
  interface StaticDrawSetOptions {
309
317
  label?: string;
310
318
  onUnsupported?: "throw" | "skip";
319
+ /**
320
+ * Admit transparent and scene-texture materials and render them, in their
321
+ * stable recorded order, during the late pass. No camera-depth sorting is
322
+ * performed inside the set.
323
+ */
324
+ allowUnsortedLateDraws?: boolean;
311
325
  }
312
326
  interface StaticDrawSet {
313
327
  readonly label: string;
@@ -337,7 +351,10 @@ interface RendererGraphBuilderContext {
337
351
  defineTextureTarget(name: string, descriptor?: RendererTextureTargetDescriptor): void;
338
352
  addForwardPass(output?: string): void;
339
353
  addOpaquePass(output?: string): void;
340
- addSceneTextureCopyPass(source?: string): void;
354
+ addSceneTextureCopyPass(source?: string, requirements?: {
355
+ readonly sceneColor?: boolean;
356
+ readonly sceneDepth?: boolean;
357
+ }): void;
341
358
  addLatePass(output?: string): void;
342
359
  addHiZHistoryPass(dependsOn?: string): void;
343
360
  addMaterialPass(descriptor?: RendererMaterialPassDescriptor): void;
@@ -411,7 +428,10 @@ interface RendererCustomPassContext {
411
428
  getSceneLightingResources(): RendererSceneLightingResources;
412
429
  }
413
430
  interface RendererSceneLightingResources {
431
+ readonly cameraBuffer: GPUBuffer;
414
432
  readonly lightBuffer: GPUBuffer;
433
+ readonly shadowSampler: GPUSampler;
434
+ readonly linearSampler: GPUSampler;
415
435
  readonly directionalShadowView: GPUTextureView;
416
436
  readonly pointShadowView: GPUTextureView;
417
437
  readonly spotShadowView: GPUTextureView;
@@ -528,7 +548,10 @@ declare class FrameGraphBuilder {
528
548
  addVisibilityPass(): void;
529
549
  addForwardPass(output?: FrameGraphTextureHandle): void;
530
550
  addOpaquePass(output?: FrameGraphTextureHandle): void;
531
- addSceneTextureCopyPass(source?: FrameGraphTextureHandle): void;
551
+ addSceneTextureCopyPass(source?: FrameGraphTextureHandle, requirements?: {
552
+ readonly sceneColor?: boolean;
553
+ readonly sceneDepth?: boolean;
554
+ }): void;
532
555
  addLatePass(output?: FrameGraphTextureHandle): void;
533
556
  addHiZHistoryPass(dependsOn?: string): void;
534
557
  addMaterialPass(descriptor?: FrameGraphMaterialPassDescriptor): void;
@@ -648,6 +671,22 @@ declare class VolumetricFogEffect {
648
671
  private readonly uniformIntegers;
649
672
  private readonly volumeData;
650
673
  private readonly lightData;
674
+ private readonly selectedPointIndices;
675
+ private readonly selectedPointScores;
676
+ private readonly selectedSpotIndices;
677
+ private readonly selectedSpotScores;
678
+ private readonly collectedVolumes;
679
+ private readonly collectedDirectionals;
680
+ private readonly collectedPoints;
681
+ private readonly collectedSpots;
682
+ private volumeCount;
683
+ private directionalCount;
684
+ private pointCount;
685
+ private spotCount;
686
+ private collectionCamera;
687
+ private readonly collectVolumeObject;
688
+ private readonly collectLightObject;
689
+ private readonly executeFroxelPass;
651
690
  private readonly projectionInverse;
652
691
  private readonly viewProjectionInverse;
653
692
  private readonly previousTemporalViewProjection;
@@ -679,8 +718,9 @@ declare class VolumetricFogEffect {
679
718
  dispose(): void;
680
719
  private executeFroxels;
681
720
  private collectSceneData;
721
+ /** Selects the nearest local lights without depending on camera rotation. */
722
+ private selectClosestLights;
682
723
  private writeVolume;
683
- private lightColor;
684
724
  private writeDirectional;
685
725
  private writeExtractedDirectional;
686
726
  private writePoint;
@@ -828,6 +868,8 @@ declare class WebGpuRenderer {
828
868
  private readonly standardVertexAttributeCache;
829
869
  private readonly geometryVertexBufferFastCache;
830
870
  private readonly vertexAttributeGroupCache;
871
+ private readonly materialVertexAttributeCache;
872
+ private readonly vertexBufferBindingPlanCache;
831
873
  private readonly vertexAttributeGroupBufferKeyCache;
832
874
  private readonly compileDrawScratch;
833
875
  private readonly dynamicIndirectSubmissionCache;
@@ -911,6 +953,7 @@ declare class WebGpuRenderer {
911
953
  private hasRenderCallbacks;
912
954
  initialize(): Promise<void>;
913
955
  createComputeKernel(descriptor: ComputeKernelDescriptor): ComputeKernel;
956
+ getDevice(): GPUDevice | null;
914
957
  setRenderGraphBuilder(builder: RendererGraphBuilder): void;
915
958
  /**
916
959
  * Associates the first directional shadow layers with cascaded-shadow-map
@@ -1107,6 +1150,8 @@ declare class WebGpuRenderer {
1107
1150
  private getInterleavedGeometryVertexBuffer;
1108
1151
  private ensureWireframeIndex;
1109
1152
  private bindGeometryVertexBuffers;
1153
+ private getStandardVertexAttribute;
1154
+ private prepareDrawGeometryVertexBuffers;
1110
1155
  private getDefaultInstanceAttributeBuffer;
1111
1156
  private getMeshExtractionCacheEntry;
1112
1157
  private getInstancedMeshExtractionCacheEntry;
@@ -1607,4 +1652,4 @@ declare class OutlineEffect {
1607
1652
  dispose(): void;
1608
1653
  }
1609
1654
 
1610
- 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, type GTAOQuality, type GTAOTemporalOptions, GTAO_PRESETS, MOTION_BLUR_PRESETS, MotionBlurEffect, MotionBlurMode, type MotionBlurOptions, type MotionBlurOverride, type MotionBlurOverrideHandle, type MotionBlurQuality, 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, type SMAACompositeOptions, type SMAAEdgeDetectionMode, SMAAEffect, type SMAAOptions, type SMAAQualityPreset, 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, VOLUMETRIC_FOG_PRESETS, type VolumetricFogBlurOptions, VolumetricFogEffect, type VolumetricFogInputs, type VolumetricFogOptions, type VolumetricFogQuality, type VolumetricFogScatteringMode, type VolumetricFogTemporalOptions, 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 };
1655
+ 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, type GTAOQuality, type GTAOTemporalOptions, GTAO_PRESETS, MOTION_BLUR_PRESETS, MotionBlurEffect, MotionBlurMode, type MotionBlurOptions, type MotionBlurOverride, type MotionBlurOverrideHandle, type MotionBlurQuality, 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, type SMAACompositeOptions, type SMAAEdgeDetectionMode, SMAAEffect, type SMAAOptions, type SMAAQualityPreset, 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, VOLUMETRIC_FOG_PRESETS, type VolumetricFogBlurOptions, VolumetricFogEffect, type VolumetricFogInputs, type VolumetricFogOptions, type VolumetricFogQuality, type VolumetricFogScatteringMode, type VolumetricFogTemporalOptions, 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, buildParticleLightingShaderHeader, configureVolumetricFogMaterial };