rhodonite 0.25.0 → 0.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +93 -19
- package/VERSION-FILE +1 -1
- package/dist/esm/foundation/components/BlendShape/BlendShapeComponent.d.ts +54 -0
- package/dist/esm/foundation/components/BlendShape/BlendShapeComponent.js +1 -1
- package/dist/esm/foundation/components/Camera/CameraComponent.d.ts +34 -0
- package/dist/esm/foundation/components/Camera/CameraComponent.js +1 -1
- package/dist/esm/foundation/components/Light/LightComponent.d.ts +3 -1
- package/dist/esm/foundation/components/Light/LightComponent.js +1 -1
- package/dist/esm/foundation/components/Mesh/MeshComponent.js +1 -1
- package/dist/esm/foundation/components/MeshRenderer/MeshRendererComponent.js +1 -1
- package/dist/esm/foundation/components/SceneGraph/SceneGraphComponent.d.ts +16 -0
- package/dist/esm/foundation/components/SceneGraph/SceneGraphComponent.js +1 -1
- package/dist/esm/foundation/components/Shape/ShapeComponent.js +1 -1
- package/dist/esm/foundation/components/Skeletal/AnimationRetarget/AbsoluteAnimation.js +1 -1
- package/dist/esm/foundation/components/Skeletal/AnimationRetarget/GlobalRetarget.js +1 -1
- package/dist/esm/foundation/components/Skeletal/AnimationRetarget/GlobalRetargetReverse.js +1 -1
- package/dist/esm/foundation/components/Skeletal/SkeletalComponent.d.ts +48 -0
- package/dist/esm/foundation/components/Skeletal/SkeletalComponent.js +1 -1
- package/dist/esm/foundation/components/Transform/TransformComponent.js +1 -1
- package/dist/esm/foundation/components/Trigger/TriggerComponent.js +1 -1
- package/dist/esm/foundation/components/Vrm/VrmComponent.js +1 -1
- package/dist/esm/foundation/constraints/VrmAimConstraint.js +1 -1
- package/dist/esm/foundation/constraints/VrmRollConstraint.js +1 -1
- package/dist/esm/foundation/constraints/VrmRotationConstraint.js +1 -1
- package/dist/esm/foundation/core/Component.js +1 -1
- package/dist/esm/foundation/core/ComponentRepository.js +1 -1
- package/dist/esm/foundation/core/Entity.js +1 -1
- package/dist/esm/foundation/core/EntityRepository.js +1 -1
- package/dist/esm/foundation/geometry/ComplexVertexAttribute.js +1 -1
- package/dist/esm/foundation/geometry/Mesh.js +1 -1
- package/dist/esm/foundation/geometry/Primitive.js +1 -1
- package/dist/esm/foundation/gizmos/AABBGizmo.js +1 -1
- package/dist/esm/foundation/gizmos/CapsuleColliderGizmo.js +1 -1
- package/dist/esm/foundation/gizmos/Gizmo.d.ts +13 -0
- package/dist/esm/foundation/gizmos/Gizmo.js +1 -1
- package/dist/esm/foundation/gizmos/JointGizmo.js +1 -1
- package/dist/esm/foundation/gizmos/LightGizmo.d.ts +0 -1
- package/dist/esm/foundation/gizmos/LightGizmo.js +1 -1
- package/dist/esm/foundation/gizmos/LocatorGizmo.js +1 -1
- package/dist/esm/foundation/gizmos/RotationGizmo.js +1 -1
- package/dist/esm/foundation/gizmos/ScaleGizmo.js +1 -1
- package/dist/esm/foundation/gizmos/ShapeGizmo.js +1 -1
- package/dist/esm/foundation/gizmos/SphereColliderGizmo.js +1 -1
- package/dist/esm/foundation/gizmos/TranslationGizmo.js +1 -1
- package/dist/esm/foundation/helpers/BloomHelper.js +1 -1
- package/dist/esm/foundation/helpers/GaussianBlurHelper.js +1 -1
- package/dist/esm/foundation/helpers/Shadow/PointShadowMap.js +1 -1
- package/dist/esm/foundation/helpers/Shadow/ShadowMap.js +1 -1
- package/dist/esm/foundation/helpers/Shadow/ShadowSystem.js +1 -1
- package/dist/esm/foundation/helpers/materials/createMotionVectorMaterial.d.ts +25 -0
- package/dist/esm/foundation/helpers/materials/createMotionVectorMaterial.js +1 -0
- package/dist/esm/foundation/helpers/materials/createTemporalAAResolveMaterial.d.ts +33 -0
- package/dist/esm/foundation/helpers/materials/createTemporalAAResolveMaterial.js +1 -0
- package/dist/esm/foundation/importer/AnimationAssigner.js +1 -1
- package/dist/esm/foundation/importer/DrcPointCloudImporter.js +1 -1
- package/dist/esm/foundation/importer/Gltf2Importer.js +1 -1
- package/dist/esm/foundation/importer/GltfImporter.js +1 -1
- package/dist/esm/foundation/importer/ModelConverter.js +1 -1
- package/dist/esm/foundation/importer/RhodoniteImportExtension.js +1 -1
- package/dist/esm/foundation/importer/Vrm0xImporter.js +1 -1
- package/dist/esm/foundation/importer/VrmImporter.js +1 -1
- package/dist/esm/foundation/materials/contents/CustomMaterialContent.js +1 -1
- package/dist/esm/foundation/materials/contents/MToon0xMaterialContent.js +18 -18
- package/dist/esm/foundation/materials/contents/MToon1MaterialContent.js +6 -6
- package/dist/esm/foundation/materials/core/AbstractMaterialContent.d.ts +11 -0
- package/dist/esm/foundation/materials/core/AbstractMaterialContent.js +1 -1
- package/dist/esm/foundation/materials/core/ShaderityUtilityWebGL.js +2 -2
- package/dist/esm/foundation/materials/core/ShaderityUtilityWebGPU.js +2 -2
- package/dist/esm/foundation/materials/nodes/CastToFloatShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/MergeVectorShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/Random_HashPRNGShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/Random_SinHashShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/SplitVectorShaderNode.js +1 -1
- package/dist/esm/foundation/math/MathClassUtil.js +1 -1
- package/dist/esm/foundation/math/Quaternion.js +1 -1
- package/dist/esm/foundation/math/Transform3D.js +1 -1
- package/dist/esm/foundation/math/shapes/MathSphere.js +1 -1
- package/dist/esm/foundation/memory/Accessor.js +6 -6
- package/dist/esm/foundation/memory/BufferView.js +1 -1
- package/dist/esm/foundation/misc/cache/Cache.js +1 -1
- package/dist/esm/foundation/physics/VRMSpring/CapsuleCollider.js +1 -1
- package/dist/esm/foundation/physics/VRMSpring/SphereCollider.js +1 -1
- package/dist/esm/foundation/physics/VRMSpring/VRMSpringBone.js +1 -1
- package/dist/esm/foundation/renderer/Frame.js +1 -1
- package/dist/esm/foundation/renderer/RenderPass.js +1 -1
- package/dist/esm/foundation/renderer/TemporalAA/PreviousFrameDataTracker.d.ts +33 -0
- package/dist/esm/foundation/renderer/TemporalAA/PreviousFrameDataTracker.js +1 -0
- package/dist/esm/foundation/renderer/TemporalAA/TemporalAASystem.d.ts +135 -0
- package/dist/esm/foundation/renderer/TemporalAA/TemporalAASystem.js +1 -0
- package/dist/esm/foundation/renderer/pipelines/DeferredRenderPipeline.js +1 -1
- package/dist/esm/foundation/renderer/pipelines/ForwardRenderPipeline.d.ts +62 -16
- package/dist/esm/foundation/renderer/pipelines/ForwardRenderPipeline.js +1 -1
- package/dist/esm/foundation/system/Engine.d.ts +37 -3
- package/dist/esm/foundation/system/Engine.js +1 -1
- package/dist/esm/foundation/textures/AbstractTexture.js +1 -1
- package/dist/esm/foundation/textures/CubeTexture.js +1 -1
- package/dist/esm/foundation/textures/RenderTargetTexture.js +1 -1
- package/dist/esm/foundation/textures/RenderTargetTexture2DArray.js +1 -1
- package/dist/esm/foundation/textures/RenderTargetTextureCube.js +1 -1
- package/dist/esm/foundation/textures/Texture.js +1 -1
- package/dist/esm/foundation/textures/TextureDataFloat.js +1 -1
- package/dist/esm/foundation/textures/VideoTexture.js +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/webgl/MultiDraw.js +1 -1
- package/dist/esm/webgl/MultiDrawRepository.js +1 -1
- package/dist/esm/webgl/WebGLStereoUtil.js +1 -1
- package/dist/esm/webgl/WebGLStrategyWebGL2.d.ts +8 -0
- package/dist/esm/webgl/WebGLStrategyWebGL2.js +47 -28
- package/dist/esm/webgl/shaderity_shaders/ClassicSingleShader/ClassicSingleShader.vert.js +0 -3
- package/dist/esm/webgl/shaderity_shaders/MotionVectorShader/MotionVectorShader.frag.js +35 -0
- package/dist/esm/webgl/shaderity_shaders/MotionVectorShader/MotionVectorShader.vert.js +140 -0
- package/dist/esm/webgl/shaderity_shaders/TemporalAAResolveShader/TemporalAAResolveShader.frag.js +175 -0
- package/dist/esm/webgl/shaderity_shaders/TemporalAAResolveShader/TemporalAAResolveShader.vert.js +18 -0
- package/dist/esm/webgl/shaders/StandardShaderPart.js +3 -3
- package/dist/esm/webgl/shaders/nodes/ConstantVariableShader.js +5 -5
- package/dist/esm/webgl/shaders/nodes/UniformDataShader.js +9 -9
- package/dist/esm/webgpu/GpuCullingRegistry.js +1 -1
- package/dist/esm/webgpu/GpuDeformRegistry.js +1 -1
- package/dist/esm/webgpu/WebGpuGpuCulling.js +1 -1
- package/dist/esm/webgpu/WebGpuGpuTimer.js +1 -1
- package/dist/esm/webgpu/WebGpuLightClusterBuilder.js +1 -1
- package/dist/esm/webgpu/WebGpuResourceRepository.js +3 -3
- package/dist/esm/webgpu/WebGpuStrategyBasic.d.ts +8 -0
- package/dist/esm/webgpu/WebGpuStrategyBasic.js +78 -59
- package/dist/esm/webgpu/WebGpuVertexDeformer.js +1 -1
- package/dist/esm/webgpu/shaderity_shaders/MotionVectorShader/MotionVectorShader.frag.wgsl.js +30 -0
- package/dist/esm/webgpu/shaderity_shaders/MotionVectorShader/MotionVectorShader.vert.wgsl.js +133 -0
- package/dist/esm/webgpu/shaderity_shaders/TemporalAAResolveShader/TemporalAAResolveShader.frag.wgsl.js +169 -0
- package/dist/esm/webgpu/shaderity_shaders/TemporalAAResolveShader/TemporalAAResolveShader.vert.wgsl.js +19 -0
- package/dist/esmdev/foundation/components/BlendShape/BlendShapeComponent.d.ts +54 -0
- package/dist/esmdev/foundation/components/BlendShape/BlendShapeComponent.js +107 -1
- package/dist/esmdev/foundation/components/Camera/CameraComponent.d.ts +34 -0
- package/dist/esmdev/foundation/components/Camera/CameraComponent.js +118 -46
- package/dist/esmdev/foundation/components/CameraController/CameraControllerComponent.js +8 -8
- package/dist/esmdev/foundation/components/CharacterController/CharacterAnimationController.js +74 -74
- package/dist/esmdev/foundation/components/CharacterController/CharacterControllerComponent.js +39 -39
- package/dist/esmdev/foundation/components/Constraint/ConstraintComponent.js +4 -4
- package/dist/esmdev/foundation/components/Light/LightComponent.d.ts +3 -1
- package/dist/esmdev/foundation/components/Light/LightComponent.js +126 -121
- package/dist/esmdev/foundation/components/Mesh/MeshComponent.js +50 -50
- package/dist/esmdev/foundation/components/MeshRenderer/MeshRendererComponent.js +96 -92
- package/dist/esmdev/foundation/components/Physics/PhysicsComponent.js +73 -73
- package/dist/esmdev/foundation/components/Raymarching/RaymarchingComponent.js +54 -54
- package/dist/esmdev/foundation/components/Raymarching/RaymarchingSdfEvaluator.js +251 -251
- package/dist/esmdev/foundation/components/SceneGraph/SceneGraphComponent.d.ts +16 -0
- package/dist/esmdev/foundation/components/SceneGraph/SceneGraphComponent.js +375 -343
- package/dist/esmdev/foundation/components/Shape/ShapeComponent.js +31 -31
- package/dist/esmdev/foundation/components/Skeletal/AnimationRetarget/AbsoluteAnimation.js +5 -5
- package/dist/esmdev/foundation/components/Skeletal/AnimationRetarget/GlobalRetarget.js +5 -5
- package/dist/esmdev/foundation/components/Skeletal/AnimationRetarget/GlobalRetargetReverse.js +9 -9
- package/dist/esmdev/foundation/components/Skeletal/SkeletalComponent.d.ts +48 -0
- package/dist/esmdev/foundation/components/Skeletal/SkeletalComponent.js +337 -205
- package/dist/esmdev/foundation/components/Transform/TransformComponent.js +93 -93
- package/dist/esmdev/foundation/components/Trigger/TriggerComponent.js +61 -61
- package/dist/esmdev/foundation/components/Vrm/VrmComponent.js +44 -44
- package/dist/esmdev/foundation/constraints/VrmAimConstraint.js +11 -11
- package/dist/esmdev/foundation/constraints/VrmRollConstraint.js +16 -16
- package/dist/esmdev/foundation/constraints/VrmRotationConstraint.js +10 -10
- package/dist/esmdev/foundation/core/Component.js +32 -32
- package/dist/esmdev/foundation/core/ComponentMemoryRegistry.js +42 -42
- package/dist/esmdev/foundation/core/ComponentRepository.js +37 -37
- package/dist/esmdev/foundation/core/Config.js +9 -9
- package/dist/esmdev/foundation/core/Entity.js +9 -9
- package/dist/esmdev/foundation/core/EntityRepository.js +19 -19
- package/dist/esmdev/foundation/core/GlobalDataRepository.js +17 -17
- package/dist/esmdev/foundation/core/MemoryManager.js +25 -25
- package/dist/esmdev/foundation/core/RnObject.js +37 -37
- package/dist/esmdev/foundation/definitions/Blend.js +3 -3
- package/dist/esmdev/foundation/definitions/ComponentType.js +7 -7
- package/dist/esmdev/foundation/definitions/CompositionType.js +50 -50
- package/dist/esmdev/foundation/definitions/CompressionTextureType.js +6 -6
- package/dist/esmdev/foundation/definitions/ShaderSemantics.js +6 -6
- package/dist/esmdev/foundation/definitions/TextureFormat.js +3 -3
- package/dist/esmdev/foundation/definitions/TextureParameter.js +3 -3
- package/dist/esmdev/foundation/definitions/VertexAttribute.js +30 -30
- package/dist/esmdev/foundation/enhanced_js_objects/Array.js +2 -2
- package/dist/esmdev/foundation/exporter/Gltf2Exporter.js +112 -112
- package/dist/esmdev/foundation/geometry/ComplexVertexAttribute.js +24 -24
- package/dist/esmdev/foundation/geometry/Frustum.js +41 -41
- package/dist/esmdev/foundation/geometry/Mesh.js +218 -218
- package/dist/esmdev/foundation/geometry/Primitive.js +133 -133
- package/dist/esmdev/foundation/geometry/SimpleVertexAttribute.js +7 -7
- package/dist/esmdev/foundation/geometry/shapes/Cylinder.js +3 -3
- package/dist/esmdev/foundation/geometry/shapes/Joint.js +33 -33
- package/dist/esmdev/foundation/gizmos/AABBGizmo.js +17 -20
- package/dist/esmdev/foundation/gizmos/CapsuleColliderGizmo.js +24 -26
- package/dist/esmdev/foundation/gizmos/Gizmo.d.ts +13 -0
- package/dist/esmdev/foundation/gizmos/Gizmo.js +43 -21
- package/dist/esmdev/foundation/gizmos/JointGizmo.js +38 -40
- package/dist/esmdev/foundation/gizmos/LightGizmo.d.ts +0 -1
- package/dist/esmdev/foundation/gizmos/LightGizmo.js +26 -30
- package/dist/esmdev/foundation/gizmos/LocatorGizmo.js +26 -29
- package/dist/esmdev/foundation/gizmos/RotationGizmo.js +217 -219
- package/dist/esmdev/foundation/gizmos/ScaleGizmo.js +135 -137
- package/dist/esmdev/foundation/gizmos/ShapeGizmo.js +44 -47
- package/dist/esmdev/foundation/gizmos/SphereColliderGizmo.js +25 -27
- package/dist/esmdev/foundation/gizmos/TranslationGizmo.js +132 -134
- package/dist/esmdev/foundation/helpers/BloomHelper.js +34 -34
- package/dist/esmdev/foundation/helpers/GaussianBlurHelper.js +18 -18
- package/dist/esmdev/foundation/helpers/Shadow/PointShadowMap.js +12 -12
- package/dist/esmdev/foundation/helpers/Shadow/ShadowMap.js +5 -5
- package/dist/esmdev/foundation/helpers/Shadow/ShadowSystem.js +119 -119
- package/dist/esmdev/foundation/helpers/materials/createMotionVectorMaterial.d.ts +25 -0
- package/dist/esmdev/foundation/helpers/materials/createMotionVectorMaterial.js +61 -0
- package/dist/esmdev/foundation/helpers/materials/createTemporalAAResolveMaterial.d.ts +33 -0
- package/dist/esmdev/foundation/helpers/materials/createTemporalAAResolveMaterial.js +127 -0
- package/dist/esmdev/foundation/importer/AnimationAssigner.js +44 -44
- package/dist/esmdev/foundation/importer/DrcPointCloudImporter.js +33 -33
- package/dist/esmdev/foundation/importer/Gltf2Importer.js +14 -14
- package/dist/esmdev/foundation/importer/GltfImporter.js +22 -22
- package/dist/esmdev/foundation/importer/ModelConverter.js +131 -131
- package/dist/esmdev/foundation/importer/RhodoniteImportExtension.js +6 -6
- package/dist/esmdev/foundation/importer/Vrm0xImporter.js +48 -48
- package/dist/esmdev/foundation/importer/VrmImporter.js +10 -10
- package/dist/esmdev/foundation/materials/contents/CustomMaterialContent.js +27 -27
- package/dist/esmdev/foundation/materials/contents/DepthEncodeMaterialContent.js +2 -2
- package/dist/esmdev/foundation/materials/contents/MToon0xMaterialContent.js +138 -138
- package/dist/esmdev/foundation/materials/contents/MToon1MaterialContent.js +19 -19
- package/dist/esmdev/foundation/materials/contents/ShadowMapDecodeClassicMaterialContent.js +5 -5
- package/dist/esmdev/foundation/materials/contents/VarianceShadowMapDecodeClassicMaterialContent.js +5 -5
- package/dist/esmdev/foundation/materials/core/AbstractMaterialContent.d.ts +11 -0
- package/dist/esmdev/foundation/materials/core/AbstractMaterialContent.js +68 -53
- package/dist/esmdev/foundation/materials/core/AbstractShaderNode.js +26 -26
- package/dist/esmdev/foundation/materials/core/DummyTextures.js +3 -3
- package/dist/esmdev/foundation/materials/core/Material.js +115 -115
- package/dist/esmdev/foundation/materials/core/MaterialRepository.js +65 -65
- package/dist/esmdev/foundation/materials/core/ShaderGraphResolver.js +38 -38
- package/dist/esmdev/foundation/materials/core/ShaderHandler.js +4 -4
- package/dist/esmdev/foundation/materials/core/ShaderityUtilityWebGL.js +16 -17
- package/dist/esmdev/foundation/materials/core/ShaderityUtilityWebGPU.js +17 -18
- package/dist/esmdev/foundation/materials/nodes/AbsShaderNode.js +13 -13
- package/dist/esmdev/foundation/materials/nodes/AcosShaderNode.js +13 -13
- package/dist/esmdev/foundation/materials/nodes/AddShaderNode.js +18 -18
- package/dist/esmdev/foundation/materials/nodes/AlphaTestShaderNode.js +5 -5
- package/dist/esmdev/foundation/materials/nodes/AndShaderNode.js +6 -6
- package/dist/esmdev/foundation/materials/nodes/Atan2ShaderNode.js +15 -15
- package/dist/esmdev/foundation/materials/nodes/AttributeColorShaderNode.js +1 -1
- package/dist/esmdev/foundation/materials/nodes/AttributeInstanceIdsShaderNode.js +1 -1
- package/dist/esmdev/foundation/materials/nodes/AttributeJointShaderNode.js +1 -1
- package/dist/esmdev/foundation/materials/nodes/AttributeNormalShaderNode.js +1 -1
- package/dist/esmdev/foundation/materials/nodes/AttributePositionShaderNode.js +2 -2
- package/dist/esmdev/foundation/materials/nodes/AttributeTangentShaderNode.js +1 -1
- package/dist/esmdev/foundation/materials/nodes/AttributeTexcoordShaderNode.js +2 -2
- package/dist/esmdev/foundation/materials/nodes/AttributeWeightShaderNode.js +1 -1
- package/dist/esmdev/foundation/materials/nodes/BlockBeginShaderNode.js +11 -11
- package/dist/esmdev/foundation/materials/nodes/BlockEndShaderNode.js +6 -6
- package/dist/esmdev/foundation/materials/nodes/BranchShaderNode.js +15 -15
- package/dist/esmdev/foundation/materials/nodes/CalcBitangentShaderNode.js +7 -7
- package/dist/esmdev/foundation/materials/nodes/CastToFloatShaderNode.js +13 -13
- package/dist/esmdev/foundation/materials/nodes/ClampShaderNode.js +15 -15
- package/dist/esmdev/foundation/materials/nodes/ClassicShaderNode.js +11 -11
- package/dist/esmdev/foundation/materials/nodes/ConstantScalarVariableShaderNode.js +1 -1
- package/dist/esmdev/foundation/materials/nodes/ConstantVariableShaderNode.js +5 -5
- package/dist/esmdev/foundation/materials/nodes/ConstantVector2VariableShaderNode.js +1 -1
- package/dist/esmdev/foundation/materials/nodes/ConstantVector3VariableShaderNode.js +1 -1
- package/dist/esmdev/foundation/materials/nodes/ConstantVector4VariableShaderNode.js +1 -1
- package/dist/esmdev/foundation/materials/nodes/CosShaderNode.js +13 -13
- package/dist/esmdev/foundation/materials/nodes/DiscardShaderNode.js +2 -2
- package/dist/esmdev/foundation/materials/nodes/DotProductShaderNode.js +10 -10
- package/dist/esmdev/foundation/materials/nodes/EqualShaderNode.js +10 -10
- package/dist/esmdev/foundation/materials/nodes/FlatShaderNode.js +5 -5
- package/dist/esmdev/foundation/materials/nodes/GreaterOrEqualShaderNode.js +10 -10
- package/dist/esmdev/foundation/materials/nodes/GreaterShaderNode.js +3 -3
- package/dist/esmdev/foundation/materials/nodes/GreaterThanShaderNode.js +10 -10
- package/dist/esmdev/foundation/materials/nodes/LengthShaderNode.js +13 -13
- package/dist/esmdev/foundation/materials/nodes/LessOrEqualShaderNode.js +10 -10
- package/dist/esmdev/foundation/materials/nodes/LessThanShaderNode.js +10 -10
- package/dist/esmdev/foundation/materials/nodes/MergeVectorShaderNode.js +19 -19
- package/dist/esmdev/foundation/materials/nodes/MinShaderNode.js +18 -18
- package/dist/esmdev/foundation/materials/nodes/MultiplyShaderNode.js +21 -21
- package/dist/esmdev/foundation/materials/nodes/NormalMatrixShaderNode.js +1 -1
- package/dist/esmdev/foundation/materials/nodes/NormalizeShaderNode.js +9 -9
- package/dist/esmdev/foundation/materials/nodes/NotEqualShaderNode.js +10 -10
- package/dist/esmdev/foundation/materials/nodes/OrShaderNode.js +6 -6
- package/dist/esmdev/foundation/materials/nodes/OutColorShaderNode.js +2 -2
- package/dist/esmdev/foundation/materials/nodes/OutPositionShaderNode.js +2 -2
- package/dist/esmdev/foundation/materials/nodes/PbrAnisotropyPropsShaderNode.js +5 -5
- package/dist/esmdev/foundation/materials/nodes/PbrAnisotropyRotationShaderNode.js +3 -3
- package/dist/esmdev/foundation/materials/nodes/PbrBaseColorPropsShaderNode.js +5 -5
- package/dist/esmdev/foundation/materials/nodes/PbrClearcoatPropsShaderNode.js +7 -7
- package/dist/esmdev/foundation/materials/nodes/PbrDiffuseTransmissionPropsShaderNode.js +6 -6
- package/dist/esmdev/foundation/materials/nodes/PbrEmissivePropsShaderNode.js +5 -5
- package/dist/esmdev/foundation/materials/nodes/PbrIridescencePropsShaderNode.js +8 -8
- package/dist/esmdev/foundation/materials/nodes/PbrMetallicRoughnessPropsShaderNode.js +6 -6
- package/dist/esmdev/foundation/materials/nodes/PbrNormalPropsShaderNode.js +11 -11
- package/dist/esmdev/foundation/materials/nodes/PbrOcclusionPropsShaderNode.js +4 -4
- package/dist/esmdev/foundation/materials/nodes/PbrShaderShaderNode.js +21 -21
- package/dist/esmdev/foundation/materials/nodes/PbrSheenPropsShaderNode.js +6 -6
- package/dist/esmdev/foundation/materials/nodes/PbrSpecularPropsShaderNode.js +6 -6
- package/dist/esmdev/foundation/materials/nodes/PbrTransmissionPropsShaderNode.js +4 -4
- package/dist/esmdev/foundation/materials/nodes/PbrVolumePropsShaderNode.js +6 -6
- package/dist/esmdev/foundation/materials/nodes/PremultipliedAlphaShaderNode.js +4 -4
- package/dist/esmdev/foundation/materials/nodes/ProcessGeometryShaderNode.js +22 -22
- package/dist/esmdev/foundation/materials/nodes/ProjectionMatrixShaderNode.js +1 -1
- package/dist/esmdev/foundation/materials/nodes/Random_HashPRNGShaderNode.js +12 -12
- package/dist/esmdev/foundation/materials/nodes/Random_SinHashShaderNode.js +12 -12
- package/dist/esmdev/foundation/materials/nodes/RemapShaderNode.js +17 -17
- package/dist/esmdev/foundation/materials/nodes/SinShaderNode.js +13 -13
- package/dist/esmdev/foundation/materials/nodes/SmoothStepShaderNode.js +15 -15
- package/dist/esmdev/foundation/materials/nodes/SplitVectorShaderNode.js +17 -17
- package/dist/esmdev/foundation/materials/nodes/StepShaderNode.js +14 -14
- package/dist/esmdev/foundation/materials/nodes/TanShaderNode.js +13 -13
- package/dist/esmdev/foundation/materials/nodes/Texture2DShaderNode.js +16 -16
- package/dist/esmdev/foundation/materials/nodes/TimeShaderNode.js +1 -1
- package/dist/esmdev/foundation/materials/nodes/TransformShaderNode.js +10 -10
- package/dist/esmdev/foundation/materials/nodes/UniformDataShaderNode.js +5 -5
- package/dist/esmdev/foundation/materials/nodes/ViewMatrixShaderNode.js +1 -1
- package/dist/esmdev/foundation/materials/nodes/WireframeMaterialNode.js +3 -3
- package/dist/esmdev/foundation/materials/nodes/WorldMatrixShaderNode.js +1 -1
- package/dist/esmdev/foundation/materials/nodes/raymarching/BendXYShaderNode.js +4 -4
- package/dist/esmdev/foundation/materials/nodes/raymarching/BendXZShaderNode.js +4 -4
- package/dist/esmdev/foundation/materials/nodes/raymarching/BendYXShaderNode.js +4 -4
- package/dist/esmdev/foundation/materials/nodes/raymarching/BendYZShaderNode.js +4 -4
- package/dist/esmdev/foundation/materials/nodes/raymarching/BendZXShaderNode.js +4 -4
- package/dist/esmdev/foundation/materials/nodes/raymarching/BendZYShaderNode.js +4 -4
- package/dist/esmdev/foundation/materials/nodes/raymarching/InitialPositionShaderNode.js +1 -1
- package/dist/esmdev/foundation/materials/nodes/raymarching/OpSmoothIntersectionShaderNode.js +5 -5
- package/dist/esmdev/foundation/materials/nodes/raymarching/OpSmoothSubtractionShaderNode.js +5 -5
- package/dist/esmdev/foundation/materials/nodes/raymarching/OpSmoothUnionShaderNode.js +5 -5
- package/dist/esmdev/foundation/materials/nodes/raymarching/OpSubtractionShaderNode.js +6 -6
- package/dist/esmdev/foundation/materials/nodes/raymarching/OpUnionShaderNode.js +6 -6
- package/dist/esmdev/foundation/materials/nodes/raymarching/OutDistanceShaderNode.js +16 -16
- package/dist/esmdev/foundation/materials/nodes/raymarching/OutShadingColorShaderNode.js +2 -2
- package/dist/esmdev/foundation/materials/nodes/raymarching/OutUnionShaderNode.js +16 -16
- package/dist/esmdev/foundation/materials/nodes/raymarching/RaymarchCameraPositionShaderNode.js +2 -2
- package/dist/esmdev/foundation/materials/nodes/raymarching/RaymarchHitDistanceShaderNode.js +2 -2
- package/dist/esmdev/foundation/materials/nodes/raymarching/RaymarchHitNormalShaderNode.js +2 -2
- package/dist/esmdev/foundation/materials/nodes/raymarching/RaymarchHitPositionShaderNode.js +2 -2
- package/dist/esmdev/foundation/materials/nodes/raymarching/RaymarchObjectIdShaderNode.js +2 -2
- package/dist/esmdev/foundation/materials/nodes/raymarching/RaymarchObjectIdUniformShaderNode.js +4 -4
- package/dist/esmdev/foundation/materials/nodes/raymarching/RaymarchRayDirectionShaderNode.js +2 -2
- package/dist/esmdev/foundation/materials/nodes/raymarching/RaymarchTBNShaderNode.js +2 -2
- package/dist/esmdev/foundation/materials/nodes/raymarching/RaymarchViewDirectionShaderNode.js +2 -2
- package/dist/esmdev/foundation/materials/nodes/raymarching/SdApplyTransformShaderNode.js +9 -9
- package/dist/esmdev/foundation/materials/nodes/raymarching/SdApplyWorldMatrixShaderNode.js +5 -5
- package/dist/esmdev/foundation/materials/nodes/raymarching/SdBarXShaderNode.js +3 -3
- package/dist/esmdev/foundation/materials/nodes/raymarching/SdBarYShaderNode.js +3 -3
- package/dist/esmdev/foundation/materials/nodes/raymarching/SdBarZShaderNode.js +3 -3
- package/dist/esmdev/foundation/materials/nodes/raymarching/SdBoxShaderNode.js +3 -3
- package/dist/esmdev/foundation/materials/nodes/raymarching/SdCapsuleShaderNode.js +5 -5
- package/dist/esmdev/foundation/materials/nodes/raymarching/SdRepeatShaderNode.js +4 -4
- package/dist/esmdev/foundation/materials/nodes/raymarching/SdRepeatXShaderNode.js +4 -4
- package/dist/esmdev/foundation/materials/nodes/raymarching/SdRepeatXYShaderNode.js +4 -4
- package/dist/esmdev/foundation/materials/nodes/raymarching/SdRepeatYShaderNode.js +4 -4
- package/dist/esmdev/foundation/materials/nodes/raymarching/SdRepeatYZShaderNode.js +4 -4
- package/dist/esmdev/foundation/materials/nodes/raymarching/SdRepeatZShaderNode.js +4 -4
- package/dist/esmdev/foundation/materials/nodes/raymarching/SdRepeatZXShaderNode.js +4 -4
- package/dist/esmdev/foundation/materials/nodes/raymarching/SdRoundBoxShaderNode.js +4 -4
- package/dist/esmdev/foundation/materials/nodes/raymarching/SdSphereShaderNode.js +3 -3
- package/dist/esmdev/foundation/materials/nodes/raymarching/SdTorusShaderNode.js +4 -4
- package/dist/esmdev/foundation/materials/nodes/raymarching/SdTubeXShaderNode.js +3 -3
- package/dist/esmdev/foundation/materials/nodes/raymarching/SdTubeYShaderNode.js +3 -3
- package/dist/esmdev/foundation/materials/nodes/raymarching/SdTubeZShaderNode.js +3 -3
- package/dist/esmdev/foundation/materials/nodes/raymarching/TwistXShaderNode.js +4 -4
- package/dist/esmdev/foundation/materials/nodes/raymarching/TwistYShaderNode.js +4 -4
- package/dist/esmdev/foundation/materials/nodes/raymarching/TwistZShaderNode.js +4 -4
- package/dist/esmdev/foundation/math/AABB.js +132 -132
- package/dist/esmdev/foundation/math/AnimatedQuaternion.js +54 -54
- package/dist/esmdev/foundation/math/AnimatedScalar.js +55 -55
- package/dist/esmdev/foundation/math/AnimatedValueEvaluationState.js +20 -20
- package/dist/esmdev/foundation/math/AnimatedVector2.js +55 -55
- package/dist/esmdev/foundation/math/AnimatedVector3.js +55 -55
- package/dist/esmdev/foundation/math/AnimatedVector4.js +55 -55
- package/dist/esmdev/foundation/math/AnimatedVectorN.js +55 -55
- package/dist/esmdev/foundation/math/IdentityMatrix33.js +2 -2
- package/dist/esmdev/foundation/math/IdentityMatrix44.js +2 -2
- package/dist/esmdev/foundation/math/MathClassUtil.js +4 -4
- package/dist/esmdev/foundation/math/Quaternion.js +20 -20
- package/dist/esmdev/foundation/math/Transform3D.js +83 -83
- package/dist/esmdev/foundation/math/shapes/MathSphere.js +9 -9
- package/dist/esmdev/foundation/memory/Accessor.js +370 -370
- package/dist/esmdev/foundation/memory/Buffer.js +40 -40
- package/dist/esmdev/foundation/memory/BufferView.js +33 -33
- package/dist/esmdev/foundation/misc/DataUtil.js +2 -2
- package/dist/esmdev/foundation/misc/EnumIO.js +10 -10
- package/dist/esmdev/foundation/misc/Logger.js +14 -14
- package/dist/esmdev/foundation/misc/RnPromise.js +14 -14
- package/dist/esmdev/foundation/misc/Time.js +27 -27
- package/dist/esmdev/foundation/misc/WeakOption.js +14 -14
- package/dist/esmdev/foundation/misc/cache/Cache.js +2 -2
- package/dist/esmdev/foundation/misc/cache/SymbolWeakMap.js +8 -8
- package/dist/esmdev/foundation/physics/PhysicsWorldQuery.js +13 -13
- package/dist/esmdev/foundation/physics/Rapier/RapierCharacterControllerStrategy.js +203 -203
- package/dist/esmdev/foundation/physics/Rapier/RapierPhysicsStrategy.js +241 -241
- package/dist/esmdev/foundation/physics/Rapier/RapierPhysicsWorldQueryStrategy.js +3 -3
- package/dist/esmdev/foundation/physics/VRMSpring/CapsuleCollider.js +42 -42
- package/dist/esmdev/foundation/physics/VRMSpring/SphereCollider.js +27 -27
- package/dist/esmdev/foundation/physics/VRMSpring/VRMSpringBone.js +10 -10
- package/dist/esmdev/foundation/physics/VRMSpring/VRMSpringBonePhysicsStrategy.js +51 -51
- package/dist/esmdev/foundation/renderer/Expression.js +6 -6
- package/dist/esmdev/foundation/renderer/Frame.js +12 -12
- package/dist/esmdev/foundation/renderer/FrameBuffer.js +25 -25
- package/dist/esmdev/foundation/renderer/RenderPass.js +102 -99
- package/dist/esmdev/foundation/renderer/TemporalAA/PreviousFrameDataTracker.d.ts +33 -0
- package/dist/esmdev/foundation/renderer/TemporalAA/PreviousFrameDataTracker.js +66 -0
- package/dist/esmdev/foundation/renderer/TemporalAA/TemporalAASystem.d.ts +135 -0
- package/dist/esmdev/foundation/renderer/TemporalAA/TemporalAASystem.js +275 -0
- package/dist/esmdev/foundation/renderer/lightCluster/LightClusterSystem.js +153 -153
- package/dist/esmdev/foundation/renderer/lightCluster/LightClusterSystemStub.js +3 -3
- package/dist/esmdev/foundation/renderer/pipelines/DeferredRenderPipeline.js +6 -6
- package/dist/esmdev/foundation/renderer/pipelines/ForwardRenderPipeline.d.ts +62 -16
- package/dist/esmdev/foundation/renderer/pipelines/ForwardRenderPipeline.js +535 -428
- package/dist/esmdev/foundation/system/Engine.d.ts +37 -3
- package/dist/esmdev/foundation/system/Engine.js +266 -224
- package/dist/esmdev/foundation/system/EventPubSub.js +8 -8
- package/dist/esmdev/foundation/system/InputManager.js +56 -56
- package/dist/esmdev/foundation/system/ModuleManager.js +6 -6
- package/dist/esmdev/foundation/textures/AbstractTexture.js +50 -50
- package/dist/esmdev/foundation/textures/CubeTexture.js +32 -32
- package/dist/esmdev/foundation/textures/RenderBuffer.js +11 -11
- package/dist/esmdev/foundation/textures/RenderTargetTexture.js +25 -25
- package/dist/esmdev/foundation/textures/RenderTargetTexture2DArray.js +37 -37
- package/dist/esmdev/foundation/textures/RenderTargetTextureCube.js +19 -19
- package/dist/esmdev/foundation/textures/Sampler.js +24 -24
- package/dist/esmdev/foundation/textures/Texture.js +83 -83
- package/dist/esmdev/foundation/textures/TextureArray.js +8 -8
- package/dist/esmdev/foundation/textures/TextureDataFloat.js +26 -26
- package/dist/esmdev/foundation/textures/VideoTexture.js +24 -24
- package/dist/esmdev/version.js +2 -2
- package/dist/esmdev/webgl/InstanceSidTable.js +62 -62
- package/dist/esmdev/webgl/MultiDraw.js +2 -2
- package/dist/esmdev/webgl/MultiDrawRepository.js +30 -30
- package/dist/esmdev/webgl/WebGLContextWrapper.js +164 -164
- package/dist/esmdev/webgl/WebGLGpuTimer.js +32 -32
- package/dist/esmdev/webgl/WebGLResourceRepository.js +306 -306
- package/dist/esmdev/webgl/WebGLStereoUtil.js +42 -42
- package/dist/esmdev/webgl/WebGLStrategyWebGL2.d.ts +8 -0
- package/dist/esmdev/webgl/WebGLStrategyWebGL2.js +296 -261
- package/dist/esmdev/webgl/debug/ShaderParameterDebugger.js +4 -4
- package/dist/esmdev/webgl/shaderity_shaders/ClassicSingleShader/ClassicSingleShader.vert.js +2 -2
- package/dist/esmdev/webgl/shaderity_shaders/MotionVectorShader/MotionVectorShader.frag.js +12 -0
- package/dist/esmdev/webgl/shaderity_shaders/MotionVectorShader/MotionVectorShader.vert.js +12 -0
- package/dist/esmdev/webgl/shaderity_shaders/TemporalAAResolveShader/TemporalAAResolveShader.frag.js +12 -0
- package/dist/esmdev/webgl/shaderity_shaders/TemporalAAResolveShader/TemporalAAResolveShader.vert.js +12 -0
- package/dist/esmdev/webgl/shaders/RaymarchingShaderPart.js +4 -4
- package/dist/esmdev/webgl/shaders/RaymarchingShadowShaderPart.js +14 -14
- package/dist/esmdev/webgl/shaders/StandardShaderPart.js +3 -3
- package/dist/esmdev/webgl/shaders/nodes/BlockBeginShader.js +10 -10
- package/dist/esmdev/webgl/shaders/nodes/BlockEndShader.js +10 -10
- package/dist/esmdev/webgl/shaders/nodes/ConstantVariableShader.js +21 -21
- package/dist/esmdev/webgl/shaders/nodes/DiscardShader.js +3 -3
- package/dist/esmdev/webgl/shaders/nodes/EndShader.js +3 -3
- package/dist/esmdev/webgl/shaders/nodes/OutDistance.js +12 -12
- package/dist/esmdev/webgl/shaders/nodes/OutUnion.js +9 -9
- package/dist/esmdev/webgl/shaders/nodes/RaymarchObjectIdUniform.js +8 -8
- package/dist/esmdev/webgl/shaders/nodes/SdApplyTransform.js +9 -9
- package/dist/esmdev/webgl/shaders/nodes/SdApplyWorldMatrix.js +8 -8
- package/dist/esmdev/webgl/shaders/nodes/Texture2DShader.js +23 -23
- package/dist/esmdev/webgl/shaders/nodes/UniformDataShader.js +23 -23
- package/dist/esmdev/webgl/textureLoader/KTX2TextureLoader.js +27 -27
- package/dist/esmdev/webgpu/GpuCullingRegistry.js +94 -94
- package/dist/esmdev/webgpu/GpuDeformRegistry.js +53 -53
- package/dist/esmdev/webgpu/RangeAllocator.js +16 -16
- package/dist/esmdev/webgpu/WebGpuBufferArena.js +21 -21
- package/dist/esmdev/webgpu/WebGpuDeviceWrapper.js +7 -7
- package/dist/esmdev/webgpu/WebGpuGpuCulling.js +198 -198
- package/dist/esmdev/webgpu/WebGpuGpuTimer.js +52 -52
- package/dist/esmdev/webgpu/WebGpuLightClusterBuilder.js +37 -37
- package/dist/esmdev/webgpu/WebGpuResourceRepository.js +597 -597
- package/dist/esmdev/webgpu/WebGpuStrategyBasic.d.ts +8 -0
- package/dist/esmdev/webgpu/WebGpuStrategyBasic.js +170 -133
- package/dist/esmdev/webgpu/WebGpuVertexDeformer.js +128 -128
- package/dist/esmdev/webgpu/shaderity_shaders/MotionVectorShader/MotionVectorShader.frag.wgsl.js +12 -0
- package/dist/esmdev/webgpu/shaderity_shaders/MotionVectorShader/MotionVectorShader.vert.wgsl.js +12 -0
- package/dist/esmdev/webgpu/shaderity_shaders/TemporalAAResolveShader/TemporalAAResolveShader.frag.wgsl.js +12 -0
- package/dist/esmdev/webgpu/shaderity_shaders/TemporalAAResolveShader/TemporalAAResolveShader.vert.wgsl.js +12 -0
- package/dist/esmdev/xr/WebARSystem.js +69 -69
- package/dist/esmdev/xr/WebXRSystem.js +153 -153
- package/package.json +1 -1
package/dist/esm/webgl/shaderity_shaders/TemporalAAResolveShader/TemporalAAResolveShader.frag.js
ADDED
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
var r=`
|
|
2
|
+
|
|
3
|
+
/* shaderity: @{glslPrecision} */
|
|
4
|
+
|
|
5
|
+
/* shaderity: @{renderTargetBegin} */
|
|
6
|
+
|
|
7
|
+
/* shaderity: @{definitions} */
|
|
8
|
+
|
|
9
|
+
/* shaderity: @{prerequisites} */
|
|
10
|
+
|
|
11
|
+
/* shaderity: @{getters} */
|
|
12
|
+
|
|
13
|
+
/* shaderity: @{vertexIn} */
|
|
14
|
+
|
|
15
|
+
// Temporal anti-aliasing resolve: blends the current (jittered) frame with the reprojected history.
|
|
16
|
+
// u_baseColorTexture: the current frame, u_historyTexture: the previous result,
|
|
17
|
+
// u_velocityTexture: xy = the motion from the previous frame in texture coordinates, z = the depth.
|
|
18
|
+
|
|
19
|
+
vec3 rgbToYCoCg(vec3 c) {
|
|
20
|
+
return vec3(0.25 * c.r + 0.5 * c.g + 0.25 * c.b, 0.5 * c.r - 0.5 * c.b, -0.25 * c.r + 0.5 * c.g - 0.25 * c.b);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
vec3 yCoCgToRgb(vec3 c) {
|
|
24
|
+
float t = c.x - c.z;
|
|
25
|
+
return vec3(t + c.y, c.x + c.z, t - c.y);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Bicubic Catmull-Rom filtering of the history with 5 bilinear taps (the 4 corner taps are dropped),
|
|
29
|
+
// which keeps the history sharp when it is resampled every frame.
|
|
30
|
+
vec3 sampleHistoryCatmullRom(vec2 uv, vec2 textureSize) {
|
|
31
|
+
vec2 samplePosition = uv * textureSize;
|
|
32
|
+
vec2 texPosition1 = floor(samplePosition - 0.5) + 0.5;
|
|
33
|
+
vec2 f = samplePosition - texPosition1;
|
|
34
|
+
vec2 w0 = f * (-0.5 + f * (1.0 - 0.5 * f));
|
|
35
|
+
vec2 w1 = 1.0 + f * f * (-2.5 + 1.5 * f);
|
|
36
|
+
vec2 w2 = f * (0.5 + f * (2.0 - 1.5 * f));
|
|
37
|
+
vec2 w3 = f * f * (-0.5 + 0.5 * f);
|
|
38
|
+
vec2 w12 = w1 + w2;
|
|
39
|
+
vec2 offset12 = w2 / w12;
|
|
40
|
+
vec2 texPosition0 = (texPosition1 - 1.0) / textureSize;
|
|
41
|
+
vec2 texPosition3 = (texPosition1 + 2.0) / textureSize;
|
|
42
|
+
vec2 texPosition12 = (texPosition1 + offset12) / textureSize;
|
|
43
|
+
|
|
44
|
+
vec3 result = texture(u_historyTexture, vec2(texPosition12.x, texPosition0.y)).rgb * (w12.x * w0.y);
|
|
45
|
+
result += texture(u_historyTexture, vec2(texPosition0.x, texPosition12.y)).rgb * (w0.x * w12.y);
|
|
46
|
+
result += texture(u_historyTexture, texPosition12).rgb * (w12.x * w12.y);
|
|
47
|
+
result += texture(u_historyTexture, vec2(texPosition3.x, texPosition12.y)).rgb * (w3.x * w12.y);
|
|
48
|
+
result += texture(u_historyTexture, vec2(texPosition12.x, texPosition3.y)).rgb * (w12.x * w3.y);
|
|
49
|
+
float weightSum = w12.x * w0.y + w0.x * w12.y + w12.x * w12.y + w3.x * w12.y + w12.x * w3.y;
|
|
50
|
+
return max(result / weightSum, vec3(0.0));
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// The color of the pixel at texelOffset for the clipping box, or fallback when that pixel moves: the box only
|
|
54
|
+
// grows to cover the sub-pixel coverage changes of still surfaces, not the colors of moving objects, whose
|
|
55
|
+
// stale history would otherwise survive behind them.
|
|
56
|
+
vec3 stillNeighborForBox(vec2 uv, vec2 texelOffset, vec2 texelSize, vec2 framebufferSize, vec3 fallback) {
|
|
57
|
+
vec2 sampleUv = uv + texelOffset * texelSize;
|
|
58
|
+
vec2 velocity = texture(u_velocityTexture, sampleUv).xy;
|
|
59
|
+
vec3 color = rgbToYCoCg(texture(u_baseColorTexture, sampleUv).rgb);
|
|
60
|
+
return length(velocity * framebufferSize) >= 0.5 ? fallback : color;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
void main ()
|
|
64
|
+
{
|
|
65
|
+
/* shaderity: @{mainPrerequisites} */
|
|
66
|
+
|
|
67
|
+
vec2 uv = v_texcoord_0;
|
|
68
|
+
vec2 framebufferSize = get_framebufferSize(materialSID, 0u);
|
|
69
|
+
vec2 texelSize = 1.0 / framebufferSize;
|
|
70
|
+
|
|
71
|
+
vec4 centerSample = texture(u_baseColorTexture, uv);
|
|
72
|
+
float currentAlpha = centerSample.a;
|
|
73
|
+
|
|
74
|
+
// The position where this frame sampled the scene, relative to the center of each pixel, in texels. The jitter
|
|
75
|
+
// moves the geometry by currentJitter (NDC), i.e. the sample position by -currentJitter. In WebGL, the texture
|
|
76
|
+
// coordinates of a render target have the same orientation as NDC (both y up).
|
|
77
|
+
vec2 currentJitter = get_currentJitter(materialSID, 0u);
|
|
78
|
+
vec2 sampleOffset = -currentJitter * framebufferSize * 0.5;
|
|
79
|
+
|
|
80
|
+
// Statistics of the 3x3 neighborhood (for the variance clipping), the closest surface in it (whose motion vector
|
|
81
|
+
// is used, so that the edges of moving objects reproject with them) and the reconstruction of the current frame.
|
|
82
|
+
vec3 moment1 = vec3(0.0);
|
|
83
|
+
vec3 moment2 = vec3(0.0);
|
|
84
|
+
vec3 filtered = vec3(0.0);
|
|
85
|
+
float filterWeightSum = 0.0;
|
|
86
|
+
float closestDepth = 2.0;
|
|
87
|
+
vec2 closestOffset = vec2(0.0);
|
|
88
|
+
for (int y = -1; y <= 1; y++) {
|
|
89
|
+
for (int x = -1; x <= 1; x++) {
|
|
90
|
+
vec2 texelOffset = vec2(float(x), float(y));
|
|
91
|
+
vec2 offset = texelOffset * texelSize;
|
|
92
|
+
vec3 neighbor = rgbToYCoCg(texture(u_baseColorTexture, uv + offset).rgb);
|
|
93
|
+
moment1 += neighbor;
|
|
94
|
+
moment2 += neighbor * neighbor;
|
|
95
|
+
// Reconstruction filter: weights each sample by its distance from the center of this pixel, with the
|
|
96
|
+
// Gaussian fit of a Blackman-Harris window (Karis 2014). Without it, the sample of every frame counts the
|
|
97
|
+
// same wherever the jitter put it, and edge pixels flicker with the period of the jitter sequence.
|
|
98
|
+
vec2 sampleDistance = texelOffset + sampleOffset;
|
|
99
|
+
float filterWeight = exp(-2.29 * dot(sampleDistance, sampleDistance));
|
|
100
|
+
filtered += neighbor * filterWeight;
|
|
101
|
+
filterWeightSum += filterWeight;
|
|
102
|
+
float depth = texture(u_velocityTexture, uv + offset).z;
|
|
103
|
+
if (depth < closestDepth) {
|
|
104
|
+
closestDepth = depth;
|
|
105
|
+
closestOffset = offset;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
vec3 currentYCoCg = filtered / filterWeightSum;
|
|
110
|
+
|
|
111
|
+
vec2 velocity = texture(u_velocityTexture, uv + closestOffset).xy;
|
|
112
|
+
vec2 historyUv = uv - velocity;
|
|
113
|
+
bool isHistoryValid = get_isHistoryValid(materialSID, 0u);
|
|
114
|
+
if (!isHistoryValid || historyUv.x < 0.0 || historyUv.x > 1.0 || historyUv.y < 0.0 || historyUv.y > 1.0) {
|
|
115
|
+
rt0 = vec4(max(yCoCgToRgb(currentYCoCg), vec3(0.0)), currentAlpha);
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
vec3 history = rgbToYCoCg(sampleHistoryCatmullRom(historyUv, framebufferSize));
|
|
120
|
+
|
|
121
|
+
// Variance clipping (Salvi 2016): clip the history into a box around the neighborhood.
|
|
122
|
+
// - The box also contains the colors 2 pixels away in the 4 axis directions, where those pixels do not move. The
|
|
123
|
+
// reconstruction filter spreads a surface into the pixels next to it, so a pixel beside a high contrast edge
|
|
124
|
+
// accumulates some of the surface; in the frames where the jitter puts the samples of its 3x3 neighborhood all
|
|
125
|
+
// on the other side, the variance box collapses (sigma = 0) and would clip that history away every few
|
|
126
|
+
// frames, which flickers.
|
|
127
|
+
// - The box always contains the sample of this pixel and the reconstructed current color, and the history is
|
|
128
|
+
// clipped along the line towards the reconstructed current color. The result then always lies between the
|
|
129
|
+
// history and the current color. Clipping towards the center of the box instead moved the luminance towards
|
|
130
|
+
// the center: a gray pixel, whose chroma extents are almost 0, was clipped by a chroma difference of 1e-4 and
|
|
131
|
+
// its luminance pulled up to the middle of an asymmetric box, once per jitter sequence.
|
|
132
|
+
// - The chroma of grays is almost 0, so the distance to the box is measured with a tolerance proportional to the
|
|
133
|
+
// luminance, so that rounding differences in the chroma do not clip the history.
|
|
134
|
+
vec3 mean = moment1 / 9.0;
|
|
135
|
+
vec3 sigma = sqrt(max(moment2 / 9.0 - mean * mean, vec3(0.0)));
|
|
136
|
+
float varianceClipGamma = get_varianceClipGamma(materialSID, 0u);
|
|
137
|
+
vec3 farLeft = stillNeighborForBox(uv, vec2(-2.0, 0.0), texelSize, framebufferSize, currentYCoCg);
|
|
138
|
+
vec3 farRight = stillNeighborForBox(uv, vec2(2.0, 0.0), texelSize, framebufferSize, currentYCoCg);
|
|
139
|
+
vec3 farDown = stillNeighborForBox(uv, vec2(0.0, -2.0), texelSize, framebufferSize, currentYCoCg);
|
|
140
|
+
vec3 farUp = stillNeighborForBox(uv, vec2(0.0, 2.0), texelSize, framebufferSize, currentYCoCg);
|
|
141
|
+
vec3 centerYCoCg = rgbToYCoCg(centerSample.rgb);
|
|
142
|
+
vec3 localMin = min(min(centerYCoCg, currentYCoCg), min(min(farLeft, farRight), min(farUp, farDown)));
|
|
143
|
+
vec3 localMax = max(max(centerYCoCg, currentYCoCg), max(max(farLeft, farRight), max(farUp, farDown)));
|
|
144
|
+
vec3 boxMin = min(mean - sigma * varianceClipGamma, localMin);
|
|
145
|
+
vec3 boxMax = max(mean + sigma * varianceClipGamma, localMax);
|
|
146
|
+
vec3 toHistory = history - currentYCoCg;
|
|
147
|
+
vec3 roomToBox = mix(currentYCoCg - boxMin, boxMax - currentYCoCg, vec3(greaterThan(toHistory, vec3(0.0))));
|
|
148
|
+
float tolerance = 1.0e-4 + 0.01 * (abs(currentYCoCg.x) + abs(history.x));
|
|
149
|
+
vec3 ratio = abs(toHistory) / max(roomToBox, vec3(tolerance));
|
|
150
|
+
float maxRatio = max(ratio.x, max(ratio.y, ratio.z));
|
|
151
|
+
if (maxRatio > 1.0) {
|
|
152
|
+
history = currentYCoCg + toHistory / maxRatio;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// The weight of the current frame. Pixels that do not move use the smaller static weight: the exponential blend
|
|
156
|
+
// weights the recent frames of the jitter sequence more, and a smaller weight averages the sequence more evenly.
|
|
157
|
+
// Pixels that move by a pixel per frame or more keep the larger weight, so that the history, resampled every
|
|
158
|
+
// frame, does not blur. Right after a reset, the weight starts at 1 / (n + 1), the even average of the frames.
|
|
159
|
+
float movingFrameWeight = get_currentFrameWeight(materialSID, 0u);
|
|
160
|
+
float staticFrameWeight = min(get_staticFrameWeight(materialSID, 0u), movingFrameWeight);
|
|
161
|
+
float speedInPixels = length(velocity * framebufferSize);
|
|
162
|
+
float historyFrameCount = get_historyFrameCount(materialSID, 0u);
|
|
163
|
+
float blendFactor = max(
|
|
164
|
+
mix(staticFrameWeight, movingFrameWeight, clamp(speedInPixels, 0.0, 1.0)),
|
|
165
|
+
1.0 / (historyFrameCount + 1.0)
|
|
166
|
+
);
|
|
167
|
+
|
|
168
|
+
// Exponential blend weighted by the inverse luminance (Karis 2014) to suppress flickering highlights.
|
|
169
|
+
float currentWeight = blendFactor / (1.0 + currentYCoCg.x);
|
|
170
|
+
float historyWeight = (1.0 - blendFactor) / (1.0 + history.x);
|
|
171
|
+
vec3 result = (currentYCoCg * currentWeight + history * historyWeight) / (currentWeight + historyWeight);
|
|
172
|
+
|
|
173
|
+
rt0 = vec4(max(yCoCgToRgb(result), vec3(0.0)), currentAlpha);
|
|
174
|
+
}
|
|
175
|
+
`,n="fragment",o=!0,i={code:r,shaderStage:n,isFragmentShader:o};export{r as code,i as default,o as isFragmentShader,n as shaderStage};
|
package/dist/esm/webgl/shaderity_shaders/TemporalAAResolveShader/TemporalAAResolveShader.vert.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
var s=`
|
|
2
|
+
/* shaderity: @{enableVertexExtensions} */
|
|
3
|
+
/* shaderity: @{glslPrecision} */
|
|
4
|
+
|
|
5
|
+
/* shaderity: @{definitions} */
|
|
6
|
+
|
|
7
|
+
/* shaderity: @{vertexInOut} */
|
|
8
|
+
/* shaderity: @{prerequisites} */
|
|
9
|
+
|
|
10
|
+
/* shaderity: @{getters} */
|
|
11
|
+
|
|
12
|
+
/* shaderity: @{matricesGetters} */
|
|
13
|
+
|
|
14
|
+
void main(){
|
|
15
|
+
/* shaderity: @{mainPrerequisites} */
|
|
16
|
+
/* shaderity: @{fullscreen} */
|
|
17
|
+
}
|
|
18
|
+
`,i="vertex",r=!1,t={code:s,shaderStage:i,isFragmentShader:r};export{s as code,t as default,r as isFragmentShader,i as shaderStage};
|
|
@@ -30,7 +30,7 @@ void main() {
|
|
|
30
30
|
}
|
|
31
31
|
`}getMaterialSIDForWebGL(){return`
|
|
32
32
|
uint materialSID = uint(u_currentComponentSIDs[0]); // index 0 data is the materialSID
|
|
33
|
-
`}getVertexPrerequisites(r,t){if(r.engineState.currentProcessApproach===p.WebGPU){let n=this.
|
|
33
|
+
`}getVertexPrerequisites(r,t){if(r.engineState.currentProcessApproach===p.WebGPU){let n=this.q_(t),i="";return i+=`
|
|
34
34
|
/* shaderity: @{definitions} */
|
|
35
35
|
#define RN_IS_NODE_SHADER
|
|
36
36
|
|
|
@@ -82,8 +82,8 @@ in vec4 a_weight;
|
|
|
82
82
|
in vec4 a_baryCentricCoord;
|
|
83
83
|
in vec4 a_tangent;
|
|
84
84
|
flat out uvec4 v_instanceIds;
|
|
85
|
-
`,e+="/* shaderity: @{getters} */",e+="/* shaderity: @{matricesGetters} */",e+="/* shaderity: @{opticalDefinition} */",e+="/* shaderity: @{shadowDefinition} */",e+="/* shaderity: @{pbrDefinition} */",e+="/* shaderity: @{iblDefinition} */",e}
|
|
86
|
-
`}return n+=`@location(${t.length}) @interpolate(flat) instanceIds: vec4<u32>,`,n}getPixelPrerequisites(r,t){if(r.engineState.currentProcessApproach===p.WebGPU){let n=this.
|
|
85
|
+
`,e+="/* shaderity: @{getters} */",e+="/* shaderity: @{matricesGetters} */",e+="/* shaderity: @{opticalDefinition} */",e+="/* shaderity: @{shadowDefinition} */",e+="/* shaderity: @{pbrDefinition} */",e+="/* shaderity: @{iblDefinition} */",e}q_(r){let t=[],e=new Set;for(let i=0;i<r.length;i++){let o=r[i];for(let a=0;a<o.inputConnections.length;a++){let d=o.inputConnections[a];if(d==null)continue;let s=o.getInputs()[a],c=y.getShaderNodeByUid(d.shaderNodeUid);if(c.getShaderStage()==="Vertex"&&o.getShaderStage()==="Fragment"){let m=s.compositionType.toWGSLType(s.componentType),u=`${c.shaderFunctionName}_${c.shaderNodeUid}_${d.outputNameOfPrev}`;if(e.has(u))continue;e.add(u);let f=s.componentType.isInteger()||s.componentType.isUnsignedInteger()||s.componentType===h.Bool;t.push({type:m,name:u,needsFlat:f})}}}t.sort((i,o)=>i.name<o.name?-1:1);let n="";for(let i=0;i<t.length;i++){let o=t[i].needsFlat?" @interpolate(flat)":"";n+=`@location(${i})${o} ${t[i].name}: ${t[i].type},
|
|
86
|
+
`}return n+=`@location(${t.length}) @interpolate(flat) instanceIds: vec4<u32>,`,n}getPixelPrerequisites(r,t){if(r.engineState.currentProcessApproach===p.WebGPU){let n=this.q_(t),i="";return i+=`
|
|
87
87
|
/* shaderity: @{definitions} */
|
|
88
88
|
#define RN_IS_NODE_SHADER
|
|
89
89
|
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import{ComponentType as r}from"../../../foundation/definitions/ComponentType.js";import{ProcessApproach as i}from"../../../foundation/definitions/ProcessApproach.js";import{StandardShaderPart as n}from"../StandardShaderPart.js";var o=class extends n{constructor(t,e,p){super();this.$A=t;this.
|
|
1
|
+
import{ComponentType as r}from"../../../foundation/definitions/ComponentType.js";import{ProcessApproach as i}from"../../../foundation/definitions/ProcessApproach.js";import{StandardShaderPart as n}from"../StandardShaderPart.js";var o=class extends n{constructor(t,e,p){super();this.$A=t;this.p_=e;this.c_=p;this.oV=""}setConstantValue(t){let e="";this.c_.isFloatingPoint()?e=t.glslStrAsFloat:this.c_.isInteger()?e=t.glslStrAsInt:this.c_.isUnsignedInteger()?e=t.glslStrAsUint:this.c_===r.Bool&&(e=t.x?"true":"false"),this.oV=e}getVertexShaderDefinitions(t){return t.engineState.currentProcessApproach===i.WebGPU?`
|
|
2
2
|
fn ${this.$A}(
|
|
3
|
-
outValue: ptr<function, ${this.
|
|
3
|
+
outValue: ptr<function, ${this.p_.toWGSLType(this.c_)}>) {
|
|
4
4
|
*outValue = ${this.oV};
|
|
5
5
|
}
|
|
6
6
|
`:`
|
|
7
7
|
void ${this.$A}(
|
|
8
|
-
out ${this.
|
|
8
|
+
out ${this.p_.getGlslStr(this.c_)} outValue) {
|
|
9
9
|
outValue = ${this.oV};
|
|
10
10
|
}
|
|
11
11
|
`}getPixelShaderDefinitions(t){return t.engineState.currentProcessApproach===i.WebGPU?`
|
|
12
12
|
fn ${this.$A}(
|
|
13
|
-
outValue: ptr<function, ${this.
|
|
13
|
+
outValue: ptr<function, ${this.p_.toWGSLType(this.c_)}>) {
|
|
14
14
|
*outValue = ${this.oV};
|
|
15
15
|
}
|
|
16
16
|
`:`
|
|
17
17
|
void ${this.$A}(
|
|
18
|
-
out ${this.
|
|
18
|
+
out ${this.p_.getGlslStr(this.c_)} outValue) {
|
|
19
19
|
outValue = ${this.oV};
|
|
20
20
|
}
|
|
21
21
|
`}get attributeNames(){return[]}get attributeSemantics(){return[]}get attributeCompositions(){return[]}};export{o as ConstantVariableShader};
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import{ProcessApproach as e}from"../../../foundation/definitions/ProcessApproach.js";import{StandardShaderPart as r}from"../StandardShaderPart.js";var i=class extends r{constructor(t,s,a){super();this.$A=t;this.
|
|
2
|
-
// #param ${this.qA}: ${this.
|
|
3
|
-
fn ${this.$A}(outValue: ptr<function, ${this.
|
|
1
|
+
import{ProcessApproach as e}from"../../../foundation/definitions/ProcessApproach.js";import{StandardShaderPart as r}from"../StandardShaderPart.js";var i=class extends r{constructor(t,s,a){super();this.$A=t;this.p_=s;this.c_=a;this.qA="";this.t$=""}setVariableName(t){this.qA=t}setDefaultValue(t){this.t$=t.toString()}getVertexShaderDefinitions(t){return t.engineState.currentProcessApproach===e.WebGPU?`
|
|
2
|
+
// #param ${this.qA}: ${this.p_.toWGSLType(this.c_)}; // initialValue=${this.t$}
|
|
3
|
+
fn ${this.$A}(outValue: ptr<function, ${this.p_.toWGSLType(this.c_)}>) {
|
|
4
4
|
*outValue = get_${this.qA}(uniformDrawParameters.materialSid, 0u);
|
|
5
5
|
}
|
|
6
6
|
`:`
|
|
7
|
-
uniform ${this.
|
|
8
|
-
void ${this.$A}(out ${this.
|
|
7
|
+
uniform ${this.p_.getGlslStr(this.c_)} u_${this.qA}; // initialValue=${this.t$}
|
|
8
|
+
void ${this.$A}(out ${this.p_.getGlslStr(this.c_)} outValue) {
|
|
9
9
|
${this.getMaterialSIDForWebGL()}
|
|
10
10
|
|
|
11
11
|
outValue = get_${this.qA}(materialSID, 0u);
|
|
12
12
|
}
|
|
13
13
|
`}getPixelShaderDefinitions(t){return t.engineState.currentProcessApproach===e.WebGPU?`
|
|
14
|
-
// #param ${this.qA}: ${this.
|
|
15
|
-
fn ${this.$A}(outValue: ptr<function, ${this.
|
|
14
|
+
// #param ${this.qA}: ${this.p_.toWGSLType(this.c_)}; // initialValue=${this.t$}
|
|
15
|
+
fn ${this.$A}(outValue: ptr<function, ${this.p_.toWGSLType(this.c_)}>) {
|
|
16
16
|
*outValue = get_${this.qA}(uniformDrawParameters.materialSid, 0u);
|
|
17
17
|
}
|
|
18
18
|
`:`
|
|
19
|
-
uniform ${this.
|
|
20
|
-
void ${this.$A}(out ${this.
|
|
19
|
+
uniform ${this.p_.getGlslStr(this.c_)} u_${this.qA}; // initialValue=${this.t$}
|
|
20
|
+
void ${this.$A}(out ${this.p_.getGlslStr(this.c_)} outValue) {
|
|
21
21
|
${this.getMaterialSIDForWebGL()}
|
|
22
22
|
|
|
23
23
|
outValue = get_${this.qA}(materialSID, 0u);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{RangeAllocator as a}from"./RangeAllocator.js";var c=64,p=class{constructor(e){this.
|
|
1
|
+
import{RangeAllocator as a}from"./RangeAllocator.js";var c=64,p=class{constructor(e){this.hG=0;this.aG=0;this.YC=[];this.rG=0;this.ZC=[];this.uG=0;this.KC=new Map;this.tG=new Map;this.QC=[];this.lG=!1;this.pG={instances:0,groups:0,draws:0,chunks:0};this.oG=0;this.Mb=0;this.iG={...e},this.sG=new a(e.instances),this.nG=new a(e.chunks)}get capacities(){return this.iG}get groupHighWater(){return this.rG}get chunkHighWater(){return this.hG}get drawHighWater(){return this.uG}get liveGroupCount(){return this.rG-this.YC.length}get version(){return this.Mb}get isOverflowed(){return this.lG}get isRecording(){return this.HC!==void 0}get requiredCapacities(){let e=this.pG;return{instances:this.oG+e.instances,groups:this.liveGroupCount+e.groups,draws:this.uG-this.ZC.length+e.draws,chunks:this.aG+e.chunks}}beginRecording(){this.HC!==void 0&&this.QC.push(this.HC),this.HC={groups:[],draws:[]},this.tG.clear()}getOrAllocateGroup(e,t,s){let i=this.HC;if(i===void 0||s<=0)return;let n=this.tG.get(e),o=n==null?void 0:n.get(t);if(o!==void 0&&o.instanceCount===s)return o;let r=Math.ceil(s/c),h=this.sG.allocate(s,1),u=this.nG.allocate(r,1),d=this.YC.length>0||this.rG<this.iG.groups;if(h<0||u<0||!d){h>=0&&this.sG.release(h,s),u>=0&&this.nG.release(u,r),this.dG(s,1,0,r);return}let l={index:this.YC.length>0?this.YC.pop():this.rG++,rangeBase:h,instanceCount:s,viewIndex:t,chunkBase:u,chunkCount:r};return this.oG+=s,this.aG+=r,this.hG=Math.max(this.hG,u+r),i.groups.push(l),n===void 0&&(n=new Map,this.tG.set(e,n)),n.set(t,l),this.Mb++,l}allocateDraw(){let e=this.HC;if(e===void 0)return-1;if(this.ZC.length===0&&this.uG>=this.iG.draws)return this.dG(0,0,1,0),-1;let t=this.ZC.length>0?this.ZC.pop():this.uG++;return e.draws.push(t),this.Mb++,t}finishRecording(e){let t=this.HC;if(t!==void 0){if(this.HC=void 0,this.tG.clear(),e===void 0){this.QC.push(t);return}this.retireBundle(e),(t.groups.length>0||t.draws.length>0)&&this.KC.set(e,t)}}abortRecording(){this.HC!==void 0&&(this.QC.push(this.HC),this.HC=void 0,this.tG.clear())}retireBundle(e){let t=this.KC.get(e);t!==void 0&&(this.KC.delete(e),this.QC.push(t))}retireAllBundles(){for(let e of this.KC.values())this.QC.push(e);this.KC.clear()}releaseRetired(){let e=this.QC;if(e.length===0)return;let t={groups:[],draws:[]};for(let s of e){for(let i of s.groups)this.sG.release(i.rangeBase,i.instanceCount),this.oG-=i.instanceCount,this.nG.release(i.chunkBase,i.chunkCount),this.aG-=i.chunkCount,this.YC.push(i.index),t.groups.push(i);for(let i of s.draws)this.ZC.push(i),t.draws.push(i)}return e.length=0,this.Mb++,t}reset(e){this.iG={...e},this.sG=new a(e.instances),this.nG=new a(e.chunks),this.hG=0,this.aG=0,this.YC.length=0,this.rG=0,this.ZC.length=0,this.uG=0,this.KC.clear(),this.HC=void 0,this.tG.clear(),this.QC.length=0,this.lG=!1,this.pG={instances:0,groups:0,draws:0,chunks:0},this.oG=0,this.Mb++}dG(e,t,s,i){this.lG=!0;let n=this.pG;n.instances+=e,n.groups+=t,n.draws+=s,n.chunks+=i}};export{c as GpuCullingChunkSize,p as GpuCullingRegistry};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{RangeAllocator as o}from"./RangeAllocator.js";var x=64,k=class{constructor(e){this.H0=new Map;this.nk=0;this.
|
|
1
|
+
import{RangeAllocator as o}from"./RangeAllocator.js";var x=64,k=class{constructor(e){this.H0=new Map;this.nk=0;this.hG=0;this.lG=!1;this.pG={sourceVertices:0,deformedVertices:0,bounds:0,chunks:0};this.Mb=0;this.iG={...e},this.ek=new o(e.sourceVertices),this.rk=new o(e.deformedVertices),this.tk=new o(e.bounds),this.nG=new o(e.chunks)}get capacities(){return this.iG}get entries(){return this.H0.values()}get entryCount(){return this.H0.size}get boundsHighWater(){return this.nk}get chunkHighWater(){return this.hG}get version(){return this.Mb}get isOverflowed(){return this.lG}get requiredCapacities(){let e={...this.pG};for(let r of this.H0.values())e.sourceVertices+=r.vertexCount,e.deformedVertices+=r.vertexCount*r.instanceCount,e.bounds+=r.instanceCount,e.chunks+=r.chunkCount;return e}acquire(e,r,n){let d=this.H0.get(e);if(d!==void 0)return d.refCount++,{entry:d,isNew:!1};if(n<=0||r.length===0)return;let b=[],p=[],s=0,l=0;for(let u of r){b.push(s);let v=Math.ceil(u/x);p.push(v),s+=u,l+=v}if(s===0)return;let m=s*n,i=l*n,c=this.ek.allocate(s,1),f=this.rk.allocate(m,1),a=this.tk.allocate(n,1),h=this.nG.allocate(i,1);if(c<0||f<0||a<0||h<0){c>=0&&this.ek.release(c,s),f>=0&&this.rk.release(f,m),a>=0&&this.tk.release(a,n),h>=0&&this.nG.release(h,i),this.lG=!0;let u=this.pG;u.sourceVertices+=s,u.deformedVertices+=m,u.bounds+=n,u.chunks+=i;return}let C={key:e,primitiveVertexCounts:r.slice(),primitiveOffsets:b,primitiveChunkCounts:p,vertexCount:s,chunkCountPerInstance:l,instanceCount:n,sourceBase:c,deformedBase:f,boundsBase:a,chunkBase:h,chunkCount:i,refCount:1};return this.H0.set(e,C),this.nk=Math.max(this.nk,a+n),this.hG=Math.max(this.hG,h+i),this.Mb++,{entry:C,isNew:!0}}release(e){return this.H0.get(e.key)!==e||(e.refCount--,e.refCount>0)?!1:(this.H0.delete(e.key),this.ek.release(e.sourceBase,e.vertexCount),this.rk.release(e.deformedBase,e.vertexCount*e.instanceCount),this.tk.release(e.boundsBase,e.instanceCount),this.nG.release(e.chunkBase,e.chunkCount),this.Mb++,!0)}reset(e){this.iG={...e},this.ek=new o(e.sourceVertices),this.rk=new o(e.deformedVertices),this.tk=new o(e.bounds),this.nG=new o(e.chunks),this.H0.clear(),this.nk=0,this.hG=0,this.lG=!1,this.pG={sourceVertices:0,deformedVertices:0,bounds:0,chunks:0},this.Mb++}};function y(t){return(t&2147483648)!==0?~t>>>0:(t|2147483648)>>>0}function D(t){return(t&2147483648)!==0?(t&2147483647)>>>0:~t>>>0}export{x as GpuDeformChunkSize,k as GpuDeformRegistry,D as decodeOrderedFloat,y as encodeOrderedFloat};
|
|
@@ -233,4 +233,4 @@ fn finalize(@builtin(global_invocation_id) id: vec3<u32>) {
|
|
|
233
233
|
// The indirect arguments are [indexCount or vertexCount, instanceCount, ...].
|
|
234
234
|
args[d * 5u + 1u] = count;
|
|
235
235
|
}
|
|
236
|
-
`,Z=64,fe=65535,V=64,X=V/4,T=16,w=60,le=w*4,O=20,F=O/4,M=16,j=16,D=4294967295,J=1,ce=2,L=8,Q={instances:8192,groups:2048,draws:4096,chunks:4096},ee=class{constructor(t){this.YG=new Uint32Array(j/4);this.aG=0;this._G=new Float32Array(0);this.WG=new Float32Array(0);this.SG=new B;this.gG=new B;this.mG=new B;this.VG=new B;this.vG=new B;this.dG=[];this.OG=[];this.TG=new Map;this.bG=!0;this.FG=-1;this.LG=-1;this.uB=t,this.rG=new ne(Q),this.nG=new se(t);let r=(a,d,l,n)=>{let f=t.createBindGroupLayout({label:`GpuCulling.${a}`,entries:n.map((p,g)=>({binding:g,visibility:GPUShaderStage.COMPUTE,buffer:{type:p}}))}),u=t.createComputePipeline({label:`GpuCulling.${a}`,layout:t.createPipelineLayout({bindGroupLayouts:[f]}),compute:{module:t.createShaderModule({label:`GpuCulling.${a}`,code:d}),entryPoint:l}});return{layout:f,pipeline:u}},e="read-only-storage",i="storage",o="uniform";this.GG={cull:r("cullChunks",oe,"cullChunks",[e,o,e,e,e,e,i,i,e]),prefix:r("prefixGroups",ue,"prefixGroups",[o,e,e,i,i]),scatter:r("scatter",ae,"scatter",[o,e,e,e,e,e,i]),finalize:r("finalize",de,"finalize",[o,e,e,i])},this.sG=t.createBuffer({label:"GpuCulling.params",size:j,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST}),this.NG(Q)}get registry(){return this.rG}get deformer(){return this.nG}get deformedVerticesBuffer(){return this.nG.deformedVerticesBuffer}beginRecording(){this.rG.beginRecording()}get isRecording(){return this.rG.isRecording}finishRecording(t){this.rG.finishRecording(t)}abortRecording(){this.rG.abortRecording()}retireAllBundles(){this.rG.retireAllBundles()}markInputsDirty(){this.bG=!0}registerDraw(t,r,e,i,o){let a=this.rG;if(!a.isRecording)return;let d=r._variationEntityInfo,l=r.meshEntitiesInner.length;if(d===void 0||d.length!==l*4||l===0)return;let n=this.$G(t,i);if(n<0)return;let f=a.getOrAllocateGroup(r,n,l);if(f===void 0)return;let u=this.dG[f.index];if(u===void 0||u.group!==f){let h=r._needsComputeDeformation,x=h?this.nG.acquire(t,r,d):void 0;u={group:f,range:{buffer:this.yG,offset:f.rangeBase*M,size:l*M},engine:t,mesh:r,entityInfo:d,positionUpdateCount:r.primitivePositionUpdateCount,deform:x,isDeformFailed:h&&x===void 0},this.dG[f.index]=u,this.HG(t,r,f,d,x)}if(u.isDeformFailed)return;let p;if(u.deform!==void 0&&(p=this.nG.getPrimitiveOffset(u.deform,e),p===void 0))return;let g=a.allocateDraw();if(g<0)return;let c=this.DG,s=g*F;return c[s]=o,c[s+1]=0,c[s+2]=0,c[s+3]=0,c[s+4]=0,this.VG.add(g,g+1),this.IG[g]=f.index,this.mG.add(g,g+1),{instanceVertexBuffer:u.range,indirectBuffer:this.lG,indirectOffset:g*O,deformedVertexOffset:p}}encode(t,r,e={}){var U,I,C,G,S,y;let i=this.rG,o=i.groupHighWater,a=i.drawHighWater;if(t==null||o===0)return;let d=this.KG(),l=re._primitivePositionUpdateVersion;l!==this.FG&&(this.FG=l,this.ZG());let n=this.nG;n.refresh();let f=n.hasEntries&&(this.bG||n.isChanged||this.fG!==t);if(!this.bG&&!f&&this.SG.isEmpty&&!d&&i.version===this.LG&&this.fG===t)return;this.bG=!1,this.LG=i.version;let u=this.uB;this.CG(this.xG,this.MG,this.SG,X),this.CG(this.uG,this.UG,this.gG,T/4),this.CG(this.cG,this.pG,this.vG,L/4),this.CG(this.wG,this.IG,this.mG,1),this.CG(this.lG,this.DG,this.VG,F);let p=i.chunkHighWater,g=Math.max(1,Math.min(p,fe)),c=this.YG;c[0]=o,c[1]=a,c[2]=p,c[3]=g,u.queue.writeBuffer(this.sG,0,c);let s=this.GG;(s.cull.bindGroup==null||this.fG!==t||this.EG!==n.boundsBuffer)&&(s.cull.bindGroup=this.AG(s.cull,[t,this.sG,this.xG,this.uG,this.oG,this.cG,this.PG,this.hG,n.boundsBuffer]),this.fG=t,this.EG=n.boundsBuffer),(I=(U=s.prefix).bindGroup)!=null||(U.bindGroup=this.AG(s.prefix,[this.sG,this.uG,this.hG,this.kG,this.BG])),(G=(C=s.scatter).bindGroup)!=null||(C.bindGroup=this.AG(s.scatter,[this.sG,this.uG,this.cG,this.hG,this.kG,this.PG,this.yG])),(y=(S=s.finalize).bindGroup)!=null||(S.bindGroup=this.AG(s.finalize,[this.sG,this.BG,this.wG,this.lG]));let h=u.createCommandEncoder({label:"GpuCulling"});f&&n.encode(h,t,e,r);let x={label:"GpuCulling"},k=r==null?void 0:r.getTimestampWrites("GpuCulling");k!=null&&(x.timestampWrites=k);let b=h.beginComputePass(x),P=Math.ceil(p/g);return p>0&&(b.setPipeline(s.cull.pipeline),b.setBindGroup(0,s.cull.bindGroup),b.dispatchWorkgroups(g,P)),b.setPipeline(s.prefix.pipeline),b.setBindGroup(0,s.prefix.bindGroup),b.dispatchWorkgroups(Math.ceil(o/Z)),p>0&&(b.setPipeline(s.scatter.pipeline),b.setBindGroup(0,s.scatter.bindGroup),b.dispatchWorkgroups(g,P)),a>0&&(b.setPipeline(s.finalize.pipeline),b.setBindGroup(0,s.finalize.bindGroup),b.dispatchWorkgroups(Math.ceil(a/Z))),b.end(),h.finish()}AG(t,r){return this.uB.createBindGroup({label:t.pipeline.label,layout:t.layout,entries:r.map((e,i)=>({binding:i,resource:{buffer:e}}))})}afterSubmit(){let t=this.rG,r=t.releaseRetired();if(r!==void 0){let d=this.UG;for(let n of r.groups){d[n.index*4+1]=0,this.gG.add(n.index,n.index+1);let f=this.pG;for(let p=0;p<n.chunkCount;p++)f[(n.chunkBase+p)*2]=D,f[(n.chunkBase+p)*2+1]=0;this.vG.add(n.chunkBase,n.chunkBase+n.chunkCount);let u=this.dG[n.index];(u==null?void 0:u.group)===n&&(u.deform!==void 0&&this.nG.release(u.deform),this.dG[n.index]=void 0)}let l=this.IG;for(let n of r.draws)l[n]=D,this.mG.add(n,n+1)}let e=this.nG,i=this.XG(),o=e.getGrownCapacities();if(i===void 0&&o===void 0&&!e.isResetRequested)return!1;let a=i!=null?i:{...t.capacities};return this.qG(),this.NG(a),t.reset(a),e.reset(o!=null?o:{...e.capacities}),this.dG.length=0,this.bG=!0,!0}XG(){let t=this.rG;if(!t.isOverflowed)return;let r=t.requiredCapacities,e=t.capacities,i=this.uB.limits,o=Math.min(i.maxStorageBufferBindingSize,i.maxBufferSize),a=(l,n,f)=>{let u=l;for(;u<n*1.25;)u*=2;return Math.max(l,Math.min(u,Math.floor(o/f)))},d={instances:a(e.instances,r.instances,V),groups:a(e.groups,r.groups,T),draws:a(e.draws,r.draws,O),chunks:a(e.chunks,r.chunks,L)};if(!(d.instances===e.instances&&d.groups===e.groups&&d.draws===e.draws&&d.chunks===e.chunks))return d}destroy(){var t;this.qG(),this.nG.destroy(),this.sG.destroy(),(t=this.oG)==null||t.destroy(),this.oG=void 0}NG(t){let r=this.uB,e=GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST;this.xG=r.createBuffer({label:"GpuCulling.records",size:t.instances*V,usage:e}),this.uG=r.createBuffer({label:"GpuCulling.groups",size:t.groups*T,usage:e}),this.BG=r.createBuffer({label:"GpuCulling.visibleCounts",size:t.groups*4,usage:GPUBufferUsage.STORAGE}),this.wG=r.createBuffer({label:"GpuCulling.drawGroups",size:t.draws*4,usage:e}),this.yG=r.createBuffer({label:"GpuCulling.visibleIds",size:t.instances*M,usage:GPUBufferUsage.VERTEX|GPUBufferUsage.STORAGE}),this.cG=r.createBuffer({label:"GpuCulling.chunks",size:t.chunks*L,usage:e}),this.hG=r.createBuffer({label:"GpuCulling.chunkCounts",size:t.chunks*4,usage:GPUBufferUsage.STORAGE}),this.kG=r.createBuffer({label:"GpuCulling.chunkOffsets",size:t.chunks*4,usage:GPUBufferUsage.STORAGE}),this.PG=r.createBuffer({label:"GpuCulling.scratchIds",size:t.instances*M,usage:GPUBufferUsage.STORAGE}),this.lG=r.createBuffer({label:"GpuCulling.args",size:t.draws*O,usage:GPUBufferUsage.INDIRECT|GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST|GPUBufferUsage.COPY_SRC}),this.zG=new ArrayBuffer(t.instances*V),this.MG=new Uint32Array(this.zG),this.RG=new Float32Array(this.zG),this.UG=new Uint32Array(t.groups*4),this.IG=new Uint32Array(t.draws).fill(D),this.DG=new Uint32Array(t.draws*F),this.pG=new Uint32Array(t.chunks*2);for(let i=0;i<t.chunks;i++)this.pG[i*2]=D;this.SG.clear(),this.gG.clear(),this.gG.add(0,t.groups),this.mG.clear(),this.mG.add(0,t.draws),this.VG.clear(),this.vG.clear(),this.vG.add(0,t.chunks),this.jG()}jG(){let t=this.GG;t.cull.bindGroup=void 0,t.prefix.bindGroup=void 0,t.scatter.bindGroup=void 0,t.finalize.bindGroup=void 0,this.fG=void 0}qG(){var t,r,e,i,o,a,d,l,n,f;(t=this.xG)==null||t.destroy(),(r=this.uG)==null||r.destroy(),(e=this.BG)==null||e.destroy(),(i=this.wG)==null||i.destroy(),(o=this.yG)==null||o.destroy(),(a=this.lG)==null||a.destroy(),(d=this.cG)==null||d.destroy(),(l=this.hG)==null||l.destroy(),(n=this.kG)==null||n.destroy(),(f=this.PG)==null||f.destroy()}CG(t,r,e,i){if(e.isEmpty)return;let o=e.min*i,a=Math.min(e.max*i,r.length);this.uB.queue.writeBuffer(t,o*4,r,o,a-o),e.clear()}ZG(){let t=this.dG;for(let r=0;r<t.length;r++){let e=t[r];e===void 0||e.mesh.primitivePositionUpdateCount===e.positionUpdateCount||(e.positionUpdateCount=e.mesh.primitivePositionUpdateCount,this.HG(e.engine,e.mesh,e.group,e.entityInfo,e.deform))}}HG(t,r,e,i,o){var N,H,q,Y,$;let a=this.UG,d=e.index*4;a[d]=e.rangeBase,a[d+1]=e.instanceCount,a[d+2]=e.viewIndex,a[d+3]=e.chunkBase,this.gG.add(e.index,e.index+1);let l=this.pG;for(let v=0;v<e.chunkCount;v++)l[(e.chunkBase+v)*2]=e.index,l[(e.chunkBase+v)*2+1]=v*ie;this.vG.add(e.chunkBase,e.chunkBase+e.chunkCount);let n=(N=z.getComponentCountPerBufferView(t).get(A))!=null?N:1,f=z.getLocationOffsetOfMemberOfComponent(t,A,"worldMatrix"),u=z.getLocationOffsetOfMemberOfComponent(t,A,"isVisible"),p=z.getLocationOffsetOfMemberOfComponent(t,A,"isBillboard"),g=r.AABB,c=!g.isVanilla(),s=g.minPoint._v,h=g.maxPoint._v,x=(s[0]+h[0])*.5,k=(s[1]+h[1])*.5,b=(s[2]+h[2])*.5,P=(h[0]-s[0])*.5,U=(h[1]-s[1])*.5,I=(h[2]-s[2])*.5,C=this.MG,G=this.RG,S=r.meshEntitiesInner,y=this.nG;for(let v=0;v<e.instanceCount;v++){let m=(e.rangeBase+v)*X,R=i[4*v],_=Math.floor(R/n),W=R%n;C[m]=R,C[m+1]=i[4*v+1],C[m+2]=i[4*v+2],C[m+3]=o!==void 0?y.getInstanceDeformedBase(o,v)+1:i[4*v+3],G[m+4]=x,G[m+5]=k,G[m+6]=b,C[m+7]=((H=f[_])!=null?H:0)+4*W,G[m+8]=P,G[m+9]=U,G[m+10]=I,C[m+11]=((q=u[_])!=null?q:0)*4+W,C[m+12]=((Y=p[_])!=null?Y:0)*4+W;let K=(($=S[v])==null?void 0:$.getTagValue("type"))==="background-assets";o!==void 0?(C[m+13]=ce|(K?J:0),C[m+14]=y.getInstanceBoundsSlot(o,v)):(C[m+13]=!c||K?J:0,C[m+14]=0),C[m+15]=0}this.SG.add(e.rangeBase,e.rangeBase+e.instanceCount)}$G(t,r){if(r<0)return-1;let e=t.componentRepository.getComponent(te,r);if(e==null)return-1;let i=this.TG.get(e);return i===void 0&&(i=this.OG.length,this.OG.push({camera:e}),this.TG.set(e,i)),i}KG(){var l;let t=this.OG,r=t.length;if(r===0)return!1;let e=!1;(this.oG==null||this.aG<r)&&((l=this.oG)==null||l.destroy(),this.aG=Math.max(8,this.aG*2,r),this.oG=this.uB.createBuffer({label:"GpuCulling.views",size:this.aG*le,usage:GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST}),this._G=new Float32Array(this.aG*w),this.WG=new Float32Array(this.aG*w),this.GG.cull.bindGroup=void 0,e=!0);let i=this._G;for(let n=0;n<r;n++){let f=t[n].camera,u=n*w;if(!f._isAlive){i[u]=0;continue}f.updateFrustum();let p=f.frustum;i[u]=1,i[u+1]=0,i[u+2]=0,i[u+3]=0;for(let c=0;c<6;c++){let s=p.getPlane(c)._v,h=u+4+c*4;i[h]=s[0],i[h+1]=s[1],i[h+2]=s[2],i[h+3]=s[3]}let g=p.corners;for(let c=0;c<8;c++){let s=g[c]._v,h=u+28+c*4;i[h]=s[0],i[h+1]=s[1],i[h+2]=s[2],i[h+3]=1}}let o=r*w,a=this.WG,d=e;if(!d){for(let n=0;n<o;n++)if(i[n]!==a[n]){d=!0;break}}return d&&(this.uB.queue.writeBuffer(this.oG,0,i,0,o),a.set(i.subarray(0,o))),d}};export{O as GpuCullingArgsByteSize,ee as WebGpuGpuCulling};
|
|
236
|
+
`,Z=64,fe=65535,V=64,X=V/4,T=16,w=60,le=w*4,O=20,F=O/4,M=16,j=16,D=4294967295,J=1,ce=2,L=8,Q={instances:8192,groups:2048,draws:4096,chunks:4096},ee=class{constructor(t){this.gB=new Uint32Array(j/4);this.bG=0;this.KG=new Float32Array(0);this.ZG=new Float32Array(0);this.WG=new B;this.kG=new B;this.PG=new B;this.HG=new B;this.UG=new B;this.CG=[];this.qG=[];this.XG=new Map;this.IG=!0;this.jG=-1;this.JG=-1;this.uB=t,this.fG=new ne(Q),this.cG=new se(t);let r=(a,d,l,n)=>{let f=t.createBindGroupLayout({label:`GpuCulling.${a}`,entries:n.map((p,g)=>({binding:g,visibility:GPUShaderStage.COMPUTE,buffer:{type:p}}))}),u=t.createComputePipeline({label:`GpuCulling.${a}`,layout:t.createPipelineLayout({bindGroupLayouts:[f]}),compute:{module:t.createShaderModule({label:`GpuCulling.${a}`,code:d}),entryPoint:l}});return{layout:f,pipeline:u}},e="read-only-storage",i="storage",o="uniform";this.AG={cull:r("cullChunks",oe,"cullChunks",[e,o,e,e,e,e,i,i,e]),prefix:r("prefixGroups",ue,"prefixGroups",[o,e,e,i,i]),scatter:r("scatter",ae,"scatter",[o,e,e,e,e,e,i]),finalize:r("finalize",de,"finalize",[o,e,e,i])},this.gG=t.createBuffer({label:"GpuCulling.params",size:j,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST}),this.QG(Q)}get registry(){return this.fG}get deformer(){return this.cG}get deformedVerticesBuffer(){return this.cG.deformedVerticesBuffer}beginRecording(){this.fG.beginRecording()}get isRecording(){return this.fG.isRecording}finishRecording(t){this.fG.finishRecording(t)}abortRecording(){this.fG.abortRecording()}retireAllBundles(){this.fG.retireAllBundles()}markInputsDirty(){this.IG=!0}registerDraw(t,r,e,i,o){let a=this.fG;if(!a.isRecording)return;let d=r._variationEntityInfo,l=r.meshEntitiesInner.length;if(d===void 0||d.length!==l*4||l===0)return;let n=this.mB(t,i);if(n<0)return;let f=a.getOrAllocateGroup(r,n,l);if(f===void 0)return;let u=this.CG[f.index];if(u===void 0||u.group!==f){let h=r._needsComputeDeformation,x=h?this.cG.acquire(t,r,d):void 0;u={group:f,range:{buffer:this.MG,offset:f.rangeBase*M,size:l*M},engine:t,mesh:r,entityInfo:d,positionUpdateCount:r.primitivePositionUpdateCount,deform:x,isDeformFailed:h&&x===void 0},this.CG[f.index]=u,this.dB(t,r,f,d,x)}if(u.isDeformFailed)return;let p;if(u.deform!==void 0&&(p=this.cG.getPrimitiveOffset(u.deform,e),p===void 0))return;let g=a.allocateDraw();if(g<0)return;let c=this.NG,s=g*F;return c[s]=o,c[s+1]=0,c[s+2]=0,c[s+3]=0,c[s+4]=0,this.HG.add(g,g+1),this._G[g]=f.index,this.PG.add(g,g+1),{instanceVertexBuffer:u.range,indirectBuffer:this.xG,indirectOffset:g*O,deformedVertexOffset:p}}encode(t,r,e={}){var U,I,C,G,S,y;let i=this.fG,o=i.groupHighWater,a=i.drawHighWater;if(t==null||o===0)return;let d=this.vB(),l=re._primitivePositionUpdateVersion;l!==this.jG&&(this.jG=l,this.CB());let n=this.cG;n.refresh();let f=n.hasEntries&&(this.IG||n.isChanged||this.GG!==t);if(!this.IG&&!f&&this.WG.isEmpty&&!d&&i.version===this.JG&&this.GG===t)return;this.IG=!1,this.JG=i.version;let u=this.uB;this.SG(this.zG,this.LG,this.WG,X),this.SG(this.vG,this.RG,this.kG,T/4),this.SG(this.yG,this.wG,this.UG,L/4),this.SG(this.VG,this._G,this.PG,1),this.SG(this.xG,this.NG,this.HG,F);let p=i.chunkHighWater,g=Math.max(1,Math.min(p,fe)),c=this.gB;c[0]=o,c[1]=a,c[2]=p,c[3]=g,u.queue.writeBuffer(this.gG,0,c);let s=this.AG;(s.cull.bindGroup==null||this.GG!==t||this.YG!==n.boundsBuffer)&&(s.cull.bindGroup=this.TG(s.cull,[t,this.gG,this.zG,this.vG,this.mG,this.yG,this.EG,this.BG,n.boundsBuffer]),this.GG=t,this.YG=n.boundsBuffer),(I=(U=s.prefix).bindGroup)!=null||(U.bindGroup=this.TG(s.prefix,[this.gG,this.vG,this.BG,this.OG,this.DG])),(G=(C=s.scatter).bindGroup)!=null||(C.bindGroup=this.TG(s.scatter,[this.gG,this.vG,this.yG,this.BG,this.OG,this.EG,this.MG])),(y=(S=s.finalize).bindGroup)!=null||(S.bindGroup=this.TG(s.finalize,[this.gG,this.DG,this.VG,this.xG]));let h=u.createCommandEncoder({label:"GpuCulling"});f&&n.encode(h,t,e,r);let x={label:"GpuCulling"},k=r==null?void 0:r.getTimestampWrites("GpuCulling");k!=null&&(x.timestampWrites=k);let b=h.beginComputePass(x),P=Math.ceil(p/g);return p>0&&(b.setPipeline(s.cull.pipeline),b.setBindGroup(0,s.cull.bindGroup),b.dispatchWorkgroups(g,P)),b.setPipeline(s.prefix.pipeline),b.setBindGroup(0,s.prefix.bindGroup),b.dispatchWorkgroups(Math.ceil(o/Z)),p>0&&(b.setPipeline(s.scatter.pipeline),b.setBindGroup(0,s.scatter.bindGroup),b.dispatchWorkgroups(g,P)),a>0&&(b.setPipeline(s.finalize.pipeline),b.setBindGroup(0,s.finalize.bindGroup),b.dispatchWorkgroups(Math.ceil(a/Z))),b.end(),h.finish()}TG(t,r){return this.uB.createBindGroup({label:t.pipeline.label,layout:t.layout,entries:r.map((e,i)=>({binding:i,resource:{buffer:e}}))})}afterSubmit(){let t=this.fG,r=t.releaseRetired();if(r!==void 0){let d=this.RG;for(let n of r.groups){d[n.index*4+1]=0,this.kG.add(n.index,n.index+1);let f=this.wG;for(let p=0;p<n.chunkCount;p++)f[(n.chunkBase+p)*2]=D,f[(n.chunkBase+p)*2+1]=0;this.UG.add(n.chunkBase,n.chunkBase+n.chunkCount);let u=this.CG[n.index];(u==null?void 0:u.group)===n&&(u.deform!==void 0&&this.cG.release(u.deform),this.CG[n.index]=void 0)}let l=this._G;for(let n of r.draws)l[n]=D,this.PG.add(n,n+1)}let e=this.cG,i=this.GB(),o=e.getGrownCapacities();if(i===void 0&&o===void 0&&!e.isResetRequested)return!1;let a=i!=null?i:{...t.capacities};return this.pB(),this.QG(a),t.reset(a),e.reset(o!=null?o:{...e.capacities}),this.CG.length=0,this.IG=!0,!0}GB(){let t=this.fG;if(!t.isOverflowed)return;let r=t.requiredCapacities,e=t.capacities,i=this.uB.limits,o=Math.min(i.maxStorageBufferBindingSize,i.maxBufferSize),a=(l,n,f)=>{let u=l;for(;u<n*1.25;)u*=2;return Math.max(l,Math.min(u,Math.floor(o/f)))},d={instances:a(e.instances,r.instances,V),groups:a(e.groups,r.groups,T),draws:a(e.draws,r.draws,O),chunks:a(e.chunks,r.chunks,L)};if(!(d.instances===e.instances&&d.groups===e.groups&&d.draws===e.draws&&d.chunks===e.chunks))return d}destroy(){var t;this.pB(),this.cG.destroy(),this.gG.destroy(),(t=this.mG)==null||t.destroy(),this.mG=void 0}QG(t){let r=this.uB,e=GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST;this.zG=r.createBuffer({label:"GpuCulling.records",size:t.instances*V,usage:e}),this.vG=r.createBuffer({label:"GpuCulling.groups",size:t.groups*T,usage:e}),this.DG=r.createBuffer({label:"GpuCulling.visibleCounts",size:t.groups*4,usage:GPUBufferUsage.STORAGE}),this.VG=r.createBuffer({label:"GpuCulling.drawGroups",size:t.draws*4,usage:e}),this.MG=r.createBuffer({label:"GpuCulling.visibleIds",size:t.instances*M,usage:GPUBufferUsage.VERTEX|GPUBufferUsage.STORAGE}),this.yG=r.createBuffer({label:"GpuCulling.chunks",size:t.chunks*L,usage:e}),this.BG=r.createBuffer({label:"GpuCulling.chunkCounts",size:t.chunks*4,usage:GPUBufferUsage.STORAGE}),this.OG=r.createBuffer({label:"GpuCulling.chunkOffsets",size:t.chunks*4,usage:GPUBufferUsage.STORAGE}),this.EG=r.createBuffer({label:"GpuCulling.scratchIds",size:t.instances*M,usage:GPUBufferUsage.STORAGE}),this.xG=r.createBuffer({label:"GpuCulling.args",size:t.draws*O,usage:GPUBufferUsage.INDIRECT|GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST|GPUBufferUsage.COPY_SRC}),this.FG=new ArrayBuffer(t.instances*V),this.LG=new Uint32Array(this.FG),this.$G=new Float32Array(this.FG),this.RG=new Uint32Array(t.groups*4),this._G=new Uint32Array(t.draws).fill(D),this.NG=new Uint32Array(t.draws*F),this.wG=new Uint32Array(t.chunks*2);for(let i=0;i<t.chunks;i++)this.wG[i*2]=D;this.WG.clear(),this.kG.clear(),this.kG.add(0,t.groups),this.PG.clear(),this.PG.add(0,t.draws),this.HG.clear(),this.UG.clear(),this.UG.add(0,t.chunks),this.xB()}xB(){let t=this.AG;t.cull.bindGroup=void 0,t.prefix.bindGroup=void 0,t.scatter.bindGroup=void 0,t.finalize.bindGroup=void 0,this.GG=void 0}pB(){var t,r,e,i,o,a,d,l,n,f;(t=this.zG)==null||t.destroy(),(r=this.vG)==null||r.destroy(),(e=this.DG)==null||e.destroy(),(i=this.VG)==null||i.destroy(),(o=this.MG)==null||o.destroy(),(a=this.xG)==null||a.destroy(),(d=this.yG)==null||d.destroy(),(l=this.BG)==null||l.destroy(),(n=this.OG)==null||n.destroy(),(f=this.EG)==null||f.destroy()}SG(t,r,e,i){if(e.isEmpty)return;let o=e.min*i,a=Math.min(e.max*i,r.length);this.uB.queue.writeBuffer(t,o*4,r,o,a-o),e.clear()}CB(){let t=this.CG;for(let r=0;r<t.length;r++){let e=t[r];e===void 0||e.mesh.primitivePositionUpdateCount===e.positionUpdateCount||(e.positionUpdateCount=e.mesh.primitivePositionUpdateCount,this.dB(e.engine,e.mesh,e.group,e.entityInfo,e.deform))}}dB(t,r,e,i,o){var N,H,q,Y,$;let a=this.RG,d=e.index*4;a[d]=e.rangeBase,a[d+1]=e.instanceCount,a[d+2]=e.viewIndex,a[d+3]=e.chunkBase,this.kG.add(e.index,e.index+1);let l=this.wG;for(let v=0;v<e.chunkCount;v++)l[(e.chunkBase+v)*2]=e.index,l[(e.chunkBase+v)*2+1]=v*ie;this.UG.add(e.chunkBase,e.chunkBase+e.chunkCount);let n=(N=z.getComponentCountPerBufferView(t).get(A))!=null?N:1,f=z.getLocationOffsetOfMemberOfComponent(t,A,"worldMatrix"),u=z.getLocationOffsetOfMemberOfComponent(t,A,"isVisible"),p=z.getLocationOffsetOfMemberOfComponent(t,A,"isBillboard"),g=r.AABB,c=!g.isVanilla(),s=g.minPoint._v,h=g.maxPoint._v,x=(s[0]+h[0])*.5,k=(s[1]+h[1])*.5,b=(s[2]+h[2])*.5,P=(h[0]-s[0])*.5,U=(h[1]-s[1])*.5,I=(h[2]-s[2])*.5,C=this.LG,G=this.$G,S=r.meshEntitiesInner,y=this.cG;for(let v=0;v<e.instanceCount;v++){let m=(e.rangeBase+v)*X,R=i[4*v],_=Math.floor(R/n),W=R%n;C[m]=R,C[m+1]=i[4*v+1],C[m+2]=i[4*v+2],C[m+3]=o!==void 0?y.getInstanceDeformedBase(o,v)+1:i[4*v+3],G[m+4]=x,G[m+5]=k,G[m+6]=b,C[m+7]=((H=f[_])!=null?H:0)+4*W,G[m+8]=P,G[m+9]=U,G[m+10]=I,C[m+11]=((q=u[_])!=null?q:0)*4+W,C[m+12]=((Y=p[_])!=null?Y:0)*4+W;let K=(($=S[v])==null?void 0:$.getTagValue("type"))==="background-assets";o!==void 0?(C[m+13]=ce|(K?J:0),C[m+14]=y.getInstanceBoundsSlot(o,v)):(C[m+13]=!c||K?J:0,C[m+14]=0),C[m+15]=0}this.WG.add(e.rangeBase,e.rangeBase+e.instanceCount)}mB(t,r){if(r<0)return-1;let e=t.componentRepository.getComponent(te,r);if(e==null)return-1;let i=this.XG.get(e);return i===void 0&&(i=this.qG.length,this.qG.push({camera:e}),this.XG.set(e,i)),i}vB(){var l;let t=this.qG,r=t.length;if(r===0)return!1;let e=!1;(this.mG==null||this.bG<r)&&((l=this.mG)==null||l.destroy(),this.bG=Math.max(8,this.bG*2,r),this.mG=this.uB.createBuffer({label:"GpuCulling.views",size:this.bG*le,usage:GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST}),this.KG=new Float32Array(this.bG*w),this.ZG=new Float32Array(this.bG*w),this.AG.cull.bindGroup=void 0,e=!0);let i=this.KG;for(let n=0;n<r;n++){let f=t[n].camera,u=n*w;if(!f._isAlive){i[u]=0;continue}f.updateFrustum();let p=f.frustum;i[u]=1,i[u+1]=0,i[u+2]=0,i[u+3]=0;for(let c=0;c<6;c++){let s=p.getPlane(c)._v,h=u+4+c*4;i[h]=s[0],i[h+1]=s[1],i[h+2]=s[2],i[h+3]=s[3]}let g=p.corners;for(let c=0;c<8;c++){let s=g[c]._v,h=u+28+c*4;i[h]=s[0],i[h+1]=s[1],i[h+2]=s[2],i[h+3]=1}}let o=r*w,a=this.ZG,d=e;if(!d){for(let n=0;n<o;n++)if(i[n]!==a[n]){d=!0;break}}return d&&(this.uB.queue.writeBuffer(this.mG,0,i,0,o),a.set(i.subarray(0,o))),d}};export{O as GpuCullingArgsByteSize,ee as WebGpuGpuCulling};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var c=class{constructor(e){this.
|
|
1
|
+
var c=class{constructor(e){this.bM=[];this.SM=0;this.cM=0;this.PM=[];this.AM=[];this.uB=e}get isSupported(){return this.uB.features.has("timestamp-query")}get lastGpuTimeMilliseconds(){return this.ZE}get lastPassGpuTimesMilliseconds(){return this.RM}beginFrame(){this.isSupported&&(this.MM={sumNanoseconds:0,passNanoseconds:new Map,pendingReadbacks:0,ended:!1,isComplete:!0})}endFrame(){let e=this.MM;e!=null&&(e.ended=!0,this.MM=void 0,this.TM(e))}getTimestampWrites(e){let s=this.MM;if(s==null)return;if(this.gM!=null&&this.gM!==s){s.isComplete=!1;return}if(this.cM+2>512){s.isComplete=!1;return}this.dM==null&&(this.dM=this.uB.createQuerySet({type:"timestamp",count:512}),this.pM=this.uB.createBuffer({size:512*8,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}));let t=this.cM;return this.cM+=2,this.PM.push(e),this.gM=s,{querySet:this.dM,beginningOfPassWriteIndex:t,endOfPassWriteIndex:t+1}}encodeResolve(e){let s=this.cM,t=this.PM,i=this.gM;if(this.cM=0,this.PM=[],this.gM=void 0,s===0||i==null)return;let n=this.bM.pop();if(n==null){if(this.SM>=8){i.isComplete=!1;return}n=this.uB.createBuffer({size:512*8,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ}),this.SM++}e.resolveQuerySet(this.dM,0,s,this.pM,0),e.copyBufferToBuffer(this.pM,0,n,0,s*8),i.pendingReadbacks++,this.AM.push({buffer:n,timestampCount:s,labels:t,frame:i})}afterSubmit(){let e=this.AM;for(let s=0;s<e.length;s++)this.UM(e[s]);e.length=0}UM(e){let{buffer:s,timestampCount:t,labels:i,frame:n}=e,u=t*8;s.mapAsync(GPUMapMode.READ,0,u).then(()=>{var d,p;let o=new BigUint64Array(s.getMappedRange(0,u));for(let r=0,f=0;r+1<t;r+=2,f++){let a=Number(o[r]),h=Number(o[r+1]);if(a!==0&&h>a){let m=h-a;n.sumNanoseconds+=m;let l=(d=i[f])!=null?d:"pass";n.passNanoseconds.set(l,((p=n.passNanoseconds.get(l))!=null?p:0)+m)}}s.unmap(),this.bM.push(s)}).catch(()=>{n.isComplete=!1}).finally(()=>{n.pendingReadbacks--,this.TM(n)})}TM(e){if(e.ended&&e.pendingReadbacks===0&&e.isComplete){this.ZE=e.sumNanoseconds/1e6;let s=new Map;for(let[t,i]of e.passNanoseconds)s.set(t,i/1e6);this.RM=s}}destroy(){var e,s;(e=this.dM)==null||e.destroy(),(s=this.pM)==null||s.destroy();for(let t of this.bM)t.destroy();this.bM.length=0,this.dM=void 0,this.pM=void 0,this.RM=void 0}};export{c as WebGpuGpuTimer};
|
|
@@ -150,4 +150,4 @@ fn buildClusters(@builtin(global_invocation_id) id: vec3<u32>) {
|
|
|
150
150
|
// use the same table lookup for both builds.
|
|
151
151
|
data[tableBase() + cluster] = vec4<f32>(f32(cluster * params.entriesPerCluster), f32(count), 0.0, 0.0);
|
|
152
152
|
}
|
|
153
|
-
`;var y=class{constructor(t){this.Lw=0;this.
|
|
153
|
+
`;var y=class{constructor(t){this.Lw=0;this.gB=new Uint32Array(32/4);this.Dw=0;this.uB=t,this.Pw=Math.max(t.limits.minUniformBufferOffsetAlignment,32),this.Uw=t.createBindGroupLayout({label:"LightClusterBuild",entries:[{binding:0,visibility:GPUShaderStage.COMPUTE,buffer:{type:"storage"}},{binding:1,visibility:GPUShaderStage.COMPUTE,buffer:{type:"uniform",hasDynamicOffset:!0,minBindingSize:32}},{binding:2,visibility:GPUShaderStage.COMPUTE,buffer:{type:"read-only-storage"}}]});let i=t.createPipelineLayout({bindGroupLayouts:[this.Uw]}),r=t.createShaderModule({label:"LightClusterBuild",code:v});this.zw=t.createComputePipeline({label:"LightClusterBuild.buildClusters",layout:i,compute:{module:r,entryPoint:"buildClusters"}})}build(t,i,r){var g,b;let n=i.views.length;if(n===0)return;let a=this.uB;(this.gG==null||this.Lw<n)&&((g=this.gG)==null||g.destroy(),this.Lw=Math.max(n,4),this.gG=a.createBuffer({label:"LightClusterBuild.params",size:this.Pw*this.Lw,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST}),this.Bw=void 0);let l=0;for(let e of i.views)l=Math.max(l,e.dataOffset+i.dataStride);if(this.bw==null||this.Dw<l){(b=this.bw)==null||b.destroy();let e=1;for(;e<l;)e*=2;this.Dw=e,this.bw=a.createBuffer({label:"LightClusterBuild.buildData",size:e*4,usage:GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST}),this.Bw=void 0}a.queue.writeBuffer(this.bw,0,i.data.subarray(0,l)),(this.Bw==null||this.Gw!==t)&&(this.Bw=a.createBindGroup({label:"LightClusterBuild",layout:this.Uw,entries:[{binding:0,resource:{buffer:t}},{binding:1,resource:{buffer:this.gG,size:32}},{binding:2,resource:{buffer:this.bw}}]}),this.Gw=t);let d=i.layout,f=d.clusterLightCapacity,m=Math.ceil(f/4),s=this.gB;for(let e=0;e<n;e++){let o=i.views[e];s[0]=o.viewVec4Base,s[1]=o.dataOffset,s[2]=o.dataOffset+i.localCapacity*4,s[3]=o.dataOffset+i.localCapacity*5,s[4]=o.localCount,s[5]=d.clusterCount,s[6]=m,s[7]=f,a.queue.writeBuffer(this.gG,e*this.Pw,s)}let c=a.createCommandEncoder({label:"LightClusterBuild"}),p={label:"LightClusterBuild"},u=r==null?void 0:r.getTimestampWrites("LightClusterBuild");u!=null&&(p.timestampWrites=u);let h=c.beginComputePass(p),w=Math.ceil(d.clusterCount/64);for(let e=0;e<n;e++)h.setBindGroup(0,this.Bw,[e*this.Pw]),h.setPipeline(this.zw),h.dispatchWorkgroups(w);h.end(),u!=null&&r.encodeResolve(c),a.queue.submit([c.finish()]),u!=null&&r.afterSubmit()}destroy(){var t,i;(t=this.gG)==null||t.destroy(),this.gG=void 0,(i=this.bw)==null||i.destroy(),this.bw=void 0,this.Bw=void 0,this.Gw=void 0}};export{y as WebGpuLightClusterBuilder};
|