@plastic-software/three 0.181.3 → 0.183.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/LICENSE +1 -1
- package/README.md +3 -4
- package/build/three.cjs +11330 -10017
- package/build/three.core.js +10011 -9493
- package/build/three.core.min.js +2 -2
- package/build/three.module.js +1414 -631
- package/build/three.module.min.js +2 -2
- package/build/three.tsl.js +21 -13
- package/build/three.tsl.min.js +2 -2
- package/build/three.webgpu.js +8007 -5427
- package/build/three.webgpu.min.js +2 -2
- package/build/three.webgpu.nodes.js +8005 -5426
- package/build/three.webgpu.nodes.min.js +2 -2
- package/examples/jsm/Addons.js +0 -3
- package/examples/jsm/animation/CCDIKSolver.js +2 -2
- package/examples/jsm/controls/ArcballControls.js +3 -3
- package/examples/jsm/controls/MapControls.js +55 -1
- package/examples/jsm/controls/OrbitControls.js +109 -6
- package/examples/jsm/controls/TrackballControls.js +6 -6
- package/examples/jsm/csm/CSM.js +2 -1
- package/examples/jsm/effects/AnaglyphEffect.js +102 -7
- package/examples/jsm/environments/ColorEnvironment.js +59 -0
- package/examples/jsm/environments/RoomEnvironment.js +3 -0
- package/examples/jsm/exporters/EXRExporter.js +1 -1
- package/examples/jsm/exporters/GLTFExporter.js +131 -4
- package/examples/jsm/exporters/USDZExporter.js +22 -3
- package/examples/jsm/geometries/DecalGeometry.js +1 -1
- package/examples/jsm/helpers/AnimationPathHelper.js +302 -0
- package/examples/jsm/helpers/LightProbeHelperGPU.js +1 -1
- package/examples/jsm/helpers/TextureHelperGPU.js +1 -1
- package/examples/jsm/helpers/ViewHelper.js +67 -8
- package/examples/jsm/inspector/Inspector.js +74 -14
- package/examples/jsm/inspector/RendererInspector.js +12 -2
- package/examples/jsm/inspector/tabs/Console.js +41 -7
- package/examples/jsm/inspector/tabs/Parameters.js +18 -2
- package/examples/jsm/inspector/tabs/Performance.js +2 -2
- package/examples/jsm/inspector/tabs/Viewer.js +4 -4
- package/examples/jsm/inspector/ui/Profiler.js +1836 -31
- package/examples/jsm/inspector/ui/Style.js +973 -14
- package/examples/jsm/inspector/ui/Tab.js +188 -1
- package/examples/jsm/inspector/ui/Values.js +17 -1
- package/examples/jsm/libs/meshopt_decoder.module.js +6 -5
- package/examples/jsm/lines/LineMaterial.js +6 -0
- package/examples/jsm/loaders/3DMLoader.js +5 -4
- package/examples/jsm/loaders/3MFLoader.js +2 -2
- package/examples/jsm/loaders/AMFLoader.js +2 -2
- package/examples/jsm/loaders/ColladaLoader.js +24 -4026
- package/examples/jsm/loaders/DRACOLoader.js +5 -5
- package/examples/jsm/loaders/EXRLoader.js +5 -5
- package/examples/jsm/loaders/FBXLoader.js +2 -4
- package/examples/jsm/loaders/GCodeLoader.js +34 -8
- package/examples/jsm/loaders/GLTFLoader.js +122 -171
- package/examples/jsm/loaders/HDRLoader.js +0 -1
- package/examples/jsm/loaders/KMZLoader.js +5 -5
- package/examples/jsm/loaders/KTX2Loader.js +19 -3
- package/examples/jsm/loaders/LDrawLoader.js +2 -3
- package/examples/jsm/loaders/LWOLoader.js +7 -39
- package/examples/jsm/loaders/NRRDLoader.js +2 -2
- package/examples/jsm/loaders/PCDLoader.js +4 -2
- package/examples/jsm/loaders/SVGLoader.js +1 -1
- package/examples/jsm/loaders/TDSLoader.js +0 -2
- package/examples/jsm/loaders/TGALoader.js +0 -2
- package/examples/jsm/loaders/USDLoader.js +100 -40
- package/examples/jsm/loaders/UltraHDRLoader.js +285 -160
- package/examples/jsm/loaders/VOXLoader.js +660 -117
- package/examples/jsm/loaders/VRMLLoader.js +79 -2
- package/examples/jsm/loaders/VTKLoader.js +37 -24
- package/examples/jsm/loaders/collada/ColladaComposer.js +2950 -0
- package/examples/jsm/loaders/collada/ColladaParser.js +1962 -0
- package/examples/jsm/loaders/usd/USDAParser.js +447 -366
- package/examples/jsm/loaders/usd/USDCParser.js +1841 -6
- package/examples/jsm/loaders/usd/USDComposer.js +4041 -0
- package/examples/jsm/materials/LDrawConditionalLineNodeMaterial.js +2 -2
- package/examples/jsm/materials/WoodNodeMaterial.js +11 -11
- package/examples/jsm/math/Octree.js +131 -1
- package/examples/jsm/misc/Volume.js +0 -1
- package/examples/jsm/misc/VolumeSlice.js +0 -1
- package/examples/jsm/objects/LensflareMesh.js +1 -1
- package/examples/jsm/objects/Sky.js +76 -4
- package/examples/jsm/objects/SkyMesh.js +127 -10
- package/examples/jsm/objects/Water.js +4 -3
- package/examples/jsm/objects/Water2.js +5 -3
- package/examples/jsm/objects/WaterMesh.js +5 -7
- package/examples/jsm/physics/AmmoPhysics.js +12 -7
- package/examples/jsm/physics/JoltPhysics.js +10 -6
- package/examples/jsm/physics/RapierPhysics.js +9 -5
- package/examples/jsm/postprocessing/EffectComposer.js +7 -5
- package/examples/jsm/postprocessing/OutputPass.js +9 -0
- package/examples/jsm/postprocessing/RenderPass.js +10 -0
- package/examples/jsm/postprocessing/RenderTransitionPass.js +1 -1
- package/examples/jsm/postprocessing/UnrealBloomPass.js +48 -18
- package/examples/jsm/renderers/CSS3DRenderer.js +1 -1
- package/examples/jsm/renderers/Projector.js +268 -30
- package/examples/jsm/renderers/SVGRenderer.js +193 -60
- package/examples/jsm/shaders/GTAOShader.js +19 -6
- package/examples/jsm/shaders/HalftoneShader.js +12 -1
- package/examples/jsm/shaders/PoissonDenoiseShader.js +6 -2
- package/examples/jsm/shaders/SAOShader.js +17 -4
- package/examples/jsm/shaders/SSAOShader.js +11 -1
- package/examples/jsm/shaders/SSRShader.js +6 -5
- package/examples/jsm/shaders/UnpackDepthRGBAShader.js +2 -4
- package/examples/jsm/shaders/VignetteShader.js +1 -1
- package/examples/jsm/transpiler/AST.js +44 -0
- package/examples/jsm/transpiler/GLSLDecoder.js +61 -4
- package/examples/jsm/transpiler/ShaderToyDecoder.js +2 -0
- package/examples/jsm/transpiler/TSLEncoder.js +46 -3
- package/examples/jsm/transpiler/TranspilerUtils.js +3 -3
- package/examples/jsm/transpiler/WGSLEncoder.js +27 -0
- package/examples/jsm/tsl/display/AfterImageNode.js +1 -1
- package/examples/jsm/tsl/display/AnaglyphPassNode.js +458 -16
- package/examples/jsm/tsl/display/AnamorphicNode.js +1 -1
- package/examples/jsm/tsl/display/BilateralBlurNode.js +364 -0
- package/examples/jsm/tsl/display/BloomNode.js +16 -6
- package/examples/jsm/tsl/display/CRT.js +150 -0
- package/examples/jsm/tsl/display/DenoiseNode.js +1 -1
- package/examples/jsm/tsl/display/DepthOfFieldNode.js +1 -1
- package/examples/jsm/tsl/display/DotScreenNode.js +1 -1
- package/examples/jsm/tsl/display/FXAANode.js +2 -2
- package/examples/jsm/tsl/display/GTAONode.js +5 -4
- package/examples/jsm/tsl/display/GaussianBlurNode.js +11 -2
- package/examples/jsm/tsl/display/GodraysNode.js +624 -0
- package/examples/jsm/tsl/display/LensflareNode.js +1 -1
- package/examples/jsm/tsl/display/Lut3DNode.js +1 -1
- package/examples/jsm/tsl/display/OutlineNode.js +3 -3
- package/examples/jsm/tsl/display/ParallaxBarrierPassNode.js +2 -2
- package/examples/jsm/tsl/display/PixelationPassNode.js +7 -6
- package/examples/jsm/tsl/display/RGBShiftNode.js +2 -2
- package/examples/jsm/tsl/display/RetroPassNode.js +263 -0
- package/examples/jsm/tsl/display/SMAANode.js +2 -2
- package/examples/jsm/tsl/display/SSAAPassNode.js +2 -2
- package/examples/jsm/tsl/display/SSGINode.js +8 -20
- package/examples/jsm/tsl/display/SSRNode.js +8 -8
- package/examples/jsm/tsl/display/SSSNode.js +6 -4
- package/examples/jsm/tsl/display/Shape.js +29 -0
- package/examples/jsm/tsl/display/SobelOperatorNode.js +2 -2
- package/examples/jsm/tsl/display/StereoCompositePassNode.js +8 -1
- package/examples/jsm/tsl/display/StereoPassNode.js +1 -2
- package/examples/jsm/tsl/display/TRAANode.js +273 -125
- package/examples/jsm/tsl/display/TransitionNode.js +1 -1
- package/examples/jsm/tsl/display/depthAwareBlend.js +80 -0
- package/examples/jsm/tsl/display/radialBlur.js +68 -0
- package/examples/jsm/tsl/math/Bayer.js +40 -1
- package/examples/jsm/utils/LDrawUtils.js +1 -1
- package/examples/jsm/utils/ShadowMapViewer.js +24 -10
- package/examples/jsm/utils/ShadowMapViewerGPU.js +1 -1
- package/examples/jsm/utils/WebGPUTextureUtils.js +1 -1
- package/package.json +20 -26
- package/src/Three.Core.js +2 -1
- package/src/Three.TSL.js +19 -11
- package/src/Three.WebGPU.Nodes.js +2 -0
- package/src/Three.WebGPU.js +3 -0
- package/src/Three.js +1 -0
- package/src/animation/AnimationAction.js +1 -1
- package/src/animation/AnimationClip.js +1 -1
- package/src/animation/AnimationMixer.js +6 -0
- package/src/animation/AnimationUtils.js +1 -12
- package/src/animation/KeyframeTrack.js +47 -8
- package/src/animation/PropertyMixer.js +4 -4
- package/src/animation/tracks/BooleanKeyframeTrack.js +1 -1
- package/src/animation/tracks/ColorKeyframeTrack.js +1 -1
- package/src/animation/tracks/NumberKeyframeTrack.js +1 -1
- package/src/animation/tracks/QuaternionKeyframeTrack.js +1 -1
- package/src/animation/tracks/StringKeyframeTrack.js +1 -1
- package/src/animation/tracks/VectorKeyframeTrack.js +1 -1
- package/src/audio/Audio.js +1 -1
- package/src/audio/AudioListener.js +5 -3
- package/src/cameras/Camera.js +32 -2
- package/src/cameras/CubeCamera.js +20 -0
- package/src/constants.js +90 -5
- package/src/core/BufferGeometry.js +14 -2
- package/src/core/Clock.js +7 -0
- package/src/core/Object3D.js +56 -4
- package/src/core/Raycaster.js +2 -2
- package/src/core/RenderTarget.js +3 -4
- package/src/extras/PMREMGenerator.js +7 -18
- package/src/extras/TextureUtils.js +5 -1
- package/src/geometries/ExtrudeGeometry.js +2 -2
- package/src/geometries/PolyhedronGeometry.js +1 -1
- package/src/geometries/TorusGeometry.js +8 -3
- package/src/helpers/CameraHelper.js +3 -0
- package/src/helpers/DirectionalLightHelper.js +4 -1
- package/src/helpers/HemisphereLightHelper.js +3 -0
- package/src/helpers/PointLightHelper.js +1 -25
- package/src/helpers/SpotLightHelper.js +3 -0
- package/src/lights/DirectionalLight.js +13 -0
- package/src/lights/HemisphereLight.js +10 -0
- package/src/lights/Light.js +1 -11
- package/src/lights/LightProbe.js +0 -15
- package/src/lights/LightShadow.js +15 -6
- package/src/lights/PointLight.js +15 -0
- package/src/lights/PointLightShadow.js +0 -86
- package/src/lights/SpotLight.js +22 -1
- package/src/lights/webgpu/IESSpotLight.js +2 -1
- package/src/loaders/Cache.js +28 -0
- package/src/loaders/FileLoader.js +1 -1
- package/src/loaders/ImageBitmapLoader.js +8 -3
- package/src/loaders/Loader.js +6 -0
- package/src/loaders/MaterialLoader.js +2 -1
- package/src/loaders/ObjectLoader.js +21 -2
- package/src/loaders/nodes/NodeLoader.js +2 -2
- package/src/materials/Material.js +2 -0
- package/src/materials/MeshLambertMaterial.js +9 -0
- package/src/materials/MeshPhongMaterial.js +9 -0
- package/src/materials/ShaderMaterial.js +20 -1
- package/src/materials/nodes/Line2NodeMaterial.js +7 -7
- package/src/materials/nodes/MeshPhysicalNodeMaterial.js +5 -2
- package/src/materials/nodes/MeshStandardNodeMaterial.js +5 -4
- package/src/materials/nodes/NodeMaterial.js +72 -25
- package/src/materials/nodes/manager/NodeMaterialObserver.js +10 -4
- package/src/math/Line3.js +3 -5
- package/src/math/MathUtils.js +10 -10
- package/src/math/Matrix4.js +74 -65
- package/src/math/Quaternion.js +3 -29
- package/src/math/Sphere.js +1 -1
- package/src/math/Vector3.js +3 -5
- package/src/math/interpolants/BezierInterpolant.js +108 -0
- package/src/nodes/Nodes.js +87 -68
- package/src/nodes/TSL.js +6 -6
- package/src/nodes/accessors/Arrays.js +1 -1
- package/src/nodes/accessors/BatchNode.js +10 -10
- package/src/nodes/accessors/Bitangent.js +5 -5
- package/src/nodes/accessors/BufferAttributeNode.js +98 -12
- package/src/nodes/accessors/BufferNode.js +29 -2
- package/src/nodes/accessors/Camera.js +149 -28
- package/src/nodes/accessors/ClippingNode.js +4 -4
- package/src/nodes/accessors/CubeTextureNode.js +20 -1
- package/src/nodes/accessors/InstanceNode.js +148 -43
- package/src/nodes/accessors/MaterialNode.js +9 -1
- package/src/nodes/accessors/MaterialReferenceNode.js +1 -2
- package/src/nodes/accessors/ModelNode.js +1 -1
- package/src/nodes/accessors/Normal.js +11 -11
- package/src/nodes/accessors/Position.js +34 -2
- package/src/nodes/accessors/ReferenceBaseNode.js +4 -4
- package/src/nodes/accessors/ReferenceNode.js +4 -4
- package/src/nodes/accessors/RendererReferenceNode.js +1 -2
- package/src/nodes/accessors/SceneProperties.js +53 -0
- package/src/nodes/accessors/SkinningNode.js +27 -26
- package/src/nodes/accessors/StorageBufferNode.js +4 -21
- package/src/nodes/accessors/StorageTextureNode.js +37 -1
- package/src/nodes/accessors/Tangent.js +4 -14
- package/src/nodes/accessors/Texture3DNode.js +32 -35
- package/src/nodes/accessors/TextureNode.js +58 -22
- package/src/nodes/accessors/UniformArrayNode.js +4 -2
- package/src/nodes/accessors/UserDataNode.js +1 -2
- package/src/nodes/accessors/VertexColorNode.js +1 -2
- package/src/nodes/code/FunctionNode.js +1 -2
- package/src/nodes/core/ArrayNode.js +20 -1
- package/src/nodes/core/AssignNode.js +2 -2
- package/src/nodes/core/AttributeNode.js +2 -2
- package/src/nodes/core/ContextNode.js +103 -4
- package/src/nodes/core/MRTNode.js +48 -2
- package/src/nodes/core/Node.js +29 -3
- package/src/nodes/core/NodeBuilder.js +170 -53
- package/src/nodes/core/NodeError.js +28 -0
- package/src/nodes/core/NodeFrame.js +12 -4
- package/src/nodes/core/NodeUtils.js +10 -8
- package/src/nodes/core/OutputStructNode.js +12 -10
- package/src/nodes/core/ParameterNode.js +3 -3
- package/src/nodes/core/PropertyNode.js +19 -3
- package/src/nodes/core/StackNode.js +65 -16
- package/src/nodes/core/StackTrace.js +139 -0
- package/src/nodes/core/StructNode.js +16 -2
- package/src/nodes/core/StructTypeNode.js +11 -17
- package/src/nodes/core/SubBuildNode.js +1 -1
- package/src/nodes/core/UniformNode.js +21 -5
- package/src/nodes/core/VarNode.js +47 -22
- package/src/nodes/core/VaryingNode.js +1 -18
- package/src/nodes/display/BlendModes.js +0 -64
- package/src/nodes/display/ColorAdjustment.js +17 -0
- package/src/nodes/display/ColorSpaceNode.js +3 -3
- package/src/nodes/display/NormalMapNode.js +39 -4
- package/src/nodes/display/PassNode.js +98 -9
- package/src/nodes/display/RenderOutputNode.js +3 -3
- package/src/nodes/display/ScreenNode.js +3 -1
- package/src/nodes/display/ToneMappingNode.js +1 -1
- package/src/nodes/display/ToonOutlinePassNode.js +2 -2
- package/src/nodes/display/ViewportDepthNode.js +52 -4
- package/src/nodes/display/ViewportTextureNode.js +21 -4
- package/src/nodes/fog/Fog.js +18 -35
- package/src/nodes/functions/BSDF/BRDF_GGX_Multiscatter.js +3 -3
- package/src/nodes/functions/BSDF/DFGLUT.js +56 -0
- package/src/nodes/functions/BSDF/EnvironmentBRDF.js +2 -2
- package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +1 -1
- package/src/nodes/functions/PhysicalLightingModel.js +126 -45
- package/src/nodes/geometry/RangeNode.js +4 -2
- package/src/nodes/gpgpu/ComputeBuiltinNode.js +1 -2
- package/src/nodes/gpgpu/ComputeNode.js +5 -4
- package/src/nodes/gpgpu/SubgroupFunctionNode.js +1 -1
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +4 -4
- package/src/nodes/lighting/AnalyticLightNode.js +53 -0
- package/src/nodes/lighting/EnvironmentNode.js +28 -3
- package/src/nodes/lighting/LightsNode.js +2 -2
- package/src/nodes/lighting/PointShadowNode.js +162 -149
- package/src/nodes/lighting/ShadowFilterNode.js +53 -65
- package/src/nodes/lighting/ShadowNode.js +97 -41
- package/src/nodes/math/BitcountNode.js +433 -0
- package/src/nodes/math/ConditionalNode.js +2 -2
- package/src/nodes/math/MathNode.js +3 -40
- package/src/nodes/math/OperatorNode.js +2 -1
- package/src/nodes/math/PackFloatNode.js +98 -0
- package/src/nodes/math/UnpackFloatNode.js +96 -0
- package/src/nodes/pmrem/PMREMNode.js +1 -1
- package/src/nodes/pmrem/PMREMUtils.js +9 -15
- package/src/nodes/tsl/TSLCore.js +17 -14
- package/src/nodes/utils/ArrayElementNode.js +13 -0
- package/src/nodes/utils/DebugNode.js +11 -11
- package/src/nodes/utils/EventNode.js +1 -2
- package/src/nodes/utils/JoinNode.js +2 -2
- package/src/nodes/utils/LoopNode.js +1 -1
- package/src/nodes/utils/MemberNode.js +1 -1
- package/src/nodes/utils/Packing.js +13 -1
- package/src/nodes/utils/PostProcessingUtils.js +33 -1
- package/src/nodes/utils/RTTNode.js +1 -1
- package/src/nodes/utils/ReflectorNode.js +3 -4
- package/src/nodes/utils/SampleNode.js +1 -1
- package/src/nodes/utils/SpriteSheetUV.js +35 -0
- package/src/nodes/utils/UVUtils.js +28 -0
- package/src/objects/BatchedMesh.js +27 -14
- package/src/objects/InstancedMesh.js +11 -0
- package/src/objects/Line.js +1 -1
- package/src/objects/Mesh.js +1 -1
- package/src/objects/Points.js +1 -1
- package/src/objects/Skeleton.js +9 -0
- package/src/renderers/WebGLRenderer.js +178 -92
- package/src/renderers/common/Backend.js +29 -0
- package/src/renderers/common/Background.js +24 -11
- package/src/renderers/common/BindGroup.js +1 -9
- package/src/renderers/common/Binding.js +11 -0
- package/src/renderers/common/Bindings.js +27 -12
- package/src/renderers/common/BlendMode.js +143 -0
- package/src/renderers/common/Buffer.js +40 -0
- package/src/renderers/common/BundleGroup.js +1 -1
- package/src/renderers/common/ChainMap.js +30 -6
- package/src/renderers/common/CubeRenderTarget.js +50 -6
- package/src/renderers/common/Geometries.js +29 -3
- package/src/renderers/common/Lighting.js +5 -21
- package/src/renderers/common/Pipelines.js +4 -4
- package/src/renderers/common/PostProcessing.js +8 -206
- package/src/renderers/common/RenderBundles.js +2 -1
- package/src/renderers/common/RenderContext.js +16 -0
- package/src/renderers/common/RenderContexts.js +33 -49
- package/src/renderers/common/RenderLists.js +2 -1
- package/src/renderers/common/RenderObject.js +15 -3
- package/src/renderers/common/RenderObjectPipeline.js +40 -0
- package/src/renderers/common/RenderObjects.js +18 -2
- package/src/renderers/common/RenderPipeline.js +203 -17
- package/src/renderers/common/Renderer.js +257 -72
- package/src/renderers/common/Sampler.js +4 -4
- package/src/renderers/common/StorageBuffer.js +13 -1
- package/src/renderers/common/Textures.js +17 -1
- package/src/renderers/common/TimestampQueryPool.js +5 -3
- package/src/renderers/common/Uniform.js +8 -0
- package/src/renderers/common/UniformsGroup.js +61 -0
- package/src/renderers/common/XRManager.js +3 -2
- package/src/renderers/common/extras/PMREMGenerator.js +2 -8
- package/src/renderers/common/nodes/NodeBuilderState.js +1 -1
- package/src/renderers/common/nodes/{Nodes.js → NodeManager.js} +18 -6
- package/src/renderers/common/nodes/NodeStorageBuffer.js +13 -2
- package/src/renderers/common/nodes/NodeUniformBuffer.js +52 -0
- package/src/renderers/shaders/DFGLUTData.js +19 -34
- package/src/renderers/shaders/ShaderChunk/batching_pars_vertex.glsl.js +2 -2
- package/src/renderers/shaders/ShaderChunk/color_fragment.glsl.js +1 -5
- package/src/renderers/shaders/ShaderChunk/color_pars_fragment.glsl.js +1 -5
- package/src/renderers/shaders/ShaderChunk/color_pars_vertex.glsl.js +1 -5
- package/src/renderers/shaders/ShaderChunk/color_vertex.glsl.js +8 -10
- package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +7 -11
- package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +5 -2
- package/src/renderers/shaders/ShaderChunk/lights_fragment_end.glsl.js +6 -0
- package/src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js +6 -2
- package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +8 -4
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +112 -51
- package/src/renderers/shaders/ShaderChunk/packing.glsl.js +20 -4
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +225 -186
- package/src/renderers/shaders/ShaderChunk/shadowmask_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/transmission_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk.js +3 -3
- package/src/renderers/shaders/ShaderLib/depth.glsl.js +3 -0
- package/src/renderers/shaders/ShaderLib/{distanceRGBA.glsl.js → distance.glsl.js} +1 -2
- package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +2 -1
- package/src/renderers/shaders/ShaderLib/meshnormal.glsl.js +1 -2
- package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +2 -1
- package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +4 -9
- package/src/renderers/shaders/ShaderLib/meshtoon.glsl.js +0 -1
- package/src/renderers/shaders/ShaderLib/shadow.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/vsm.glsl.js +4 -6
- package/src/renderers/shaders/ShaderLib.js +7 -5
- package/src/renderers/shaders/UniformsLib.js +0 -3
- package/src/renderers/webgl/WebGLBackground.js +2 -2
- package/src/renderers/webgl/WebGLBindingStates.js +99 -27
- package/src/renderers/webgl/WebGLCapabilities.js +3 -4
- package/src/renderers/webgl/WebGLEnvironments.js +228 -0
- package/src/renderers/webgl/WebGLGeometries.js +10 -7
- package/src/renderers/webgl/WebGLLights.js +18 -1
- package/src/renderers/webgl/WebGLMaterials.js +12 -0
- package/src/renderers/webgl/WebGLObjects.js +3 -1
- package/src/renderers/webgl/WebGLOutput.js +267 -0
- package/src/renderers/webgl/WebGLProgram.js +45 -109
- package/src/renderers/webgl/WebGLPrograms.js +45 -49
- package/src/renderers/webgl/WebGLRenderLists.js +15 -0
- package/src/renderers/webgl/WebGLShadowMap.js +188 -24
- package/src/renderers/webgl/WebGLState.js +32 -37
- package/src/renderers/webgl/WebGLTextures.js +89 -28
- package/src/renderers/webgl/WebGLUniforms.js +40 -3
- package/src/renderers/webgl/WebGLUtils.js +6 -2
- package/src/renderers/webgl-fallback/WebGLBackend.js +148 -18
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +156 -35
- package/src/renderers/webgl-fallback/utils/WebGLState.js +181 -5
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +5 -3
- package/src/renderers/webgl-fallback/utils/WebGLTimestampQueryPool.js +9 -9
- package/src/renderers/webgl-fallback/utils/WebGLUtils.js +6 -2
- package/src/renderers/webgpu/WebGPUBackend.js +119 -13
- package/src/renderers/webgpu/WebGPURenderer.js +2 -1
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +322 -68
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +4 -17
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +357 -200
- package/src/renderers/webgpu/utils/WebGPUConstants.js +2 -0
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +61 -23
- package/src/renderers/webgpu/utils/WebGPUTexturePassUtils.js +152 -200
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +65 -42
- package/src/renderers/webgpu/utils/WebGPUTimestampQueryPool.js +7 -7
- package/src/renderers/webgpu/utils/WebGPUUtils.js +17 -11
- package/src/renderers/webxr/WebXRManager.js +2 -2
- package/src/textures/CubeDepthTexture.js +76 -0
- package/src/textures/Source.js +1 -1
- package/src/textures/Texture.js +3 -3
- package/src/utils.js +258 -3
- package/examples/jsm/materials/MeshGouraudMaterial.js +0 -434
- package/examples/jsm/materials/MeshPostProcessingMaterial.js +0 -167
- package/examples/jsm/shaders/GodRaysShader.js +0 -333
- package/src/nodes/accessors/SceneNode.js +0 -145
- package/src/nodes/code/ScriptableNode.js +0 -726
- package/src/nodes/code/ScriptableValueNode.js +0 -253
- package/src/nodes/display/PosterizeNode.js +0 -65
- package/src/nodes/functions/BSDF/DFGApprox.js +0 -71
- package/src/nodes/utils/SpriteSheetUVNode.js +0 -90
- package/src/renderers/webgl/WebGLCubeMaps.js +0 -99
- package/src/renderers/webgl/WebGLCubeUVMaps.js +0 -134
|
@@ -16,11 +16,10 @@ import { NodeAccess } from '../../../nodes/core/constants.js';
|
|
|
16
16
|
import VarNode from '../../../nodes/core/VarNode.js';
|
|
17
17
|
import ExpressionNode from '../../../nodes/code/ExpressionNode.js';
|
|
18
18
|
|
|
19
|
-
import { FloatType, RepeatWrapping, ClampToEdgeWrapping, MirroredRepeatWrapping, NearestFilter } from '../../../constants.js';
|
|
19
|
+
import { FloatType, RepeatWrapping, ClampToEdgeWrapping, MirroredRepeatWrapping, NearestFilter, Compatibility } from '../../../constants.js';
|
|
20
20
|
import { warn, error } from '../../../utils.js';
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
const GPUShaderStage = ( typeof self !== 'undefined' ) ? self.GPUShaderStage : { VERTEX: 1, FRAGMENT: 2, COMPUTE: 4 };
|
|
22
|
+
import { GPUShaderStage } from '../utils/WebGPUConstants.js';
|
|
24
23
|
|
|
25
24
|
const accessNames = {
|
|
26
25
|
[ NodeAccess.READ_ONLY ]: 'read',
|
|
@@ -35,9 +34,9 @@ const wrapNames = {
|
|
|
35
34
|
};
|
|
36
35
|
|
|
37
36
|
const gpuShaderStageLib = {
|
|
38
|
-
'vertex': GPUShaderStage
|
|
39
|
-
'fragment': GPUShaderStage
|
|
40
|
-
'compute': GPUShaderStage
|
|
37
|
+
'vertex': GPUShaderStage.VERTEX,
|
|
38
|
+
'fragment': GPUShaderStage.FRAGMENT,
|
|
39
|
+
'compute': GPUShaderStage.COMPUTE
|
|
41
40
|
};
|
|
42
41
|
|
|
43
42
|
const supports = {
|
|
@@ -113,6 +112,29 @@ fn tsl_biquadraticTexture( map : texture_2d<f32>, coord : vec2f, iRes : vec2u, l
|
|
|
113
112
|
|
|
114
113
|
return mix( mix( rg1, rg2, f.x ), mix( rg3, rg4, f.x ), f.y );
|
|
115
114
|
|
|
115
|
+
}
|
|
116
|
+
` ),
|
|
117
|
+
biquadraticTextureArray: new CodeNode( /* wgsl */`
|
|
118
|
+
fn tsl_biquadraticTexture_array( map : texture_2d_array<f32>, coord : vec2f, iRes : vec2u, layer : u32, level : u32 ) -> vec4f {
|
|
119
|
+
|
|
120
|
+
let res = vec2f( iRes );
|
|
121
|
+
|
|
122
|
+
let uvScaled = coord * res;
|
|
123
|
+
let uvWrapping = ( ( uvScaled % res ) + res ) % res;
|
|
124
|
+
|
|
125
|
+
// https://www.shadertoy.com/view/WtyXRy
|
|
126
|
+
|
|
127
|
+
let uv = uvWrapping - 0.5;
|
|
128
|
+
let iuv = floor( uv );
|
|
129
|
+
let f = fract( uv );
|
|
130
|
+
|
|
131
|
+
let rg1 = textureLoad( map, vec2u( iuv + vec2( 0.5, 0.5 ) ) % iRes, layer, level );
|
|
132
|
+
let rg2 = textureLoad( map, vec2u( iuv + vec2( 1.5, 0.5 ) ) % iRes, layer, level );
|
|
133
|
+
let rg3 = textureLoad( map, vec2u( iuv + vec2( 0.5, 1.5 ) ) % iRes, layer, level );
|
|
134
|
+
let rg4 = textureLoad( map, vec2u( iuv + vec2( 1.5, 1.5 ) ) % iRes, layer, level );
|
|
135
|
+
|
|
136
|
+
return mix( mix( rg1, rg2, f.x ), mix( rg3, rg4, f.x ), f.y );
|
|
137
|
+
|
|
116
138
|
}
|
|
117
139
|
` )
|
|
118
140
|
};
|
|
@@ -129,7 +151,13 @@ const wgslMethods = {
|
|
|
129
151
|
equals_bvec3: 'tsl_equals_bvec3',
|
|
130
152
|
equals_bvec4: 'tsl_equals_bvec4',
|
|
131
153
|
inversesqrt: 'inverseSqrt',
|
|
132
|
-
bitcast: 'bitcast<f32>'
|
|
154
|
+
bitcast: 'bitcast<f32>',
|
|
155
|
+
floatpack_snorm_2x16: 'pack2x16snorm',
|
|
156
|
+
floatpack_unorm_2x16: 'pack2x16unorm',
|
|
157
|
+
floatpack_float16_2x16: 'pack2x16float',
|
|
158
|
+
floatunpack_snorm_2x16: 'unpack2x16snorm',
|
|
159
|
+
floatunpack_unorm_2x16: 'unpack2x16unorm',
|
|
160
|
+
floatunpack_float16_2x16: 'unpack2x16float'
|
|
133
161
|
};
|
|
134
162
|
|
|
135
163
|
//
|
|
@@ -172,6 +200,14 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
172
200
|
*/
|
|
173
201
|
this.uniformGroups = {};
|
|
174
202
|
|
|
203
|
+
/**
|
|
204
|
+
* A dictionary that holds the assigned binding indices for each uniform group.
|
|
205
|
+
* This ensures the same binding index is used across all shader stages.
|
|
206
|
+
*
|
|
207
|
+
* @type {Object<string,{index: number, id: number}>}
|
|
208
|
+
*/
|
|
209
|
+
this.uniformGroupsBindings = {};
|
|
210
|
+
|
|
175
211
|
/**
|
|
176
212
|
* A dictionary that holds for each shader stage a Map of builtins.
|
|
177
213
|
*
|
|
@@ -258,17 +294,31 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
258
294
|
|
|
259
295
|
if ( this.isUnfilterable( texture ) === false ) {
|
|
260
296
|
|
|
261
|
-
if (
|
|
297
|
+
if ( depthSnippet ) {
|
|
262
298
|
|
|
263
|
-
|
|
299
|
+
if ( offsetSnippet ) {
|
|
264
300
|
|
|
265
|
-
|
|
301
|
+
return `textureSampleLevel( ${ textureProperty }, ${ textureProperty }_sampler, ${ uvSnippet }, ${ depthSnippet }, ${ levelSnippet }, ${ offsetSnippet } )`;
|
|
266
302
|
|
|
267
|
-
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
return `textureSampleLevel( ${ textureProperty }, ${ textureProperty }_sampler, ${ uvSnippet }, ${ depthSnippet }, ${ levelSnippet } )`;
|
|
306
|
+
|
|
307
|
+
} else {
|
|
308
|
+
|
|
309
|
+
if ( offsetSnippet ) {
|
|
310
|
+
|
|
311
|
+
return `textureSampleLevel( ${ textureProperty }, ${ textureProperty }_sampler, ${ uvSnippet }, ${ levelSnippet }, ${ offsetSnippet } )`;
|
|
312
|
+
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
return `textureSampleLevel( ${ textureProperty }, ${ textureProperty }_sampler, ${ uvSnippet }, ${ levelSnippet } )`;
|
|
316
|
+
|
|
317
|
+
}
|
|
268
318
|
|
|
269
319
|
} else if ( this.isFilteredTexture( texture ) ) {
|
|
270
320
|
|
|
271
|
-
return this.generateFilteredTexture( texture, textureProperty, uvSnippet, offsetSnippet, levelSnippet );
|
|
321
|
+
return this.generateFilteredTexture( texture, textureProperty, uvSnippet, offsetSnippet, levelSnippet, depthSnippet );
|
|
272
322
|
|
|
273
323
|
} else {
|
|
274
324
|
|
|
@@ -286,7 +336,7 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
286
336
|
*/
|
|
287
337
|
generateWrapFunction( texture ) {
|
|
288
338
|
|
|
289
|
-
const functionName = `tsl_coord_${ wrapNames[ texture.wrapS ] }S_${ wrapNames[ texture.wrapT ] }_${ texture.isData3DTexture ? '3d' : '2d' }T`;
|
|
339
|
+
const functionName = `tsl_coord_${ wrapNames[ texture.wrapS ] }S_${ wrapNames[ texture.wrapT ] }_${ texture.is3DTexture || texture.isData3DTexture ? '3d' : '2d' }T`;
|
|
290
340
|
|
|
291
341
|
let nodeCode = wgslCodeCache[ functionName ];
|
|
292
342
|
|
|
@@ -295,7 +345,7 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
295
345
|
const includes = [];
|
|
296
346
|
|
|
297
347
|
// For 3D textures, use vec3f; for texture arrays, keep vec2f since array index is separate
|
|
298
|
-
const coordType = texture.isData3DTexture ? 'vec3f' : 'vec2f';
|
|
348
|
+
const coordType = texture.is3DTexture || texture.isData3DTexture ? 'vec3f' : 'vec2f';
|
|
299
349
|
let code = `fn ${ functionName }( coord : ${ coordType } ) -> ${ coordType } {\n\n\treturn ${ coordType }(\n`;
|
|
300
350
|
|
|
301
351
|
const addWrapSnippet = ( wrap, axis ) => {
|
|
@@ -334,7 +384,7 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
334
384
|
|
|
335
385
|
addWrapSnippet( texture.wrapT, 'y' );
|
|
336
386
|
|
|
337
|
-
if ( texture.isData3DTexture ) {
|
|
387
|
+
if ( texture.is3DTexture || texture.isData3DTexture ) {
|
|
338
388
|
|
|
339
389
|
code += ',\n';
|
|
340
390
|
addWrapSnippet( texture.wrapR, 'z' );
|
|
@@ -392,7 +442,7 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
392
442
|
const { primarySamples } = this.renderer.backend.utils.getTextureSampleData( texture );
|
|
393
443
|
const isMultisampled = primarySamples > 1;
|
|
394
444
|
|
|
395
|
-
if ( texture.isData3DTexture ) {
|
|
445
|
+
if ( texture.is3DTexture || texture.isData3DTexture ) {
|
|
396
446
|
|
|
397
447
|
dimensionType = 'vec3<u32>';
|
|
398
448
|
|
|
@@ -418,7 +468,7 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
418
468
|
|
|
419
469
|
textureData.dimensionsSnippet[ levelSnippet ] = textureDimensionNode;
|
|
420
470
|
|
|
421
|
-
if ( texture.isArrayTexture || texture.isDataArrayTexture || texture.isData3DTexture ) {
|
|
471
|
+
if ( texture.isArrayTexture || texture.isDataArrayTexture || texture.is3DTexture || texture.isData3DTexture ) {
|
|
422
472
|
|
|
423
473
|
textureData.arrayLayerCount = new VarNode(
|
|
424
474
|
new ExpressionNode(
|
|
@@ -452,11 +502,10 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
452
502
|
* @param {string} uvSnippet - A WGSL snippet that represents texture coordinates used for sampling.
|
|
453
503
|
* @param {?string} offsetSnippet - A WGSL snippet that represents the offset that will be applied to the unnormalized texture coordinate before sampling the texture.
|
|
454
504
|
* @param {string} [levelSnippet='0u'] - A WGSL snippet that represents the mip level, with level 0 containing a full size version of the texture.
|
|
505
|
+
* @param {?string} depthSnippet - A WGSL snippet that represents 0-based texture array index to sample.
|
|
455
506
|
* @return {string} The WGSL snippet.
|
|
456
507
|
*/
|
|
457
|
-
generateFilteredTexture( texture, textureProperty, uvSnippet, offsetSnippet, levelSnippet = '0u' ) {
|
|
458
|
-
|
|
459
|
-
this._include( 'biquadraticTexture' );
|
|
508
|
+
generateFilteredTexture( texture, textureProperty, uvSnippet, offsetSnippet, levelSnippet = '0u', depthSnippet ) {
|
|
460
509
|
|
|
461
510
|
const wrapFunction = this.generateWrapFunction( texture );
|
|
462
511
|
const textureDimension = this.generateTextureDimension( texture, textureProperty, levelSnippet );
|
|
@@ -467,6 +516,16 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
467
516
|
|
|
468
517
|
}
|
|
469
518
|
|
|
519
|
+
if ( depthSnippet ) {
|
|
520
|
+
|
|
521
|
+
this._include( 'biquadraticTextureArray' );
|
|
522
|
+
|
|
523
|
+
return `tsl_biquadraticTexture_array( ${ textureProperty }, ${ wrapFunction }( ${ uvSnippet } ), ${ textureDimension }, u32( ${ depthSnippet } ), u32( ${ levelSnippet } ) )`;
|
|
524
|
+
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
this._include( 'biquadraticTexture' );
|
|
528
|
+
|
|
470
529
|
return `tsl_biquadraticTexture( ${ textureProperty }, ${ wrapFunction }( ${ uvSnippet } ), ${ textureDimension }, u32( ${ levelSnippet } ) )`;
|
|
471
530
|
|
|
472
531
|
}
|
|
@@ -485,10 +544,27 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
485
544
|
*/
|
|
486
545
|
generateTextureLod( texture, textureProperty, uvSnippet, depthSnippet, offsetSnippet, levelSnippet = '0u' ) {
|
|
487
546
|
|
|
547
|
+
// Cube textures cannot use textureLoad in WGSL, must use textureSampleLevel
|
|
548
|
+
if ( texture.isCubeTexture === true ) {
|
|
549
|
+
|
|
550
|
+
if ( offsetSnippet ) {
|
|
551
|
+
|
|
552
|
+
uvSnippet = `${ uvSnippet } + vec3<f32>(${ offsetSnippet })`;
|
|
553
|
+
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
// Depth textures require integer level, regular textures use float
|
|
557
|
+
const levelType = texture.isDepthTexture ? 'u32' : 'f32';
|
|
558
|
+
|
|
559
|
+
return `textureSampleLevel( ${ textureProperty }, ${ textureProperty }_sampler, ${ uvSnippet }, ${ levelType }( ${ levelSnippet } ) )`;
|
|
560
|
+
|
|
561
|
+
}
|
|
562
|
+
|
|
488
563
|
const wrapFunction = this.generateWrapFunction( texture );
|
|
489
564
|
const textureDimension = this.generateTextureDimension( texture, textureProperty, levelSnippet );
|
|
490
565
|
|
|
491
|
-
const vecType = texture.isData3DTexture ? 'vec3' : 'vec2';
|
|
566
|
+
const vecType = texture.is3DTexture || texture.isData3DTexture ? 'vec3' : 'vec2';
|
|
567
|
+
const textureDimensionMargin = ( vecType === 'vec3' ) ? 'vec3<u32>( 1, 1, 1 )' : 'vec2<u32>( 1, 1 )';
|
|
492
568
|
|
|
493
569
|
if ( offsetSnippet ) {
|
|
494
570
|
|
|
@@ -496,9 +572,47 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
496
572
|
|
|
497
573
|
}
|
|
498
574
|
|
|
499
|
-
const
|
|
575
|
+
const clampMin = `${ vecType }<f32>( 0 )`;
|
|
576
|
+
const clampMax = `${ vecType }<f32>( ${ textureDimension } - ${ textureDimensionMargin } )`;
|
|
577
|
+
|
|
578
|
+
uvSnippet = `${ vecType }<u32>( clamp( floor( ${ wrapFunction }( ${ uvSnippet } ) * ${ vecType }<f32>( ${ textureDimension } ) ), ${ clampMin }, ${ clampMax } ) )`;
|
|
500
579
|
|
|
501
|
-
return this.generateTextureLoad( texture, textureProperty,
|
|
580
|
+
return this.generateTextureLoad( texture, textureProperty, uvSnippet, levelSnippet, depthSnippet, null );
|
|
581
|
+
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
/**
|
|
585
|
+
* Generates the WGSL snippet that reads a single texel from a storage texture.
|
|
586
|
+
*
|
|
587
|
+
* @param {Texture} texture - The texture.
|
|
588
|
+
* @param {string} textureProperty - The name of the texture uniform in the shader.
|
|
589
|
+
* @param {string} uvIndexSnippet - A WGSL snippet that represents texture coordinates used for sampling.
|
|
590
|
+
* @param {?string} levelSnippet - A WGSL snippet that represents the mip level, with level 0 containing a full size version of the texture.
|
|
591
|
+
* @param {?string} depthSnippet - A WGSL snippet that represents 0-based texture array index to sample.
|
|
592
|
+
* @param {?string} offsetSnippet - A WGSL snippet that represents the offset that will be applied to the unnormalized texture coordinate before sampling the texture.
|
|
593
|
+
* @return {string} The WGSL snippet.
|
|
594
|
+
*/
|
|
595
|
+
generateStorageTextureLoad( texture, textureProperty, uvIndexSnippet, levelSnippet, depthSnippet, offsetSnippet ) {
|
|
596
|
+
|
|
597
|
+
if ( offsetSnippet ) {
|
|
598
|
+
|
|
599
|
+
uvIndexSnippet = `${ uvIndexSnippet } + ${ offsetSnippet }`;
|
|
600
|
+
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
let snippet;
|
|
604
|
+
|
|
605
|
+
if ( depthSnippet ) {
|
|
606
|
+
|
|
607
|
+
snippet = `textureLoad( ${ textureProperty }, ${ uvIndexSnippet }, ${ depthSnippet } )`;
|
|
608
|
+
|
|
609
|
+
} else {
|
|
610
|
+
|
|
611
|
+
snippet = `textureLoad( ${ textureProperty }, ${ uvIndexSnippet } )`;
|
|
612
|
+
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
return snippet;
|
|
502
616
|
|
|
503
617
|
}
|
|
504
618
|
|
|
@@ -581,7 +695,7 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
581
695
|
*/
|
|
582
696
|
isSampleCompare( texture ) {
|
|
583
697
|
|
|
584
|
-
return texture.isDepthTexture === true && texture.compareFunction !== null;
|
|
698
|
+
return texture.isDepthTexture === true && texture.compareFunction !== null && this.renderer.hasCompatibility( Compatibility.TEXTURE_COMPARE );
|
|
585
699
|
|
|
586
700
|
}
|
|
587
701
|
|
|
@@ -645,14 +759,27 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
645
759
|
|
|
646
760
|
if ( shaderStage === 'fragment' ) {
|
|
647
761
|
|
|
648
|
-
|
|
649
|
-
|
|
762
|
+
if ( depthSnippet ) {
|
|
763
|
+
|
|
764
|
+
if ( offsetSnippet ) {
|
|
650
765
|
|
|
651
|
-
|
|
766
|
+
return `textureSampleGrad( ${ textureProperty }, ${ textureProperty }_sampler, ${ uvSnippet }, ${ depthSnippet }, ${ gradSnippet[ 0 ] }, ${ gradSnippet[ 1 ] }, ${ offsetSnippet } )`;
|
|
652
767
|
|
|
653
|
-
|
|
768
|
+
}
|
|
654
769
|
|
|
655
|
-
|
|
770
|
+
return `textureSampleGrad( ${ textureProperty }, ${ textureProperty }_sampler, ${ uvSnippet }, ${ depthSnippet }, ${ gradSnippet[ 0 ] }, ${ gradSnippet[ 1 ] } )`;
|
|
771
|
+
|
|
772
|
+
} else {
|
|
773
|
+
|
|
774
|
+
if ( offsetSnippet ) {
|
|
775
|
+
|
|
776
|
+
return `textureSampleGrad( ${ textureProperty }, ${ textureProperty }_sampler, ${ uvSnippet }, ${ gradSnippet[ 0 ] }, ${ gradSnippet[ 1 ] }, ${ offsetSnippet } )`;
|
|
777
|
+
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
return `textureSampleGrad( ${ textureProperty }, ${ textureProperty }_sampler, ${ uvSnippet }, ${ gradSnippet[ 0 ] }, ${ gradSnippet[ 1 ] } )`;
|
|
781
|
+
|
|
782
|
+
}
|
|
656
783
|
|
|
657
784
|
} else {
|
|
658
785
|
|
|
@@ -723,17 +850,31 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
723
850
|
|
|
724
851
|
if ( this.isUnfilterable( texture ) === false ) {
|
|
725
852
|
|
|
726
|
-
if (
|
|
853
|
+
if ( depthSnippet ) {
|
|
854
|
+
|
|
855
|
+
if ( offsetSnippet ) {
|
|
727
856
|
|
|
728
|
-
|
|
857
|
+
return `textureSampleLevel( ${ textureProperty }, ${ textureProperty }_sampler, ${ uvSnippet }, ${ depthSnippet }, ${ levelSnippet }, ${ offsetSnippet } )`;
|
|
729
858
|
|
|
730
|
-
|
|
859
|
+
}
|
|
731
860
|
|
|
732
|
-
|
|
861
|
+
return `textureSampleLevel( ${ textureProperty }, ${ textureProperty }_sampler, ${ uvSnippet }, ${ depthSnippet }, ${ levelSnippet } )`;
|
|
862
|
+
|
|
863
|
+
} else {
|
|
864
|
+
|
|
865
|
+
if ( offsetSnippet ) {
|
|
866
|
+
|
|
867
|
+
return `textureSampleLevel( ${ textureProperty }, ${ textureProperty }_sampler, ${ uvSnippet }, ${ levelSnippet }, ${ offsetSnippet } )`;
|
|
868
|
+
|
|
869
|
+
}
|
|
870
|
+
|
|
871
|
+
return `textureSampleLevel( ${ textureProperty }, ${ textureProperty }_sampler, ${ uvSnippet }, ${ levelSnippet } )`;
|
|
872
|
+
|
|
873
|
+
}
|
|
733
874
|
|
|
734
875
|
} else if ( this.isFilteredTexture( texture ) ) {
|
|
735
876
|
|
|
736
|
-
return this.generateFilteredTexture( texture, textureProperty, uvSnippet, offsetSnippet, levelSnippet );
|
|
877
|
+
return this.generateFilteredTexture( texture, textureProperty, uvSnippet, offsetSnippet, levelSnippet, depthSnippet );
|
|
737
878
|
|
|
738
879
|
} else {
|
|
739
880
|
|
|
@@ -759,13 +900,27 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
759
900
|
|
|
760
901
|
if ( shaderStage === 'fragment' ) {
|
|
761
902
|
|
|
762
|
-
if (
|
|
903
|
+
if ( depthSnippet ) {
|
|
763
904
|
|
|
764
|
-
|
|
905
|
+
if ( offsetSnippet ) {
|
|
765
906
|
|
|
766
|
-
|
|
907
|
+
return `textureSampleBias( ${ textureProperty }, ${ textureProperty }_sampler, ${ uvSnippet }, ${ depthSnippet }, ${ biasSnippet }, ${ offsetSnippet } )`;
|
|
908
|
+
|
|
909
|
+
}
|
|
910
|
+
|
|
911
|
+
return `textureSampleBias( ${ textureProperty }, ${ textureProperty }_sampler, ${ uvSnippet }, ${ depthSnippet }, ${ biasSnippet } )`;
|
|
912
|
+
|
|
913
|
+
} else {
|
|
914
|
+
|
|
915
|
+
if ( offsetSnippet ) {
|
|
916
|
+
|
|
917
|
+
return `textureSampleBias( ${ textureProperty }, ${ textureProperty }_sampler, ${ uvSnippet }, ${ biasSnippet }, ${ offsetSnippet } )`;
|
|
918
|
+
|
|
919
|
+
}
|
|
767
920
|
|
|
768
|
-
|
|
921
|
+
return `textureSampleBias( ${ textureProperty }, ${ textureProperty }_sampler, ${ uvSnippet }, ${ biasSnippet } )`;
|
|
922
|
+
|
|
923
|
+
}
|
|
769
924
|
|
|
770
925
|
} else {
|
|
771
926
|
|
|
@@ -797,7 +952,7 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
797
952
|
const name = node.name;
|
|
798
953
|
const type = node.type;
|
|
799
954
|
|
|
800
|
-
if ( type === 'texture' || type === 'cubeTexture' || type === 'storageTexture' || type === 'texture3D' ) {
|
|
955
|
+
if ( type === 'texture' || type === 'cubeTexture' || type === 'cubeDepthTexture' || type === 'storageTexture' || type === 'texture3D' ) {
|
|
801
956
|
|
|
802
957
|
return name;
|
|
803
958
|
|
|
@@ -923,7 +1078,7 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
923
1078
|
|
|
924
1079
|
const bindings = this.getBindGroupArray( groupName, shaderStage );
|
|
925
1080
|
|
|
926
|
-
if ( type === 'texture' || type === 'cubeTexture' || type === 'storageTexture' || type === 'texture3D' ) {
|
|
1081
|
+
if ( type === 'texture' || type === 'cubeTexture' || type === 'cubeDepthTexture' || type === 'storageTexture' || type === 'texture3D' ) {
|
|
927
1082
|
|
|
928
1083
|
let texture = null;
|
|
929
1084
|
|
|
@@ -941,7 +1096,7 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
941
1096
|
|
|
942
1097
|
}
|
|
943
1098
|
|
|
944
|
-
} else if ( type === 'cubeTexture' ) {
|
|
1099
|
+
} else if ( type === 'cubeTexture' || type === 'cubeDepthTexture' ) {
|
|
945
1100
|
|
|
946
1101
|
texture = new NodeSampledCubeTexture( uniformNode.name, uniformNode.node, group, access );
|
|
947
1102
|
|
|
@@ -955,7 +1110,10 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
955
1110
|
texture.mipLevel = texture.store ? node.mipLevel : 0;
|
|
956
1111
|
texture.setVisibility( gpuShaderStageLib[ shaderStage ] );
|
|
957
1112
|
|
|
958
|
-
|
|
1113
|
+
// Cube textures always need samplers (they use textureSampleLevel, not textureLoad)
|
|
1114
|
+
const needsSampler = node.value.isCubeTexture === true || ( this.isUnfilterable( node.value ) === false && texture.store === false );
|
|
1115
|
+
|
|
1116
|
+
if ( needsSampler ) {
|
|
959
1117
|
|
|
960
1118
|
const sampler = new NodeSampler( `${ uniformNode.name }_sampler`, uniformNode.node, group );
|
|
961
1119
|
sampler.setVisibility( gpuShaderStageLib[ shaderStage ] );
|
|
@@ -974,10 +1132,21 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
974
1132
|
|
|
975
1133
|
} else if ( type === 'buffer' || type === 'storageBuffer' || type === 'indirectStorageBuffer' ) {
|
|
976
1134
|
|
|
977
|
-
const
|
|
1135
|
+
const sharedData = this.getSharedDataFromNode( node );
|
|
1136
|
+
|
|
1137
|
+
let buffer = sharedData.buffer;
|
|
1138
|
+
|
|
1139
|
+
if ( buffer === undefined ) {
|
|
1140
|
+
|
|
1141
|
+
const bufferClass = type === 'buffer' ? NodeUniformBuffer : NodeStorageBuffer;
|
|
978
1142
|
|
|
979
|
-
|
|
980
|
-
|
|
1143
|
+
buffer = new bufferClass( node, group );
|
|
1144
|
+
|
|
1145
|
+
sharedData.buffer = buffer;
|
|
1146
|
+
|
|
1147
|
+
}
|
|
1148
|
+
|
|
1149
|
+
buffer.setVisibility( buffer.getVisibility() | gpuShaderStageLib[ shaderStage ] );
|
|
981
1150
|
|
|
982
1151
|
bindings.push( buffer );
|
|
983
1152
|
|
|
@@ -987,16 +1156,19 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
987
1156
|
|
|
988
1157
|
} else {
|
|
989
1158
|
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
let uniformsGroup = uniformsStage[ groupName ];
|
|
1159
|
+
let uniformsGroup = this.uniformGroups[ groupName ];
|
|
993
1160
|
|
|
994
1161
|
if ( uniformsGroup === undefined ) {
|
|
995
1162
|
|
|
996
1163
|
uniformsGroup = new NodeUniformsGroup( groupName, group );
|
|
997
|
-
uniformsGroup.setVisibility(
|
|
1164
|
+
uniformsGroup.setVisibility( GPUShaderStage.VERTEX | GPUShaderStage.FRAGMENT | GPUShaderStage.COMPUTE );
|
|
998
1165
|
|
|
999
|
-
|
|
1166
|
+
this.uniformGroups[ groupName ] = uniformsGroup;
|
|
1167
|
+
|
|
1168
|
+
}
|
|
1169
|
+
|
|
1170
|
+
// Add to bindings for this stage if not already present
|
|
1171
|
+
if ( bindings.indexOf( uniformsGroup ) === - 1 ) {
|
|
1000
1172
|
|
|
1001
1173
|
bindings.push( uniformsGroup );
|
|
1002
1174
|
|
|
@@ -1004,7 +1176,15 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
1004
1176
|
|
|
1005
1177
|
uniformGPU = this.getNodeUniform( uniformNode, type );
|
|
1006
1178
|
|
|
1007
|
-
|
|
1179
|
+
// Only add uniform if not already present in the group (check by name to avoid duplicates across stages)
|
|
1180
|
+
const uniformName = uniformGPU.name;
|
|
1181
|
+
const alreadyExists = uniformsGroup.uniforms.some( u => u.name === uniformName );
|
|
1182
|
+
|
|
1183
|
+
if ( ! alreadyExists ) {
|
|
1184
|
+
|
|
1185
|
+
uniformsGroup.addUniform( uniformGPU );
|
|
1186
|
+
|
|
1187
|
+
}
|
|
1008
1188
|
|
|
1009
1189
|
}
|
|
1010
1190
|
|
|
@@ -1610,7 +1790,7 @@ ${ flowData.code }
|
|
|
1610
1790
|
|
|
1611
1791
|
if ( shaderStage === 'vertex' ) {
|
|
1612
1792
|
|
|
1613
|
-
this.getBuiltin( 'position', '
|
|
1793
|
+
this.getBuiltin( 'position', 'builtinClipSpace', 'vec4<f32>', 'vertex' );
|
|
1614
1794
|
|
|
1615
1795
|
}
|
|
1616
1796
|
|
|
@@ -1637,7 +1817,7 @@ ${ flowData.code }
|
|
|
1637
1817
|
|
|
1638
1818
|
} else if ( /^(int|uint|ivec|uvec)/.test( varying.type ) ) {
|
|
1639
1819
|
|
|
1640
|
-
attributesSnippet +=
|
|
1820
|
+
attributesSnippet += ' @interpolate(flat, either)';
|
|
1641
1821
|
|
|
1642
1822
|
}
|
|
1643
1823
|
|
|
@@ -1698,11 +1878,14 @@ ${ flowData.code }
|
|
|
1698
1878
|
const groupName = uniform.groupNode.name;
|
|
1699
1879
|
const uniformIndexes = this.bindingsIndexes[ groupName ];
|
|
1700
1880
|
|
|
1701
|
-
if ( uniform.type === 'texture' || uniform.type === 'cubeTexture' || uniform.type === 'storageTexture' || uniform.type === 'texture3D' ) {
|
|
1881
|
+
if ( uniform.type === 'texture' || uniform.type === 'cubeTexture' || uniform.type === 'cubeDepthTexture' || uniform.type === 'storageTexture' || uniform.type === 'texture3D' ) {
|
|
1702
1882
|
|
|
1703
1883
|
const texture = uniform.node.value;
|
|
1704
1884
|
|
|
1705
|
-
|
|
1885
|
+
// Cube textures always need samplers (they use textureSampleLevel, not textureLoad)
|
|
1886
|
+
const needsSampler = texture.isCubeTexture === true || ( this.isUnfilterable( texture ) === false && uniform.node.isStorageTextureNode !== true );
|
|
1887
|
+
|
|
1888
|
+
if ( needsSampler ) {
|
|
1706
1889
|
|
|
1707
1890
|
if ( this.isSampleCompare( texture ) ) {
|
|
1708
1891
|
|
|
@@ -1728,7 +1911,11 @@ ${ flowData.code }
|
|
|
1728
1911
|
|
|
1729
1912
|
}
|
|
1730
1913
|
|
|
1731
|
-
if ( texture.isCubeTexture === true ) {
|
|
1914
|
+
if ( texture.isCubeTexture === true && texture.isDepthTexture === true ) {
|
|
1915
|
+
|
|
1916
|
+
textureType = 'texture_depth_cube';
|
|
1917
|
+
|
|
1918
|
+
} else if ( texture.isCubeTexture === true ) {
|
|
1732
1919
|
|
|
1733
1920
|
textureType = 'texture_cube<f32>';
|
|
1734
1921
|
|
|
@@ -1797,16 +1984,51 @@ ${ flowData.code }
|
|
|
1797
1984
|
|
|
1798
1985
|
} else {
|
|
1799
1986
|
|
|
1800
|
-
const vectorType = this.getType( this.getVectorType( uniform.type ) );
|
|
1801
1987
|
const groupName = uniform.groupNode.name;
|
|
1802
1988
|
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1989
|
+
// Check if this group has already been processed in this shader stage
|
|
1990
|
+
if ( uniformGroups[ groupName ] === undefined ) {
|
|
1991
|
+
|
|
1992
|
+
// Get the shared uniform group that contains uniforms from all stages
|
|
1993
|
+
const sharedUniformGroup = this.uniformGroups[ groupName ];
|
|
1994
|
+
|
|
1995
|
+
if ( sharedUniformGroup !== undefined ) {
|
|
1996
|
+
|
|
1997
|
+
// Generate snippets for ALL uniforms in this shared group
|
|
1998
|
+
const snippets = [];
|
|
1999
|
+
|
|
2000
|
+
for ( const sharedUniform of sharedUniformGroup.uniforms ) {
|
|
2001
|
+
|
|
2002
|
+
const type = sharedUniform.getType();
|
|
2003
|
+
const vectorType = this.getType( this.getVectorType( type ) );
|
|
2004
|
+
snippets.push( `\t${ sharedUniform.name } : ${ vectorType }` );
|
|
2005
|
+
|
|
2006
|
+
}
|
|
2007
|
+
|
|
2008
|
+
// Check if this group already has an assigned binding index (from another shader stage)
|
|
2009
|
+
let groupBinding = this.uniformGroupsBindings[ groupName ];
|
|
2010
|
+
|
|
2011
|
+
if ( groupBinding === undefined ) {
|
|
2012
|
+
|
|
2013
|
+
// First time processing this group - assign a new binding index
|
|
2014
|
+
groupBinding = {
|
|
2015
|
+
index: uniformIndexes.binding ++,
|
|
2016
|
+
id: uniformIndexes.group
|
|
2017
|
+
};
|
|
2018
|
+
|
|
2019
|
+
this.uniformGroupsBindings[ groupName ] = groupBinding;
|
|
2020
|
+
|
|
2021
|
+
}
|
|
2022
|
+
|
|
2023
|
+
uniformGroups[ groupName ] = {
|
|
2024
|
+
index: groupBinding.index,
|
|
2025
|
+
id: groupBinding.id,
|
|
2026
|
+
snippets: snippets
|
|
2027
|
+
};
|
|
2028
|
+
|
|
2029
|
+
}
|
|
1808
2030
|
|
|
1809
|
-
|
|
2031
|
+
}
|
|
1810
2032
|
|
|
1811
2033
|
}
|
|
1812
2034
|
|
|
@@ -1820,9 +2042,7 @@ ${ flowData.code }
|
|
|
1820
2042
|
|
|
1821
2043
|
}
|
|
1822
2044
|
|
|
1823
|
-
|
|
1824
|
-
code += bufferSnippets.join( '\n' );
|
|
1825
|
-
code += structSnippets.join( '\n' );
|
|
2045
|
+
const code = [ ...bindingSnippets, ...bufferSnippets, ...structSnippets ].join( '\n' );
|
|
1826
2046
|
|
|
1827
2047
|
return code;
|
|
1828
2048
|
|
|
@@ -1883,7 +2103,7 @@ ${ flowData.code }
|
|
|
1883
2103
|
|
|
1884
2104
|
if ( shaderStage === 'vertex' ) {
|
|
1885
2105
|
|
|
1886
|
-
flow += `varyings.
|
|
2106
|
+
flow += `varyings.builtinClipSpace = ${ flowSlotData.result };`;
|
|
1887
2107
|
|
|
1888
2108
|
} else if ( shaderStage === 'fragment' ) {
|
|
1889
2109
|
|
|
@@ -1980,6 +2200,30 @@ ${ flowData.code }
|
|
|
1980
2200
|
|
|
1981
2201
|
}
|
|
1982
2202
|
|
|
2203
|
+
/**
|
|
2204
|
+
* Returns the float packing method name for a given numeric encoding.
|
|
2205
|
+
*
|
|
2206
|
+
* @param {string} encoding - The numeric encoding that describes how the float values are mapped to the integer range.
|
|
2207
|
+
* @returns {string} The resolve WGSL float packing method name.
|
|
2208
|
+
*/
|
|
2209
|
+
getFloatPackingMethod( encoding ) {
|
|
2210
|
+
|
|
2211
|
+
return this.getMethod( `floatpack_${ encoding }_2x16` );
|
|
2212
|
+
|
|
2213
|
+
}
|
|
2214
|
+
|
|
2215
|
+
/**
|
|
2216
|
+
* Returns the float unpacking method name for a given numeric encoding.
|
|
2217
|
+
*
|
|
2218
|
+
* @param {string} encoding - The numeric encoding that describes how the integer values are mapped to the float range.
|
|
2219
|
+
* @returns {string} The resolve WGSL float unpacking method name.
|
|
2220
|
+
*/
|
|
2221
|
+
getFloatUnpackingMethod( encoding ) {
|
|
2222
|
+
|
|
2223
|
+
return this.getMethod( `floatunpack_${ encoding }_2x16` );
|
|
2224
|
+
|
|
2225
|
+
}
|
|
2226
|
+
|
|
1983
2227
|
/**
|
|
1984
2228
|
* Returns the native snippet for a ternary operation.
|
|
1985
2229
|
*
|
|
@@ -1994,7 +2238,6 @@ ${ flowData.code }
|
|
|
1994
2238
|
|
|
1995
2239
|
}
|
|
1996
2240
|
|
|
1997
|
-
|
|
1998
2241
|
/**
|
|
1999
2242
|
* Returns the WGSL type of the given node data type.
|
|
2000
2243
|
*
|
|
@@ -2037,6 +2280,17 @@ ${ flowData.code }
|
|
|
2037
2280
|
|
|
2038
2281
|
}
|
|
2039
2282
|
|
|
2283
|
+
/**
|
|
2284
|
+
* Returns the maximum uniform buffer size limit.
|
|
2285
|
+
*
|
|
2286
|
+
* @return {number} The maximum uniform buffer size in bytes.
|
|
2287
|
+
*/
|
|
2288
|
+
getUniformBufferLimit() {
|
|
2289
|
+
|
|
2290
|
+
return this.renderer.backend.device.limits.maxUniformBufferBindingSize;
|
|
2291
|
+
|
|
2292
|
+
}
|
|
2293
|
+
|
|
2040
2294
|
/**
|
|
2041
2295
|
* Returns the native shader method name for a given generic name.
|
|
2042
2296
|
*
|