@aura3d/rendering 1.0.6
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 +18 -0
- package/dist/ArchitecturalLightingFixtures.d.ts +40 -0
- package/dist/ArchitecturalLightingFixtures.d.ts.map +1 -0
- package/dist/ArchitecturalLightingFixtures.js +171 -0
- package/dist/ArchitecturalLightingFixtures.js.map +1 -0
- package/dist/ArchitecturalMaterialCatalog.d.ts +30 -0
- package/dist/ArchitecturalMaterialCatalog.d.ts.map +1 -0
- package/dist/ArchitecturalMaterialCatalog.js +90 -0
- package/dist/ArchitecturalMaterialCatalog.js.map +1 -0
- package/dist/ArchitecturalMeasurementFixtures.d.ts +30 -0
- package/dist/ArchitecturalMeasurementFixtures.d.ts.map +1 -0
- package/dist/ArchitecturalMeasurementFixtures.js +115 -0
- package/dist/ArchitecturalMeasurementFixtures.js.map +1 -0
- package/dist/BRDFLut.d.ts +13 -0
- package/dist/BRDFLut.d.ts.map +1 -0
- package/dist/BRDFLut.js +34 -0
- package/dist/BRDFLut.js.map +1 -0
- package/dist/CameraFraming.d.ts +31 -0
- package/dist/CameraFraming.d.ts.map +1 -0
- package/dist/CameraFraming.js +143 -0
- package/dist/CameraFraming.js.map +1 -0
- package/dist/CanonicalSceneFixtures.d.ts +13 -0
- package/dist/CanonicalSceneFixtures.d.ts.map +1 -0
- package/dist/CanonicalSceneFixtures.js +78 -0
- package/dist/CanonicalSceneFixtures.js.map +1 -0
- package/dist/CascadedShadowMaps.d.ts +121 -0
- package/dist/CascadedShadowMaps.d.ts.map +1 -0
- package/dist/CascadedShadowMaps.js +315 -0
- package/dist/CascadedShadowMaps.js.map +1 -0
- package/dist/ColorManagement.d.ts +33 -0
- package/dist/ColorManagement.d.ts.map +1 -0
- package/dist/ColorManagement.js +71 -0
- package/dist/ColorManagement.js.map +1 -0
- package/dist/CullingFixtures.d.ts +70 -0
- package/dist/CullingFixtures.d.ts.map +1 -0
- package/dist/CullingFixtures.js +191 -0
- package/dist/CullingFixtures.js.map +1 -0
- package/dist/DecalGeometry.d.ts +3 -0
- package/dist/DecalGeometry.d.ts.map +1 -0
- package/dist/DecalGeometry.js +2 -0
- package/dist/DecalGeometry.js.map +1 -0
- package/dist/DepthPass.d.ts +23 -0
- package/dist/DepthPass.d.ts.map +1 -0
- package/dist/DepthPass.js +99 -0
- package/dist/DepthPass.js.map +1 -0
- package/dist/EnvironmentBackgroundPass.d.ts +27 -0
- package/dist/EnvironmentBackgroundPass.d.ts.map +1 -0
- package/dist/EnvironmentBackgroundPass.js +167 -0
- package/dist/EnvironmentBackgroundPass.js.map +1 -0
- package/dist/EnvironmentBackgroundResources.d.ts +31 -0
- package/dist/EnvironmentBackgroundResources.d.ts.map +1 -0
- package/dist/EnvironmentBackgroundResources.js +237 -0
- package/dist/EnvironmentBackgroundResources.js.map +1 -0
- package/dist/EnvironmentLighting.d.ts +10 -0
- package/dist/EnvironmentLighting.d.ts.map +1 -0
- package/dist/EnvironmentLighting.js +64 -0
- package/dist/EnvironmentLighting.js.map +1 -0
- package/dist/EnvironmentMapResources.d.ts +98 -0
- package/dist/EnvironmentMapResources.d.ts.map +1 -0
- package/dist/EnvironmentMapResources.js +794 -0
- package/dist/EnvironmentMapResources.js.map +1 -0
- package/dist/EnvironmentPipeline.d.ts +21 -0
- package/dist/EnvironmentPipeline.d.ts.map +1 -0
- package/dist/EnvironmentPipeline.js +43 -0
- package/dist/EnvironmentPipeline.js.map +1 -0
- package/dist/EnvironmentPlatform.d.ts +185 -0
- package/dist/EnvironmentPlatform.d.ts.map +1 -0
- package/dist/EnvironmentPlatform.js +922 -0
- package/dist/EnvironmentPlatform.js.map +1 -0
- package/dist/EnvironmentPreset.d.ts +35 -0
- package/dist/EnvironmentPreset.d.ts.map +1 -0
- package/dist/EnvironmentPreset.js +96 -0
- package/dist/EnvironmentPreset.js.map +1 -0
- package/dist/Exposure.d.ts +19 -0
- package/dist/Exposure.d.ts.map +1 -0
- package/dist/Exposure.js +34 -0
- package/dist/Exposure.js.map +1 -0
- package/dist/ExternalParityRenderPreset.d.ts +149 -0
- package/dist/ExternalParityRenderPreset.d.ts.map +1 -0
- package/dist/ExternalParityRenderPreset.js +519 -0
- package/dist/ExternalParityRenderPreset.js.map +1 -0
- package/dist/ForwardPass.d.ts +122 -0
- package/dist/ForwardPass.d.ts.map +1 -0
- package/dist/ForwardPass.js +1352 -0
- package/dist/ForwardPass.js.map +1 -0
- package/dist/FrameVisualMetrics.d.ts +60 -0
- package/dist/FrameVisualMetrics.d.ts.map +1 -0
- package/dist/FrameVisualMetrics.js +146 -0
- package/dist/FrameVisualMetrics.js.map +1 -0
- package/dist/Geometry.d.ts +50 -0
- package/dist/Geometry.d.ts.map +1 -0
- package/dist/Geometry.js +385 -0
- package/dist/Geometry.js.map +1 -0
- package/dist/GeometryPrimitives.d.ts +3 -0
- package/dist/GeometryPrimitives.d.ts.map +1 -0
- package/dist/GeometryPrimitives.js +2 -0
- package/dist/GeometryPrimitives.js.map +1 -0
- package/dist/HDRRenderPipeline.d.ts +27 -0
- package/dist/HDRRenderPipeline.d.ts.map +1 -0
- package/dist/HDRRenderPipeline.js +67 -0
- package/dist/HDRRenderPipeline.js.map +1 -0
- package/dist/IBL.d.ts +37 -0
- package/dist/IBL.d.ts.map +1 -0
- package/dist/IBL.js +48 -0
- package/dist/IBL.js.map +1 -0
- package/dist/IndexBuffer.d.ts +15 -0
- package/dist/IndexBuffer.d.ts.map +1 -0
- package/dist/IndexBuffer.js +51 -0
- package/dist/IndexBuffer.js.map +1 -0
- package/dist/InstancedPBRMaterial.d.ts +33 -0
- package/dist/InstancedPBRMaterial.d.ts.map +1 -0
- package/dist/InstancedPBRMaterial.js +147 -0
- package/dist/InstancedPBRMaterial.js.map +1 -0
- package/dist/InstancedUnlitMaterial.d.ts +11 -0
- package/dist/InstancedUnlitMaterial.d.ts.map +1 -0
- package/dist/InstancedUnlitMaterial.js +50 -0
- package/dist/InstancedUnlitMaterial.js.map +1 -0
- package/dist/Instancing.d.ts +7 -0
- package/dist/Instancing.d.ts.map +1 -0
- package/dist/Instancing.js +14 -0
- package/dist/Instancing.js.map +1 -0
- package/dist/LightCollector.d.ts +24 -0
- package/dist/LightCollector.d.ts.map +1 -0
- package/dist/LightCollector.js +56 -0
- package/dist/LightCollector.js.map +1 -0
- package/dist/LightUniforms.d.ts +14 -0
- package/dist/LightUniforms.d.ts.map +1 -0
- package/dist/LightUniforms.js +37 -0
- package/dist/LightUniforms.js.map +1 -0
- package/dist/LightingDebug.d.ts +13 -0
- package/dist/LightingDebug.d.ts.map +1 -0
- package/dist/LightingDebug.js +69 -0
- package/dist/LightingDebug.js.map +1 -0
- package/dist/LightingDefaults.d.ts +13 -0
- package/dist/LightingDefaults.d.ts.map +1 -0
- package/dist/LightingDefaults.js +64 -0
- package/dist/LightingDefaults.js.map +1 -0
- package/dist/LightingRig.d.ts +53 -0
- package/dist/LightingRig.d.ts.map +1 -0
- package/dist/LightingRig.js +197 -0
- package/dist/LightingRig.js.map +1 -0
- package/dist/LineGeometry.d.ts +3 -0
- package/dist/LineGeometry.d.ts.map +1 -0
- package/dist/LineGeometry.js +2 -0
- package/dist/LineGeometry.js.map +1 -0
- package/dist/Material.d.ts +77 -0
- package/dist/Material.d.ts.map +1 -0
- package/dist/Material.js +137 -0
- package/dist/Material.js.map +1 -0
- package/dist/MaterialBinding.d.ts +17 -0
- package/dist/MaterialBinding.d.ts.map +1 -0
- package/dist/MaterialBinding.js +119 -0
- package/dist/MaterialBinding.js.map +1 -0
- package/dist/MaterialInstance.d.ts +16 -0
- package/dist/MaterialInstance.d.ts.map +1 -0
- package/dist/MaterialInstance.js +53 -0
- package/dist/MaterialInstance.js.map +1 -0
- package/dist/MaterialPresets.d.ts +31 -0
- package/dist/MaterialPresets.d.ts.map +1 -0
- package/dist/MaterialPresets.js +219 -0
- package/dist/MaterialPresets.js.map +1 -0
- package/dist/MorphTarget.d.ts +10 -0
- package/dist/MorphTarget.d.ts.map +1 -0
- package/dist/MorphTarget.js +101 -0
- package/dist/MorphTarget.js.map +1 -0
- package/dist/MorphUnlitMaterial.d.ts +11 -0
- package/dist/MorphUnlitMaterial.d.ts.map +1 -0
- package/dist/MorphUnlitMaterial.js +45 -0
- package/dist/MorphUnlitMaterial.js.map +1 -0
- package/dist/NormalMappedPBRMaterial.d.ts +37 -0
- package/dist/NormalMappedPBRMaterial.d.ts.map +1 -0
- package/dist/NormalMappedPBRMaterial.js +148 -0
- package/dist/NormalMappedPBRMaterial.js.map +1 -0
- package/dist/OceanFixtures.d.ts +62 -0
- package/dist/OceanFixtures.d.ts.map +1 -0
- package/dist/OceanFixtures.js +240 -0
- package/dist/OceanFixtures.js.map +1 -0
- package/dist/PBRLightingDefaults.d.ts +4 -0
- package/dist/PBRLightingDefaults.d.ts.map +1 -0
- package/dist/PBRLightingDefaults.js +10 -0
- package/dist/PBRLightingDefaults.js.map +1 -0
- package/dist/PBRMaterial.d.ts +84 -0
- package/dist/PBRMaterial.d.ts.map +1 -0
- package/dist/PBRMaterial.js +349 -0
- package/dist/PBRMaterial.js.map +1 -0
- package/dist/PMREM.d.ts +26 -0
- package/dist/PMREM.d.ts.map +1 -0
- package/dist/PMREM.js +26 -0
- package/dist/PMREM.js.map +1 -0
- package/dist/PbrReference.d.ts +153 -0
- package/dist/PbrReference.d.ts.map +1 -0
- package/dist/PbrReference.js +500 -0
- package/dist/PbrReference.js.map +1 -0
- package/dist/PostProcessPass.d.ts +439 -0
- package/dist/PostProcessPass.d.ts.map +1 -0
- package/dist/PostProcessPass.js +1834 -0
- package/dist/PostProcessPass.js.map +1 -0
- package/dist/ProceduralTextureFixtures.d.ts +27 -0
- package/dist/ProceduralTextureFixtures.d.ts.map +1 -0
- package/dist/ProceduralTextureFixtures.js +336 -0
- package/dist/ProceduralTextureFixtures.js.map +1 -0
- package/dist/ProductTurntableFixtures.d.ts +96 -0
- package/dist/ProductTurntableFixtures.d.ts.map +1 -0
- package/dist/ProductTurntableFixtures.js +559 -0
- package/dist/ProductTurntableFixtures.js.map +1 -0
- package/dist/Raycaster.d.ts +14 -0
- package/dist/Raycaster.d.ts.map +1 -0
- package/dist/Raycaster.js +10 -0
- package/dist/Raycaster.js.map +1 -0
- package/dist/ReflectionProbe.d.ts +8 -0
- package/dist/ReflectionProbe.d.ts.map +1 -0
- package/dist/ReflectionProbe.js +10 -0
- package/dist/ReflectionProbe.js.map +1 -0
- package/dist/ReflectionSurfaces.d.ts +35 -0
- package/dist/ReflectionSurfaces.d.ts.map +1 -0
- package/dist/ReflectionSurfaces.js +155 -0
- package/dist/ReflectionSurfaces.js.map +1 -0
- package/dist/RenderBackend.d.ts +14 -0
- package/dist/RenderBackend.d.ts.map +1 -0
- package/dist/RenderBackend.js +33 -0
- package/dist/RenderBackend.js.map +1 -0
- package/dist/RenderDebugViews.d.ts +26 -0
- package/dist/RenderDebugViews.d.ts.map +1 -0
- package/dist/RenderDebugViews.js +97 -0
- package/dist/RenderDebugViews.js.map +1 -0
- package/dist/RenderDevice.d.ts +280 -0
- package/dist/RenderDevice.d.ts.map +1 -0
- package/dist/RenderDevice.js +561 -0
- package/dist/RenderDevice.js.map +1 -0
- package/dist/RenderGraph.d.ts +22 -0
- package/dist/RenderGraph.d.ts.map +1 -0
- package/dist/RenderGraph.js +159 -0
- package/dist/RenderGraph.js.map +1 -0
- package/dist/RenderPass.d.ts +23 -0
- package/dist/RenderPass.d.ts.map +1 -0
- package/dist/RenderPass.js +14 -0
- package/dist/RenderPass.js.map +1 -0
- package/dist/RenderPipeline.d.ts +39 -0
- package/dist/RenderPipeline.d.ts.map +1 -0
- package/dist/RenderPipeline.js +67 -0
- package/dist/RenderPipeline.js.map +1 -0
- package/dist/RenderQueue.d.ts +3 -0
- package/dist/RenderQueue.d.ts.map +1 -0
- package/dist/RenderQueue.js +2 -0
- package/dist/RenderQueue.js.map +1 -0
- package/dist/RenderState.d.ts +3 -0
- package/dist/RenderState.d.ts.map +1 -0
- package/dist/RenderState.js +2 -0
- package/dist/RenderState.js.map +1 -0
- package/dist/Renderer.d.ts +265 -0
- package/dist/Renderer.d.ts.map +1 -0
- package/dist/Renderer.js +2094 -0
- package/dist/Renderer.js.map +1 -0
- package/dist/RendererDebugOverlay.d.ts +20 -0
- package/dist/RendererDebugOverlay.d.ts.map +1 -0
- package/dist/RendererDebugOverlay.js +54 -0
- package/dist/RendererDebugOverlay.js.map +1 -0
- package/dist/RendererFeatureGates.d.ts +17 -0
- package/dist/RendererFeatureGates.d.ts.map +1 -0
- package/dist/RendererFeatureGates.js +92 -0
- package/dist/RendererFeatureGates.js.map +1 -0
- package/dist/RendererPostprocessPlan.d.ts +59 -0
- package/dist/RendererPostprocessPlan.d.ts.map +1 -0
- package/dist/RendererPostprocessPlan.js +155 -0
- package/dist/RendererPostprocessPlan.js.map +1 -0
- package/dist/RendererTiming.d.ts +53 -0
- package/dist/RendererTiming.d.ts.map +1 -0
- package/dist/RendererTiming.js +186 -0
- package/dist/RendererTiming.js.map +1 -0
- package/dist/RendererVisualPipelineReport.d.ts +224 -0
- package/dist/RendererVisualPipelineReport.d.ts.map +1 -0
- package/dist/RendererVisualPipelineReport.js +499 -0
- package/dist/RendererVisualPipelineReport.js.map +1 -0
- package/dist/ResourceLifecycle.d.ts +8 -0
- package/dist/ResourceLifecycle.d.ts.map +1 -0
- package/dist/ResourceLifecycle.js +18 -0
- package/dist/ResourceLifecycle.js.map +1 -0
- package/dist/Sampler.d.ts +20 -0
- package/dist/Sampler.d.ts.map +1 -0
- package/dist/Sampler.js +19 -0
- package/dist/Sampler.js.map +1 -0
- package/dist/SceneOptimization.d.ts +127 -0
- package/dist/SceneOptimization.d.ts.map +1 -0
- package/dist/SceneOptimization.js +342 -0
- package/dist/SceneOptimization.js.map +1 -0
- package/dist/ShaderChunks.d.ts +8 -0
- package/dist/ShaderChunks.d.ts.map +1 -0
- package/dist/ShaderChunks.js +386 -0
- package/dist/ShaderChunks.js.map +1 -0
- package/dist/ShaderLibrary.d.ts +63 -0
- package/dist/ShaderLibrary.d.ts.map +1 -0
- package/dist/ShaderLibrary.js +2707 -0
- package/dist/ShaderLibrary.js.map +1 -0
- package/dist/ShaderModule.d.ts +14 -0
- package/dist/ShaderModule.d.ts.map +1 -0
- package/dist/ShaderModule.js +33 -0
- package/dist/ShaderModule.js.map +1 -0
- package/dist/ShaderPreprocessor.d.ts +19 -0
- package/dist/ShaderPreprocessor.d.ts.map +1 -0
- package/dist/ShaderPreprocessor.js +212 -0
- package/dist/ShaderPreprocessor.js.map +1 -0
- package/dist/ShaderReflection.d.ts +23 -0
- package/dist/ShaderReflection.d.ts.map +1 -0
- package/dist/ShaderReflection.js +134 -0
- package/dist/ShaderReflection.js.map +1 -0
- package/dist/ShadowMap.d.ts +58 -0
- package/dist/ShadowMap.d.ts.map +1 -0
- package/dist/ShadowMap.js +183 -0
- package/dist/ShadowMap.js.map +1 -0
- package/dist/ShadowPass.d.ts +44 -0
- package/dist/ShadowPass.d.ts.map +1 -0
- package/dist/ShadowPass.js +162 -0
- package/dist/ShadowPass.js.map +1 -0
- package/dist/ShadowProjection.d.ts +15 -0
- package/dist/ShadowProjection.d.ts.map +1 -0
- package/dist/ShadowProjection.js +90 -0
- package/dist/ShadowProjection.js.map +1 -0
- package/dist/SkinnedLitMaterial.d.ts +63 -0
- package/dist/SkinnedLitMaterial.d.ts.map +1 -0
- package/dist/SkinnedLitMaterial.js +296 -0
- package/dist/SkinnedLitMaterial.js.map +1 -0
- package/dist/SkinnedUnlitMaterial.d.ts +13 -0
- package/dist/SkinnedUnlitMaterial.d.ts.map +1 -0
- package/dist/SkinnedUnlitMaterial.js +52 -0
- package/dist/SkinnedUnlitMaterial.js.map +1 -0
- package/dist/SkinningBounds.d.ts +10 -0
- package/dist/SkinningBounds.d.ts.map +1 -0
- package/dist/SkinningBounds.js +107 -0
- package/dist/SkinningBounds.js.map +1 -0
- package/dist/SpaceEnvironmentFixtures.d.ts +59 -0
- package/dist/SpaceEnvironmentFixtures.d.ts.map +1 -0
- package/dist/SpaceEnvironmentFixtures.js +132 -0
- package/dist/SpaceEnvironmentFixtures.js.map +1 -0
- package/dist/SpriteGeometry.d.ts +3 -0
- package/dist/SpriteGeometry.d.ts.map +1 -0
- package/dist/SpriteGeometry.js +21 -0
- package/dist/SpriteGeometry.js.map +1 -0
- package/dist/StereoCameraRig.d.ts +34 -0
- package/dist/StereoCameraRig.d.ts.map +1 -0
- package/dist/StereoCameraRig.js +79 -0
- package/dist/StereoCameraRig.js.map +1 -0
- package/dist/StereoEffects.d.ts +90 -0
- package/dist/StereoEffects.d.ts.map +1 -0
- package/dist/StereoEffects.js +171 -0
- package/dist/StereoEffects.js.map +1 -0
- package/dist/TerrainFixtures.d.ts +36 -0
- package/dist/TerrainFixtures.d.ts.map +1 -0
- package/dist/TerrainFixtures.js +143 -0
- package/dist/TerrainFixtures.js.map +1 -0
- package/dist/Texture.d.ts +64 -0
- package/dist/Texture.d.ts.map +1 -0
- package/dist/Texture.js +257 -0
- package/dist/Texture.js.map +1 -0
- package/dist/TextureBinding.d.ts +38 -0
- package/dist/TextureBinding.d.ts.map +1 -0
- package/dist/TextureBinding.js +66 -0
- package/dist/TextureBinding.js.map +1 -0
- package/dist/TexturedPBRMaterial.d.ts +206 -0
- package/dist/TexturedPBRMaterial.d.ts.map +1 -0
- package/dist/TexturedPBRMaterial.js +842 -0
- package/dist/TexturedPBRMaterial.js.map +1 -0
- package/dist/TexturedUnlitMaterial.d.ts +19 -0
- package/dist/TexturedUnlitMaterial.d.ts.map +1 -0
- package/dist/TexturedUnlitMaterial.js +52 -0
- package/dist/TexturedUnlitMaterial.js.map +1 -0
- package/dist/ToneMapping.d.ts +19 -0
- package/dist/ToneMapping.d.ts.map +1 -0
- package/dist/ToneMapping.js +53 -0
- package/dist/ToneMapping.js.map +1 -0
- package/dist/UniformBinder.d.ts +7 -0
- package/dist/UniformBinder.d.ts.map +1 -0
- package/dist/UniformBinder.js +14 -0
- package/dist/UniformBinder.js.map +1 -0
- package/dist/UniformLayout.d.ts +19 -0
- package/dist/UniformLayout.d.ts.map +1 -0
- package/dist/UniformLayout.js +107 -0
- package/dist/UniformLayout.js.map +1 -0
- package/dist/UnlitMaterial.d.ts +16 -0
- package/dist/UnlitMaterial.d.ts.map +1 -0
- package/dist/UnlitMaterial.js +60 -0
- package/dist/UnlitMaterial.js.map +1 -0
- package/dist/VegetationFixtures.d.ts +68 -0
- package/dist/VegetationFixtures.d.ts.map +1 -0
- package/dist/VegetationFixtures.js +241 -0
- package/dist/VegetationFixtures.js.map +1 -0
- package/dist/VertexBuffer.d.ts +29 -0
- package/dist/VertexBuffer.d.ts.map +1 -0
- package/dist/VertexBuffer.js +106 -0
- package/dist/VertexBuffer.js.map +1 -0
- package/dist/VertexFormat.d.ts +36 -0
- package/dist/VertexFormat.d.ts.map +1 -0
- package/dist/VertexFormat.js +127 -0
- package/dist/VertexFormat.js.map +1 -0
- package/dist/VoxelWorldFixtures.d.ts +54 -0
- package/dist/VoxelWorldFixtures.d.ts.map +1 -0
- package/dist/VoxelWorldFixtures.js +186 -0
- package/dist/VoxelWorldFixtures.js.map +1 -0
- package/dist/WeatherFixtures.d.ts +46 -0
- package/dist/WeatherFixtures.d.ts.map +1 -0
- package/dist/WeatherFixtures.js +142 -0
- package/dist/WeatherFixtures.js.map +1 -0
- package/dist/WebGL2Device.d.ts +137 -0
- package/dist/WebGL2Device.d.ts.map +1 -0
- package/dist/WebGL2Device.js +2107 -0
- package/dist/WebGL2Device.js.map +1 -0
- package/dist/WebGL2StateCache.d.ts +89 -0
- package/dist/WebGL2StateCache.d.ts.map +1 -0
- package/dist/WebGL2StateCache.js +265 -0
- package/dist/WebGL2StateCache.js.map +1 -0
- package/dist/WebGPUDevice.d.ts +287 -0
- package/dist/WebGPUDevice.d.ts.map +1 -0
- package/dist/WebGPUDevice.js +2403 -0
- package/dist/WebGPUDevice.js.map +1 -0
- package/dist/WebGPURenderToTextureProof.d.ts +29 -0
- package/dist/WebGPURenderToTextureProof.d.ts.map +1 -0
- package/dist/WebGPURenderToTextureProof.js +96 -0
- package/dist/WebGPURenderToTextureProof.js.map +1 -0
- package/dist/advanced-runtime/AdvancedRenderer.d.ts +23 -0
- package/dist/advanced-runtime/AdvancedRenderer.d.ts.map +1 -0
- package/dist/advanced-runtime/AdvancedRenderer.js +45 -0
- package/dist/advanced-runtime/AdvancedRenderer.js.map +1 -0
- package/dist/advanced-runtime/index.d.ts +10 -0
- package/dist/advanced-runtime/index.d.ts.map +1 -0
- package/dist/advanced-runtime/index.js +9 -0
- package/dist/advanced-runtime/index.js.map +1 -0
- package/dist/cinematic/BloomPass.d.ts +10 -0
- package/dist/cinematic/BloomPass.d.ts.map +1 -0
- package/dist/cinematic/BloomPass.js +18 -0
- package/dist/cinematic/BloomPass.js.map +1 -0
- package/dist/cinematic/CinematicDepthComposition.d.ts +12 -0
- package/dist/cinematic/CinematicDepthComposition.d.ts.map +1 -0
- package/dist/cinematic/CinematicDepthComposition.js +22 -0
- package/dist/cinematic/CinematicDepthComposition.js.map +1 -0
- package/dist/cinematic/CinematicEvidence.d.ts +43 -0
- package/dist/cinematic/CinematicEvidence.d.ts.map +1 -0
- package/dist/cinematic/CinematicEvidence.js +55 -0
- package/dist/cinematic/CinematicEvidence.js.map +1 -0
- package/dist/cinematic/CinematicLightingRig.d.ts +32 -0
- package/dist/cinematic/CinematicLightingRig.d.ts.map +1 -0
- package/dist/cinematic/CinematicLightingRig.js +90 -0
- package/dist/cinematic/CinematicLightingRig.js.map +1 -0
- package/dist/cinematic/CinematicMaterialPresets.d.ts +16 -0
- package/dist/cinematic/CinematicMaterialPresets.d.ts.map +1 -0
- package/dist/cinematic/CinematicMaterialPresets.js +114 -0
- package/dist/cinematic/CinematicMaterialPresets.js.map +1 -0
- package/dist/cinematic/CinematicPostProcess.d.ts +25 -0
- package/dist/cinematic/CinematicPostProcess.d.ts.map +1 -0
- package/dist/cinematic/CinematicPostProcess.js +64 -0
- package/dist/cinematic/CinematicPostProcess.js.map +1 -0
- package/dist/cinematic/DepthHazePass.d.ts +12 -0
- package/dist/cinematic/DepthHazePass.d.ts.map +1 -0
- package/dist/cinematic/DepthHazePass.js +20 -0
- package/dist/cinematic/DepthHazePass.js.map +1 -0
- package/dist/cinematic/EmissivePracticalLightSystem.d.ts +18 -0
- package/dist/cinematic/EmissivePracticalLightSystem.d.ts.map +1 -0
- package/dist/cinematic/EmissivePracticalLightSystem.js +25 -0
- package/dist/cinematic/EmissivePracticalLightSystem.js.map +1 -0
- package/dist/cinematic/FilmGrainPass.d.ts +9 -0
- package/dist/cinematic/FilmGrainPass.d.ts.map +1 -0
- package/dist/cinematic/FilmGrainPass.js +17 -0
- package/dist/cinematic/FilmGrainPass.js.map +1 -0
- package/dist/cinematic/FogVolumeSystem.d.ts +12 -0
- package/dist/cinematic/FogVolumeSystem.d.ts.map +1 -0
- package/dist/cinematic/FogVolumeSystem.js +20 -0
- package/dist/cinematic/FogVolumeSystem.js.map +1 -0
- package/dist/cinematic/GlowCardSystem.d.ts +17 -0
- package/dist/cinematic/GlowCardSystem.d.ts.map +1 -0
- package/dist/cinematic/GlowCardSystem.js +28 -0
- package/dist/cinematic/GlowCardSystem.js.map +1 -0
- package/dist/cinematic/RainParticleSystem.d.ts +22 -0
- package/dist/cinematic/RainParticleSystem.d.ts.map +1 -0
- package/dist/cinematic/RainParticleSystem.js +114 -0
- package/dist/cinematic/RainParticleSystem.js.map +1 -0
- package/dist/cinematic/VignettePass.d.ts +10 -0
- package/dist/cinematic/VignettePass.d.ts.map +1 -0
- package/dist/cinematic/VignettePass.js +17 -0
- package/dist/cinematic/VignettePass.js.map +1 -0
- package/dist/cinematic/WetReflectionApproximation.d.ts +13 -0
- package/dist/cinematic/WetReflectionApproximation.d.ts.map +1 -0
- package/dist/cinematic/WetReflectionApproximation.js +18 -0
- package/dist/cinematic/WetReflectionApproximation.js.map +1 -0
- package/dist/cinematic/index.d.ts +15 -0
- package/dist/cinematic/index.d.ts.map +1 -0
- package/dist/cinematic/index.js +15 -0
- package/dist/cinematic/index.js.map +1 -0
- package/dist/effects/CollisionModule.d.ts +15 -0
- package/dist/effects/CollisionModule.d.ts.map +1 -0
- package/dist/effects/CollisionModule.js +46 -0
- package/dist/effects/CollisionModule.js.map +1 -0
- package/dist/effects/ColorModule.d.ts +15 -0
- package/dist/effects/ColorModule.d.ts.map +1 -0
- package/dist/effects/ColorModule.js +45 -0
- package/dist/effects/ColorModule.js.map +1 -0
- package/dist/effects/ForceModule.d.ts +11 -0
- package/dist/effects/ForceModule.d.ts.map +1 -0
- package/dist/effects/ForceModule.js +17 -0
- package/dist/effects/ForceModule.js.map +1 -0
- package/dist/effects/GPUParticleBackend.d.ts +153 -0
- package/dist/effects/GPUParticleBackend.d.ts.map +1 -0
- package/dist/effects/GPUParticleBackend.js +397 -0
- package/dist/effects/GPUParticleBackend.js.map +1 -0
- package/dist/effects/Particle.d.ts +49 -0
- package/dist/effects/Particle.d.ts.map +1 -0
- package/dist/effects/Particle.js +56 -0
- package/dist/effects/Particle.js.map +1 -0
- package/dist/effects/ParticleDiagnostics.d.ts +58 -0
- package/dist/effects/ParticleDiagnostics.d.ts.map +1 -0
- package/dist/effects/ParticleDiagnostics.js +145 -0
- package/dist/effects/ParticleDiagnostics.js.map +1 -0
- package/dist/effects/ParticleEffectPresets.d.ts +8 -0
- package/dist/effects/ParticleEffectPresets.d.ts.map +1 -0
- package/dist/effects/ParticleEffectPresets.js +137 -0
- package/dist/effects/ParticleEffectPresets.js.map +1 -0
- package/dist/effects/ParticleEmitter.d.ts +87 -0
- package/dist/effects/ParticleEmitter.d.ts.map +1 -0
- package/dist/effects/ParticleEmitter.js +254 -0
- package/dist/effects/ParticleEmitter.js.map +1 -0
- package/dist/effects/ParticleModule.d.ts +15 -0
- package/dist/effects/ParticleModule.d.ts.map +1 -0
- package/dist/effects/ParticleModule.js +6 -0
- package/dist/effects/ParticleModule.js.map +1 -0
- package/dist/effects/ParticleRenderPass.d.ts +35 -0
- package/dist/effects/ParticleRenderPass.d.ts.map +1 -0
- package/dist/effects/ParticleRenderPass.js +91 -0
- package/dist/effects/ParticleRenderPass.js.map +1 -0
- package/dist/effects/ParticleRenderer.d.ts +34 -0
- package/dist/effects/ParticleRenderer.d.ts.map +1 -0
- package/dist/effects/ParticleRenderer.js +93 -0
- package/dist/effects/ParticleRenderer.js.map +1 -0
- package/dist/effects/ParticleSystem.d.ts +51 -0
- package/dist/effects/ParticleSystem.d.ts.map +1 -0
- package/dist/effects/ParticleSystem.js +261 -0
- package/dist/effects/ParticleSystem.js.map +1 -0
- package/dist/effects/SizeModule.d.ts +14 -0
- package/dist/effects/SizeModule.d.ts.map +1 -0
- package/dist/effects/SizeModule.js +42 -0
- package/dist/effects/SizeModule.js.map +1 -0
- package/dist/effects/TrailModule.d.ts +22 -0
- package/dist/effects/TrailModule.d.ts.map +1 -0
- package/dist/effects/TrailModule.js +50 -0
- package/dist/effects/TrailModule.js.map +1 -0
- package/dist/effects/VelocityModule.d.ts +15 -0
- package/dist/effects/VelocityModule.d.ts.map +1 -0
- package/dist/effects/VelocityModule.js +57 -0
- package/dist/effects/VelocityModule.js.map +1 -0
- package/dist/effects/index.d.ts +16 -0
- package/dist/effects/index.d.ts.map +1 -0
- package/dist/effects/index.js +16 -0
- package/dist/effects/index.js.map +1 -0
- package/dist/index.d.ts +260 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +155 -0
- package/dist/index.js.map +1 -0
- package/dist/materials/AlphaSorting.d.ts +8 -0
- package/dist/materials/AlphaSorting.d.ts.map +1 -0
- package/dist/materials/AlphaSorting.js +26 -0
- package/dist/materials/AlphaSorting.js.map +1 -0
- package/dist/materials/MaterialExtensions.d.ts +10 -0
- package/dist/materials/MaterialExtensions.d.ts.map +1 -0
- package/dist/materials/MaterialExtensions.js +20 -0
- package/dist/materials/MaterialExtensions.js.map +1 -0
- package/dist/materials/PhysicalMaterial.d.ts +36 -0
- package/dist/materials/PhysicalMaterial.d.ts.map +1 -0
- package/dist/materials/PhysicalMaterial.js +79 -0
- package/dist/materials/PhysicalMaterial.js.map +1 -0
- package/dist/materials/TransmissionPass.d.ts +16 -0
- package/dist/materials/TransmissionPass.d.ts.map +1 -0
- package/dist/materials/TransmissionPass.js +30 -0
- package/dist/materials/TransmissionPass.js.map +1 -0
- package/dist/performance/BVH.d.ts +3 -0
- package/dist/performance/BVH.d.ts.map +1 -0
- package/dist/performance/BVH.js +2 -0
- package/dist/performance/BVH.js.map +1 -0
- package/dist/performance/Batcher.d.ts +3 -0
- package/dist/performance/Batcher.d.ts.map +1 -0
- package/dist/performance/Batcher.js +2 -0
- package/dist/performance/Batcher.js.map +1 -0
- package/dist/performance/FrustumCuller.d.ts +3 -0
- package/dist/performance/FrustumCuller.d.ts.map +1 -0
- package/dist/performance/FrustumCuller.js +5 -0
- package/dist/performance/FrustumCuller.js.map +1 -0
- package/dist/performance/LOD.d.ts +8 -0
- package/dist/performance/LOD.d.ts.map +1 -0
- package/dist/performance/LOD.js +15 -0
- package/dist/performance/LOD.js.map +1 -0
- package/dist/performance/Octree.d.ts +7 -0
- package/dist/performance/Octree.d.ts.map +1 -0
- package/dist/performance/Octree.js +4 -0
- package/dist/performance/Octree.js.map +1 -0
- package/dist/performance/RenderItemSorting.d.ts +43 -0
- package/dist/performance/RenderItemSorting.d.ts.map +1 -0
- package/dist/performance/RenderItemSorting.js +111 -0
- package/dist/performance/RenderItemSorting.js.map +1 -0
- package/dist/performance/RendererStats.d.ts +23 -0
- package/dist/performance/RendererStats.d.ts.map +1 -0
- package/dist/performance/RendererStats.js +23 -0
- package/dist/performance/RendererStats.js.map +1 -0
- package/dist/performance/ResourceBudget.d.ts +19 -0
- package/dist/performance/ResourceBudget.d.ts.map +1 -0
- package/dist/performance/ResourceBudget.js +21 -0
- package/dist/performance/ResourceBudget.js.map +1 -0
- package/dist/postprocess/BloomPass.d.ts +11 -0
- package/dist/postprocess/BloomPass.d.ts.map +1 -0
- package/dist/postprocess/BloomPass.js +14 -0
- package/dist/postprocess/BloomPass.js.map +1 -0
- package/dist/postprocess/CinematicDiagnostics.d.ts +112 -0
- package/dist/postprocess/CinematicDiagnostics.d.ts.map +1 -0
- package/dist/postprocess/CinematicDiagnostics.js +492 -0
- package/dist/postprocess/CinematicDiagnostics.js.map +1 -0
- package/dist/postprocess/ColorGradingPass.d.ts +4 -0
- package/dist/postprocess/ColorGradingPass.d.ts.map +1 -0
- package/dist/postprocess/ColorGradingPass.js +15 -0
- package/dist/postprocess/ColorGradingPass.js.map +1 -0
- package/dist/postprocess/DepthOfFieldPass.d.ts +3 -0
- package/dist/postprocess/DepthOfFieldPass.d.ts.map +1 -0
- package/dist/postprocess/DepthOfFieldPass.js +7 -0
- package/dist/postprocess/DepthOfFieldPass.js.map +1 -0
- package/dist/postprocess/EffectComposer.d.ts +110 -0
- package/dist/postprocess/EffectComposer.d.ts.map +1 -0
- package/dist/postprocess/EffectComposer.js +249 -0
- package/dist/postprocess/EffectComposer.js.map +1 -0
- package/dist/postprocess/SSAOPass.d.ts +6 -0
- package/dist/postprocess/SSAOPass.d.ts.map +1 -0
- package/dist/postprocess/SSAOPass.js +18 -0
- package/dist/postprocess/SSAOPass.js.map +1 -0
- package/dist/postprocess/index.d.ts +11 -0
- package/dist/postprocess/index.d.ts.map +1 -0
- package/dist/postprocess/index.js +7 -0
- package/dist/postprocess/index.js.map +1 -0
- package/dist/production-runtime/AnimationControlsPipeline.d.ts +37 -0
- package/dist/production-runtime/AnimationControlsPipeline.d.ts.map +1 -0
- package/dist/production-runtime/AnimationControlsPipeline.js +41 -0
- package/dist/production-runtime/AnimationControlsPipeline.js.map +1 -0
- package/dist/production-runtime/PBRHDRPipeline.d.ts +81 -0
- package/dist/production-runtime/PBRHDRPipeline.d.ts.map +1 -0
- package/dist/production-runtime/PBRHDRPipeline.js +279 -0
- package/dist/production-runtime/PBRHDRPipeline.js.map +1 -0
- package/dist/production-runtime/ProductionEffectsPipeline.d.ts +20 -0
- package/dist/production-runtime/ProductionEffectsPipeline.d.ts.map +1 -0
- package/dist/production-runtime/ProductionEffectsPipeline.js +65 -0
- package/dist/production-runtime/ProductionEffectsPipeline.js.map +1 -0
- package/dist/production-runtime/ProductionRendererTypes.d.ts +97 -0
- package/dist/production-runtime/ProductionRendererTypes.d.ts.map +1 -0
- package/dist/production-runtime/ProductionRendererTypes.js +29 -0
- package/dist/production-runtime/ProductionRendererTypes.js.map +1 -0
- package/dist/production-runtime/ProductionRuntimeRenderer.d.ts +36 -0
- package/dist/production-runtime/ProductionRuntimeRenderer.d.ts.map +1 -0
- package/dist/production-runtime/ProductionRuntimeRenderer.js +124 -0
- package/dist/production-runtime/ProductionRuntimeRenderer.js.map +1 -0
- package/dist/production-runtime/ProductionWebGL2Renderer.d.ts +51 -0
- package/dist/production-runtime/ProductionWebGL2Renderer.d.ts.map +1 -0
- package/dist/production-runtime/ProductionWebGL2Renderer.js +269 -0
- package/dist/production-runtime/ProductionWebGL2Renderer.js.map +1 -0
- package/dist/production-runtime/ProductionWebGPURenderer.d.ts +69 -0
- package/dist/production-runtime/ProductionWebGPURenderer.d.ts.map +1 -0
- package/dist/production-runtime/ProductionWebGPURenderer.js +313 -0
- package/dist/production-runtime/ProductionWebGPURenderer.js.map +1 -0
- package/dist/production-runtime/TransmissionBackdropCapture.d.ts +11 -0
- package/dist/production-runtime/TransmissionBackdropCapture.d.ts.map +1 -0
- package/dist/production-runtime/TransmissionBackdropCapture.js +119 -0
- package/dist/production-runtime/TransmissionBackdropCapture.js.map +1 -0
- package/dist/production-runtime/animation/MorphTargetRenderer.d.ts +7 -0
- package/dist/production-runtime/animation/MorphTargetRenderer.d.ts.map +1 -0
- package/dist/production-runtime/animation/MorphTargetRenderer.js +2 -0
- package/dist/production-runtime/animation/MorphTargetRenderer.js.map +1 -0
- package/dist/production-runtime/animation/SkinningRenderer.d.ts +7 -0
- package/dist/production-runtime/animation/SkinningRenderer.d.ts.map +1 -0
- package/dist/production-runtime/animation/SkinningRenderer.js +2 -0
- package/dist/production-runtime/animation/SkinningRenderer.js.map +1 -0
- package/dist/production-runtime/backends/RendererBackend.d.ts +16 -0
- package/dist/production-runtime/backends/RendererBackend.d.ts.map +1 -0
- package/dist/production-runtime/backends/RendererBackend.js +2 -0
- package/dist/production-runtime/backends/RendererBackend.js.map +1 -0
- package/dist/production-runtime/backends/WebGL2RendererBackend.d.ts +15 -0
- package/dist/production-runtime/backends/WebGL2RendererBackend.d.ts.map +1 -0
- package/dist/production-runtime/backends/WebGL2RendererBackend.js +25 -0
- package/dist/production-runtime/backends/WebGL2RendererBackend.js.map +1 -0
- package/dist/production-runtime/backends/WebGPURendererBackend.d.ts +20 -0
- package/dist/production-runtime/backends/WebGPURendererBackend.d.ts.map +1 -0
- package/dist/production-runtime/backends/WebGPURendererBackend.js +19 -0
- package/dist/production-runtime/backends/WebGPURendererBackend.js.map +1 -0
- package/dist/production-runtime/backends/webgl2/WebGL2Buffer.d.ts +11 -0
- package/dist/production-runtime/backends/webgl2/WebGL2Buffer.d.ts.map +1 -0
- package/dist/production-runtime/backends/webgl2/WebGL2Buffer.js +8 -0
- package/dist/production-runtime/backends/webgl2/WebGL2Buffer.js.map +1 -0
- package/dist/production-runtime/backends/webgl2/WebGL2Capabilities.d.ts +11 -0
- package/dist/production-runtime/backends/webgl2/WebGL2Capabilities.d.ts.map +1 -0
- package/dist/production-runtime/backends/webgl2/WebGL2Capabilities.js +8 -0
- package/dist/production-runtime/backends/webgl2/WebGL2Capabilities.js.map +1 -0
- package/dist/production-runtime/backends/webgl2/WebGL2RenderTarget.d.ts +11 -0
- package/dist/production-runtime/backends/webgl2/WebGL2RenderTarget.d.ts.map +1 -0
- package/dist/production-runtime/backends/webgl2/WebGL2RenderTarget.js +8 -0
- package/dist/production-runtime/backends/webgl2/WebGL2RenderTarget.js.map +1 -0
- package/dist/production-runtime/backends/webgl2/WebGL2Shader.d.ts +11 -0
- package/dist/production-runtime/backends/webgl2/WebGL2Shader.d.ts.map +1 -0
- package/dist/production-runtime/backends/webgl2/WebGL2Shader.js +8 -0
- package/dist/production-runtime/backends/webgl2/WebGL2Shader.js.map +1 -0
- package/dist/production-runtime/backends/webgl2/WebGL2StateCache.d.ts +2 -0
- package/dist/production-runtime/backends/webgl2/WebGL2StateCache.d.ts.map +1 -0
- package/dist/production-runtime/backends/webgl2/WebGL2StateCache.js +2 -0
- package/dist/production-runtime/backends/webgl2/WebGL2StateCache.js.map +1 -0
- package/dist/production-runtime/backends/webgl2/WebGL2Texture.d.ts +11 -0
- package/dist/production-runtime/backends/webgl2/WebGL2Texture.d.ts.map +1 -0
- package/dist/production-runtime/backends/webgl2/WebGL2Texture.js +8 -0
- package/dist/production-runtime/backends/webgl2/WebGL2Texture.js.map +1 -0
- package/dist/production-runtime/backends/webgpu/WebGPUBuffer.d.ts +11 -0
- package/dist/production-runtime/backends/webgpu/WebGPUBuffer.d.ts.map +1 -0
- package/dist/production-runtime/backends/webgpu/WebGPUBuffer.js +8 -0
- package/dist/production-runtime/backends/webgpu/WebGPUBuffer.js.map +1 -0
- package/dist/production-runtime/backends/webgpu/WebGPUCapabilities.d.ts +11 -0
- package/dist/production-runtime/backends/webgpu/WebGPUCapabilities.d.ts.map +1 -0
- package/dist/production-runtime/backends/webgpu/WebGPUCapabilities.js +8 -0
- package/dist/production-runtime/backends/webgpu/WebGPUCapabilities.js.map +1 -0
- package/dist/production-runtime/backends/webgpu/WebGPURenderTarget.d.ts +11 -0
- package/dist/production-runtime/backends/webgpu/WebGPURenderTarget.d.ts.map +1 -0
- package/dist/production-runtime/backends/webgpu/WebGPURenderTarget.js +8 -0
- package/dist/production-runtime/backends/webgpu/WebGPURenderTarget.js.map +1 -0
- package/dist/production-runtime/backends/webgpu/WebGPUShader.d.ts +11 -0
- package/dist/production-runtime/backends/webgpu/WebGPUShader.d.ts.map +1 -0
- package/dist/production-runtime/backends/webgpu/WebGPUShader.js +8 -0
- package/dist/production-runtime/backends/webgpu/WebGPUShader.js.map +1 -0
- package/dist/production-runtime/backends/webgpu/WebGPUTexture.d.ts +11 -0
- package/dist/production-runtime/backends/webgpu/WebGPUTexture.d.ts.map +1 -0
- package/dist/production-runtime/backends/webgpu/WebGPUTexture.js +8 -0
- package/dist/production-runtime/backends/webgpu/WebGPUTexture.js.map +1 -0
- package/dist/production-runtime/color/ColorManagement.d.ts +4 -0
- package/dist/production-runtime/color/ColorManagement.d.ts.map +1 -0
- package/dist/production-runtime/color/ColorManagement.js +3 -0
- package/dist/production-runtime/color/ColorManagement.js.map +1 -0
- package/dist/production-runtime/color/ToneMapping.d.ts +3 -0
- package/dist/production-runtime/color/ToneMapping.d.ts.map +1 -0
- package/dist/production-runtime/color/ToneMapping.js +9 -0
- package/dist/production-runtime/color/ToneMapping.js.map +1 -0
- package/dist/production-runtime/diagnostics/FrameCapture.d.ts +7 -0
- package/dist/production-runtime/diagnostics/FrameCapture.d.ts.map +1 -0
- package/dist/production-runtime/diagnostics/FrameCapture.js +2 -0
- package/dist/production-runtime/diagnostics/FrameCapture.js.map +1 -0
- package/dist/production-runtime/diagnostics/GPUCapabilities.d.ts +9 -0
- package/dist/production-runtime/diagnostics/GPUCapabilities.d.ts.map +1 -0
- package/dist/production-runtime/diagnostics/GPUCapabilities.js +2 -0
- package/dist/production-runtime/diagnostics/GPUCapabilities.js.map +1 -0
- package/dist/production-runtime/diagnostics/RendererStats.d.ts +9 -0
- package/dist/production-runtime/diagnostics/RendererStats.d.ts.map +1 -0
- package/dist/production-runtime/diagnostics/RendererStats.js +2 -0
- package/dist/production-runtime/diagnostics/RendererStats.js.map +1 -0
- package/dist/production-runtime/environment/EnvironmentMap.d.ts +8 -0
- package/dist/production-runtime/environment/EnvironmentMap.d.ts.map +1 -0
- package/dist/production-runtime/environment/EnvironmentMap.js +2 -0
- package/dist/production-runtime/environment/EnvironmentMap.js.map +1 -0
- package/dist/production-runtime/environment/HDRLoader.d.ts +19 -0
- package/dist/production-runtime/environment/HDRLoader.d.ts.map +1 -0
- package/dist/production-runtime/environment/HDRLoader.js +22 -0
- package/dist/production-runtime/environment/HDRLoader.js.map +1 -0
- package/dist/production-runtime/environment/PMREMGenerator.d.ts +99 -0
- package/dist/production-runtime/environment/PMREMGenerator.d.ts.map +1 -0
- package/dist/production-runtime/environment/PMREMGenerator.js +534 -0
- package/dist/production-runtime/environment/PMREMGenerator.js.map +1 -0
- package/dist/production-runtime/framegraph/FrameGraph.d.ts +8 -0
- package/dist/production-runtime/framegraph/FrameGraph.d.ts.map +1 -0
- package/dist/production-runtime/framegraph/FrameGraph.js +14 -0
- package/dist/production-runtime/framegraph/FrameGraph.js.map +1 -0
- package/dist/production-runtime/framegraph/RenderPass.d.ts +14 -0
- package/dist/production-runtime/framegraph/RenderPass.d.ts.map +1 -0
- package/dist/production-runtime/framegraph/RenderPass.js +2 -0
- package/dist/production-runtime/framegraph/RenderPass.js.map +1 -0
- package/dist/production-runtime/geometry/ProjectedDecalGeometry.d.ts +53 -0
- package/dist/production-runtime/geometry/ProjectedDecalGeometry.d.ts.map +1 -0
- package/dist/production-runtime/geometry/ProjectedDecalGeometry.js +340 -0
- package/dist/production-runtime/geometry/ProjectedDecalGeometry.js.map +1 -0
- package/dist/production-runtime/index.d.ts +73 -0
- package/dist/production-runtime/index.d.ts.map +1 -0
- package/dist/production-runtime/index.js +67 -0
- package/dist/production-runtime/index.js.map +1 -0
- package/dist/production-runtime/lights/LightManager.d.ts +8 -0
- package/dist/production-runtime/lights/LightManager.d.ts.map +1 -0
- package/dist/production-runtime/lights/LightManager.js +7 -0
- package/dist/production-runtime/lights/LightManager.js.map +1 -0
- package/dist/production-runtime/lights/ShadowMapRenderer.d.ts +8 -0
- package/dist/production-runtime/lights/ShadowMapRenderer.d.ts.map +1 -0
- package/dist/production-runtime/lights/ShadowMapRenderer.js +4 -0
- package/dist/production-runtime/lights/ShadowMapRenderer.js.map +1 -0
- package/dist/production-runtime/materials/GLTFMaterialAdapter.d.ts +14 -0
- package/dist/production-runtime/materials/GLTFMaterialAdapter.d.ts.map +1 -0
- package/dist/production-runtime/materials/GLTFMaterialAdapter.js +5 -0
- package/dist/production-runtime/materials/GLTFMaterialAdapter.js.map +1 -0
- package/dist/production-runtime/materials/GLTFPBRMaterialAdapter.d.ts +3 -0
- package/dist/production-runtime/materials/GLTFPBRMaterialAdapter.d.ts.map +1 -0
- package/dist/production-runtime/materials/GLTFPBRMaterialAdapter.js +2 -0
- package/dist/production-runtime/materials/GLTFPBRMaterialAdapter.js.map +1 -0
- package/dist/production-runtime/materials/MaterialCompiler.d.ts +9 -0
- package/dist/production-runtime/materials/MaterialCompiler.d.ts.map +1 -0
- package/dist/production-runtime/materials/MaterialCompiler.js +5 -0
- package/dist/production-runtime/materials/MaterialCompiler.js.map +1 -0
- package/dist/production-runtime/materials/MaterialTextureBindings.d.ts +8 -0
- package/dist/production-runtime/materials/MaterialTextureBindings.d.ts.map +1 -0
- package/dist/production-runtime/materials/MaterialTextureBindings.js +4 -0
- package/dist/production-runtime/materials/MaterialTextureBindings.js.map +1 -0
- package/dist/production-runtime/materials/PBRMaterial.d.ts +23 -0
- package/dist/production-runtime/materials/PBRMaterial.d.ts.map +1 -0
- package/dist/production-runtime/materials/PBRMaterial.js +2 -0
- package/dist/production-runtime/materials/PBRMaterial.js.map +1 -0
- package/dist/production-runtime/materials/PBRShaderFeatures.d.ts +13 -0
- package/dist/production-runtime/materials/PBRShaderFeatures.d.ts.map +1 -0
- package/dist/production-runtime/materials/PBRShaderFeatures.js +2 -0
- package/dist/production-runtime/materials/PBRShaderFeatures.js.map +1 -0
- package/dist/production-runtime/passes/ContactShadowPass.d.ts +40 -0
- package/dist/production-runtime/passes/ContactShadowPass.d.ts.map +1 -0
- package/dist/production-runtime/passes/ContactShadowPass.js +126 -0
- package/dist/production-runtime/passes/ContactShadowPass.js.map +1 -0
- package/dist/production-runtime/passes/DepthPrepass.d.ts +8 -0
- package/dist/production-runtime/passes/DepthPrepass.d.ts.map +1 -0
- package/dist/production-runtime/passes/DepthPrepass.js +7 -0
- package/dist/production-runtime/passes/DepthPrepass.js.map +1 -0
- package/dist/production-runtime/passes/OpaquePass.d.ts +8 -0
- package/dist/production-runtime/passes/OpaquePass.d.ts.map +1 -0
- package/dist/production-runtime/passes/OpaquePass.js +7 -0
- package/dist/production-runtime/passes/OpaquePass.js.map +1 -0
- package/dist/production-runtime/passes/ShadowPass.d.ts +8 -0
- package/dist/production-runtime/passes/ShadowPass.d.ts.map +1 -0
- package/dist/production-runtime/passes/ShadowPass.js +7 -0
- package/dist/production-runtime/passes/ShadowPass.js.map +1 -0
- package/dist/production-runtime/passes/SkyboxPass.d.ts +8 -0
- package/dist/production-runtime/passes/SkyboxPass.d.ts.map +1 -0
- package/dist/production-runtime/passes/SkyboxPass.js +7 -0
- package/dist/production-runtime/passes/SkyboxPass.js.map +1 -0
- package/dist/production-runtime/passes/ToneMappingPass.d.ts +8 -0
- package/dist/production-runtime/passes/ToneMappingPass.d.ts.map +1 -0
- package/dist/production-runtime/passes/ToneMappingPass.js +7 -0
- package/dist/production-runtime/passes/ToneMappingPass.js.map +1 -0
- package/dist/production-runtime/passes/TransparentPass.d.ts +8 -0
- package/dist/production-runtime/passes/TransparentPass.d.ts.map +1 -0
- package/dist/production-runtime/passes/TransparentPass.js +7 -0
- package/dist/production-runtime/passes/TransparentPass.js.map +1 -0
- package/dist/production-runtime/postprocess/BloomPass.d.ts +15 -0
- package/dist/production-runtime/postprocess/BloomPass.d.ts.map +1 -0
- package/dist/production-runtime/postprocess/BloomPass.js +37 -0
- package/dist/production-runtime/postprocess/BloomPass.js.map +1 -0
- package/dist/production-runtime/postprocess/ColorGradingPass.d.ts +16 -0
- package/dist/production-runtime/postprocess/ColorGradingPass.d.ts.map +1 -0
- package/dist/production-runtime/postprocess/ColorGradingPass.js +34 -0
- package/dist/production-runtime/postprocess/ColorGradingPass.js.map +1 -0
- package/dist/production-runtime/postprocess/DOFPass.d.ts +16 -0
- package/dist/production-runtime/postprocess/DOFPass.d.ts.map +1 -0
- package/dist/production-runtime/postprocess/DOFPass.js +31 -0
- package/dist/production-runtime/postprocess/DOFPass.js.map +1 -0
- package/dist/production-runtime/postprocess/FXAAPass.d.ts +16 -0
- package/dist/production-runtime/postprocess/FXAAPass.d.ts.map +1 -0
- package/dist/production-runtime/postprocess/FXAAPass.js +39 -0
- package/dist/production-runtime/postprocess/FXAAPass.js.map +1 -0
- package/dist/production-runtime/postprocess/ProductionEffectComposer.d.ts +21 -0
- package/dist/production-runtime/postprocess/ProductionEffectComposer.d.ts.map +1 -0
- package/dist/production-runtime/postprocess/ProductionEffectComposer.js +53 -0
- package/dist/production-runtime/postprocess/ProductionEffectComposer.js.map +1 -0
- package/dist/production-runtime/postprocess/ProductionPostProcessTypes.d.ts +37 -0
- package/dist/production-runtime/postprocess/ProductionPostProcessTypes.d.ts.map +1 -0
- package/dist/production-runtime/postprocess/ProductionPostProcessTypes.js +124 -0
- package/dist/production-runtime/postprocess/ProductionPostProcessTypes.js.map +1 -0
- package/dist/production-runtime/postprocess/SSAOPass.d.ts +15 -0
- package/dist/production-runtime/postprocess/SSAOPass.d.ts.map +1 -0
- package/dist/production-runtime/postprocess/SSAOPass.js +30 -0
- package/dist/production-runtime/postprocess/SSAOPass.js.map +1 -0
- package/dist/production-runtime/resources/GPUBuffer.d.ts +10 -0
- package/dist/production-runtime/resources/GPUBuffer.d.ts.map +1 -0
- package/dist/production-runtime/resources/GPUBuffer.js +7 -0
- package/dist/production-runtime/resources/GPUBuffer.js.map +1 -0
- package/dist/production-runtime/resources/GPUTexture.d.ts +12 -0
- package/dist/production-runtime/resources/GPUTexture.d.ts.map +1 -0
- package/dist/production-runtime/resources/GPUTexture.js +7 -0
- package/dist/production-runtime/resources/GPUTexture.js.map +1 -0
- package/dist/production-runtime/resources/RenderTarget.d.ts +11 -0
- package/dist/production-runtime/resources/RenderTarget.d.ts.map +1 -0
- package/dist/production-runtime/resources/RenderTarget.js +7 -0
- package/dist/production-runtime/resources/RenderTarget.js.map +1 -0
- package/dist/production-runtime/resources/ResourceCache.d.ts +8 -0
- package/dist/production-runtime/resources/ResourceCache.d.ts.map +1 -0
- package/dist/production-runtime/resources/ResourceCache.js +8 -0
- package/dist/production-runtime/resources/ResourceCache.js.map +1 -0
- package/dist/production-runtime/scene/Camera.d.ts +8 -0
- package/dist/production-runtime/scene/Camera.d.ts.map +1 -0
- package/dist/production-runtime/scene/Camera.js +2 -0
- package/dist/production-runtime/scene/Camera.js.map +1 -0
- package/dist/production-runtime/scene/Lights.d.ts +9 -0
- package/dist/production-runtime/scene/Lights.d.ts.map +1 -0
- package/dist/production-runtime/scene/Lights.js +2 -0
- package/dist/production-runtime/scene/Lights.js.map +1 -0
- package/dist/production-runtime/scene/RenderableMesh.d.ts +8 -0
- package/dist/production-runtime/scene/RenderableMesh.d.ts.map +1 -0
- package/dist/production-runtime/scene/RenderableMesh.js +2 -0
- package/dist/production-runtime/scene/RenderableMesh.js.map +1 -0
- package/dist/production-runtime/scene/RenderablePrimitive.d.ts +8 -0
- package/dist/production-runtime/scene/RenderablePrimitive.d.ts.map +1 -0
- package/dist/production-runtime/scene/RenderablePrimitive.js +2 -0
- package/dist/production-runtime/scene/RenderablePrimitive.js.map +1 -0
- package/dist/production-runtime/scene/RenderableScene.d.ts +11 -0
- package/dist/production-runtime/scene/RenderableScene.d.ts.map +1 -0
- package/dist/production-runtime/scene/RenderableScene.js +2 -0
- package/dist/production-runtime/scene/RenderableScene.js.map +1 -0
- package/dist/production-runtime/shaders/ShaderProgramLibrary.d.ts +12 -0
- package/dist/production-runtime/shaders/ShaderProgramLibrary.d.ts.map +1 -0
- package/dist/production-runtime/shaders/ShaderProgramLibrary.js +7 -0
- package/dist/production-runtime/shaders/ShaderProgramLibrary.js.map +1 -0
- package/dist/shadows/CascadedShadowPipeline.d.ts +25 -0
- package/dist/shadows/CascadedShadowPipeline.d.ts.map +1 -0
- package/dist/shadows/CascadedShadowPipeline.js +31 -0
- package/dist/shadows/CascadedShadowPipeline.js.map +1 -0
- package/dist/shadows/ContactShadows.d.ts +37 -0
- package/dist/shadows/ContactShadows.d.ts.map +1 -0
- package/dist/shadows/ContactShadows.js +68 -0
- package/dist/shadows/ContactShadows.js.map +1 -0
- package/dist/shadows/ShadowDebugViews.d.ts +12 -0
- package/dist/shadows/ShadowDebugViews.d.ts.map +1 -0
- package/dist/shadows/ShadowDebugViews.js +35 -0
- package/dist/shadows/ShadowDebugViews.js.map +1 -0
- package/dist/threejs-compatibility/InstancingSystem.d.ts +10 -0
- package/dist/threejs-compatibility/InstancingSystem.d.ts.map +1 -0
- package/dist/threejs-compatibility/InstancingSystem.js +11 -0
- package/dist/threejs-compatibility/InstancingSystem.js.map +1 -0
- package/dist/threejs-compatibility/LightingSystem.d.ts +11 -0
- package/dist/threejs-compatibility/LightingSystem.d.ts.map +1 -0
- package/dist/threejs-compatibility/LightingSystem.js +14 -0
- package/dist/threejs-compatibility/LightingSystem.js.map +1 -0
- package/dist/threejs-compatibility/MaterialSystem.d.ts +6 -0
- package/dist/threejs-compatibility/MaterialSystem.d.ts.map +1 -0
- package/dist/threejs-compatibility/MaterialSystem.js +7 -0
- package/dist/threejs-compatibility/MaterialSystem.js.map +1 -0
- package/dist/threejs-compatibility/RenderTargetSystem.d.ts +16 -0
- package/dist/threejs-compatibility/RenderTargetSystem.d.ts.map +1 -0
- package/dist/threejs-compatibility/RenderTargetSystem.js +23 -0
- package/dist/threejs-compatibility/RenderTargetSystem.js.map +1 -0
- package/dist/threejs-compatibility/RendererDiagnostics.d.ts +27 -0
- package/dist/threejs-compatibility/RendererDiagnostics.d.ts.map +1 -0
- package/dist/threejs-compatibility/RendererDiagnostics.js +41 -0
- package/dist/threejs-compatibility/RendererDiagnostics.js.map +1 -0
- package/dist/threejs-compatibility/SceneRenderer.d.ts +19 -0
- package/dist/threejs-compatibility/SceneRenderer.d.ts.map +1 -0
- package/dist/threejs-compatibility/SceneRenderer.js +18 -0
- package/dist/threejs-compatibility/SceneRenderer.js.map +1 -0
- package/dist/threejs-compatibility/ShadowSystem.d.ts +11 -0
- package/dist/threejs-compatibility/ShadowSystem.d.ts.map +1 -0
- package/dist/threejs-compatibility/ShadowSystem.js +12 -0
- package/dist/threejs-compatibility/ShadowSystem.js.map +1 -0
- package/dist/threejs-compatibility/TextureSystem.d.ts +9 -0
- package/dist/threejs-compatibility/TextureSystem.d.ts.map +1 -0
- package/dist/threejs-compatibility/TextureSystem.js +14 -0
- package/dist/threejs-compatibility/TextureSystem.js.map +1 -0
- package/dist/threejs-compatibility/ThreeCompatRenderer.d.ts +37 -0
- package/dist/threejs-compatibility/ThreeCompatRenderer.d.ts.map +1 -0
- package/dist/threejs-compatibility/ThreeCompatRenderer.js +77 -0
- package/dist/threejs-compatibility/ThreeCompatRenderer.js.map +1 -0
- package/dist/threejs-compatibility/TransparencySystem.d.ts +11 -0
- package/dist/threejs-compatibility/TransparencySystem.d.ts.map +1 -0
- package/dist/threejs-compatibility/TransparencySystem.js +12 -0
- package/dist/threejs-compatibility/TransparencySystem.js.map +1 -0
- package/dist/threejs-compatibility/index.d.ts +25 -0
- package/dist/threejs-compatibility/index.d.ts.map +1 -0
- package/dist/threejs-compatibility/index.js +15 -0
- package/dist/threejs-compatibility/index.js.map +1 -0
- package/dist/threejs-compatibility/performance/BVH.d.ts +11 -0
- package/dist/threejs-compatibility/performance/BVH.d.ts.map +1 -0
- package/dist/threejs-compatibility/performance/BVH.js +10 -0
- package/dist/threejs-compatibility/performance/BVH.js.map +1 -0
- package/dist/threejs-compatibility/performance/FrustumCulling.d.ts +7 -0
- package/dist/threejs-compatibility/performance/FrustumCulling.d.ts.map +1 -0
- package/dist/threejs-compatibility/performance/FrustumCulling.js +5 -0
- package/dist/threejs-compatibility/performance/FrustumCulling.js.map +1 -0
- package/dist/threejs-compatibility/performance/Instancing.d.ts +7 -0
- package/dist/threejs-compatibility/performance/Instancing.d.ts.map +1 -0
- package/dist/threejs-compatibility/performance/Instancing.js +10 -0
- package/dist/threejs-compatibility/performance/Instancing.js.map +1 -0
- package/dist/threejs-compatibility/performance/LODSystem.d.ts +9 -0
- package/dist/threejs-compatibility/performance/LODSystem.d.ts.map +1 -0
- package/dist/threejs-compatibility/performance/LODSystem.js +11 -0
- package/dist/threejs-compatibility/performance/LODSystem.js.map +1 -0
- package/dist/threejs-compatibility/performance/OcclusionCulling.d.ts +3 -0
- package/dist/threejs-compatibility/performance/OcclusionCulling.d.ts.map +1 -0
- package/dist/threejs-compatibility/performance/OcclusionCulling.js +5 -0
- package/dist/threejs-compatibility/performance/OcclusionCulling.js.map +1 -0
- package/dist/threejs-compatibility/performance/RaycastAcceleration.d.ts +8 -0
- package/dist/threejs-compatibility/performance/RaycastAcceleration.d.ts.map +1 -0
- package/dist/threejs-compatibility/performance/RaycastAcceleration.js +11 -0
- package/dist/threejs-compatibility/performance/RaycastAcceleration.js.map +1 -0
- package/dist/threejs-compatibility/performance/RendererProfiler.d.ts +11 -0
- package/dist/threejs-compatibility/performance/RendererProfiler.d.ts.map +1 -0
- package/dist/threejs-compatibility/performance/RendererProfiler.js +10 -0
- package/dist/threejs-compatibility/performance/RendererProfiler.js.map +1 -0
- package/dist/threejs-compatibility/performance/TextureStreaming.d.ts +7 -0
- package/dist/threejs-compatibility/performance/TextureStreaming.d.ts.map +1 -0
- package/dist/threejs-compatibility/performance/TextureStreaming.js +10 -0
- package/dist/threejs-compatibility/performance/TextureStreaming.js.map +1 -0
- package/dist/threejs-compatibility/performance/index.d.ts +13 -0
- package/dist/threejs-compatibility/performance/index.d.ts.map +1 -0
- package/dist/threejs-compatibility/performance/index.js +9 -0
- package/dist/threejs-compatibility/performance/index.js.map +1 -0
- package/dist/threejs-compatibility/postprocess/BloomPass.d.ts +9 -0
- package/dist/threejs-compatibility/postprocess/BloomPass.d.ts.map +1 -0
- package/dist/threejs-compatibility/postprocess/BloomPass.js +14 -0
- package/dist/threejs-compatibility/postprocess/BloomPass.js.map +1 -0
- package/dist/threejs-compatibility/postprocess/ColorGradingPass.d.ts +10 -0
- package/dist/threejs-compatibility/postprocess/ColorGradingPass.d.ts.map +1 -0
- package/dist/threejs-compatibility/postprocess/ColorGradingPass.js +16 -0
- package/dist/threejs-compatibility/postprocess/ColorGradingPass.js.map +1 -0
- package/dist/threejs-compatibility/postprocess/DepthOfFieldPass.d.ts +9 -0
- package/dist/threejs-compatibility/postprocess/DepthOfFieldPass.d.ts.map +1 -0
- package/dist/threejs-compatibility/postprocess/DepthOfFieldPass.js +19 -0
- package/dist/threejs-compatibility/postprocess/DepthOfFieldPass.js.map +1 -0
- package/dist/threejs-compatibility/postprocess/EffectComposer.d.ts +7 -0
- package/dist/threejs-compatibility/postprocess/EffectComposer.d.ts.map +1 -0
- package/dist/threejs-compatibility/postprocess/EffectComposer.js +11 -0
- package/dist/threejs-compatibility/postprocess/EffectComposer.js.map +1 -0
- package/dist/threejs-compatibility/postprocess/FXAAPass.d.ts +7 -0
- package/dist/threejs-compatibility/postprocess/FXAAPass.d.ts.map +1 -0
- package/dist/threejs-compatibility/postprocess/FXAAPass.js +10 -0
- package/dist/threejs-compatibility/postprocess/FXAAPass.js.map +1 -0
- package/dist/threejs-compatibility/postprocess/MotionBlurPass.d.ts +9 -0
- package/dist/threejs-compatibility/postprocess/MotionBlurPass.d.ts.map +1 -0
- package/dist/threejs-compatibility/postprocess/MotionBlurPass.js +18 -0
- package/dist/threejs-compatibility/postprocess/MotionBlurPass.js.map +1 -0
- package/dist/threejs-compatibility/postprocess/OutlinePass.d.ts +9 -0
- package/dist/threejs-compatibility/postprocess/OutlinePass.d.ts.map +1 -0
- package/dist/threejs-compatibility/postprocess/OutlinePass.js +19 -0
- package/dist/threejs-compatibility/postprocess/OutlinePass.js.map +1 -0
- package/dist/threejs-compatibility/postprocess/PostProcessTypes.d.ts +42 -0
- package/dist/threejs-compatibility/postprocess/PostProcessTypes.d.ts.map +1 -0
- package/dist/threejs-compatibility/postprocess/PostProcessTypes.js +123 -0
- package/dist/threejs-compatibility/postprocess/PostProcessTypes.js.map +1 -0
- package/dist/threejs-compatibility/postprocess/RenderPass.d.ts +7 -0
- package/dist/threejs-compatibility/postprocess/RenderPass.d.ts.map +1 -0
- package/dist/threejs-compatibility/postprocess/RenderPass.js +8 -0
- package/dist/threejs-compatibility/postprocess/RenderPass.js.map +1 -0
- package/dist/threejs-compatibility/postprocess/SMAAPass.d.ts +7 -0
- package/dist/threejs-compatibility/postprocess/SMAAPass.d.ts.map +1 -0
- package/dist/threejs-compatibility/postprocess/SMAAPass.js +10 -0
- package/dist/threejs-compatibility/postprocess/SMAAPass.js.map +1 -0
- package/dist/threejs-compatibility/postprocess/SSAOPass.d.ts +9 -0
- package/dist/threejs-compatibility/postprocess/SSAOPass.d.ts.map +1 -0
- package/dist/threejs-compatibility/postprocess/SSAOPass.js +19 -0
- package/dist/threejs-compatibility/postprocess/SSAOPass.js.map +1 -0
- package/dist/threejs-compatibility/postprocess/ShaderPass.d.ts +9 -0
- package/dist/threejs-compatibility/postprocess/ShaderPass.d.ts.map +1 -0
- package/dist/threejs-compatibility/postprocess/ShaderPass.js +11 -0
- package/dist/threejs-compatibility/postprocess/ShaderPass.js.map +1 -0
- package/dist/threejs-compatibility/postprocess/TAAPass.d.ts +7 -0
- package/dist/threejs-compatibility/postprocess/TAAPass.d.ts.map +1 -0
- package/dist/threejs-compatibility/postprocess/TAAPass.js +10 -0
- package/dist/threejs-compatibility/postprocess/TAAPass.js.map +1 -0
- package/dist/threejs-compatibility/postprocess/VignettePass.d.ts +9 -0
- package/dist/threejs-compatibility/postprocess/VignettePass.d.ts.map +1 -0
- package/dist/threejs-compatibility/postprocess/VignettePass.js +14 -0
- package/dist/threejs-compatibility/postprocess/VignettePass.js.map +1 -0
- package/dist/threejs-compatibility/postprocess/index.d.ts +16 -0
- package/dist/threejs-compatibility/postprocess/index.d.ts.map +1 -0
- package/dist/threejs-compatibility/postprocess/index.js +15 -0
- package/dist/threejs-compatibility/postprocess/index.js.map +1 -0
- package/dist/threejs-compatibility/shaders/NodeMaterial.d.ts +14 -0
- package/dist/threejs-compatibility/shaders/NodeMaterial.d.ts.map +1 -0
- package/dist/threejs-compatibility/shaders/NodeMaterial.js +15 -0
- package/dist/threejs-compatibility/shaders/NodeMaterial.js.map +1 -0
- package/dist/threejs-compatibility/shaders/RawShaderMaterial.d.ts +6 -0
- package/dist/threejs-compatibility/shaders/RawShaderMaterial.d.ts.map +1 -0
- package/dist/threejs-compatibility/shaders/RawShaderMaterial.js +6 -0
- package/dist/threejs-compatibility/shaders/RawShaderMaterial.js.map +1 -0
- package/dist/threejs-compatibility/shaders/ShaderDiagnostics.d.ts +7 -0
- package/dist/threejs-compatibility/shaders/ShaderDiagnostics.d.ts.map +1 -0
- package/dist/threejs-compatibility/shaders/ShaderDiagnostics.js +12 -0
- package/dist/threejs-compatibility/shaders/ShaderDiagnostics.js.map +1 -0
- package/dist/threejs-compatibility/shaders/ShaderMaterial.d.ts +12 -0
- package/dist/threejs-compatibility/shaders/ShaderMaterial.d.ts.map +1 -0
- package/dist/threejs-compatibility/shaders/ShaderMaterial.js +20 -0
- package/dist/threejs-compatibility/shaders/ShaderMaterial.js.map +1 -0
- package/dist/threejs-compatibility/shaders/ThreeCompatShaderChunks.d.ts +7 -0
- package/dist/threejs-compatibility/shaders/ThreeCompatShaderChunks.d.ts.map +1 -0
- package/dist/threejs-compatibility/shaders/ThreeCompatShaderChunks.js +7 -0
- package/dist/threejs-compatibility/shaders/ThreeCompatShaderChunks.js.map +1 -0
- package/dist/threejs-compatibility/shaders/Uniforms.d.ts +8 -0
- package/dist/threejs-compatibility/shaders/Uniforms.d.ts.map +1 -0
- package/dist/threejs-compatibility/shaders/Uniforms.js +14 -0
- package/dist/threejs-compatibility/shaders/Uniforms.js.map +1 -0
- package/dist/threejs-compatibility/shaders/index.d.ts +10 -0
- package/dist/threejs-compatibility/shaders/index.d.ts.map +1 -0
- package/dist/threejs-compatibility/shaders/index.js +7 -0
- package/dist/threejs-compatibility/shaders/index.js.map +1 -0
- package/dist/threejs-compatibility/vfx/GPUPointCloud.d.ts +7 -0
- package/dist/threejs-compatibility/vfx/GPUPointCloud.d.ts.map +1 -0
- package/dist/threejs-compatibility/vfx/GPUPointCloud.js +12 -0
- package/dist/threejs-compatibility/vfx/GPUPointCloud.js.map +1 -0
- package/dist/threejs-compatibility/vfx/LineRenderer.d.ts +10 -0
- package/dist/threejs-compatibility/vfx/LineRenderer.d.ts.map +1 -0
- package/dist/threejs-compatibility/vfx/LineRenderer.js +7 -0
- package/dist/threejs-compatibility/vfx/LineRenderer.js.map +1 -0
- package/dist/threejs-compatibility/vfx/ParticleSystem.d.ts +12 -0
- package/dist/threejs-compatibility/vfx/ParticleSystem.d.ts.map +1 -0
- package/dist/threejs-compatibility/vfx/ParticleSystem.js +15 -0
- package/dist/threejs-compatibility/vfx/ParticleSystem.js.map +1 -0
- package/dist/threejs-compatibility/vfx/SpriteSystem.d.ts +11 -0
- package/dist/threejs-compatibility/vfx/SpriteSystem.d.ts.map +1 -0
- package/dist/threejs-compatibility/vfx/SpriteSystem.js +7 -0
- package/dist/threejs-compatibility/vfx/SpriteSystem.js.map +1 -0
- package/dist/threejs-compatibility/vfx/TrailRenderer.d.ts +5 -0
- package/dist/threejs-compatibility/vfx/TrailRenderer.d.ts.map +1 -0
- package/dist/threejs-compatibility/vfx/TrailRenderer.js +9 -0
- package/dist/threejs-compatibility/vfx/TrailRenderer.js.map +1 -0
- package/dist/threejs-compatibility/vfx/VFXDiagnostics.d.ts +21 -0
- package/dist/threejs-compatibility/vfx/VFXDiagnostics.d.ts.map +1 -0
- package/dist/threejs-compatibility/vfx/VFXDiagnostics.js +12 -0
- package/dist/threejs-compatibility/vfx/VFXDiagnostics.js.map +1 -0
- package/dist/threejs-compatibility/vfx/index.d.ts +10 -0
- package/dist/threejs-compatibility/vfx/index.d.ts.map +1 -0
- package/dist/threejs-compatibility/vfx/index.js +7 -0
- package/dist/threejs-compatibility/vfx/index.js.map +1 -0
- package/dist/threejs-example-parity/index.d.ts +57 -0
- package/dist/threejs-example-parity/index.d.ts.map +1 -0
- package/dist/threejs-example-parity/index.js +139 -0
- package/dist/threejs-example-parity/index.js.map +1 -0
- package/dist/webgpu/WebGPUBuffer.d.ts +2 -0
- package/dist/webgpu/WebGPUBuffer.d.ts.map +1 -0
- package/dist/webgpu/WebGPUBuffer.js +2 -0
- package/dist/webgpu/WebGPUBuffer.js.map +1 -0
- package/dist/webgpu/WebGPUCompute.d.ts +3 -0
- package/dist/webgpu/WebGPUCompute.d.ts.map +1 -0
- package/dist/webgpu/WebGPUCompute.js +2 -0
- package/dist/webgpu/WebGPUCompute.js.map +1 -0
- package/dist/webgpu/WebGPUPipelineCache.d.ts +6 -0
- package/dist/webgpu/WebGPUPipelineCache.d.ts.map +1 -0
- package/dist/webgpu/WebGPUPipelineCache.js +15 -0
- package/dist/webgpu/WebGPUPipelineCache.js.map +1 -0
- package/dist/webgpu/WebGPUPostProcess.d.ts +3 -0
- package/dist/webgpu/WebGPUPostProcess.d.ts.map +1 -0
- package/dist/webgpu/WebGPUPostProcess.js +2 -0
- package/dist/webgpu/WebGPUPostProcess.js.map +1 -0
- package/dist/webgpu/WebGPUTexture.d.ts +3 -0
- package/dist/webgpu/WebGPUTexture.d.ts.map +1 -0
- package/dist/webgpu/WebGPUTexture.js +2 -0
- package/dist/webgpu/WebGPUTexture.js.map +1 -0
- package/package.json +18 -0
- package/src/ArchitecturalLightingFixtures.ts +241 -0
- package/src/ArchitecturalMaterialCatalog.ts +130 -0
- package/src/ArchitecturalMeasurementFixtures.ts +155 -0
- package/src/BRDFLut.ts +47 -0
- package/src/CameraFraming.ts +200 -0
- package/src/CanonicalSceneFixtures.ts +95 -0
- package/src/CascadedShadowMaps.ts +449 -0
- package/src/ColorManagement.ts +127 -0
- package/src/CullingFixtures.ts +280 -0
- package/src/DecalGeometry.ts +26 -0
- package/src/DepthPass.ts +110 -0
- package/src/EnvironmentBackgroundPass.ts +194 -0
- package/src/EnvironmentBackgroundResources.ts +309 -0
- package/src/EnvironmentLighting.ts +96 -0
- package/src/EnvironmentMapResources.ts +1026 -0
- package/src/EnvironmentPipeline.ts +69 -0
- package/src/EnvironmentPlatform.ts +1306 -0
- package/src/EnvironmentPreset.ts +155 -0
- package/src/Exposure.ts +66 -0
- package/src/ExternalParityRenderPreset.ts +725 -0
- package/src/ForwardPass.ts +1639 -0
- package/src/FrameVisualMetrics.ts +218 -0
- package/src/Geometry.ts +461 -0
- package/src/GeometryPrimitives.ts +2 -0
- package/src/HDRRenderPipeline.ts +94 -0
- package/src/IBL.ts +86 -0
- package/src/IndexBuffer.ts +57 -0
- package/src/InstancedPBRMaterial.ts +186 -0
- package/src/InstancedUnlitMaterial.ts +60 -0
- package/src/Instancing.ts +19 -0
- package/src/LightCollector.ts +82 -0
- package/src/LightUniforms.ts +47 -0
- package/src/LightingDebug.ts +80 -0
- package/src/LightingDefaults.ts +79 -0
- package/src/LightingRig.ts +301 -0
- package/src/LineGeometry.ts +2 -0
- package/src/Material.ts +209 -0
- package/src/MaterialBinding.ts +131 -0
- package/src/MaterialInstance.ts +59 -0
- package/src/MaterialPresets.ts +272 -0
- package/src/MorphTarget.ts +123 -0
- package/src/MorphUnlitMaterial.ts +54 -0
- package/src/NormalMappedPBRMaterial.ts +188 -0
- package/src/OceanFixtures.ts +318 -0
- package/src/PBRLightingDefaults.ts +12 -0
- package/src/PBRMaterial.ts +442 -0
- package/src/PMREM.ts +53 -0
- package/src/PbrReference.ts +681 -0
- package/src/PostProcessPass.ts +2507 -0
- package/src/ProceduralTextureFixtures.ts +393 -0
- package/src/ProductTurntableFixtures.ts +815 -0
- package/src/Raycaster.ts +21 -0
- package/src/ReflectionProbe.ts +13 -0
- package/src/ReflectionSurfaces.ts +219 -0
- package/src/RenderBackend.ts +43 -0
- package/src/RenderDebugViews.ts +138 -0
- package/src/RenderDevice.ts +836 -0
- package/src/RenderGraph.ts +194 -0
- package/src/RenderPass.ts +27 -0
- package/src/RenderPipeline.ts +101 -0
- package/src/RenderQueue.ts +12 -0
- package/src/RenderState.ts +12 -0
- package/src/Renderer.ts +2626 -0
- package/src/RendererDebugOverlay.ts +80 -0
- package/src/RendererFeatureGates.ts +150 -0
- package/src/RendererPostprocessPlan.ts +279 -0
- package/src/RendererTiming.ts +251 -0
- package/src/RendererVisualPipelineReport.ts +836 -0
- package/src/ResourceLifecycle.ts +21 -0
- package/src/Sampler.ts +37 -0
- package/src/SceneOptimization.ts +518 -0
- package/src/ShaderChunks.ts +393 -0
- package/src/ShaderLibrary.ts +2738 -0
- package/src/ShaderModule.ts +36 -0
- package/src/ShaderPreprocessor.ts +260 -0
- package/src/ShaderReflection.ts +201 -0
- package/src/ShadowMap.ts +237 -0
- package/src/ShadowPass.ts +198 -0
- package/src/ShadowProjection.ts +115 -0
- package/src/SkinnedLitMaterial.ts +366 -0
- package/src/SkinnedUnlitMaterial.ts +63 -0
- package/src/SkinningBounds.ts +131 -0
- package/src/SpaceEnvironmentFixtures.ts +200 -0
- package/src/SpriteGeometry.ts +21 -0
- package/src/StereoCameraRig.ts +127 -0
- package/src/StereoEffects.ts +274 -0
- package/src/TerrainFixtures.ts +180 -0
- package/src/Texture.ts +307 -0
- package/src/TextureBinding.ts +91 -0
- package/src/TexturedPBRMaterial.ts +1112 -0
- package/src/TexturedUnlitMaterial.ts +67 -0
- package/src/ToneMapping.ts +105 -0
- package/src/UniformBinder.ts +16 -0
- package/src/UniformLayout.ts +129 -0
- package/src/UnlitMaterial.ts +75 -0
- package/src/VegetationFixtures.ts +314 -0
- package/src/VertexBuffer.ts +120 -0
- package/src/VertexFormat.ts +171 -0
- package/src/VoxelWorldFixtures.ts +280 -0
- package/src/WeatherFixtures.ts +223 -0
- package/src/WebGL2Device.ts +2280 -0
- package/src/WebGL2StateCache.ts +330 -0
- package/src/WebGPUDevice.ts +2806 -0
- package/src/WebGPURenderToTextureProof.ts +139 -0
- package/src/advanced-runtime/AdvancedRenderer.ts +73 -0
- package/src/advanced-runtime/index.ts +9 -0
- package/src/cinematic/BloomPass.ts +26 -0
- package/src/cinematic/CinematicDepthComposition.ts +30 -0
- package/src/cinematic/CinematicEvidence.ts +123 -0
- package/src/cinematic/CinematicLightingRig.ts +144 -0
- package/src/cinematic/CinematicMaterialPresets.ts +130 -0
- package/src/cinematic/CinematicPostProcess.ts +83 -0
- package/src/cinematic/DepthHazePass.ts +30 -0
- package/src/cinematic/EmissivePracticalLightSystem.ts +45 -0
- package/src/cinematic/FilmGrainPass.ts +24 -0
- package/src/cinematic/FogVolumeSystem.ts +30 -0
- package/src/cinematic/GlowCardSystem.ts +44 -0
- package/src/cinematic/RainParticleSystem.ts +151 -0
- package/src/cinematic/VignettePass.ts +25 -0
- package/src/cinematic/WetReflectionApproximation.ts +27 -0
- package/src/cinematic/index.ts +14 -0
- package/src/effects/CollisionModule.ts +64 -0
- package/src/effects/ColorModule.ts +60 -0
- package/src/effects/ForceModule.ts +25 -0
- package/src/effects/GPUParticleBackend.ts +569 -0
- package/src/effects/Particle.ts +108 -0
- package/src/effects/ParticleDiagnostics.ts +224 -0
- package/src/effects/ParticleEffectPresets.ts +147 -0
- package/src/effects/ParticleEmitter.ts +326 -0
- package/src/effects/ParticleModule.ts +26 -0
- package/src/effects/ParticleRenderPass.ts +117 -0
- package/src/effects/ParticleRenderer.ts +132 -0
- package/src/effects/ParticleSystem.ts +333 -0
- package/src/effects/SizeModule.ts +56 -0
- package/src/effects/TrailModule.ts +72 -0
- package/src/effects/VelocityModule.ts +75 -0
- package/src/effects/index.ts +15 -0
- package/src/index.ts +914 -0
- package/src/materials/AlphaSorting.ts +30 -0
- package/src/materials/MaterialExtensions.ts +42 -0
- package/src/materials/PhysicalMaterial.ts +133 -0
- package/src/materials/TransmissionPass.ts +51 -0
- package/src/performance/BVH.ts +18 -0
- package/src/performance/Batcher.ts +2 -0
- package/src/performance/FrustumCuller.ts +9 -0
- package/src/performance/LOD.ts +20 -0
- package/src/performance/Octree.ts +10 -0
- package/src/performance/RenderItemSorting.ts +167 -0
- package/src/performance/RendererStats.ts +43 -0
- package/src/performance/ResourceBudget.ts +44 -0
- package/src/postprocess/BloomPass.ts +28 -0
- package/src/postprocess/CinematicDiagnostics.ts +642 -0
- package/src/postprocess/ColorGradingPass.ts +24 -0
- package/src/postprocess/DepthOfFieldPass.ts +12 -0
- package/src/postprocess/EffectComposer.ts +349 -0
- package/src/postprocess/SSAOPass.ts +20 -0
- package/src/postprocess/index.ts +34 -0
- package/src/production-runtime/AnimationControlsPipeline.ts +77 -0
- package/src/production-runtime/PBRHDRPipeline.ts +381 -0
- package/src/production-runtime/ProductionEffectsPipeline.ts +85 -0
- package/src/production-runtime/ProductionRendererTypes.ts +136 -0
- package/src/production-runtime/ProductionRuntimeRenderer.ts +172 -0
- package/src/production-runtime/ProductionWebGL2Renderer.ts +313 -0
- package/src/production-runtime/ProductionWebGPURenderer.ts +396 -0
- package/src/production-runtime/TransmissionBackdropCapture.ts +130 -0
- package/src/production-runtime/animation/MorphTargetRenderer.ts +2 -0
- package/src/production-runtime/animation/SkinningRenderer.ts +2 -0
- package/src/production-runtime/backends/RendererBackend.ts +17 -0
- package/src/production-runtime/backends/WebGL2RendererBackend.ts +30 -0
- package/src/production-runtime/backends/WebGPURendererBackend.ts +24 -0
- package/src/production-runtime/backends/webgl2/WebGL2Buffer.ts +2 -0
- package/src/production-runtime/backends/webgl2/WebGL2Capabilities.ts +2 -0
- package/src/production-runtime/backends/webgl2/WebGL2RenderTarget.ts +2 -0
- package/src/production-runtime/backends/webgl2/WebGL2Shader.ts +2 -0
- package/src/production-runtime/backends/webgl2/WebGL2StateCache.ts +1 -0
- package/src/production-runtime/backends/webgl2/WebGL2Texture.ts +2 -0
- package/src/production-runtime/backends/webgpu/WebGPUBuffer.ts +2 -0
- package/src/production-runtime/backends/webgpu/WebGPUCapabilities.ts +2 -0
- package/src/production-runtime/backends/webgpu/WebGPURenderTarget.ts +2 -0
- package/src/production-runtime/backends/webgpu/WebGPUShader.ts +2 -0
- package/src/production-runtime/backends/webgpu/WebGPUTexture.ts +2 -0
- package/src/production-runtime/color/ColorManagement.ts +3 -0
- package/src/production-runtime/color/ToneMapping.ts +7 -0
- package/src/production-runtime/diagnostics/FrameCapture.ts +2 -0
- package/src/production-runtime/diagnostics/GPUCapabilities.ts +2 -0
- package/src/production-runtime/diagnostics/RendererStats.ts +2 -0
- package/src/production-runtime/environment/EnvironmentMap.ts +1 -0
- package/src/production-runtime/environment/HDRLoader.ts +57 -0
- package/src/production-runtime/environment/PMREMGenerator.ts +713 -0
- package/src/production-runtime/framegraph/FrameGraph.ts +18 -0
- package/src/production-runtime/framegraph/RenderPass.ts +15 -0
- package/src/production-runtime/geometry/ProjectedDecalGeometry.ts +439 -0
- package/src/production-runtime/index.ts +127 -0
- package/src/production-runtime/lights/LightManager.ts +7 -0
- package/src/production-runtime/lights/ShadowMapRenderer.ts +5 -0
- package/src/production-runtime/materials/GLTFMaterialAdapter.ts +6 -0
- package/src/production-runtime/materials/GLTFPBRMaterialAdapter.ts +2 -0
- package/src/production-runtime/materials/MaterialCompiler.ts +7 -0
- package/src/production-runtime/materials/MaterialTextureBindings.ts +5 -0
- package/src/production-runtime/materials/PBRMaterial.ts +2 -0
- package/src/production-runtime/materials/PBRShaderFeatures.ts +2 -0
- package/src/production-runtime/passes/ContactShadowPass.ts +184 -0
- package/src/production-runtime/passes/DepthPrepass.ts +7 -0
- package/src/production-runtime/passes/OpaquePass.ts +7 -0
- package/src/production-runtime/passes/ShadowPass.ts +7 -0
- package/src/production-runtime/passes/SkyboxPass.ts +7 -0
- package/src/production-runtime/passes/ToneMappingPass.ts +7 -0
- package/src/production-runtime/passes/TransparentPass.ts +7 -0
- package/src/production-runtime/postprocess/BloomPass.ts +51 -0
- package/src/production-runtime/postprocess/ColorGradingPass.ts +49 -0
- package/src/production-runtime/postprocess/DOFPass.ts +47 -0
- package/src/production-runtime/postprocess/FXAAPass.ts +53 -0
- package/src/production-runtime/postprocess/ProductionEffectComposer.ts +78 -0
- package/src/production-runtime/postprocess/ProductionPostProcessTypes.ts +174 -0
- package/src/production-runtime/postprocess/SSAOPass.ts +45 -0
- package/src/production-runtime/resources/GPUBuffer.ts +2 -0
- package/src/production-runtime/resources/GPUTexture.ts +2 -0
- package/src/production-runtime/resources/RenderTarget.ts +3 -0
- package/src/production-runtime/resources/ResourceCache.ts +7 -0
- package/src/production-runtime/scene/Camera.ts +1 -0
- package/src/production-runtime/scene/Lights.ts +2 -0
- package/src/production-runtime/scene/RenderableMesh.ts +2 -0
- package/src/production-runtime/scene/RenderablePrimitive.ts +1 -0
- package/src/production-runtime/scene/RenderableScene.ts +4 -0
- package/src/production-runtime/shaders/ShaderProgramLibrary.ts +7 -0
- package/src/production-runtime/shaders/chunks/brdf.glsl +2 -0
- package/src/production-runtime/shaders/chunks/ibl.glsl +3 -0
- package/src/production-runtime/shaders/chunks/pbr.frag.glsl +47 -0
- package/src/production-runtime/shaders/chunks/pbr.vert.glsl +8 -0
- package/src/production-runtime/shaders/chunks/shadows.glsl +2 -0
- package/src/production-runtime/shaders/wgsl/pbr.wgsl +3 -0
- package/src/production-runtime/shaders/wgsl/postprocess.wgsl +2 -0
- package/src/production-runtime/shaders/wgsl/skybox.wgsl +2 -0
- package/src/shaders/depth.frag.glsl +5 -0
- package/src/shaders/depth.vert.glsl +8 -0
- package/src/shaders/pbr-direct.frag.glsl +687 -0
- package/src/shaders/pbr-direct.vert.glsl +18 -0
- package/src/shaders/unlit.frag.glsl +18 -0
- package/src/shaders/unlit.vert.glsl +13 -0
- package/src/shadows/CascadedShadowPipeline.ts +53 -0
- package/src/shadows/ContactShadows.ts +106 -0
- package/src/shadows/ShadowDebugViews.ts +46 -0
- package/src/threejs-compatibility/InstancingSystem.ts +17 -0
- package/src/threejs-compatibility/LightingSystem.ts +22 -0
- package/src/threejs-compatibility/MaterialSystem.ts +9 -0
- package/src/threejs-compatibility/RenderTargetSystem.ts +35 -0
- package/src/threejs-compatibility/RendererDiagnostics.ts +61 -0
- package/src/threejs-compatibility/SceneRenderer.ts +34 -0
- package/src/threejs-compatibility/ShadowSystem.ts +19 -0
- package/src/threejs-compatibility/TextureSystem.ts +19 -0
- package/src/threejs-compatibility/ThreeCompatRenderer.ts +90 -0
- package/src/threejs-compatibility/TransparencySystem.ts +19 -0
- package/src/threejs-compatibility/index.ts +29 -0
- package/src/threejs-compatibility/performance/BVH.ts +14 -0
- package/src/threejs-compatibility/performance/FrustumCulling.ts +10 -0
- package/src/threejs-compatibility/performance/Instancing.ts +4 -0
- package/src/threejs-compatibility/performance/LODSystem.ts +16 -0
- package/src/threejs-compatibility/performance/OcclusionCulling.ts +6 -0
- package/src/threejs-compatibility/performance/RaycastAcceleration.ts +12 -0
- package/src/threejs-compatibility/performance/RendererProfiler.ts +19 -0
- package/src/threejs-compatibility/performance/TextureStreaming.ts +4 -0
- package/src/threejs-compatibility/performance/index.ts +12 -0
- package/src/threejs-compatibility/postprocess/BloomPass.ts +16 -0
- package/src/threejs-compatibility/postprocess/ColorGradingPass.ts +16 -0
- package/src/threejs-compatibility/postprocess/DepthOfFieldPass.ts +21 -0
- package/src/threejs-compatibility/postprocess/EffectComposer.ts +14 -0
- package/src/threejs-compatibility/postprocess/FXAAPass.ts +15 -0
- package/src/threejs-compatibility/postprocess/MotionBlurPass.ts +20 -0
- package/src/threejs-compatibility/postprocess/OutlinePass.ts +21 -0
- package/src/threejs-compatibility/postprocess/PostProcessTypes.ts +169 -0
- package/src/threejs-compatibility/postprocess/RenderPass.ts +9 -0
- package/src/threejs-compatibility/postprocess/SMAAPass.ts +15 -0
- package/src/threejs-compatibility/postprocess/SSAOPass.ts +21 -0
- package/src/threejs-compatibility/postprocess/ShaderPass.ts +7 -0
- package/src/threejs-compatibility/postprocess/TAAPass.ts +15 -0
- package/src/threejs-compatibility/postprocess/VignettePass.ts +16 -0
- package/src/threejs-compatibility/postprocess/index.ts +15 -0
- package/src/threejs-compatibility/shaders/NodeMaterial.ts +21 -0
- package/src/threejs-compatibility/shaders/RawShaderMaterial.ts +6 -0
- package/src/threejs-compatibility/shaders/ShaderDiagnostics.ts +17 -0
- package/src/threejs-compatibility/shaders/ShaderMaterial.ts +18 -0
- package/src/threejs-compatibility/shaders/ThreeCompatShaderChunks.ts +6 -0
- package/src/threejs-compatibility/shaders/Uniforms.ts +18 -0
- package/src/threejs-compatibility/shaders/index.ts +9 -0
- package/src/threejs-compatibility/vfx/GPUPointCloud.ts +7 -0
- package/src/threejs-compatibility/vfx/LineRenderer.ts +13 -0
- package/src/threejs-compatibility/vfx/ParticleSystem.ts +23 -0
- package/src/threejs-compatibility/vfx/SpriteSystem.ts +14 -0
- package/src/threejs-compatibility/vfx/TrailRenderer.ts +8 -0
- package/src/threejs-compatibility/vfx/VFXDiagnostics.ts +23 -0
- package/src/threejs-compatibility/vfx/index.ts +9 -0
- package/src/threejs-example-parity/index.ts +205 -0
- package/src/webgpu/WebGPUBuffer.ts +1 -0
- package/src/webgpu/WebGPUCompute.ts +2 -0
- package/src/webgpu/WebGPUPipelineCache.ts +15 -0
- package/src/webgpu/WebGPUPostProcess.ts +2 -0
- package/src/webgpu/WebGPUTexture.ts +2 -0
- package/tsconfig.json +26 -0
- package/vitest.config.ts +20 -0
|
@@ -0,0 +1,2403 @@
|
|
|
1
|
+
import { RenderDeviceError, viewBytes } from "./RenderDevice.js";
|
|
2
|
+
import { reflectShaderSources } from "./ShaderReflection.js";
|
|
3
|
+
import { Texture, bytesPerPixel, isCompressedTextureFormat } from "./Texture.js";
|
|
4
|
+
import { TextureBinding } from "./TextureBinding.js";
|
|
5
|
+
import {} from "./VertexFormat.js";
|
|
6
|
+
const BUFFER_USAGE = {
|
|
7
|
+
MAP_READ: 0x0001,
|
|
8
|
+
COPY_SRC: 0x0004,
|
|
9
|
+
COPY_DST: 0x0008,
|
|
10
|
+
INDEX: 0x0010,
|
|
11
|
+
VERTEX: 0x0020,
|
|
12
|
+
UNIFORM: 0x0040
|
|
13
|
+
};
|
|
14
|
+
const MAP_MODE = {
|
|
15
|
+
READ: 0x0001
|
|
16
|
+
};
|
|
17
|
+
const TEXTURE_USAGE = {
|
|
18
|
+
RENDER_ATTACHMENT: 0x0010,
|
|
19
|
+
COPY_SRC: 0x0001,
|
|
20
|
+
COPY_DST: 0x0002,
|
|
21
|
+
TEXTURE_BINDING: 0x0004
|
|
22
|
+
};
|
|
23
|
+
const DEPTH_TEXTURE_FORMAT = "depth24plus";
|
|
24
|
+
class WebGPURenderBuffer {
|
|
25
|
+
id;
|
|
26
|
+
usage;
|
|
27
|
+
byteLength;
|
|
28
|
+
nativeByteLength;
|
|
29
|
+
handle;
|
|
30
|
+
disposed = false;
|
|
31
|
+
bytes;
|
|
32
|
+
constructor(id, usage, byteLength, nativeByteLength, handle, initialData) {
|
|
33
|
+
this.id = id;
|
|
34
|
+
this.usage = usage;
|
|
35
|
+
this.byteLength = byteLength;
|
|
36
|
+
this.nativeByteLength = nativeByteLength;
|
|
37
|
+
this.handle = handle;
|
|
38
|
+
this.bytes = new Uint8Array(byteLength);
|
|
39
|
+
if (initialData)
|
|
40
|
+
this.bytes.set(viewBytes(initialData), 0);
|
|
41
|
+
}
|
|
42
|
+
dispose() {
|
|
43
|
+
if (!this.disposed) {
|
|
44
|
+
this.handle.destroy();
|
|
45
|
+
this.disposed = true;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
class WebGPUShaderProgram {
|
|
50
|
+
id;
|
|
51
|
+
label;
|
|
52
|
+
marker;
|
|
53
|
+
reflection;
|
|
54
|
+
modules;
|
|
55
|
+
entryPoints;
|
|
56
|
+
nativeUniformLayout;
|
|
57
|
+
disposed = false;
|
|
58
|
+
renderPipelines = new Map();
|
|
59
|
+
constructor(id, label, marker, reflection, modules, entryPoints, nativeUniformLayout) {
|
|
60
|
+
this.id = id;
|
|
61
|
+
this.label = label;
|
|
62
|
+
this.marker = marker;
|
|
63
|
+
this.reflection = reflection;
|
|
64
|
+
this.modules = modules;
|
|
65
|
+
this.entryPoints = entryPoints;
|
|
66
|
+
this.nativeUniformLayout = nativeUniformLayout;
|
|
67
|
+
}
|
|
68
|
+
dispose() {
|
|
69
|
+
this.disposed = true;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
class WebGPURenderTarget {
|
|
73
|
+
id;
|
|
74
|
+
width;
|
|
75
|
+
height;
|
|
76
|
+
label;
|
|
77
|
+
colorTexture;
|
|
78
|
+
depthTexture;
|
|
79
|
+
nativeTexture;
|
|
80
|
+
nativeView;
|
|
81
|
+
nativeDepthTexture;
|
|
82
|
+
nativeDepthView;
|
|
83
|
+
hasDepth;
|
|
84
|
+
disposed = false;
|
|
85
|
+
nativeNeedsClear = true;
|
|
86
|
+
nativeClearColor = [0, 0, 0, 1];
|
|
87
|
+
colorPixels;
|
|
88
|
+
colorFloatPixels;
|
|
89
|
+
depthPixels;
|
|
90
|
+
constructor(id, width, height, label, colorTexture, depthTexture, nativeTexture, nativeView, nativeDepthTexture, nativeDepthView, hasDepth) {
|
|
91
|
+
this.id = id;
|
|
92
|
+
this.width = width;
|
|
93
|
+
this.height = height;
|
|
94
|
+
this.label = label;
|
|
95
|
+
this.colorTexture = colorTexture;
|
|
96
|
+
this.depthTexture = depthTexture;
|
|
97
|
+
this.nativeTexture = nativeTexture;
|
|
98
|
+
this.nativeView = nativeView;
|
|
99
|
+
this.nativeDepthTexture = nativeDepthTexture;
|
|
100
|
+
this.nativeDepthView = nativeDepthView;
|
|
101
|
+
this.hasDepth = hasDepth;
|
|
102
|
+
this.colorPixels = new Uint8Array(width * height * 4);
|
|
103
|
+
this.colorFloatPixels = colorTexture.format === "rgba16f" || colorTexture.format === "rgba32f"
|
|
104
|
+
? new Float32Array(width * height * 4)
|
|
105
|
+
: null;
|
|
106
|
+
this.depthPixels = hasDepth ? new Float32Array(width * height).fill(1) : null;
|
|
107
|
+
}
|
|
108
|
+
dispose() {
|
|
109
|
+
if (!this.disposed) {
|
|
110
|
+
this.nativeTexture?.destroy();
|
|
111
|
+
this.nativeDepthTexture?.destroy();
|
|
112
|
+
this.colorTexture.dispose();
|
|
113
|
+
this.depthTexture?.dispose();
|
|
114
|
+
this.disposed = true;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
export class WebGPUDevice {
|
|
119
|
+
adapter;
|
|
120
|
+
device;
|
|
121
|
+
canvasContext;
|
|
122
|
+
presentationFormat;
|
|
123
|
+
kind = "webgpu";
|
|
124
|
+
info;
|
|
125
|
+
disposed = false;
|
|
126
|
+
contextLost = false;
|
|
127
|
+
nextId = 1;
|
|
128
|
+
frameActive = false;
|
|
129
|
+
drawCalls = 0;
|
|
130
|
+
viewportWidth = 0;
|
|
131
|
+
viewportHeight = 0;
|
|
132
|
+
clearColor = [0, 0, 0, 1];
|
|
133
|
+
lastError = null;
|
|
134
|
+
nativeSubmissions = 0;
|
|
135
|
+
nativeTextureBindings = 0;
|
|
136
|
+
nativeGeneratedBasicSubmissions = 0;
|
|
137
|
+
nativeGeneratedTextureSubmissions = 0;
|
|
138
|
+
nativePassthroughSubmissions = 0;
|
|
139
|
+
nativePbrSubmissions = 0;
|
|
140
|
+
nativeInstancedSubmissions = 0;
|
|
141
|
+
nativeSkinnedSubmissions = 0;
|
|
142
|
+
nativeMorphSubmissions = 0;
|
|
143
|
+
nativeEnvironmentBindings = 0;
|
|
144
|
+
nativeShadowMapBindings = 0;
|
|
145
|
+
canvasSubmissions = 0;
|
|
146
|
+
buffers = new Set();
|
|
147
|
+
shaders = new Set();
|
|
148
|
+
renderTargets = new Set();
|
|
149
|
+
nativeSampledTextures = new Map();
|
|
150
|
+
activeRenderTarget = null;
|
|
151
|
+
backbufferPixels = null;
|
|
152
|
+
backbufferWidth = 0;
|
|
153
|
+
backbufferHeight = 0;
|
|
154
|
+
canvasDepthTexture = null;
|
|
155
|
+
canvasDepthView = null;
|
|
156
|
+
canvasDepthWidth = 0;
|
|
157
|
+
canvasDepthHeight = 0;
|
|
158
|
+
static async create(options = {}) {
|
|
159
|
+
const gpu = options.gpu ?? readWebGPU(globalThis);
|
|
160
|
+
const adapter = options.adapter ?? (await requestAdapter(gpu));
|
|
161
|
+
if (!adapter) {
|
|
162
|
+
throw new RenderDeviceError("WebGPU adapter request did not return a device owner", "WEBGPU_ADAPTER_MISSING");
|
|
163
|
+
}
|
|
164
|
+
const device = validateWebGPUDevice(await requestDevice(adapter, options.device));
|
|
165
|
+
const canvasContext = options.canvas ? acquireWebGPUCanvasContext(options.canvas) : null;
|
|
166
|
+
const presentationFormat = options.presentationFormat ?? gpu?.getPreferredCanvasFormat?.() ?? "bgra8unorm";
|
|
167
|
+
if (canvasContext) {
|
|
168
|
+
canvasContext.configure({
|
|
169
|
+
device,
|
|
170
|
+
format: presentationFormat,
|
|
171
|
+
alphaMode: "opaque"
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
return new WebGPUDevice(adapter, device, canvasContext, presentationFormat);
|
|
175
|
+
}
|
|
176
|
+
constructor(adapter, device, canvasContext, presentationFormat) {
|
|
177
|
+
this.adapter = adapter;
|
|
178
|
+
this.device = device;
|
|
179
|
+
this.canvasContext = canvasContext;
|
|
180
|
+
this.presentationFormat = presentationFormat;
|
|
181
|
+
const supportsNativeRenderPipeline = hasNativeRenderPipeline(device);
|
|
182
|
+
const supportsNativeTextureReadback = hasNativeTextureReadback(device);
|
|
183
|
+
const supportsCanvasSurface = supportsNativeRenderPipeline && canvasContext !== null;
|
|
184
|
+
this.info = {
|
|
185
|
+
backend: "webgpu",
|
|
186
|
+
vendor: adapter.info?.vendor ?? "webgpu",
|
|
187
|
+
renderer: describeAdapter(adapter) ?? "webgpu-render-device",
|
|
188
|
+
capabilities: [
|
|
189
|
+
"buffers",
|
|
190
|
+
"buffer-readback",
|
|
191
|
+
"shader-validation",
|
|
192
|
+
"render-targets",
|
|
193
|
+
"pixel-readback",
|
|
194
|
+
"postprocess-presentation",
|
|
195
|
+
"hdr-render-targets",
|
|
196
|
+
"float-readback",
|
|
197
|
+
"draw-validation",
|
|
198
|
+
"rasterization",
|
|
199
|
+
"depth-render-targets",
|
|
200
|
+
"spot-shadow-maps",
|
|
201
|
+
"point-shadow-maps",
|
|
202
|
+
"hdr-image-based-lighting",
|
|
203
|
+
...(supportsNativeRenderPipeline ? ["native-render-pipeline"] : []),
|
|
204
|
+
...(hasNativeSampledTextureBinding(device) ? ["native-sampled-textures"] : []),
|
|
205
|
+
...(supportsNativeTextureReadback ? ["native-texture-readback"] : []),
|
|
206
|
+
...(supportsCanvasSurface ? ["canvas-surface"] : [])
|
|
207
|
+
],
|
|
208
|
+
limitations: [
|
|
209
|
+
"Synchronous readPixels remains CPU-shadowed for deterministic tests; use readPixelsAsync for native WebGPU texture-to-buffer readback when available.",
|
|
210
|
+
"Renderer.render() stays synchronous and uses CPU-shadowed readback for deterministic compatibility; use Renderer.renderAsync() when renderer-owned WebGPU postprocess must read native render targets.",
|
|
211
|
+
"Sampleable WebGPU depth render-target textures are not advertised until native texture binding and depth readback evidence exists.",
|
|
212
|
+
...(supportsNativeRenderPipeline ? [] : ["native WebGPU render-pipeline submission requires createRenderPipeline, createTexture, and createCommandEncoder."]),
|
|
213
|
+
...(hasNativeSampledTextureBinding(device) ? [] : ["native WebGPU sampled texture binding requires createSampler, createTexture, and queue.writeTexture."]),
|
|
214
|
+
...(supportsNativeTextureReadback ? [] : ["native WebGPU texture readback requires copyTextureToBuffer plus mappable readback buffers."]),
|
|
215
|
+
...(canvasContext ? [] : ["Canvas presentation requires a canvas that exposes a webgpu context."])
|
|
216
|
+
]
|
|
217
|
+
};
|
|
218
|
+
this.observeDeviceLost();
|
|
219
|
+
}
|
|
220
|
+
createBuffer(usage, byteLength, initialData) {
|
|
221
|
+
this.assertAlive();
|
|
222
|
+
if (byteLength <= 0 || !Number.isInteger(byteLength)) {
|
|
223
|
+
throw new RenderDeviceError("Buffer byteLength must be a positive integer", "INVALID_BUFFER_SIZE", { byteLength });
|
|
224
|
+
}
|
|
225
|
+
if (initialData && initialData.byteLength > byteLength) {
|
|
226
|
+
throw new RenderDeviceError("Initial data exceeds buffer size", "BUFFER_OVERFLOW", {
|
|
227
|
+
byteLength,
|
|
228
|
+
dataByteLength: initialData.byteLength
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
const handle = this.device.createBuffer({
|
|
232
|
+
label: `aura3d-${usage}-${this.nextId}`,
|
|
233
|
+
size: alignTo(byteLength, 4),
|
|
234
|
+
usage: bufferUsageFlags(usage)
|
|
235
|
+
});
|
|
236
|
+
const buffer = new WebGPURenderBuffer(this.nextId++, usage, byteLength, alignTo(byteLength, 4), handle, initialData);
|
|
237
|
+
this.buffers.add(buffer);
|
|
238
|
+
if (initialData)
|
|
239
|
+
writeAlignedQueueBuffer(this.device.queue, handle, 0, initialData, buffer.nativeByteLength);
|
|
240
|
+
return buffer;
|
|
241
|
+
}
|
|
242
|
+
updateBuffer(buffer, byteOffset, data) {
|
|
243
|
+
this.assertAlive();
|
|
244
|
+
const webgpuBuffer = this.requireBuffer(buffer);
|
|
245
|
+
if (byteOffset < 0 || byteOffset + data.byteLength > webgpuBuffer.byteLength) {
|
|
246
|
+
throw new RenderDeviceError("Buffer update range is out of bounds", "BUFFER_RANGE_OUT_OF_BOUNDS", {
|
|
247
|
+
byteOffset,
|
|
248
|
+
dataByteLength: data.byteLength,
|
|
249
|
+
byteLength: webgpuBuffer.byteLength
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
webgpuBuffer.bytes.set(viewBytes(data), byteOffset);
|
|
253
|
+
writeAlignedQueueBuffer(this.device.queue, webgpuBuffer.handle, byteOffset, webgpuBuffer.bytes.subarray(byteOffset, byteOffset + data.byteLength), webgpuBuffer.nativeByteLength);
|
|
254
|
+
}
|
|
255
|
+
readBuffer(buffer, byteOffset = 0, byteLength = buffer.byteLength - byteOffset) {
|
|
256
|
+
this.assertAlive();
|
|
257
|
+
const webgpuBuffer = this.requireBuffer(buffer);
|
|
258
|
+
if (byteOffset < 0 || byteLength < 0 || byteOffset + byteLength > webgpuBuffer.byteLength) {
|
|
259
|
+
throw new RenderDeviceError("Buffer read range is out of bounds", "BUFFER_RANGE_OUT_OF_BOUNDS", {
|
|
260
|
+
byteOffset,
|
|
261
|
+
byteLength,
|
|
262
|
+
bufferByteLength: webgpuBuffer.byteLength
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
return webgpuBuffer.bytes.slice(byteOffset, byteOffset + byteLength);
|
|
266
|
+
}
|
|
267
|
+
createShaderProgram(sources) {
|
|
268
|
+
this.assertAlive();
|
|
269
|
+
if (!sources.vertex.includes(sources.marker) || !sources.fragment.includes(sources.marker)) {
|
|
270
|
+
throw new RenderDeviceError("Shader source marker is missing from compiled sources", "SHADER_MARKER_MISSING", {
|
|
271
|
+
label: sources.label,
|
|
272
|
+
marker: sources.marker
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
const nativeSources = createNativeShaderSources(sources);
|
|
276
|
+
const modules = this.device.createShaderModule
|
|
277
|
+
? [
|
|
278
|
+
this.device.createShaderModule({ label: `${sources.label}-vertex`, code: nativeSources.vertex }),
|
|
279
|
+
this.device.createShaderModule({ label: `${sources.label}-fragment`, code: nativeSources.fragment })
|
|
280
|
+
]
|
|
281
|
+
: [];
|
|
282
|
+
const shader = new WebGPUShaderProgram(this.nextId++, sources.label, sources.marker, reflectShaderSources(sources), modules, nativeSources.entryPoints, nativeSources.uniformLayout);
|
|
283
|
+
this.shaders.add(shader);
|
|
284
|
+
return shader;
|
|
285
|
+
}
|
|
286
|
+
createRenderTarget(descriptor) {
|
|
287
|
+
this.assertAlive();
|
|
288
|
+
if (!Number.isInteger(descriptor.width) ||
|
|
289
|
+
descriptor.width <= 0 ||
|
|
290
|
+
!Number.isInteger(descriptor.height) ||
|
|
291
|
+
descriptor.height <= 0) {
|
|
292
|
+
throw new RenderDeviceError("Render target dimensions must be positive integers", "INVALID_RENDER_TARGET_SIZE", {
|
|
293
|
+
width: descriptor.width,
|
|
294
|
+
height: descriptor.height,
|
|
295
|
+
label: descriptor.label
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
const nativeTexture = this.device.createTexture?.({
|
|
299
|
+
label: descriptor.label ?? "aura3d-webgpu-render-target",
|
|
300
|
+
size: [descriptor.width, descriptor.height],
|
|
301
|
+
format: webgpuTextureFormat(descriptor.format ?? "rgba8"),
|
|
302
|
+
usage: TEXTURE_USAGE.RENDER_ATTACHMENT | TEXTURE_USAGE.COPY_SRC | TEXTURE_USAGE.COPY_DST | TEXTURE_USAGE.TEXTURE_BINDING
|
|
303
|
+
}) ?? null;
|
|
304
|
+
const hasDepth = descriptor.depth !== false;
|
|
305
|
+
const hasSampleableDepth = descriptor.depth === "texture";
|
|
306
|
+
const nativeDepthTexture = hasDepth
|
|
307
|
+
? this.device.createTexture?.({
|
|
308
|
+
label: `${descriptor.label ?? "aura3d-webgpu-render-target"}-depth`,
|
|
309
|
+
size: [descriptor.width, descriptor.height],
|
|
310
|
+
format: DEPTH_TEXTURE_FORMAT,
|
|
311
|
+
usage: TEXTURE_USAGE.RENDER_ATTACHMENT | (hasSampleableDepth ? TEXTURE_USAGE.TEXTURE_BINDING : 0)
|
|
312
|
+
}) ?? null
|
|
313
|
+
: null;
|
|
314
|
+
const depthTexture = hasSampleableDepth
|
|
315
|
+
? new Texture({ width: descriptor.width, height: descriptor.height, format: "depth24", label: `${descriptor.label ?? "render-target"}-depth` })
|
|
316
|
+
: undefined;
|
|
317
|
+
const target = new WebGPURenderTarget(this.nextId++, descriptor.width, descriptor.height, descriptor.label ?? "render-target", new Texture({ width: descriptor.width, height: descriptor.height, format: descriptor.format ?? "rgba8", label: descriptor.label ?? "render-target-color" }), depthTexture, nativeTexture, nativeTexture?.createView() ?? null, nativeDepthTexture, nativeDepthTexture?.createView() ?? null, hasDepth);
|
|
318
|
+
this.renderTargets.add(target);
|
|
319
|
+
return target;
|
|
320
|
+
}
|
|
321
|
+
setRenderTarget(target) {
|
|
322
|
+
this.assertAlive();
|
|
323
|
+
if (target === null) {
|
|
324
|
+
this.activeRenderTarget = null;
|
|
325
|
+
return;
|
|
326
|
+
}
|
|
327
|
+
if (!(target instanceof WebGPURenderTarget) || !this.renderTargets.has(target) || target.disposed) {
|
|
328
|
+
throw new RenderDeviceError("Render target is not a live WebGPU resource owned by this device", "INVALID_RESOURCE", {
|
|
329
|
+
targetId: target.id
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
this.activeRenderTarget = target;
|
|
333
|
+
}
|
|
334
|
+
writeRenderTargetPixels(target, pixels) {
|
|
335
|
+
this.assertAlive();
|
|
336
|
+
const webgpuTarget = this.requireRenderTarget(target);
|
|
337
|
+
const expectedLength = webgpuTarget.width * webgpuTarget.height * 4;
|
|
338
|
+
if (pixels.length !== expectedLength) {
|
|
339
|
+
throw new RenderDeviceError("Render target pixel upload length does not match target dimensions", "INVALID_RENDER_TARGET_PIXELS", {
|
|
340
|
+
targetId: target.id,
|
|
341
|
+
expectedLength,
|
|
342
|
+
actualLength: pixels.length
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
webgpuTarget.colorPixels.set(pixels);
|
|
346
|
+
if (webgpuTarget.colorFloatPixels) {
|
|
347
|
+
for (let index = 0; index < pixels.length; index += 1) {
|
|
348
|
+
webgpuTarget.colorFloatPixels[index] = pixels[index] / 255;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
if (webgpuTarget.nativeTexture && webgpuTarget.colorTexture.format === "rgba8" && hasNativeTextureUpload(this.device)) {
|
|
352
|
+
this.device.queue.writeTexture({ texture: webgpuTarget.nativeTexture }, pixels, { bytesPerRow: webgpuTarget.width * 4, rowsPerImage: webgpuTarget.height }, { width: webgpuTarget.width, height: webgpuTarget.height, depthOrArrayLayers: 1 });
|
|
353
|
+
webgpuTarget.nativeNeedsClear = false;
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
presentRenderTarget(source) {
|
|
357
|
+
this.assertAlive();
|
|
358
|
+
const target = this.requireRenderTarget(source);
|
|
359
|
+
if (target.colorTexture.format !== "rgba8") {
|
|
360
|
+
throw new RenderDeviceError("WebGPU backbuffer presentation currently requires rgba8 source pixels", "PRESENT_FORMAT_UNSUPPORTED", {
|
|
361
|
+
source: source.label,
|
|
362
|
+
format: target.colorTexture.format
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
this.backbufferPixels = target.colorPixels.slice();
|
|
366
|
+
this.backbufferWidth = target.width;
|
|
367
|
+
this.backbufferHeight = target.height;
|
|
368
|
+
this.activeRenderTarget = null;
|
|
369
|
+
this.canvasSubmissions += 1;
|
|
370
|
+
}
|
|
371
|
+
readPixels(x, y, width, height) {
|
|
372
|
+
this.assertAlive();
|
|
373
|
+
if (![x, y, width, height].every(Number.isInteger) || x < 0 || y < 0 || width <= 0 || height <= 0) {
|
|
374
|
+
throw new RenderDeviceError("Readback rectangle must be positive and in bounds", "INVALID_READBACK_RECT", { x, y, width, height });
|
|
375
|
+
}
|
|
376
|
+
const boundsWidth = this.activeRenderTarget?.width ?? (this.backbufferPixels ? this.backbufferWidth : this.viewportWidth);
|
|
377
|
+
const boundsHeight = this.activeRenderTarget?.height ?? (this.backbufferPixels ? this.backbufferHeight : this.viewportHeight);
|
|
378
|
+
if (x + width > boundsWidth || y + height > boundsHeight) {
|
|
379
|
+
throw new RenderDeviceError("Readback rectangle exceeds framebuffer bounds", "READBACK_OUT_OF_BOUNDS", {
|
|
380
|
+
x,
|
|
381
|
+
y,
|
|
382
|
+
width,
|
|
383
|
+
height,
|
|
384
|
+
boundsWidth,
|
|
385
|
+
boundsHeight
|
|
386
|
+
});
|
|
387
|
+
}
|
|
388
|
+
const output = new Uint8Array(width * height * 4);
|
|
389
|
+
const target = this.activeRenderTarget;
|
|
390
|
+
if (!target) {
|
|
391
|
+
if (this.backbufferPixels) {
|
|
392
|
+
for (let row = 0; row < height; row += 1) {
|
|
393
|
+
const sourceOffset = ((y + row) * this.backbufferWidth + x) * 4;
|
|
394
|
+
const destOffset = row * width * 4;
|
|
395
|
+
output.set(this.backbufferPixels.subarray(sourceOffset, sourceOffset + width * 4), destOffset);
|
|
396
|
+
}
|
|
397
|
+
return output;
|
|
398
|
+
}
|
|
399
|
+
const bytes = rgbaBytes(this.clearColor);
|
|
400
|
+
for (let index = 0; index < output.length; index += 4)
|
|
401
|
+
output.set(bytes, index);
|
|
402
|
+
return output;
|
|
403
|
+
}
|
|
404
|
+
for (let row = 0; row < height; row += 1) {
|
|
405
|
+
const sourceOffset = ((y + row) * target.width + x) * 4;
|
|
406
|
+
const destOffset = row * width * 4;
|
|
407
|
+
output.set(target.colorPixels.subarray(sourceOffset, sourceOffset + width * 4), destOffset);
|
|
408
|
+
}
|
|
409
|
+
return output;
|
|
410
|
+
}
|
|
411
|
+
async readPixelsAsync(x, y, width, height) {
|
|
412
|
+
this.assertAlive();
|
|
413
|
+
if (![x, y, width, height].every(Number.isInteger) || x < 0 || y < 0 || width <= 0 || height <= 0) {
|
|
414
|
+
throw new RenderDeviceError("Readback rectangle must be positive and in bounds", "INVALID_READBACK_RECT", { x, y, width, height });
|
|
415
|
+
}
|
|
416
|
+
const target = this.activeRenderTarget;
|
|
417
|
+
if (!target || !target.nativeTexture) {
|
|
418
|
+
throw new RenderDeviceError("Native WebGPU readback requires an active native render target", "NATIVE_READBACK_TARGET_MISSING", {
|
|
419
|
+
x,
|
|
420
|
+
y,
|
|
421
|
+
width,
|
|
422
|
+
height,
|
|
423
|
+
renderTarget: target?.label ?? null
|
|
424
|
+
});
|
|
425
|
+
}
|
|
426
|
+
if (target.colorTexture.format !== "rgba8") {
|
|
427
|
+
throw new RenderDeviceError("Native WebGPU readback currently supports rgba8 render targets", "NATIVE_READBACK_FORMAT_UNSUPPORTED", {
|
|
428
|
+
format: target.colorTexture.format,
|
|
429
|
+
renderTarget: target.label
|
|
430
|
+
});
|
|
431
|
+
}
|
|
432
|
+
if (x + width > target.width || y + height > target.height) {
|
|
433
|
+
throw new RenderDeviceError("Readback rectangle exceeds framebuffer bounds", "READBACK_OUT_OF_BOUNDS", {
|
|
434
|
+
x,
|
|
435
|
+
y,
|
|
436
|
+
width,
|
|
437
|
+
height,
|
|
438
|
+
boundsWidth: target.width,
|
|
439
|
+
boundsHeight: target.height
|
|
440
|
+
});
|
|
441
|
+
}
|
|
442
|
+
if (!hasNativeTextureReadback(this.device)) {
|
|
443
|
+
throw new RenderDeviceError("WebGPU device does not expose native texture-to-buffer readback", "NATIVE_READBACK_UNSUPPORTED");
|
|
444
|
+
}
|
|
445
|
+
this.flushNativeRenderTargetClear(target);
|
|
446
|
+
const bytesPerPixel = 4;
|
|
447
|
+
const unpaddedBytesPerRow = width * bytesPerPixel;
|
|
448
|
+
const bytesPerRow = alignTo(unpaddedBytesPerRow, 256);
|
|
449
|
+
const bufferSize = bytesPerRow * height;
|
|
450
|
+
const readback = this.device.createBuffer({
|
|
451
|
+
label: `${target.label}-native-readback`,
|
|
452
|
+
size: bufferSize,
|
|
453
|
+
usage: BUFFER_USAGE.MAP_READ | BUFFER_USAGE.COPY_DST
|
|
454
|
+
});
|
|
455
|
+
const encoder = this.device.createCommandEncoder({ label: `${target.label}-native-readback-encoder` });
|
|
456
|
+
const copyTextureToBuffer = encoder.copyTextureToBuffer;
|
|
457
|
+
if (!copyTextureToBuffer) {
|
|
458
|
+
readback.destroy();
|
|
459
|
+
throw new RenderDeviceError("WebGPU command encoder does not expose texture-to-buffer copy", "NATIVE_READBACK_UNSUPPORTED");
|
|
460
|
+
}
|
|
461
|
+
copyTextureToBuffer.call(encoder, { texture: target.nativeTexture, origin: { x, y, z: 0 } }, { buffer: readback, bytesPerRow, rowsPerImage: height }, { width, height, depthOrArrayLayers: 1 });
|
|
462
|
+
this.device.queue.submit([encoder.finish()]);
|
|
463
|
+
try {
|
|
464
|
+
const mapAsync = readback.mapAsync;
|
|
465
|
+
const getMappedRange = readback.getMappedRange;
|
|
466
|
+
const unmap = readback.unmap;
|
|
467
|
+
if (!mapAsync || !getMappedRange || !unmap) {
|
|
468
|
+
throw new RenderDeviceError("WebGPU readback buffer does not expose mapped readback APIs", "NATIVE_READBACK_UNSUPPORTED");
|
|
469
|
+
}
|
|
470
|
+
await mapAsync.call(readback, MAP_MODE.READ);
|
|
471
|
+
const mapped = new Uint8Array(getMappedRange.call(readback));
|
|
472
|
+
const output = new Uint8Array(width * height * bytesPerPixel);
|
|
473
|
+
for (let row = 0; row < height; row += 1) {
|
|
474
|
+
const sourceOffset = row * bytesPerRow;
|
|
475
|
+
const destOffset = (height - 1 - row) * unpaddedBytesPerRow;
|
|
476
|
+
output.set(mapped.subarray(sourceOffset, sourceOffset + unpaddedBytesPerRow), destOffset);
|
|
477
|
+
}
|
|
478
|
+
unmap.call(readback);
|
|
479
|
+
return output;
|
|
480
|
+
}
|
|
481
|
+
finally {
|
|
482
|
+
readback.destroy();
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
async readFloatPixelsAsync(x, y, width, height) {
|
|
486
|
+
this.assertAlive();
|
|
487
|
+
if (![x, y, width, height].every(Number.isInteger) || x < 0 || y < 0 || width <= 0 || height <= 0) {
|
|
488
|
+
throw new RenderDeviceError("Float readback rectangle must be positive and in bounds", "INVALID_READBACK_RECT", { x, y, width, height });
|
|
489
|
+
}
|
|
490
|
+
const target = this.activeRenderTarget;
|
|
491
|
+
if (!target || !target.nativeTexture) {
|
|
492
|
+
throw new RenderDeviceError("Native WebGPU float readback requires an active native render target", "NATIVE_READBACK_TARGET_MISSING", {
|
|
493
|
+
x,
|
|
494
|
+
y,
|
|
495
|
+
width,
|
|
496
|
+
height,
|
|
497
|
+
renderTarget: target?.label ?? null
|
|
498
|
+
});
|
|
499
|
+
}
|
|
500
|
+
if (x + width > target.width || y + height > target.height) {
|
|
501
|
+
throw new RenderDeviceError("Float readback rectangle exceeds framebuffer bounds", "READBACK_OUT_OF_BOUNDS", {
|
|
502
|
+
x,
|
|
503
|
+
y,
|
|
504
|
+
width,
|
|
505
|
+
height,
|
|
506
|
+
boundsWidth: target.width,
|
|
507
|
+
boundsHeight: target.height
|
|
508
|
+
});
|
|
509
|
+
}
|
|
510
|
+
if (!hasNativeTextureReadback(this.device)) {
|
|
511
|
+
throw new RenderDeviceError("WebGPU device does not expose native texture-to-buffer readback", "NATIVE_READBACK_UNSUPPORTED");
|
|
512
|
+
}
|
|
513
|
+
this.flushNativeRenderTargetClear(target);
|
|
514
|
+
const format = target.colorTexture.format;
|
|
515
|
+
const bytesPerPixel = format === "rgba32f" ? 16 : format === "rgba16f" ? 8 : 4;
|
|
516
|
+
const unpaddedBytesPerRow = width * bytesPerPixel;
|
|
517
|
+
const bytesPerRow = alignTo(unpaddedBytesPerRow, 256);
|
|
518
|
+
const bufferSize = bytesPerRow * height;
|
|
519
|
+
const readback = this.device.createBuffer({
|
|
520
|
+
label: `${target.label}-native-float-readback`,
|
|
521
|
+
size: bufferSize,
|
|
522
|
+
usage: BUFFER_USAGE.MAP_READ | BUFFER_USAGE.COPY_DST
|
|
523
|
+
});
|
|
524
|
+
const encoder = this.device.createCommandEncoder({ label: `${target.label}-native-float-readback-encoder` });
|
|
525
|
+
const copyTextureToBuffer = encoder.copyTextureToBuffer;
|
|
526
|
+
if (!copyTextureToBuffer) {
|
|
527
|
+
readback.destroy();
|
|
528
|
+
throw new RenderDeviceError("WebGPU command encoder does not expose texture-to-buffer copy", "NATIVE_READBACK_UNSUPPORTED");
|
|
529
|
+
}
|
|
530
|
+
copyTextureToBuffer.call(encoder, { texture: target.nativeTexture, origin: { x, y, z: 0 } }, { buffer: readback, bytesPerRow, rowsPerImage: height }, { width, height, depthOrArrayLayers: 1 });
|
|
531
|
+
this.device.queue.submit([encoder.finish()]);
|
|
532
|
+
try {
|
|
533
|
+
const mapAsync = readback.mapAsync;
|
|
534
|
+
const getMappedRange = readback.getMappedRange;
|
|
535
|
+
const unmap = readback.unmap;
|
|
536
|
+
if (!mapAsync || !getMappedRange || !unmap) {
|
|
537
|
+
throw new RenderDeviceError("WebGPU readback buffer does not expose mapped readback APIs", "NATIVE_READBACK_UNSUPPORTED");
|
|
538
|
+
}
|
|
539
|
+
await mapAsync.call(readback, MAP_MODE.READ);
|
|
540
|
+
const mapped = new Uint8Array(getMappedRange.call(readback));
|
|
541
|
+
const view = new DataView(mapped.buffer, mapped.byteOffset, mapped.byteLength);
|
|
542
|
+
const output = new Float32Array(width * height * 4);
|
|
543
|
+
for (let row = 0; row < height; row += 1) {
|
|
544
|
+
const destRow = height - 1 - row;
|
|
545
|
+
for (let column = 0; column < width; column += 1) {
|
|
546
|
+
const sourceOffset = row * bytesPerRow + column * bytesPerPixel;
|
|
547
|
+
const destOffset = (destRow * width + column) * 4;
|
|
548
|
+
if (format === "rgba32f") {
|
|
549
|
+
output[destOffset] = view.getFloat32(sourceOffset, true);
|
|
550
|
+
output[destOffset + 1] = view.getFloat32(sourceOffset + 4, true);
|
|
551
|
+
output[destOffset + 2] = view.getFloat32(sourceOffset + 8, true);
|
|
552
|
+
output[destOffset + 3] = view.getFloat32(sourceOffset + 12, true);
|
|
553
|
+
}
|
|
554
|
+
else if (format === "rgba16f") {
|
|
555
|
+
output[destOffset] = halfFloatToNumber(view.getUint16(sourceOffset, true));
|
|
556
|
+
output[destOffset + 1] = halfFloatToNumber(view.getUint16(sourceOffset + 2, true));
|
|
557
|
+
output[destOffset + 2] = halfFloatToNumber(view.getUint16(sourceOffset + 4, true));
|
|
558
|
+
output[destOffset + 3] = halfFloatToNumber(view.getUint16(sourceOffset + 6, true));
|
|
559
|
+
}
|
|
560
|
+
else {
|
|
561
|
+
output[destOffset] = (mapped[sourceOffset] ?? 0) / 255;
|
|
562
|
+
output[destOffset + 1] = (mapped[sourceOffset + 1] ?? 0) / 255;
|
|
563
|
+
output[destOffset + 2] = (mapped[sourceOffset + 2] ?? 0) / 255;
|
|
564
|
+
output[destOffset + 3] = (mapped[sourceOffset + 3] ?? 0) / 255;
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
unmap.call(readback);
|
|
569
|
+
return output;
|
|
570
|
+
}
|
|
571
|
+
finally {
|
|
572
|
+
readback.destroy();
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
readFloatPixels(x, y, width, height) {
|
|
576
|
+
this.assertAlive();
|
|
577
|
+
if (![x, y, width, height].every(Number.isInteger) || x < 0 || y < 0 || width <= 0 || height <= 0) {
|
|
578
|
+
throw new RenderDeviceError("Float readback rectangle must be positive and in bounds", "INVALID_READBACK_RECT", { x, y, width, height });
|
|
579
|
+
}
|
|
580
|
+
const boundsWidth = this.activeRenderTarget?.width ?? (this.backbufferPixels ? this.backbufferWidth : this.viewportWidth);
|
|
581
|
+
const boundsHeight = this.activeRenderTarget?.height ?? (this.backbufferPixels ? this.backbufferHeight : this.viewportHeight);
|
|
582
|
+
if (x + width > boundsWidth || y + height > boundsHeight) {
|
|
583
|
+
throw new RenderDeviceError("Float readback rectangle exceeds framebuffer bounds", "READBACK_OUT_OF_BOUNDS", {
|
|
584
|
+
x,
|
|
585
|
+
y,
|
|
586
|
+
width,
|
|
587
|
+
height,
|
|
588
|
+
boundsWidth,
|
|
589
|
+
boundsHeight
|
|
590
|
+
});
|
|
591
|
+
}
|
|
592
|
+
const output = new Float32Array(width * height * 4);
|
|
593
|
+
const target = this.activeRenderTarget;
|
|
594
|
+
if (!target) {
|
|
595
|
+
if (this.backbufferPixels) {
|
|
596
|
+
const bytes = this.readPixels(x, y, width, height);
|
|
597
|
+
for (let index = 0; index < bytes.length; index += 1)
|
|
598
|
+
output[index] = bytes[index] / 255;
|
|
599
|
+
return output;
|
|
600
|
+
}
|
|
601
|
+
for (let index = 0; index < output.length; index += 4) {
|
|
602
|
+
output[index] = this.clearColor[0];
|
|
603
|
+
output[index + 1] = this.clearColor[1];
|
|
604
|
+
output[index + 2] = this.clearColor[2];
|
|
605
|
+
output[index + 3] = this.clearColor[3];
|
|
606
|
+
}
|
|
607
|
+
return output;
|
|
608
|
+
}
|
|
609
|
+
if (target.colorFloatPixels) {
|
|
610
|
+
for (let row = 0; row < height; row += 1) {
|
|
611
|
+
const sourceOffset = ((y + row) * target.width + x) * 4;
|
|
612
|
+
const destOffset = row * width * 4;
|
|
613
|
+
output.set(target.colorFloatPixels.subarray(sourceOffset, sourceOffset + width * 4), destOffset);
|
|
614
|
+
}
|
|
615
|
+
return output;
|
|
616
|
+
}
|
|
617
|
+
const bytes = this.readPixels(x, y, width, height);
|
|
618
|
+
for (let index = 0; index < bytes.length; index += 1)
|
|
619
|
+
output[index] = bytes[index] / 255;
|
|
620
|
+
return output;
|
|
621
|
+
}
|
|
622
|
+
beginFrame(width, height) {
|
|
623
|
+
this.assertAlive();
|
|
624
|
+
if (this.frameActive) {
|
|
625
|
+
throw new RenderDeviceError("Frame is already active", "FRAME_ALREADY_ACTIVE");
|
|
626
|
+
}
|
|
627
|
+
if (width <= 0 || height <= 0) {
|
|
628
|
+
throw new RenderDeviceError("Frame dimensions must be positive", "INVALID_FRAME_SIZE", { width, height });
|
|
629
|
+
}
|
|
630
|
+
this.frameActive = true;
|
|
631
|
+
this.drawCalls = 0;
|
|
632
|
+
this.lastError = null;
|
|
633
|
+
this.viewportWidth = width;
|
|
634
|
+
this.viewportHeight = height;
|
|
635
|
+
this.ensureCanvasDepthAttachment(width, height);
|
|
636
|
+
}
|
|
637
|
+
clear(color) {
|
|
638
|
+
this.assertFrame();
|
|
639
|
+
this.clearColor = color;
|
|
640
|
+
if (this.activeRenderTarget) {
|
|
641
|
+
this.clearActiveRenderTarget(color);
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
clearRenderTarget(color) {
|
|
645
|
+
this.assertFrame();
|
|
646
|
+
if (!this.activeRenderTarget) {
|
|
647
|
+
this.clearColor = color;
|
|
648
|
+
return;
|
|
649
|
+
}
|
|
650
|
+
this.clearActiveRenderTarget(color);
|
|
651
|
+
}
|
|
652
|
+
draw(command) {
|
|
653
|
+
this.assertFrame();
|
|
654
|
+
const vertexBuffer = this.requireBuffer(command.vertexBuffer);
|
|
655
|
+
if (vertexBuffer.disposed) {
|
|
656
|
+
throw new RenderDeviceError("Cannot draw with a disposed vertex buffer", "DISPOSED_RESOURCE", {
|
|
657
|
+
bufferId: command.vertexBuffer.id
|
|
658
|
+
});
|
|
659
|
+
}
|
|
660
|
+
if (command.indexBuffer) {
|
|
661
|
+
const indexBuffer = this.requireBuffer(command.indexBuffer);
|
|
662
|
+
if (indexBuffer.disposed) {
|
|
663
|
+
throw new RenderDeviceError("Cannot draw with a disposed index buffer", "DISPOSED_RESOURCE", {
|
|
664
|
+
bufferId: command.indexBuffer.id
|
|
665
|
+
});
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
if (command.shader)
|
|
669
|
+
this.requireShader(command.shader);
|
|
670
|
+
if (command.vertexCount <= 0) {
|
|
671
|
+
throw new RenderDeviceError("Draw command must have a positive vertex count", "INVALID_DRAW_COMMAND", {
|
|
672
|
+
vertexCount: command.vertexCount,
|
|
673
|
+
label: command.label
|
|
674
|
+
});
|
|
675
|
+
}
|
|
676
|
+
if (command.firstVertex !== undefined && (!Number.isInteger(command.firstVertex) || command.firstVertex < 0)) {
|
|
677
|
+
throw new RenderDeviceError("Draw command firstVertex must be a non-negative integer", "INVALID_DRAW_COMMAND", {
|
|
678
|
+
firstVertex: command.firstVertex,
|
|
679
|
+
label: command.label
|
|
680
|
+
});
|
|
681
|
+
}
|
|
682
|
+
if (command.indexBuffer && (command.indexCount === undefined || command.indexCount <= 0)) {
|
|
683
|
+
throw new RenderDeviceError("Indexed draw command must have a positive index count", "INVALID_DRAW_COMMAND", {
|
|
684
|
+
indexCount: command.indexCount,
|
|
685
|
+
label: command.label
|
|
686
|
+
});
|
|
687
|
+
}
|
|
688
|
+
if (command.firstIndex !== undefined && (!Number.isInteger(command.firstIndex) || command.firstIndex < 0)) {
|
|
689
|
+
throw new RenderDeviceError("Draw command firstIndex must be a non-negative integer", "INVALID_DRAW_COMMAND", {
|
|
690
|
+
firstIndex: command.firstIndex,
|
|
691
|
+
label: command.label
|
|
692
|
+
});
|
|
693
|
+
}
|
|
694
|
+
if (command.instanceCount !== undefined && (!Number.isInteger(command.instanceCount) || command.instanceCount <= 0)) {
|
|
695
|
+
throw new RenderDeviceError("Draw command instanceCount must be a positive integer", "INVALID_DRAW_COMMAND", {
|
|
696
|
+
instanceCount: command.instanceCount,
|
|
697
|
+
label: command.label
|
|
698
|
+
});
|
|
699
|
+
}
|
|
700
|
+
this.submitNativeRenderPass(command, vertexBuffer);
|
|
701
|
+
this.rasterizeDraw(command, vertexBuffer);
|
|
702
|
+
this.drawCalls += 1;
|
|
703
|
+
}
|
|
704
|
+
endFrame() {
|
|
705
|
+
this.assertFrame();
|
|
706
|
+
this.frameActive = false;
|
|
707
|
+
this.device.queue.submit([]);
|
|
708
|
+
}
|
|
709
|
+
captureState() {
|
|
710
|
+
return new Map([
|
|
711
|
+
["backend", this.kind],
|
|
712
|
+
["disposed", this.disposed],
|
|
713
|
+
["contextLost", this.contextLost],
|
|
714
|
+
["frameActive", this.frameActive],
|
|
715
|
+
["viewportWidth", this.viewportWidth],
|
|
716
|
+
["viewportHeight", this.viewportHeight],
|
|
717
|
+
["renderTarget", this.activeRenderTarget?.label ?? null],
|
|
718
|
+
["presentationFormat", this.presentationFormat],
|
|
719
|
+
["drawCalls", this.drawCalls],
|
|
720
|
+
["nativeSubmissions", this.nativeSubmissions],
|
|
721
|
+
["nativeTextureBindings", this.nativeTextureBindings],
|
|
722
|
+
["nativeGeneratedBasicSubmissions", this.nativeGeneratedBasicSubmissions],
|
|
723
|
+
["nativeGeneratedTextureSubmissions", this.nativeGeneratedTextureSubmissions],
|
|
724
|
+
["nativePassthroughSubmissions", this.nativePassthroughSubmissions],
|
|
725
|
+
["nativePbrSubmissions", this.nativePbrSubmissions],
|
|
726
|
+
["nativeInstancedSubmissions", this.nativeInstancedSubmissions],
|
|
727
|
+
["nativeSkinnedSubmissions", this.nativeSkinnedSubmissions],
|
|
728
|
+
["nativeMorphSubmissions", this.nativeMorphSubmissions],
|
|
729
|
+
["nativeEnvironmentBindings", this.nativeEnvironmentBindings],
|
|
730
|
+
["nativeShadowMapBindings", this.nativeShadowMapBindings],
|
|
731
|
+
["canvasSubmissions", this.canvasSubmissions]
|
|
732
|
+
]);
|
|
733
|
+
}
|
|
734
|
+
getDiagnostics() {
|
|
735
|
+
const liveRenderTargets = [...this.renderTargets].filter((target) => !target.disposed);
|
|
736
|
+
const bufferBytes = [...this.buffers].filter((buffer) => !buffer.disposed).reduce((total, buffer) => total + buffer.byteLength, 0);
|
|
737
|
+
const textureBytes = liveRenderTargets.reduce((total, target) => total + target.colorTexture.byteLength + (target.depthTexture?.byteLength ?? 0), 0);
|
|
738
|
+
return {
|
|
739
|
+
drawCalls: this.drawCalls,
|
|
740
|
+
buffers: [...this.buffers].filter((buffer) => !buffer.disposed).length,
|
|
741
|
+
shaders: [...this.shaders].filter((shader) => !shader.disposed).length,
|
|
742
|
+
renderTargets: liveRenderTargets.length,
|
|
743
|
+
textures: liveRenderTargets.length,
|
|
744
|
+
bufferBytes,
|
|
745
|
+
textureBytes,
|
|
746
|
+
approximateGpuMemoryBytes: bufferBytes + textureBytes,
|
|
747
|
+
compressedTextures: 0,
|
|
748
|
+
compressedTextureBytes: 0,
|
|
749
|
+
textureFallbacks: 0,
|
|
750
|
+
textureFallbackBytes: 0,
|
|
751
|
+
disposedBuffers: [...this.buffers].filter((buffer) => buffer.disposed).length,
|
|
752
|
+
disposedShaders: [...this.shaders].filter((shader) => shader.disposed).length,
|
|
753
|
+
disposedRenderTargets: [...this.renderTargets].filter((target) => target.disposed).length,
|
|
754
|
+
disposedTextures: [...this.renderTargets].reduce((total, target) => total + (target.colorTexture.disposed ? 1 : 0) + (target.depthTexture?.disposed ? 1 : 0), 0),
|
|
755
|
+
nativeSubmissions: this.nativeSubmissions,
|
|
756
|
+
nativeTextureBindings: this.nativeTextureBindings,
|
|
757
|
+
nativeGeneratedBasicSubmissions: this.nativeGeneratedBasicSubmissions,
|
|
758
|
+
nativeGeneratedTextureSubmissions: this.nativeGeneratedTextureSubmissions,
|
|
759
|
+
nativePassthroughSubmissions: this.nativePassthroughSubmissions,
|
|
760
|
+
nativePbrSubmissions: this.nativePbrSubmissions,
|
|
761
|
+
nativeInstancedSubmissions: this.nativeInstancedSubmissions,
|
|
762
|
+
nativeSkinnedSubmissions: this.nativeSkinnedSubmissions,
|
|
763
|
+
nativeMorphSubmissions: this.nativeMorphSubmissions,
|
|
764
|
+
nativeEnvironmentBindings: this.nativeEnvironmentBindings,
|
|
765
|
+
nativeShadowMapBindings: this.nativeShadowMapBindings,
|
|
766
|
+
lastError: this.lastError,
|
|
767
|
+
contextLost: this.contextLost
|
|
768
|
+
};
|
|
769
|
+
}
|
|
770
|
+
dispose() {
|
|
771
|
+
if (this.disposed)
|
|
772
|
+
return;
|
|
773
|
+
for (const buffer of this.buffers)
|
|
774
|
+
buffer.dispose();
|
|
775
|
+
for (const shader of this.shaders)
|
|
776
|
+
shader.dispose();
|
|
777
|
+
for (const target of this.renderTargets)
|
|
778
|
+
target.dispose();
|
|
779
|
+
for (const resource of this.nativeSampledTextures.values())
|
|
780
|
+
resource.texture.destroy();
|
|
781
|
+
this.nativeSampledTextures.clear();
|
|
782
|
+
this.canvasDepthTexture?.destroy();
|
|
783
|
+
this.canvasDepthTexture = null;
|
|
784
|
+
this.canvasDepthView = null;
|
|
785
|
+
this.canvasContext?.unconfigure?.();
|
|
786
|
+
this.device.destroy?.();
|
|
787
|
+
this.frameActive = false;
|
|
788
|
+
this.disposed = true;
|
|
789
|
+
}
|
|
790
|
+
assertAlive() {
|
|
791
|
+
if (this.disposed) {
|
|
792
|
+
throw new RenderDeviceError("Render device is disposed", "DISPOSED_DEVICE");
|
|
793
|
+
}
|
|
794
|
+
if (this.contextLost) {
|
|
795
|
+
throw new RenderDeviceError("Render context is lost", "CONTEXT_LOST");
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
assertFrame() {
|
|
799
|
+
this.assertAlive();
|
|
800
|
+
if (!this.frameActive) {
|
|
801
|
+
throw new RenderDeviceError("No active frame", "NO_ACTIVE_FRAME");
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
observeDeviceLost() {
|
|
805
|
+
const lost = this.device.lost;
|
|
806
|
+
if (!lost || typeof lost.then !== "function")
|
|
807
|
+
return;
|
|
808
|
+
void lost.then((info) => {
|
|
809
|
+
if (this.disposed)
|
|
810
|
+
return;
|
|
811
|
+
this.contextLost = true;
|
|
812
|
+
const detail = [info.reason, info.message].filter(Boolean).join(": ");
|
|
813
|
+
this.lastError = detail ? `WebGPU device lost: ${detail}` : "WebGPU device lost";
|
|
814
|
+
}).catch((error) => {
|
|
815
|
+
if (this.disposed)
|
|
816
|
+
return;
|
|
817
|
+
this.contextLost = true;
|
|
818
|
+
this.lastError = `WebGPU device lost promise rejected: ${error instanceof Error ? error.message : String(error)}`;
|
|
819
|
+
});
|
|
820
|
+
}
|
|
821
|
+
requireBuffer(buffer) {
|
|
822
|
+
if (!(buffer instanceof WebGPURenderBuffer) || !this.buffers.has(buffer)) {
|
|
823
|
+
throw new RenderDeviceError("Buffer was not created by this WebGPU device", "FOREIGN_RESOURCE", {
|
|
824
|
+
bufferId: buffer.id
|
|
825
|
+
});
|
|
826
|
+
}
|
|
827
|
+
if (buffer.disposed) {
|
|
828
|
+
throw new RenderDeviceError("Cannot use a disposed buffer", "DISPOSED_RESOURCE", { bufferId: buffer.id });
|
|
829
|
+
}
|
|
830
|
+
return buffer;
|
|
831
|
+
}
|
|
832
|
+
requireShader(shader) {
|
|
833
|
+
if (!(shader instanceof WebGPUShaderProgram) || !this.shaders.has(shader)) {
|
|
834
|
+
throw new RenderDeviceError("Shader was not created by this WebGPU device", "FOREIGN_RESOURCE", {
|
|
835
|
+
shaderId: shader.id
|
|
836
|
+
});
|
|
837
|
+
}
|
|
838
|
+
if (shader.disposed) {
|
|
839
|
+
throw new RenderDeviceError("Cannot use a disposed shader", "DISPOSED_RESOURCE", { shaderId: shader.id });
|
|
840
|
+
}
|
|
841
|
+
return shader;
|
|
842
|
+
}
|
|
843
|
+
requireRenderTarget(target) {
|
|
844
|
+
if (!(target instanceof WebGPURenderTarget) || !this.renderTargets.has(target)) {
|
|
845
|
+
throw new RenderDeviceError("Render target was not created by this WebGPU device", "FOREIGN_RESOURCE", {
|
|
846
|
+
targetId: target.id
|
|
847
|
+
});
|
|
848
|
+
}
|
|
849
|
+
if (target.disposed) {
|
|
850
|
+
throw new RenderDeviceError("Cannot use a disposed render target", "DISPOSED_RESOURCE", { targetId: target.id });
|
|
851
|
+
}
|
|
852
|
+
return target;
|
|
853
|
+
}
|
|
854
|
+
rasterizeDraw(command, vertexBuffer) {
|
|
855
|
+
if (!this.activeRenderTarget || !command.vertexFormat?.hasAttribute("position"))
|
|
856
|
+
return;
|
|
857
|
+
const position = command.vertexFormat.getAttribute("position");
|
|
858
|
+
const colorAttribute = command.vertexFormat.hasAttribute("color") ? command.vertexFormat.getAttribute("color") : null;
|
|
859
|
+
const uvAttribute = command.vertexFormat.hasAttribute("uv") ? command.vertexFormat.getAttribute("uv") : null;
|
|
860
|
+
if (position.components < 2)
|
|
861
|
+
return;
|
|
862
|
+
const indices = this.indicesFor(command);
|
|
863
|
+
const color = uniformColor(command.uniforms);
|
|
864
|
+
const texture = uniformBaseColorTextureBinding(command.uniforms);
|
|
865
|
+
const shadow = uniformForwardShadow(command.uniforms);
|
|
866
|
+
const instanceMatrices = uniformRasterMatrices(command.uniforms, command.instanceCount ?? 1);
|
|
867
|
+
const modelMatrices = uniformRasterModelMatrices(command.uniforms, command.instanceCount ?? 1);
|
|
868
|
+
const depthTest = command.renderState?.depthTest !== false && this.activeRenderTarget.depthPixels !== null;
|
|
869
|
+
const depthWrite = command.renderState?.depthWrite !== false;
|
|
870
|
+
for (let instanceIndex = 0; instanceIndex < instanceMatrices.length; instanceIndex += 1) {
|
|
871
|
+
const matrix = instanceMatrices[instanceIndex] ?? identityMatrix();
|
|
872
|
+
const modelMatrix = modelMatrices[instanceIndex] ?? identityMatrix();
|
|
873
|
+
if (command.topology === "triangles") {
|
|
874
|
+
for (let offset = 0; offset + 2 < indices.length; offset += 3) {
|
|
875
|
+
const indexA = indices[offset];
|
|
876
|
+
const indexB = indices[offset + 1];
|
|
877
|
+
const indexC = indices[offset + 2];
|
|
878
|
+
const localA = readMorphedPosition(vertexBuffer.bytes, command.vertexFormat.stride, position.offset, indexA, command.uniforms);
|
|
879
|
+
const localB = readMorphedPosition(vertexBuffer.bytes, command.vertexFormat.stride, position.offset, indexB, command.uniforms);
|
|
880
|
+
const localC = readMorphedPosition(vertexBuffer.bytes, command.vertexFormat.stride, position.offset, indexC, command.uniforms);
|
|
881
|
+
const a = transformPosition(localA, matrix);
|
|
882
|
+
const b = transformPosition(localB, matrix);
|
|
883
|
+
const c = transformPosition(localC, matrix);
|
|
884
|
+
const worldA = transformPosition(localA, modelMatrix);
|
|
885
|
+
const worldB = transformPosition(localB, modelMatrix);
|
|
886
|
+
const worldC = transformPosition(localC, modelMatrix);
|
|
887
|
+
const colorA = readVertexColor(vertexBuffer.bytes, command.vertexFormat.stride, colorAttribute?.offset, indexA);
|
|
888
|
+
const colorB = readVertexColor(vertexBuffer.bytes, command.vertexFormat.stride, colorAttribute?.offset, indexB);
|
|
889
|
+
const colorC = readVertexColor(vertexBuffer.bytes, command.vertexFormat.stride, colorAttribute?.offset, indexC);
|
|
890
|
+
const uvA = readVertexUv(vertexBuffer.bytes, command.vertexFormat.stride, uvAttribute?.offset, indexA);
|
|
891
|
+
const uvB = readVertexUv(vertexBuffer.bytes, command.vertexFormat.stride, uvAttribute?.offset, indexB);
|
|
892
|
+
const uvC = readVertexUv(vertexBuffer.bytes, command.vertexFormat.stride, uvAttribute?.offset, indexC);
|
|
893
|
+
rasterizeTriangle(this.activeRenderTarget, a, b, c, worldA, worldB, worldC, color, colorA, colorB, colorC, uvA, uvB, uvC, texture, shadow, depthTest, depthWrite);
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
else if (command.topology === "lines") {
|
|
897
|
+
for (let offset = 0; offset + 1 < indices.length; offset += 2) {
|
|
898
|
+
const indexA = indices[offset];
|
|
899
|
+
const indexB = indices[offset + 1];
|
|
900
|
+
const a = transformPosition(readMorphedPosition(vertexBuffer.bytes, command.vertexFormat.stride, position.offset, indexA, command.uniforms), matrix);
|
|
901
|
+
const b = transformPosition(readMorphedPosition(vertexBuffer.bytes, command.vertexFormat.stride, position.offset, indexB, command.uniforms), matrix);
|
|
902
|
+
const colorA = readVertexColor(vertexBuffer.bytes, command.vertexFormat.stride, colorAttribute?.offset, indexA);
|
|
903
|
+
const colorB = readVertexColor(vertexBuffer.bytes, command.vertexFormat.stride, colorAttribute?.offset, indexB);
|
|
904
|
+
rasterizeLine(this.activeRenderTarget, a, b, color, colorA, colorB, depthTest, depthWrite);
|
|
905
|
+
}
|
|
906
|
+
}
|
|
907
|
+
else {
|
|
908
|
+
for (const index of indices) {
|
|
909
|
+
const point = transformPosition(readMorphedPosition(vertexBuffer.bytes, command.vertexFormat.stride, position.offset, index, command.uniforms), matrix);
|
|
910
|
+
const vertexColor = readVertexColor(vertexBuffer.bytes, command.vertexFormat.stride, colorAttribute?.offset, index);
|
|
911
|
+
rasterizePoint(this.activeRenderTarget, point, multiplyColor(color, vertexColor), depthTest, depthWrite);
|
|
912
|
+
}
|
|
913
|
+
}
|
|
914
|
+
}
|
|
915
|
+
}
|
|
916
|
+
submitNativeRenderPass(command, vertexBuffer) {
|
|
917
|
+
const nativeView = this.activeRenderTarget?.nativeView ?? this.currentCanvasView();
|
|
918
|
+
if (!nativeView || !command.shader)
|
|
919
|
+
return;
|
|
920
|
+
if (!hasNativeRenderPipeline(this.device))
|
|
921
|
+
return;
|
|
922
|
+
const shader = this.requireShader(command.shader);
|
|
923
|
+
const vertexModule = shader.modules[0];
|
|
924
|
+
const fragmentModule = shader.modules[1] ?? vertexModule;
|
|
925
|
+
if (!vertexModule || !fragmentModule)
|
|
926
|
+
return;
|
|
927
|
+
const topology = command.topology === "lines" ? "line-list" : command.topology === "points" ? "point-list" : "triangle-list";
|
|
928
|
+
const targetFormat = this.activeRenderTarget ? webgpuTextureFormat(this.activeRenderTarget.colorTexture.format) : this.presentationFormat;
|
|
929
|
+
const vertexBuffers = command.vertexFormat ? [vertexBufferLayout(command.vertexFormat)] : undefined;
|
|
930
|
+
const shouldClear = this.activeRenderTarget ? this.activeRenderTarget.nativeNeedsClear : this.drawCalls === 0;
|
|
931
|
+
const depthView = this.activeRenderTarget?.nativeDepthView ?? this.canvasDepthView;
|
|
932
|
+
const depthEnabled = depthView !== null &&
|
|
933
|
+
depthView !== undefined &&
|
|
934
|
+
command.renderState?.depthTest !== false;
|
|
935
|
+
const depthWriteEnabled = command.renderState?.depthWrite ?? true;
|
|
936
|
+
const depthCompare = command.renderState?.depthCompare ?? "less-equal";
|
|
937
|
+
const blendEnabled = command.renderState?.blend === true;
|
|
938
|
+
const pipelineKey = `${shader.nativeUniformLayout}:${topology}:${targetFormat}:${blendEnabled ? "blend" : "opaque"}:${depthEnabled ? `${depthWriteEnabled}:${depthCompare}` : "nodepth"}:${command.vertexFormat?.stride ?? 0}:${command.vertexFormat?.attributes.map((attribute) => `${attribute.shaderLocation}/${attribute.offset}/${attribute.components}`).join(",") ?? "none"}`;
|
|
939
|
+
let pipeline = shader.renderPipelines.get(pipelineKey);
|
|
940
|
+
if (!pipeline) {
|
|
941
|
+
pipeline = this.device.createRenderPipeline({
|
|
942
|
+
label: `${shader.label}-pipeline`,
|
|
943
|
+
layout: "auto",
|
|
944
|
+
vertex: { module: vertexModule, entryPoint: shader.entryPoints[0], ...(vertexBuffers ? { buffers: vertexBuffers } : {}) },
|
|
945
|
+
fragment: {
|
|
946
|
+
module: fragmentModule,
|
|
947
|
+
entryPoint: shader.entryPoints[1],
|
|
948
|
+
targets: [{
|
|
949
|
+
format: targetFormat,
|
|
950
|
+
...(blendEnabled
|
|
951
|
+
? {
|
|
952
|
+
blend: {
|
|
953
|
+
color: { srcFactor: "src-alpha", dstFactor: "one-minus-src-alpha", operation: "add" },
|
|
954
|
+
alpha: { srcFactor: "one", dstFactor: "one-minus-src-alpha", operation: "add" }
|
|
955
|
+
}
|
|
956
|
+
}
|
|
957
|
+
: {})
|
|
958
|
+
}]
|
|
959
|
+
},
|
|
960
|
+
primitive: { topology },
|
|
961
|
+
...(depthEnabled
|
|
962
|
+
? {
|
|
963
|
+
depthStencil: {
|
|
964
|
+
format: DEPTH_TEXTURE_FORMAT,
|
|
965
|
+
depthWriteEnabled,
|
|
966
|
+
depthCompare
|
|
967
|
+
}
|
|
968
|
+
}
|
|
969
|
+
: {})
|
|
970
|
+
});
|
|
971
|
+
shader.renderPipelines.set(pipelineKey, pipeline);
|
|
972
|
+
}
|
|
973
|
+
const encoder = this.device.createCommandEncoder({ label: `${command.label ?? "draw"}-encoder` });
|
|
974
|
+
const uniformBuffer = usesNativeDrawUniforms(shader.nativeUniformLayout) ? this.createNativeDrawUniformBuffer(command) : null;
|
|
975
|
+
const sampledTexture = shader.nativeUniformLayout === "generated-texture" ? this.createNativeSampledTextureBinding(uniformBaseColorTextureBinding(command.uniforms)) : null;
|
|
976
|
+
const materialTextures = usesNativePbrTextureBindings(shader.nativeUniformLayout) ? this.createNativePbrTextureBindings(command) : null;
|
|
977
|
+
if (shader.nativeUniformLayout === "generated-texture" && !sampledTexture) {
|
|
978
|
+
uniformBuffer?.destroy();
|
|
979
|
+
return;
|
|
980
|
+
}
|
|
981
|
+
if (usesNativePbrTextureBindings(shader.nativeUniformLayout) && !materialTextures) {
|
|
982
|
+
uniformBuffer?.destroy();
|
|
983
|
+
return;
|
|
984
|
+
}
|
|
985
|
+
const bindGroup = uniformBuffer && pipeline.getBindGroupLayout && this.device.createBindGroup
|
|
986
|
+
? this.device.createBindGroup({
|
|
987
|
+
label: `${command.label ?? "draw"}-draw-bind-group`,
|
|
988
|
+
layout: pipeline.getBindGroupLayout(0),
|
|
989
|
+
entries: [
|
|
990
|
+
{ binding: 0, resource: { buffer: uniformBuffer } },
|
|
991
|
+
...(sampledTexture ? [
|
|
992
|
+
{ binding: 1, resource: sampledTexture.sampler },
|
|
993
|
+
{ binding: 2, resource: sampledTexture.view }
|
|
994
|
+
] : []),
|
|
995
|
+
...(materialTextures ? [
|
|
996
|
+
{ binding: 1, resource: materialTextures.base.sampler },
|
|
997
|
+
{ binding: 2, resource: materialTextures.base.view },
|
|
998
|
+
{ binding: 3, resource: materialTextures.environment.sampler },
|
|
999
|
+
{ binding: 4, resource: materialTextures.environment.view },
|
|
1000
|
+
{ binding: 5, resource: materialTextures.brdf.sampler },
|
|
1001
|
+
{ binding: 6, resource: materialTextures.brdf.view },
|
|
1002
|
+
{ binding: 7, resource: materialTextures.shadow.sampler },
|
|
1003
|
+
{ binding: 8, resource: materialTextures.shadow.view },
|
|
1004
|
+
{ binding: 9, resource: materialTextures.normal.sampler },
|
|
1005
|
+
{ binding: 10, resource: materialTextures.normal.view },
|
|
1006
|
+
{ binding: 11, resource: materialTextures.metallicRoughness.sampler },
|
|
1007
|
+
{ binding: 12, resource: materialTextures.metallicRoughness.view },
|
|
1008
|
+
{ binding: 13, resource: materialTextures.occlusion.sampler },
|
|
1009
|
+
{ binding: 14, resource: materialTextures.occlusion.view }
|
|
1010
|
+
] : [])
|
|
1011
|
+
]
|
|
1012
|
+
})
|
|
1013
|
+
: null;
|
|
1014
|
+
const pass = encoder.beginRenderPass({
|
|
1015
|
+
label: `${command.label ?? "draw"}-pass`,
|
|
1016
|
+
colorAttachments: [{
|
|
1017
|
+
view: nativeView,
|
|
1018
|
+
clearValue: this.activeRenderTarget?.nativeClearColor ?? this.clearColor,
|
|
1019
|
+
loadOp: shouldClear ? "clear" : "load",
|
|
1020
|
+
storeOp: "store"
|
|
1021
|
+
}],
|
|
1022
|
+
...(depthEnabled
|
|
1023
|
+
? {
|
|
1024
|
+
depthStencilAttachment: {
|
|
1025
|
+
view: depthView,
|
|
1026
|
+
depthClearValue: 1,
|
|
1027
|
+
depthLoadOp: shouldClear ? "clear" : "load",
|
|
1028
|
+
depthStoreOp: "store"
|
|
1029
|
+
}
|
|
1030
|
+
}
|
|
1031
|
+
: {})
|
|
1032
|
+
});
|
|
1033
|
+
pass.setPipeline(pipeline);
|
|
1034
|
+
pass.setVertexBuffer(0, vertexBuffer.handle);
|
|
1035
|
+
if (bindGroup)
|
|
1036
|
+
pass.setBindGroup?.(0, bindGroup);
|
|
1037
|
+
if (command.indexBuffer) {
|
|
1038
|
+
if (!pass.setIndexBuffer || !pass.drawIndexed) {
|
|
1039
|
+
pass.end();
|
|
1040
|
+
uniformBuffer?.destroy();
|
|
1041
|
+
this.lastError = "Native WebGPU indexed draw skipped because the render-pass encoder does not expose indexed draw APIs.";
|
|
1042
|
+
return;
|
|
1043
|
+
}
|
|
1044
|
+
const indexBuffer = this.requireBuffer(command.indexBuffer);
|
|
1045
|
+
pass.setIndexBuffer(indexBuffer.handle, command.indexType ?? "uint16");
|
|
1046
|
+
pass.drawIndexed(command.indexCount ?? this.indicesFor(command).length, command.instanceCount ?? 1, command.firstIndex ?? 0);
|
|
1047
|
+
}
|
|
1048
|
+
else {
|
|
1049
|
+
pass.draw(command.vertexCount, command.instanceCount ?? 1, command.firstVertex ?? 0);
|
|
1050
|
+
}
|
|
1051
|
+
pass.end();
|
|
1052
|
+
this.device.queue.submit([encoder.finish()]);
|
|
1053
|
+
if (this.activeRenderTarget)
|
|
1054
|
+
this.activeRenderTarget.nativeNeedsClear = false;
|
|
1055
|
+
uniformBuffer?.destroy();
|
|
1056
|
+
this.nativeSubmissions += 1;
|
|
1057
|
+
if (sampledTexture)
|
|
1058
|
+
this.nativeTextureBindings += 1;
|
|
1059
|
+
if (shader.nativeUniformLayout === "generated-basic")
|
|
1060
|
+
this.nativeGeneratedBasicSubmissions += 1;
|
|
1061
|
+
if (shader.nativeUniformLayout === "generated-texture")
|
|
1062
|
+
this.nativeGeneratedTextureSubmissions += 1;
|
|
1063
|
+
if (shader.nativeUniformLayout === "passthrough")
|
|
1064
|
+
this.nativePassthroughSubmissions += 1;
|
|
1065
|
+
if (shader.nativeUniformLayout === "generated-pbr" || shader.nativeUniformLayout === "generated-textured-pbr" || shader.nativeUniformLayout === "generated-instanced-pbr")
|
|
1066
|
+
this.nativePbrSubmissions += 1;
|
|
1067
|
+
if (shader.nativeUniformLayout === "generated-instanced-pbr")
|
|
1068
|
+
this.nativeInstancedSubmissions += 1;
|
|
1069
|
+
if (shader.nativeUniformLayout === "generated-skinned-unlit")
|
|
1070
|
+
this.nativeSkinnedSubmissions += 1;
|
|
1071
|
+
if (shader.nativeUniformLayout === "generated-morph-unlit")
|
|
1072
|
+
this.nativeMorphSubmissions += 1;
|
|
1073
|
+
if (materialTextures?.actualBaseColor)
|
|
1074
|
+
this.nativeTextureBindings += 1;
|
|
1075
|
+
if (materialTextures?.actualNormal)
|
|
1076
|
+
this.nativeTextureBindings += 1;
|
|
1077
|
+
if (materialTextures?.actualMetallicRoughness)
|
|
1078
|
+
this.nativeTextureBindings += 1;
|
|
1079
|
+
if (materialTextures?.actualOcclusion)
|
|
1080
|
+
this.nativeTextureBindings += 1;
|
|
1081
|
+
if (materialTextures?.actualEnvironment)
|
|
1082
|
+
this.nativeEnvironmentBindings += 1;
|
|
1083
|
+
if (materialTextures?.actualBrdf)
|
|
1084
|
+
this.nativeEnvironmentBindings += 1;
|
|
1085
|
+
if (materialTextures?.actualShadow)
|
|
1086
|
+
this.nativeShadowMapBindings += 1;
|
|
1087
|
+
if (!this.activeRenderTarget)
|
|
1088
|
+
this.canvasSubmissions += 1;
|
|
1089
|
+
}
|
|
1090
|
+
flushNativeRenderTargetClear(target) {
|
|
1091
|
+
if (!target.nativeNeedsClear || !target.nativeView || !this.device.createCommandEncoder)
|
|
1092
|
+
return;
|
|
1093
|
+
const encoder = this.device.createCommandEncoder({ label: `${target.label}-native-clear` });
|
|
1094
|
+
const pass = encoder.beginRenderPass({
|
|
1095
|
+
label: `${target.label}-native-clear-pass`,
|
|
1096
|
+
colorAttachments: [{
|
|
1097
|
+
view: target.nativeView,
|
|
1098
|
+
clearValue: target.nativeClearColor,
|
|
1099
|
+
loadOp: "clear",
|
|
1100
|
+
storeOp: "store"
|
|
1101
|
+
}],
|
|
1102
|
+
...(target.nativeDepthView
|
|
1103
|
+
? {
|
|
1104
|
+
depthStencilAttachment: {
|
|
1105
|
+
view: target.nativeDepthView,
|
|
1106
|
+
depthClearValue: 1,
|
|
1107
|
+
depthLoadOp: "clear",
|
|
1108
|
+
depthStoreOp: "store"
|
|
1109
|
+
}
|
|
1110
|
+
}
|
|
1111
|
+
: {})
|
|
1112
|
+
});
|
|
1113
|
+
pass.end();
|
|
1114
|
+
this.device.queue.submit([encoder.finish()]);
|
|
1115
|
+
target.nativeNeedsClear = false;
|
|
1116
|
+
}
|
|
1117
|
+
createNativeSampledTextureBinding(binding) {
|
|
1118
|
+
if (!binding?.texture || binding.texture.disposed || !binding.validate().ok || !hasNativeSampledTextureBinding(this.device))
|
|
1119
|
+
return null;
|
|
1120
|
+
const texture = binding.texture;
|
|
1121
|
+
let resource = this.nativeSampledTextures.get(texture);
|
|
1122
|
+
if (!resource) {
|
|
1123
|
+
if (texture.source) {
|
|
1124
|
+
const sourceLevels = nativeTextureSourceLevels(texture);
|
|
1125
|
+
if (sourceLevels.length === 0)
|
|
1126
|
+
return null;
|
|
1127
|
+
const nativeTexture = this.device.createTexture({
|
|
1128
|
+
label: texture.label,
|
|
1129
|
+
size: { width: texture.width, height: texture.height, depthOrArrayLayers: 1 },
|
|
1130
|
+
format: webgpuSampledTextureFormat(texture, "rgba8"),
|
|
1131
|
+
usage: TEXTURE_USAGE.TEXTURE_BINDING | TEXTURE_USAGE.COPY_DST,
|
|
1132
|
+
mipLevelCount: sourceLevels.length
|
|
1133
|
+
});
|
|
1134
|
+
const writeTexture = this.device.queue.writeTexture;
|
|
1135
|
+
if (!writeTexture)
|
|
1136
|
+
return null;
|
|
1137
|
+
sourceLevels.forEach((level, mipLevel) => {
|
|
1138
|
+
writeTexture.call(this.device.queue, { texture: nativeTexture, mipLevel }, level.data, { bytesPerRow: level.bytesPerRow, rowsPerImage: level.height }, { width: level.width, height: level.height, depthOrArrayLayers: 1 });
|
|
1139
|
+
});
|
|
1140
|
+
resource = { texture: nativeTexture, view: nativeTexture.createView() };
|
|
1141
|
+
}
|
|
1142
|
+
else {
|
|
1143
|
+
const sampledTexture = nativeSampledTextureLevels(texture);
|
|
1144
|
+
if (!sampledTexture)
|
|
1145
|
+
return null;
|
|
1146
|
+
const { levels, format } = sampledTexture;
|
|
1147
|
+
const baseLevel = levels[0];
|
|
1148
|
+
if (!baseLevel)
|
|
1149
|
+
return null;
|
|
1150
|
+
const levelBytesPerPixel = bytesPerPixel(format);
|
|
1151
|
+
if (levels.some((level) => level.data.byteLength < level.width * level.height * levelBytesPerPixel))
|
|
1152
|
+
return null;
|
|
1153
|
+
const nativeTexture = this.device.createTexture({
|
|
1154
|
+
label: texture.label,
|
|
1155
|
+
size: { width: baseLevel.width, height: baseLevel.height, depthOrArrayLayers: 1 },
|
|
1156
|
+
format: webgpuSampledTextureFormat(texture, format),
|
|
1157
|
+
usage: TEXTURE_USAGE.TEXTURE_BINDING | TEXTURE_USAGE.COPY_DST,
|
|
1158
|
+
mipLevelCount: levels.length
|
|
1159
|
+
});
|
|
1160
|
+
for (const [mipLevel, level] of levels.entries()) {
|
|
1161
|
+
this.device.queue.writeTexture({ texture: nativeTexture, mipLevel }, level.data, { bytesPerRow: level.width * levelBytesPerPixel, rowsPerImage: level.height }, { width: level.width, height: level.height, depthOrArrayLayers: 1 });
|
|
1162
|
+
}
|
|
1163
|
+
resource = { texture: nativeTexture, view: nativeTexture.createView() };
|
|
1164
|
+
}
|
|
1165
|
+
this.nativeSampledTextures.set(texture, resource);
|
|
1166
|
+
}
|
|
1167
|
+
return {
|
|
1168
|
+
view: resource.view,
|
|
1169
|
+
sampler: this.device.createSampler(webgpuSamplerDescriptor(binding.sampler)),
|
|
1170
|
+
actual: true
|
|
1171
|
+
};
|
|
1172
|
+
}
|
|
1173
|
+
createNativePbrTextureBindings(command) {
|
|
1174
|
+
if (!hasNativeSampledTextureBinding(this.device))
|
|
1175
|
+
return null;
|
|
1176
|
+
const baseBinding = uniformBaseColorTextureBinding(command.uniforms);
|
|
1177
|
+
const environmentBinding = uniformTextureBinding(command.uniforms, "u_environmentMapTexture");
|
|
1178
|
+
const brdfBinding = uniformTextureBinding(command.uniforms, "u_environmentBrdfLutTexture");
|
|
1179
|
+
const shadowBinding = uniformTextureBinding(command.uniforms, "u_shadowMapTexture");
|
|
1180
|
+
const normalBinding = uniformTextureBinding(command.uniforms, "u_normalTexture");
|
|
1181
|
+
const metallicRoughnessBinding = uniformTextureBinding(command.uniforms, "u_metallicRoughnessTexture");
|
|
1182
|
+
const occlusionBinding = uniformTextureBinding(command.uniforms, "u_occlusionTexture");
|
|
1183
|
+
const base = this.createNativeSampledTextureBinding(baseBinding) ?? this.createNativeFallbackSampledTextureBinding("white-srgb", [255, 255, 255, 255], "srgb");
|
|
1184
|
+
const environment = this.createNativeSampledTextureBinding(environmentBinding) ?? this.createNativeFallbackSampledTextureBinding("environment-srgb", [92, 116, 156, 255], "srgb");
|
|
1185
|
+
const brdf = this.createNativeSampledTextureBinding(brdfBinding) ?? this.createNativeFallbackSampledTextureBinding("brdf-linear", [180, 180, 255, 255], "linear");
|
|
1186
|
+
const shadow = this.createNativeSampledTextureBinding(shadowBinding) ?? this.createNativeFallbackSampledTextureBinding("shadow-lit-linear", [255, 255, 255, 255], "linear");
|
|
1187
|
+
const normal = this.createNativeSampledTextureBinding(normalBinding) ?? this.createNativeFallbackSampledTextureBinding("flat-normal-linear", [128, 128, 255, 255], "linear");
|
|
1188
|
+
const metallicRoughness = this.createNativeSampledTextureBinding(metallicRoughnessBinding) ?? this.createNativeFallbackSampledTextureBinding("metallic-roughness-linear", [255, 255, 255, 255], "linear");
|
|
1189
|
+
const occlusion = this.createNativeSampledTextureBinding(occlusionBinding) ?? this.createNativeFallbackSampledTextureBinding("occlusion-linear", [255, 255, 255, 255], "linear");
|
|
1190
|
+
if (!base || !environment || !brdf || !shadow || !normal || !metallicRoughness || !occlusion)
|
|
1191
|
+
return null;
|
|
1192
|
+
return {
|
|
1193
|
+
base,
|
|
1194
|
+
environment,
|
|
1195
|
+
brdf,
|
|
1196
|
+
shadow,
|
|
1197
|
+
normal,
|
|
1198
|
+
metallicRoughness,
|
|
1199
|
+
occlusion,
|
|
1200
|
+
actualBaseColor: baseBinding !== null && base.actual,
|
|
1201
|
+
actualEnvironment: environmentBinding !== null && environment.actual,
|
|
1202
|
+
actualBrdf: brdfBinding !== null && brdf.actual,
|
|
1203
|
+
actualShadow: shadowBinding !== null && shadow.actual,
|
|
1204
|
+
actualNormal: normalBinding !== null && normal.actual,
|
|
1205
|
+
actualMetallicRoughness: metallicRoughnessBinding !== null && metallicRoughness.actual,
|
|
1206
|
+
actualOcclusion: occlusionBinding !== null && occlusion.actual
|
|
1207
|
+
};
|
|
1208
|
+
}
|
|
1209
|
+
createNativeFallbackSampledTextureBinding(key, rgba, colorSpace) {
|
|
1210
|
+
if (!hasNativeSampledTextureBinding(this.device))
|
|
1211
|
+
return null;
|
|
1212
|
+
let resource = this.nativeSampledTextures.get(`fallback:${key}`);
|
|
1213
|
+
if (!resource) {
|
|
1214
|
+
const nativeTexture = this.device.createTexture({
|
|
1215
|
+
label: `aura3d-native-${key}`,
|
|
1216
|
+
size: { width: 1, height: 1, depthOrArrayLayers: 1 },
|
|
1217
|
+
format: colorSpace === "srgb" ? "rgba8unorm-srgb" : "rgba8unorm",
|
|
1218
|
+
usage: TEXTURE_USAGE.TEXTURE_BINDING | TEXTURE_USAGE.COPY_DST
|
|
1219
|
+
});
|
|
1220
|
+
this.device.queue.writeTexture({ texture: nativeTexture }, new Uint8Array(rgba), { bytesPerRow: 4, rowsPerImage: 1 }, { width: 1, height: 1, depthOrArrayLayers: 1 });
|
|
1221
|
+
resource = { texture: nativeTexture, view: nativeTexture.createView() };
|
|
1222
|
+
this.nativeSampledTextures.set(`fallback:${key}`, resource);
|
|
1223
|
+
}
|
|
1224
|
+
return {
|
|
1225
|
+
view: resource.view,
|
|
1226
|
+
sampler: this.device.createSampler({
|
|
1227
|
+
minFilter: "nearest",
|
|
1228
|
+
magFilter: "nearest",
|
|
1229
|
+
addressModeU: "clamp-to-edge",
|
|
1230
|
+
addressModeV: "clamp-to-edge"
|
|
1231
|
+
}),
|
|
1232
|
+
actual: false
|
|
1233
|
+
};
|
|
1234
|
+
}
|
|
1235
|
+
createNativeDrawUniformBuffer(command) {
|
|
1236
|
+
if (!this.device.createBindGroup)
|
|
1237
|
+
return null;
|
|
1238
|
+
const data = new Float32Array(188);
|
|
1239
|
+
const baseColorBinding = uniformBaseColorTextureBinding(command.uniforms);
|
|
1240
|
+
const environmentBinding = uniformTextureBinding(command.uniforms, "u_environmentMapTexture");
|
|
1241
|
+
const normalBinding = uniformTextureBinding(command.uniforms, "u_normalTexture");
|
|
1242
|
+
const metallicRoughnessBinding = uniformTextureBinding(command.uniforms, "u_metallicRoughnessTexture");
|
|
1243
|
+
const occlusionBinding = uniformTextureBinding(command.uniforms, "u_occlusionTexture");
|
|
1244
|
+
data.set(uniformMat4(command.uniforms?.get("u_modelViewProjection")) ?? identityMatrix(), 0);
|
|
1245
|
+
data.set(uniformColor(command.uniforms), 16);
|
|
1246
|
+
data[20] = uniformNumber(command.uniforms?.get("u_metallic"), 0);
|
|
1247
|
+
data[21] = uniformNumber(command.uniforms?.get("u_roughness"), 0.5);
|
|
1248
|
+
data[22] = uniformNumber(command.uniforms?.get("u_environmentIntensity"), 0);
|
|
1249
|
+
data[23] = uniformNumber(command.uniforms?.get("u_environmentMapTextureIntensity"), 0);
|
|
1250
|
+
data[24] = uniformNumber(command.uniforms?.get("u_baseColorTextureEnabled"), baseColorBinding ? 1 : 0);
|
|
1251
|
+
data[25] = uniformNumber(command.uniforms?.get("u_shadowMapEnabled"), 0);
|
|
1252
|
+
data[26] = uniformNumber(command.uniforms?.get("u_shadowMapStrength"), 0.65);
|
|
1253
|
+
data[27] = uniformNumber(command.uniforms?.get("u_environmentMapTextureEnabled"), environmentBinding ? 1 : 0);
|
|
1254
|
+
const morphWeights = command.uniforms?.get("u_morphWeights");
|
|
1255
|
+
data[28] = morphWeights instanceof Float32Array || Array.isArray(morphWeights) ? Number(morphWeights[0] ?? 0) : 0;
|
|
1256
|
+
data[29] = uniformNumber(command.uniforms?.get("u_morphTargetCount"), 0);
|
|
1257
|
+
data[30] = uniformNumber(command.uniforms?.get("u_environmentMapTextureMipCount"), 1);
|
|
1258
|
+
data[31] = uniformNumber(command.uniforms?.get("u_environmentMapTextureSpecularIntensity"), 0)
|
|
1259
|
+
* uniformNumber(command.uniforms?.get("u_materialEnvironmentSpecularScale"), 1);
|
|
1260
|
+
data[128] = uniformNumber(command.uniforms?.get("u_normalTextureEnabled"), normalBinding ? 1 : 0);
|
|
1261
|
+
data[129] = uniformNumber(command.uniforms?.get("u_normalScale"), 1);
|
|
1262
|
+
data[130] = uniformNumber(command.uniforms?.get("u_occlusionStrength"), 1);
|
|
1263
|
+
data[160] = uniformNumber(command.uniforms?.get("u_alphaCutoff"), 0);
|
|
1264
|
+
data[161] = uniformNumber(command.uniforms?.get("u_transmissionFactor"), 0);
|
|
1265
|
+
data[162] = uniformNumber(command.uniforms?.get("u_diffuseTransmissionFactor"), 0);
|
|
1266
|
+
data.set(uniformVec3(command.uniforms?.get("u_cameraPosition")) ?? [0, 0, 1], 164);
|
|
1267
|
+
data[167] = 1;
|
|
1268
|
+
data[168] = uniformNumber(command.uniforms?.get("u_metallicRoughnessTextureEnabled"), metallicRoughnessBinding ? 1 : 0);
|
|
1269
|
+
data[169] = uniformNumber(command.uniforms?.get("u_occlusionTextureEnabled"), occlusionBinding ? 1 : 0);
|
|
1270
|
+
data[170] = uniformNumber(command.uniforms?.get("u_productColorSmoothing"), 0);
|
|
1271
|
+
data.set(uniformMat4(command.uniforms?.get("u_normalMatrix")) ?? identityMatrix(), 172);
|
|
1272
|
+
const modelMatrix = uniformMat4(command.uniforms?.get("u_modelMatrix")) ?? identityMatrix();
|
|
1273
|
+
const instanceMatrixValue = command.uniforms?.get("u_instanceMatrices");
|
|
1274
|
+
const instanceMatrixNumbers = instanceMatrixValue instanceof Float32Array || Array.isArray(instanceMatrixValue) ? Array.from(instanceMatrixValue) : [];
|
|
1275
|
+
const hasInstanceMatrices = instanceMatrixNumbers.length >= 16 && instanceMatrixNumbers.slice(0, 16).every(Number.isFinite);
|
|
1276
|
+
const instanceMatrices = hasInstanceMatrices ? uniformMat4Array(instanceMatrixValue, 4) : [];
|
|
1277
|
+
for (let index = 0; index < 4; index += 1) {
|
|
1278
|
+
data.set(instanceMatrices[index] ?? (index === 0 ? modelMatrix : identityMatrix()), 32 + index * 16);
|
|
1279
|
+
}
|
|
1280
|
+
const jointMatrices = uniformMat4Array(command.uniforms?.get("u_jointMatrices"), 2);
|
|
1281
|
+
for (let index = 0; index < 2; index += 1) {
|
|
1282
|
+
data.set(jointMatrices[index] ?? identityMatrix(), 96 + index * 16);
|
|
1283
|
+
}
|
|
1284
|
+
const morphDeltas = command.uniforms?.get("u_morphPositionDeltas");
|
|
1285
|
+
const morphNumbers = morphDeltas instanceof Float32Array || Array.isArray(morphDeltas) ? Array.from(morphDeltas).slice(0, 32) : [];
|
|
1286
|
+
if (morphNumbers.length > 0)
|
|
1287
|
+
data.set(morphNumbers, 128);
|
|
1288
|
+
const buffer = this.device.createBuffer({
|
|
1289
|
+
label: `${command.label ?? "draw"}-draw-uniforms`,
|
|
1290
|
+
size: data.byteLength,
|
|
1291
|
+
usage: BUFFER_USAGE.UNIFORM | BUFFER_USAGE.COPY_DST
|
|
1292
|
+
});
|
|
1293
|
+
this.device.queue.writeBuffer(buffer, 0, data);
|
|
1294
|
+
return buffer;
|
|
1295
|
+
}
|
|
1296
|
+
currentCanvasView() {
|
|
1297
|
+
if (!this.canvasContext)
|
|
1298
|
+
return null;
|
|
1299
|
+
return this.canvasContext.getCurrentTexture().createView();
|
|
1300
|
+
}
|
|
1301
|
+
ensureCanvasDepthAttachment(width, height) {
|
|
1302
|
+
if (!this.canvasContext || !this.device.createTexture)
|
|
1303
|
+
return;
|
|
1304
|
+
if (this.canvasDepthTexture &&
|
|
1305
|
+
this.canvasDepthView &&
|
|
1306
|
+
this.canvasDepthWidth === width &&
|
|
1307
|
+
this.canvasDepthHeight === height) {
|
|
1308
|
+
return;
|
|
1309
|
+
}
|
|
1310
|
+
this.canvasDepthTexture?.destroy();
|
|
1311
|
+
this.canvasDepthTexture = this.device.createTexture({
|
|
1312
|
+
label: "aura3d-webgpu-canvas-depth",
|
|
1313
|
+
size: [width, height],
|
|
1314
|
+
format: DEPTH_TEXTURE_FORMAT,
|
|
1315
|
+
usage: TEXTURE_USAGE.RENDER_ATTACHMENT
|
|
1316
|
+
});
|
|
1317
|
+
this.canvasDepthView = this.canvasDepthTexture.createView();
|
|
1318
|
+
this.canvasDepthWidth = width;
|
|
1319
|
+
this.canvasDepthHeight = height;
|
|
1320
|
+
}
|
|
1321
|
+
clearActiveRenderTarget(color) {
|
|
1322
|
+
if (!this.activeRenderTarget)
|
|
1323
|
+
return;
|
|
1324
|
+
const bytes = rgbaBytes(color);
|
|
1325
|
+
for (let index = 0; index < this.activeRenderTarget.colorPixels.length; index += 4) {
|
|
1326
|
+
this.activeRenderTarget.colorPixels.set(bytes, index);
|
|
1327
|
+
}
|
|
1328
|
+
this.activeRenderTarget.nativeNeedsClear = true;
|
|
1329
|
+
this.activeRenderTarget.nativeClearColor = color;
|
|
1330
|
+
this.activeRenderTarget.depthPixels?.fill(1);
|
|
1331
|
+
if (this.activeRenderTarget.colorFloatPixels) {
|
|
1332
|
+
for (let index = 0; index < this.activeRenderTarget.colorFloatPixels.length; index += 4) {
|
|
1333
|
+
this.activeRenderTarget.colorFloatPixels[index] = color[0];
|
|
1334
|
+
this.activeRenderTarget.colorFloatPixels[index + 1] = color[1];
|
|
1335
|
+
this.activeRenderTarget.colorFloatPixels[index + 2] = color[2];
|
|
1336
|
+
this.activeRenderTarget.colorFloatPixels[index + 3] = color[3];
|
|
1337
|
+
}
|
|
1338
|
+
}
|
|
1339
|
+
}
|
|
1340
|
+
indicesFor(command) {
|
|
1341
|
+
if (!command.indexBuffer) {
|
|
1342
|
+
const firstVertex = command.firstVertex ?? 0;
|
|
1343
|
+
return Array.from({ length: command.vertexCount }, (_, index) => firstVertex + index);
|
|
1344
|
+
}
|
|
1345
|
+
const indexBuffer = this.requireBuffer(command.indexBuffer);
|
|
1346
|
+
const indexCount = command.indexCount ?? Math.floor(indexBuffer.byteLength / (command.indexType === "uint32" ? 4 : 2));
|
|
1347
|
+
const indices = [];
|
|
1348
|
+
const view = new DataView(indexBuffer.bytes.buffer, indexBuffer.bytes.byteOffset, indexBuffer.bytes.byteLength);
|
|
1349
|
+
const firstIndex = command.firstIndex ?? 0;
|
|
1350
|
+
for (let index = 0; index < indexCount; index += 1) {
|
|
1351
|
+
const byteOffset = (firstIndex + index) * (command.indexType === "uint32" ? 4 : 2);
|
|
1352
|
+
indices.push(command.indexType === "uint32" ? view.getUint32(byteOffset, true) : view.getUint16(byteOffset, true));
|
|
1353
|
+
}
|
|
1354
|
+
return indices;
|
|
1355
|
+
}
|
|
1356
|
+
}
|
|
1357
|
+
async function requestAdapter(gpu) {
|
|
1358
|
+
if (!gpu) {
|
|
1359
|
+
throw new RenderDeviceError("WebGPU runtime is missing from the current environment", "WEBGPU_RUNTIME_MISSING");
|
|
1360
|
+
}
|
|
1361
|
+
return gpu.requestAdapter();
|
|
1362
|
+
}
|
|
1363
|
+
async function requestDevice(adapter, injectedDevice) {
|
|
1364
|
+
if (injectedDevice) {
|
|
1365
|
+
return injectedDevice;
|
|
1366
|
+
}
|
|
1367
|
+
try {
|
|
1368
|
+
return await adapter.requestDevice();
|
|
1369
|
+
}
|
|
1370
|
+
catch (error) {
|
|
1371
|
+
throw new RenderDeviceError("WebGPU adapter failed to create a device", "WEBGPU_DEVICE_REQUEST_FAILED", {
|
|
1372
|
+
adapter: describeAdapter(adapter),
|
|
1373
|
+
reason: error instanceof Error ? error.message : String(error)
|
|
1374
|
+
});
|
|
1375
|
+
}
|
|
1376
|
+
}
|
|
1377
|
+
function validateWebGPUDevice(device) {
|
|
1378
|
+
const missing = [];
|
|
1379
|
+
if (!device || typeof device !== "object")
|
|
1380
|
+
missing.push("device");
|
|
1381
|
+
if (typeof device?.createBuffer !== "function")
|
|
1382
|
+
missing.push("createBuffer");
|
|
1383
|
+
if (typeof device?.queue?.writeBuffer !== "function")
|
|
1384
|
+
missing.push("queue.writeBuffer");
|
|
1385
|
+
if (typeof device?.queue?.submit !== "function")
|
|
1386
|
+
missing.push("queue.submit");
|
|
1387
|
+
if (missing.length > 0) {
|
|
1388
|
+
throw new RenderDeviceError("WebGPU device is missing required render-device capabilities", "WEBGPU_DEVICE_INVALID", {
|
|
1389
|
+
missing
|
|
1390
|
+
});
|
|
1391
|
+
}
|
|
1392
|
+
return device;
|
|
1393
|
+
}
|
|
1394
|
+
function hasNativeRenderPipeline(device) {
|
|
1395
|
+
return typeof device.createCommandEncoder === "function" &&
|
|
1396
|
+
typeof device.createRenderPipeline === "function" &&
|
|
1397
|
+
typeof device.createBindGroup === "function" &&
|
|
1398
|
+
typeof device.createTexture === "function";
|
|
1399
|
+
}
|
|
1400
|
+
function hasNativeSampledTextureBinding(device) {
|
|
1401
|
+
return typeof device.createTexture === "function" &&
|
|
1402
|
+
typeof device.createSampler === "function" &&
|
|
1403
|
+
typeof device.queue.writeTexture === "function";
|
|
1404
|
+
}
|
|
1405
|
+
function hasNativeTextureUpload(device) {
|
|
1406
|
+
return typeof device.queue.writeTexture === "function";
|
|
1407
|
+
}
|
|
1408
|
+
function hasNativeTextureReadback(device) {
|
|
1409
|
+
if (typeof device.createCommandEncoder !== "function" || typeof device.createTexture !== "function")
|
|
1410
|
+
return false;
|
|
1411
|
+
const probe = device.createBuffer({
|
|
1412
|
+
label: "aura3d-native-readback-capability-probe",
|
|
1413
|
+
size: 4,
|
|
1414
|
+
usage: BUFFER_USAGE.MAP_READ | BUFFER_USAGE.COPY_DST
|
|
1415
|
+
});
|
|
1416
|
+
const supported = typeof probe.mapAsync === "function" &&
|
|
1417
|
+
typeof probe.getMappedRange === "function" &&
|
|
1418
|
+
typeof probe.unmap === "function" &&
|
|
1419
|
+
typeof device.createCommandEncoder({ label: "aura3d-native-readback-capability-probe" }).copyTextureToBuffer === "function";
|
|
1420
|
+
probe.destroy();
|
|
1421
|
+
return supported;
|
|
1422
|
+
}
|
|
1423
|
+
function alignTo(value, alignment) {
|
|
1424
|
+
return Math.ceil(value / alignment) * alignment;
|
|
1425
|
+
}
|
|
1426
|
+
function readWebGPU(globalScope) {
|
|
1427
|
+
return globalScope.navigator?.gpu;
|
|
1428
|
+
}
|
|
1429
|
+
function acquireWebGPUCanvasContext(canvas) {
|
|
1430
|
+
const getContext = canvas.getContext;
|
|
1431
|
+
if (typeof getContext !== "function") {
|
|
1432
|
+
throw new RenderDeviceError("WebGPU canvas presentation requires getContext(\"webgpu\")", "WEBGPU_CANVAS_CONTEXT_MISSING");
|
|
1433
|
+
}
|
|
1434
|
+
const context = getContext.call(canvas, "webgpu");
|
|
1435
|
+
if (!context || typeof context.configure !== "function" || typeof context.getCurrentTexture !== "function") {
|
|
1436
|
+
throw new RenderDeviceError("Canvas did not provide a usable WebGPU presentation context", "WEBGPU_CANVAS_CONTEXT_INVALID");
|
|
1437
|
+
}
|
|
1438
|
+
return context;
|
|
1439
|
+
}
|
|
1440
|
+
function describeAdapter(adapter) {
|
|
1441
|
+
if (adapter.name)
|
|
1442
|
+
return adapter.name;
|
|
1443
|
+
const parts = [adapter.info?.vendor, adapter.info?.architecture, adapter.info?.device, adapter.info?.description].filter(Boolean);
|
|
1444
|
+
return parts.length > 0 ? parts.join(" ") : undefined;
|
|
1445
|
+
}
|
|
1446
|
+
function bufferUsageFlags(usage) {
|
|
1447
|
+
if (usage === "vertex")
|
|
1448
|
+
return BUFFER_USAGE.VERTEX | BUFFER_USAGE.COPY_DST | BUFFER_USAGE.COPY_SRC;
|
|
1449
|
+
if (usage === "index")
|
|
1450
|
+
return BUFFER_USAGE.INDEX | BUFFER_USAGE.COPY_DST | BUFFER_USAGE.COPY_SRC;
|
|
1451
|
+
if (usage === "uniform")
|
|
1452
|
+
return BUFFER_USAGE.UNIFORM | BUFFER_USAGE.COPY_DST | BUFFER_USAGE.COPY_SRC;
|
|
1453
|
+
return BUFFER_USAGE.MAP_READ | BUFFER_USAGE.COPY_DST;
|
|
1454
|
+
}
|
|
1455
|
+
function webgpuTextureFormat(format) {
|
|
1456
|
+
if (format === "rgba16f")
|
|
1457
|
+
return "rgba16float";
|
|
1458
|
+
if (format === "rgba32f")
|
|
1459
|
+
return "rgba32float";
|
|
1460
|
+
return "rgba8unorm";
|
|
1461
|
+
}
|
|
1462
|
+
function nativeSampledTextureLevels(texture) {
|
|
1463
|
+
if (isCompressedTextureFormat(texture.format)) {
|
|
1464
|
+
const fallback = texture.fallbackTextureLevels;
|
|
1465
|
+
return fallback.length > 0 ? { levels: fallback, format: "rgba8" } : null;
|
|
1466
|
+
}
|
|
1467
|
+
if (texture.format === "depth24")
|
|
1468
|
+
return null;
|
|
1469
|
+
const levels = texture.textureLevels;
|
|
1470
|
+
return levels.length > 0 ? { levels, format: texture.format } : null;
|
|
1471
|
+
}
|
|
1472
|
+
function nativeTextureSourceLevels(texture) {
|
|
1473
|
+
const source = texture.source;
|
|
1474
|
+
if (!source || typeof globalThis === "undefined")
|
|
1475
|
+
return [];
|
|
1476
|
+
const width = Math.max(1, Math.round(texture.width));
|
|
1477
|
+
const height = Math.max(1, Math.round(texture.height));
|
|
1478
|
+
const mipCount = Math.max(1, Math.floor(Math.log2(Math.max(width, height))) + 1);
|
|
1479
|
+
const levels = [];
|
|
1480
|
+
for (let level = 0; level < mipCount; level += 1) {
|
|
1481
|
+
const levelWidth = Math.max(1, width >> level);
|
|
1482
|
+
const levelHeight = Math.max(1, height >> level);
|
|
1483
|
+
const canvas = createTextureReadbackCanvas(levelWidth, levelHeight);
|
|
1484
|
+
if (!canvas)
|
|
1485
|
+
return levels;
|
|
1486
|
+
const context = canvas.getContext("2d", { willReadFrequently: true });
|
|
1487
|
+
if (!context)
|
|
1488
|
+
return levels;
|
|
1489
|
+
context.clearRect(0, 0, levelWidth, levelHeight);
|
|
1490
|
+
context.drawImage(source, 0, 0, levelWidth, levelHeight);
|
|
1491
|
+
const pixels = context.getImageData(0, 0, levelWidth, levelHeight).data;
|
|
1492
|
+
const sourceBytesPerRow = levelWidth * 4;
|
|
1493
|
+
const bytesPerRow = alignTo(sourceBytesPerRow, 256);
|
|
1494
|
+
if (bytesPerRow === sourceBytesPerRow) {
|
|
1495
|
+
levels.push({ width: levelWidth, height: levelHeight, bytesPerRow, data: new Uint8Array(pixels.buffer.slice(pixels.byteOffset, pixels.byteOffset + pixels.byteLength)) });
|
|
1496
|
+
continue;
|
|
1497
|
+
}
|
|
1498
|
+
const data = new Uint8Array(bytesPerRow * levelHeight);
|
|
1499
|
+
for (let row = 0; row < levelHeight; row += 1) {
|
|
1500
|
+
data.set(pixels.subarray(row * sourceBytesPerRow, (row + 1) * sourceBytesPerRow), row * bytesPerRow);
|
|
1501
|
+
}
|
|
1502
|
+
levels.push({ width: levelWidth, height: levelHeight, bytesPerRow, data });
|
|
1503
|
+
}
|
|
1504
|
+
return levels;
|
|
1505
|
+
}
|
|
1506
|
+
function createTextureReadbackCanvas(width, height) {
|
|
1507
|
+
const offscreenCanvas = globalThis.OffscreenCanvas;
|
|
1508
|
+
if (offscreenCanvas)
|
|
1509
|
+
return new offscreenCanvas(width, height);
|
|
1510
|
+
if (typeof document === "undefined")
|
|
1511
|
+
return null;
|
|
1512
|
+
const canvas = document.createElement("canvas");
|
|
1513
|
+
canvas.width = width;
|
|
1514
|
+
canvas.height = height;
|
|
1515
|
+
return canvas;
|
|
1516
|
+
}
|
|
1517
|
+
function webgpuSampledTextureFormat(texture, format) {
|
|
1518
|
+
if (format === "rgba16f")
|
|
1519
|
+
return "rgba16float";
|
|
1520
|
+
if (format === "rgba32f")
|
|
1521
|
+
return "rgba32float";
|
|
1522
|
+
return texture.colorSpace === "srgb" ? "rgba8unorm-srgb" : "rgba8unorm";
|
|
1523
|
+
}
|
|
1524
|
+
function webgpuMinFilter(filter) {
|
|
1525
|
+
if (filter === "nearest" || filter === "nearest-mipmap-nearest" || filter === "nearest-mipmap-linear")
|
|
1526
|
+
return "nearest";
|
|
1527
|
+
return "linear";
|
|
1528
|
+
}
|
|
1529
|
+
function webgpuMagFilter(filter) {
|
|
1530
|
+
return filter;
|
|
1531
|
+
}
|
|
1532
|
+
function webgpuMipmapFilter(filter) {
|
|
1533
|
+
if (filter === "nearest-mipmap-nearest" || filter === "linear-mipmap-nearest")
|
|
1534
|
+
return "nearest";
|
|
1535
|
+
if (filter === "nearest-mipmap-linear" || filter === "linear-mipmap-linear")
|
|
1536
|
+
return "linear";
|
|
1537
|
+
return undefined;
|
|
1538
|
+
}
|
|
1539
|
+
function webgpuSamplerDescriptor(sampler) {
|
|
1540
|
+
const minFilter = webgpuMinFilter(sampler.minFilter);
|
|
1541
|
+
const magFilter = webgpuMagFilter(sampler.magFilter);
|
|
1542
|
+
const mipmapFilter = webgpuMipmapFilter(sampler.minFilter);
|
|
1543
|
+
const descriptor = {
|
|
1544
|
+
minFilter,
|
|
1545
|
+
magFilter,
|
|
1546
|
+
...(mipmapFilter ? { mipmapFilter } : {}),
|
|
1547
|
+
addressModeU: sampler.addressU,
|
|
1548
|
+
addressModeV: sampler.addressV
|
|
1549
|
+
};
|
|
1550
|
+
const maxAnisotropy = webgpuMaxAnisotropy(sampler.maxAnisotropy, minFilter, magFilter, mipmapFilter);
|
|
1551
|
+
return maxAnisotropy === undefined ? descriptor : { ...descriptor, maxAnisotropy };
|
|
1552
|
+
}
|
|
1553
|
+
function webgpuMaxAnisotropy(maxAnisotropy, minFilter, magFilter, mipmapFilter) {
|
|
1554
|
+
if (maxAnisotropy <= 1)
|
|
1555
|
+
return undefined;
|
|
1556
|
+
if (minFilter !== "linear" || magFilter !== "linear" || mipmapFilter !== "linear")
|
|
1557
|
+
return undefined;
|
|
1558
|
+
return Math.min(16, Math.max(1, Math.floor(maxAnisotropy)));
|
|
1559
|
+
}
|
|
1560
|
+
function usesNativeDrawUniforms(layout) {
|
|
1561
|
+
return layout !== "passthrough";
|
|
1562
|
+
}
|
|
1563
|
+
function usesNativePbrTextureBindings(layout) {
|
|
1564
|
+
return layout === "generated-pbr" ||
|
|
1565
|
+
layout === "generated-textured-pbr" ||
|
|
1566
|
+
layout === "generated-instanced-pbr";
|
|
1567
|
+
}
|
|
1568
|
+
function writeAlignedQueueBuffer(queue, buffer, byteOffset, data, nativeByteLength) {
|
|
1569
|
+
const bytes = viewBytes(data);
|
|
1570
|
+
if (byteOffset % 4 === 0 && bytes.byteLength % 4 === 0) {
|
|
1571
|
+
queue.writeBuffer(buffer, byteOffset, bytes);
|
|
1572
|
+
return;
|
|
1573
|
+
}
|
|
1574
|
+
const alignedOffset = Math.floor(byteOffset / 4) * 4;
|
|
1575
|
+
const alignedEnd = alignTo(byteOffset + bytes.byteLength, 4);
|
|
1576
|
+
if (alignedEnd > nativeByteLength) {
|
|
1577
|
+
throw new RenderDeviceError("Aligned WebGPU buffer write exceeds native buffer allocation", "BUFFER_RANGE_OUT_OF_BOUNDS", {
|
|
1578
|
+
byteOffset,
|
|
1579
|
+
dataByteLength: bytes.byteLength,
|
|
1580
|
+
alignedOffset,
|
|
1581
|
+
alignedEnd,
|
|
1582
|
+
nativeByteLength
|
|
1583
|
+
});
|
|
1584
|
+
}
|
|
1585
|
+
const padded = new Uint8Array(alignedEnd - alignedOffset);
|
|
1586
|
+
padded.set(bytes, byteOffset - alignedOffset);
|
|
1587
|
+
queue.writeBuffer(buffer, alignedOffset, padded);
|
|
1588
|
+
}
|
|
1589
|
+
function rgbaBytes(color) {
|
|
1590
|
+
return new Uint8Array(color.map((channel) => Math.round(Math.max(0, Math.min(1, channel)) * 255)));
|
|
1591
|
+
}
|
|
1592
|
+
function halfFloatToNumber(bits) {
|
|
1593
|
+
const sign = (bits & 0x8000) ? -1 : 1;
|
|
1594
|
+
const exponent = (bits >> 10) & 0x1f;
|
|
1595
|
+
const fraction = bits & 0x03ff;
|
|
1596
|
+
if (exponent === 0) {
|
|
1597
|
+
return sign * 2 ** -14 * (fraction / 1024);
|
|
1598
|
+
}
|
|
1599
|
+
if (exponent === 0x1f) {
|
|
1600
|
+
return fraction === 0 ? sign * Infinity : Number.NaN;
|
|
1601
|
+
}
|
|
1602
|
+
return sign * 2 ** (exponent - 15) * (1 + fraction / 1024);
|
|
1603
|
+
}
|
|
1604
|
+
function uniformColor(uniforms) {
|
|
1605
|
+
const value = uniforms?.get("u_baseColor") ?? uniforms?.get("u_color") ?? uniforms?.get("color");
|
|
1606
|
+
const components = value instanceof Float32Array || Array.isArray(value) ? Array.from(value).slice(0, 4) : [];
|
|
1607
|
+
if (components.length >= 3 && components.every((component) => Number.isFinite(component))) {
|
|
1608
|
+
return [
|
|
1609
|
+
components[0] ?? 1,
|
|
1610
|
+
components[1] ?? 1,
|
|
1611
|
+
components[2] ?? 1,
|
|
1612
|
+
components[3] ?? 1
|
|
1613
|
+
];
|
|
1614
|
+
}
|
|
1615
|
+
return [1, 1, 1, 1];
|
|
1616
|
+
}
|
|
1617
|
+
function uniformBaseColorTextureBinding(uniforms) {
|
|
1618
|
+
if (!uniforms)
|
|
1619
|
+
return null;
|
|
1620
|
+
const direct = uniforms.get("u_texture") ?? uniforms.get("u_baseColorTexture") ?? uniforms.get("baseColorTexture");
|
|
1621
|
+
if (direct instanceof TextureBinding && direct.texture && !direct.texture.disposed && direct.validate().ok) {
|
|
1622
|
+
return direct;
|
|
1623
|
+
}
|
|
1624
|
+
return null;
|
|
1625
|
+
}
|
|
1626
|
+
function uniformTextureBinding(uniforms, name) {
|
|
1627
|
+
const value = uniforms?.get(name);
|
|
1628
|
+
return value instanceof TextureBinding && value.texture && !value.texture.disposed && value.validate().ok ? value : null;
|
|
1629
|
+
}
|
|
1630
|
+
function uniformNumber(value, fallback) {
|
|
1631
|
+
return typeof value === "number" && Number.isFinite(value) ? value : fallback;
|
|
1632
|
+
}
|
|
1633
|
+
function uniformVec3(value) {
|
|
1634
|
+
const components = value instanceof Float32Array || Array.isArray(value) ? Array.from(value).slice(0, 3) : [];
|
|
1635
|
+
return components.length === 3 && components.every(Number.isFinite)
|
|
1636
|
+
? [components[0], components[1], components[2]]
|
|
1637
|
+
: null;
|
|
1638
|
+
}
|
|
1639
|
+
function uniformMat4Array(value, count) {
|
|
1640
|
+
const numbers = value instanceof Float32Array || Array.isArray(value) ? Array.from(value) : [];
|
|
1641
|
+
return Array.from({ length: count }, (_, index) => {
|
|
1642
|
+
const start = index * 16;
|
|
1643
|
+
const matrix = numbers.slice(start, start + 16);
|
|
1644
|
+
return matrix.length === 16 && matrix.every(Number.isFinite) ? matrix : identityMatrix();
|
|
1645
|
+
});
|
|
1646
|
+
}
|
|
1647
|
+
function uniformRasterMatrices(uniforms, instanceCount) {
|
|
1648
|
+
const modelViewProjection = uniformMat4(uniforms?.get("u_modelViewProjection")) ?? identityMatrix();
|
|
1649
|
+
const value = uniforms?.get("u_instanceMatrices");
|
|
1650
|
+
const numbers = value instanceof Float32Array || Array.isArray(value) ? Array.from(value) : [];
|
|
1651
|
+
if (numbers.length < instanceCount * 16 || !numbers.slice(0, instanceCount * 16).every(Number.isFinite)) {
|
|
1652
|
+
return Array.from({ length: instanceCount }, () => modelViewProjection);
|
|
1653
|
+
}
|
|
1654
|
+
return Array.from({ length: instanceCount }, (_, index) => multiplyMat4(modelViewProjection, numbers.slice(index * 16, index * 16 + 16)));
|
|
1655
|
+
}
|
|
1656
|
+
function uniformRasterModelMatrices(uniforms, instanceCount) {
|
|
1657
|
+
const modelMatrix = uniformMat4(uniforms?.get("u_modelMatrix")) ?? identityMatrix();
|
|
1658
|
+
const value = uniforms?.get("u_instanceMatrices");
|
|
1659
|
+
const numbers = value instanceof Float32Array || Array.isArray(value) ? Array.from(value) : [];
|
|
1660
|
+
if (numbers.length < instanceCount * 16 || !numbers.slice(0, instanceCount * 16).every(Number.isFinite)) {
|
|
1661
|
+
return Array.from({ length: instanceCount }, () => modelMatrix);
|
|
1662
|
+
}
|
|
1663
|
+
return Array.from({ length: instanceCount }, (_, index) => multiplyMat4(modelMatrix, numbers.slice(index * 16, index * 16 + 16)));
|
|
1664
|
+
}
|
|
1665
|
+
function uniformForwardShadow(uniforms) {
|
|
1666
|
+
if (!uniforms)
|
|
1667
|
+
return null;
|
|
1668
|
+
const enabled = uniforms.get("u_shadowMapEnabled");
|
|
1669
|
+
if (typeof enabled !== "number" || enabled < 0.5)
|
|
1670
|
+
return null;
|
|
1671
|
+
const texture = uniforms.get("u_shadowMapTexture");
|
|
1672
|
+
const matrix = uniformMat4(uniforms.get("u_shadowMapMatrix")) ?? identityMatrix();
|
|
1673
|
+
if (!(texture instanceof TextureBinding) || !texture.texture || texture.texture.disposed || !texture.validate().ok) {
|
|
1674
|
+
return null;
|
|
1675
|
+
}
|
|
1676
|
+
const strengthValue = uniforms.get("u_shadowMapStrength");
|
|
1677
|
+
const biasValue = uniforms.get("u_shadowMapBias");
|
|
1678
|
+
const strength = typeof strengthValue === "number" && Number.isFinite(strengthValue) ? Math.max(0, Math.min(1, strengthValue)) : 0.65;
|
|
1679
|
+
const bias = typeof biasValue === "number" && Number.isFinite(biasValue) ? Math.max(0, biasValue) : 0.001;
|
|
1680
|
+
return { texture, matrix, strength, bias };
|
|
1681
|
+
}
|
|
1682
|
+
function uniformMat4(value) {
|
|
1683
|
+
const numbers = value instanceof Float32Array || Array.isArray(value) ? Array.from(value) : [];
|
|
1684
|
+
return numbers.length === 16 && numbers.every(Number.isFinite) ? numbers : null;
|
|
1685
|
+
}
|
|
1686
|
+
function multiplyMat4(left, right) {
|
|
1687
|
+
const out = new Array(16);
|
|
1688
|
+
for (let row = 0; row < 4; row += 1) {
|
|
1689
|
+
for (let column = 0; column < 4; column += 1) {
|
|
1690
|
+
out[column * 4 + row] =
|
|
1691
|
+
(left[0 * 4 + row] ?? 0) * (right[column * 4 + 0] ?? 0) +
|
|
1692
|
+
(left[1 * 4 + row] ?? 0) * (right[column * 4 + 1] ?? 0) +
|
|
1693
|
+
(left[2 * 4 + row] ?? 0) * (right[column * 4 + 2] ?? 0) +
|
|
1694
|
+
(left[3 * 4 + row] ?? 0) * (right[column * 4 + 3] ?? 0);
|
|
1695
|
+
}
|
|
1696
|
+
}
|
|
1697
|
+
return out;
|
|
1698
|
+
}
|
|
1699
|
+
function transformPosition(position, matrix) {
|
|
1700
|
+
const x = (matrix[0] ?? 1) * position[0] + (matrix[4] ?? 0) * position[1] + (matrix[8] ?? 0) * position[2] + (matrix[12] ?? 0);
|
|
1701
|
+
const y = (matrix[1] ?? 0) * position[0] + (matrix[5] ?? 1) * position[1] + (matrix[9] ?? 0) * position[2] + (matrix[13] ?? 0);
|
|
1702
|
+
const z = (matrix[2] ?? 0) * position[0] + (matrix[6] ?? 0) * position[1] + (matrix[10] ?? 1) * position[2] + (matrix[14] ?? 0);
|
|
1703
|
+
const w = (matrix[3] ?? 0) * position[0] + (matrix[7] ?? 0) * position[1] + (matrix[11] ?? 0) * position[2] + (matrix[15] ?? 1);
|
|
1704
|
+
const inverseW = Math.abs(w) > 1e-8 ? 1 / w : 1;
|
|
1705
|
+
return [
|
|
1706
|
+
x * inverseW,
|
|
1707
|
+
y * inverseW,
|
|
1708
|
+
z * inverseW
|
|
1709
|
+
];
|
|
1710
|
+
}
|
|
1711
|
+
function toDepth(ndcZ) {
|
|
1712
|
+
return Math.max(0, Math.min(1, ndcZ * 0.5 + 0.5));
|
|
1713
|
+
}
|
|
1714
|
+
function passesDepthTest(target, pixelIndex, depth, enabled, write) {
|
|
1715
|
+
if (!enabled || !target.depthPixels)
|
|
1716
|
+
return true;
|
|
1717
|
+
if (depth > (target.depthPixels[pixelIndex] ?? 1) + 1e-6)
|
|
1718
|
+
return false;
|
|
1719
|
+
if (write)
|
|
1720
|
+
target.depthPixels[pixelIndex] = depth;
|
|
1721
|
+
return true;
|
|
1722
|
+
}
|
|
1723
|
+
function readPosition(bytes, stride, offset, vertexIndex) {
|
|
1724
|
+
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
1725
|
+
const base = vertexIndex * stride + offset;
|
|
1726
|
+
return [
|
|
1727
|
+
view.getFloat32(base, true),
|
|
1728
|
+
view.getFloat32(base + 4, true),
|
|
1729
|
+
view.getFloat32(base + 8, true)
|
|
1730
|
+
];
|
|
1731
|
+
}
|
|
1732
|
+
function readMorphedPosition(bytes, stride, offset, vertexIndex, uniforms) {
|
|
1733
|
+
const basePosition = readPosition(bytes, stride, offset, vertexIndex);
|
|
1734
|
+
const packed = uniforms?.get("u_morphPositionDeltas");
|
|
1735
|
+
const weights = uniforms?.get("u_morphWeights");
|
|
1736
|
+
const targetCountValue = uniforms?.get("u_morphTargetCount");
|
|
1737
|
+
if (!(packed instanceof Float32Array) || !(weights instanceof Float32Array) || typeof targetCountValue !== "number") {
|
|
1738
|
+
return basePosition;
|
|
1739
|
+
}
|
|
1740
|
+
const targetCount = Math.max(0, Math.min(weights.length, Math.floor(targetCountValue)));
|
|
1741
|
+
let x = basePosition[0];
|
|
1742
|
+
let y = basePosition[1];
|
|
1743
|
+
let z = basePosition[2];
|
|
1744
|
+
for (let target = 0; target < targetCount; target += 1) {
|
|
1745
|
+
const weight = weights[target] ?? 0;
|
|
1746
|
+
const deltaOffset = (target * 64 + vertexIndex) * 4;
|
|
1747
|
+
x += (packed[deltaOffset] ?? 0) * weight;
|
|
1748
|
+
y += (packed[deltaOffset + 1] ?? 0) * weight;
|
|
1749
|
+
z += (packed[deltaOffset + 2] ?? 0) * weight;
|
|
1750
|
+
}
|
|
1751
|
+
return [x, y, z];
|
|
1752
|
+
}
|
|
1753
|
+
function toPixel(position, width, height) {
|
|
1754
|
+
return [
|
|
1755
|
+
(position[0] * 0.5 + 0.5) * (width - 1),
|
|
1756
|
+
(1 - (position[1] * 0.5 + 0.5)) * (height - 1),
|
|
1757
|
+
toDepth(position[2])
|
|
1758
|
+
];
|
|
1759
|
+
}
|
|
1760
|
+
function identityMatrix() {
|
|
1761
|
+
return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
|
|
1762
|
+
}
|
|
1763
|
+
function readVertexColor(bytes, stride, offset, vertexIndex) {
|
|
1764
|
+
if (offset === undefined)
|
|
1765
|
+
return [1, 1, 1, 1];
|
|
1766
|
+
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
1767
|
+
const base = vertexIndex * stride + offset;
|
|
1768
|
+
return [
|
|
1769
|
+
view.getFloat32(base, true),
|
|
1770
|
+
view.getFloat32(base + 4, true),
|
|
1771
|
+
view.getFloat32(base + 8, true),
|
|
1772
|
+
view.getFloat32(base + 12, true)
|
|
1773
|
+
];
|
|
1774
|
+
}
|
|
1775
|
+
function readVertexUv(bytes, stride, offset, vertexIndex) {
|
|
1776
|
+
if (offset === undefined)
|
|
1777
|
+
return [0, 0];
|
|
1778
|
+
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
1779
|
+
const base = vertexIndex * stride + offset;
|
|
1780
|
+
return [view.getFloat32(base, true), view.getFloat32(base + 4, true)];
|
|
1781
|
+
}
|
|
1782
|
+
function rasterizeTriangle(target, a, b, c, worldA, worldB, worldC, color, colorA, colorB, colorC, uvA, uvB, uvC, texture, shadow, depthTest, depthWrite) {
|
|
1783
|
+
const pa = toPixel(a, target.width, target.height);
|
|
1784
|
+
const pb = toPixel(b, target.width, target.height);
|
|
1785
|
+
const pc = toPixel(c, target.width, target.height);
|
|
1786
|
+
const minX = clampInt(Math.floor(Math.min(pa[0], pb[0], pc[0])), 0, target.width - 1);
|
|
1787
|
+
const maxX = clampInt(Math.ceil(Math.max(pa[0], pb[0], pc[0])), 0, target.width - 1);
|
|
1788
|
+
const minY = clampInt(Math.floor(Math.min(pa[1], pb[1], pc[1])), 0, target.height - 1);
|
|
1789
|
+
const maxY = clampInt(Math.ceil(Math.max(pa[1], pb[1], pc[1])), 0, target.height - 1);
|
|
1790
|
+
const area = edge(pa, pb, pc);
|
|
1791
|
+
if (Math.abs(area) < 1e-6)
|
|
1792
|
+
return;
|
|
1793
|
+
for (let y = minY; y <= maxY; y += 1) {
|
|
1794
|
+
for (let x = minX; x <= maxX; x += 1) {
|
|
1795
|
+
const p = [x + 0.5, y + 0.5];
|
|
1796
|
+
const w0 = edge(pb, pc, p);
|
|
1797
|
+
const w1 = edge(pc, pa, p);
|
|
1798
|
+
const w2 = edge(pa, pb, p);
|
|
1799
|
+
if ((w0 >= 0 && w1 >= 0 && w2 >= 0) || (w0 <= 0 && w1 <= 0 && w2 <= 0)) {
|
|
1800
|
+
const invArea = 1 / area;
|
|
1801
|
+
const wa = w0 * invArea;
|
|
1802
|
+
const wb = w1 * invArea;
|
|
1803
|
+
const wc = w2 * invArea;
|
|
1804
|
+
const uv = [
|
|
1805
|
+
uvA[0] * wa + uvB[0] * wb + uvC[0] * wc,
|
|
1806
|
+
uvA[1] * wa + uvB[1] * wb + uvC[1] * wc
|
|
1807
|
+
];
|
|
1808
|
+
const worldPosition = [
|
|
1809
|
+
worldA[0] * wa + worldB[0] * wb + worldC[0] * wc,
|
|
1810
|
+
worldA[1] * wa + worldB[1] * wb + worldC[1] * wc,
|
|
1811
|
+
worldA[2] * wa + worldB[2] * wb + worldC[2] * wc
|
|
1812
|
+
];
|
|
1813
|
+
const pixelIndex = y * target.width + x;
|
|
1814
|
+
const depth = pa[2] * wa + pb[2] * wb + pc[2] * wc;
|
|
1815
|
+
if (!passesDepthTest(target, pixelIndex, depth, depthTest, depthWrite))
|
|
1816
|
+
continue;
|
|
1817
|
+
const shadedColor = multiplyColor(multiplyColor(color, interpolateColor(colorA, colorB, colorC, wa, wb, wc)), texture ? sampleTextureBinding(texture, uv) : [1, 1, 1, 1]);
|
|
1818
|
+
target.colorPixels.set(rgbaBytes(multiplyColor(shadedColor, shadowFactor(shadow, worldPosition))), pixelIndex * 4);
|
|
1819
|
+
}
|
|
1820
|
+
}
|
|
1821
|
+
}
|
|
1822
|
+
}
|
|
1823
|
+
function rasterizeLine(target, a, b, color, colorA, colorB, depthTest, depthWrite) {
|
|
1824
|
+
const pa = toPixel(a, target.width, target.height);
|
|
1825
|
+
const pb = toPixel(b, target.width, target.height);
|
|
1826
|
+
const x0 = clampInt(Math.round(pa[0]), 0, target.width - 1);
|
|
1827
|
+
const y0 = clampInt(Math.round(pa[1]), 0, target.height - 1);
|
|
1828
|
+
const x1 = clampInt(Math.round(pb[0]), 0, target.width - 1);
|
|
1829
|
+
const y1 = clampInt(Math.round(pb[1]), 0, target.height - 1);
|
|
1830
|
+
const dx = Math.abs(x1 - x0);
|
|
1831
|
+
const dy = Math.abs(y1 - y0);
|
|
1832
|
+
const steps = Math.max(dx, dy, 1);
|
|
1833
|
+
const shadedA = multiplyColor(color, colorA);
|
|
1834
|
+
const shadedB = multiplyColor(color, colorB);
|
|
1835
|
+
for (let step = 0; step <= steps; step += 1) {
|
|
1836
|
+
const t = step / steps;
|
|
1837
|
+
const x = clampInt(Math.round(x0 + (x1 - x0) * t), 0, target.width - 1);
|
|
1838
|
+
const y = clampInt(Math.round(y0 + (y1 - y0) * t), 0, target.height - 1);
|
|
1839
|
+
const pixelIndex = y * target.width + x;
|
|
1840
|
+
const depth = pa[2] + (pb[2] - pa[2]) * t;
|
|
1841
|
+
if (!passesDepthTest(target, pixelIndex, depth, depthTest, depthWrite))
|
|
1842
|
+
continue;
|
|
1843
|
+
const shaded = lerpColor(shadedA, shadedB, t);
|
|
1844
|
+
target.colorPixels.set(rgbaBytes(shaded), pixelIndex * 4);
|
|
1845
|
+
}
|
|
1846
|
+
}
|
|
1847
|
+
function rasterizePoint(target, point, color, depthTest, depthWrite) {
|
|
1848
|
+
const pixel = toPixel(point, target.width, target.height);
|
|
1849
|
+
const centerX = clampInt(Math.round(pixel[0]), 0, target.width - 1);
|
|
1850
|
+
const centerY = clampInt(Math.round(pixel[1]), 0, target.height - 1);
|
|
1851
|
+
const bytes = rgbaBytes(color);
|
|
1852
|
+
for (let y = centerY - 2; y <= centerY + 2; y += 1) {
|
|
1853
|
+
if (y < 0 || y >= target.height)
|
|
1854
|
+
continue;
|
|
1855
|
+
for (let x = centerX - 2; x <= centerX + 2; x += 1) {
|
|
1856
|
+
if (x < 0 || x >= target.width)
|
|
1857
|
+
continue;
|
|
1858
|
+
const pixelIndex = y * target.width + x;
|
|
1859
|
+
if (!passesDepthTest(target, pixelIndex, pixel[2], depthTest, depthWrite))
|
|
1860
|
+
continue;
|
|
1861
|
+
target.colorPixels.set(bytes, pixelIndex * 4);
|
|
1862
|
+
}
|
|
1863
|
+
}
|
|
1864
|
+
}
|
|
1865
|
+
function sampleTextureBinding(binding, uv) {
|
|
1866
|
+
const texture = binding.texture;
|
|
1867
|
+
if (!texture || texture.disposed)
|
|
1868
|
+
return [1, 1, 1, 1];
|
|
1869
|
+
const level = texture.textureLevels[0] ?? texture.fallbackTextureLevels[0];
|
|
1870
|
+
if (!level || level.data.length < level.width * level.height * 4)
|
|
1871
|
+
return [1, 1, 1, 1];
|
|
1872
|
+
const transformed = binding.transformUV(uv);
|
|
1873
|
+
const u = addressCoordinate(transformed[0], binding.sampler.addressU);
|
|
1874
|
+
const v = addressCoordinate(transformed[1], binding.sampler.addressV);
|
|
1875
|
+
const x = clampInt(Math.round(u * (level.width - 1)), 0, level.width - 1);
|
|
1876
|
+
const y = clampInt(Math.round(v * (level.height - 1)), 0, level.height - 1);
|
|
1877
|
+
const offset = (y * level.width + x) * 4;
|
|
1878
|
+
const r = (level.data[offset] ?? 255) / 255;
|
|
1879
|
+
const g = (level.data[offset + 1] ?? 255) / 255;
|
|
1880
|
+
const b = (level.data[offset + 2] ?? 255) / 255;
|
|
1881
|
+
return [
|
|
1882
|
+
texture.colorSpace === "srgb" ? srgbToLinear(r) : r,
|
|
1883
|
+
texture.colorSpace === "srgb" ? srgbToLinear(g) : g,
|
|
1884
|
+
texture.colorSpace === "srgb" ? srgbToLinear(b) : b,
|
|
1885
|
+
(level.data[offset + 3] ?? 255) / 255
|
|
1886
|
+
];
|
|
1887
|
+
}
|
|
1888
|
+
function srgbToLinear(value) {
|
|
1889
|
+
return value <= 0.04045 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4;
|
|
1890
|
+
}
|
|
1891
|
+
function shadowFactor(shadow, worldPosition) {
|
|
1892
|
+
if (!shadow)
|
|
1893
|
+
return [1, 1, 1, 1];
|
|
1894
|
+
const projected = transformPosition(worldPosition, shadow.matrix);
|
|
1895
|
+
if (projected[0] < -1 || projected[0] > 1 || projected[1] < -1 || projected[1] > 1 || projected[2] < -1 || projected[2] > 1) {
|
|
1896
|
+
return [1, 1, 1, 1];
|
|
1897
|
+
}
|
|
1898
|
+
const uv = [projected[0] * 0.5 + 0.5, projected[1] * 0.5 + 0.5];
|
|
1899
|
+
const storedDepth = sampleTextureBinding(shadow.texture, uv)[0];
|
|
1900
|
+
const receiverDepth = projected[2] * 0.5 + 0.5 - shadow.bias;
|
|
1901
|
+
const visibility = receiverDepth > storedDepth ? 1 - shadow.strength : 1;
|
|
1902
|
+
return [visibility, visibility, visibility, 1];
|
|
1903
|
+
}
|
|
1904
|
+
function addressCoordinate(value, mode) {
|
|
1905
|
+
if (mode === "repeat")
|
|
1906
|
+
return value - Math.floor(value);
|
|
1907
|
+
if (mode === "mirror-repeat") {
|
|
1908
|
+
const repeated = value - Math.floor(value);
|
|
1909
|
+
return Math.floor(value) % 2 === 0 ? repeated : 1 - repeated;
|
|
1910
|
+
}
|
|
1911
|
+
return Math.min(1, Math.max(0, value));
|
|
1912
|
+
}
|
|
1913
|
+
function lerpColor(a, b, t) {
|
|
1914
|
+
return [
|
|
1915
|
+
a[0] + (b[0] - a[0]) * t,
|
|
1916
|
+
a[1] + (b[1] - a[1]) * t,
|
|
1917
|
+
a[2] + (b[2] - a[2]) * t,
|
|
1918
|
+
a[3] + (b[3] - a[3]) * t
|
|
1919
|
+
];
|
|
1920
|
+
}
|
|
1921
|
+
function interpolateColor(a, b, c, wa, wb, wc) {
|
|
1922
|
+
return [
|
|
1923
|
+
a[0] * wa + b[0] * wb + c[0] * wc,
|
|
1924
|
+
a[1] * wa + b[1] * wb + c[1] * wc,
|
|
1925
|
+
a[2] * wa + b[2] * wb + c[2] * wc,
|
|
1926
|
+
a[3] * wa + b[3] * wb + c[3] * wc
|
|
1927
|
+
];
|
|
1928
|
+
}
|
|
1929
|
+
function multiplyColor(a, b) {
|
|
1930
|
+
return [a[0] * b[0], a[1] * b[1], a[2] * b[2], a[3] * b[3]];
|
|
1931
|
+
}
|
|
1932
|
+
function edge(a, b, c) {
|
|
1933
|
+
return (c[0] - a[0]) * (b[1] - a[1]) - (c[1] - a[1]) * (b[0] - a[0]);
|
|
1934
|
+
}
|
|
1935
|
+
function clampInt(value, min, max) {
|
|
1936
|
+
return Math.min(max, Math.max(min, value));
|
|
1937
|
+
}
|
|
1938
|
+
function createNativeShaderSources(sources) {
|
|
1939
|
+
const vertexEntry = inferWGSLVertexEntryPoint(sources.vertex) ?? "vs_main";
|
|
1940
|
+
const fragmentEntry = inferWGSLFragmentEntryPoint(sources.fragment) ?? "fs_main";
|
|
1941
|
+
if (/\@(vertex|fragment|compute)\b/.test(sources.vertex) || /\@(vertex|fragment|compute)\b/.test(sources.fragment)) {
|
|
1942
|
+
return { vertex: sources.vertex, fragment: sources.fragment, entryPoints: [vertexEntry, fragmentEntry], uniformLayout: "passthrough" };
|
|
1943
|
+
}
|
|
1944
|
+
if (sources.marker.includes("instanced-pbr")) {
|
|
1945
|
+
return { ...nativeInstancedPbrShader(vertexEntry, fragmentEntry, sources.marker), entryPoints: [vertexEntry, fragmentEntry], uniformLayout: "generated-instanced-pbr" };
|
|
1946
|
+
}
|
|
1947
|
+
if (sources.marker.includes("pbr-textured")) {
|
|
1948
|
+
return { ...nativeTexturedPbrShader(vertexEntry, fragmentEntry, sources.marker, nativeShaderUsesTangent(sources.vertex)), entryPoints: [vertexEntry, fragmentEntry], uniformLayout: "generated-textured-pbr" };
|
|
1949
|
+
}
|
|
1950
|
+
if (sources.marker.includes("pbr-direct")) {
|
|
1951
|
+
return sources.fragment.includes("u_baseColorTexture")
|
|
1952
|
+
? { ...nativeTexturedPbrShader(vertexEntry, fragmentEntry, sources.marker, nativeShaderUsesTangent(sources.vertex)), entryPoints: [vertexEntry, fragmentEntry], uniformLayout: "generated-textured-pbr" }
|
|
1953
|
+
: { ...nativePbrShader(vertexEntry, fragmentEntry, sources.marker), entryPoints: [vertexEntry, fragmentEntry], uniformLayout: "generated-pbr" };
|
|
1954
|
+
}
|
|
1955
|
+
if (sources.marker.includes("skinned-unlit")) {
|
|
1956
|
+
return { ...nativeSkinnedUnlitShader(vertexEntry, fragmentEntry, sources.marker), entryPoints: [vertexEntry, fragmentEntry], uniformLayout: "generated-skinned-unlit" };
|
|
1957
|
+
}
|
|
1958
|
+
if (sources.marker.includes("morph-unlit")) {
|
|
1959
|
+
return { ...nativeMorphUnlitShader(vertexEntry, fragmentEntry, sources.marker), entryPoints: [vertexEntry, fragmentEntry], uniformLayout: "generated-morph-unlit" };
|
|
1960
|
+
}
|
|
1961
|
+
if (/sampler2D/.test(sources.fragment) && /layout\s*\(\s*location\s*=\s*2\s*\)\s*in\s+vec2/.test(sources.vertex)) {
|
|
1962
|
+
return {
|
|
1963
|
+
vertex: `// ${sources.marker}\nstruct DrawUniforms {\n modelViewProjection: mat4x4<f32>,\n color: vec4<f32>,\n};\n\nstruct VertexOutput {\n @builtin(position) position: vec4<f32>,\n @location(0) uv: vec2<f32>,\n};\n\n@group(0) @binding(0) var<uniform> u_draw: DrawUniforms;\n\n@vertex\nfn ${vertexEntry}(@location(0) position: vec3<f32>, @location(2) uv: vec2<f32>) -> VertexOutput {\n var output: VertexOutput;\n let clipPosition = u_draw.modelViewProjection * vec4<f32>(position, 1.0);
|
|
1964
|
+
output.position = vec4<f32>(clipPosition.x, clipPosition.y, clipPosition.z * 0.5 + clipPosition.w * 0.5, clipPosition.w);\n output.uv = uv;\n return output;\n}\n`,
|
|
1965
|
+
fragment: `// ${sources.marker}\nstruct DrawUniforms {\n modelViewProjection: mat4x4<f32>,\n color: vec4<f32>,\n};\n\nstruct VertexOutput {\n @builtin(position) position: vec4<f32>,\n @location(0) uv: vec2<f32>,\n};\n\n@group(0) @binding(0) var<uniform> u_draw: DrawUniforms;\n@group(0) @binding(1) var u_textureSampler: sampler;\n@group(0) @binding(2) var u_texture: texture_2d<f32>;\n\n@fragment\nfn ${fragmentEntry}(input: VertexOutput) -> @location(0) vec4<f32> {\n return u_draw.color * textureSample(u_texture, u_textureSampler, input.uv);\n}\n`,
|
|
1966
|
+
entryPoints: [vertexEntry, fragmentEntry],
|
|
1967
|
+
uniformLayout: "generated-texture"
|
|
1968
|
+
};
|
|
1969
|
+
}
|
|
1970
|
+
return {
|
|
1971
|
+
vertex: `// ${sources.marker}\nstruct DrawUniforms {\n modelViewProjection: mat4x4<f32>,\n color: vec4<f32>,\n};\n\nstruct VertexOutput {\n @builtin(position) position: vec4<f32>,\n};\n\n@group(0) @binding(0) var<uniform> u_draw: DrawUniforms;\n\n@vertex\nfn ${vertexEntry}(@location(0) position: vec3<f32>) -> VertexOutput {\n var output: VertexOutput;\n let clipPosition = u_draw.modelViewProjection * vec4<f32>(position, 1.0);
|
|
1972
|
+
output.position = vec4<f32>(clipPosition.x, clipPosition.y, clipPosition.z * 0.5 + clipPosition.w * 0.5, clipPosition.w);\n return output;\n}\n`,
|
|
1973
|
+
fragment: `// ${sources.marker}\nstruct DrawUniforms {\n modelViewProjection: mat4x4<f32>,\n color: vec4<f32>,\n};\n\n@group(0) @binding(0) var<uniform> u_draw: DrawUniforms;\n\n@fragment\nfn ${fragmentEntry}() -> @location(0) vec4<f32> {\n return u_draw.color;\n}\n`,
|
|
1974
|
+
entryPoints: [vertexEntry, fragmentEntry],
|
|
1975
|
+
uniformLayout: "generated-basic"
|
|
1976
|
+
};
|
|
1977
|
+
}
|
|
1978
|
+
function nativeUniformStruct() {
|
|
1979
|
+
return `struct DrawUniforms {
|
|
1980
|
+
modelViewProjection: mat4x4<f32>,
|
|
1981
|
+
color: vec4<f32>,
|
|
1982
|
+
params: vec4<f32>,
|
|
1983
|
+
flags: vec4<f32>,
|
|
1984
|
+
reserved0: vec4<f32>,
|
|
1985
|
+
instance0: mat4x4<f32>,
|
|
1986
|
+
instance1: mat4x4<f32>,
|
|
1987
|
+
instance2: mat4x4<f32>,
|
|
1988
|
+
instance3: mat4x4<f32>,
|
|
1989
|
+
joint0: mat4x4<f32>,
|
|
1990
|
+
joint1: mat4x4<f32>,
|
|
1991
|
+
morph0: vec4<f32>,
|
|
1992
|
+
morph1: vec4<f32>,
|
|
1993
|
+
morph2: vec4<f32>,
|
|
1994
|
+
morph3: vec4<f32>,
|
|
1995
|
+
morph4: vec4<f32>,
|
|
1996
|
+
morph5: vec4<f32>,
|
|
1997
|
+
morph6: vec4<f32>,
|
|
1998
|
+
morph7: vec4<f32>,
|
|
1999
|
+
material: vec4<f32>,
|
|
2000
|
+
camera: vec4<f32>,
|
|
2001
|
+
materialFlags: vec4<f32>,
|
|
2002
|
+
normalMatrix: mat4x4<f32>,
|
|
2003
|
+
};
|
|
2004
|
+
|
|
2005
|
+
@group(0) @binding(0) var<uniform> u_draw: DrawUniforms;
|
|
2006
|
+
|
|
2007
|
+
fn a3dWebGPUClipPosition(clipPosition: vec4<f32>) -> vec4<f32> {
|
|
2008
|
+
return vec4<f32>(clipPosition.x, clipPosition.y, clipPosition.z * 0.5 + clipPosition.w * 0.5, clipPosition.w);
|
|
2009
|
+
}
|
|
2010
|
+
`;
|
|
2011
|
+
}
|
|
2012
|
+
function nativeShaderUsesTangent(vertexSource) {
|
|
2013
|
+
return /\ba_tangent\b/.test(vertexSource) || /layout\s*\(\s*location\s*=\s*3\s*\)\s*in\s+vec4/.test(vertexSource);
|
|
2014
|
+
}
|
|
2015
|
+
function nativePbrFragmentPrelude(marker) {
|
|
2016
|
+
return `// ${marker}
|
|
2017
|
+
${nativeUniformStruct()}
|
|
2018
|
+
@group(0) @binding(1) var u_baseSampler: sampler;
|
|
2019
|
+
@group(0) @binding(2) var u_baseTexture: texture_2d<f32>;
|
|
2020
|
+
@group(0) @binding(3) var u_environmentSampler: sampler;
|
|
2021
|
+
@group(0) @binding(4) var u_environmentTexture: texture_2d<f32>;
|
|
2022
|
+
@group(0) @binding(5) var u_brdfSampler: sampler;
|
|
2023
|
+
@group(0) @binding(6) var u_brdfTexture: texture_2d<f32>;
|
|
2024
|
+
@group(0) @binding(7) var u_shadowSampler: sampler;
|
|
2025
|
+
@group(0) @binding(8) var u_shadowTexture: texture_2d<f32>;
|
|
2026
|
+
@group(0) @binding(9) var u_normalSampler: sampler;
|
|
2027
|
+
@group(0) @binding(10) var u_normalTexture: texture_2d<f32>;
|
|
2028
|
+
@group(0) @binding(11) var u_metallicRoughnessSampler: sampler;
|
|
2029
|
+
@group(0) @binding(12) var u_metallicRoughnessTexture: texture_2d<f32>;
|
|
2030
|
+
@group(0) @binding(13) var u_occlusionSampler: sampler;
|
|
2031
|
+
@group(0) @binding(14) var u_occlusionTexture: texture_2d<f32>;
|
|
2032
|
+
|
|
2033
|
+
struct VertexOutput {
|
|
2034
|
+
@builtin(position) position: vec4<f32>,
|
|
2035
|
+
@location(0) normal: vec3<f32>,
|
|
2036
|
+
@location(1) uv: vec2<f32>,
|
|
2037
|
+
@location(2) worldPosition: vec3<f32>,
|
|
2038
|
+
@location(3) tangent: vec4<f32>,
|
|
2039
|
+
};
|
|
2040
|
+
|
|
2041
|
+
fn fresnelSchlick(cosTheta: f32, f0: vec3<f32>) -> vec3<f32> {
|
|
2042
|
+
return f0 + (vec3<f32>(1.0, 1.0, 1.0) - f0) * pow(clamp(1.0 - cosTheta, 0.0, 1.0), 5.0);
|
|
2043
|
+
}
|
|
2044
|
+
|
|
2045
|
+
fn fresnelSchlickRoughness(cosTheta: f32, f0: vec3<f32>, roughness: f32) -> vec3<f32> {
|
|
2046
|
+
let smoothness = 1.0 - clamp(roughness, 0.0, 1.0);
|
|
2047
|
+
return f0 + (max(vec3<f32>(smoothness, smoothness, smoothness), f0) - f0) * pow(clamp(1.0 - cosTheta, 0.0, 1.0), 5.0);
|
|
2048
|
+
}
|
|
2049
|
+
|
|
2050
|
+
fn ggxDistribution(nDotH: f32, roughness: f32) -> f32 {
|
|
2051
|
+
let a = max(roughness * roughness, 0.045);
|
|
2052
|
+
let a2 = a * a;
|
|
2053
|
+
let denom = max((nDotH * nDotH) * (a2 - 1.0) + 1.0, 0.001);
|
|
2054
|
+
return a2 / max(3.14159265 * denom * denom, 0.001);
|
|
2055
|
+
}
|
|
2056
|
+
|
|
2057
|
+
fn ggxVisibilitySmithCorrelated(nDotV: f32, nDotL: f32, roughness: f32) -> f32 {
|
|
2058
|
+
let a = max(roughness * roughness, 0.045);
|
|
2059
|
+
let a2 = a * a;
|
|
2060
|
+
let lambdaV = nDotL * sqrt(max((nDotV - a2 * nDotV) * nDotV + a2, 0.00001));
|
|
2061
|
+
let lambdaL = nDotV * sqrt(max((nDotL - a2 * nDotL) * nDotL + a2, 0.00001));
|
|
2062
|
+
return 0.5 / max(lambdaV + lambdaL, 0.00001);
|
|
2063
|
+
}
|
|
2064
|
+
|
|
2065
|
+
fn diffuseBurley(nDotV: f32, nDotL: f32, lDotH: f32, roughness: f32) -> f32 {
|
|
2066
|
+
let energyBias = mix(0.0, 0.5, roughness);
|
|
2067
|
+
let energyFactor = mix(1.0, 1.0 / 1.51, roughness);
|
|
2068
|
+
let fd90 = energyBias + 2.0 * lDotH * lDotH * roughness;
|
|
2069
|
+
let lightScatter = 1.0 + (fd90 - 1.0) * pow(clamp(1.0 - nDotL, 0.0, 1.0), 5.0);
|
|
2070
|
+
let viewScatter = 1.0 + (fd90 - 1.0) * pow(clamp(1.0 - nDotV, 0.0, 1.0), 5.0);
|
|
2071
|
+
return lightScatter * viewScatter * energyFactor;
|
|
2072
|
+
}
|
|
2073
|
+
|
|
2074
|
+
fn encodePbrOutput(linearColor: vec3<f32>) -> vec3<f32> {
|
|
2075
|
+
let color = max(linearColor, vec3<f32>(0.0, 0.0, 0.0));
|
|
2076
|
+
let filmic = clamp((color * (2.51 * color + vec3<f32>(0.03, 0.03, 0.03))) / (color * (2.43 * color + vec3<f32>(0.59, 0.59, 0.59)) + vec3<f32>(0.14, 0.14, 0.14)), vec3<f32>(0.0, 0.0, 0.0), vec3<f32>(1.0, 1.0, 1.0));
|
|
2077
|
+
return pow(filmic, vec3<f32>(1.0 / 2.2, 1.0 / 2.2, 1.0 / 2.2));
|
|
2078
|
+
}
|
|
2079
|
+
|
|
2080
|
+
fn productPropBodyGate(baseColor: vec3<f32>, strength: f32) -> f32 {
|
|
2081
|
+
let maxChannel = max(max(baseColor.r, baseColor.g), baseColor.b);
|
|
2082
|
+
let minChannel = min(min(baseColor.r, baseColor.g), baseColor.b);
|
|
2083
|
+
let normalized = baseColor / max(maxChannel, 0.001);
|
|
2084
|
+
let warm = clamp(strength, 0.0, 1.0)
|
|
2085
|
+
* smoothstep(0.18, 0.42, maxChannel)
|
|
2086
|
+
* smoothstep(0.04, 0.2, maxChannel - minChannel)
|
|
2087
|
+
* smoothstep(0.64, 0.84, normalized.r)
|
|
2088
|
+
* (1.0 - smoothstep(0.12, 0.32, normalized.b));
|
|
2089
|
+
return warm * smoothstep(0.46, 0.64, normalized.g) * (1.0 - smoothstep(0.74, 0.94, normalized.b));
|
|
2090
|
+
}
|
|
2091
|
+
|
|
2092
|
+
fn productPropOrangeGate(baseColor: vec3<f32>, strength: f32) -> f32 {
|
|
2093
|
+
let maxChannel = max(max(baseColor.r, baseColor.g), baseColor.b);
|
|
2094
|
+
let minChannel = min(min(baseColor.r, baseColor.g), baseColor.b);
|
|
2095
|
+
let normalized = baseColor / max(maxChannel, 0.001);
|
|
2096
|
+
let warm = clamp(strength, 0.0, 1.0)
|
|
2097
|
+
* smoothstep(0.32, 0.58, maxChannel)
|
|
2098
|
+
* smoothstep(0.05, 0.24, maxChannel - minChannel)
|
|
2099
|
+
* smoothstep(0.68, 0.88, normalized.r)
|
|
2100
|
+
* (1.0 - smoothstep(0.1, 0.28, normalized.b));
|
|
2101
|
+
return warm * (1.0 - smoothstep(0.34, 0.58, normalized.g)) * smoothstep(0.012, 0.08, baseColor.g);
|
|
2102
|
+
}
|
|
2103
|
+
|
|
2104
|
+
fn productPropAlbedo(baseColor: vec3<f32>, strength: f32) -> vec3<f32> {
|
|
2105
|
+
let orangeGate = productPropOrangeGate(baseColor, strength);
|
|
2106
|
+
let bodyGate = productPropBodyGate(baseColor, strength) * (1.0 - orangeGate * 0.92);
|
|
2107
|
+
let maxChannel = max(max(baseColor.r, baseColor.g), baseColor.b);
|
|
2108
|
+
let bodyLuma = mix(0.98, 1.03, smoothstep(0.24, 0.9, maxChannel));
|
|
2109
|
+
let beakLuma = mix(0.94, 1.02, smoothstep(0.2, 0.82, maxChannel));
|
|
2110
|
+
var color = mix(baseColor, vec3<f32>(1.0, 0.88, 0.012) * bodyLuma, clamp(bodyGate * 0.995, 0.0, 0.995));
|
|
2111
|
+
color = mix(color, vec3<f32>(1.0, 0.24, 0.018) * beakLuma, clamp(orangeGate * 0.99, 0.0, 0.99));
|
|
2112
|
+
return color;
|
|
2113
|
+
}
|
|
2114
|
+
|
|
2115
|
+
fn perturbNormal(normalInput: vec3<f32>, tangentFrame: vec4<f32>, normalSample: vec3<f32>, normalScale: f32) -> vec3<f32> {
|
|
2116
|
+
let n = normalize(normalInput);
|
|
2117
|
+
let tangent = normalize(tangentFrame.xyz);
|
|
2118
|
+
let bitangent = normalize(cross(n, tangent) * tangentFrame.w);
|
|
2119
|
+
let mapped = vec3<f32>((normalSample.xy * 2.0 - vec2<f32>(1.0, 1.0)) * max(normalScale, 0.0), normalSample.z * 2.0 - 1.0);
|
|
2120
|
+
return normalize(tangent * mapped.x + bitangent * mapped.y + n * max(mapped.z, 0.001));
|
|
2121
|
+
}
|
|
2122
|
+
|
|
2123
|
+
fn shadePbr(normalInput: vec3<f32>, tangentFrame: vec4<f32>, uv: vec2<f32>, worldPosition: vec3<f32>) -> vec4<f32> {
|
|
2124
|
+
var normal = normalize(normalInput);
|
|
2125
|
+
if (u_draw.morph0.x > 0.5) {
|
|
2126
|
+
normal = perturbNormal(normal, tangentFrame, textureSample(u_normalTexture, u_normalSampler, uv).rgb, u_draw.morph0.y);
|
|
2127
|
+
}
|
|
2128
|
+
let viewDirection = normalize(u_draw.camera.xyz - worldPosition);
|
|
2129
|
+
let lightDirection = normalize(vec3<f32>(0.36, 0.52, 0.78));
|
|
2130
|
+
let halfVector = normalize(lightDirection + viewDirection);
|
|
2131
|
+
var baseColor = u_draw.color.rgb;
|
|
2132
|
+
var materialAlpha = u_draw.color.a;
|
|
2133
|
+
if (u_draw.flags.x > 0.5) {
|
|
2134
|
+
let baseSample = textureSample(u_baseTexture, u_baseSampler, uv);
|
|
2135
|
+
baseColor = baseColor * baseSample.rgb;
|
|
2136
|
+
materialAlpha = materialAlpha * baseSample.a;
|
|
2137
|
+
}
|
|
2138
|
+
let sourceProductBaseColor = baseColor;
|
|
2139
|
+
let productOrangeGate = productPropOrangeGate(sourceProductBaseColor, u_draw.materialFlags.z);
|
|
2140
|
+
let productBodyGate = productPropBodyGate(sourceProductBaseColor, u_draw.materialFlags.z) * (1.0 - productOrangeGate * 0.92);
|
|
2141
|
+
let productSurfaceGate = clamp(productBodyGate + productOrangeGate * 0.72, 0.0, 1.0);
|
|
2142
|
+
baseColor = productPropAlbedo(sourceProductBaseColor, u_draw.materialFlags.z);
|
|
2143
|
+
if (materialAlpha < u_draw.material.x) {
|
|
2144
|
+
discard;
|
|
2145
|
+
}
|
|
2146
|
+
let transmission = clamp(max(u_draw.material.y, u_draw.material.z), 0.0, 1.0);
|
|
2147
|
+
let metallicRoughnessSample = textureSample(u_metallicRoughnessTexture, u_metallicRoughnessSampler, uv);
|
|
2148
|
+
let metallicRoughnessEnabled = step(0.5, u_draw.materialFlags.x);
|
|
2149
|
+
let occlusionEnabled = step(0.5, u_draw.materialFlags.y);
|
|
2150
|
+
let sampledMetallic = clamp(u_draw.params.x * metallicRoughnessSample.b, 0.0, 1.0);
|
|
2151
|
+
let sampledRoughness = clamp(u_draw.params.y * metallicRoughnessSample.g, 0.045, 1.0);
|
|
2152
|
+
let sampledOcclusion = mix(1.0, textureSample(u_occlusionTexture, u_occlusionSampler, uv).r, clamp(u_draw.morph0.z, 0.0, 1.0));
|
|
2153
|
+
let metallic = mix(clamp(u_draw.params.x, 0.0, 1.0), sampledMetallic, metallicRoughnessEnabled);
|
|
2154
|
+
let roughness = mix(clamp(u_draw.params.y, 0.045, 1.0), sampledRoughness, metallicRoughnessEnabled);
|
|
2155
|
+
let occlusion = mix(1.0, sampledOcclusion, occlusionEnabled);
|
|
2156
|
+
let smoothedProductNormal = normalize(vec3<f32>(normal.x * 0.42, max(normal.y, 0.28), normal.z * 0.42));
|
|
2157
|
+
normal = normalize(mix(normal, smoothedProductNormal, productBodyGate * 0.46 + productOrangeGate * 0.84));
|
|
2158
|
+
let nDotL = max(dot(normal, lightDirection), 0.0);
|
|
2159
|
+
let nDotV = max(dot(normal, viewDirection), 0.001);
|
|
2160
|
+
let nDotH = max(dot(normal, halfVector), 0.001);
|
|
2161
|
+
let vDotH = max(dot(viewDirection, halfVector), 0.001);
|
|
2162
|
+
let f0 = mix(vec3<f32>(0.04, 0.04, 0.04), baseColor, metallic);
|
|
2163
|
+
let fresnel = fresnelSchlick(vDotH, f0);
|
|
2164
|
+
let distribution = ggxDistribution(nDotH, roughness);
|
|
2165
|
+
let visibility = ggxVisibilitySmithCorrelated(nDotV, nDotL, roughness);
|
|
2166
|
+
let lDotH = max(dot(lightDirection, halfVector), 0.0);
|
|
2167
|
+
let kd = (vec3<f32>(1.0, 1.0, 1.0) - fresnel) * (1.0 - metallic);
|
|
2168
|
+
let specular = fresnel * distribution * visibility;
|
|
2169
|
+
let diffuse = kd * baseColor * diffuseBurley(nDotV, nDotL, lDotH, roughness) / 3.14159265;
|
|
2170
|
+
var environment = baseColor * u_draw.params.z * (0.28 + 0.72 * clamp(normal.y * 0.5 + 0.5, 0.0, 1.0)) * occlusion;
|
|
2171
|
+
var environmentSpecularContribution = vec3<f32>(0.0, 0.0, 0.0);
|
|
2172
|
+
if (u_draw.flags.w > 0.5) {
|
|
2173
|
+
let reflectionDirection = reflect(-viewDirection, normal);
|
|
2174
|
+
let diffuseUv = vec2<f32>(fract(atan2(normal.z, normal.x) / 6.2831853 + 0.5), acos(clamp(normal.y, -1.0, 1.0)) / 3.14159265);
|
|
2175
|
+
let specularUv = vec2<f32>(fract(atan2(reflectionDirection.z, reflectionDirection.x) / 6.2831853 + 0.5), acos(clamp(reflectionDirection.y, -1.0, 1.0)) / 3.14159265);
|
|
2176
|
+
let environmentMipCount = max(u_draw.reserved0.z, 1.0);
|
|
2177
|
+
let diffuseEnv = textureSampleLevel(u_environmentTexture, u_environmentSampler, diffuseUv, max(environmentMipCount - 1.0, 0.0)).rgb;
|
|
2178
|
+
let specularEnv = textureSampleLevel(u_environmentTexture, u_environmentSampler, specularUv, roughness * max(environmentMipCount - 1.0, 0.0)).rgb;
|
|
2179
|
+
let brdf = textureSampleLevel(u_brdfTexture, u_brdfSampler, vec2<f32>(nDotV, roughness), 0.0).rg;
|
|
2180
|
+
let environmentFresnel = fresnelSchlickRoughness(nDotV, f0, roughness);
|
|
2181
|
+
let environmentDiffuse = (vec3<f32>(1.0, 1.0, 1.0) - environmentFresnel) * (1.0 - metallic) * diffuseEnv * baseColor * u_draw.params.w * occlusion;
|
|
2182
|
+
let environmentSpecular = specularEnv * (f0 * brdf.x + vec3<f32>(brdf.y, brdf.y, brdf.y)) * max(u_draw.reserved0.w, 0.0);
|
|
2183
|
+
environmentSpecularContribution = environmentSpecular;
|
|
2184
|
+
environment = environment + environmentDiffuse + environmentSpecular;
|
|
2185
|
+
}
|
|
2186
|
+
var shadow = 1.0;
|
|
2187
|
+
if (u_draw.flags.y > 0.5) {
|
|
2188
|
+
let shadowDepth = textureSampleLevel(u_shadowTexture, u_shadowSampler, vec2<f32>(0.5, 0.5), 0.0).r;
|
|
2189
|
+
shadow = mix(1.0, shadowDepth, clamp(u_draw.flags.z, 0.0, 1.0));
|
|
2190
|
+
}
|
|
2191
|
+
let litOpaqueLinearColor = environment + (diffuse + specular) * nDotL * 2.25 * shadow;
|
|
2192
|
+
let smoothedBodyColor = mix(baseColor, vec3<f32>(1.0, 0.88, 0.012), productBodyGate * 0.32);
|
|
2193
|
+
let smoothedBeakColor = mix(baseColor, vec3<f32>(1.0, 0.24, 0.018), productOrangeGate * 0.82);
|
|
2194
|
+
let softBodyProduct = smoothedBodyColor * (1.5 + 0.06 * nDotL) + specular * nDotL * 0.018;
|
|
2195
|
+
let softBeakProduct = smoothedBeakColor * (1.08 + 0.05 * nDotL) + specular * nDotL * 0.018;
|
|
2196
|
+
var opaqueLinearColor = mix(litOpaqueLinearColor, softBodyProduct, productBodyGate * 0.78);
|
|
2197
|
+
opaqueLinearColor = mix(opaqueLinearColor, softBeakProduct, productOrangeGate * 0.95);
|
|
2198
|
+
let transmittedTint = baseColor * u_draw.params.w * (0.18 + 0.42 * clamp(1.0 - roughness, 0.0, 1.0)) + environmentSpecularContribution * 1.35;
|
|
2199
|
+
let linearColor = mix(opaqueLinearColor, opaqueLinearColor * 0.22 + transmittedTint, transmission);
|
|
2200
|
+
let outputAlpha = mix(materialAlpha, min(materialAlpha, 0.22), transmission);
|
|
2201
|
+
return vec4<f32>(encodePbrOutput(linearColor), outputAlpha);
|
|
2202
|
+
}
|
|
2203
|
+
`;
|
|
2204
|
+
}
|
|
2205
|
+
function nativePbrShader(vertexEntry, fragmentEntry, marker) {
|
|
2206
|
+
return {
|
|
2207
|
+
vertex: `// ${marker}
|
|
2208
|
+
${nativeUniformStruct()}
|
|
2209
|
+
struct VertexOutput {
|
|
2210
|
+
@builtin(position) position: vec4<f32>,
|
|
2211
|
+
@location(0) normal: vec3<f32>,
|
|
2212
|
+
@location(1) uv: vec2<f32>,
|
|
2213
|
+
@location(2) worldPosition: vec3<f32>,
|
|
2214
|
+
@location(3) tangent: vec4<f32>,
|
|
2215
|
+
};
|
|
2216
|
+
|
|
2217
|
+
@vertex
|
|
2218
|
+
fn ${vertexEntry}(@location(0) position: vec3<f32>, @location(1) normal: vec3<f32>) -> VertexOutput {
|
|
2219
|
+
var output: VertexOutput;
|
|
2220
|
+
let worldPosition = (u_draw.instance0 * vec4<f32>(position, 1.0)).xyz;
|
|
2221
|
+
output.position = a3dWebGPUClipPosition(u_draw.modelViewProjection * vec4<f32>(position, 1.0));
|
|
2222
|
+
output.normal = normalize((u_draw.normalMatrix * vec4<f32>(normal, 0.0)).xyz);
|
|
2223
|
+
output.uv = vec2<f32>(0.5, 0.5);
|
|
2224
|
+
output.worldPosition = worldPosition;
|
|
2225
|
+
output.tangent = vec4<f32>(1.0, 0.0, 0.0, 1.0);
|
|
2226
|
+
return output;
|
|
2227
|
+
}
|
|
2228
|
+
`,
|
|
2229
|
+
fragment: `${nativePbrFragmentPrelude(marker)}
|
|
2230
|
+
@fragment
|
|
2231
|
+
fn ${fragmentEntry}(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
2232
|
+
return shadePbr(input.normal, input.tangent, input.uv, input.worldPosition);
|
|
2233
|
+
}
|
|
2234
|
+
`
|
|
2235
|
+
};
|
|
2236
|
+
}
|
|
2237
|
+
function nativeTexturedPbrShader(vertexEntry, fragmentEntry, marker, usesTangent) {
|
|
2238
|
+
return {
|
|
2239
|
+
vertex: `// ${marker}
|
|
2240
|
+
${nativeUniformStruct()}
|
|
2241
|
+
struct VertexOutput {
|
|
2242
|
+
@builtin(position) position: vec4<f32>,
|
|
2243
|
+
@location(0) normal: vec3<f32>,
|
|
2244
|
+
@location(1) uv: vec2<f32>,
|
|
2245
|
+
@location(2) worldPosition: vec3<f32>,
|
|
2246
|
+
@location(3) tangent: vec4<f32>,
|
|
2247
|
+
};
|
|
2248
|
+
|
|
2249
|
+
@vertex
|
|
2250
|
+
fn ${vertexEntry}(@location(0) position: vec3<f32>, @location(1) normal: vec3<f32>, @location(2) uv: vec2<f32>${usesTangent ? ", @location(3) tangent: vec4<f32>" : ""}) -> VertexOutput {
|
|
2251
|
+
var output: VertexOutput;
|
|
2252
|
+
let worldPosition = (u_draw.instance0 * vec4<f32>(position, 1.0)).xyz;
|
|
2253
|
+
output.position = a3dWebGPUClipPosition(u_draw.modelViewProjection * vec4<f32>(position, 1.0));
|
|
2254
|
+
output.normal = normalize((u_draw.normalMatrix * vec4<f32>(normal, 0.0)).xyz);
|
|
2255
|
+
output.uv = uv;
|
|
2256
|
+
output.worldPosition = worldPosition;
|
|
2257
|
+
${usesTangent ? "output.tangent = vec4<f32>(normalize((u_draw.normalMatrix * vec4<f32>(tangent.xyz, 0.0)).xyz), tangent.w);" : "output.tangent = vec4<f32>(1.0, 0.0, 0.0, 1.0);"}
|
|
2258
|
+
return output;
|
|
2259
|
+
}
|
|
2260
|
+
`,
|
|
2261
|
+
fragment: `${nativePbrFragmentPrelude(marker)}
|
|
2262
|
+
@fragment
|
|
2263
|
+
fn ${fragmentEntry}(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
2264
|
+
return shadePbr(input.normal, input.tangent, input.uv, input.worldPosition);
|
|
2265
|
+
}
|
|
2266
|
+
`
|
|
2267
|
+
};
|
|
2268
|
+
}
|
|
2269
|
+
function nativeInstancedPbrShader(vertexEntry, fragmentEntry, marker) {
|
|
2270
|
+
return {
|
|
2271
|
+
vertex: `// ${marker}
|
|
2272
|
+
${nativeUniformStruct()}
|
|
2273
|
+
struct VertexOutput {
|
|
2274
|
+
@builtin(position) position: vec4<f32>,
|
|
2275
|
+
@location(0) normal: vec3<f32>,
|
|
2276
|
+
@location(1) uv: vec2<f32>,
|
|
2277
|
+
@location(2) worldPosition: vec3<f32>,
|
|
2278
|
+
@location(3) tangent: vec4<f32>,
|
|
2279
|
+
};
|
|
2280
|
+
|
|
2281
|
+
fn instanceMatrix(index: u32) -> mat4x4<f32> {
|
|
2282
|
+
if (index == 1u) { return u_draw.instance1; }
|
|
2283
|
+
if (index == 2u) { return u_draw.instance2; }
|
|
2284
|
+
if (index == 3u) { return u_draw.instance3; }
|
|
2285
|
+
return u_draw.instance0;
|
|
2286
|
+
}
|
|
2287
|
+
|
|
2288
|
+
@vertex
|
|
2289
|
+
fn ${vertexEntry}(@location(0) position: vec3<f32>, @location(1) normal: vec3<f32>, @builtin(instance_index) instanceIndex: u32) -> VertexOutput {
|
|
2290
|
+
var output: VertexOutput;
|
|
2291
|
+
let model = instanceMatrix(instanceIndex);
|
|
2292
|
+
let worldPosition = (model * vec4<f32>(position, 1.0)).xyz;
|
|
2293
|
+
output.position = a3dWebGPUClipPosition(u_draw.modelViewProjection * model * vec4<f32>(position, 1.0));
|
|
2294
|
+
output.normal = normalize((model * vec4<f32>(normal, 0.0)).xyz);
|
|
2295
|
+
output.uv = vec2<f32>(0.5, 0.5);
|
|
2296
|
+
output.worldPosition = worldPosition;
|
|
2297
|
+
output.tangent = vec4<f32>(1.0, 0.0, 0.0, 1.0);
|
|
2298
|
+
return output;
|
|
2299
|
+
}
|
|
2300
|
+
`,
|
|
2301
|
+
fragment: `${nativePbrFragmentPrelude(marker)}
|
|
2302
|
+
@fragment
|
|
2303
|
+
fn ${fragmentEntry}(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
2304
|
+
return shadePbr(input.normal, input.tangent, input.uv, input.worldPosition);
|
|
2305
|
+
}
|
|
2306
|
+
`
|
|
2307
|
+
};
|
|
2308
|
+
}
|
|
2309
|
+
function nativeSkinnedUnlitShader(vertexEntry, fragmentEntry, marker) {
|
|
2310
|
+
return {
|
|
2311
|
+
vertex: `// ${marker}
|
|
2312
|
+
${nativeUniformStruct()}
|
|
2313
|
+
struct VertexOutput {
|
|
2314
|
+
@builtin(position) position: vec4<f32>,
|
|
2315
|
+
};
|
|
2316
|
+
|
|
2317
|
+
fn jointMatrix(index: f32) -> mat4x4<f32> {
|
|
2318
|
+
if (index > 0.5) { return u_draw.joint1; }
|
|
2319
|
+
return u_draw.joint0;
|
|
2320
|
+
}
|
|
2321
|
+
|
|
2322
|
+
@vertex
|
|
2323
|
+
fn ${vertexEntry}(@location(0) position: vec3<f32>, @location(5) joints: vec4<f32>, @location(6) weights: vec4<f32>) -> VertexOutput {
|
|
2324
|
+
var output: VertexOutput;
|
|
2325
|
+
let skin = jointMatrix(joints.x) * weights.x + jointMatrix(joints.y) * weights.y + jointMatrix(joints.z) * weights.z + jointMatrix(joints.w) * weights.w;
|
|
2326
|
+
let weightSum = weights.x + weights.y + weights.z + weights.w;
|
|
2327
|
+
let skinned = select(vec4<f32>(position, 1.0), skin * vec4<f32>(position, 1.0), weightSum > 0.0001);
|
|
2328
|
+
output.position = a3dWebGPUClipPosition(u_draw.modelViewProjection * skinned);
|
|
2329
|
+
return output;
|
|
2330
|
+
}
|
|
2331
|
+
`,
|
|
2332
|
+
fragment: `// ${marker}
|
|
2333
|
+
${nativeUniformStruct()}
|
|
2334
|
+
@fragment
|
|
2335
|
+
fn ${fragmentEntry}() -> @location(0) vec4<f32> {
|
|
2336
|
+
return u_draw.color;
|
|
2337
|
+
}
|
|
2338
|
+
`
|
|
2339
|
+
};
|
|
2340
|
+
}
|
|
2341
|
+
function nativeMorphUnlitShader(vertexEntry, fragmentEntry, marker) {
|
|
2342
|
+
return {
|
|
2343
|
+
vertex: `// ${marker}
|
|
2344
|
+
${nativeUniformStruct()}
|
|
2345
|
+
struct VertexOutput {
|
|
2346
|
+
@builtin(position) position: vec4<f32>,
|
|
2347
|
+
};
|
|
2348
|
+
|
|
2349
|
+
fn morphDelta(index: u32) -> vec3<f32> {
|
|
2350
|
+
if (index == 0u) { return u_draw.morph0.xyz; }
|
|
2351
|
+
if (index == 1u) { return u_draw.morph1.xyz; }
|
|
2352
|
+
if (index == 2u) { return u_draw.morph2.xyz; }
|
|
2353
|
+
if (index == 3u) { return u_draw.morph3.xyz; }
|
|
2354
|
+
if (index == 4u) { return u_draw.morph4.xyz; }
|
|
2355
|
+
if (index == 5u) { return u_draw.morph5.xyz; }
|
|
2356
|
+
if (index == 6u) { return u_draw.morph6.xyz; }
|
|
2357
|
+
return u_draw.morph7.xyz;
|
|
2358
|
+
}
|
|
2359
|
+
|
|
2360
|
+
@vertex
|
|
2361
|
+
fn ${vertexEntry}(@location(0) position: vec3<f32>, @builtin(vertex_index) vertexIndex: u32) -> VertexOutput {
|
|
2362
|
+
var output: VertexOutput;
|
|
2363
|
+
let enabled = min(u_draw.reserved0.y, 1.0);
|
|
2364
|
+
let morphed = position + morphDelta(min(vertexIndex, 7u)) * u_draw.reserved0.x * enabled;
|
|
2365
|
+
output.position = a3dWebGPUClipPosition(u_draw.modelViewProjection * vec4<f32>(morphed, 1.0));
|
|
2366
|
+
return output;
|
|
2367
|
+
}
|
|
2368
|
+
`,
|
|
2369
|
+
fragment: `// ${marker}
|
|
2370
|
+
${nativeUniformStruct()}
|
|
2371
|
+
@fragment
|
|
2372
|
+
fn ${fragmentEntry}() -> @location(0) vec4<f32> {
|
|
2373
|
+
return u_draw.color;
|
|
2374
|
+
}
|
|
2375
|
+
`
|
|
2376
|
+
};
|
|
2377
|
+
}
|
|
2378
|
+
function inferWGSLVertexEntryPoint(source) {
|
|
2379
|
+
return /@vertex\s+fn\s+([A-Za-z_]\w*)/.exec(source)?.[1];
|
|
2380
|
+
}
|
|
2381
|
+
function inferWGSLFragmentEntryPoint(source) {
|
|
2382
|
+
return /@fragment\s+fn\s+([A-Za-z_]\w*)/.exec(source)?.[1];
|
|
2383
|
+
}
|
|
2384
|
+
function vertexBufferLayout(format) {
|
|
2385
|
+
return {
|
|
2386
|
+
arrayStride: format.stride,
|
|
2387
|
+
attributes: format.attributes.map((attribute) => ({
|
|
2388
|
+
shaderLocation: attribute.shaderLocation,
|
|
2389
|
+
offset: attribute.offset,
|
|
2390
|
+
format: vertexAttributeFormat(attribute.components)
|
|
2391
|
+
}))
|
|
2392
|
+
};
|
|
2393
|
+
}
|
|
2394
|
+
function vertexAttributeFormat(components) {
|
|
2395
|
+
if (components === 1)
|
|
2396
|
+
return "float32";
|
|
2397
|
+
if (components === 2)
|
|
2398
|
+
return "float32x2";
|
|
2399
|
+
if (components === 3)
|
|
2400
|
+
return "float32x3";
|
|
2401
|
+
return "float32x4";
|
|
2402
|
+
}
|
|
2403
|
+
//# sourceMappingURL=WebGPUDevice.js.map
|