@woosh/meep-engine 2.33.23 → 2.33.27
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/binary/BitSet.js +151 -167
- package/core/binary/BitSet.spec.js +99 -1
- package/core/binary/ValidatingBitSetWrapper.js +81 -0
- package/core/bvh2/BinaryNode.js +1 -1
- package/core/bvh2/aabb3/AABB3.js +21 -10
- 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 +22 -5
- package/core/cache/Cache.d.ts +4 -2
- package/core/cache/Cache.js +5 -2
- package/core/collection/ArrayUtils.js +1 -1
- package/core/collection/HashMap.d.ts +9 -2
- package/core/collection/HashSet.d.ts +7 -2
- package/core/collection/HashSet.js +7 -2
- 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/array/typed/typed_array_copy.js +1 -1
- 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/array_setFromProjectionMatrix.js +3 -3
- package/core/geom/3d/frustum/frustum3_computeNearestPointToPoint.js +1 -1
- 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/ray/ray_computeNearestPointToPoint.js +37 -0
- package/core/geom/3d/shape/AbstractShape3D.js +65 -0
- package/core/geom/3d/shape/TransformedShape3D.js +181 -0
- package/core/geom/3d/shape/TransformedShape3D.spec.js +33 -0
- package/core/geom/3d/shape/UnionShape3D.js +255 -0
- package/core/geom/3d/shape/UnitCubeShape3D.js +101 -0
- package/core/geom/3d/shape/UnitCubeShape3D.spec.js +42 -0
- package/core/geom/3d/shape/UnitSphereShape3D.js +55 -0
- package/core/geom/3d/shape/util/compute_signed_distance_gradient_by_sampling.js +48 -0
- package/core/geom/3d/shape/util/shape_to_visual_entity.js +159 -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/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/parser/simple/Token.d.ts +13 -0
- package/core/parser/simple/Token.js +61 -27
- 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/tools/FoliagePaintTool.js +4 -4
- 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 +62 -1
- package/engine/asset/loaders/image/ImageDecoderWorker.js +4 -3
- package/engine/asset/loaders/image/ImageRGBADataAsset.js +10 -2
- package/engine/asset/loaders/image/ImageRGBADataLoader.js +3 -3
- package/engine/asset/loaders/image/codec/NativeImageDecoder.js +2 -1
- package/engine/asset/loaders/image/png/PNG.js +113 -6
- package/engine/asset/loaders/image/png/PNGReader.js +5 -0
- package/engine/asset/loaders/material/bitmap2sampler_gl.js +1 -1
- package/engine/asset/loaders/material/computeImageBitmapEquality.js +6 -1
- package/engine/asset/loaders/material/computeMaterialHash.js +3 -1
- package/engine/asset/loaders/material/computeTextureEquality.js +40 -49
- package/engine/asset/loaders/material/computeTextureHash.js +2 -1
- package/engine/ecs/EntityBuilder.js +25 -5
- package/engine/ecs/EntityComponentDataset.js +1 -1
- 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/InstancedFoliage.js +277 -266
- package/engine/ecs/foliage/ecs/Foliage2System.js +7 -7
- package/engine/ecs/foliage/ecs/InstancedMeshComponent.js +37 -0
- package/engine/ecs/foliage/ecs/{Foliage2.js → InstancedMeshLayer.js} +3 -45
- package/engine/ecs/foliage/ecs/InstancedMeshSerializationAdapter.js +6 -5
- package/engine/ecs/foliage/ecs/InstancedMeshUtils.js +7 -6
- 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/storage/binary/BinarySerializationRegistry.js +1 -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/ecs/layers/TerrainLayer.js +12 -16
- 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/graphics/GraphicsEngine.js +11 -6
- 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/geometry/AttributeSpec.js +105 -0
- package/engine/graphics/{micron/format/MicronVertexDataSpec.js → geometry/VertexDataSpec.js} +56 -25
- package/engine/graphics/geometry/instancing/InstancedMeshGroup.js +14 -72
- package/engine/graphics/geometry/instancing/rewriteMaterial.js +70 -0
- package/engine/graphics/material/manager/MaterialManager.js +2 -1
- 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 +11 -9
- package/engine/graphics/micron/render/instanced/ThreeInstancedAdapter.js +0 -2
- 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 +8 -2
- package/engine/graphics/particles/particular/engine/emitter/PARTICULAR_PARTICLE_SPECIFICATION.js +80 -16
- package/engine/graphics/particles/particular/engine/emitter/ParticleEmitter.js +71 -77
- package/engine/graphics/particles/particular/engine/emitter/ParticleEmitterFlag.js +5 -0
- package/engine/graphics/particles/particular/engine/emitter/ParticleLayer.js +2 -1
- 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 +1 -1
- 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 +81 -48
- 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 +938 -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/simple-fx/ao/AmbientOcclusionPostProcessEffect.js +16 -11
- 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 +117 -94
- 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/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/FPlusDebugMaterial.js +3 -3
- package/engine/graphics/render/forward_plus/materials/ForwardPlusThreeMaterial.js +1 -1
- 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 +594 -59
- package/engine/graphics/render/forward_plus/prototypeLightManager.js +208 -89
- 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 +74 -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/visibility/IncrementalDeltaSet.js +11 -0
- package/engine/graphics/render/visibility/hiz/prototypeHiZ.js +1 -1
- package/engine/graphics/shaders/TerrainShader.js +4 -5
- package/engine/graphics/shadows/ShadowMapRenderer.js +8 -2
- package/engine/graphics/texture/atlas/ManagedTextureAtlas.js +12 -1
- 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 +3 -1
- package/engine/graphics/texture/sampler/convertTexture2Sampler2D.js +1 -1
- package/engine/graphics/texture/sampler/copy_Sampler2D_channel_data.js +66 -0
- package/engine/graphics/texture/sampler/distanceField.spec.js +1 -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 +1 -1
- 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/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 +1 -1
- package/misc/makeMaterialIconCached.js +2 -2
- package/package.json +1 -1
- 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/MinimapWorldGL.js +12 -5
- 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 -357
|
@@ -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,6 +517,7 @@ 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
|
|
|
511
522
|
// clear cache
|
|
512
523
|
LOOKUP_CACHE.fill(0xFFFFFFFF);
|
|
@@ -567,10 +578,11 @@ export class LightManager {
|
|
|
567
578
|
|
|
568
579
|
|
|
569
580
|
// at this point we have a fully constructed cluster, we can query lights within the cluster
|
|
570
|
-
const match_count =
|
|
581
|
+
const match_count = query_bvh_frustum_from_texture(
|
|
571
582
|
scratch_light_nodes,
|
|
572
583
|
0,
|
|
573
584
|
bvh,
|
|
585
|
+
light_source_data,
|
|
574
586
|
scratch_frustum_planes,
|
|
575
587
|
scratch_corners
|
|
576
588
|
);
|
|
@@ -626,15 +638,15 @@ export class LightManager {
|
|
|
626
638
|
// write address of the lookup table
|
|
627
639
|
tile_texture_data[tile_address] = lookup_address_offset;
|
|
628
640
|
|
|
629
|
-
for (
|
|
641
|
+
for (i = 0; i < match_count; i++) {
|
|
630
642
|
/**
|
|
631
643
|
*
|
|
632
|
-
* @type {
|
|
644
|
+
* @type {number[]}
|
|
633
645
|
*/
|
|
634
|
-
const
|
|
646
|
+
const light_index = scratch_light_nodes[i];
|
|
635
647
|
|
|
636
648
|
// construct lookup table
|
|
637
|
-
light_lookup_texture_data[lookup_address_offset] =
|
|
649
|
+
light_lookup_texture_data[lookup_address_offset] = light_index * 2;
|
|
638
650
|
|
|
639
651
|
lookup_address_offset++;
|
|
640
652
|
}
|
|
@@ -732,6 +744,7 @@ export class LightManager {
|
|
|
732
744
|
const y_plane_count = tr_y + 1;
|
|
733
745
|
const z_plane_count = tr_z + 1;
|
|
734
746
|
|
|
747
|
+
// TODO compute slices to minimize world-space volume difference between clusters
|
|
735
748
|
const z_slice_stride = x_plane_count * y_plane_count;
|
|
736
749
|
|
|
737
750
|
const points_data = this.__cluster_frustum_points;
|
|
@@ -782,16 +795,20 @@ export class LightManager {
|
|
|
782
795
|
|
|
783
796
|
/**
|
|
784
797
|
* Build light tile texture
|
|
785
|
-
* @param {Camera} camera
|
|
798
|
+
* @param {Camera|THREE.PerspectiveCamera} camera
|
|
786
799
|
*/
|
|
787
800
|
buildTiles(camera) {
|
|
788
801
|
camera.updateProjectionMatrix();
|
|
802
|
+
camera.updateMatrix();
|
|
789
803
|
camera.updateMatrixWorld(true);
|
|
790
804
|
|
|
791
805
|
//update world inverse matrix
|
|
792
806
|
camera.matrixWorldInverse.copy(camera.matrixWorld);
|
|
793
807
|
camera.matrixWorldInverse.invert();
|
|
794
808
|
|
|
809
|
+
// this.__projection_matrix.set(camera.matrixWorldInverse.elements);
|
|
810
|
+
mat4.multiply(this.__projection_matrix, camera.projectionMatrix.elements, camera.matrixWorldInverse.elements);
|
|
811
|
+
|
|
795
812
|
// console.time('__build_view_frustum');
|
|
796
813
|
this.__build_view_frustum(camera);
|
|
797
814
|
// console.timeEnd('__build_view_frustum');
|
|
@@ -836,12 +853,18 @@ export class LightManager {
|
|
|
836
853
|
this.__cluster_texture_needs_rebuild = true;
|
|
837
854
|
this.__update_cluster_texture();
|
|
838
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
|
+
|
|
839
861
|
this.__cluster_planes = new Float32Array(
|
|
840
|
-
|
|
862
|
+
buffer, 0,
|
|
863
|
+
cluster_planes_size
|
|
841
864
|
);
|
|
842
|
-
|
|
843
865
|
this.__cluster_frustum_points = new Float32Array(
|
|
844
|
-
|
|
866
|
+
buffer, cluster_planes_size * 4,
|
|
867
|
+
cluster_frustum_points_size
|
|
845
868
|
);
|
|
846
869
|
}
|
|
847
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;
|
|
@@ -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
|
+
`;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export const FP_SHADER_CHUNK_DECODE_PARS = `
|
|
2
|
+
// don't rely on three.js light number define to ensure that point light calculations are available
|
|
3
|
+
#if NUM_POINT_LIGHTS < 1
|
|
4
|
+
struct PointLight {
|
|
5
|
+
vec3 position;
|
|
6
|
+
vec3 color;
|
|
7
|
+
float distance;
|
|
8
|
+
float decay;
|
|
9
|
+
};
|
|
10
|
+
#endif
|
|
11
|
+
|
|
12
|
+
// directLight is an out parameter as having it as a return value caused compiler errors on some devices
|
|
13
|
+
void fp_getPointDirectLightIrradiance( const in PointLight pointLight, out IncidentLight directLight, vec3 viewPosition ) {
|
|
14
|
+
|
|
15
|
+
// TODO consider moving light position transformation to view-space over to CPU
|
|
16
|
+
vec3 lVector = (viewMatrix*vec4(pointLight.position,1.0)).xyz + viewPosition;
|
|
17
|
+
|
|
18
|
+
directLight.direction = normalize( lVector );
|
|
19
|
+
|
|
20
|
+
float lightDistance = length( lVector );
|
|
21
|
+
|
|
22
|
+
directLight.color = pointLight.color;
|
|
23
|
+
directLight.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
|
|
24
|
+
directLight.visible = ( directLight.color != vec3( 0.0 ) );
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
float convert_depth_to_linear(in float d){
|
|
28
|
+
float d_n = 2.0*d - 1.0;
|
|
29
|
+
|
|
30
|
+
float f = fp_f_camera_far;
|
|
31
|
+
float n = fp_f_camera_near;
|
|
32
|
+
|
|
33
|
+
float fn = f*n;
|
|
34
|
+
|
|
35
|
+
float z_diff = f - n;
|
|
36
|
+
|
|
37
|
+
float denominator = (f + n - d_n * z_diff );
|
|
38
|
+
|
|
39
|
+
float z_view = (2.0*fn) / denominator;
|
|
40
|
+
|
|
41
|
+
return (z_view - n) / z_diff;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
ivec2 address_to_data_texture_coordinates(uint address){
|
|
45
|
+
// Lookup texture has 128 width
|
|
46
|
+
uint lookup_index_x = address % 128u;
|
|
47
|
+
uint lookup_index_y = address >> 7;
|
|
48
|
+
|
|
49
|
+
return ivec2(int(lookup_index_x),int(lookup_index_y));
|
|
50
|
+
}
|
|
51
|
+
`;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export const FP_SHADER_CHUNK_PREAMBLE = `precision mediump usampler3D;
|
|
2
|
+
precision mediump usampler2D;
|
|
3
|
+
|
|
4
|
+
uniform usampler3D fp_t_light_tiles;
|
|
5
|
+
|
|
6
|
+
uniform usampler2D fp_t_light_lookup;
|
|
7
|
+
uniform sampler2D fp_t_light_data;
|
|
8
|
+
|
|
9
|
+
uniform vec3 fp_v3_light_cluster_resolution;
|
|
10
|
+
|
|
11
|
+
uniform float fp_f_camera_near;
|
|
12
|
+
uniform float fp_f_camera_far;
|
|
13
|
+
|
|
14
|
+
#define gl_FragDepthEXT gl_FragDepth
|
|
15
|
+
#define texture2D texture
|
|
16
|
+
#define textureCube texture
|
|
17
|
+
#define texture2DProj textureProj
|
|
18
|
+
#define texture2DLodEXT textureLod
|
|
19
|
+
#define texture2DProjLodEXT textureProjLod
|
|
20
|
+
#define textureCubeLodEXT textureLod
|
|
21
|
+
#define texture2DGradEXT textureGrad
|
|
22
|
+
#define texture2DProjGradEXT textureProjGrad
|
|
23
|
+
#define textureCubeGradEXT textureGrad
|
|
24
|
+
|
|
25
|
+
uniform vec2 fp_resolution;`;
|
|
@@ -36,7 +36,7 @@ const f_shader = `
|
|
|
36
36
|
|
|
37
37
|
uniform sampler2D t_heatmap_lookup;
|
|
38
38
|
|
|
39
|
-
uniform vec2
|
|
39
|
+
uniform vec2 fp_resolution;
|
|
40
40
|
|
|
41
41
|
uniform mat4 projectionMatrix;
|
|
42
42
|
|
|
@@ -79,7 +79,7 @@ const f_shader = `
|
|
|
79
79
|
|
|
80
80
|
void main(){
|
|
81
81
|
|
|
82
|
-
vec3 clip_v = vec3(gl_FragCoord.xy /
|
|
82
|
+
vec3 clip_v = vec3(gl_FragCoord.xy / fp_resolution, convert_depth_to_linear( gl_FragCoord.z));
|
|
83
83
|
|
|
84
84
|
ivec3 v3_cluster_resolution = textureSize(fp_t_light_tiles, 0);
|
|
85
85
|
ivec3 v3_cluster_position = ivec3( ( 1.0 - clip_v.x) * float(v3_cluster_resolution.x), clip_v.y*float(v3_cluster_resolution.y), (clip_v.z)*float(v3_cluster_resolution.z) );
|
|
@@ -119,7 +119,7 @@ export class FPlusDebugMaterial extends ShaderMaterial {
|
|
|
119
119
|
type: 'f',
|
|
120
120
|
value: 0
|
|
121
121
|
},
|
|
122
|
-
|
|
122
|
+
fp_resolution: {
|
|
123
123
|
type: 'v2',
|
|
124
124
|
value: new Vector2()
|
|
125
125
|
},
|