@needle-tools/three 0.169.20-experimental.0 → 0.183.2-canary.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 +5 -6
- package/build/three.cjs +54184 -56703
- package/build/three.core.js +59506 -0
- package/build/three.core.min.js +6 -0
- package/build/three.module.js +11645 -73000
- package/build/three.module.min.js +2 -2
- package/build/three.tsl.js +648 -0
- package/build/three.tsl.min.js +6 -0
- package/build/three.webgpu.js +53912 -51652
- package/build/three.webgpu.min.js +2 -2
- package/build/three.webgpu.nodes.js +53888 -51806
- package/build/three.webgpu.nodes.min.js +2 -2
- package/examples/fonts/MPLUSRounded1c/MPLUSRounded1c-Regular.typeface.json.zip +0 -0
- package/examples/fonts/MPLUSRounded1c/OFL.txt +91 -0
- package/examples/jsm/Addons.js +5 -15
- package/examples/jsm/animation/AnimationClipCreator.js +58 -6
- package/examples/jsm/animation/CCDIKSolver.js +152 -45
- package/examples/jsm/capabilities/WebGL.js +28 -29
- package/examples/jsm/capabilities/WebGPU.js +19 -17
- package/examples/jsm/controls/ArcballControls.js +474 -178
- package/examples/jsm/controls/DragControls.js +100 -58
- package/examples/jsm/controls/FirstPersonControls.js +116 -6
- package/examples/jsm/controls/FlyControls.js +50 -2
- package/examples/jsm/controls/MapControls.js +96 -8
- package/examples/jsm/controls/OrbitControls.js +496 -57
- package/examples/jsm/controls/PointerLockControls.js +115 -22
- package/examples/jsm/controls/TrackballControls.js +166 -14
- package/examples/jsm/controls/TransformControls.js +336 -26
- package/examples/jsm/csm/CSM.js +232 -18
- package/examples/jsm/csm/CSMFrustum.js +61 -4
- package/examples/jsm/csm/CSMHelper.js +50 -0
- package/examples/jsm/csm/CSMShader.js +13 -1
- package/examples/jsm/csm/CSMShadowNode.js +599 -0
- package/examples/jsm/curves/CurveExtras.js +303 -31
- package/examples/jsm/curves/NURBSCurve.js +91 -16
- package/examples/jsm/curves/NURBSSurface.js +52 -6
- package/examples/jsm/curves/NURBSUtils.js +102 -112
- package/examples/jsm/curves/NURBSVolume.js +24 -4
- package/examples/jsm/effects/AnaglyphEffect.js +134 -7
- package/examples/jsm/effects/AsciiEffect.js +69 -22
- package/examples/jsm/effects/OutlineEffect.js +61 -111
- package/examples/jsm/effects/ParallaxBarrierEffect.js +30 -0
- package/examples/jsm/effects/StereoEffect.js +31 -0
- package/examples/jsm/environments/ColorEnvironment.js +59 -0
- package/examples/jsm/environments/DebugEnvironment.js +50 -0
- package/examples/jsm/environments/RoomEnvironment.js +83 -42
- package/examples/jsm/exporters/DRACOExporter.js +56 -14
- package/examples/jsm/exporters/EXRExporter.js +40 -9
- package/examples/jsm/exporters/GLTFExporter.js +502 -169
- package/examples/jsm/exporters/OBJExporter.js +21 -1
- package/examples/jsm/exporters/PLYExporter.js +44 -12
- package/examples/jsm/exporters/STLExporter.js +27 -5
- package/examples/jsm/exporters/USDZExporter.js +781 -291
- package/examples/jsm/geometries/BoxLineGeometry.js +23 -0
- package/examples/jsm/geometries/ConvexGeometry.js +19 -0
- package/examples/jsm/geometries/DecalGeometry.js +91 -30
- package/examples/jsm/geometries/ParametricFunctions.js +100 -0
- package/examples/jsm/geometries/ParametricGeometry.js +38 -5
- package/examples/jsm/geometries/RoundedBoxGeometry.js +68 -7
- package/examples/jsm/geometries/TeapotGeometry.js +23 -38
- package/examples/jsm/geometries/TextGeometry.js +48 -29
- package/examples/jsm/gpgpu/BitonicSort.js +715 -0
- package/examples/jsm/helpers/AnimationPathHelper.js +302 -0
- package/examples/jsm/helpers/LightProbeHelper.js +36 -0
- package/examples/jsm/helpers/LightProbeHelperGPU.js +38 -1
- package/examples/jsm/helpers/OctreeHelper.js +36 -0
- package/examples/jsm/helpers/PositionalAudioHelper.js +60 -0
- package/examples/jsm/helpers/RapierHelper.js +59 -0
- package/examples/jsm/helpers/RectAreaLightHelper.js +36 -3
- package/examples/jsm/helpers/TextureHelper.js +28 -0
- package/examples/jsm/helpers/TextureHelperGPU.js +214 -0
- package/examples/jsm/helpers/VertexNormalsHelper.js +61 -2
- package/examples/jsm/helpers/VertexTangentsHelper.js +47 -2
- package/examples/jsm/helpers/ViewHelper.js +181 -9
- package/examples/jsm/inspector/Inspector.js +487 -0
- package/examples/jsm/inspector/RendererInspector.js +425 -0
- package/examples/jsm/inspector/tabs/Console.js +238 -0
- package/examples/jsm/inspector/tabs/Parameters.js +348 -0
- package/examples/jsm/inspector/tabs/Performance.js +268 -0
- package/examples/jsm/inspector/tabs/Viewer.js +166 -0
- package/examples/jsm/inspector/ui/Graph.js +95 -0
- package/examples/jsm/inspector/ui/Item.js +170 -0
- package/examples/jsm/inspector/ui/List.js +75 -0
- package/examples/jsm/inspector/ui/Profiler.js +1975 -0
- package/examples/jsm/inspector/ui/Style.js +1613 -0
- package/examples/jsm/inspector/ui/Tab.js +233 -0
- package/examples/jsm/inspector/ui/Values.js +439 -0
- package/examples/jsm/inspector/ui/utils.js +56 -0
- package/examples/jsm/interactive/HTMLMesh.js +43 -12
- package/examples/jsm/interactive/InteractiveGroup.js +170 -52
- package/examples/jsm/interactive/SelectionBox.js +106 -9
- package/examples/jsm/interactive/SelectionHelper.js +76 -30
- package/examples/jsm/libs/demuxer_mp4.js +109 -0
- package/examples/jsm/libs/meshopt_decoder.module.js +76 -58
- package/examples/jsm/libs/motion-controllers.module.js +1 -1
- package/examples/jsm/lighting/TiledLighting.js +42 -0
- package/examples/jsm/lights/LightProbeGenerator.js +44 -7
- package/examples/jsm/lights/RectAreaLightTexturesLib.js +50 -14
- package/examples/jsm/lights/RectAreaLightUniformsLib.js +16 -0
- package/examples/jsm/lines/Line2.js +41 -4
- package/examples/jsm/lines/LineGeometry.js +80 -2
- package/examples/jsm/lines/LineMaterial.js +105 -5
- package/examples/jsm/lines/LineSegments2.js +54 -4
- package/examples/jsm/lines/LineSegmentsGeometry.js +65 -8
- package/examples/jsm/lines/Wireframe.js +41 -4
- package/examples/jsm/lines/WireframeGeometry2.js +27 -2
- package/examples/jsm/lines/webgpu/Line2.js +28 -2
- package/examples/jsm/lines/webgpu/LineSegments2.js +59 -24
- package/examples/jsm/lines/webgpu/Wireframe.js +86 -0
- package/examples/jsm/loaders/3DMLoader.js +78 -6
- package/examples/jsm/loaders/3MFLoader.js +148 -7
- package/examples/jsm/loaders/AMFLoader.js +34 -14
- package/examples/jsm/loaders/BVHLoader.js +59 -12
- package/examples/jsm/loaders/ColladaLoader.js +61 -4027
- package/examples/jsm/loaders/DDSLoader.js +68 -1
- package/examples/jsm/loaders/DRACOLoader.js +146 -22
- package/examples/jsm/loaders/EXRLoader.js +255 -34
- package/examples/jsm/loaders/FBXLoader.js +80 -42
- package/examples/jsm/loaders/FontLoader.js +83 -6
- package/examples/jsm/loaders/GCodeLoader.js +71 -14
- package/examples/jsm/loaders/GLTFLoader.js +381 -263
- package/examples/jsm/loaders/HDRCubeTextureLoader.js +52 -3
- package/examples/jsm/loaders/HDRLoader.js +485 -0
- package/examples/jsm/loaders/IESLoader.js +42 -0
- package/examples/jsm/loaders/KMZLoader.js +39 -6
- package/examples/jsm/loaders/KTX2Loader.js +124 -48
- package/examples/jsm/loaders/KTXLoader.js +31 -10
- package/examples/jsm/loaders/LDrawLoader.js +192 -145
- package/examples/jsm/loaders/LUT3dlLoader.js +47 -10
- package/examples/jsm/loaders/LUTCubeLoader.js +46 -9
- package/examples/jsm/loaders/LUTImageLoader.js +79 -38
- package/examples/jsm/loaders/LWOLoader.js +54 -59
- package/examples/jsm/loaders/LottieLoader.js +54 -1
- package/examples/jsm/loaders/MD2Loader.js +37 -1
- package/examples/jsm/loaders/MDDLoader.js +57 -12
- package/examples/jsm/loaders/MTLLoader.js +60 -35
- package/examples/jsm/loaders/MaterialXLoader.js +268 -34
- package/examples/jsm/loaders/NRRDLoader.js +40 -8
- package/examples/jsm/loaders/OBJLoader.js +51 -2
- package/examples/jsm/loaders/PCDLoader.js +173 -21
- package/examples/jsm/loaders/PDBLoader.js +41 -2
- package/examples/jsm/loaders/PLYLoader.js +70 -39
- package/examples/jsm/loaders/PVRLoader.js +25 -6
- package/examples/jsm/loaders/RGBELoader.js +6 -438
- package/examples/jsm/loaders/STLLoader.js +48 -38
- package/examples/jsm/loaders/SVGLoader.js +119 -25
- package/examples/jsm/loaders/TDSLoader.js +92 -74
- package/examples/jsm/loaders/TGALoader.js +23 -2
- package/examples/jsm/loaders/TIFFLoader.js +23 -0
- package/examples/jsm/loaders/TTFLoader.js +50 -3
- package/examples/jsm/loaders/USDLoader.js +279 -0
- package/examples/jsm/loaders/USDZLoader.js +4 -858
- package/examples/jsm/loaders/UltraHDRLoader.js +338 -166
- package/examples/jsm/loaders/VOXLoader.js +688 -87
- package/examples/jsm/loaders/VRMLLoader.js +121 -12
- package/examples/jsm/loaders/VTKLoader.js +77 -25
- package/examples/jsm/loaders/XYZLoader.js +36 -0
- package/examples/jsm/loaders/collada/ColladaComposer.js +2950 -0
- package/examples/jsm/loaders/collada/ColladaParser.js +1962 -0
- package/examples/jsm/loaders/lwo/IFFParser.js +77 -77
- package/examples/jsm/loaders/usd/USDAParser.js +822 -0
- package/examples/jsm/loaders/usd/USDCParser.js +1852 -0
- package/examples/jsm/loaders/usd/USDComposer.js +4041 -0
- package/examples/jsm/materials/LDrawConditionalLineMaterial.js +183 -0
- package/examples/jsm/materials/LDrawConditionalLineNodeMaterial.js +154 -0
- package/examples/jsm/materials/WoodNodeMaterial.js +533 -0
- package/examples/jsm/math/Capsule.js +91 -14
- package/examples/jsm/math/ColorConverter.js +22 -0
- package/examples/jsm/math/ColorSpaces.js +74 -2
- package/examples/jsm/math/ConvexHull.js +517 -93
- package/examples/jsm/math/ImprovedNoise.js +32 -15
- package/examples/jsm/math/Lut.js +113 -0
- package/examples/jsm/math/MeshSurfaceSampler.js +78 -13
- package/examples/jsm/math/OBB.js +141 -29
- package/examples/jsm/math/Octree.js +283 -7
- package/examples/jsm/math/SimplexNoise.js +68 -42
- package/examples/jsm/misc/ConvexObjectBreaker.js +45 -25
- package/examples/jsm/misc/GPUComputationRenderer.js +96 -20
- package/examples/jsm/misc/Gyroscope.js +12 -0
- package/examples/jsm/misc/MD2Character.js +117 -2
- package/examples/jsm/misc/MD2CharacterComplex.js +175 -11
- package/examples/jsm/misc/MorphAnimMesh.js +44 -0
- package/examples/jsm/misc/MorphBlendMesh.js +103 -0
- package/examples/jsm/misc/ProgressiveLightMap.js +100 -54
- package/examples/jsm/misc/ProgressiveLightMapGPU.js +322 -0
- package/examples/jsm/misc/RollerCoaster.js +57 -0
- package/examples/jsm/misc/TubePainter.js +437 -40
- package/examples/jsm/misc/Volume.js +123 -76
- package/examples/jsm/misc/VolumeSlice.js +95 -49
- package/examples/jsm/modifiers/CurveModifier.js +66 -38
- package/examples/jsm/modifiers/CurveModifierGPU.js +42 -19
- package/examples/jsm/modifiers/EdgeSplitModifier.js +20 -0
- package/examples/jsm/modifiers/SimplifyModifier.js +24 -10
- package/examples/jsm/modifiers/TessellateModifier.js +35 -2
- package/examples/jsm/objects/GroundedSkybox.js +25 -6
- package/examples/jsm/objects/Lensflare.js +94 -2
- package/examples/jsm/objects/LensflareMesh.js +64 -10
- package/examples/jsm/objects/MarchingCubes.js +90 -5
- package/examples/jsm/objects/Reflector.js +76 -2
- package/examples/jsm/objects/ReflectorForSSRPass.js +41 -0
- package/examples/jsm/objects/Refractor.js +62 -0
- package/examples/jsm/objects/ShadowMesh.js +54 -4
- package/examples/jsm/objects/Sky.js +106 -16
- package/examples/jsm/objects/SkyMesh.js +211 -38
- package/examples/jsm/objects/Water.js +49 -8
- package/examples/jsm/objects/Water2.js +49 -7
- package/examples/jsm/objects/Water2Mesh.js +50 -9
- package/examples/jsm/objects/WaterMesh.js +136 -43
- package/examples/jsm/physics/AmmoPhysics.js +60 -7
- package/examples/jsm/physics/JoltPhysics.js +65 -12
- package/examples/jsm/physics/RapierPhysics.js +217 -21
- package/examples/jsm/postprocessing/AfterimagePass.js +110 -29
- package/examples/jsm/postprocessing/BloomPass.js +128 -26
- package/examples/jsm/postprocessing/BokehPass.js +99 -22
- package/examples/jsm/postprocessing/ClearPass.js +54 -3
- package/examples/jsm/postprocessing/CubeTexturePass.js +82 -21
- package/examples/jsm/postprocessing/DotScreenPass.js +59 -10
- package/examples/jsm/postprocessing/EffectComposer.js +140 -6
- package/examples/jsm/postprocessing/FXAAPass.js +40 -0
- package/examples/jsm/postprocessing/FilmPass.js +54 -5
- package/examples/jsm/postprocessing/GTAOPass.js +202 -57
- package/examples/jsm/postprocessing/GlitchPass.js +86 -34
- package/examples/jsm/postprocessing/HalftonePass.js +65 -10
- package/examples/jsm/postprocessing/LUTPass.js +38 -8
- package/examples/jsm/postprocessing/MaskPass.js +91 -0
- package/examples/jsm/postprocessing/OutlinePass.js +272 -135
- package/examples/jsm/postprocessing/OutputPass.js +65 -14
- package/examples/jsm/postprocessing/Pass.js +100 -4
- package/examples/jsm/postprocessing/RenderPass.js +94 -0
- package/examples/jsm/postprocessing/RenderPixelatedPass.js +124 -45
- package/examples/jsm/postprocessing/RenderTransitionPass.js +120 -21
- package/examples/jsm/postprocessing/SAOPass.js +128 -55
- package/examples/jsm/postprocessing/SMAAPass.js +106 -75
- package/examples/jsm/postprocessing/SSAARenderPass.js +118 -35
- package/examples/jsm/postprocessing/SSAOPass.js +173 -60
- package/examples/jsm/postprocessing/SSRPass.js +268 -53
- package/examples/jsm/postprocessing/SavePass.js +69 -16
- package/examples/jsm/postprocessing/ShaderPass.js +65 -7
- package/examples/jsm/postprocessing/TAARenderPass.js +79 -24
- package/examples/jsm/postprocessing/TexturePass.js +72 -8
- package/examples/jsm/postprocessing/UnrealBloomPass.js +168 -59
- package/examples/jsm/renderers/CSS2DRenderer.js +98 -5
- package/examples/jsm/renderers/CSS3DRenderer.js +111 -7
- package/examples/jsm/renderers/Projector.js +288 -32
- package/examples/jsm/renderers/SVGRenderer.js +323 -61
- package/examples/jsm/renderers/webgl-legacy/nodes/GLSL1NodeBuilder.js +3 -1
- package/examples/jsm/renderers/webgl-legacy/nodes/SlotNode.js +1 -1
- package/examples/jsm/renderers/webgl-legacy/nodes/WebGLNodeBuilder.js +5 -1
- package/examples/jsm/shaders/ACESFilmicToneMappingShader.js +12 -5
- package/examples/jsm/shaders/AfterimageShader.js +8 -3
- package/examples/jsm/shaders/BasicShader.js +8 -1
- package/examples/jsm/shaders/BleachBypassShader.js +10 -3
- package/examples/jsm/shaders/BlendShader.js +8 -1
- package/examples/jsm/shaders/BokehShader.js +9 -3
- package/examples/jsm/shaders/BokehShader2.js +11 -4
- package/examples/jsm/shaders/BrightnessContrastShader.js +10 -4
- package/examples/jsm/shaders/ColorCorrectionShader.js +8 -1
- package/examples/jsm/shaders/ColorifyShader.js +8 -1
- package/examples/jsm/shaders/ConvolutionShader.js +9 -38
- package/examples/jsm/shaders/CopyShader.js +8 -1
- package/examples/jsm/shaders/DOFMipMapShader.js +10 -3
- package/examples/jsm/shaders/DepthLimitedBlurShader.js +10 -1
- package/examples/jsm/shaders/DigitalGlitch.js +10 -7
- package/examples/jsm/shaders/DotScreenShader.js +8 -3
- package/examples/jsm/shaders/ExposureShader.js +8 -1
- package/examples/jsm/shaders/FXAAShader.js +233 -221
- package/examples/jsm/shaders/FilmShader.js +13 -0
- package/examples/jsm/shaders/FocusShader.js +8 -3
- package/examples/jsm/shaders/FreiChenShader.js +10 -3
- package/examples/jsm/shaders/GTAOShader.js +55 -45
- package/examples/jsm/shaders/GammaCorrectionShader.js +11 -2
- package/examples/jsm/shaders/HalftoneShader.js +24 -4
- package/examples/jsm/shaders/HorizontalBlurShader.js +12 -3
- package/examples/jsm/shaders/HorizontalTiltShiftShader.js +9 -2
- package/examples/jsm/shaders/HueSaturationShader.js +10 -3
- package/examples/jsm/shaders/KaleidoShader.js +11 -4
- package/examples/jsm/shaders/LuminosityHighPassShader.js +8 -4
- package/examples/jsm/shaders/LuminosityShader.js +8 -2
- package/examples/jsm/shaders/MirrorShader.js +10 -4
- package/examples/jsm/shaders/NormalMapShader.js +7 -2
- package/examples/jsm/shaders/OutputShader.js +19 -1
- package/examples/jsm/shaders/PoissonDenoiseShader.js +30 -17
- package/examples/jsm/shaders/RGBShiftShader.js +8 -1
- package/examples/jsm/shaders/SAOShader.js +27 -5
- package/examples/jsm/shaders/SMAAShader.js +24 -1
- package/examples/jsm/shaders/SSAOShader.js +37 -6
- package/examples/jsm/shaders/SSRShader.js +32 -6
- package/examples/jsm/shaders/SepiaShader.js +8 -3
- package/examples/jsm/shaders/SobelOperatorShader.js +9 -3
- package/examples/jsm/shaders/SubsurfaceScatteringShader.js +13 -8
- package/examples/jsm/shaders/TechnicolorShader.js +10 -4
- package/examples/jsm/shaders/ToonShader.js +29 -6
- package/examples/jsm/shaders/TriangleBlurShader.js +9 -4
- package/examples/jsm/shaders/UnpackDepthRGBAShader.js +19 -6
- package/examples/jsm/shaders/VelocityShader.js +8 -1
- package/examples/jsm/shaders/VerticalBlurShader.js +9 -2
- package/examples/jsm/shaders/VerticalTiltShiftShader.js +8 -1
- package/examples/jsm/shaders/VignetteShader.js +8 -3
- package/examples/jsm/shaders/VolumeShader.js +11 -2
- package/examples/jsm/shaders/WaterRefractionShader.js +11 -0
- package/examples/jsm/textures/FlakesTexture.js +14 -0
- package/examples/jsm/transpiler/AST.js +436 -31
- package/examples/jsm/transpiler/GLSLDecoder.js +380 -135
- package/examples/jsm/transpiler/Linker.js +327 -0
- package/examples/jsm/transpiler/ShaderToyDecoder.js +3 -1
- package/examples/jsm/transpiler/TSLEncoder.js +363 -97
- package/examples/jsm/transpiler/Transpiler.js +50 -1
- package/examples/jsm/transpiler/TranspilerUtils.js +29 -0
- package/examples/jsm/transpiler/WGSLEncoder.js +839 -0
- package/examples/jsm/tsl/display/AfterImageNode.js +244 -0
- package/examples/jsm/tsl/display/AnaglyphPassNode.js +549 -0
- package/examples/jsm/tsl/display/AnamorphicNode.js +282 -0
- package/examples/jsm/tsl/display/BilateralBlurNode.js +364 -0
- package/{src/nodes → examples/jsm/tsl}/display/BleachBypass.js +11 -4
- package/examples/jsm/tsl/display/BloomNode.js +534 -0
- package/examples/jsm/tsl/display/CRT.js +150 -0
- package/examples/jsm/tsl/display/ChromaticAberrationNode.js +207 -0
- package/examples/jsm/tsl/display/DenoiseNode.js +334 -0
- package/examples/jsm/tsl/display/DepthOfFieldNode.js +554 -0
- package/examples/jsm/tsl/display/DotScreenNode.js +104 -0
- package/examples/jsm/tsl/display/FXAANode.js +365 -0
- package/examples/jsm/tsl/display/FilmNode.js +101 -0
- package/examples/jsm/tsl/display/GTAONode.js +571 -0
- package/examples/jsm/tsl/display/GaussianBlurNode.js +389 -0
- package/examples/jsm/tsl/display/GodraysNode.js +624 -0
- package/examples/jsm/tsl/display/LensflareNode.js +279 -0
- package/examples/jsm/tsl/display/Lut3DNode.js +109 -0
- package/examples/jsm/tsl/display/MotionBlur.js +33 -0
- package/examples/jsm/tsl/display/OutlineNode.js +762 -0
- package/examples/jsm/tsl/display/ParallaxBarrierPassNode.js +89 -0
- package/examples/jsm/tsl/display/PixelationPassNode.js +335 -0
- package/examples/jsm/tsl/display/RGBShiftNode.js +96 -0
- package/examples/jsm/tsl/display/RetroPassNode.js +263 -0
- package/examples/jsm/tsl/display/SMAANode.js +768 -0
- package/{src/nodes → examples/jsm/tsl}/display/SSAAPassNode.js +120 -49
- package/examples/jsm/tsl/display/SSGINode.js +642 -0
- package/examples/jsm/tsl/display/SSRNode.js +656 -0
- package/examples/jsm/tsl/display/SSSNode.js +490 -0
- package/{src/nodes → examples/jsm/tsl}/display/Sepia.js +9 -2
- package/examples/jsm/tsl/display/Shape.js +29 -0
- package/{src/nodes → examples/jsm/tsl}/display/SobelOperatorNode.js +61 -19
- package/examples/jsm/tsl/display/StereoCompositePassNode.js +192 -0
- package/{src/nodes → examples/jsm/tsl}/display/StereoPassNode.js +48 -12
- package/examples/jsm/tsl/display/TRAANode.js +726 -0
- package/examples/jsm/tsl/display/TransitionNode.js +141 -0
- package/examples/jsm/tsl/display/boxBlur.js +65 -0
- package/examples/jsm/tsl/display/depthAwareBlend.js +80 -0
- package/examples/jsm/tsl/display/hashBlur.js +54 -0
- package/examples/jsm/tsl/display/radialBlur.js +68 -0
- package/examples/jsm/tsl/lighting/TiledLightsNode.js +442 -0
- package/examples/jsm/tsl/math/Bayer.js +73 -0
- package/examples/jsm/tsl/shadows/TileShadowNode.js +456 -0
- package/examples/jsm/tsl/shadows/TileShadowNodeHelper.js +212 -0
- package/examples/jsm/tsl/utils/Raymarching.js +70 -0
- package/examples/jsm/utils/BufferGeometryUtils.js +91 -29
- package/examples/jsm/utils/CameraUtils.js +15 -6
- package/examples/jsm/utils/GeometryCompressionUtils.js +23 -30
- package/examples/jsm/utils/GeometryUtils.js +32 -27
- package/examples/jsm/utils/LDrawUtils.js +14 -5
- package/examples/jsm/utils/SceneOptimizer.js +458 -0
- package/examples/jsm/utils/SceneUtils.js +53 -3
- package/examples/jsm/utils/ShadowMapViewer.js +72 -33
- package/examples/jsm/utils/ShadowMapViewerGPU.js +61 -29
- package/examples/jsm/utils/SkeletonUtils.js +48 -0
- package/examples/jsm/utils/SortUtils.js +17 -5
- package/examples/jsm/utils/UVsDebug.js +12 -4
- package/examples/jsm/utils/{TextureUtils.js → WebGLTextureUtils.js} +16 -0
- package/examples/jsm/utils/{TextureUtilsGPU.js → WebGPUTextureUtils.js} +20 -2
- package/examples/jsm/utils/WorkerPool.js +67 -2
- package/examples/jsm/webxr/ARButton.js +19 -0
- package/examples/jsm/webxr/OculusHandModel.js +84 -0
- package/examples/jsm/webxr/OculusHandPointerModel.js +148 -22
- package/examples/jsm/webxr/Text2D.js +20 -6
- package/examples/jsm/webxr/VRButton.js +31 -0
- package/examples/jsm/webxr/XRButton.js +23 -0
- package/examples/jsm/webxr/XRControllerModelFactory.js +94 -3
- package/examples/jsm/webxr/XREstimatedLight.js +35 -4
- package/examples/jsm/webxr/XRHandMeshModel.js +37 -0
- package/examples/jsm/webxr/XRHandModelFactory.js +96 -6
- package/examples/jsm/webxr/XRHandPrimitiveModel.js +44 -0
- package/examples/jsm/webxr/XRPlanes.js +18 -0
- package/package.json +29 -37
- package/src/Three.Core.js +198 -0
- package/src/Three.Legacy.js +0 -21
- package/src/Three.TSL.js +641 -0
- package/src/Three.WebGPU.Nodes.js +14 -186
- package/src/Three.WebGPU.js +16 -186
- package/src/Three.js +2 -197
- package/src/animation/AnimationAction.js +263 -31
- package/src/animation/AnimationClip.js +162 -7
- package/src/animation/AnimationMixer.js +105 -15
- package/src/animation/AnimationObjectGroup.js +45 -21
- package/src/animation/AnimationUtils.js +163 -24
- package/src/animation/KeyframeTrack.js +191 -17
- package/src/animation/PropertyBinding.js +91 -16
- package/src/animation/PropertyMixer.js +72 -5
- package/src/animation/tracks/BooleanKeyframeTrack.js +33 -6
- package/src/animation/tracks/ColorKeyframeTrack.js +26 -5
- package/src/animation/tracks/NumberKeyframeTrack.js +26 -2
- package/src/animation/tracks/QuaternionKeyframeTrack.js +30 -1
- package/src/animation/tracks/StringKeyframeTrack.js +33 -2
- package/src/animation/tracks/VectorKeyframeTrack.js +26 -2
- package/src/audio/Audio.js +386 -8
- package/src/audio/AudioAnalyser.js +58 -1
- package/src/audio/AudioContext.js +15 -0
- package/src/audio/AudioListener.js +94 -13
- package/src/audio/PositionalAudio.js +107 -0
- package/src/cameras/ArrayCamera.js +37 -0
- package/src/cameras/Camera.js +61 -0
- package/src/cameras/CubeCamera.js +86 -0
- package/src/cameras/OrthographicCamera.js +110 -1
- package/src/cameras/PerspectiveCamera.js +174 -35
- package/src/cameras/StereoCamera.js +48 -2
- package/src/constants.js +1546 -11
- package/src/core/BufferAttribute.js +417 -3
- package/src/core/BufferGeometry.js +407 -22
- package/src/core/Clock.js +69 -8
- package/src/core/EventDispatcher.js +52 -8
- package/src/core/GLBufferAttribute.js +113 -2
- package/src/core/InstancedBufferAttribute.js +29 -0
- package/src/core/InstancedBufferGeometry.js +20 -0
- package/src/core/InstancedInterleavedBuffer.js +26 -0
- package/src/core/InterleavedBuffer.js +141 -7
- package/src/core/InterleavedBufferAttribute.js +200 -2
- package/src/core/Layers.js +71 -10
- package/src/core/Object3D.js +673 -26
- package/src/core/Raycaster.js +136 -2
- package/src/core/RenderTarget.js +256 -27
- package/src/core/RenderTarget3D.js +48 -0
- package/src/core/Timer.js +184 -0
- package/src/core/Uniform.js +29 -0
- package/src/core/UniformsGroup.js +84 -2
- package/src/extras/Controls.js +89 -1
- package/src/extras/DataUtils.js +50 -9
- package/src/extras/Earcut.js +18 -779
- package/src/extras/ImageUtils.js +22 -14
- package/src/extras/PMREMGenerator.js +316 -67
- package/src/extras/ShapeUtils.js +24 -2
- package/src/extras/TextureUtils.js +101 -15
- package/src/extras/core/Curve.js +156 -55
- package/src/extras/core/CurvePath.js +63 -22
- package/src/extras/core/Interpolations.js +34 -2
- package/src/extras/core/Path.js +134 -1
- package/src/extras/core/Shape.js +66 -3
- package/src/extras/core/ShapePath.js +80 -4
- package/src/extras/curves/ArcCurve.js +22 -0
- package/src/extras/curves/CatmullRomCurve3.js +89 -18
- package/src/extras/curves/CubicBezierCurve.js +67 -0
- package/src/extras/curves/CubicBezierCurve3.js +50 -0
- package/src/extras/curves/EllipseCurve.js +102 -0
- package/src/extras/curves/LineCurve.js +36 -0
- package/src/extras/curves/LineCurve3.js +36 -0
- package/src/extras/curves/QuadraticBezierCurve.js +59 -0
- package/src/extras/curves/QuadraticBezierCurve3.js +43 -0
- package/src/extras/curves/SplineCurve.js +48 -0
- package/src/extras/lib/earcut.js +685 -0
- package/src/geometries/BoxGeometry.js +39 -0
- package/src/geometries/CapsuleGeometry.js +196 -11
- package/src/geometries/CircleGeometry.js +41 -0
- package/src/geometries/ConeGeometry.js +39 -0
- package/src/geometries/CylinderGeometry.js +42 -2
- package/src/geometries/DodecahedronGeometry.js +33 -0
- package/src/geometries/EdgesGeometry.js +30 -2
- package/src/geometries/ExtrudeGeometry.js +148 -52
- package/src/geometries/IcosahedronGeometry.js +33 -0
- package/src/geometries/LatheGeometry.js +44 -3
- package/src/geometries/OctahedronGeometry.js +33 -0
- package/src/geometries/PlaneGeometry.js +35 -0
- package/src/geometries/PolyhedronGeometry.js +30 -1
- package/src/geometries/RingGeometry.js +37 -0
- package/src/geometries/ShapeGeometry.js +38 -0
- package/src/geometries/SphereGeometry.js +38 -0
- package/src/geometries/TetrahedronGeometry.js +33 -0
- package/src/geometries/TorusGeometry.js +44 -3
- package/src/geometries/TorusKnotGeometry.js +39 -0
- package/src/geometries/TubeGeometry.js +50 -0
- package/src/geometries/WireframeGeometry.js +32 -0
- package/src/helpers/ArrowHelper.js +62 -5
- package/src/helpers/AxesHelper.js +28 -0
- package/src/helpers/Box3Helper.js +28 -0
- package/src/helpers/BoxHelper.js +43 -7
- package/src/helpers/CameraHelper.js +103 -27
- package/src/helpers/DirectionalLightHelper.js +55 -0
- package/src/helpers/GridHelper.js +26 -0
- package/src/helpers/HemisphereLightHelper.js +42 -0
- package/src/helpers/PlaneHelper.js +33 -0
- package/src/helpers/PointLightHelper.js +43 -24
- package/src/helpers/PolarGridHelper.js +30 -0
- package/src/helpers/SkeletonHelper.js +73 -7
- package/src/helpers/SpotLightHelper.js +43 -0
- package/src/lights/AmbientLight.js +25 -0
- package/src/lights/DirectionalLight.js +70 -0
- package/src/lights/DirectionalLightShadow.js +15 -0
- package/src/lights/HemisphereLight.js +42 -0
- package/src/lights/Light.js +37 -11
- package/src/lights/LightProbe.js +37 -9
- package/src/lights/LightShadow.js +202 -7
- package/src/lights/PointLight.js +74 -0
- package/src/lights/PointLightShadow.js +15 -80
- package/src/lights/RectAreaLight.js +59 -0
- package/src/lights/SpotLight.js +124 -1
- package/src/lights/SpotLightShadow.js +33 -3
- package/src/lights/webgpu/IESSpotLight.js +22 -0
- package/src/lights/webgpu/ProjectorLight.js +46 -0
- package/src/loaders/AnimationLoader.js +34 -2
- package/src/loaders/AudioLoader.js +34 -2
- package/src/loaders/BufferGeometryLoader.js +38 -13
- package/src/loaders/Cache.js +75 -2
- package/src/loaders/CompressedTextureLoader.js +36 -3
- package/src/loaders/CubeTextureLoader.js +45 -0
- package/src/loaders/DataTextureLoader.js +45 -4
- package/src/loaders/FileLoader.js +85 -5
- package/src/loaders/ImageBitmapLoader.js +113 -11
- package/src/loaders/ImageLoader.js +85 -8
- package/src/loaders/Loader.js +150 -0
- package/src/loaders/LoaderUtils.js +18 -36
- package/src/loaders/LoadingManager.js +187 -0
- package/src/loaders/MaterialLoader.js +62 -3
- package/src/loaders/ObjectLoader.js +131 -31
- package/src/loaders/TextureLoader.js +33 -0
- package/src/loaders/nodes/NodeLoader.js +68 -4
- package/src/loaders/nodes/NodeMaterialLoader.js +45 -0
- package/src/loaders/nodes/NodeObjectLoader.js +61 -0
- package/src/materials/LineBasicMaterial.js +74 -1
- package/src/materials/LineDashedMaterial.js +52 -1
- package/src/materials/Material.js +502 -8
- package/src/materials/MeshBasicMaterial.js +168 -2
- package/src/materials/MeshDepthMaterial.js +94 -0
- package/src/materials/MeshDistanceMaterial.js +76 -0
- package/src/materials/MeshLambertMaterial.js +283 -0
- package/src/materials/MeshMatcapMaterial.js +164 -0
- package/src/materials/MeshNormalMaterial.js +114 -0
- package/src/materials/MeshPhongMaterial.js +298 -0
- package/src/materials/MeshPhysicalMaterial.js +296 -4
- package/src/materials/MeshStandardMaterial.js +300 -2
- package/src/materials/MeshToonMaterial.js +219 -0
- package/src/materials/PointsMaterial.js +89 -0
- package/src/materials/RawShaderMaterial.js +25 -0
- package/src/materials/ShaderMaterial.js +234 -6
- package/src/materials/ShadowMaterial.js +54 -0
- package/src/materials/SpriteMaterial.js +82 -0
- package/src/materials/nodes/Line2NodeMaterial.js +158 -53
- package/src/materials/nodes/LineBasicNodeMaterial.js +17 -2
- package/src/materials/nodes/LineDashedNodeMaterial.js +81 -6
- package/src/materials/nodes/MeshBasicNodeMaterial.js +59 -2
- package/src/materials/nodes/MeshLambertNodeMaterial.js +35 -0
- package/src/materials/nodes/MeshMatcapNodeMaterial.js +23 -3
- package/src/materials/nodes/MeshNormalNodeMaterial.js +27 -4
- package/src/materials/nodes/MeshPhongNodeMaterial.js +64 -1
- package/src/materials/nodes/MeshPhysicalNodeMaterial.js +276 -3
- package/src/materials/nodes/MeshSSSNodeMaterial.js +98 -10
- package/src/materials/nodes/MeshStandardNodeMaterial.js +83 -4
- package/src/materials/nodes/MeshToonNodeMaterial.js +28 -0
- package/src/materials/nodes/NodeMaterial.js +789 -74
- package/src/materials/nodes/NodeMaterials.js +0 -1
- package/src/materials/nodes/PointsNodeMaterial.js +180 -11
- package/src/materials/nodes/ShadowNodeMaterial.js +38 -0
- package/src/materials/nodes/SpriteNodeMaterial.js +86 -23
- package/src/materials/nodes/VolumeNodeMaterial.js +57 -84
- package/src/materials/nodes/manager/NodeMaterialObserver.js +329 -12
- package/src/math/Box2.js +177 -0
- package/src/math/Box3.js +271 -0
- package/src/math/Color.js +355 -11
- package/src/math/ColorManagement.js +158 -92
- package/src/math/Cylindrical.js +65 -6
- package/src/math/Euler.js +139 -5
- package/src/math/Frustum.js +108 -9
- package/src/math/FrustumArray.js +258 -0
- package/src/math/Interpolant.js +87 -8
- package/src/math/Line3.js +221 -2
- package/src/math/MathUtils.js +408 -20
- package/src/math/Matrix2.js +70 -0
- package/src/math/Matrix3.js +229 -4
- package/src/math/Matrix4.js +489 -94
- package/src/math/Plane.js +164 -2
- package/src/math/Quaternion.js +322 -90
- package/src/math/Ray.js +162 -0
- package/src/math/Sphere.js +175 -0
- package/src/math/Spherical.js +73 -11
- package/src/math/SphericalHarmonics3.js +112 -14
- package/src/math/Triangle.js +206 -2
- package/src/math/Vector2.js +396 -10
- package/src/math/Vector3.js +550 -15
- package/src/math/Vector4.js +415 -9
- package/src/math/interpolants/BezierInterpolant.js +108 -0
- package/src/math/interpolants/CubicInterpolant.js +10 -1
- package/src/math/interpolants/DiscreteInterpolant.js +10 -2
- package/src/math/interpolants/LinearInterpolant.js +13 -0
- package/src/math/interpolants/QuaternionLinearInterpolant.js +10 -1
- package/src/nodes/Nodes.js +91 -88
- package/src/nodes/TSL.js +32 -38
- package/src/nodes/accessors/AccessorsUtils.js +37 -9
- package/src/nodes/accessors/Arrays.js +68 -0
- package/src/nodes/accessors/BatchNode.js +49 -14
- package/src/nodes/accessors/Bitangent.js +82 -13
- package/src/nodes/accessors/BufferAttributeNode.js +269 -8
- package/src/nodes/accessors/BufferNode.js +91 -2
- package/src/nodes/accessors/BuiltinNode.js +63 -0
- package/src/nodes/accessors/Camera.js +400 -10
- package/src/nodes/accessors/ClippingNode.js +149 -45
- package/src/nodes/accessors/CubeTextureNode.js +137 -7
- package/src/nodes/accessors/InstanceNode.js +245 -40
- package/src/nodes/accessors/InstancedMeshNode.js +50 -0
- package/src/nodes/accessors/Lights.js +88 -0
- package/src/nodes/accessors/MaterialNode.js +355 -13
- package/src/nodes/accessors/MaterialProperties.js +57 -1
- package/src/nodes/accessors/MaterialReferenceNode.js +52 -14
- package/src/nodes/accessors/ModelNode.js +117 -5
- package/src/nodes/accessors/ModelViewProjectionNode.js +10 -39
- package/src/nodes/accessors/MorphNode.js +73 -26
- package/src/nodes/accessors/Normal.js +174 -19
- package/src/nodes/accessors/Object3DNode.js +146 -12
- package/src/nodes/accessors/PointUVNode.js +25 -0
- package/src/nodes/accessors/Position.js +119 -7
- package/src/nodes/accessors/ReferenceBaseNode.js +190 -4
- package/src/nodes/accessors/ReferenceNode.js +223 -8
- package/src/nodes/accessors/ReflectVector.js +29 -3
- package/src/nodes/accessors/RendererReferenceNode.js +45 -2
- package/src/nodes/accessors/SceneProperties.js +53 -0
- package/src/nodes/accessors/SkinningNode.js +180 -43
- package/src/nodes/accessors/StorageBufferNode.js +278 -26
- package/src/nodes/accessors/StorageTextureNode.js +205 -12
- package/src/nodes/accessors/Tangent.js +48 -10
- package/src/nodes/accessors/TangentUtils.js +46 -0
- package/src/nodes/accessors/Texture3DNode.js +104 -11
- package/src/nodes/accessors/TextureBicubic.js +31 -4
- package/src/nodes/accessors/TextureNode.js +564 -52
- package/src/nodes/accessors/TextureSizeNode.js +42 -1
- package/src/nodes/accessors/UV.js +9 -1
- package/src/nodes/accessors/UniformArrayNode.js +226 -34
- package/src/nodes/accessors/UserDataNode.js +46 -2
- package/src/nodes/accessors/VelocityNode.js +93 -3
- package/src/nodes/accessors/VertexColorNode.js +39 -4
- package/src/nodes/code/CodeNode.js +101 -8
- package/src/nodes/code/ExpressionNode.js +29 -2
- package/src/nodes/code/FunctionCallNode.js +98 -10
- package/src/nodes/code/FunctionNode.js +69 -2
- package/src/nodes/core/ArrayNode.js +174 -0
- package/src/nodes/core/AssignNode.js +80 -9
- package/src/nodes/core/AttributeNode.js +47 -4
- package/src/nodes/core/BypassNode.js +47 -3
- package/src/nodes/core/ConstNode.js +32 -0
- package/src/nodes/core/ContextNode.js +220 -14
- package/src/nodes/core/IndexNode.js +72 -7
- package/src/nodes/core/InputNode.js +50 -1
- package/src/nodes/core/InspectorNode.js +128 -0
- package/src/nodes/core/IsolateNode.js +133 -0
- package/src/nodes/core/LightingModel.js +65 -5
- package/src/nodes/core/MRTNode.js +113 -2
- package/src/nodes/core/Node.js +595 -36
- package/src/nodes/core/NodeAttribute.js +38 -0
- package/src/nodes/core/NodeBuilder.js +1840 -121
- package/src/nodes/core/NodeCache.js +41 -2
- package/src/nodes/core/NodeCode.js +31 -0
- package/src/nodes/core/NodeError.js +28 -0
- package/src/nodes/core/NodeFrame.js +153 -24
- package/src/nodes/core/NodeFunction.js +48 -1
- package/src/nodes/core/NodeFunctionInput.js +44 -0
- package/src/nodes/core/NodeParser.js +13 -1
- package/src/nodes/core/NodeUniform.js +53 -1
- package/src/nodes/core/NodeUtils.js +201 -51
- package/src/nodes/core/NodeVar.js +47 -1
- package/src/nodes/core/NodeVarying.js +47 -1
- package/src/nodes/core/OutputStructNode.js +54 -12
- package/src/nodes/core/ParameterNode.js +60 -2
- package/src/nodes/core/PropertyNode.js +286 -7
- package/src/nodes/core/StackNode.js +337 -20
- package/src/nodes/core/StackTrace.js +139 -0
- package/src/nodes/core/StructNode.js +134 -0
- package/src/nodes/core/StructType.js +13 -0
- package/src/nodes/core/StructTypeNode.js +126 -6
- package/src/nodes/core/SubBuildNode.js +89 -0
- package/src/nodes/core/TempNode.js +31 -5
- package/src/nodes/core/UniformGroupNode.js +85 -7
- package/src/nodes/core/UniformNode.js +163 -16
- package/src/nodes/core/VarNode.js +317 -10
- package/src/nodes/core/VaryingNode.js +115 -13
- package/src/nodes/core/constants.js +40 -0
- package/src/nodes/display/BlendModes.js +171 -0
- package/src/nodes/display/BumpMapNode.js +38 -2
- package/src/nodes/display/ColorAdjustment.js +118 -6
- package/src/nodes/display/ColorSpaceFunctions.js +22 -6
- package/src/nodes/display/ColorSpaceNode.js +97 -47
- package/src/nodes/display/FrontFacingNode.js +64 -7
- package/src/nodes/display/NormalMapNode.js +101 -54
- package/src/nodes/display/PassNode.js +690 -33
- package/src/nodes/display/RenderOutputNode.js +94 -4
- package/src/nodes/display/ScreenNode.js +138 -27
- package/src/nodes/display/ToneMappingFunctions.js +62 -10
- package/src/nodes/display/ToneMappingNode.js +88 -8
- package/src/nodes/display/ToonOutlinePassNode.js +84 -4
- package/src/nodes/display/ViewportDepthNode.js +227 -10
- package/src/nodes/display/ViewportDepthTextureNode.js +39 -5
- package/src/nodes/display/ViewportSharedTextureNode.js +35 -1
- package/src/nodes/display/ViewportTextureNode.js +171 -7
- package/src/nodes/fog/Fog.js +97 -0
- package/src/nodes/functions/BSDF/BRDF_GGX.js +2 -6
- package/src/nodes/functions/BSDF/BRDF_GGX_Multiscatter.js +52 -0
- package/src/nodes/functions/BSDF/BRDF_Sheen.js +4 -4
- package/src/nodes/functions/BSDF/DFGLUT.js +56 -0
- package/src/nodes/functions/BSDF/EnvironmentBRDF.js +2 -2
- package/src/nodes/functions/BSDF/LTC.js +45 -1
- package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +1 -1
- package/src/nodes/functions/BasicLightingModel.js +28 -6
- package/src/nodes/functions/PhongLightingModel.js +36 -6
- package/src/nodes/functions/PhysicalLightingModel.js +336 -91
- package/src/nodes/functions/ShadowMaskModel.js +30 -3
- package/src/nodes/functions/ToonLightingModel.js +21 -2
- package/src/nodes/functions/VolumetricLightingModel.js +183 -0
- package/src/nodes/functions/material/getAlphaHashThreshold.js +68 -0
- package/src/nodes/functions/material/getGeometryRoughness.js +10 -4
- package/src/nodes/functions/material/getParallaxCorrectNormal.js +37 -0
- package/src/nodes/geometry/RangeNode.js +97 -8
- package/src/nodes/gpgpu/AtomicFunctionNode.js +198 -23
- package/src/nodes/gpgpu/BarrierNode.js +52 -3
- package/src/nodes/gpgpu/ComputeBuiltinNode.js +135 -6
- package/src/nodes/gpgpu/ComputeNode.js +212 -16
- package/src/nodes/gpgpu/SubgroupFunctionNode.js +455 -0
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +143 -9
- package/src/nodes/lighting/AONode.js +18 -0
- package/src/nodes/lighting/AmbientLightNode.js +10 -0
- package/src/nodes/lighting/AnalyticLightNode.js +186 -399
- package/src/nodes/lighting/BasicEnvironmentNode.js +19 -0
- package/src/nodes/lighting/BasicLightMapNode.js +17 -0
- package/src/nodes/lighting/DirectionalLightNode.js +12 -11
- package/src/nodes/lighting/EnvironmentNode.js +59 -19
- package/src/nodes/lighting/HemisphereLightNode.js +33 -2
- package/src/nodes/lighting/IESSpotLightNode.js +13 -1
- package/src/nodes/lighting/IrradianceNode.js +17 -0
- package/src/nodes/lighting/LightProbeNode.js +20 -0
- package/src/nodes/lighting/LightUtils.js +11 -3
- package/src/nodes/lighting/LightingContextNode.js +52 -4
- package/src/nodes/lighting/LightingNode.js +15 -6
- package/src/nodes/lighting/LightsNode.js +238 -35
- package/src/nodes/lighting/PointLightNode.js +60 -25
- package/src/nodes/lighting/PointShadowNode.js +325 -0
- package/src/nodes/lighting/ProjectorLightNode.js +91 -0
- package/src/nodes/lighting/RectAreaLightNode.js +50 -14
- package/src/nodes/lighting/ShadowBaseNode.js +81 -0
- package/src/nodes/lighting/ShadowFilterNode.js +264 -0
- package/src/nodes/lighting/ShadowNode.js +867 -0
- package/src/nodes/lighting/SpotLightNode.js +99 -18
- package/src/nodes/materialx/MaterialXNodes.js +131 -2
- package/src/nodes/materialx/lib/mx_noise.js +166 -2
- package/src/nodes/math/BitcastNode.js +156 -0
- package/src/nodes/math/BitcountNode.js +433 -0
- package/src/nodes/math/ConditionalNode.js +110 -21
- package/src/nodes/math/Hash.js +8 -0
- package/src/nodes/math/MathNode.js +820 -97
- package/src/nodes/math/MathUtils.js +47 -1
- package/src/nodes/math/OperatorNode.js +517 -84
- package/src/nodes/math/PackFloatNode.js +98 -0
- package/src/nodes/math/TriNoise3D.js +17 -7
- package/src/nodes/math/UnpackFloatNode.js +96 -0
- package/src/nodes/parsers/GLSLNodeFunction.js +16 -0
- package/src/nodes/parsers/GLSLNodeParser.js +11 -0
- package/src/nodes/pmrem/PMREMNode.js +180 -23
- package/src/nodes/pmrem/PMREMUtils.js +114 -5
- package/src/nodes/procedural/Checker.js +8 -0
- package/src/nodes/shapes/Shapes.js +33 -0
- package/src/nodes/tsl/TSLBase.js +10 -4
- package/src/nodes/tsl/TSLCore.js +732 -160
- package/src/nodes/utils/ArrayElementNode.js +55 -4
- package/src/nodes/utils/ConvertNode.js +31 -0
- package/src/nodes/utils/CubeMapNode.js +79 -2
- package/src/nodes/utils/DebugNode.js +83 -0
- package/src/nodes/utils/Discard.js +18 -2
- package/src/nodes/utils/EquirectUV.js +27 -0
- package/src/nodes/utils/EventNode.js +118 -0
- package/src/nodes/utils/FlipNode.js +38 -0
- package/src/nodes/utils/FunctionOverloadingNode.js +91 -22
- package/src/nodes/utils/JoinNode.js +57 -4
- package/src/nodes/utils/LoopNode.js +193 -55
- package/src/nodes/utils/MatcapUV.js +22 -0
- package/src/nodes/utils/MaxMipLevelNode.js +49 -1
- package/src/nodes/utils/MemberNode.js +120 -0
- package/src/nodes/utils/Oscillators.js +41 -0
- package/src/nodes/utils/Packing.js +30 -1
- package/src/nodes/utils/PostProcessingUtils.js +154 -0
- package/src/nodes/utils/RTTNode.js +165 -9
- package/src/nodes/utils/ReflectorNode.js +407 -21
- package/src/nodes/utils/RemapNode.js +81 -2
- package/src/nodes/utils/RotateNode.js +41 -1
- package/src/nodes/utils/SampleNode.js +91 -0
- package/src/nodes/utils/SetNode.js +44 -1
- package/src/nodes/utils/SplitNode.js +66 -3
- package/src/nodes/utils/SpriteSheetUV.js +35 -0
- package/src/nodes/utils/SpriteUtils.js +16 -0
- package/src/nodes/utils/StorageArrayElementNode.js +56 -3
- package/src/nodes/utils/Timer.js +26 -0
- package/src/nodes/utils/TriplanarTextures.js +65 -0
- package/src/nodes/utils/UVUtils.js +48 -0
- package/src/nodes/utils/ViewportUtils.js +12 -0
- package/src/objects/BatchedMesh.js +798 -309
- package/src/objects/Bone.js +24 -0
- package/src/objects/ClippingGroup.js +68 -0
- package/src/objects/Group.js +24 -0
- package/src/objects/InstancedMesh.js +131 -2
- package/src/objects/LOD.js +99 -5
- package/src/objects/Line.js +90 -7
- package/src/objects/LineLoop.js +20 -0
- package/src/objects/LineSegments.js +20 -1
- package/src/objects/Mesh.js +84 -0
- package/src/objects/Points.js +60 -0
- package/src/objects/Skeleton.js +120 -5
- package/src/objects/SkinnedMesh.js +102 -6
- package/src/objects/Sprite.js +65 -1
- package/src/renderers/WebGL3DRenderTarget.js +26 -0
- package/src/renderers/WebGLArrayRenderTarget.js +26 -0
- package/src/renderers/WebGLCubeRenderTarget.js +41 -5
- package/src/renderers/WebGLRenderTarget.js +19 -0
- package/src/renderers/WebGLRenderer.js +1016 -278
- package/src/renderers/common/Animation.js +123 -14
- package/src/renderers/common/Attributes.js +41 -1
- package/src/renderers/common/Backend.js +623 -44
- package/src/renderers/common/Background.js +99 -16
- package/src/renderers/common/BindGroup.js +37 -2
- package/src/renderers/common/Binding.js +46 -0
- package/src/renderers/common/Bindings.js +211 -20
- package/src/renderers/common/BlendMode.js +143 -0
- package/src/renderers/common/Buffer.js +89 -0
- package/src/renderers/common/BufferUtils.js +25 -0
- package/src/renderers/common/BundleGroup.js +57 -0
- package/src/renderers/common/CanvasTarget.js +341 -0
- package/src/renderers/common/ChainMap.js +73 -10
- package/src/renderers/common/ClippingContext.js +172 -87
- package/src/renderers/common/Color4.js +40 -0
- package/src/renderers/common/ComputePipeline.js +24 -0
- package/src/renderers/common/Constants.js +2 -1
- package/src/renderers/common/CubeRenderTarget.js +77 -7
- package/src/renderers/common/DataMap.js +37 -1
- package/src/renderers/common/Geometries.js +163 -14
- package/src/renderers/common/IndirectStorageBufferAttribute.js +38 -0
- package/src/renderers/common/Info.js +81 -36
- package/src/renderers/common/InspectorBase.js +146 -0
- package/src/renderers/common/Lighting.js +57 -0
- package/src/renderers/common/Pipeline.js +22 -0
- package/src/renderers/common/Pipelines.js +150 -7
- package/src/renderers/common/PostProcessing.js +22 -84
- package/src/renderers/common/ProgrammableStage.js +60 -2
- package/src/renderers/common/QuadMesh.js +63 -6
- package/src/renderers/common/RenderBundle.js +14 -8
- package/src/renderers/common/RenderBundles.js +40 -10
- package/src/renderers/common/RenderContext.js +219 -4
- package/src/renderers/common/RenderContexts.js +54 -17
- package/src/renderers/common/RenderList.js +233 -24
- package/src/renderers/common/RenderLists.js +46 -6
- package/src/renderers/common/RenderObject.js +548 -46
- package/src/renderers/common/RenderObjectPipeline.js +40 -0
- package/src/renderers/common/RenderObjects.js +133 -15
- package/src/renderers/common/RenderPipeline.js +216 -6
- package/src/renderers/common/Renderer.js +2155 -332
- package/src/renderers/common/RendererUtils.js +200 -0
- package/src/renderers/common/SampledTexture.js +99 -39
- package/src/renderers/common/Sampler.js +148 -1
- package/src/renderers/common/Storage3DTexture.js +100 -0
- package/src/renderers/common/StorageArrayTexture.js +84 -0
- package/src/renderers/common/StorageBuffer.js +38 -2
- package/src/renderers/common/StorageBufferAttribute.js +31 -2
- package/src/renderers/common/StorageInstancedBufferAttribute.js +31 -2
- package/src/renderers/common/StorageTexture.js +65 -0
- package/src/renderers/common/Textures.js +273 -57
- package/src/renderers/common/TimestampQueryPool.js +163 -0
- package/src/renderers/common/Uniform.js +233 -3
- package/src/renderers/common/UniformBuffer.js +19 -0
- package/src/renderers/common/UniformsGroup.js +235 -26
- package/src/renderers/common/XRManager.js +1677 -0
- package/src/renderers/common/XRRenderTarget.js +91 -0
- package/src/renderers/common/extras/PMREMGenerator.js +371 -108
- package/src/renderers/common/nodes/NodeBuilderState.js +100 -6
- package/src/renderers/common/nodes/NodeLibrary.js +95 -17
- package/src/renderers/common/nodes/NodeManager.js +852 -0
- package/src/renderers/common/nodes/NodeSampledTexture.js +84 -8
- package/src/renderers/common/nodes/NodeSampler.js +41 -1
- package/src/renderers/common/nodes/NodeStorageBuffer.js +48 -3
- package/src/renderers/common/nodes/NodeUniform.js +285 -2
- package/src/renderers/common/nodes/NodeUniformBuffer.js +81 -0
- package/src/renderers/common/nodes/NodeUniformsGroup.js +31 -18
- package/src/renderers/shaders/DFGLUTData.js +49 -0
- 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/colorspace_pars_fragment.glsl.js +4 -24
- package/src/renderers/shaders/ShaderChunk/common.glsl.js +0 -12
- package/src/renderers/shaders/ShaderChunk/emissivemap_fragment.glsl.js +8 -0
- package/src/renderers/shaders/ShaderChunk/envmap_common_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +7 -11
- package/src/renderers/shaders/ShaderChunk/envmap_physical_pars_fragment.glsl.js +1 -1
- 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 +154 -59
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/map_fragment.glsl.js +2 -2
- package/src/renderers/shaders/ShaderChunk/packing.glsl.js +20 -4
- package/src/renderers/shaders/ShaderChunk/premultiplied_alpha_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +230 -181
- 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/transmission_pars_fragment.glsl.js +7 -7
- package/src/renderers/shaders/ShaderChunk.js +3 -3
- package/src/renderers/shaders/ShaderLib/background.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/depth.glsl.js +14 -2
- 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 +2 -7
- package/src/renderers/shaders/UniformsUtils.js +21 -2
- package/src/renderers/webgl/WebGLAttributes.js +4 -0
- package/src/renderers/webgl/WebGLBackground.js +30 -5
- package/src/renderers/webgl/WebGLBindingStates.js +99 -27
- package/src/renderers/webgl/WebGLBufferRenderer.js +2 -6
- package/src/renderers/webgl/WebGLCapabilities.js +7 -14
- package/src/renderers/webgl/WebGLEnvironments.js +228 -0
- package/src/renderers/webgl/WebGLExtensions.js +2 -25
- package/src/renderers/webgl/WebGLGeometries.js +10 -35
- package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +2 -6
- package/src/renderers/webgl/WebGLInfo.js +3 -1
- 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 +87 -148
- package/src/renderers/webgl/WebGLPrograms.js +53 -51
- package/src/renderers/webgl/WebGLRenderLists.js +15 -0
- package/src/renderers/webgl/WebGLShadowMap.js +204 -28
- package/src/renderers/webgl/WebGLState.js +88 -56
- package/src/renderers/webgl/WebGLTextures.js +293 -59
- package/src/renderers/webgl/WebGLUniforms.js +40 -3
- package/src/renderers/webgl/WebGLUniformsGroups.js +5 -3
- package/src/renderers/webgl/WebGLUtils.js +7 -5
- package/src/renderers/webgl-fallback/WebGLBackend.js +1416 -293
- package/src/renderers/webgl-fallback/WebGLBufferRenderer.js +5 -10
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +785 -92
- package/src/renderers/webgl-fallback/utils/WebGLAttributeUtils.js +62 -1
- package/src/renderers/webgl-fallback/utils/WebGLCapabilities.js +28 -0
- package/src/renderers/webgl-fallback/utils/WebGLConstants.js +3 -3
- package/src/renderers/webgl-fallback/utils/WebGLExtensions.js +45 -0
- package/src/renderers/webgl-fallback/utils/WebGLState.js +584 -20
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +468 -80
- package/src/renderers/webgl-fallback/utils/WebGLTimestampQueryPool.js +396 -0
- package/src/renderers/webgl-fallback/utils/WebGLUtils.js +72 -24
- package/src/renderers/webgpu/WebGPUBackend.js +1517 -428
- package/src/renderers/webgpu/WebGPURenderer.Nodes.js +31 -4
- package/src/renderers/webgpu/WebGPURenderer.js +55 -4
- package/src/renderers/webgpu/nodes/BasicNodeLibrary.js +23 -16
- package/src/renderers/webgpu/nodes/StandardNodeLibrary.js +37 -42
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +1335 -241
- package/src/renderers/webgpu/nodes/WGSLNodeFunction.js +32 -4
- package/src/renderers/webgpu/nodes/WGSLNodeParser.js +11 -0
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +144 -20
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +460 -116
- package/src/renderers/webgpu/utils/WebGPUConstants.js +17 -4
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +283 -69
- package/src/renderers/webgpu/utils/WebGPUTexturePassUtils.js +225 -178
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +583 -191
- package/src/renderers/webgpu/utils/WebGPUTimestampQueryPool.js +310 -0
- package/src/renderers/webgpu/utils/WebGPUUtils.js +150 -28
- package/src/renderers/webxr/WebXRController.js +87 -2
- package/src/renderers/webxr/WebXRDepthSensing.js +52 -7
- package/src/renderers/webxr/WebXRManager.js +275 -15
- package/src/scenes/Fog.js +60 -0
- package/src/scenes/FogExp2.js +51 -0
- package/src/scenes/Scene.js +88 -0
- package/src/textures/CanvasTexture.js +28 -0
- package/src/textures/CompressedArrayTexture.js +57 -0
- package/src/textures/CompressedCubeTexture.js +29 -0
- package/src/textures/CompressedTexture.js +64 -6
- package/src/textures/CubeDepthTexture.js +76 -0
- package/src/textures/CubeTexture.js +52 -4
- package/src/textures/Data3DTexture.js +79 -2
- package/src/textures/DataArrayTexture.js +93 -0
- package/src/textures/DataTexture.js +65 -0
- package/src/textures/DepthTexture.js +59 -11
- package/src/textures/ExternalTexture.js +56 -0
- package/src/textures/FramebufferTexture.js +62 -0
- package/src/textures/Source.js +106 -4
- package/src/textures/Texture.js +488 -6
- package/src/textures/VideoFrameTexture.js +72 -0
- package/src/textures/VideoTexture.js +78 -6
- package/src/utils.js +322 -3
- package/examples/jsm/animation/MMDAnimationHelper.js +0 -1207
- package/examples/jsm/animation/MMDPhysics.js +0 -1406
- package/examples/jsm/cameras/CinematicCamera.js +0 -208
- package/examples/jsm/effects/PeppersGhostEffect.js +0 -153
- package/examples/jsm/exporters/MMDExporter.js +0 -217
- package/examples/jsm/geometries/InstancedPointsGeometry.js +0 -174
- package/examples/jsm/geometries/ParametricGeometries.js +0 -254
- package/examples/jsm/libs/mmdparser.module.js +0 -11530
- package/examples/jsm/loaders/GLTFLoaderAnimationPointer.js +0 -729
- package/examples/jsm/loaders/MMDLoader.js +0 -2295
- package/examples/jsm/loaders/RGBMLoader.js +0 -1081
- package/examples/jsm/materials/MeshGouraudMaterial.js +0 -432
- package/examples/jsm/materials/MeshPostProcessingMaterial.js +0 -144
- package/examples/jsm/misc/Timer.js +0 -128
- package/examples/jsm/objects/InstancedPoints.js +0 -21
- package/examples/jsm/shaders/GodRaysShader.js +0 -321
- package/examples/jsm/shaders/MMDToonShader.js +0 -134
- package/src/materials/nodes/InstancedPointsNodeMaterial.js +0 -156
- package/src/nodes/accessors/InstancedPointsMaterialNode.js +0 -24
- package/src/nodes/accessors/SceneNode.js +0 -55
- package/src/nodes/code/ScriptableNode.js +0 -505
- package/src/nodes/code/ScriptableValueNode.js +0 -170
- package/src/nodes/core/CacheNode.js +0 -50
- package/src/nodes/core/UniformGroup.js +0 -13
- package/src/nodes/display/AfterImageNode.js +0 -158
- package/src/nodes/display/AnaglyphPassNode.js +0 -67
- package/src/nodes/display/AnamorphicNode.js +0 -151
- package/src/nodes/display/BlendMode.js +0 -54
- package/src/nodes/display/BloomNode.js +0 -341
- package/src/nodes/display/DenoiseNode.js +0 -204
- package/src/nodes/display/DepthOfFieldNode.js +0 -124
- package/src/nodes/display/DotScreenNode.js +0 -66
- package/src/nodes/display/FXAANode.js +0 -332
- package/src/nodes/display/FilmNode.js +0 -56
- package/src/nodes/display/GTAONode.js +0 -331
- package/src/nodes/display/GaussianBlurNode.js +0 -213
- package/src/nodes/display/Lut3DNode.js +0 -57
- package/src/nodes/display/MotionBlur.js +0 -25
- package/src/nodes/display/ParallaxBarrierPassNode.js +0 -58
- package/src/nodes/display/PixelationPassNode.js +0 -213
- package/src/nodes/display/PosterizeNode.js +0 -33
- package/src/nodes/display/RGBShiftNode.js +0 -53
- package/src/nodes/display/StereoCompositePassNode.js +0 -110
- package/src/nodes/display/TransitionNode.js +0 -80
- package/src/nodes/fog/FogExp2Node.js +0 -35
- package/src/nodes/fog/FogNode.js +0 -50
- package/src/nodes/fog/FogRangeNode.js +0 -36
- package/src/nodes/functions/BSDF/DFGApprox.js +0 -30
- package/src/nodes/utils/EquirectUVNode.js +0 -36
- package/src/nodes/utils/MatcapUVNode.js +0 -33
- package/src/nodes/utils/OscNode.js +0 -85
- package/src/nodes/utils/SpriteSheetUVNode.js +0 -45
- package/src/nodes/utils/TimerNode.js +0 -97
- package/src/nodes/utils/TriplanarTexturesNode.js +0 -64
- package/src/renderers/common/nodes/Nodes.js +0 -534
- package/src/renderers/webgl/WebGLCubeMaps.js +0 -99
- package/src/renderers/webgl/WebGLCubeUVMaps.js +0 -136
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GLSLNodeParser, NodeBuilder, TextureNode, vectorComponents } from '../../../nodes/Nodes.js';
|
|
1
|
+
import { GLSLNodeParser, NodeBuilder, TextureNode, vectorComponents, CodeNode } from '../../../nodes/Nodes.js';
|
|
2
2
|
|
|
3
3
|
import NodeUniformBuffer from '../../common/nodes/NodeUniformBuffer.js';
|
|
4
4
|
import NodeUniformsGroup from '../../common/nodes/NodeUniformsGroup.js';
|
|
@@ -7,11 +7,28 @@ import { NodeSampledTexture, NodeSampledCubeTexture, NodeSampledTexture3D } from
|
|
|
7
7
|
|
|
8
8
|
import { NoColorSpace, ByteType, ShortType, RGBAIntegerFormat, RGBIntegerFormat, RedIntegerFormat, RGIntegerFormat, UnsignedByteType, UnsignedIntType, UnsignedShortType, RedFormat, RGFormat, IntType, RGBFormat, RGBAFormat, FloatType } from '../../../constants.js';
|
|
9
9
|
import { DataTexture } from '../../../textures/DataTexture.js';
|
|
10
|
+
import { error } from '../../../utils.js';
|
|
11
|
+
|
|
12
|
+
const glslPolyfills = {
|
|
13
|
+
bitcast_int_uint: new CodeNode( /* glsl */'uint tsl_bitcast_int_to_uint ( int x ) { return floatBitsToUint( intBitsToFloat ( x ) ); }' ),
|
|
14
|
+
bitcast_uint_int: new CodeNode( /* glsl */'uint tsl_bitcast_uint_to_int ( uint x ) { return floatBitsToInt( uintBitsToFloat ( x ) ); }' )
|
|
15
|
+
};
|
|
10
16
|
|
|
11
17
|
const glslMethods = {
|
|
12
|
-
atan2: 'atan',
|
|
13
18
|
textureDimensions: 'textureSize',
|
|
14
|
-
equals: 'equal'
|
|
19
|
+
equals: 'equal',
|
|
20
|
+
bitcast_float_int: 'floatBitsToInt',
|
|
21
|
+
bitcast_int_float: 'intBitsToFloat',
|
|
22
|
+
bitcast_uint_float: 'uintBitsToFloat',
|
|
23
|
+
bitcast_float_uint: 'floatBitsToUint',
|
|
24
|
+
bitcast_uint_int: 'tsl_bitcast_uint_to_int',
|
|
25
|
+
bitcast_int_uint: 'tsl_bitcast_int_to_uint',
|
|
26
|
+
floatpack_snorm_2x16: 'packSnorm2x16',
|
|
27
|
+
floatpack_unorm_2x16: 'packUnorm2x16',
|
|
28
|
+
floatpack_float16_2x16: 'packHalf2x16',
|
|
29
|
+
floatunpack_snorm_2x16: 'unpackSnorm2x16',
|
|
30
|
+
floatunpack_unorm_2x16: 'unpackUnorm2x16',
|
|
31
|
+
floatunpack_float16_2x16: 'unpackHalf2x16'
|
|
15
32
|
};
|
|
16
33
|
|
|
17
34
|
const precisionLib = {
|
|
@@ -25,6 +42,15 @@ const supports = {
|
|
|
25
42
|
storageBuffer: false
|
|
26
43
|
};
|
|
27
44
|
|
|
45
|
+
const interpolationTypeMap = {
|
|
46
|
+
perspective: 'smooth',
|
|
47
|
+
linear: 'noperspective'
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const interpolationModeMap = {
|
|
51
|
+
'centroid': 'centroid'
|
|
52
|
+
};
|
|
53
|
+
|
|
28
54
|
const defaultPrecisions = `
|
|
29
55
|
precision highp float;
|
|
30
56
|
precision highp int;
|
|
@@ -43,41 +69,182 @@ precision highp isampler3D;
|
|
|
43
69
|
precision highp isamplerCube;
|
|
44
70
|
precision highp isampler2DArray;
|
|
45
71
|
|
|
46
|
-
precision
|
|
72
|
+
precision highp sampler2DShadow;
|
|
73
|
+
precision highp sampler2DArrayShadow;
|
|
74
|
+
precision highp samplerCubeShadow;
|
|
47
75
|
`;
|
|
48
76
|
|
|
77
|
+
/**
|
|
78
|
+
* A node builder targeting GLSL.
|
|
79
|
+
*
|
|
80
|
+
* This module generates GLSL shader code from node materials and also
|
|
81
|
+
* generates the respective bindings and vertex buffer definitions. These
|
|
82
|
+
* data are later used by the renderer to create render and compute pipelines
|
|
83
|
+
* for render objects.
|
|
84
|
+
*
|
|
85
|
+
* @augments NodeBuilder
|
|
86
|
+
*/
|
|
49
87
|
class GLSLNodeBuilder extends NodeBuilder {
|
|
50
88
|
|
|
89
|
+
/**
|
|
90
|
+
* Constructs a new GLSL node builder renderer.
|
|
91
|
+
*
|
|
92
|
+
* @param {Object3D} object - The 3D object.
|
|
93
|
+
* @param {Renderer} renderer - The renderer.
|
|
94
|
+
*/
|
|
51
95
|
constructor( object, renderer ) {
|
|
52
96
|
|
|
53
97
|
super( object, renderer, new GLSLNodeParser() );
|
|
54
98
|
|
|
99
|
+
/**
|
|
100
|
+
* A dictionary holds for each shader stage ('vertex', 'fragment', 'compute')
|
|
101
|
+
* another dictionary which manages UBOs per group ('render','frame','object').
|
|
102
|
+
*
|
|
103
|
+
* @type {Object<string,Object<string,NodeUniformsGroup>>}
|
|
104
|
+
*/
|
|
55
105
|
this.uniformGroups = {};
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* An array that holds objects defining the varying and attribute data in
|
|
109
|
+
* context of Transform Feedback.
|
|
110
|
+
*
|
|
111
|
+
* @type {Array<Object<string,AttributeNode|string>>}
|
|
112
|
+
*/
|
|
56
113
|
this.transforms = [];
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* A dictionary that holds for each shader stage a Map of used extensions.
|
|
117
|
+
*
|
|
118
|
+
* @type {Object<string,Map<string,Object>>}
|
|
119
|
+
*/
|
|
57
120
|
this.extensions = {};
|
|
58
121
|
|
|
59
|
-
|
|
122
|
+
/**
|
|
123
|
+
* A dictionary that holds for each shader stage an Array of used builtins.
|
|
124
|
+
*
|
|
125
|
+
* @type {Object<string,Array<string>>}
|
|
126
|
+
*/
|
|
127
|
+
this.builtins = { vertex: [], fragment: [], compute: [] };
|
|
60
128
|
|
|
61
129
|
}
|
|
62
130
|
|
|
63
|
-
|
|
131
|
+
/**
|
|
132
|
+
* Checks if the given texture requires a manual conversion to the working color space.
|
|
133
|
+
*
|
|
134
|
+
* @param {Texture} texture - The texture to check.
|
|
135
|
+
* @return {boolean} Whether the given texture requires a conversion to working color space or not.
|
|
136
|
+
*/
|
|
137
|
+
needsToWorkingColorSpace( texture ) {
|
|
64
138
|
|
|
65
139
|
return texture.isVideoTexture === true && texture.colorSpace !== NoColorSpace;
|
|
66
140
|
|
|
67
141
|
}
|
|
68
142
|
|
|
143
|
+
/**
|
|
144
|
+
* Includes the given method name into the current
|
|
145
|
+
* function node.
|
|
146
|
+
*
|
|
147
|
+
* @private
|
|
148
|
+
* @param {string} name - The method name to include.
|
|
149
|
+
* @return {CodeNode} The respective code node.
|
|
150
|
+
*/
|
|
151
|
+
_include( name ) {
|
|
152
|
+
|
|
153
|
+
const codeNode = glslPolyfills[ name ];
|
|
154
|
+
codeNode.build( this );
|
|
155
|
+
|
|
156
|
+
this.addInclude( codeNode );
|
|
157
|
+
|
|
158
|
+
return codeNode;
|
|
159
|
+
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Returns the native shader method name for a given generic name.
|
|
164
|
+
*
|
|
165
|
+
* @param {string} method - The method name to resolve.
|
|
166
|
+
* @return {string} The resolved GLSL method name.
|
|
167
|
+
*/
|
|
69
168
|
getMethod( method ) {
|
|
70
169
|
|
|
170
|
+
if ( glslPolyfills[ method ] !== undefined ) {
|
|
171
|
+
|
|
172
|
+
this._include( method );
|
|
173
|
+
|
|
174
|
+
}
|
|
175
|
+
|
|
71
176
|
return glslMethods[ method ] || method;
|
|
72
177
|
|
|
73
178
|
}
|
|
74
179
|
|
|
180
|
+
/**
|
|
181
|
+
* Returns the bitcast method name for a given input and outputType.
|
|
182
|
+
*
|
|
183
|
+
* @param {string} type - The output type to bitcast to.
|
|
184
|
+
* @param {string} inputType - The input type of the.
|
|
185
|
+
* @return {string} The resolved WGSL bitcast invocation.
|
|
186
|
+
*/
|
|
187
|
+
getBitcastMethod( type, inputType ) {
|
|
188
|
+
|
|
189
|
+
return this.getMethod( `bitcast_${ inputType }_${ type }` );
|
|
190
|
+
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Returns the float packing method name for a given numeric encoding.
|
|
195
|
+
*
|
|
196
|
+
* @param {string} encoding - The numeric encoding that describes how the float values are mapped to the integer range.
|
|
197
|
+
* @returns {string} The resolved GLSL float packing method name.
|
|
198
|
+
*/
|
|
199
|
+
getFloatPackingMethod( encoding ) {
|
|
200
|
+
|
|
201
|
+
return this.getMethod( `floatpack_${ encoding }_2x16` );
|
|
202
|
+
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Returns the float unpacking method name for a given numeric encoding.
|
|
207
|
+
*
|
|
208
|
+
* @param {string} encoding - The numeric encoding that describes how the integer values are mapped to the float range.
|
|
209
|
+
* @returns {string} The resolved GLSL float unpacking method name.
|
|
210
|
+
*/
|
|
211
|
+
getFloatUnpackingMethod( encoding ) {
|
|
212
|
+
|
|
213
|
+
return this.getMethod( `floatunpack_${ encoding }_2x16` );
|
|
214
|
+
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Returns the native snippet for a ternary operation.
|
|
219
|
+
*
|
|
220
|
+
* @param {string} condSnippet - The condition determining which expression gets resolved.
|
|
221
|
+
* @param {string} ifSnippet - The expression to resolve to if the condition is true.
|
|
222
|
+
* @param {string} elseSnippet - The expression to resolve to if the condition is false.
|
|
223
|
+
* @return {string} The resolved method name.
|
|
224
|
+
*/
|
|
225
|
+
getTernary( condSnippet, ifSnippet, elseSnippet ) {
|
|
226
|
+
|
|
227
|
+
return `${condSnippet} ? ${ifSnippet} : ${elseSnippet}`;
|
|
228
|
+
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Returns the output struct name. Not relevant for GLSL.
|
|
233
|
+
*
|
|
234
|
+
* @return {string}
|
|
235
|
+
*/
|
|
75
236
|
getOutputStructName() {
|
|
76
237
|
|
|
77
238
|
return '';
|
|
78
239
|
|
|
79
240
|
}
|
|
80
241
|
|
|
242
|
+
/**
|
|
243
|
+
* Builds the given shader node.
|
|
244
|
+
*
|
|
245
|
+
* @param {ShaderNodeInternal} shaderNode - The shader node.
|
|
246
|
+
* @return {string} The GLSL function code.
|
|
247
|
+
*/
|
|
81
248
|
buildFunctionCode( shaderNode ) {
|
|
82
249
|
|
|
83
250
|
const layout = shaderNode.layout;
|
|
@@ -108,6 +275,12 @@ ${ flowData.code }
|
|
|
108
275
|
|
|
109
276
|
}
|
|
110
277
|
|
|
278
|
+
/**
|
|
279
|
+
* Setups the Pixel Buffer Object (PBO) for the given storage
|
|
280
|
+
* buffer node.
|
|
281
|
+
*
|
|
282
|
+
* @param {StorageBufferNode} storageBufferNode - The storage buffer node.
|
|
283
|
+
*/
|
|
111
284
|
setupPBO( storageBufferNode ) {
|
|
112
285
|
|
|
113
286
|
const attribute = storageBufferNode.value;
|
|
@@ -123,7 +296,6 @@ ${ flowData.code }
|
|
|
123
296
|
|
|
124
297
|
let format = isInteger ? RedIntegerFormat : RedFormat;
|
|
125
298
|
|
|
126
|
-
|
|
127
299
|
if ( itemSize === 2 ) {
|
|
128
300
|
|
|
129
301
|
format = isInteger ? RGIntegerFormat : RGFormat;
|
|
@@ -171,17 +343,24 @@ ${ flowData.code }
|
|
|
171
343
|
attribute.pboNode = pbo;
|
|
172
344
|
attribute.pbo = pbo.value;
|
|
173
345
|
|
|
174
|
-
this.getUniformFromNode( attribute.pboNode, 'texture', this.shaderStage, this.context.
|
|
346
|
+
this.getUniformFromNode( attribute.pboNode, 'texture', this.shaderStage, this.context.nodeName );
|
|
175
347
|
|
|
176
348
|
}
|
|
177
349
|
|
|
178
350
|
}
|
|
179
351
|
|
|
352
|
+
/**
|
|
353
|
+
* Returns a GLSL snippet that represents the property name of the given node.
|
|
354
|
+
*
|
|
355
|
+
* @param {Node} node - The node.
|
|
356
|
+
* @param {string} [shaderStage=this.shaderStage] - The shader stage this code snippet is generated for.
|
|
357
|
+
* @return {string} The property name.
|
|
358
|
+
*/
|
|
180
359
|
getPropertyName( node, shaderStage = this.shaderStage ) {
|
|
181
360
|
|
|
182
361
|
if ( node.isNodeUniform && node.node.isTextureNode !== true && node.node.isBufferNode !== true ) {
|
|
183
362
|
|
|
184
|
-
return
|
|
363
|
+
return node.name;
|
|
185
364
|
|
|
186
365
|
}
|
|
187
366
|
|
|
@@ -189,6 +368,13 @@ ${ flowData.code }
|
|
|
189
368
|
|
|
190
369
|
}
|
|
191
370
|
|
|
371
|
+
/**
|
|
372
|
+
* Setups the Pixel Buffer Object (PBO) for the given storage
|
|
373
|
+
* buffer node.
|
|
374
|
+
*
|
|
375
|
+
* @param {StorageArrayElementNode} storageArrayElementNode - The storage array element node.
|
|
376
|
+
* @return {string} The property name.
|
|
377
|
+
*/
|
|
192
378
|
generatePBO( storageArrayElementNode ) {
|
|
193
379
|
|
|
194
380
|
const { node, indexNode } = storageArrayElementNode;
|
|
@@ -201,8 +387,7 @@ ${ flowData.code }
|
|
|
201
387
|
|
|
202
388
|
}
|
|
203
389
|
|
|
204
|
-
|
|
205
|
-
const nodeUniform = this.getUniformFromNode( attribute.pboNode, 'texture', this.shaderStage, this.context.label );
|
|
390
|
+
const nodeUniform = this.getUniformFromNode( attribute.pboNode, 'texture', this.shaderStage, this.context.nodeName );
|
|
206
391
|
const textureName = this.getPropertyName( nodeUniform );
|
|
207
392
|
|
|
208
393
|
this.increaseUsage( indexNode ); // force cache generate to be used as index in x,y
|
|
@@ -245,7 +430,7 @@ ${ flowData.code }
|
|
|
245
430
|
const channel = '.' + vectorComponents.join( '' ).slice( 0, itemSize );
|
|
246
431
|
const uvSnippet = `ivec2(${indexSnippet} % ${ propertySizeName }, ${indexSnippet} / ${ propertySizeName })`;
|
|
247
432
|
|
|
248
|
-
const snippet = this.generateTextureLoad( null, textureName, uvSnippet,
|
|
433
|
+
const snippet = this.generateTextureLoad( null, textureName, uvSnippet, '0', null, null );
|
|
249
434
|
|
|
250
435
|
//
|
|
251
436
|
|
|
@@ -272,68 +457,220 @@ ${ flowData.code }
|
|
|
272
457
|
|
|
273
458
|
}
|
|
274
459
|
|
|
275
|
-
|
|
460
|
+
/**
|
|
461
|
+
* Generates the GLSL snippet that reads a single texel from a texture without sampling or filtering.
|
|
462
|
+
*
|
|
463
|
+
* @param {?Texture} texture - The texture.
|
|
464
|
+
* @param {string} textureProperty - The name of the texture uniform in the shader.
|
|
465
|
+
* @param {string} uvIndexSnippet - A GLSL snippet that represents texture coordinates used for sampling.
|
|
466
|
+
* @param {?string} levelSnippet - A GLSL snippet that represents the mip level, with level 0 containing a full size version of the texture.
|
|
467
|
+
* @param {?string} depthSnippet - A GLSL snippet that represents the 0-based texture array index to sample.
|
|
468
|
+
* @param {?string} offsetSnippet - A GLSL snippet that represents the offset that will be applied to the unnormalized texture coordinate before sampling the texture.
|
|
469
|
+
* @return {string} The GLSL snippet.
|
|
470
|
+
*/
|
|
471
|
+
generateTextureLoad( texture, textureProperty, uvIndexSnippet, levelSnippet, depthSnippet, offsetSnippet ) {
|
|
472
|
+
|
|
473
|
+
if ( levelSnippet === null ) levelSnippet = '0';
|
|
474
|
+
|
|
475
|
+
let snippet;
|
|
276
476
|
|
|
277
477
|
if ( depthSnippet ) {
|
|
278
478
|
|
|
279
|
-
|
|
479
|
+
if ( offsetSnippet ) {
|
|
480
|
+
|
|
481
|
+
snippet = `texelFetchOffset( ${ textureProperty }, ivec3( ${ uvIndexSnippet }, ${ depthSnippet } ), ${ levelSnippet }, ${ offsetSnippet } )`;
|
|
482
|
+
|
|
483
|
+
} else {
|
|
484
|
+
|
|
485
|
+
snippet = `texelFetch( ${ textureProperty }, ivec3( ${ uvIndexSnippet }, ${ depthSnippet } ), ${ levelSnippet } )`;
|
|
486
|
+
|
|
487
|
+
}
|
|
280
488
|
|
|
281
489
|
} else {
|
|
282
490
|
|
|
283
|
-
|
|
491
|
+
if ( offsetSnippet ) {
|
|
492
|
+
|
|
493
|
+
snippet = `texelFetchOffset( ${ textureProperty }, ${ uvIndexSnippet }, ${ levelSnippet }, ${ offsetSnippet } )`;
|
|
494
|
+
|
|
495
|
+
} else {
|
|
496
|
+
|
|
497
|
+
snippet = `texelFetch( ${ textureProperty }, ${ uvIndexSnippet }, ${ levelSnippet } )`;
|
|
498
|
+
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
if ( texture !== null && texture.isDepthTexture ) {
|
|
504
|
+
|
|
505
|
+
snippet += '.x';
|
|
284
506
|
|
|
285
507
|
}
|
|
286
508
|
|
|
509
|
+
return snippet;
|
|
510
|
+
|
|
287
511
|
}
|
|
288
512
|
|
|
289
|
-
|
|
513
|
+
/**
|
|
514
|
+
* Generates the GLSL snippet for sampling/loading the given texture.
|
|
515
|
+
*
|
|
516
|
+
* @param {Texture} texture - The texture.
|
|
517
|
+
* @param {string} textureProperty - The name of the texture uniform in the shader.
|
|
518
|
+
* @param {string} uvSnippet - A GLSL snippet that represents texture coordinates used for sampling.
|
|
519
|
+
* @param {?string} depthSnippet - A GLSL snippet that represents the 0-based texture array index to sample.
|
|
520
|
+
* @param {?string} offsetSnippet - A GLSL snippet that represents the offset that will be applied to the unnormalized texture coordinate before sampling the texture.
|
|
521
|
+
* @return {string} The GLSL snippet.
|
|
522
|
+
*/
|
|
523
|
+
generateTexture( texture, textureProperty, uvSnippet, depthSnippet, offsetSnippet ) {
|
|
524
|
+
|
|
525
|
+
if ( depthSnippet ) uvSnippet = `vec3( ${ uvSnippet }, ${ depthSnippet } )`;
|
|
290
526
|
|
|
291
527
|
if ( texture.isDepthTexture ) {
|
|
292
528
|
|
|
293
|
-
return `
|
|
529
|
+
if ( offsetSnippet ) return `textureOffset( ${ textureProperty }, ${ uvSnippet }, ${ offsetSnippet } ).x`;
|
|
294
530
|
|
|
295
|
-
|
|
531
|
+
return `texture( ${ textureProperty }, ${ uvSnippet } ).x`;
|
|
296
532
|
|
|
297
|
-
|
|
533
|
+
}
|
|
298
534
|
|
|
299
|
-
|
|
535
|
+
if ( offsetSnippet ) return `textureOffset( ${ textureProperty }, ${ uvSnippet }, ${ offsetSnippet } )`;
|
|
300
536
|
|
|
301
|
-
}
|
|
537
|
+
return `texture( ${ textureProperty }, ${ uvSnippet } )`;
|
|
302
538
|
|
|
303
539
|
}
|
|
304
540
|
|
|
305
|
-
|
|
541
|
+
/**
|
|
542
|
+
* Generates the GLSL snippet when sampling textures with explicit mip level.
|
|
543
|
+
*
|
|
544
|
+
* @param {Texture} texture - The texture.
|
|
545
|
+
* @param {string} textureProperty - The name of the texture uniform in the shader.
|
|
546
|
+
* @param {string} uvSnippet - A GLSL snippet that represents texture coordinates used for sampling.
|
|
547
|
+
* @param {string} levelSnippet - A GLSL snippet that represents the mip level, with level 0 containing a full size version of the texture.
|
|
548
|
+
* @param {?string} depthSnippet - A GLSL snippet that represents 0-based texture array index to sample.
|
|
549
|
+
* @param {?string} offsetSnippet - A GLSL snippet that represents the offset that will be applied to the unnormalized texture coordinate before sampling the texture.
|
|
550
|
+
* @return {string} The GLSL snippet.
|
|
551
|
+
*/
|
|
552
|
+
generateTextureLevel( texture, textureProperty, uvSnippet, levelSnippet, depthSnippet, offsetSnippet ) {
|
|
553
|
+
|
|
554
|
+
if ( depthSnippet ) uvSnippet = `vec3( ${ uvSnippet }, ${ depthSnippet } )`;
|
|
555
|
+
|
|
556
|
+
if ( offsetSnippet ) {
|
|
557
|
+
|
|
558
|
+
return `textureLodOffset( ${ textureProperty }, ${ uvSnippet }, ${ levelSnippet }, ${ offsetSnippet } )`;
|
|
559
|
+
|
|
560
|
+
}
|
|
306
561
|
|
|
307
562
|
return `textureLod( ${ textureProperty }, ${ uvSnippet }, ${ levelSnippet } )`;
|
|
308
563
|
|
|
309
564
|
}
|
|
310
565
|
|
|
311
|
-
|
|
566
|
+
/**
|
|
567
|
+
* Generates the GLSL snippet when sampling textures with a bias to the mip level.
|
|
568
|
+
*
|
|
569
|
+
* @param {Texture} texture - The texture.
|
|
570
|
+
* @param {string} textureProperty - The name of the texture uniform in the shader.
|
|
571
|
+
* @param {string} uvSnippet - A GLSL snippet that represents texture coordinates used for sampling.
|
|
572
|
+
* @param {string} biasSnippet - A GLSL snippet that represents the bias to apply to the mip level before sampling.
|
|
573
|
+
* @param {?string} depthSnippet - A GLSL snippet that represents 0-based texture array index to sample.
|
|
574
|
+
* @param {?string} offsetSnippet - A GLSL snippet that represents the offset that will be applied to the unnormalized texture coordinate before sampling the texture.
|
|
575
|
+
* @return {string} The GLSL snippet.
|
|
576
|
+
*/
|
|
577
|
+
generateTextureBias( texture, textureProperty, uvSnippet, biasSnippet, depthSnippet, offsetSnippet ) {
|
|
578
|
+
|
|
579
|
+
if ( depthSnippet ) uvSnippet = `vec3( ${ uvSnippet }, ${ depthSnippet } )`;
|
|
580
|
+
|
|
581
|
+
if ( offsetSnippet ) {
|
|
582
|
+
|
|
583
|
+
return `textureOffset( ${ textureProperty }, ${ uvSnippet }, ${ offsetSnippet }, ${ biasSnippet } )`;
|
|
584
|
+
|
|
585
|
+
}
|
|
312
586
|
|
|
313
587
|
return `texture( ${ textureProperty }, ${ uvSnippet }, ${ biasSnippet } )`;
|
|
314
588
|
|
|
315
589
|
}
|
|
316
590
|
|
|
317
|
-
|
|
591
|
+
/**
|
|
592
|
+
* Generates the GLSL snippet for sampling/loading the given texture using explicit gradients.
|
|
593
|
+
*
|
|
594
|
+
* @param {Texture} texture - The texture.
|
|
595
|
+
* @param {string} textureProperty - The name of the texture uniform in the shader.
|
|
596
|
+
* @param {string} uvSnippet - A GLSL snippet that represents texture coordinates used for sampling.
|
|
597
|
+
* @param {Array<string>} gradSnippet - An array holding both gradient GLSL snippets.
|
|
598
|
+
* @param {?string} depthSnippet - A GLSL snippet that represents 0-based texture array index to sample.
|
|
599
|
+
* @param {?string} offsetSnippet - A GLSL snippet that represents the offset that will be applied to the unnormalized texture coordinate before sampling the texture.
|
|
600
|
+
* @return {string} The GLSL snippet.
|
|
601
|
+
*/
|
|
602
|
+
generateTextureGrad( texture, textureProperty, uvSnippet, gradSnippet, depthSnippet, offsetSnippet ) {
|
|
603
|
+
|
|
604
|
+
if ( depthSnippet ) uvSnippet = `vec3( ${ uvSnippet }, ${ depthSnippet } )`;
|
|
605
|
+
|
|
606
|
+
if ( offsetSnippet ) {
|
|
607
|
+
|
|
608
|
+
return `textureGradOffset( ${ textureProperty }, ${ uvSnippet }, ${ gradSnippet[ 0 ] }, ${ gradSnippet[ 1 ] }, ${ offsetSnippet } )`;
|
|
609
|
+
|
|
610
|
+
}
|
|
318
611
|
|
|
319
612
|
return `textureGrad( ${ textureProperty }, ${ uvSnippet }, ${ gradSnippet[ 0 ] }, ${ gradSnippet[ 1 ] } )`;
|
|
320
613
|
|
|
321
614
|
}
|
|
322
615
|
|
|
323
|
-
|
|
616
|
+
/**
|
|
617
|
+
* Generates the GLSL snippet for sampling a depth texture and comparing the sampled depth values
|
|
618
|
+
* against a reference value.
|
|
619
|
+
*
|
|
620
|
+
* @param {Texture} texture - The texture.
|
|
621
|
+
* @param {string} textureProperty - The name of the texture uniform in the shader.
|
|
622
|
+
* @param {string} uvSnippet - A GLSL snippet that represents texture coordinates used for sampling.
|
|
623
|
+
* @param {string} compareSnippet - A GLSL snippet that represents the reference value.
|
|
624
|
+
* @param {?string} depthSnippet - A GLSL snippet that represents 0-based texture array index to sample.
|
|
625
|
+
* @param {?string} offsetSnippet - A GLSL snippet that represents the offset that will be applied to the unnormalized texture coordinate before sampling the texture.
|
|
626
|
+
* @param {string} [shaderStage=this.shaderStage] - The shader stage this code snippet is generated for.
|
|
627
|
+
* @return {string} The GLSL snippet.
|
|
628
|
+
*/
|
|
629
|
+
generateTextureCompare( texture, textureProperty, uvSnippet, compareSnippet, depthSnippet, offsetSnippet, shaderStage = this.shaderStage ) {
|
|
324
630
|
|
|
325
631
|
if ( shaderStage === 'fragment' ) {
|
|
326
632
|
|
|
633
|
+
// Cube shadow maps use vec4(direction, compareValue)
|
|
634
|
+
if ( texture.isCubeTexture ) {
|
|
635
|
+
|
|
636
|
+
return `texture( ${ textureProperty }, vec4( ${ uvSnippet }, ${ compareSnippet } ) )`;
|
|
637
|
+
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
if ( depthSnippet ) {
|
|
641
|
+
|
|
642
|
+
if ( offsetSnippet ) {
|
|
643
|
+
|
|
644
|
+
return `textureOffset( ${ textureProperty }, vec4( ${ uvSnippet }, ${ depthSnippet }, ${ compareSnippet } ), ${ offsetSnippet } )`;
|
|
645
|
+
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
return `texture( ${ textureProperty }, vec4( ${ uvSnippet }, ${ depthSnippet }, ${ compareSnippet } ) )`;
|
|
649
|
+
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
if ( offsetSnippet ) {
|
|
653
|
+
|
|
654
|
+
return `textureOffset( ${ textureProperty }, vec3( ${ uvSnippet }, ${ compareSnippet } ), ${ offsetSnippet } )`;
|
|
655
|
+
|
|
656
|
+
}
|
|
657
|
+
|
|
327
658
|
return `texture( ${ textureProperty }, vec3( ${ uvSnippet }, ${ compareSnippet } ) )`;
|
|
328
659
|
|
|
329
660
|
} else {
|
|
330
661
|
|
|
331
|
-
|
|
662
|
+
error( `WebGPURenderer: THREE.DepthTexture.compareFunction() does not support ${ shaderStage } shader.` );
|
|
332
663
|
|
|
333
664
|
}
|
|
334
665
|
|
|
335
666
|
}
|
|
336
667
|
|
|
668
|
+
/**
|
|
669
|
+
* Returns the variables of the given shader stage as a GLSL string.
|
|
670
|
+
*
|
|
671
|
+
* @param {string} shaderStage - The shader stage.
|
|
672
|
+
* @return {string} The GLSL snippet that defines the variables.
|
|
673
|
+
*/
|
|
337
674
|
getVars( shaderStage ) {
|
|
338
675
|
|
|
339
676
|
const snippets = [];
|
|
@@ -344,7 +681,7 @@ ${ flowData.code }
|
|
|
344
681
|
|
|
345
682
|
for ( const variable of vars ) {
|
|
346
683
|
|
|
347
|
-
snippets.push( `${ this.getVar( variable.type, variable.name ) };` );
|
|
684
|
+
snippets.push( `${ this.getVar( variable.type, variable.name, variable.count ) };` );
|
|
348
685
|
|
|
349
686
|
}
|
|
350
687
|
|
|
@@ -354,6 +691,12 @@ ${ flowData.code }
|
|
|
354
691
|
|
|
355
692
|
}
|
|
356
693
|
|
|
694
|
+
/**
|
|
695
|
+
* Returns the uniforms of the given shader stage as a GLSL string.
|
|
696
|
+
*
|
|
697
|
+
* @param {string} shaderStage - The shader stage.
|
|
698
|
+
* @return {string} The GLSL snippet that defines the uniforms.
|
|
699
|
+
*/
|
|
357
700
|
getUniforms( shaderStage ) {
|
|
358
701
|
|
|
359
702
|
const uniforms = this.uniforms[ shaderStage ];
|
|
@@ -366,14 +709,13 @@ ${ flowData.code }
|
|
|
366
709
|
let snippet = null;
|
|
367
710
|
let group = false;
|
|
368
711
|
|
|
369
|
-
if ( uniform.type === 'texture' ) {
|
|
712
|
+
if ( uniform.type === 'texture' || uniform.type === 'texture3D' ) {
|
|
370
713
|
|
|
371
714
|
const texture = uniform.node.value;
|
|
372
715
|
|
|
373
716
|
let typePrefix = '';
|
|
374
717
|
|
|
375
|
-
if ( texture.isDataTexture === true ) {
|
|
376
|
-
|
|
718
|
+
if ( texture.isDataTexture === true || texture.isData3DTexture === true ) {
|
|
377
719
|
|
|
378
720
|
if ( texture.type === UnsignedIntType ) {
|
|
379
721
|
|
|
@@ -387,11 +729,23 @@ ${ flowData.code }
|
|
|
387
729
|
|
|
388
730
|
}
|
|
389
731
|
|
|
390
|
-
if ( texture.
|
|
732
|
+
if ( uniform.type === 'texture3D' && texture.isArrayTexture === false ) {
|
|
733
|
+
|
|
734
|
+
snippet = `${typePrefix}sampler3D ${ uniform.name };`;
|
|
391
735
|
|
|
392
|
-
|
|
736
|
+
} else if ( texture.compareFunction ) {
|
|
393
737
|
|
|
394
|
-
|
|
738
|
+
if ( texture.isArrayTexture === true ) {
|
|
739
|
+
|
|
740
|
+
snippet = `sampler2DArrayShadow ${ uniform.name };`;
|
|
741
|
+
|
|
742
|
+
} else {
|
|
743
|
+
|
|
744
|
+
snippet = `sampler2DShadow ${ uniform.name };`;
|
|
745
|
+
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
} else if ( texture.isArrayTexture === true || texture.isDataArrayTexture === true || texture.isCompressedArrayTexture === true ) {
|
|
395
749
|
|
|
396
750
|
snippet = `${typePrefix}sampler2DArray ${ uniform.name };`;
|
|
397
751
|
|
|
@@ -405,9 +759,19 @@ ${ flowData.code }
|
|
|
405
759
|
|
|
406
760
|
snippet = `samplerCube ${ uniform.name };`;
|
|
407
761
|
|
|
408
|
-
} else if ( uniform.type === '
|
|
762
|
+
} else if ( uniform.type === 'cubeDepthTexture' ) {
|
|
409
763
|
|
|
410
|
-
|
|
764
|
+
const texture = uniform.node.value;
|
|
765
|
+
|
|
766
|
+
if ( texture.compareFunction ) {
|
|
767
|
+
|
|
768
|
+
snippet = `samplerCubeShadow ${ uniform.name };`;
|
|
769
|
+
|
|
770
|
+
} else {
|
|
771
|
+
|
|
772
|
+
snippet = `samplerCube ${ uniform.name };`;
|
|
773
|
+
|
|
774
|
+
}
|
|
411
775
|
|
|
412
776
|
} else if ( uniform.type === 'buffer' ) {
|
|
413
777
|
|
|
@@ -420,32 +784,56 @@ ${ flowData.code }
|
|
|
420
784
|
|
|
421
785
|
} else {
|
|
422
786
|
|
|
423
|
-
const
|
|
787
|
+
const groupName = uniform.groupNode.name;
|
|
424
788
|
|
|
425
|
-
|
|
789
|
+
// Check if this group has already been processed
|
|
790
|
+
if ( uniformGroups[ groupName ] === undefined ) {
|
|
426
791
|
|
|
427
|
-
|
|
792
|
+
// Get the shared uniform group that contains uniforms from all stages
|
|
793
|
+
const sharedUniformGroup = this.uniformGroups[ groupName ];
|
|
428
794
|
|
|
429
|
-
|
|
795
|
+
if ( sharedUniformGroup !== undefined ) {
|
|
796
|
+
|
|
797
|
+
// Generate snippets for ALL uniforms in this shared group
|
|
798
|
+
const snippets = [];
|
|
799
|
+
|
|
800
|
+
for ( const sharedUniform of sharedUniformGroup.uniforms ) {
|
|
801
|
+
|
|
802
|
+
const type = sharedUniform.getType();
|
|
803
|
+
const vectorType = this.getVectorType( type );
|
|
804
|
+
const precision = sharedUniform.nodeUniform.node.precision;
|
|
430
805
|
|
|
431
|
-
|
|
806
|
+
let uniformSnippet = `${ vectorType } ${ sharedUniform.name };`;
|
|
432
807
|
|
|
433
|
-
|
|
808
|
+
if ( precision !== null ) {
|
|
434
809
|
|
|
435
|
-
|
|
810
|
+
uniformSnippet = precisionLib[ precision ] + ' ' + uniformSnippet;
|
|
811
|
+
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
snippets.push( '\t' + uniformSnippet );
|
|
815
|
+
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
uniformGroups[ groupName ] = snippets;
|
|
819
|
+
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
}
|
|
823
|
+
|
|
824
|
+
group = true;
|
|
436
825
|
|
|
437
826
|
}
|
|
438
827
|
|
|
439
|
-
if ( group ) {
|
|
828
|
+
if ( ! group ) {
|
|
440
829
|
|
|
441
|
-
|
|
830
|
+
const precision = uniform.node.precision;
|
|
442
831
|
|
|
443
|
-
|
|
444
|
-
const groupSnippets = uniformGroups[ groupName ] || ( uniformGroups[ groupName ] = [] );
|
|
832
|
+
if ( precision !== null ) {
|
|
445
833
|
|
|
446
|
-
|
|
834
|
+
snippet = precisionLib[ precision ] + ' ' + snippet;
|
|
447
835
|
|
|
448
|
-
|
|
836
|
+
}
|
|
449
837
|
|
|
450
838
|
snippet = 'uniform ' + snippet;
|
|
451
839
|
|
|
@@ -461,7 +849,7 @@ ${ flowData.code }
|
|
|
461
849
|
|
|
462
850
|
const groupSnippets = uniformGroups[ name ];
|
|
463
851
|
|
|
464
|
-
output += this._getGLSLUniformStruct(
|
|
852
|
+
output += this._getGLSLUniformStruct( name, groupSnippets.join( '\n' ) ) + '\n';
|
|
465
853
|
|
|
466
854
|
}
|
|
467
855
|
|
|
@@ -471,6 +859,12 @@ ${ flowData.code }
|
|
|
471
859
|
|
|
472
860
|
}
|
|
473
861
|
|
|
862
|
+
/**
|
|
863
|
+
* Returns the type for a given buffer attribute.
|
|
864
|
+
*
|
|
865
|
+
* @param {BufferAttribute} attribute - The buffer attribute.
|
|
866
|
+
* @return {string} The type.
|
|
867
|
+
*/
|
|
474
868
|
getTypeFromAttribute( attribute ) {
|
|
475
869
|
|
|
476
870
|
let nodeType = super.getTypeFromAttribute( attribute );
|
|
@@ -495,6 +889,12 @@ ${ flowData.code }
|
|
|
495
889
|
|
|
496
890
|
}
|
|
497
891
|
|
|
892
|
+
/**
|
|
893
|
+
* Returns the shader attributes of the given shader stage as a GLSL string.
|
|
894
|
+
*
|
|
895
|
+
* @param {string} shaderStage - The shader stage.
|
|
896
|
+
* @return {string} The GLSL snippet that defines the shader attributes.
|
|
897
|
+
*/
|
|
498
898
|
getAttributes( shaderStage ) {
|
|
499
899
|
|
|
500
900
|
let snippet = '';
|
|
@@ -517,15 +917,19 @@ ${ flowData.code }
|
|
|
517
917
|
|
|
518
918
|
}
|
|
519
919
|
|
|
920
|
+
/**
|
|
921
|
+
* Returns the members of the given struct type node as a GLSL string.
|
|
922
|
+
*
|
|
923
|
+
* @param {StructTypeNode} struct - The struct type node.
|
|
924
|
+
* @return {string} The GLSL snippet that defines the struct members.
|
|
925
|
+
*/
|
|
520
926
|
getStructMembers( struct ) {
|
|
521
927
|
|
|
522
928
|
const snippets = [];
|
|
523
|
-
const members = struct.getMemberTypes();
|
|
524
929
|
|
|
525
|
-
for (
|
|
930
|
+
for ( const member of struct.members ) {
|
|
526
931
|
|
|
527
|
-
|
|
528
|
-
snippets.push( `layout( location = ${i} ) out ${ member} m${i};` );
|
|
932
|
+
snippets.push( `\t${ member.type } ${ member.name };` );
|
|
529
933
|
|
|
530
934
|
}
|
|
531
935
|
|
|
@@ -533,33 +937,57 @@ ${ flowData.code }
|
|
|
533
937
|
|
|
534
938
|
}
|
|
535
939
|
|
|
940
|
+
/**
|
|
941
|
+
* Returns the structs of the given shader stage as a GLSL string.
|
|
942
|
+
*
|
|
943
|
+
* @param {string} shaderStage - The shader stage.
|
|
944
|
+
* @return {string} The GLSL snippet that defines the structs.
|
|
945
|
+
*/
|
|
536
946
|
getStructs( shaderStage ) {
|
|
537
947
|
|
|
538
948
|
const snippets = [];
|
|
539
949
|
const structs = this.structs[ shaderStage ];
|
|
540
950
|
|
|
541
|
-
|
|
951
|
+
const outputSnippet = [];
|
|
542
952
|
|
|
543
|
-
|
|
953
|
+
for ( const struct of structs ) {
|
|
544
954
|
|
|
545
|
-
|
|
955
|
+
if ( struct.output ) {
|
|
546
956
|
|
|
547
|
-
|
|
957
|
+
for ( const member of struct.members ) {
|
|
548
958
|
|
|
549
|
-
|
|
959
|
+
outputSnippet.push( `layout( location = ${ member.index } ) out ${ member.type } ${ member.name };` );
|
|
550
960
|
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
961
|
+
}
|
|
962
|
+
|
|
963
|
+
} else {
|
|
964
|
+
|
|
965
|
+
let snippet = 'struct ' + struct.name + ' {\n';
|
|
966
|
+
snippet += this.getStructMembers( struct );
|
|
967
|
+
snippet += '\n};\n';
|
|
554
968
|
|
|
555
|
-
|
|
969
|
+
snippets.push( snippet );
|
|
970
|
+
|
|
971
|
+
}
|
|
556
972
|
|
|
557
973
|
}
|
|
558
974
|
|
|
559
|
-
|
|
975
|
+
if ( outputSnippet.length === 0 ) {
|
|
976
|
+
|
|
977
|
+
outputSnippet.push( 'layout( location = 0 ) out vec4 fragColor;' );
|
|
978
|
+
|
|
979
|
+
}
|
|
980
|
+
|
|
981
|
+
return '\n' + outputSnippet.join( '\n' ) + '\n\n' + snippets.join( '\n' );
|
|
560
982
|
|
|
561
983
|
}
|
|
562
984
|
|
|
985
|
+
/**
|
|
986
|
+
* Returns the varyings of the given shader stage as a GLSL string.
|
|
987
|
+
*
|
|
988
|
+
* @param {string} shaderStage - The shader stage.
|
|
989
|
+
* @return {string} The GLSL snippet that defines the varyings.
|
|
990
|
+
*/
|
|
563
991
|
getVaryings( shaderStage ) {
|
|
564
992
|
|
|
565
993
|
let snippet = '';
|
|
@@ -571,10 +999,31 @@ ${ flowData.code }
|
|
|
571
999
|
for ( const varying of varyings ) {
|
|
572
1000
|
|
|
573
1001
|
if ( shaderStage === 'compute' ) varying.needsInterpolation = true;
|
|
574
|
-
const type = varying.type;
|
|
575
|
-
const flat = type.includes( 'int' ) || type.includes( 'uv' ) || type.includes( 'iv' ) ? 'flat ' : '';
|
|
576
1002
|
|
|
577
|
-
|
|
1003
|
+
const type = this.getType( varying.type );
|
|
1004
|
+
|
|
1005
|
+
if ( varying.needsInterpolation ) {
|
|
1006
|
+
|
|
1007
|
+
if ( varying.interpolationType ) {
|
|
1008
|
+
|
|
1009
|
+
const interpolationType = interpolationTypeMap[ varying.interpolationType ] || varying.interpolationType;
|
|
1010
|
+
const sampling = interpolationModeMap[ varying.interpolationSampling ] || '';
|
|
1011
|
+
|
|
1012
|
+
snippet += `${ interpolationType } ${ sampling } out ${ type } ${ varying.name };\n`;
|
|
1013
|
+
|
|
1014
|
+
} else {
|
|
1015
|
+
|
|
1016
|
+
const flat = type.includes( 'int' ) || type.includes( 'uv' ) || type.includes( 'iv' ) ? 'flat ' : '';
|
|
1017
|
+
|
|
1018
|
+
snippet += `${ flat }out ${ type } ${ varying.name };\n`;
|
|
1019
|
+
|
|
1020
|
+
}
|
|
1021
|
+
|
|
1022
|
+
} else {
|
|
1023
|
+
|
|
1024
|
+
snippet += `${type} ${varying.name};\n`; // generate variable (no varying required)
|
|
1025
|
+
|
|
1026
|
+
}
|
|
578
1027
|
|
|
579
1028
|
}
|
|
580
1029
|
|
|
@@ -584,10 +1033,23 @@ ${ flowData.code }
|
|
|
584
1033
|
|
|
585
1034
|
if ( varying.needsInterpolation ) {
|
|
586
1035
|
|
|
587
|
-
const type = varying.type;
|
|
588
|
-
|
|
1036
|
+
const type = this.getType( varying.type );
|
|
1037
|
+
|
|
1038
|
+
if ( varying.interpolationType ) {
|
|
1039
|
+
|
|
1040
|
+
const interpolationType = interpolationTypeMap[ varying.interpolationType ] || varying.interpolationType;
|
|
1041
|
+
const sampling = interpolationModeMap[ varying.interpolationSampling ] || '';
|
|
1042
|
+
|
|
1043
|
+
snippet += `${ interpolationType } ${ sampling } in ${ type } ${ varying.name };\n`;
|
|
1044
|
+
|
|
1045
|
+
|
|
1046
|
+
} else {
|
|
589
1047
|
|
|
590
|
-
|
|
1048
|
+
const flat = type.includes( 'int' ) || type.includes( 'uv' ) || type.includes( 'iv' ) ? 'flat ' : '';
|
|
1049
|
+
|
|
1050
|
+
snippet += `${ flat }in ${ type } ${ varying.name };\n`;
|
|
1051
|
+
|
|
1052
|
+
}
|
|
591
1053
|
|
|
592
1054
|
}
|
|
593
1055
|
|
|
@@ -595,22 +1057,44 @@ ${ flowData.code }
|
|
|
595
1057
|
|
|
596
1058
|
}
|
|
597
1059
|
|
|
1060
|
+
for ( const builtin of this.builtins[ shaderStage ] ) {
|
|
1061
|
+
|
|
1062
|
+
snippet += `${builtin};\n`;
|
|
1063
|
+
|
|
1064
|
+
}
|
|
1065
|
+
|
|
598
1066
|
return snippet;
|
|
599
1067
|
|
|
600
1068
|
}
|
|
601
1069
|
|
|
1070
|
+
/**
|
|
1071
|
+
* Returns the vertex index builtin.
|
|
1072
|
+
*
|
|
1073
|
+
* @return {string} The vertex index.
|
|
1074
|
+
*/
|
|
602
1075
|
getVertexIndex() {
|
|
603
1076
|
|
|
604
1077
|
return 'uint( gl_VertexID )';
|
|
605
1078
|
|
|
606
1079
|
}
|
|
607
1080
|
|
|
1081
|
+
/**
|
|
1082
|
+
* Contextually returns either the vertex stage instance index builtin
|
|
1083
|
+
* or the linearized index of an compute invocation within a grid of workgroups.
|
|
1084
|
+
*
|
|
1085
|
+
* @return {string} The instance index.
|
|
1086
|
+
*/
|
|
608
1087
|
getInstanceIndex() {
|
|
609
1088
|
|
|
610
1089
|
return 'uint( gl_InstanceID )';
|
|
611
1090
|
|
|
612
1091
|
}
|
|
613
1092
|
|
|
1093
|
+
/**
|
|
1094
|
+
* Returns a builtin representing the index of an invocation within its workgroup.
|
|
1095
|
+
*
|
|
1096
|
+
* @return {string} The invocation local index.
|
|
1097
|
+
*/
|
|
614
1098
|
getInvocationLocalIndex() {
|
|
615
1099
|
|
|
616
1100
|
const workgroupSize = this.object.workgroupSize;
|
|
@@ -621,6 +1105,38 @@ ${ flowData.code }
|
|
|
621
1105
|
|
|
622
1106
|
}
|
|
623
1107
|
|
|
1108
|
+
/**
|
|
1109
|
+
* Returns a builtin representing the size of a subgroup within the current shader.
|
|
1110
|
+
*/
|
|
1111
|
+
getSubgroupSize() {
|
|
1112
|
+
|
|
1113
|
+
error( 'GLSLNodeBuilder: WebGLBackend does not support the subgroupSize node' );
|
|
1114
|
+
|
|
1115
|
+
}
|
|
1116
|
+
|
|
1117
|
+
/**
|
|
1118
|
+
* Returns a builtin representing the index of an invocation within its subgroup.
|
|
1119
|
+
*/
|
|
1120
|
+
getInvocationSubgroupIndex() {
|
|
1121
|
+
|
|
1122
|
+
error( 'GLSLNodeBuilder: WebGLBackend does not support the invocationSubgroupIndex node' );
|
|
1123
|
+
|
|
1124
|
+
}
|
|
1125
|
+
|
|
1126
|
+
/**
|
|
1127
|
+
* Returns a builtin representing the index of the current invocation's subgroup within its workgroup.
|
|
1128
|
+
*/
|
|
1129
|
+
getSubgroupIndex() {
|
|
1130
|
+
|
|
1131
|
+
error( 'GLSLNodeBuilder: WebGLBackend does not support the subgroupIndex node' );
|
|
1132
|
+
|
|
1133
|
+
}
|
|
1134
|
+
|
|
1135
|
+
/**
|
|
1136
|
+
* Returns the draw index builtin.
|
|
1137
|
+
*
|
|
1138
|
+
* @return {?string} The drawIndex shader string. Returns `null` if `WEBGL_multi_draw` isn't supported by the device.
|
|
1139
|
+
*/
|
|
624
1140
|
getDrawIndex() {
|
|
625
1141
|
|
|
626
1142
|
const extensions = this.renderer.backend.extensions;
|
|
@@ -635,24 +1151,46 @@ ${ flowData.code }
|
|
|
635
1151
|
|
|
636
1152
|
}
|
|
637
1153
|
|
|
1154
|
+
/**
|
|
1155
|
+
* Returns the front facing builtin.
|
|
1156
|
+
*
|
|
1157
|
+
* @return {string} The front facing builtin.
|
|
1158
|
+
*/
|
|
638
1159
|
getFrontFacing() {
|
|
639
1160
|
|
|
640
1161
|
return 'gl_FrontFacing';
|
|
641
1162
|
|
|
642
1163
|
}
|
|
643
1164
|
|
|
1165
|
+
/**
|
|
1166
|
+
* Returns the frag coord builtin.
|
|
1167
|
+
*
|
|
1168
|
+
* @return {string} The frag coord builtin.
|
|
1169
|
+
*/
|
|
644
1170
|
getFragCoord() {
|
|
645
1171
|
|
|
646
1172
|
return 'gl_FragCoord.xy';
|
|
647
1173
|
|
|
648
1174
|
}
|
|
649
1175
|
|
|
1176
|
+
/**
|
|
1177
|
+
* Returns the frag depth builtin.
|
|
1178
|
+
*
|
|
1179
|
+
* @return {string} The frag depth builtin.
|
|
1180
|
+
*/
|
|
650
1181
|
getFragDepth() {
|
|
651
1182
|
|
|
652
1183
|
return 'gl_FragDepth';
|
|
653
1184
|
|
|
654
1185
|
}
|
|
655
1186
|
|
|
1187
|
+
/**
|
|
1188
|
+
* Enables the given extension.
|
|
1189
|
+
*
|
|
1190
|
+
* @param {string} name - The extension name.
|
|
1191
|
+
* @param {string} behavior - The extension behavior.
|
|
1192
|
+
* @param {string} [shaderStage=this.shaderStage] - The shader stage.
|
|
1193
|
+
*/
|
|
656
1194
|
enableExtension( name, behavior, shaderStage = this.shaderStage ) {
|
|
657
1195
|
|
|
658
1196
|
const map = this.extensions[ shaderStage ] || ( this.extensions[ shaderStage ] = new Map() );
|
|
@@ -668,6 +1206,12 @@ ${ flowData.code }
|
|
|
668
1206
|
|
|
669
1207
|
}
|
|
670
1208
|
|
|
1209
|
+
/**
|
|
1210
|
+
* Returns the enabled extensions of the given shader stage as a GLSL string.
|
|
1211
|
+
*
|
|
1212
|
+
* @param {string} shaderStage - The shader stage.
|
|
1213
|
+
* @return {string} The GLSL snippet that defines the enabled extensions.
|
|
1214
|
+
*/
|
|
671
1215
|
getExtensions( shaderStage ) {
|
|
672
1216
|
|
|
673
1217
|
const snippets = [];
|
|
@@ -701,24 +1245,53 @@ ${ flowData.code }
|
|
|
701
1245
|
|
|
702
1246
|
}
|
|
703
1247
|
|
|
1248
|
+
/**
|
|
1249
|
+
* Returns the clip distances builtin.
|
|
1250
|
+
*
|
|
1251
|
+
* @return {string} The clip distances builtin.
|
|
1252
|
+
*/
|
|
1253
|
+
getClipDistance() {
|
|
1254
|
+
|
|
1255
|
+
return 'gl_ClipDistance';
|
|
1256
|
+
|
|
1257
|
+
}
|
|
1258
|
+
|
|
1259
|
+
/**
|
|
1260
|
+
* Whether the requested feature is available or not.
|
|
1261
|
+
*
|
|
1262
|
+
* @param {string} name - The requested feature.
|
|
1263
|
+
* @return {boolean} Whether the requested feature is supported or not.
|
|
1264
|
+
*/
|
|
704
1265
|
isAvailable( name ) {
|
|
705
1266
|
|
|
706
1267
|
let result = supports[ name ];
|
|
707
1268
|
|
|
708
1269
|
if ( result === undefined ) {
|
|
709
1270
|
|
|
710
|
-
|
|
1271
|
+
let extensionName;
|
|
711
1272
|
|
|
712
|
-
|
|
1273
|
+
result = false;
|
|
713
1274
|
|
|
714
|
-
|
|
1275
|
+
switch ( name ) {
|
|
715
1276
|
|
|
716
|
-
|
|
717
|
-
|
|
1277
|
+
case 'float32Filterable':
|
|
1278
|
+
extensionName = 'OES_texture_float_linear';
|
|
1279
|
+
break;
|
|
718
1280
|
|
|
719
|
-
|
|
1281
|
+
case 'clipDistance':
|
|
1282
|
+
extensionName = 'WEBGL_clip_cull_distance';
|
|
1283
|
+
break;
|
|
720
1284
|
|
|
721
|
-
|
|
1285
|
+
}
|
|
1286
|
+
|
|
1287
|
+
if ( extensionName !== undefined ) {
|
|
1288
|
+
|
|
1289
|
+
const extensions = this.renderer.backend.extensions;
|
|
1290
|
+
|
|
1291
|
+
if ( extensions.has( extensionName ) ) {
|
|
1292
|
+
|
|
1293
|
+
extensions.get( extensionName );
|
|
1294
|
+
result = true;
|
|
722
1295
|
|
|
723
1296
|
}
|
|
724
1297
|
|
|
@@ -732,18 +1305,72 @@ ${ flowData.code }
|
|
|
732
1305
|
|
|
733
1306
|
}
|
|
734
1307
|
|
|
1308
|
+
/**
|
|
1309
|
+
* Whether to flip texture data along its vertical axis or not.
|
|
1310
|
+
*
|
|
1311
|
+
* @return {boolean} Returns always `true` in context of GLSL.
|
|
1312
|
+
*/
|
|
735
1313
|
isFlipY() {
|
|
736
1314
|
|
|
737
1315
|
return true;
|
|
738
1316
|
|
|
739
1317
|
}
|
|
740
1318
|
|
|
1319
|
+
/**
|
|
1320
|
+
* Returns the maximum number of bytes available for uniform buffers.
|
|
1321
|
+
*
|
|
1322
|
+
* @return {number} The maximum number of bytes available for uniform buffers.
|
|
1323
|
+
*/
|
|
1324
|
+
getUniformBufferLimit() {
|
|
1325
|
+
|
|
1326
|
+
const gl = this.renderer.backend.gl;
|
|
1327
|
+
return gl.getParameter( gl.MAX_UNIFORM_BLOCK_SIZE );
|
|
1328
|
+
|
|
1329
|
+
}
|
|
1330
|
+
|
|
1331
|
+
/**
|
|
1332
|
+
* Enables hardware clipping.
|
|
1333
|
+
*
|
|
1334
|
+
* @param {string} planeCount - The clipping plane count.
|
|
1335
|
+
*/
|
|
1336
|
+
enableHardwareClipping( planeCount ) {
|
|
1337
|
+
|
|
1338
|
+
this.enableExtension( 'GL_ANGLE_clip_cull_distance', 'require' );
|
|
1339
|
+
|
|
1340
|
+
this.builtins[ 'vertex' ].push( `out float gl_ClipDistance[ ${ planeCount } ]` );
|
|
1341
|
+
|
|
1342
|
+
}
|
|
1343
|
+
|
|
1344
|
+
/**
|
|
1345
|
+
* Enables multiview.
|
|
1346
|
+
*/
|
|
1347
|
+
enableMultiview() {
|
|
1348
|
+
|
|
1349
|
+
this.enableExtension( 'GL_OVR_multiview2', 'require', 'fragment' );
|
|
1350
|
+
this.enableExtension( 'GL_OVR_multiview2', 'require', 'vertex' );
|
|
1351
|
+
|
|
1352
|
+
this.builtins[ 'vertex' ].push( 'layout(num_views = 2) in' );
|
|
1353
|
+
|
|
1354
|
+
}
|
|
1355
|
+
|
|
1356
|
+
/**
|
|
1357
|
+
* Registers a transform in context of Transform Feedback.
|
|
1358
|
+
*
|
|
1359
|
+
* @param {string} varyingName - The varying name.
|
|
1360
|
+
* @param {AttributeNode} attributeNode - The attribute node.
|
|
1361
|
+
*/
|
|
741
1362
|
registerTransform( varyingName, attributeNode ) {
|
|
742
1363
|
|
|
743
1364
|
this.transforms.push( { varyingName, attributeNode } );
|
|
744
1365
|
|
|
745
1366
|
}
|
|
746
1367
|
|
|
1368
|
+
/**
|
|
1369
|
+
* Returns the transforms of the given shader stage as a GLSL string.
|
|
1370
|
+
*
|
|
1371
|
+
* @param {string} shaderStage - The shader stage.
|
|
1372
|
+
* @return {string} The GLSL snippet that defines the transforms.
|
|
1373
|
+
*/
|
|
747
1374
|
getTransforms( /* shaderStage */ ) {
|
|
748
1375
|
|
|
749
1376
|
const transforms = this.transforms;
|
|
@@ -753,10 +1380,9 @@ ${ flowData.code }
|
|
|
753
1380
|
for ( let i = 0; i < transforms.length; i ++ ) {
|
|
754
1381
|
|
|
755
1382
|
const transform = transforms[ i ];
|
|
756
|
-
|
|
757
1383
|
const attributeName = this.getPropertyName( transform.attributeNode );
|
|
758
1384
|
|
|
759
|
-
snippet += `${ transform.varyingName } = ${ attributeName };\n\t`;
|
|
1385
|
+
if ( attributeName ) snippet += `${ transform.varyingName } = ${ attributeName };\n\t`;
|
|
760
1386
|
|
|
761
1387
|
}
|
|
762
1388
|
|
|
@@ -764,6 +1390,14 @@ ${ flowData.code }
|
|
|
764
1390
|
|
|
765
1391
|
}
|
|
766
1392
|
|
|
1393
|
+
/**
|
|
1394
|
+
* Returns a GLSL struct based on the given name and variables.
|
|
1395
|
+
*
|
|
1396
|
+
* @private
|
|
1397
|
+
* @param {string} name - The struct name.
|
|
1398
|
+
* @param {string} vars - The struct variables.
|
|
1399
|
+
* @return {string} The GLSL snippet representing a struct.
|
|
1400
|
+
*/
|
|
767
1401
|
_getGLSLUniformStruct( name, vars ) {
|
|
768
1402
|
|
|
769
1403
|
return `
|
|
@@ -773,13 +1407,20 @@ ${vars}
|
|
|
773
1407
|
|
|
774
1408
|
}
|
|
775
1409
|
|
|
1410
|
+
/**
|
|
1411
|
+
* Returns a GLSL vertex shader based on the given shader data.
|
|
1412
|
+
*
|
|
1413
|
+
* @private
|
|
1414
|
+
* @param {Object} shaderData - The shader data.
|
|
1415
|
+
* @return {string} The vertex shader.
|
|
1416
|
+
*/
|
|
776
1417
|
_getGLSLVertexCode( shaderData ) {
|
|
777
1418
|
|
|
778
1419
|
return `#version 300 es
|
|
779
1420
|
|
|
780
1421
|
${ this.getSignature() }
|
|
781
1422
|
|
|
782
|
-
// extensions
|
|
1423
|
+
// extensions
|
|
783
1424
|
${shaderData.extensions}
|
|
784
1425
|
|
|
785
1426
|
// precision
|
|
@@ -815,15 +1456,28 @@ void main() {
|
|
|
815
1456
|
|
|
816
1457
|
}
|
|
817
1458
|
|
|
1459
|
+
/**
|
|
1460
|
+
* Returns a GLSL fragment shader based on the given shader data.
|
|
1461
|
+
*
|
|
1462
|
+
* @private
|
|
1463
|
+
* @param {Object} shaderData - The shader data.
|
|
1464
|
+
* @return {string} The vertex shader.
|
|
1465
|
+
*/
|
|
818
1466
|
_getGLSLFragmentCode( shaderData ) {
|
|
819
1467
|
|
|
820
1468
|
return `#version 300 es
|
|
821
1469
|
|
|
822
1470
|
${ this.getSignature() }
|
|
823
1471
|
|
|
1472
|
+
// extensions
|
|
1473
|
+
${shaderData.extensions}
|
|
1474
|
+
|
|
824
1475
|
// precision
|
|
825
1476
|
${ defaultPrecisions }
|
|
826
1477
|
|
|
1478
|
+
// structs
|
|
1479
|
+
${shaderData.structs}
|
|
1480
|
+
|
|
827
1481
|
// uniforms
|
|
828
1482
|
${shaderData.uniforms}
|
|
829
1483
|
|
|
@@ -833,8 +1487,6 @@ ${shaderData.varyings}
|
|
|
833
1487
|
// codes
|
|
834
1488
|
${shaderData.codes}
|
|
835
1489
|
|
|
836
|
-
${shaderData.structs}
|
|
837
|
-
|
|
838
1490
|
void main() {
|
|
839
1491
|
|
|
840
1492
|
// vars
|
|
@@ -848,6 +1500,9 @@ void main() {
|
|
|
848
1500
|
|
|
849
1501
|
}
|
|
850
1502
|
|
|
1503
|
+
/**
|
|
1504
|
+
* Controls the code build of the shader stages.
|
|
1505
|
+
*/
|
|
851
1506
|
buildCode() {
|
|
852
1507
|
|
|
853
1508
|
const shadersData = this.material !== null ? { fragment: {}, vertex: {} } : { compute: {} };
|
|
@@ -928,6 +1583,19 @@ void main() {
|
|
|
928
1583
|
|
|
929
1584
|
}
|
|
930
1585
|
|
|
1586
|
+
/**
|
|
1587
|
+
* This method is one of the more important ones since it's responsible
|
|
1588
|
+
* for generating a matching binding instance for the given uniform node.
|
|
1589
|
+
*
|
|
1590
|
+
* These bindings are later used in the renderer to create bind groups
|
|
1591
|
+
* and layouts.
|
|
1592
|
+
*
|
|
1593
|
+
* @param {UniformNode} node - The uniform node.
|
|
1594
|
+
* @param {string} type - The node data type.
|
|
1595
|
+
* @param {string} shaderStage - The shader stage.
|
|
1596
|
+
* @param {?string} [name=null] - An optional uniform name.
|
|
1597
|
+
* @return {NodeUniform} The node uniform object.
|
|
1598
|
+
*/
|
|
931
1599
|
getUniformFromNode( node, type, shaderStage, name = null ) {
|
|
932
1600
|
|
|
933
1601
|
const uniformNode = super.getUniformFromNode( node, type, shaderStage, name );
|
|
@@ -947,7 +1615,7 @@ void main() {
|
|
|
947
1615
|
uniformGPU = new NodeSampledTexture( uniformNode.name, uniformNode.node, group );
|
|
948
1616
|
bindings.push( uniformGPU );
|
|
949
1617
|
|
|
950
|
-
} else if ( type === 'cubeTexture' ) {
|
|
1618
|
+
} else if ( type === 'cubeTexture' || type === 'cubeDepthTexture' ) {
|
|
951
1619
|
|
|
952
1620
|
uniformGPU = new NodeSampledCubeTexture( uniformNode.name, uniformNode.node, group );
|
|
953
1621
|
bindings.push( uniformGPU );
|
|
@@ -959,11 +1627,22 @@ void main() {
|
|
|
959
1627
|
|
|
960
1628
|
} else if ( type === 'buffer' ) {
|
|
961
1629
|
|
|
962
|
-
node.name = `NodeBuffer_${ node.id }`;
|
|
963
1630
|
uniformNode.name = `buffer${ node.id }`;
|
|
964
1631
|
|
|
965
|
-
const
|
|
966
|
-
|
|
1632
|
+
const sharedData = this.getSharedDataFromNode( node );
|
|
1633
|
+
|
|
1634
|
+
let buffer = sharedData.buffer;
|
|
1635
|
+
|
|
1636
|
+
if ( buffer === undefined ) {
|
|
1637
|
+
|
|
1638
|
+
node.name = `NodeBuffer_${ node.id }`;
|
|
1639
|
+
|
|
1640
|
+
buffer = new NodeUniformBuffer( node, group );
|
|
1641
|
+
buffer.name = node.name;
|
|
1642
|
+
|
|
1643
|
+
sharedData.buffer = buffer;
|
|
1644
|
+
|
|
1645
|
+
}
|
|
967
1646
|
|
|
968
1647
|
bindings.push( buffer );
|
|
969
1648
|
|
|
@@ -971,24 +1650,38 @@ void main() {
|
|
|
971
1650
|
|
|
972
1651
|
} else {
|
|
973
1652
|
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
let uniformsGroup = uniformsStage[ groupName ];
|
|
1653
|
+
let uniformsGroup = this.uniformGroups[ groupName ];
|
|
977
1654
|
|
|
978
1655
|
if ( uniformsGroup === undefined ) {
|
|
979
1656
|
|
|
980
|
-
uniformsGroup = new NodeUniformsGroup(
|
|
981
|
-
//uniformsGroup.setVisibility( gpuShaderStageLib[ shaderStage ] );
|
|
1657
|
+
uniformsGroup = new NodeUniformsGroup( groupName, group );
|
|
982
1658
|
|
|
983
|
-
|
|
1659
|
+
this.uniformGroups[ groupName ] = uniformsGroup;
|
|
984
1660
|
|
|
985
1661
|
bindings.push( uniformsGroup );
|
|
986
1662
|
|
|
1663
|
+
} else {
|
|
1664
|
+
|
|
1665
|
+
// Add to bindings for this stage if not already present
|
|
1666
|
+
if ( bindings.indexOf( uniformsGroup ) === - 1 ) {
|
|
1667
|
+
|
|
1668
|
+
bindings.push( uniformsGroup );
|
|
1669
|
+
|
|
1670
|
+
}
|
|
1671
|
+
|
|
987
1672
|
}
|
|
988
1673
|
|
|
989
1674
|
uniformGPU = this.getNodeUniform( uniformNode, type );
|
|
990
1675
|
|
|
991
|
-
|
|
1676
|
+
// Only add uniform if not already present in the group (check by name to avoid duplicates across stages)
|
|
1677
|
+
const uniformName = uniformGPU.name;
|
|
1678
|
+
const alreadyExists = uniformsGroup.uniforms.some( u => u.name === uniformName );
|
|
1679
|
+
|
|
1680
|
+
if ( ! alreadyExists ) {
|
|
1681
|
+
|
|
1682
|
+
uniformsGroup.addUniform( uniformGPU );
|
|
1683
|
+
|
|
1684
|
+
}
|
|
992
1685
|
|
|
993
1686
|
}
|
|
994
1687
|
|