@woosh/meep-engine 2.33.21 → 2.33.25
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/core/assert.js +3 -1
- package/core/bvh2/BinaryNode.js +1 -1
- package/core/bvh2/aabb3/AABB3.js +18 -0
- package/core/bvh2/aabb3/AABB3Math.js +1 -1
- package/core/bvh2/binary/2/BinaryUint32BVH.js +498 -0
- package/core/bvh2/binary/2/BinaryUint32BVH.spec.js +54 -0
- package/core/bvh2/binary/IndexedBinaryBVH.js +22 -26
- package/core/bvh2/traversal/ThreeClippingPlaneComputingBVHVisitor.js +5 -1
- package/core/bvh2/traversal/__detailed_box_volume_intersection.js +31 -11
- package/core/collection/ArrayUtils.js +1 -1
- package/core/collection/array/arrayQuickSort.js +9 -6
- package/core/collection/array/array_swap.js +22 -0
- package/core/collection/array/binarySearchHighIndex.js +1 -1
- package/core/collection/array/computeHashArray.js +22 -0
- package/core/collection/array/computeHashIntegerArray.js +15 -0
- package/core/collection/array/copyArray.js +2 -2
- package/core/collection/table/DataType2TypedArrayConstructorMapping.js +15 -0
- package/core/color/Color.js +2 -1
- package/core/function/FunctionCompiler.js +2 -1
- package/core/geom/3d/aabb/aabb3_computeDistanceAbovePlane.js +9 -33
- package/core/geom/3d/frustum/frustum3_computeNearestPointToPoint.js +10 -2
- package/core/geom/3d/line/line3_computeSegmentPointDistance_sqr.js +41 -0
- package/core/geom/3d/morton/mortonEncode_magicbits.js +2 -1
- package/core/geom/3d/morton/reinterpret_float32_as_int32.js +13 -0
- package/core/geom/3d/morton/v3_morton_encode_transformed.js +33 -0
- package/core/geom/3d/normal/hemioct/unit_hemioct.spec.js +1 -1
- package/core/geom/3d/plane/plane_computeConvex3PlaneIntersection.js +13 -14
- package/core/geom/3d/ray/ray_computeNearestPointToPoint.js +37 -0
- package/core/geom/3d/shape/AbstractShape3D.js +38 -0
- package/core/geom/3d/shape/CompositeShape.js +240 -0
- package/core/geom/3d/shape/TransformedShape3D.js +126 -0
- package/core/geom/3d/shape/UnitCubeShape3D.js +24 -0
- package/core/geom/3d/shape/UnitSphereShape3D.js +24 -0
- package/core/geom/3d/shape/util/shape_to_visual_entity.js +159 -0
- package/core/geom/3d/voxel/DenseBitVolume3D.js +87 -0
- package/core/geom/3d/voxel/buildVolumeFromProjectedGeometry.js +23 -0
- package/core/geom/AABB2.js +1 -1
- package/core/geom/ConicRay.js +3 -1
- package/core/geom/LineSegment.js +0 -78
- package/core/geom/Matrix4.js +7 -8
- package/core/geom/Plane.js +14 -9
- package/core/geom/Rectangle.js +2 -1
- package/core/geom/Vector1.js +1 -1
- package/core/geom/Vector3.js +2 -1
- package/core/geom/Vector4.js +2 -1
- package/core/geom/random/randomPointInBox.js +7 -3
- package/core/geom/random/randomPointInPoint.js +6 -3
- package/core/geom/random/randomPointInSphere.js +9 -5
- package/core/geom/random/randomPointOnBox.js +7 -3
- package/core/geom/random/randomPointOnSphere.js +6 -3
- package/core/geom/v3_length.js +8 -3
- package/core/graph/graph_k_means_cluster.js +1 -1
- package/core/json/resolvePathByArray.js +2 -2
- package/core/math/MathUtils.js +0 -354
- package/core/math/MathUtils.spec.js +7 -1
- package/core/math/gaussian.js +9 -0
- package/core/math/hash/computeHashFloat.js +17 -0
- package/core/math/hash/computeHashFloatArray.js +34 -0
- package/core/math/hash/computeObjectHash.js +54 -0
- package/core/math/intersects1D.js +19 -0
- package/core/math/interval/NumericInterval.js +2 -2
- package/core/math/isValueBetween.js +10 -0
- package/core/math/isValueBetweenInclusive.js +10 -0
- package/core/math/noise/curl_noise_3dt.js +1 -1
- package/core/math/noise/sdnoise.js +10 -10
- package/core/math/overlap1D.js +19 -0
- package/core/math/pingpong.js +17 -0
- package/core/math/random/makeRangedRandom.js +19 -0
- package/core/math/random/randomFloatBetween.js +14 -0
- package/core/math/random/randomFromArray.js +19 -0
- package/core/math/random/randomGaussian.js +15 -0
- package/core/math/random/randomIntegerBetween.js +14 -0
- package/core/math/random/roundFair.js +15 -0
- package/core/math/separation1D.js +21 -0
- package/core/math/solveQuadratic.js +25 -0
- package/core/model/BoundedValue.js +1 -1
- package/core/model/node-graph/node/NodeInstancePortReference.js +1 -1
- package/core/model/node-graph/node/Port.js +1 -1
- package/core/model/reactive/evaluation/MultiPredicateEvaluator.spec.js +3 -1
- package/core/model/reactive/model/ReactiveBinaryExpression.js +1 -1
- package/core/model/reactive/model/terminal/ReactiveLiteralNumber.js +1 -1
- package/core/model/reactive/model/terminal/ReactiveReference.js +1 -1
- package/core/model/reactive/model/util/createRandomReactiveExpression.js +1 -1
- package/core/model/stat/LinearModifier.js +1 -1
- package/core/primitives/array/computeIntegerArrayHash.js +1 -1
- package/{engine/graphics/render/forward_plus/materials → core/primitives/strings}/insert_after.js +3 -0
- package/core/primitives/strings/insert_after_or_replace.js +27 -0
- package/editor/process/symbolic/makeHelperBoxGeometry.js +44 -0
- package/editor/view/ecs/EntityEditor.js +2 -2
- package/editor/view/ecs/components/particles/ParticleEmitterController.js +2 -2
- package/engine/EngineHarness.js +1 -0
- package/engine/animation/AnimationUtils.js +5 -5
- package/engine/animation/curve/AnimationCurve.js +72 -0
- package/engine/animation/curve/Keyframe.js +27 -0
- package/engine/animation/keyed2/AnimationTrack.js +27 -3
- package/engine/asset/Asset.js +1 -1
- package/engine/asset/loaders/GLTFAssetLoader.d.ts +1 -1
- package/engine/asset/loaders/GLTFAssetLoader.js +10 -0
- package/engine/asset/loaders/image/ImageRGBADataAsset.js +8 -1
- package/engine/asset/loaders/material/computeImageBitmapEquality.js +11 -0
- package/engine/asset/loaders/material/computeImageBitmapHash.js +22 -28
- package/engine/asset/loaders/material/computeMaterialHash.js +3 -1
- package/engine/asset/loaders/material/computeTextureHash.js +2 -1
- package/engine/ecs/EntityBuilder.js +25 -5
- package/engine/ecs/animation/Animation.js +2 -1
- package/engine/ecs/animation/InverseKinematics.js +2 -1
- package/engine/ecs/attachment/AttachmentBinding.js +8 -0
- package/engine/ecs/attachment/AttachmentSystem.js +4 -0
- package/engine/ecs/attachment/TransformAttachmentBinding.js +14 -44
- package/engine/ecs/components/Tag.js +27 -6
- package/engine/ecs/dynamic_actions/DynamicActorSystem.js +2 -1
- package/engine/ecs/dynamic_actions/DynamicRuleDescriptionTable.spec.js +3 -5
- package/engine/ecs/dynamic_actions/actions/definition/WeightedRandomActionDescription.js +1 -1
- package/engine/ecs/evaluation/complex/PointFitnessGaussianBlur.js +1 -1
- package/engine/ecs/foliage/ecs/Foliage2.js +1 -1
- package/engine/ecs/fow/FogOfWar.js +4 -0
- package/engine/ecs/fow/FogOfWarSystem.js +2 -0
- package/engine/ecs/fow/shader/FogOfWarRenderer.js +1 -1
- package/engine/ecs/gui/GUIElement.js +1 -1
- package/engine/ecs/gui/hud/HeadsUpDisplay.js +1 -1
- package/engine/ecs/gui/hud/HeadsUpDisplaySystem.js +2 -0
- package/engine/ecs/gui/position/ViewportPosition.js +2 -1
- package/engine/ecs/system/AbstractContextSystem.js +1 -1
- package/engine/ecs/systems/RangedAttackSystem.js +1 -1
- package/engine/ecs/systems/SteeringSystem.js +1 -1
- package/engine/ecs/systems/TagSystem.js +17 -0
- package/engine/ecs/terrain/tiles/TerrainTileManager.js +1 -1
- package/engine/ecs/tooltip/TooltipComponent.js +15 -0
- package/engine/ecs/transform/Transform.js +19 -6
- package/engine/ecs/util/hideEntityGracefully.js +18 -0
- package/engine/graphics/GraphicsEngine.js +11 -23
- package/engine/graphics/camera/testClippingPlaneComputation.js +2 -2
- package/engine/graphics/composit/CompositLayer.js +17 -4
- package/engine/graphics/composit/CompositingStages.js +8 -0
- package/engine/graphics/composit/LayerCompositer.js +35 -6
- package/engine/graphics/ecs/animation/animator/AnimationClip.js +2 -1
- package/engine/graphics/ecs/animation/animator/AnimationClipDefinition.js +2 -1
- package/engine/graphics/ecs/animation/animator/AnimationNotification.js +2 -1
- package/engine/graphics/ecs/animation/animator/AnimationNotificationDefinition.js +2 -1
- package/engine/graphics/ecs/animation/animator/graph/AnimationGraph.js +2 -1
- package/engine/graphics/ecs/animation/animator/graph/definition/AnimationGraphDefinition.js +2 -1
- package/engine/graphics/ecs/animation/animator/graph/definition/AnimationStateDefinition.js +1 -1
- package/engine/graphics/ecs/animation/animator/graph/definition/AnimationTransitionDefinition.js +2 -1
- package/engine/graphics/ecs/camera/CameraClippingPlaneComputer.js +1 -1
- package/engine/graphics/ecs/highlight/HighlightDefinition.js +2 -1
- package/engine/graphics/ecs/highlight/plugin/OutlineRenderPlugin.js +11 -7
- package/engine/graphics/ecs/light/Light.d.ts +1 -1
- package/engine/graphics/ecs/light/Light.js +5 -0
- package/engine/graphics/ecs/light/binding/three/ThreeLightBinding.js +5 -1
- package/engine/graphics/ecs/mesh/Mesh.js +2 -1
- package/engine/graphics/ecs/mesh-v2/DrawMode.js +5 -0
- package/engine/graphics/ecs/mesh-v2/ShadedGeometry.d.ts +13 -0
- package/engine/graphics/ecs/mesh-v2/ShadedGeometry.js +32 -18
- package/engine/graphics/ecs/mesh-v2/ShadedGeometrySystem.d.ts +6 -0
- package/engine/graphics/ecs/path/testPathDisplaySystem.js +98 -98
- package/engine/graphics/ecs/trail2d/Trail2D.js +17 -4
- package/engine/graphics/ecs/trail2d/Trail2DSystem.d.ts +2 -3
- package/engine/graphics/ecs/trail2d/Trail2DSystem.js +34 -118
- package/engine/graphics/geometry/AttributeSpec.js +105 -0
- package/engine/graphics/{micron/format/MicronVertexDataSpec.js → geometry/VertexDataSpec.js} +56 -25
- package/engine/graphics/micron/build/buildMicronGeometryFromBufferGeometry.js +7 -7
- package/engine/graphics/micron/build/fill_patch_geometry_data.js +1 -1
- package/engine/graphics/micron/buildPatchwork.js +1 -1
- package/engine/graphics/micron/format/MicronGeometry.js +3 -3
- package/engine/graphics/micron/format/serialization/MicronGeometryBinarySerializationAdapter.js +2 -2
- package/engine/graphics/micron/format/serialization/deserialize_attribute_spec.js +1 -1
- package/engine/graphics/micron/format/serialization/serialize_attribute_spec.js +1 -1
- package/engine/graphics/micron/render/PatchCacheKey.js +1 -1
- package/engine/graphics/micron/render/instanced/AttributeDataTexture.js +5 -5
- package/engine/graphics/micron/render/v1/ThreeVirtualGeometryAdapter.js +1 -1
- package/engine/graphics/particles/ParticleEmitterLibrary.js +3 -0
- package/engine/graphics/particles/ecs/{ParticleEmitterSystem2.js → ParticleEmitterSystem.js} +17 -9
- package/engine/graphics/particles/particular/engine/ParticularEngine.js +12 -4
- package/engine/graphics/particles/particular/engine/emitter/PARTICULAR_PARTICLE_SPECIFICATION.js +84 -0
- package/engine/graphics/particles/particular/engine/emitter/ParticleEmitter.js +106 -169
- package/engine/graphics/particles/particular/engine/emitter/ParticleEmitterFlag.js +5 -0
- package/engine/graphics/particles/particular/engine/emitter/ParticleLayer.js +14 -3
- package/engine/graphics/particles/particular/engine/emitter/ParticlePool.js +141 -14
- package/engine/graphics/particles/particular/engine/emitter/ParticlePool.spec.js +8 -7
- package/engine/graphics/particles/particular/engine/emitter/computeEmissionFunction.js +37 -0
- package/engine/graphics/particles/particular/engine/emitter/distance_to_camera.js +25 -0
- package/engine/graphics/particles/particular/engine/emitter/serde/ParameterLookupTableSerializationAdapter.js +8 -2
- package/engine/graphics/particles/particular/engine/parameter/ParameterLookupTable.js +2 -1
- package/engine/graphics/particles/particular/engine/parameter/ParameterTrack.js +1 -1
- package/engine/graphics/particles/particular/engine/parameter/ParticleParameter.js +1 -1
- package/engine/graphics/particles/particular/engine/renderers/billboard/BILLBOARD_PARTICLE_SPECIFICATION.js +24 -0
- package/engine/graphics/particles/particular/engine/renderers/billboard/ParticleBillboardMaterial.js +262 -71
- package/engine/graphics/particles/particular/engine/renderers/billboard/prototypeBillboardRenderer.js +9 -9
- package/engine/graphics/particles/particular/engine/shader/ShaderManager.js +80 -46
- package/engine/graphics/particles/particular/engine/shader/debugAtlas.js +14 -0
- package/engine/graphics/particles/particular/engine/simulator/SimulationStepApplyForce.js +2 -5
- package/engine/graphics/particles/particular/engine/simulator/SimulationStepCurlNoiseAcceleration.js +2 -6
- package/engine/graphics/particles/particular/engine/simulator/SimulationStepCurlNoiseVelocity.js +2 -7
- package/engine/graphics/particles/particular/engine/simulator/SimulationStepFixedPhysics.js +2 -5
- package/engine/graphics/particles/particular/engine/simulator/update_parameters.js +1 -1
- package/engine/graphics/particles/particular/engine/utils/distributeParticlesOnObject3D.js +1 -1
- package/engine/graphics/particles/particular/engine/utils/distrubuteParticlesOnMesh.js +1 -1
- package/engine/graphics/particles/particular/engine/utils/volume/AttributeValue.js +141 -0
- package/engine/graphics/particles/particular/engine/utils/volume/ParticleVolume.js +478 -0
- package/engine/graphics/particles/particular/engine/utils/volume/lut_to_sampler.js +27 -0
- package/engine/graphics/particles/particular/engine/utils/volume/prototypeParticleVolume.js +935 -0
- package/engine/graphics/particles/particular/group/Operation.js +18 -0
- package/engine/graphics/particles/particular/group/OperationType.js +9 -0
- package/engine/graphics/particles/particular/group/ParticleAttribute.js +2 -1
- package/engine/graphics/particles/particular/group/ParticleAttributeType.js +11 -0
- package/engine/graphics/particles/particular/group/ParticleDataType.js +10 -0
- package/engine/graphics/particles/particular/group/ParticleGroup.js +7 -245
- package/engine/graphics/particles/particular/group/ParticleGroup.spec.js +3 -1
- package/engine/graphics/particles/particular/group/ParticleSpecification.js +21 -14
- package/engine/graphics/particles/particular/group/itemSizeFromAttributeType.js +20 -0
- package/engine/graphics/particles/particular/group/optimizeCommandQueue.js +162 -0
- package/engine/graphics/particles/particular/group/typedArrayConstructorFromDataType.js +19 -0
- package/engine/graphics/render/buffer/buffers/prototypeNormalFrameBuffer.js +2 -2
- package/engine/graphics/render/buffer/simple-fx/ao/AmbientOcclusionPostProcessEffect.js +13 -7
- package/engine/graphics/render/buffer/slot/parameter/ProgramValueSlotParameter.js +2 -1
- package/engine/graphics/render/buffer/slot/parameter/ProgramValueSlotParameterSet.js +1 -1
- package/engine/graphics/render/forward_plus/LightManager.js +126 -95
- package/engine/graphics/render/forward_plus/PointLight.js +9 -0
- package/engine/graphics/render/forward_plus/PointLightData.js +1 -1
- package/engine/graphics/render/forward_plus/SpotLight.js +9 -0
- package/engine/graphics/render/forward_plus/cluster/compute_light_data_hash_0.js +2 -2
- package/engine/graphics/render/forward_plus/computeFrustumCorners.js +14 -32
- package/engine/graphics/render/forward_plus/materials/FP_INJECTION_POINT_ACCUMULATION.js +1 -0
- package/engine/graphics/render/forward_plus/materials/FP_SHADER_CHUNK_ACCUMULATION.js +32 -0
- package/engine/graphics/render/forward_plus/materials/FP_SHADER_CHUNK_DECODE_PARS.js +51 -0
- package/engine/graphics/render/forward_plus/materials/FP_SHADER_CHUNK_PREAMBLE.js +25 -0
- package/engine/graphics/render/forward_plus/materials/fp_build_fragment_shader.js +31 -120
- package/engine/graphics/render/forward_plus/materials/fp_build_vertex_lighting_shared.js +35 -0
- package/engine/graphics/render/forward_plus/materials/fp_build_vertex_shader.js +4 -5
- package/engine/graphics/render/forward_plus/plugin/ForwardPlusRenderingPlugin.js +1 -1
- package/engine/graphics/render/forward_plus/plugin/MaterialTransformer.js +10 -3
- package/engine/graphics/render/forward_plus/plugin/ptototypeFPPlugin.js +595 -60
- package/engine/graphics/render/forward_plus/prototypeLightManager.js +256 -136
- package/engine/graphics/render/forward_plus/query/analytical_triplanar_corner_mapping.js +8 -0
- package/engine/graphics/render/forward_plus/query/cube_mapping.js +38 -0
- package/engine/graphics/render/forward_plus/query/detailed_sphere_frustum_intersection_test.js +86 -0
- package/engine/graphics/render/forward_plus/query/point_light_inside_volume.js +73 -0
- package/engine/graphics/render/forward_plus/query/query_bvh_frustum_from_objects.js +131 -0
- package/engine/graphics/render/forward_plus/query/query_bvh_frustum_from_texture.js +129 -0
- package/engine/graphics/render/forward_plus/query/spot_light_inside_volume.js +33 -0
- package/engine/graphics/render/forward_plus/read_frustum_corner.js +14 -0
- package/engine/graphics/render/forward_plus/testClusterEquality.js +22 -0
- package/engine/graphics/render/layers/RenderLayerUtils.js +7 -4
- package/engine/graphics/render/visibility/IncrementalDeltaSet.js +11 -0
- package/engine/graphics/render/visibility/hiz/prototypeHiZ.js +2 -2
- package/engine/graphics/shaders/TerrainShader.js +4 -5
- package/engine/graphics/texture/atlas/AtlasPatch.js +7 -2
- package/engine/graphics/texture/atlas/TextureAtlas.js +2 -2
- package/engine/graphics/texture/sampler/HarmonicDiffusionGrid.spec.js +1 -1
- package/engine/graphics/texture/sampler/SampleTraverser.js +1 -1
- package/engine/graphics/texture/sampler/Sampler2D.js +8 -7
- package/engine/graphics/texture/sampler/distanceField.spec.js +1 -1
- package/engine/graphics/texture/sampler/scaleSampler2D.js +7 -10
- package/engine/graphics/trail/x/RibbonMaterialX.js +3 -3
- package/engine/graphics/trail/x/RibbonX.js +17 -2
- package/engine/graphics/trail/x/RibbonXPlugin.js +51 -1
- package/engine/graphics/util/composeMatrix4.js +33 -23
- package/engine/graphics/util/decompose_matrix_4_array.js +61 -0
- package/engine/grid/components/GridObstacle.js +3 -10
- package/engine/intelligence/behavior/ecs/BehaviorComponent.js +30 -14
- package/engine/intelligence/behavior/selector/WeightedElement.js +2 -1
- package/engine/intelligence/optimization/RandomOptimizer.js +1 -1
- package/engine/knowledge/database/StaticKnowledgeDataTable.js +6 -1
- package/engine/navigation/ecs/components/Path.js +1 -6
- package/engine/navigation/grid/FastBinaryHeap.spec.js +1 -1
- package/engine/reference/v2/Reference.js +6 -0
- package/engine/sound/ecs/emitter/SoundEmitter.js +2 -1
- package/engine/sound/ecs/emitter/SoundTrack.js +2 -1
- package/engine/sound/material/concrete/RandomSoundMaterial.js +1 -1
- package/engine/ui/notification/notificationGenerator.js +1 -1
- package/generation/filtering/numeric/complex/CellFilterGaussianBlur.js +1 -1
- package/generation/grid/generation/GridTaskExecuteRuleTimes.js +2 -1
- package/generation/markers/actions/MarkerNodeActionSelectRandom.js +1 -1
- package/generation/markers/transform/MarkerNodeTransformerRecordUniqueRandomEnum.js +1 -1
- package/generation/placement/action/random/CellActionSelectRandom.js +1 -1
- package/generation/theme/ThemeEngine.js +2 -2
- package/misc/makeMaterialIconCached.js +2 -2
- package/package.json +3 -3
- package/view/View.js +4 -2
- package/view/elements/image/HTMLElementCacheKey.js +2 -1
- package/view/elements/radial/RadialText.js +2 -1
- package/view/minimap/gl/MinimapMarkersGL.js +6 -100
- package/view/minimap/gl/buildMaterial.js +94 -0
- package/engine/graphics/micron/format/MicronGeometryBufferAttributeSpec.js +0 -71
- package/engine/graphics/render/forward_plus/queryBVH_Frustum.js +0 -345
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { computeHashFloat, computeHashIntegerArray } from "../../../../../../core/math/MathUtils.js";
|
|
2
1
|
import { ProgramValueSlotParameterType } from "./ProgramValueSlotParameterType.js";
|
|
3
2
|
import { computeStringHash } from "../../../../../../core/primitives/strings/computeStringHash.js";
|
|
3
|
+
import { computeHashIntegerArray } from "../../../../../../core/collection/array/computeHashIntegerArray.js";
|
|
4
|
+
import { computeHashFloat } from "../../../../../../core/math/hash/computeHashFloat.js";
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
*
|
|
@@ -3,7 +3,7 @@ import { PointLightData } from "./PointLightData.js";
|
|
|
3
3
|
import { DataTexture, DataTexture3D, Frustum, NearestFilter, RGBIntegerFormat, UnsignedShortType } from "three";
|
|
4
4
|
import { frustumFromCamera } from "../../ecs/camera/CameraSystem.js";
|
|
5
5
|
import Vector3 from "../../../../core/geom/Vector3.js";
|
|
6
|
-
import {
|
|
6
|
+
import { query_bvh_frustum_from_objects } from "./query/query_bvh_frustum_from_objects.js";
|
|
7
7
|
import { IncrementalDeltaSet } from "../visibility/IncrementalDeltaSet.js";
|
|
8
8
|
import { computeFrustumCorners } from "./computeFrustumCorners.js";
|
|
9
9
|
import { arraySwapElements } from "../../../../core/collection/ArrayUtils.js";
|
|
@@ -18,69 +18,25 @@ import { NumericType } from "./data/NumericType.js";
|
|
|
18
18
|
import { computeDataType } from "./data/computeDataType.js";
|
|
19
19
|
import { computeThreeTextureTypeFromDataType } from "./data/computeThreeTextureTypeFromDataType.js";
|
|
20
20
|
import { computeThreeTextureInternalFormatFromDataType } from "./data/computeThreeTextureInternalFormatFromDataType.js";
|
|
21
|
+
import { testClusterEquality } from "./testClusterEquality.js";
|
|
22
|
+
import { read_frustum_corner } from "./read_frustum_corner.js";
|
|
23
|
+
import { BinaryUint32BVH } from "../../../../core/bvh2/binary/2/BinaryUint32BVH.js";
|
|
24
|
+
import { query_bvh_frustum_from_texture } from "./query/query_bvh_frustum_from_texture.js";
|
|
25
|
+
import { mat4 } from "gl-matrix";
|
|
26
|
+
import { mortonEncode_magicbits } from "../../../../core/geom/3d/morton/mortonEncode_magicbits.js";
|
|
21
27
|
|
|
22
28
|
const LOOKUP_CACHE_SIZE = 16384; // must be power of two
|
|
23
|
-
/**
|
|
24
|
-
* Cache used to identify duplicate cells. Helps reduce memory usage and just point to equivalent existing cells instead of allocating new ones.
|
|
25
|
-
* @type {Uint16Array|Uint32Array}
|
|
26
|
-
*/
|
|
27
|
-
const LOOKUP_CACHE = new Uint32Array(LOOKUP_CACHE_SIZE);
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
*
|
|
31
|
-
* @param {PointLightData[]} lights
|
|
32
|
-
* @param {number} count
|
|
33
|
-
* @param {number[]|Uint32Array|Uint16Array|Uint8Array|Uint8ClampedArray} light_lookup_texture_data
|
|
34
|
-
* @param {number} address
|
|
35
|
-
* @returns {boolean}
|
|
36
|
-
*/
|
|
37
|
-
function testClusterEquality(lights, count, light_lookup_texture_data, address) {
|
|
38
|
-
for (let i = 0; i < count; i++) {
|
|
39
|
-
|
|
40
|
-
const actual_visible_index = light_lookup_texture_data[address + i];
|
|
41
|
-
|
|
42
|
-
const datum = scratch_light_nodes[i];
|
|
43
|
-
|
|
44
|
-
const expected_visible_index = datum.visible_index;
|
|
45
|
-
|
|
46
|
-
if (expected_visible_index !== actual_visible_index) {
|
|
47
|
-
return false;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return true;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
*
|
|
56
|
-
* @param {PointLightData} datum
|
|
57
|
-
* @returns {number}
|
|
58
|
-
*/
|
|
59
|
-
function get_light_visible_index(datum) {
|
|
60
|
-
return datum.visible_index;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
*
|
|
65
|
-
* @param {number[]|Float32Array|Float64Array} source
|
|
66
|
-
* @param {number} source_index
|
|
67
|
-
* @param {number[]|Float32Array|Float64Array} destination
|
|
68
|
-
* @param {number} destination_offset
|
|
69
|
-
*/
|
|
70
|
-
function read_frustum_corner(source, source_index, destination, destination_offset) {
|
|
71
|
-
const address = source_index * 3;
|
|
72
|
-
|
|
73
|
-
destination[destination_offset] = source[address];
|
|
74
|
-
destination[destination_offset + 1] = source[address + 1];
|
|
75
|
-
destination[destination_offset + 2] = source[address + 2];
|
|
76
|
-
}
|
|
77
29
|
|
|
78
30
|
/**
|
|
79
31
|
* Using continuous buffer for related attributes to get better cache utilization
|
|
80
32
|
* @type {ArrayBuffer}
|
|
81
33
|
* @private
|
|
82
34
|
*/
|
|
83
|
-
const _scratch_array_buffer = new ArrayBuffer(
|
|
35
|
+
const _scratch_array_buffer = new ArrayBuffer(
|
|
36
|
+
24 * 4
|
|
37
|
+
+ 24 * 4
|
|
38
|
+
+ LOOKUP_CACHE_SIZE * 4
|
|
39
|
+
);
|
|
84
40
|
|
|
85
41
|
/**
|
|
86
42
|
*
|
|
@@ -88,11 +44,6 @@ const _scratch_array_buffer = new ArrayBuffer((24 + 24) * 4);
|
|
|
88
44
|
*/
|
|
89
45
|
const scratch_corners = new Float32Array(_scratch_array_buffer, 0, 24);
|
|
90
46
|
|
|
91
|
-
/**
|
|
92
|
-
*
|
|
93
|
-
* @type {PointLightData[]}
|
|
94
|
-
*/
|
|
95
|
-
const scratch_light_nodes = [];
|
|
96
47
|
|
|
97
48
|
/**
|
|
98
49
|
* Linear access data structure with parameters of each plane of the frustum
|
|
@@ -102,6 +53,18 @@ const scratch_light_nodes = [];
|
|
|
102
53
|
*/
|
|
103
54
|
const scratch_frustum_planes = new Float32Array(_scratch_array_buffer, 24 * 4, 24);
|
|
104
55
|
|
|
56
|
+
/**
|
|
57
|
+
* Cache used to identify duplicate cells. Helps reduce memory usage and just point to equivalent existing cells instead of allocating new ones.
|
|
58
|
+
* @type {Uint16Array|Uint32Array}
|
|
59
|
+
*/
|
|
60
|
+
const LOOKUP_CACHE = new Uint32Array(_scratch_array_buffer, (24 + 24) * 4, LOOKUP_CACHE_SIZE);
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
*
|
|
64
|
+
* @type {number[]}
|
|
65
|
+
*/
|
|
66
|
+
const scratch_light_nodes = [];
|
|
67
|
+
|
|
105
68
|
export class LightManager {
|
|
106
69
|
|
|
107
70
|
constructor() {
|
|
@@ -170,10 +133,10 @@ export class LightManager {
|
|
|
170
133
|
|
|
171
134
|
/**
|
|
172
135
|
*
|
|
173
|
-
* @type {
|
|
136
|
+
* @type {BinaryUint32BVH}
|
|
174
137
|
* @private
|
|
175
138
|
*/
|
|
176
|
-
this.__visible_bvh = new
|
|
139
|
+
this.__visible_bvh = new BinaryUint32BVH();
|
|
177
140
|
|
|
178
141
|
/**
|
|
179
142
|
*
|
|
@@ -189,6 +152,13 @@ export class LightManager {
|
|
|
189
152
|
*/
|
|
190
153
|
this.__view_frustum_points = new Float32Array(24);
|
|
191
154
|
|
|
155
|
+
/**
|
|
156
|
+
*
|
|
157
|
+
* @type {Float32Array|mat4|number[]}
|
|
158
|
+
* @private
|
|
159
|
+
*/
|
|
160
|
+
this.__projection_matrix = new Float32Array(16);
|
|
161
|
+
|
|
192
162
|
|
|
193
163
|
/**
|
|
194
164
|
* Accelerated data structure with pre-computed plane normals for clusters in each dimensions. Order: X, Y, Z
|
|
@@ -313,6 +283,14 @@ export class LightManager {
|
|
|
313
283
|
return this.__tiles_resolution;
|
|
314
284
|
}
|
|
315
285
|
|
|
286
|
+
/**
|
|
287
|
+
*
|
|
288
|
+
* @private
|
|
289
|
+
*/
|
|
290
|
+
__request_update_visible_bvh() {
|
|
291
|
+
this.__visible_bvh_needs_update = true;
|
|
292
|
+
}
|
|
293
|
+
|
|
316
294
|
/**
|
|
317
295
|
*
|
|
318
296
|
* @param {PointLightData} data
|
|
@@ -320,6 +298,8 @@ export class LightManager {
|
|
|
320
298
|
*/
|
|
321
299
|
__handle_visible_added(data) {
|
|
322
300
|
this.__visible_bvh_needs_update = true;
|
|
301
|
+
|
|
302
|
+
data.light.onDimensionChanged(this.__request_update_visible_bvh, this);
|
|
323
303
|
}
|
|
324
304
|
|
|
325
305
|
/**
|
|
@@ -331,40 +311,70 @@ export class LightManager {
|
|
|
331
311
|
this.__visible_bvh_needs_update = true;
|
|
332
312
|
|
|
333
313
|
data.bvh_leaf_visible.disconnect();
|
|
314
|
+
|
|
315
|
+
data.light.offDimensionChanged(this.__request_update_visible_bvh, this);
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
*
|
|
320
|
+
* @param {PointLightData} light
|
|
321
|
+
* @returns {number}
|
|
322
|
+
* @private
|
|
323
|
+
*/
|
|
324
|
+
__sort_visible_light_score(light) {
|
|
325
|
+
const p = light.light.position;
|
|
326
|
+
|
|
327
|
+
// return v3_morton_encode_transformed(p.x, p.y, p.z, this.__projection_matrix);
|
|
328
|
+
return mortonEncode_magicbits(p.x, p.y, p.z);
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* Sort lights for better data locality
|
|
333
|
+
* @private
|
|
334
|
+
*/
|
|
335
|
+
__sort_visible_light() {
|
|
336
|
+
this.__visible_lights.sort(this.__sort_visible_light_score, this);
|
|
334
337
|
}
|
|
335
338
|
|
|
336
339
|
__update_visible_bvh() {
|
|
337
340
|
this.__visible_bvh_needs_update = false;
|
|
338
341
|
|
|
339
|
-
this.__visible_bvh.reset();
|
|
340
|
-
|
|
341
342
|
const lights = this.__visible_lights.elements;
|
|
342
343
|
const light_count = lights.length;
|
|
343
344
|
|
|
344
|
-
|
|
345
|
+
// sort light for better search and query locality
|
|
346
|
+
this.__sort_visible_light();
|
|
347
|
+
|
|
348
|
+
const vbvh = this.__visible_bvh;
|
|
349
|
+
|
|
350
|
+
vbvh.setLeafCount(light_count);
|
|
351
|
+
vbvh.initialize_structure();
|
|
352
|
+
|
|
353
|
+
for (let i = 0; i < light_count; i++) {
|
|
354
|
+
|
|
345
355
|
/**
|
|
346
356
|
*
|
|
347
357
|
* @type {PointLightData}
|
|
348
358
|
*/
|
|
349
359
|
const datum = lights[i];
|
|
350
360
|
|
|
351
|
-
|
|
361
|
+
const bb = datum.bvh_leaf_main;
|
|
352
362
|
|
|
353
|
-
|
|
363
|
+
vbvh.setLeafData(
|
|
364
|
+
i, i,
|
|
365
|
+
bb.x0, bb.y0, bb.z0,
|
|
366
|
+
bb.x1, bb.y1, bb.z1
|
|
367
|
+
);
|
|
354
368
|
}
|
|
355
369
|
|
|
356
|
-
this.
|
|
370
|
+
// vbvh.sort_morton(this.__projection_matrix);
|
|
371
|
+
// vbvh.sort_bubble_sah();
|
|
357
372
|
|
|
358
|
-
|
|
373
|
+
vbvh.build();
|
|
359
374
|
|
|
360
|
-
/**
|
|
361
|
-
*
|
|
362
|
-
* @returns {BinaryNode<PointLightData>}
|
|
363
|
-
*/
|
|
364
|
-
getBVH() {
|
|
365
|
-
return this.__light_points_bvh;
|
|
366
375
|
}
|
|
367
376
|
|
|
377
|
+
|
|
368
378
|
/**
|
|
369
379
|
*
|
|
370
380
|
* @param {Camera} camera
|
|
@@ -388,13 +398,11 @@ export class LightManager {
|
|
|
388
398
|
|
|
389
399
|
visible_lights.initializeUpdate();
|
|
390
400
|
|
|
391
|
-
let index_counter = 0;
|
|
392
|
-
|
|
393
401
|
const nodes = [];
|
|
394
402
|
|
|
395
403
|
read_frustum_planes_to_array(this.__view_frustum.planes, scratch_frustum_planes)
|
|
396
404
|
|
|
397
|
-
const match_count =
|
|
405
|
+
const match_count = query_bvh_frustum_from_objects(nodes, 0, this.__light_points_bvh, scratch_frustum_planes, this.__view_frustum_points);
|
|
398
406
|
|
|
399
407
|
for (let i = 0; i < match_count; i++) {
|
|
400
408
|
|
|
@@ -404,10 +412,6 @@ export class LightManager {
|
|
|
404
412
|
*/
|
|
405
413
|
const light_data = nodes[i];
|
|
406
414
|
|
|
407
|
-
const index = index_counter++;
|
|
408
|
-
|
|
409
|
-
light_data.visible_index = index;
|
|
410
|
-
|
|
411
415
|
visible_lights.push(light_data);
|
|
412
416
|
}
|
|
413
417
|
|
|
@@ -433,7 +437,7 @@ export class LightManager {
|
|
|
433
437
|
|
|
434
438
|
this.__light_data.update();
|
|
435
439
|
|
|
436
|
-
// update lookup precision
|
|
440
|
+
// update required lookup precision
|
|
437
441
|
this.__lookup_data.precision = Math.max(0, Math.ceil(Math.log2(this.__light_data.size)));
|
|
438
442
|
|
|
439
443
|
const tx_light = this.__light_data.getTexture();
|
|
@@ -448,7 +452,7 @@ export class LightManager {
|
|
|
448
452
|
const datum = visible_lights[i];
|
|
449
453
|
|
|
450
454
|
|
|
451
|
-
const address =
|
|
455
|
+
const address = i * 8;
|
|
452
456
|
|
|
453
457
|
assert.lessThan(address, tx_light_data.length, "overflow")
|
|
454
458
|
|
|
@@ -490,6 +494,12 @@ export class LightManager {
|
|
|
490
494
|
const cluster_planes_y_offset = tr_x_1 * 4;
|
|
491
495
|
const cluster_planes_z_offset = cluster_planes_y_offset + tr_y_1 * 4;
|
|
492
496
|
|
|
497
|
+
/**
|
|
498
|
+
*
|
|
499
|
+
* @type {number[]|Uint8ClampedArray}
|
|
500
|
+
*/
|
|
501
|
+
const light_source_data = this.__light_data.getTexture().image.data;
|
|
502
|
+
|
|
493
503
|
const tile_slice_size = tr_x * tr_y;
|
|
494
504
|
|
|
495
505
|
const light_cluster_texture = this.__cluster_texture;
|
|
@@ -507,7 +517,9 @@ export class LightManager {
|
|
|
507
517
|
|
|
508
518
|
let lookup_address_offset = 0;
|
|
509
519
|
let i_x_0, i_y_0, i_z_0;
|
|
520
|
+
let i;
|
|
510
521
|
|
|
522
|
+
// clear cache
|
|
511
523
|
LOOKUP_CACHE.fill(0xFFFFFFFF);
|
|
512
524
|
|
|
513
525
|
for (i_z_0 = 0; i_z_0 < tr_z; i_z_0++) {
|
|
@@ -529,7 +541,6 @@ export class LightManager {
|
|
|
529
541
|
read_plane_pair(cluster_planes, y_plane_index_offset_0, scratch_frustum_planes, 8);
|
|
530
542
|
|
|
531
543
|
for (i_x_0 = 0; i_x_0 < tr_x; i_x_0++) {
|
|
532
|
-
const i_x_1 = i_x_0 + 1;
|
|
533
544
|
|
|
534
545
|
// construct x planes
|
|
535
546
|
|
|
@@ -551,6 +562,8 @@ export class LightManager {
|
|
|
551
562
|
const frustum_point_index_011 = i_z_1 * tr_xy_1 + i_y_1 * tr_x_1 + i_x_0;
|
|
552
563
|
read_frustum_corner(cluster_frustum_points, frustum_point_index_011, scratch_corners, 9);
|
|
553
564
|
|
|
565
|
+
const i_x_1 = i_x_0 + 1;
|
|
566
|
+
|
|
554
567
|
const frustum_point_index_100 = i_z_0 * tr_xy_1 + i_y_0 * tr_x_1 + i_x_1;
|
|
555
568
|
read_frustum_corner(cluster_frustum_points, frustum_point_index_100, scratch_corners, 12);
|
|
556
569
|
|
|
@@ -565,7 +578,14 @@ export class LightManager {
|
|
|
565
578
|
|
|
566
579
|
|
|
567
580
|
// at this point we have a fully constructed cluster, we can query lights within the cluster
|
|
568
|
-
const match_count =
|
|
581
|
+
const match_count = query_bvh_frustum_from_texture(
|
|
582
|
+
scratch_light_nodes,
|
|
583
|
+
0,
|
|
584
|
+
bvh,
|
|
585
|
+
light_source_data,
|
|
586
|
+
scratch_frustum_planes,
|
|
587
|
+
scratch_corners
|
|
588
|
+
);
|
|
569
589
|
|
|
570
590
|
const tile_index = (i_z_0 * tile_slice_size) + (i_y_0 * tr_x) + (tr_x - i_x_1);
|
|
571
591
|
|
|
@@ -618,15 +638,15 @@ export class LightManager {
|
|
|
618
638
|
// write address of the lookup table
|
|
619
639
|
tile_texture_data[tile_address] = lookup_address_offset;
|
|
620
640
|
|
|
621
|
-
for (
|
|
641
|
+
for (i = 0; i < match_count; i++) {
|
|
622
642
|
/**
|
|
623
643
|
*
|
|
624
|
-
* @type {
|
|
644
|
+
* @type {number[]}
|
|
625
645
|
*/
|
|
626
|
-
const
|
|
646
|
+
const light_index = scratch_light_nodes[i];
|
|
627
647
|
|
|
628
648
|
// construct lookup table
|
|
629
|
-
light_lookup_texture_data[lookup_address_offset] =
|
|
649
|
+
light_lookup_texture_data[lookup_address_offset] = light_index * 2;
|
|
630
650
|
|
|
631
651
|
lookup_address_offset++;
|
|
632
652
|
}
|
|
@@ -724,6 +744,7 @@ export class LightManager {
|
|
|
724
744
|
const y_plane_count = tr_y + 1;
|
|
725
745
|
const z_plane_count = tr_z + 1;
|
|
726
746
|
|
|
747
|
+
// TODO compute slices to minimize world-space volume difference between clusters
|
|
727
748
|
const z_slice_stride = x_plane_count * y_plane_count;
|
|
728
749
|
|
|
729
750
|
const points_data = this.__cluster_frustum_points;
|
|
@@ -774,16 +795,20 @@ export class LightManager {
|
|
|
774
795
|
|
|
775
796
|
/**
|
|
776
797
|
* Build light tile texture
|
|
777
|
-
* @param {Camera} camera
|
|
798
|
+
* @param {Camera|THREE.PerspectiveCamera} camera
|
|
778
799
|
*/
|
|
779
800
|
buildTiles(camera) {
|
|
780
801
|
camera.updateProjectionMatrix();
|
|
802
|
+
camera.updateMatrix();
|
|
781
803
|
camera.updateMatrixWorld(true);
|
|
782
804
|
|
|
783
805
|
//update world inverse matrix
|
|
784
806
|
camera.matrixWorldInverse.copy(camera.matrixWorld);
|
|
785
807
|
camera.matrixWorldInverse.invert();
|
|
786
808
|
|
|
809
|
+
// this.__projection_matrix.set(camera.matrixWorldInverse.elements);
|
|
810
|
+
mat4.multiply(this.__projection_matrix, camera.projectionMatrix.elements, camera.matrixWorldInverse.elements);
|
|
811
|
+
|
|
787
812
|
// console.time('__build_view_frustum');
|
|
788
813
|
this.__build_view_frustum(camera);
|
|
789
814
|
// console.timeEnd('__build_view_frustum');
|
|
@@ -828,12 +853,18 @@ export class LightManager {
|
|
|
828
853
|
this.__cluster_texture_needs_rebuild = true;
|
|
829
854
|
this.__update_cluster_texture();
|
|
830
855
|
|
|
856
|
+
const cluster_planes_size = ((x + 1) + (y + 1) + (z + 1)) * 4;
|
|
857
|
+
const cluster_frustum_points_size = (x + 1) * (y + 1) * (z + 1) * 3;
|
|
858
|
+
|
|
859
|
+
const buffer = new ArrayBuffer((cluster_planes_size + cluster_frustum_points_size) * 4);
|
|
860
|
+
|
|
831
861
|
this.__cluster_planes = new Float32Array(
|
|
832
|
-
|
|
862
|
+
buffer, 0,
|
|
863
|
+
cluster_planes_size
|
|
833
864
|
);
|
|
834
|
-
|
|
835
865
|
this.__cluster_frustum_points = new Float32Array(
|
|
836
|
-
|
|
866
|
+
buffer, cluster_planes_size * 4,
|
|
867
|
+
cluster_frustum_points_size
|
|
837
868
|
);
|
|
838
869
|
}
|
|
839
870
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import Vector3 from "../../../../core/geom/Vector3.js";
|
|
2
2
|
import { Color } from "../../../../core/color/Color.js";
|
|
3
3
|
import Vector1 from "../../../../core/geom/Vector1.js";
|
|
4
|
+
import { mortonEncode_magicbits } from "../../../../core/geom/3d/morton/mortonEncode_magicbits.js";
|
|
4
5
|
|
|
5
6
|
export class PointLight {
|
|
6
7
|
constructor() {
|
|
@@ -21,6 +22,14 @@ export class PointLight {
|
|
|
21
22
|
this.intensity = new Vector1(1);
|
|
22
23
|
}
|
|
23
24
|
|
|
25
|
+
/**
|
|
26
|
+
*
|
|
27
|
+
* @returns {number}
|
|
28
|
+
*/
|
|
29
|
+
computeMortonCode() {
|
|
30
|
+
return mortonEncode_magicbits(this.position.x, this.position.y, this.position.z);
|
|
31
|
+
}
|
|
32
|
+
|
|
24
33
|
/**
|
|
25
34
|
*
|
|
26
35
|
* @param {AABB3} result
|
|
@@ -2,6 +2,7 @@ import Vector3 from "../../../../core/geom/Vector3.js";
|
|
|
2
2
|
import Vector1 from "../../../../core/geom/Vector1.js";
|
|
3
3
|
import { Color } from "../../../../core/color/Color.js";
|
|
4
4
|
import { computeConeBoundingBox } from "../../../../core/geom/3d/cone/computeConeBoundingBox.js";
|
|
5
|
+
import { mortonEncode_magicbits } from "../../../../core/geom/3d/morton/mortonEncode_magicbits.js";
|
|
5
6
|
|
|
6
7
|
export class SpotLight {
|
|
7
8
|
constructor() {
|
|
@@ -48,6 +49,14 @@ export class SpotLight {
|
|
|
48
49
|
this.penumbra = new Vector1(0.4);
|
|
49
50
|
}
|
|
50
51
|
|
|
52
|
+
/**
|
|
53
|
+
*
|
|
54
|
+
* @returns {number}
|
|
55
|
+
*/
|
|
56
|
+
computeMortonCode() {
|
|
57
|
+
return mortonEncode_magicbits(this.position.x, this.position.y, this.position.z);
|
|
58
|
+
}
|
|
59
|
+
|
|
51
60
|
/**
|
|
52
61
|
*
|
|
53
62
|
* @param {AABB3} result
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Hash function using prime shift
|
|
3
|
-
* @param {
|
|
3
|
+
* @param {number[]} nodes
|
|
4
4
|
* @param {number} count
|
|
5
5
|
*/
|
|
6
6
|
export function compute_light_data_hash_0(nodes, count) {
|
|
@@ -10,7 +10,7 @@ export function compute_light_data_hash_0(nodes, count) {
|
|
|
10
10
|
for (let i = 0; i < count; i++) {
|
|
11
11
|
const datum = nodes[i];
|
|
12
12
|
|
|
13
|
-
hash =
|
|
13
|
+
hash = hash * 31 + datum;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
return hash & 0x7fffffff;
|
|
@@ -1,15 +1,5 @@
|
|
|
1
|
-
import Vector3 from "../../../../core/geom/Vector3.js";
|
|
2
1
|
import { plane_three_computeConvex3PlaneIntersection } from "../../../../core/geom/3d/plane/plane_computeConvex3PlaneIntersection.js";
|
|
3
2
|
|
|
4
|
-
const v_000 = new Vector3();
|
|
5
|
-
const v_001 = new Vector3();
|
|
6
|
-
const v_010 = new Vector3();
|
|
7
|
-
const v_011 = new Vector3();
|
|
8
|
-
const v_100 = new Vector3();
|
|
9
|
-
const v_101 = new Vector3();
|
|
10
|
-
const v_110 = new Vector3();
|
|
11
|
-
const v_111 = new Vector3();
|
|
12
|
-
|
|
13
3
|
/**
|
|
14
4
|
*
|
|
15
5
|
* @param {Float32Array|number[]} result
|
|
@@ -18,68 +8,60 @@ const v_111 = new Vector3();
|
|
|
18
8
|
export function computeFrustumCorners(result, planes) {
|
|
19
9
|
|
|
20
10
|
const plane_x0 = planes[0];
|
|
21
|
-
const plane_x1 = planes[1];
|
|
22
|
-
|
|
23
11
|
const plane_y0 = planes[2];
|
|
24
|
-
const plane_y1 = planes[3];
|
|
25
|
-
|
|
26
12
|
const plane_z0 = planes[4];
|
|
27
|
-
const plane_z1 = planes[5];
|
|
28
13
|
|
|
29
|
-
plane_three_computeConvex3PlaneIntersection(
|
|
14
|
+
plane_three_computeConvex3PlaneIntersection(result, 0,
|
|
30
15
|
plane_x0,
|
|
31
16
|
plane_y0,
|
|
32
17
|
plane_z0
|
|
33
18
|
);
|
|
34
19
|
|
|
35
|
-
|
|
20
|
+
const plane_z1 = planes[5];
|
|
21
|
+
|
|
22
|
+
plane_three_computeConvex3PlaneIntersection(result, 3,
|
|
36
23
|
plane_x0,
|
|
37
24
|
plane_y0,
|
|
38
25
|
plane_z1
|
|
39
26
|
);
|
|
40
27
|
|
|
41
|
-
|
|
28
|
+
const plane_y1 = planes[3];
|
|
29
|
+
|
|
30
|
+
plane_three_computeConvex3PlaneIntersection(result, 6,
|
|
42
31
|
plane_x0,
|
|
43
32
|
plane_y1,
|
|
44
33
|
plane_z0
|
|
45
34
|
);
|
|
46
35
|
|
|
47
|
-
plane_three_computeConvex3PlaneIntersection(
|
|
36
|
+
plane_three_computeConvex3PlaneIntersection(result, 9,
|
|
48
37
|
plane_x0,
|
|
49
38
|
plane_y1,
|
|
50
39
|
plane_z1
|
|
51
40
|
);
|
|
52
41
|
|
|
53
|
-
|
|
42
|
+
const plane_x1 = planes[1];
|
|
43
|
+
|
|
44
|
+
plane_three_computeConvex3PlaneIntersection(result, 12,
|
|
54
45
|
plane_x1,
|
|
55
46
|
plane_y0,
|
|
56
47
|
plane_z0
|
|
57
48
|
);
|
|
58
49
|
|
|
59
|
-
plane_three_computeConvex3PlaneIntersection(
|
|
50
|
+
plane_three_computeConvex3PlaneIntersection(result, 15,
|
|
60
51
|
plane_x1,
|
|
61
52
|
plane_y0,
|
|
62
53
|
plane_z1
|
|
63
54
|
);
|
|
64
55
|
|
|
65
|
-
plane_three_computeConvex3PlaneIntersection(
|
|
56
|
+
plane_three_computeConvex3PlaneIntersection(result, 18,
|
|
66
57
|
plane_x1,
|
|
67
58
|
plane_y1,
|
|
68
59
|
plane_z0
|
|
69
60
|
);
|
|
70
61
|
|
|
71
|
-
plane_three_computeConvex3PlaneIntersection(
|
|
62
|
+
plane_three_computeConvex3PlaneIntersection(result, 21,
|
|
72
63
|
plane_x1,
|
|
73
64
|
plane_y1,
|
|
74
65
|
plane_z1
|
|
75
66
|
);
|
|
76
|
-
|
|
77
|
-
v_000.writeToArray(result, 0);
|
|
78
|
-
v_001.writeToArray(result, 3);
|
|
79
|
-
v_010.writeToArray(result, 6);
|
|
80
|
-
v_011.writeToArray(result, 9);
|
|
81
|
-
v_100.writeToArray(result, 12);
|
|
82
|
-
v_101.writeToArray(result, 15);
|
|
83
|
-
v_110.writeToArray(result, 18);
|
|
84
|
-
v_111.writeToArray(result, 21);
|
|
85
67
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const FP_INJECTION_POINT_ACCUMULATION = '//@injection_point FORWARD_PLUS:accumulation';
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export const FP_SHADER_CHUNK_ACCUMULATION = `
|
|
2
|
+
ivec3 v3_cluster_resolution = textureSize(fp_t_light_tiles, 0);
|
|
3
|
+
ivec3 v3_cluster_position = ivec3( clip_v.x * float(v3_cluster_resolution.x), clip_v.y*float(v3_cluster_resolution.y), (clip_v.z)*float(v3_cluster_resolution.z) );
|
|
4
|
+
|
|
5
|
+
uvec3 cluster_metadata = texelFetch(fp_t_light_tiles, v3_cluster_position , 0).rgb;
|
|
6
|
+
|
|
7
|
+
// read light data
|
|
8
|
+
for(uint i=0u; i < cluster_metadata.y; i++){
|
|
9
|
+
uint lookup_index = cluster_metadata.x + i;
|
|
10
|
+
|
|
11
|
+
uint light_address = texelFetch(fp_t_light_lookup, address_to_data_texture_coordinates(lookup_index), 0 ).r;
|
|
12
|
+
|
|
13
|
+
vec4 light_data_0 = texelFetch(fp_t_light_data, address_to_data_texture_coordinates(light_address), 0);
|
|
14
|
+
vec4 light_data_1 = texelFetch(fp_t_light_data, address_to_data_texture_coordinates(light_address+1u), 0);
|
|
15
|
+
|
|
16
|
+
vec3 light_position = light_data_0.xyz;
|
|
17
|
+
float light_radius = light_data_0.w;
|
|
18
|
+
|
|
19
|
+
vec3 light_color = light_data_1.xyz;
|
|
20
|
+
float light_intensity = light_data_1.w;
|
|
21
|
+
|
|
22
|
+
PointLight pointlight;
|
|
23
|
+
|
|
24
|
+
pointlight.position = light_position;
|
|
25
|
+
pointlight.distance = light_radius;
|
|
26
|
+
pointlight.color = light_color*light_intensity;
|
|
27
|
+
pointlight.decay = 1.0;
|
|
28
|
+
|
|
29
|
+
fp_getPointDirectLightIrradiance( pointlight, directLight, vViewPosition );
|
|
30
|
+
RE_Direct( directLight, geometry, material, reflectedLight );
|
|
31
|
+
}
|
|
32
|
+
`;
|