@hology/webgpu-renderer 0.1.7 → 0.1.9
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 +27 -4
- package/dist/index.js +1 -1
- package/package.json +1 -1
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, PointLight, SpotLight, Object3D, PerspectiveCamera, OrthographicCamera, Scene } from 'three';
|
|
2
|
+
import { Color, Vector2, Vector3, Vector4, Matrix3, Matrix4, Material, Texture, MaterialParameters, DirectionalLight, PointLight, SpotLight, Object3D, PerspectiveCamera, OrthographicCamera, BufferGeometry, 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 {
|
|
@@ -380,6 +380,8 @@ interface RendererMaterialPassDescriptor {
|
|
|
380
380
|
readonly drawStage?: "all" | "opaque" | "late";
|
|
381
381
|
/** Preserve existing attachment contents instead of clearing them. */
|
|
382
382
|
readonly loadColor?: boolean;
|
|
383
|
+
/** Color used when clearing the attachments. Defaults to the renderer clear color. */
|
|
384
|
+
readonly clearColor?: readonly [number, number, number, number];
|
|
383
385
|
/** Preserve depth written by an earlier pass. Defaults to clear. */
|
|
384
386
|
readonly loadDepth?: boolean;
|
|
385
387
|
/** Draw only objects accepted by this predicate. Intended for selection/mask passes. */
|
|
@@ -422,6 +424,8 @@ interface RendererCustomPassContext {
|
|
|
422
424
|
view: GPUTextureView;
|
|
423
425
|
sampler: GPUSampler;
|
|
424
426
|
};
|
|
427
|
+
/** Resolves the current renderer-owned vertex buffer for a geometry. */
|
|
428
|
+
getGeometryVertexBuffer(geometry: BufferGeometry, attribute: "position" | "normal"): GPUBuffer;
|
|
425
429
|
getColorFormat(name: string): GPUTextureFormat;
|
|
426
430
|
getShadowMapDebugInfo(): RendererShadowMapDebugInfo;
|
|
427
431
|
/** Shared light uniforms and shadow arrays used by the forward renderer. */
|
|
@@ -527,6 +531,7 @@ interface FrameGraphMaterialPassDescriptor {
|
|
|
527
531
|
readonly outputs?: FrameGraphTextureHandle | readonly FrameGraphTextureHandle[];
|
|
528
532
|
readonly drawStage?: "all" | "opaque" | "late";
|
|
529
533
|
readonly loadColor?: boolean;
|
|
534
|
+
readonly clearColor?: readonly [number, number, number, number];
|
|
530
535
|
readonly loadDepth?: boolean;
|
|
531
536
|
readonly objectFilter?: (object: Object3D | null) => boolean;
|
|
532
537
|
readonly overrideMaterial?: WGSLShaderMaterial | ((source: WGSLShaderMaterial, skinned: boolean) => WGSLShaderMaterial);
|
|
@@ -611,8 +616,8 @@ interface VolumetricFogOptions {
|
|
|
611
616
|
/** Temporal sub-froxel jitter accumulated by fog history and optionally TAA. */
|
|
612
617
|
readonly temporalJitter?: boolean;
|
|
613
618
|
/**
|
|
614
|
-
* Fog-local temporal reconstruction
|
|
615
|
-
*
|
|
619
|
+
* Fog-local temporal reconstruction of the 3D scattering/extinction grid.
|
|
620
|
+
* This history is accumulated before front-to-back integration.
|
|
616
621
|
*/
|
|
617
622
|
readonly temporal?: false | VolumetricFogTemporalOptions;
|
|
618
623
|
/** Stable per-ray depth jitter. Breaks slice bands without animated noise. */
|
|
@@ -664,6 +669,8 @@ declare class VolumetricFogEffect {
|
|
|
664
669
|
private scene;
|
|
665
670
|
readonly integratedVolume: FrameGraphTextureHandle;
|
|
666
671
|
readonly columnDepthBounds: FrameGraphTextureHandle;
|
|
672
|
+
readonly scatteringHistoryA: FrameGraphTextureHandle;
|
|
673
|
+
readonly scatteringHistoryB: FrameGraphTextureHandle;
|
|
667
674
|
private readonly options;
|
|
668
675
|
private readonly resources;
|
|
669
676
|
private readonly uniformStorage;
|
|
@@ -690,6 +697,16 @@ declare class VolumetricFogEffect {
|
|
|
690
697
|
private readonly projectionInverse;
|
|
691
698
|
private readonly viewProjectionInverse;
|
|
692
699
|
private readonly previousTemporalViewProjection;
|
|
700
|
+
private readonly previousFroxelViewProjection;
|
|
701
|
+
private readonly previousFroxelCameraPosition;
|
|
702
|
+
private previousFroxelNear;
|
|
703
|
+
private previousFroxelFar;
|
|
704
|
+
private previousFroxelWidth;
|
|
705
|
+
private previousFroxelHeight;
|
|
706
|
+
private froxelHistoryValid;
|
|
707
|
+
private froxelHistoryWriteIndex;
|
|
708
|
+
private activeHistoryRead;
|
|
709
|
+
private activeHistoryWrite;
|
|
693
710
|
private explicitVolumes;
|
|
694
711
|
private volumeObjects;
|
|
695
712
|
private extractedLights;
|
|
@@ -730,7 +747,7 @@ declare class VolumetricFogEffect {
|
|
|
730
747
|
private getResources;
|
|
731
748
|
}
|
|
732
749
|
/** WGSL appended to a material that calls rendererApplyVolumetricFog(). */
|
|
733
|
-
declare const VOLUMETRIC_FOG_MATERIAL_WGSL = "\nfn
|
|
750
|
+
declare const VOLUMETRIC_FOG_MATERIAL_WGSL = "\nfn rendererSampleIntegratedFogRaw(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 rendererSampleIntegratedFog(uv: vec2<f32>, normalizedDepth: f32) -> vec4<f32> {\n return rendererSampleIntegratedFogRaw(uv, normalizedDepth);\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(log(max(distance, bounds.x) / bounds.x) / max(log(bounds.y / bounds.x), 0.0001), 0.0, 1.0);\n let fog = rendererSampleIntegratedFog(uv, z);\n return vec4<f32>(fog.rgb + color.rgb * fog.a, color.a);\n}";
|
|
734
751
|
/** Adds the froxel input; append VOLUMETRIC_FOG_MATERIAL_WGSL and call its helper in fsMain. */
|
|
735
752
|
declare function configureVolumetricFogMaterial(material: WGSLShaderMaterial, resource?: string, boundsResource?: string): WGSLShaderMaterial;
|
|
736
753
|
|
|
@@ -1126,6 +1143,8 @@ declare class WebGpuRenderer {
|
|
|
1126
1143
|
private clearSpotShadow;
|
|
1127
1144
|
private drawDepthLike;
|
|
1128
1145
|
private getGeometryResource;
|
|
1146
|
+
/** Upload changed standard BufferAttributes without replacing their buffers. */
|
|
1147
|
+
private updateDynamicGeometryAttributes;
|
|
1129
1148
|
private getSkinnedGeometryResource;
|
|
1130
1149
|
private getSkinningPalette;
|
|
1131
1150
|
private refreshSkinningPalette;
|
|
@@ -1617,6 +1636,8 @@ interface OutlineOptions {
|
|
|
1617
1636
|
readonly edgeStrength?: number;
|
|
1618
1637
|
/** Outline radius in physical render pixels. */
|
|
1619
1638
|
readonly edgeThickness?: number;
|
|
1639
|
+
/** Width of the outline's antialiased falloff in physical render pixels. */
|
|
1640
|
+
readonly edgeSoftness?: number;
|
|
1620
1641
|
readonly targetPrefix?: string;
|
|
1621
1642
|
}
|
|
1622
1643
|
interface OutlineInputs {
|
|
@@ -1638,6 +1659,7 @@ declare class OutlineEffect {
|
|
|
1638
1659
|
visibleEdgeColor: [number, number, number];
|
|
1639
1660
|
edgeStrength: number;
|
|
1640
1661
|
edgeThickness: number;
|
|
1662
|
+
edgeSoftness: number;
|
|
1641
1663
|
readonly selectedObjects: Set<Object3D<three.Object3DEventMap>>;
|
|
1642
1664
|
readonly selectedInstances: OutlineInstanceSelection[];
|
|
1643
1665
|
private readonly targetPrefix;
|
|
@@ -1649,6 +1671,7 @@ declare class OutlineEffect {
|
|
|
1649
1671
|
setSelectedObjects(objects: Iterable<Object3D>): void;
|
|
1650
1672
|
setSelectedInstances(selections: Iterable<OutlineInstanceSelection>): void;
|
|
1651
1673
|
addPass(graph: FrameGraphBuilder, source: FrameGraphTextureHandle): FrameGraphTextureHandle;
|
|
1674
|
+
private addCachedPass;
|
|
1652
1675
|
dispose(): void;
|
|
1653
1676
|
}
|
|
1654
1677
|
|