@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
|
@@ -174,7 +174,7 @@ class ConditionalNode extends Node {
|
|
|
174
174
|
|
|
175
175
|
if ( functionNode === null ) {
|
|
176
176
|
|
|
177
|
-
warn( 'TSL: Return statement used in an inline \'Fn()\'. Define a layout struct to allow return values.' );
|
|
177
|
+
warn( 'TSL: Return statement used in an inline \'Fn()\'. Define a layout struct to allow return values.', this.stackTrace );
|
|
178
178
|
|
|
179
179
|
ifSnippet = '// ' + ifSnippet;
|
|
180
180
|
|
|
@@ -204,7 +204,7 @@ class ConditionalNode extends Node {
|
|
|
204
204
|
|
|
205
205
|
if ( functionNode === null ) {
|
|
206
206
|
|
|
207
|
-
warn( 'TSL: Return statement used in an inline \'Fn()\'. Define a layout struct to allow return values.' );
|
|
207
|
+
warn( 'TSL: Return statement used in an inline \'Fn()\'. Define a layout struct to allow return values.', this.stackTrace );
|
|
208
208
|
|
|
209
209
|
elseSnippet = '// ' + elseSnippet;
|
|
210
210
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import TempNode from '../core/TempNode.js';
|
|
2
|
-
import { sub, mul, div, mod
|
|
2
|
+
import { sub, mul, div, mod } from './OperatorNode.js';
|
|
3
3
|
import { addMethodChaining, nodeObject, nodeProxyIntent, float, vec2, vec3, vec4, Fn } from '../tsl/TSLCore.js';
|
|
4
4
|
import { WebGLCoordinateSystem, WebGPUCoordinateSystem } from '../../constants.js';
|
|
5
5
|
import { warn } from '../../utils.js';
|
|
@@ -291,7 +291,7 @@ class MathNode extends TempNode {
|
|
|
291
291
|
|
|
292
292
|
if ( builder.shaderStage !== 'fragment' && ( method === MathNode.DFDX || method === MathNode.DFDY ) ) {
|
|
293
293
|
|
|
294
|
-
warn( `TSL: '${ method }' is not supported in the ${ builder.shaderStage } stage
|
|
294
|
+
warn( `TSL: '${ method }' is not supported in the ${ builder.shaderStage } stage.`, this.stackTrace );
|
|
295
295
|
|
|
296
296
|
method = '/*' + method + '*/';
|
|
297
297
|
|
|
@@ -784,23 +784,6 @@ export const inverse = /*@__PURE__*/ nodeProxyIntent( MathNode, MathNode.INVERSE
|
|
|
784
784
|
|
|
785
785
|
// 2 inputs
|
|
786
786
|
|
|
787
|
-
/**
|
|
788
|
-
* Returns `true` if `x` equals `y`.
|
|
789
|
-
*
|
|
790
|
-
* @tsl
|
|
791
|
-
* @function
|
|
792
|
-
* @param {Node | number} x - The first parameter.
|
|
793
|
-
* @param {Node | number} y - The second parameter.
|
|
794
|
-
* @deprecated since r175. Use {@link equal} instead.
|
|
795
|
-
* @returns {Node<bool>}
|
|
796
|
-
*/
|
|
797
|
-
export const equals = ( x, y ) => { // @deprecated, r172
|
|
798
|
-
|
|
799
|
-
warn( 'TSL: "equals" is deprecated. Use "equal" inside a vector instead, like: "bvec*( equal( ... ) )"' );
|
|
800
|
-
return equal( x, y );
|
|
801
|
-
|
|
802
|
-
};
|
|
803
|
-
|
|
804
787
|
/**
|
|
805
788
|
* Returns the least of the given values.
|
|
806
789
|
*
|
|
@@ -981,7 +964,7 @@ export const mix = /*@__PURE__*/ nodeProxyIntent( MathNode, MathNode.MIX ).setPa
|
|
|
981
964
|
* @param {Node | number} [high=1] - The upper bound.
|
|
982
965
|
* @returns {Node}
|
|
983
966
|
*/
|
|
984
|
-
export const clamp = ( value, low = 0, high = 1 ) =>
|
|
967
|
+
export const clamp = ( value, low = 0, high = 1 ) => new MathNode( MathNode.CLAMP, nodeObject( value ), nodeObject( low ), nodeObject( high ) );
|
|
985
968
|
|
|
986
969
|
/**
|
|
987
970
|
* Constrains a value between `0` and `1`.
|
|
@@ -1081,24 +1064,6 @@ export const smoothstepElement = ( x, low, high ) => smoothstep( low, high, x );
|
|
|
1081
1064
|
*/
|
|
1082
1065
|
export const stepElement = ( x, edge ) => step( edge, x );
|
|
1083
1066
|
|
|
1084
|
-
/**
|
|
1085
|
-
* Returns the arc-tangent of the quotient of its parameters.
|
|
1086
|
-
*
|
|
1087
|
-
* @tsl
|
|
1088
|
-
* @function
|
|
1089
|
-
* @deprecated since r172. Use {@link atan} instead.
|
|
1090
|
-
*
|
|
1091
|
-
* @param {Node | number} y - The y parameter.
|
|
1092
|
-
* @param {Node | number} x - The x parameter.
|
|
1093
|
-
* @returns {Node}
|
|
1094
|
-
*/
|
|
1095
|
-
export const atan2 = ( y, x ) => { // @deprecated, r172
|
|
1096
|
-
|
|
1097
|
-
warn( 'TSL: "atan2" is overloaded. Use "atan" instead.' );
|
|
1098
|
-
return atan( y, x );
|
|
1099
|
-
|
|
1100
|
-
};
|
|
1101
|
-
|
|
1102
1067
|
// GLSL alias function
|
|
1103
1068
|
|
|
1104
1069
|
export const faceforward = faceForward;
|
|
@@ -1108,7 +1073,6 @@ export const inversesqrt = inverseSqrt;
|
|
|
1108
1073
|
|
|
1109
1074
|
addMethodChaining( 'all', all );
|
|
1110
1075
|
addMethodChaining( 'any', any );
|
|
1111
|
-
addMethodChaining( 'equals', equals );
|
|
1112
1076
|
|
|
1113
1077
|
addMethodChaining( 'radians', radians );
|
|
1114
1078
|
addMethodChaining( 'degrees', degrees );
|
|
@@ -1140,7 +1104,6 @@ addMethodChaining( 'round', round );
|
|
|
1140
1104
|
addMethodChaining( 'reciprocal', reciprocal );
|
|
1141
1105
|
addMethodChaining( 'trunc', trunc );
|
|
1142
1106
|
addMethodChaining( 'fwidth', fwidth );
|
|
1143
|
-
addMethodChaining( 'atan2', atan2 );
|
|
1144
1107
|
addMethodChaining( 'min', min );
|
|
1145
1108
|
addMethodChaining( 'max', max );
|
|
1146
1109
|
addMethodChaining( 'step', stepElement );
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { WebGLCoordinateSystem } from '../../constants.js';
|
|
2
2
|
import TempNode from '../core/TempNode.js';
|
|
3
|
+
import StackTrace from '../core/StackTrace.js';
|
|
3
4
|
import { addMethodChaining, Fn, int, nodeProxyIntent } from '../tsl/TSLCore.js';
|
|
4
5
|
import { warn } from '../../utils.js';
|
|
5
6
|
|
|
@@ -743,7 +744,7 @@ addMethodChaining( 'decrement', decrement );
|
|
|
743
744
|
*/
|
|
744
745
|
export const modInt = ( a, b ) => { // @deprecated, r175
|
|
745
746
|
|
|
746
|
-
warn( 'TSL: "modInt()" is deprecated. Use "mod( int( ... ) )" instead.' );
|
|
747
|
+
warn( 'TSL: "modInt()" is deprecated. Use "mod( int( ... ) )" instead.', new StackTrace() );
|
|
747
748
|
return mod( int( a ), int( b ) );
|
|
748
749
|
|
|
749
750
|
};
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import TempNode from '../core/TempNode.js';
|
|
2
|
+
import { nodeProxyIntent } from '../tsl/TSLCore.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* This node represents an operation that packs floating-point values of a vector into an unsigned 32-bit integer
|
|
6
|
+
*
|
|
7
|
+
* @augments TempNode
|
|
8
|
+
*/
|
|
9
|
+
class PackFloatNode extends TempNode {
|
|
10
|
+
|
|
11
|
+
static get type() {
|
|
12
|
+
|
|
13
|
+
return 'PackFloatNode';
|
|
14
|
+
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
*
|
|
19
|
+
* @param {'snorm' | 'unorm' | 'float16'} encoding - The numeric encoding that describes how the float values are mapped to the integer range.
|
|
20
|
+
* @param {Node} vectorNode - The vector node to be packed
|
|
21
|
+
*/
|
|
22
|
+
constructor( encoding, vectorNode ) {
|
|
23
|
+
|
|
24
|
+
super();
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The vector to be packed.
|
|
28
|
+
*
|
|
29
|
+
* @type {Node}
|
|
30
|
+
*/
|
|
31
|
+
this.vectorNode = vectorNode;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* The numeric encoding.
|
|
35
|
+
*
|
|
36
|
+
* @type {string}
|
|
37
|
+
*/
|
|
38
|
+
this.encoding = encoding;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* This flag can be used for type testing.
|
|
42
|
+
*
|
|
43
|
+
* @type {boolean}
|
|
44
|
+
* @readonly
|
|
45
|
+
* @default true
|
|
46
|
+
*/
|
|
47
|
+
this.isPackFloatNode = true;
|
|
48
|
+
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
getNodeType() {
|
|
52
|
+
|
|
53
|
+
return 'uint';
|
|
54
|
+
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
generate( builder ) {
|
|
58
|
+
|
|
59
|
+
const inputType = this.vectorNode.getNodeType( builder );
|
|
60
|
+
return `${ builder.getFloatPackingMethod( this.encoding ) }(${ this.vectorNode.build( builder, inputType )})`;
|
|
61
|
+
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export default PackFloatNode;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Converts each component of the normalized float to 16-bit integer values. The results are packed into a single unsigned integer.
|
|
70
|
+
* round(clamp(c, -1, +1) * 32767.0)
|
|
71
|
+
*
|
|
72
|
+
* @tsl
|
|
73
|
+
* @function
|
|
74
|
+
* @param {Node<vec2>} value - The 2-component vector to be packed
|
|
75
|
+
* @returns {Node}
|
|
76
|
+
*/
|
|
77
|
+
export const packSnorm2x16 = /*@__PURE__*/ nodeProxyIntent( PackFloatNode, 'snorm' ).setParameterLength( 1 );
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Converts each component of the normalized float to 16-bit integer values. The results are packed into a single unsigned integer.
|
|
81
|
+
* round(clamp(c, 0, +1) * 65535.0)
|
|
82
|
+
*
|
|
83
|
+
* @tsl
|
|
84
|
+
* @function
|
|
85
|
+
* @param {Node<vec2>} value - The 2-component vector to be packed
|
|
86
|
+
* @returns {Node}
|
|
87
|
+
*/
|
|
88
|
+
export const packUnorm2x16 = /*@__PURE__*/ nodeProxyIntent( PackFloatNode, 'unorm' ).setParameterLength( 1 );
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Converts each component of the vec2 to 16-bit floating-point values. The results are packed into a single unsigned integer.
|
|
92
|
+
*
|
|
93
|
+
* @tsl
|
|
94
|
+
* @function
|
|
95
|
+
* @param {Node<vec2>} value - The 2-component vector to be packed
|
|
96
|
+
* @returns {Node}
|
|
97
|
+
*/
|
|
98
|
+
export const packHalf2x16 = /*@__PURE__*/ nodeProxyIntent( PackFloatNode, 'float16' ).setParameterLength( 1 );
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import TempNode from '../core/TempNode.js';
|
|
2
|
+
import { nodeProxyIntent } from '../tsl/TSLCore.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* This node represents an operation that unpacks values from a 32-bit unsigned integer, reinterpreting the results as a floating-point vector
|
|
6
|
+
*
|
|
7
|
+
* @augments TempNode
|
|
8
|
+
*/
|
|
9
|
+
class UnpackFloatNode extends TempNode {
|
|
10
|
+
|
|
11
|
+
static get type() {
|
|
12
|
+
|
|
13
|
+
return 'UnpackFloatNode';
|
|
14
|
+
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
*
|
|
19
|
+
* @param {'snorm' | 'unorm' | 'float16'} encoding - The numeric encoding that describes how the integer values are mapped to the float range
|
|
20
|
+
* @param {Node} uintNode - The uint node to be unpacked
|
|
21
|
+
*/
|
|
22
|
+
constructor( encoding, uintNode ) {
|
|
23
|
+
|
|
24
|
+
super();
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The unsigned integer to be unpacked.
|
|
28
|
+
*
|
|
29
|
+
* @type {Node}
|
|
30
|
+
*/
|
|
31
|
+
this.uintNode = uintNode;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* The numeric encoding.
|
|
35
|
+
*
|
|
36
|
+
* @type {string}
|
|
37
|
+
*/
|
|
38
|
+
this.encoding = encoding;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* This flag can be used for type testing.
|
|
42
|
+
*
|
|
43
|
+
* @type {boolean}
|
|
44
|
+
* @readonly
|
|
45
|
+
* @default true
|
|
46
|
+
*/
|
|
47
|
+
this.isUnpackFloatNode = true;
|
|
48
|
+
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
getNodeType() {
|
|
52
|
+
|
|
53
|
+
return 'vec2';
|
|
54
|
+
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
generate( builder ) {
|
|
58
|
+
|
|
59
|
+
const inputType = this.uintNode.getNodeType( builder );
|
|
60
|
+
return `${ builder.getFloatUnpackingMethod( this.encoding ) }(${ this.uintNode.build( builder, inputType )})`;
|
|
61
|
+
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export default UnpackFloatNode;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Unpacks a 32-bit unsigned integer into two 16-bit values, interpreted as normalized signed integers. Returns a vec2 with both values.
|
|
70
|
+
*
|
|
71
|
+
* @tsl
|
|
72
|
+
* @function
|
|
73
|
+
* @param {Node<uint>} value - The unsigned integer to be unpacked
|
|
74
|
+
* @returns {Node}
|
|
75
|
+
*/
|
|
76
|
+
export const unpackSnorm2x16 = /*@__PURE__*/ nodeProxyIntent( UnpackFloatNode, 'snorm' ).setParameterLength( 1 );
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Unpacks a 32-bit unsigned integer into two 16-bit values, interpreted as normalized unsigned integers. Returns a vec2 with both values.
|
|
80
|
+
*
|
|
81
|
+
* @tsl
|
|
82
|
+
* @function
|
|
83
|
+
* @param {Node<uint>} value - The unsigned integer to be unpacked
|
|
84
|
+
* @returns {Node}
|
|
85
|
+
*/
|
|
86
|
+
export const unpackUnorm2x16 = /*@__PURE__*/ nodeProxyIntent( UnpackFloatNode, 'unorm' ).setParameterLength( 1 );
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Unpacks a 32-bit unsigned integer into two 16-bit values, interpreted as 16-bit floating-point numbers. Returns a vec2 with both values.
|
|
90
|
+
*
|
|
91
|
+
* @tsl
|
|
92
|
+
* @function
|
|
93
|
+
* @param {Node<uint>} value - The unsigned integer to be unpacked
|
|
94
|
+
* @returns {Node}
|
|
95
|
+
*/
|
|
96
|
+
export const unpackHalf2x16 = /*@__PURE__*/ nodeProxyIntent( UnpackFloatNode, 'float16' ).setParameterLength( 1 );
|
|
@@ -312,30 +312,24 @@ const hammersley = /*@__PURE__*/ Fn( ( [ i, N ] ) => {
|
|
|
312
312
|
// GGX VNDF importance sampling (Eric Heitz 2018)
|
|
313
313
|
// "Sampling the GGX Distribution of Visible Normals"
|
|
314
314
|
// https://jcgt.org/published/0007/04/01/
|
|
315
|
-
const importanceSampleGGX_VNDF = /*@__PURE__*/ Fn( ( [ Xi,
|
|
315
|
+
const importanceSampleGGX_VNDF = /*@__PURE__*/ Fn( ( [ Xi, V, roughness ] ) => {
|
|
316
316
|
|
|
317
|
-
const
|
|
318
|
-
const roughness = float( roughness_immutable );
|
|
319
|
-
const alpha = roughness.mul( roughness ).toVar();
|
|
320
|
-
|
|
321
|
-
// Section 3.2: Transform view direction to hemisphere configuration
|
|
322
|
-
const Vh = normalize( vec3( alpha.mul( V.x ), alpha.mul( V.y ), V.z ) ).toVar();
|
|
317
|
+
const alpha = roughness.mul( roughness ).toConst();
|
|
323
318
|
|
|
324
319
|
// Section 4.1: Orthonormal basis
|
|
325
|
-
const
|
|
326
|
-
const
|
|
327
|
-
const T2 = cross( Vh, T1 ).toVar();
|
|
320
|
+
const T1 = vec3( 1.0, 0.0, 0.0 ).toConst();
|
|
321
|
+
const T2 = cross( V, T1 ).toConst();
|
|
328
322
|
|
|
329
323
|
// Section 4.2: Parameterization of projected area
|
|
330
|
-
const r = sqrt( Xi.x );
|
|
331
|
-
const phi = mul( 2.0, 3.14159265359 ).mul( Xi.y );
|
|
332
|
-
const t1 = r.mul( cos( phi ) ).
|
|
324
|
+
const r = sqrt( Xi.x ).toConst();
|
|
325
|
+
const phi = mul( 2.0, 3.14159265359 ).mul( Xi.y ).toConst();
|
|
326
|
+
const t1 = r.mul( cos( phi ) ).toConst();
|
|
333
327
|
const t2 = r.mul( sin( phi ) ).toVar();
|
|
334
|
-
const s = mul( 0.5,
|
|
328
|
+
const s = mul( 0.5, V.z.add( 1.0 ) ).toConst();
|
|
335
329
|
t2.assign( s.oneMinus().mul( sqrt( t1.mul( t1 ).oneMinus() ) ).add( s.mul( t2 ) ) );
|
|
336
330
|
|
|
337
331
|
// Section 4.3: Reprojection onto hemisphere
|
|
338
|
-
const Nh = T1.mul( t1 ).add( T2.mul( t2 ) ).add(
|
|
332
|
+
const Nh = T1.mul( t1 ).add( T2.mul( t2 ) ).add( V.mul( sqrt( max( 0.0, t1.mul( t1 ).add( t2.mul( t2 ) ).oneMinus() ) ) ) );
|
|
339
333
|
|
|
340
334
|
// Section 3.4: Transform back to ellipsoid configuration
|
|
341
335
|
return normalize( vec3( alpha.mul( Nh.x ), alpha.mul( Nh.y ), max( 0.0, Nh.z ) ) );
|
package/src/nodes/tsl/TSLCore.js
CHANGED
|
@@ -7,6 +7,7 @@ import SetNode from '../utils/SetNode.js';
|
|
|
7
7
|
import FlipNode from '../utils/FlipNode.js';
|
|
8
8
|
import ConstNode from '../core/ConstNode.js';
|
|
9
9
|
import MemberNode from '../utils/MemberNode.js';
|
|
10
|
+
import StackTrace from '../core/StackTrace.js';
|
|
10
11
|
import { getValueFromType, getValueType } from '../core/NodeUtils.js';
|
|
11
12
|
import { warn, error } from '../../utils.js';
|
|
12
13
|
|
|
@@ -18,6 +19,8 @@ const NodeElements = new Map();
|
|
|
18
19
|
|
|
19
20
|
export function addMethodChaining( name, nodeElement ) {
|
|
20
21
|
|
|
22
|
+
// No require StackTrace because this is internal API
|
|
23
|
+
|
|
21
24
|
if ( NodeElements.has( name ) ) {
|
|
22
25
|
|
|
23
26
|
warn( `TSL: Redefinition of method chaining '${ name }'.` );
|
|
@@ -66,7 +69,7 @@ Node.prototype.assign = function ( ...params ) {
|
|
|
66
69
|
|
|
67
70
|
} else {
|
|
68
71
|
|
|
69
|
-
error( 'TSL: No stack defined for assign operation. Make sure the assign is inside a Fn().' );
|
|
72
|
+
error( 'TSL: No stack defined for assign operation. Make sure the assign is inside a Fn().', new StackTrace() );
|
|
70
73
|
|
|
71
74
|
}
|
|
72
75
|
|
|
@@ -374,13 +377,13 @@ const ShaderNodeProxy = function ( NodeClass, scope = null, factor = null, setti
|
|
|
374
377
|
|
|
375
378
|
if ( minParams !== undefined && params.length < minParams ) {
|
|
376
379
|
|
|
377
|
-
error( `TSL: "${ tslName }" parameter length is less than minimum required
|
|
380
|
+
error( `TSL: "${ tslName }" parameter length is less than minimum required.`, new StackTrace() );
|
|
378
381
|
|
|
379
382
|
return params.concat( new Array( minParams - params.length ).fill( 0 ) );
|
|
380
383
|
|
|
381
384
|
} else if ( maxParams !== undefined && params.length > maxParams ) {
|
|
382
385
|
|
|
383
|
-
error( `TSL: "${ tslName }" parameter length exceeds limit
|
|
386
|
+
error( `TSL: "${ tslName }" parameter length exceeds limit.`, new StackTrace() );
|
|
384
387
|
|
|
385
388
|
return params.slice( 0, maxParams );
|
|
386
389
|
|
|
@@ -441,7 +444,7 @@ const ShaderNodeProxy = function ( NodeClass, scope = null, factor = null, setti
|
|
|
441
444
|
|
|
442
445
|
const ShaderNodeImmutable = function ( NodeClass, ...params ) {
|
|
443
446
|
|
|
444
|
-
return
|
|
447
|
+
return new NodeClass( ...nodeArray( params ) );
|
|
445
448
|
|
|
446
449
|
};
|
|
447
450
|
|
|
@@ -871,9 +874,9 @@ const ConvertType = function ( type, cacheMap = null ) {
|
|
|
871
874
|
|
|
872
875
|
if ( param === undefined ) {
|
|
873
876
|
|
|
874
|
-
error( `TSL: Invalid parameter for the type "${ type }"
|
|
877
|
+
error( `TSL: Invalid parameter for the type "${ type }".`, new StackTrace() );
|
|
875
878
|
|
|
876
|
-
return
|
|
879
|
+
return new ConstNode( 0, type );
|
|
877
880
|
|
|
878
881
|
}
|
|
879
882
|
|
|
@@ -960,7 +963,7 @@ class FnNode extends Node {
|
|
|
960
963
|
|
|
961
964
|
} else {
|
|
962
965
|
|
|
963
|
-
error( 'TSL: Invalid layout type.' );
|
|
966
|
+
error( 'TSL: Invalid layout type.', new StackTrace() );
|
|
964
967
|
|
|
965
968
|
}
|
|
966
969
|
|
|
@@ -1044,7 +1047,7 @@ class FnNode extends Node {
|
|
|
1044
1047
|
|
|
1045
1048
|
const type = this.getNodeType( builder );
|
|
1046
1049
|
|
|
1047
|
-
error( 'TSL: "Fn()" was declared but not invoked. Try calling it like "Fn()( ...params )".' );
|
|
1050
|
+
error( 'TSL: "Fn()" was declared but not invoked. Try calling it like "Fn()( ...params )".', this.stackTrace );
|
|
1048
1051
|
|
|
1049
1052
|
return builder.generateConst( type );
|
|
1050
1053
|
|
|
@@ -1171,8 +1174,8 @@ export const mat2 = new ConvertType( 'mat2' );
|
|
|
1171
1174
|
export const mat3 = new ConvertType( 'mat3' );
|
|
1172
1175
|
export const mat4 = new ConvertType( 'mat4' );
|
|
1173
1176
|
|
|
1174
|
-
export const string = ( value = '' ) =>
|
|
1175
|
-
export const arrayBuffer = ( value ) =>
|
|
1177
|
+
export const string = ( value = '' ) => new ConstNode( value, 'string' );
|
|
1178
|
+
export const arrayBuffer = ( value ) => new ConstNode( value, 'ArrayBuffer' );
|
|
1176
1179
|
|
|
1177
1180
|
addMethodChaining( 'toColor', color );
|
|
1178
1181
|
addMethodChaining( 'toFloat', float );
|
|
@@ -1198,8 +1201,8 @@ addMethodChaining( 'toMat4', mat4 );
|
|
|
1198
1201
|
// basic nodes
|
|
1199
1202
|
|
|
1200
1203
|
export const element = /*@__PURE__*/ nodeProxy( ArrayElementNode ).setParameterLength( 2 );
|
|
1201
|
-
export const convert = ( node, types ) =>
|
|
1202
|
-
export const split = ( node, channels ) =>
|
|
1204
|
+
export const convert = ( node, types ) => new ConvertNode( nodeObject( node ), types );
|
|
1205
|
+
export const split = ( node, channels ) => new SplitNode( nodeObject( node ), channels );
|
|
1203
1206
|
|
|
1204
1207
|
addMethodChaining( 'element', element );
|
|
1205
1208
|
addMethodChaining( 'convert', convert );
|
|
@@ -1216,14 +1219,14 @@ addMethodChaining( 'convert', convert );
|
|
|
1216
1219
|
*/
|
|
1217
1220
|
export const append = ( node ) => { // @deprecated, r176
|
|
1218
1221
|
|
|
1219
|
-
warn( 'TSL: append() has been renamed to Stack().' );
|
|
1222
|
+
warn( 'TSL: append() has been renamed to Stack().', new StackTrace() );
|
|
1220
1223
|
return Stack( node );
|
|
1221
1224
|
|
|
1222
1225
|
};
|
|
1223
1226
|
|
|
1224
1227
|
addMethodChaining( 'append', ( node ) => { // @deprecated, r176
|
|
1225
1228
|
|
|
1226
|
-
warn( 'TSL: .append() has been renamed to .toStack().' );
|
|
1229
|
+
warn( 'TSL: .append() has been renamed to .toStack().', new StackTrace() );
|
|
1227
1230
|
return Stack( node );
|
|
1228
1231
|
|
|
1229
1232
|
} );
|
|
@@ -61,6 +61,19 @@ class ArrayElementNode extends Node { // @TODO: If extending from TempNode it br
|
|
|
61
61
|
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
+
/**
|
|
65
|
+
* This method is overwritten since the member type is inferred from the array-like node.
|
|
66
|
+
*
|
|
67
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
68
|
+
* @param {string} name - The member name.
|
|
69
|
+
* @return {string} The member type.
|
|
70
|
+
*/
|
|
71
|
+
getMemberType( builder, name ) {
|
|
72
|
+
|
|
73
|
+
return this.node.getMemberType( builder, name );
|
|
74
|
+
|
|
75
|
+
}
|
|
76
|
+
|
|
64
77
|
generate( builder ) {
|
|
65
78
|
|
|
66
79
|
const indexType = this.indexNode.getNodeType( builder );
|
|
@@ -42,21 +42,21 @@ class DebugNode extends TempNode {
|
|
|
42
42
|
const callback = this.callback;
|
|
43
43
|
const snippet = this.node.build( builder );
|
|
44
44
|
|
|
45
|
-
const title = '--- TSL debug - ' + builder.shaderStage + ' shader ---';
|
|
46
|
-
const border = '-'.repeat( title.length );
|
|
47
|
-
|
|
48
|
-
let code = '';
|
|
49
|
-
code += '// #' + title + '#\n';
|
|
50
|
-
code += builder.flow.code.replace( /^\t/mg, '' ) + '\n';
|
|
51
|
-
code += '/* ... */ ' + snippet + ' /* ... */\n';
|
|
52
|
-
code += '// #' + border + '#\n';
|
|
53
|
-
|
|
54
45
|
if ( callback !== null ) {
|
|
55
46
|
|
|
56
|
-
callback( builder,
|
|
47
|
+
callback( builder, snippet );
|
|
57
48
|
|
|
58
49
|
} else {
|
|
59
50
|
|
|
51
|
+
const title = '--- TSL debug - ' + builder.shaderStage + ' shader ---';
|
|
52
|
+
const border = '-'.repeat( title.length );
|
|
53
|
+
|
|
54
|
+
let code = '';
|
|
55
|
+
code += '// #' + title + '#\n';
|
|
56
|
+
code += builder.flow.code.replace( /^\t/mg, '' ) + '\n';
|
|
57
|
+
code += '/* ... */ ' + snippet + ' /* ... */\n';
|
|
58
|
+
code += '// #' + border + '#\n';
|
|
59
|
+
|
|
60
60
|
log( code );
|
|
61
61
|
|
|
62
62
|
}
|
|
@@ -78,6 +78,6 @@ export default DebugNode;
|
|
|
78
78
|
* @param {?Function} [callback=null] - Optional callback function to handle the debug output.
|
|
79
79
|
* @returns {DebugNode}
|
|
80
80
|
*/
|
|
81
|
-
export const debug = ( node, callback = null ) =>
|
|
81
|
+
export const debug = ( node, callback = null ) => new DebugNode( nodeObject( node ), callback ).toStack();
|
|
82
82
|
|
|
83
83
|
addMethodChaining( 'debug', debug );
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import Node from '../core/Node.js';
|
|
2
2
|
import { NodeUpdateType } from '../core/constants.js';
|
|
3
|
-
import { nodeObject } from '../tsl/TSLCore.js';
|
|
4
3
|
|
|
5
4
|
/**
|
|
6
5
|
* EventNode is a node that executes a callback during specific update phases.
|
|
@@ -76,7 +75,7 @@ export default EventNode;
|
|
|
76
75
|
* @param {Function} callback - The callback function.
|
|
77
76
|
* @returns {EventNode}
|
|
78
77
|
*/
|
|
79
|
-
const createEvent = ( type, callback ) =>
|
|
78
|
+
const createEvent = ( type, callback ) => new EventNode( type, callback ).toStack();
|
|
80
79
|
|
|
81
80
|
/**
|
|
82
81
|
* Creates an event that triggers a function every time an object (Mesh|Sprite) is rendered.
|
|
@@ -71,7 +71,7 @@ class JoinNode extends TempNode {
|
|
|
71
71
|
|
|
72
72
|
if ( length >= maxLength ) {
|
|
73
73
|
|
|
74
|
-
error( `TSL: Length of parameters exceeds maximum length of function '${ type }()' type
|
|
74
|
+
error( `TSL: Length of parameters exceeds maximum length of function '${ type }()' type.`, this.stackTrace );
|
|
75
75
|
break;
|
|
76
76
|
|
|
77
77
|
}
|
|
@@ -82,7 +82,7 @@ class JoinNode extends TempNode {
|
|
|
82
82
|
|
|
83
83
|
if ( length + inputTypeLength > maxLength ) {
|
|
84
84
|
|
|
85
|
-
error( `TSL: Length of '${ type }()' data exceeds maximum length of output type
|
|
85
|
+
error( `TSL: Length of '${ type }()' data exceeds maximum length of output type.`, this.stackTrace );
|
|
86
86
|
|
|
87
87
|
inputTypeLength = maxLength - length;
|
|
88
88
|
inputType = builder.getTypeFromLength( inputTypeLength );
|
|
@@ -265,7 +265,7 @@ class LoopNode extends Node {
|
|
|
265
265
|
|
|
266
266
|
} else {
|
|
267
267
|
|
|
268
|
-
error( 'TSL: \'Loop( { update: ... } )\' is not a function, string or number.' );
|
|
268
|
+
error( 'TSL: \'Loop( { update: ... } )\' is not a function, string or number.', this.stackTrace );
|
|
269
269
|
|
|
270
270
|
updateSnippet = 'break /* invalid update */';
|
|
271
271
|
|
|
@@ -101,7 +101,7 @@ class MemberNode extends Node {
|
|
|
101
101
|
|
|
102
102
|
if ( this.hasMember( builder ) === false ) {
|
|
103
103
|
|
|
104
|
-
warn( `TSL: Member "${ this.property }" does not exist in struct
|
|
104
|
+
warn( `TSL: Member "${ this.property }" does not exist in struct.`, this.stackTrace );
|
|
105
105
|
|
|
106
106
|
const type = this.getNodeType( builder );
|
|
107
107
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { nodeObject } from '../tsl/TSLBase.js';
|
|
1
|
+
import { nodeObject, vec3, float } from '../tsl/TSLBase.js';
|
|
2
|
+
import { dot, sqrt, saturate } from '../math/MathNode.js';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Packs a direction vector into a color value.
|
|
@@ -19,3 +20,14 @@ export const directionToColor = ( node ) => nodeObject( node ).mul( 0.5 ).add( 0
|
|
|
19
20
|
* @return {Node<vec3>} The direction.
|
|
20
21
|
*/
|
|
21
22
|
export const colorToDirection = ( node ) => nodeObject( node ).mul( 2.0 ).sub( 1 );
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Unpacks a tangent space normal, reconstructing the Z component by projecting the X,Y coordinates onto the hemisphere.
|
|
26
|
+
* The X,Y coordinates are expected to be in the [-1, 1] range.
|
|
27
|
+
*
|
|
28
|
+
* @tsl
|
|
29
|
+
* @function
|
|
30
|
+
* @param {Node<vec2>} xy - The X,Y coordinates of the normal.
|
|
31
|
+
* @return {Node<vec3>} The resulting normal.
|
|
32
|
+
*/
|
|
33
|
+
export const unpackNormal = ( xy ) => vec3( xy, sqrt( saturate( float( 1.0 ).sub( dot( xy, xy ) ) ) ) );
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { abs, cross, float, Fn, normalize, ivec2, sub, vec2, vec3, vec4, fract, dot } from '../tsl/TSLBase.js';
|
|
1
|
+
import { abs, cross, float, Fn, normalize, ivec2, sub, vec2, vec3, vec4, fract, dot, cos, sin } from '../tsl/TSLBase.js';
|
|
2
|
+
import { sqrt } from '../math/MathNode.js';
|
|
2
3
|
import { textureSize } from '../accessors/TextureSizeNode.js';
|
|
3
4
|
import { textureLoad } from '../accessors/TextureNode.js';
|
|
4
5
|
import { WebGPUCoordinateSystem } from '../../constants.js';
|
|
@@ -120,3 +121,34 @@ export const interleavedGradientNoise = Fn( ( [ position ] ) => {
|
|
|
120
121
|
{ name: 'position', type: 'vec2' }
|
|
121
122
|
]
|
|
122
123
|
} );
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Vogel disk sampling for uniform circular distribution.
|
|
127
|
+
*
|
|
128
|
+
* This function generates sample points distributed uniformly on a disk using the golden angle,
|
|
129
|
+
* resulting in an efficient low-discrepancy sequence for sampling. The rotation parameter (phi)
|
|
130
|
+
* allows randomizing the pattern per-pixel when combined with IGN.
|
|
131
|
+
*
|
|
132
|
+
* @tsl
|
|
133
|
+
* @function
|
|
134
|
+
* @param {Node<int>} sampleIndex - The index of the current sample (0-based).
|
|
135
|
+
* @param {Node<int>} samplesCount - The total number of samples.
|
|
136
|
+
* @param {Node<float>} phi - Rotation angle in radians (typically from IGN * 2π).
|
|
137
|
+
* @return {Node<vec2>} A 2D point on the unit disk.
|
|
138
|
+
*/
|
|
139
|
+
export const vogelDiskSample = Fn( ( [ sampleIndex, samplesCount, phi ] ) => {
|
|
140
|
+
|
|
141
|
+
const goldenAngle = float( 2.399963229728653 ); // 2π * (2 - φ) where φ is golden ratio
|
|
142
|
+
const r = sqrt( float( sampleIndex ).add( 0.5 ).div( float( samplesCount ) ) );
|
|
143
|
+
const theta = float( sampleIndex ).mul( goldenAngle ).add( phi );
|
|
144
|
+
return vec2( cos( theta ), sin( theta ) ).mul( r );
|
|
145
|
+
|
|
146
|
+
} ).setLayout( {
|
|
147
|
+
name: 'vogelDiskSample',
|
|
148
|
+
type: 'vec2',
|
|
149
|
+
inputs: [
|
|
150
|
+
{ name: 'sampleIndex', type: 'int' },
|
|
151
|
+
{ name: 'samplesCount', type: 'int' },
|
|
152
|
+
{ name: 'phi', type: 'float' }
|
|
153
|
+
]
|
|
154
|
+
} );
|
|
@@ -266,7 +266,7 @@ export default RTTNode;
|
|
|
266
266
|
* @param {Object} [options={type:HalfFloatType}] - The options for the internal render target.
|
|
267
267
|
* @returns {RTTNode}
|
|
268
268
|
*/
|
|
269
|
-
export const rtt = ( node, ...params ) =>
|
|
269
|
+
export const rtt = ( node, ...params ) => new RTTNode( nodeObject( node ), ...params );
|
|
270
270
|
|
|
271
271
|
/**
|
|
272
272
|
* TSL function for converting nodes to textures nodes.
|