@plastic-software/three 0.180.0 → 0.181.2
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/build/three.cjs +944 -487
- package/build/three.core.js +506 -327
- package/build/three.core.min.js +1 -1
- package/build/three.module.js +436 -164
- package/build/three.module.min.js +1 -1
- package/build/three.tsl.js +8 -2
- package/build/three.tsl.min.js +1 -1
- package/build/three.webgpu.js +3753 -1177
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +3752 -1176
- package/build/three.webgpu.nodes.min.js +1 -1
- package/examples/fonts/MPLUSRounded1c/MPLUSRounded1c-Regular.typeface.json.zip +0 -0
- package/examples/fonts/MPLUSRounded1c/OFL.txt +91 -0
- package/examples/jsm/animation/CCDIKSolver.js +1 -1
- package/examples/jsm/controls/ArcballControls.js +1 -1
- package/examples/jsm/controls/DragControls.js +1 -1
- package/examples/jsm/controls/FirstPersonControls.js +1 -1
- package/examples/jsm/controls/FlyControls.js +1 -1
- package/examples/jsm/controls/OrbitControls.js +2 -2
- package/examples/jsm/controls/PointerLockControls.js +2 -2
- package/examples/jsm/controls/TrackballControls.js +1 -1
- package/examples/jsm/controls/TransformControls.js +1 -1
- package/examples/jsm/effects/AsciiEffect.js +8 -8
- package/examples/jsm/exporters/DRACOExporter.js +2 -2
- package/examples/jsm/exporters/EXRExporter.js +1 -1
- package/examples/jsm/exporters/GLTFExporter.js +3 -3
- package/examples/jsm/exporters/USDZExporter.js +9 -2
- package/examples/jsm/geometries/DecalGeometry.js +2 -2
- package/examples/jsm/geometries/ParametricGeometry.js +1 -1
- package/examples/jsm/geometries/TeapotGeometry.js +2 -2
- package/examples/jsm/geometries/TextGeometry.js +3 -2
- package/examples/jsm/gpgpu/BitonicSort.js +715 -0
- package/examples/jsm/helpers/ViewHelper.js +43 -5
- package/examples/jsm/inspector/Inspector.js +427 -0
- package/examples/jsm/inspector/RendererInspector.js +415 -0
- package/examples/jsm/inspector/tabs/Console.js +204 -0
- package/examples/jsm/inspector/tabs/Parameters.js +332 -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 +170 -0
- package/examples/jsm/inspector/ui/Style.js +654 -0
- package/examples/jsm/inspector/ui/Tab.js +46 -0
- package/examples/jsm/inspector/ui/Values.js +423 -0
- package/examples/jsm/inspector/ui/utils.js +56 -0
- package/examples/jsm/interactive/HTMLMesh.js +6 -10
- package/examples/jsm/interactive/InteractiveGroup.js +1 -1
- package/examples/jsm/interactive/SelectionBox.js +30 -0
- package/examples/jsm/lights/RectAreaLightTexturesLib.js +1 -1
- package/examples/jsm/loaders/3MFLoader.js +1 -1
- package/examples/jsm/loaders/ColladaLoader.js +2 -2
- package/examples/jsm/loaders/DDSLoader.js +1 -1
- package/examples/jsm/loaders/DRACOLoader.js +73 -22
- package/examples/jsm/loaders/FBXLoader.js +2 -2
- package/examples/jsm/loaders/FontLoader.js +23 -5
- package/examples/jsm/loaders/GLTFLoader.js +5 -3
- package/examples/jsm/loaders/KTX2Loader.js +28 -21
- package/examples/jsm/loaders/KTXLoader.js +2 -2
- package/examples/jsm/loaders/LDrawLoader.js +1 -1
- package/examples/jsm/loaders/LUT3dlLoader.js +2 -2
- package/examples/jsm/loaders/LUTCubeLoader.js +1 -1
- package/examples/jsm/loaders/LWOLoader.js +2 -2
- package/examples/jsm/loaders/MaterialXLoader.js +22 -5
- package/examples/jsm/loaders/OBJLoader.js +1 -1
- package/examples/jsm/loaders/PDBLoader.js +1 -1
- package/examples/jsm/loaders/SVGLoader.js +2 -2
- package/examples/jsm/loaders/UltraHDRLoader.js +1 -1
- package/examples/jsm/math/ConvexHull.js +1 -1
- package/examples/jsm/math/ImprovedNoise.js +1 -1
- package/examples/jsm/math/SimplexNoise.js +1 -1
- package/examples/jsm/misc/ProgressiveLightMap.js +9 -3
- package/examples/jsm/misc/ProgressiveLightMapGPU.js +7 -1
- package/examples/jsm/misc/TubePainter.js +383 -40
- package/examples/jsm/modifiers/SimplifyModifier.js +1 -1
- package/examples/jsm/objects/ReflectorForSSRPass.js +1 -0
- package/examples/jsm/objects/Sky.js +1 -1
- package/examples/jsm/objects/SkyMesh.js +1 -1
- package/examples/jsm/objects/Water.js +3 -3
- package/examples/jsm/objects/WaterMesh.js +6 -6
- package/examples/jsm/postprocessing/GlitchPass.js +2 -2
- package/examples/jsm/postprocessing/UnrealBloomPass.js +8 -6
- package/examples/jsm/renderers/CSS2DRenderer.js +16 -5
- package/examples/jsm/renderers/CSS3DRenderer.js +7 -6
- package/examples/jsm/renderers/SVGRenderer.js +1 -1
- package/examples/jsm/shaders/ACESFilmicToneMappingShader.js +1 -1
- package/examples/jsm/shaders/AfterimageShader.js +1 -1
- package/examples/jsm/shaders/BleachBypassShader.js +1 -1
- package/examples/jsm/shaders/BokehShader.js +1 -1
- package/examples/jsm/shaders/BokehShader2.js +1 -1
- package/examples/jsm/shaders/DotScreenShader.js +1 -1
- package/examples/jsm/shaders/FocusShader.js +1 -1
- package/examples/jsm/shaders/GTAOShader.js +2 -2
- package/examples/jsm/shaders/GodRaysShader.js +1 -1
- package/examples/jsm/shaders/KaleidoShader.js +1 -1
- package/examples/jsm/shaders/PoissonDenoiseShader.js +2 -2
- package/examples/jsm/shaders/SSRShader.js +1 -1
- package/examples/jsm/shaders/SepiaShader.js +1 -1
- package/examples/jsm/shaders/SubsurfaceScatteringShader.js +1 -1
- package/examples/jsm/shaders/TriangleBlurShader.js +1 -1
- package/examples/jsm/shaders/VignetteShader.js +1 -1
- package/examples/jsm/transpiler/TSLEncoder.js +7 -0
- package/examples/jsm/tsl/display/AfterImageNode.js +26 -24
- package/examples/jsm/tsl/display/AnamorphicNode.js +2 -1
- package/examples/jsm/tsl/display/BloomNode.js +4 -0
- package/examples/jsm/tsl/display/DenoiseNode.js +2 -0
- package/examples/jsm/tsl/display/DepthOfFieldNode.js +7 -0
- package/examples/jsm/tsl/display/GTAONode.js +45 -5
- package/examples/jsm/tsl/display/GaussianBlurNode.js +5 -3
- package/examples/jsm/tsl/display/OutlineNode.js +11 -0
- package/examples/jsm/tsl/display/SSGINode.js +654 -0
- package/examples/jsm/tsl/display/SSRNode.js +2 -0
- package/examples/jsm/tsl/display/SSSNode.js +488 -0
- package/examples/jsm/tsl/display/TRAANode.js +123 -6
- package/examples/jsm/tsl/display/boxBlur.js +1 -0
- package/examples/jsm/tsl/display/hashBlur.js +1 -0
- package/examples/jsm/tsl/lighting/TiledLightsNode.js +21 -1
- package/examples/jsm/webxr/XRControllerModelFactory.js +1 -1
- package/examples/jsm/webxr/XRHandModelFactory.js +2 -6
- package/package.json +5 -10
- package/src/Three.Core.js +3 -2
- package/src/Three.TSL.js +7 -1
- package/src/Three.WebGPU.Nodes.js +2 -0
- package/src/Three.WebGPU.js +2 -0
- package/src/animation/AnimationClip.js +3 -2
- package/src/animation/AnimationMixer.js +3 -3
- package/src/animation/AnimationObjectGroup.js +2 -1
- package/src/animation/KeyframeTrack.js +7 -6
- package/src/animation/PropertyBinding.js +12 -11
- package/src/audio/Audio.js +10 -9
- package/src/audio/PositionalAudio.js +1 -1
- package/src/cameras/OrthographicCamera.js +1 -1
- package/src/cameras/PerspectiveCamera.js +1 -1
- package/src/cameras/StereoCamera.js +2 -2
- package/src/constants.js +1 -1
- package/src/core/BufferGeometry.js +8 -8
- package/src/core/EventDispatcher.js +1 -1
- package/src/core/InterleavedBuffer.js +1 -1
- package/src/core/InterleavedBufferAttribute.js +3 -2
- package/src/core/Object3D.js +3 -2
- package/src/core/Raycaster.js +2 -1
- package/src/core/RenderTarget.js +10 -1
- package/src/extras/Controls.js +5 -4
- package/src/extras/DataUtils.js +2 -1
- package/src/extras/Earcut.js +6 -0
- package/src/extras/ImageUtils.js +2 -2
- package/src/extras/PMREMGenerator.js +268 -55
- package/src/extras/core/Curve.js +2 -1
- package/src/extras/core/Interpolations.js +7 -1
- package/src/extras/core/ShapePath.js +4 -4
- package/src/extras/lib/earcut.js +7 -7
- package/src/geometries/BoxGeometry.js +1 -0
- package/src/geometries/CapsuleGeometry.js +1 -0
- package/src/geometries/CircleGeometry.js +1 -0
- package/src/geometries/ConeGeometry.js +1 -0
- package/src/geometries/CylinderGeometry.js +1 -0
- package/src/geometries/DodecahedronGeometry.js +1 -0
- package/src/geometries/ExtrudeGeometry.js +8 -6
- package/src/geometries/IcosahedronGeometry.js +1 -0
- package/src/geometries/LatheGeometry.js +1 -0
- package/src/geometries/OctahedronGeometry.js +1 -0
- package/src/geometries/PlaneGeometry.js +1 -0
- package/src/geometries/RingGeometry.js +1 -0
- package/src/geometries/ShapeGeometry.js +1 -0
- package/src/geometries/SphereGeometry.js +1 -0
- package/src/geometries/TetrahedronGeometry.js +1 -0
- package/src/geometries/TorusGeometry.js +1 -0
- package/src/geometries/TorusKnotGeometry.js +1 -0
- package/src/geometries/TubeGeometry.js +1 -0
- package/src/helpers/CameraHelper.js +1 -1
- package/src/loaders/AnimationLoader.js +2 -1
- package/src/loaders/AudioLoader.js +2 -1
- package/src/loaders/BufferGeometryLoader.js +2 -2
- package/src/loaders/Cache.js +2 -2
- package/src/loaders/DataTextureLoader.js +1 -1
- package/src/loaders/FileLoader.js +3 -2
- package/src/loaders/ImageBitmapLoader.js +5 -4
- package/src/loaders/ImageLoader.js +1 -1
- package/src/loaders/Loader.js +3 -3
- package/src/loaders/LoadingManager.js +25 -3
- package/src/loaders/MaterialLoader.js +3 -2
- package/src/loaders/ObjectLoader.js +13 -13
- package/src/loaders/TextureLoader.js +1 -1
- package/src/loaders/nodes/NodeLoader.js +3 -2
- package/src/materials/Material.js +4 -3
- package/src/materials/MeshBasicMaterial.js +1 -0
- package/src/materials/MeshDepthMaterial.js +1 -0
- package/src/materials/MeshLambertMaterial.js +2 -1
- package/src/materials/MeshMatcapMaterial.js +22 -0
- package/src/materials/MeshNormalMaterial.js +1 -0
- package/src/materials/MeshPhongMaterial.js +2 -1
- package/src/materials/MeshPhysicalMaterial.js +2 -1
- package/src/materials/MeshStandardMaterial.js +8 -7
- package/src/materials/MeshToonMaterial.js +1 -0
- package/src/materials/PointsMaterial.js +1 -1
- package/src/materials/ShaderMaterial.js +2 -2
- package/src/materials/nodes/Line2NodeMaterial.js +2 -2
- package/src/materials/nodes/MeshSSSNodeMaterial.js +1 -1
- package/src/materials/nodes/NodeMaterial.js +62 -22
- package/src/materials/nodes/manager/NodeMaterialObserver.js +2 -1
- package/src/math/Color.js +6 -5
- package/src/math/ColorManagement.js +2 -2
- package/src/math/Cylindrical.js +1 -1
- package/src/math/Euler.js +2 -1
- package/src/math/MathUtils.js +13 -11
- package/src/math/Matrix2.js +1 -1
- package/src/math/Matrix3.js +2 -2
- package/src/math/Matrix4.js +7 -7
- package/src/math/Plane.js +1 -1
- package/src/math/Quaternion.js +68 -66
- package/src/math/Spherical.js +1 -1
- package/src/nodes/Nodes.js +1 -1
- package/src/nodes/TSL.js +1 -1
- package/src/nodes/accessors/CubeTextureNode.js +3 -2
- package/src/nodes/accessors/InstanceNode.js +22 -4
- package/src/nodes/accessors/Lights.js +10 -0
- package/src/nodes/accessors/Normal.js +5 -4
- package/src/nodes/accessors/Position.js +18 -2
- package/src/nodes/accessors/ReferenceNode.js +2 -1
- package/src/nodes/accessors/SceneNode.js +2 -1
- package/src/nodes/accessors/StorageBufferNode.js +2 -1
- package/src/nodes/accessors/StorageTextureNode.js +22 -0
- package/src/nodes/accessors/Texture3DNode.js +1 -1
- package/src/nodes/accessors/TextureNode.js +61 -27
- package/src/nodes/code/FunctionCallNode.js +5 -4
- package/src/nodes/core/ArrayNode.js +1 -0
- package/src/nodes/core/AttributeNode.js +2 -1
- package/src/nodes/core/ContextNode.js +5 -10
- package/src/nodes/core/IndexNode.js +2 -2
- package/src/nodes/core/InputNode.js +2 -1
- package/src/nodes/core/InspectorNode.js +128 -0
- package/src/nodes/core/{CacheNode.js → IsolateNode.js} +40 -7
- package/src/nodes/core/Node.js +137 -12
- package/src/nodes/core/NodeBuilder.js +135 -21
- package/src/nodes/core/NodeFrame.js +20 -20
- package/src/nodes/core/NodeFunction.js +2 -1
- package/src/nodes/core/NodeParser.js +2 -1
- package/src/nodes/core/NodeUtils.js +17 -90
- package/src/nodes/core/ParameterNode.js +31 -0
- package/src/nodes/core/PropertyNode.js +7 -0
- package/src/nodes/core/StackNode.js +16 -14
- package/src/nodes/core/UniformNode.js +2 -1
- package/src/nodes/core/VarNode.js +70 -12
- package/src/nodes/core/VaryingNode.js +3 -2
- package/src/nodes/display/BlendModes.js +5 -4
- package/src/nodes/display/BumpMapNode.js +1 -1
- package/src/nodes/display/ColorAdjustment.js +1 -1
- package/src/nodes/display/NormalMapNode.js +2 -1
- package/src/nodes/display/PassNode.js +51 -10
- package/src/nodes/display/RenderOutputNode.js +28 -2
- package/src/nodes/display/ScreenNode.js +2 -1
- package/src/nodes/display/ToneMappingNode.js +31 -4
- package/src/nodes/display/ToonOutlinePassNode.js +8 -0
- package/src/nodes/fog/Fog.js +3 -2
- package/src/nodes/functions/BSDF/BRDF_GGX_Multiscatter.js +52 -0
- package/src/nodes/functions/BSDF/DFGApprox.js +60 -19
- package/src/nodes/functions/BasicLightingModel.js +2 -1
- package/src/nodes/functions/PhysicalLightingModel.js +3 -2
- package/src/nodes/functions/VolumetricLightingModel.js +5 -5
- package/src/nodes/geometry/RangeNode.js +40 -4
- package/src/nodes/gpgpu/ComputeBuiltinNode.js +2 -1
- package/src/nodes/gpgpu/ComputeNode.js +17 -5
- package/src/nodes/gpgpu/SubgroupFunctionNode.js +25 -0
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +2 -1
- package/src/nodes/lighting/EnvironmentNode.js +6 -6
- package/src/nodes/lighting/LightsNode.js +2 -3
- package/src/nodes/lighting/PointShadowNode.js +6 -0
- package/src/nodes/lighting/ShadowFilterNode.js +2 -0
- package/src/nodes/lighting/ShadowNode.js +75 -8
- package/src/nodes/math/ConditionalNode.js +6 -5
- package/src/nodes/math/MathNode.js +22 -4
- package/src/nodes/math/OperatorNode.js +3 -2
- package/src/nodes/pmrem/PMREMUtils.js +117 -2
- package/src/nodes/shapes/Shapes.js +1 -1
- package/src/nodes/tsl/TSLBase.js +5 -2
- package/src/nodes/tsl/TSLCore.js +36 -15
- package/src/nodes/utils/DebugNode.js +2 -1
- package/src/nodes/utils/EventNode.js +36 -0
- package/src/nodes/utils/FunctionOverloadingNode.js +37 -19
- package/src/nodes/utils/JoinNode.js +3 -2
- package/src/nodes/utils/LoopNode.js +20 -24
- package/src/nodes/utils/MemberNode.js +2 -1
- package/src/nodes/utils/PostProcessingUtils.js +28 -1
- package/src/nodes/utils/RTTNode.js +12 -2
- package/src/nodes/utils/ReflectorNode.js +10 -3
- package/src/objects/Line.js +2 -1
- package/src/objects/LineSegments.js +2 -1
- package/src/objects/Skeleton.js +3 -2
- package/src/objects/SkinnedMesh.js +3 -1
- package/src/objects/Sprite.js +2 -1
- package/src/renderers/WebGLRenderer.js +49 -33
- package/src/renderers/common/Animation.js +13 -1
- package/src/renderers/common/Backend.js +93 -30
- package/src/renderers/common/Background.js +2 -1
- package/src/renderers/common/Bindings.js +56 -2
- package/src/renderers/common/CanvasTarget.js +341 -0
- package/src/renderers/common/Geometries.js +26 -0
- package/src/renderers/common/Info.js +4 -2
- package/src/renderers/common/InspectorBase.js +146 -0
- package/src/renderers/common/PostProcessing.js +6 -25
- package/src/renderers/common/QuadMesh.js +7 -1
- package/src/renderers/common/RenderList.js +7 -3
- package/src/renderers/common/RenderObject.js +3 -1
- package/src/renderers/common/RenderObjects.js +1 -1
- package/src/renderers/common/Renderer.js +436 -228
- package/src/renderers/common/RendererUtils.js +9 -0
- package/src/renderers/common/SampledTexture.js +8 -0
- package/src/renderers/common/Sampler.js +37 -11
- package/src/renderers/common/StorageTexture.js +9 -1
- package/src/renderers/common/Textures.js +89 -35
- package/src/renderers/common/TimestampQueryPool.js +63 -1
- package/src/renderers/common/UniformsGroup.js +2 -1
- package/src/renderers/common/XRManager.js +7 -3
- package/src/renderers/common/extras/PMREMGenerator.js +160 -65
- package/src/renderers/common/nodes/NodeLibrary.js +4 -2
- package/src/renderers/common/nodes/NodeSampler.js +13 -1
- package/src/renderers/common/nodes/Nodes.js +38 -16
- package/src/renderers/shaders/DFGLUTData.js +64 -0
- package/src/renderers/shaders/ShaderChunk/common.glsl.js +0 -12
- package/src/renderers/shaders/ShaderChunk/envmap_common_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/envmap_physical_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +52 -18
- package/src/renderers/shaders/UniformsLib.js +1 -0
- package/src/renderers/shaders/UniformsUtils.js +25 -4
- package/src/renderers/webgl/WebGLCapabilities.js +2 -1
- package/src/renderers/webgl/WebGLExtensions.js +2 -25
- package/src/renderers/webgl/WebGLInfo.js +3 -1
- package/src/renderers/webgl/WebGLProgram.js +11 -10
- package/src/renderers/webgl/WebGLPrograms.js +2 -1
- package/src/renderers/webgl/WebGLShadowMap.js +2 -1
- package/src/renderers/webgl/WebGLState.js +15 -14
- package/src/renderers/webgl/WebGLTextures.js +18 -14
- package/src/renderers/webgl/WebGLUniformsGroups.js +5 -3
- package/src/renderers/webgl-fallback/WebGLBackend.js +22 -41
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +74 -11
- package/src/renderers/webgl-fallback/utils/WebGLConstants.js +2 -3
- package/src/renderers/webgl-fallback/utils/WebGLState.js +6 -5
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +117 -16
- package/src/renderers/webgl-fallback/utils/WebGLTimestampQueryPool.js +42 -12
- package/src/renderers/webgpu/WebGPUBackend.js +134 -108
- package/src/renderers/webgpu/WebGPURenderer.Nodes.js +2 -1
- package/src/renderers/webgpu/WebGPURenderer.js +3 -2
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +21 -19
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +2 -1
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +5 -3
- package/src/renderers/webgpu/utils/WebGPUConstants.js +5 -0
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +44 -16
- package/src/renderers/webgpu/utils/WebGPUTexturePassUtils.js +6 -8
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +146 -74
- package/src/renderers/webgpu/utils/WebGPUTimestampQueryPool.js +29 -6
- package/src/renderers/webgpu/utils/WebGPUUtils.js +22 -2
- package/src/renderers/webxr/WebXRManager.js +3 -2
- package/src/textures/Source.js +2 -1
- package/src/textures/Texture.js +3 -2
- package/src/textures/VideoTexture.js +2 -0
- package/src/utils.js +67 -3
|
@@ -2,6 +2,7 @@ import TempNode from '../core/TempNode.js';
|
|
|
2
2
|
import { sub, mul, div, mod, equal } from './OperatorNode.js';
|
|
3
3
|
import { addMethodChaining, nodeObject, nodeProxyIntent, float, vec2, vec3, vec4, Fn } from '../tsl/TSLCore.js';
|
|
4
4
|
import { WebGLCoordinateSystem, WebGPUCoordinateSystem } from '../../constants.js';
|
|
5
|
+
import { warn } from '../../utils.js';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* This node represents a variety of mathematical methods available in shaders.
|
|
@@ -290,7 +291,7 @@ class MathNode extends TempNode {
|
|
|
290
291
|
|
|
291
292
|
if ( builder.shaderStage !== 'fragment' && ( method === MathNode.DFDX || method === MathNode.DFDY ) ) {
|
|
292
293
|
|
|
293
|
-
|
|
294
|
+
warn( `TSL: '${ method }' is not supported in the ${ builder.shaderStage } stage.` );
|
|
294
295
|
|
|
295
296
|
method = '/*' + method + '*/';
|
|
296
297
|
|
|
@@ -414,13 +415,30 @@ export const INFINITY = /*@__PURE__*/ float( 1e6 );
|
|
|
414
415
|
*/
|
|
415
416
|
export const PI = /*@__PURE__*/ float( Math.PI );
|
|
416
417
|
|
|
418
|
+
/**
|
|
419
|
+
* Represents PI * 2. Please use the non-deprecated version `TWO_PI`.
|
|
420
|
+
*
|
|
421
|
+
* @tsl
|
|
422
|
+
* @deprecated
|
|
423
|
+
* @type {Node<float>}
|
|
424
|
+
*/
|
|
425
|
+
export const PI2 = /*@__PURE__*/ float( Math.PI * 2 ); // @deprecated r181
|
|
426
|
+
|
|
417
427
|
/**
|
|
418
428
|
* Represents PI * 2.
|
|
419
429
|
*
|
|
420
430
|
* @tsl
|
|
421
431
|
* @type {Node<float>}
|
|
422
432
|
*/
|
|
423
|
-
export const
|
|
433
|
+
export const TWO_PI = /*@__PURE__*/ float( Math.PI * 2 );
|
|
434
|
+
|
|
435
|
+
/**
|
|
436
|
+
* Represents PI / 2.
|
|
437
|
+
*
|
|
438
|
+
* @tsl
|
|
439
|
+
* @type {Node<float>}
|
|
440
|
+
*/
|
|
441
|
+
export const HALF_PI = /*@__PURE__*/ float( Math.PI * 0.5 );
|
|
424
442
|
|
|
425
443
|
/**
|
|
426
444
|
* Returns `true` if all components of `x` are `true`.
|
|
@@ -778,7 +796,7 @@ export const inverse = /*@__PURE__*/ nodeProxyIntent( MathNode, MathNode.INVERSE
|
|
|
778
796
|
*/
|
|
779
797
|
export const equals = ( x, y ) => { // @deprecated, r172
|
|
780
798
|
|
|
781
|
-
|
|
799
|
+
warn( 'TSL: "equals" is deprecated. Use "equal" inside a vector instead, like: "bvec*( equal( ... ) )"' );
|
|
782
800
|
return equal( x, y );
|
|
783
801
|
|
|
784
802
|
};
|
|
@@ -1076,7 +1094,7 @@ export const stepElement = ( x, edge ) => step( edge, x );
|
|
|
1076
1094
|
*/
|
|
1077
1095
|
export const atan2 = ( y, x ) => { // @deprecated, r172
|
|
1078
1096
|
|
|
1079
|
-
|
|
1097
|
+
warn( 'TSL: "atan2" is overloaded. Use "atan" instead.' );
|
|
1080
1098
|
return atan( y, x );
|
|
1081
1099
|
|
|
1082
1100
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { WebGLCoordinateSystem } from '../../constants.js';
|
|
2
2
|
import TempNode from '../core/TempNode.js';
|
|
3
3
|
import { addMethodChaining, Fn, int, nodeProxyIntent } from '../tsl/TSLCore.js';
|
|
4
|
+
import { warn } from '../../utils.js';
|
|
4
5
|
|
|
5
6
|
const _vectorOperators = {
|
|
6
7
|
'==': 'equal',
|
|
@@ -596,7 +597,7 @@ export const bitAnd = /*@__PURE__*/ nodeProxyIntent( OperatorNode, '&' ).setPara
|
|
|
596
597
|
* @param {Node} b - The second input.
|
|
597
598
|
* @returns {OperatorNode}
|
|
598
599
|
*/
|
|
599
|
-
export const bitNot = /*@__PURE__*/ nodeProxyIntent( OperatorNode, '~' ).setParameterLength(
|
|
600
|
+
export const bitNot = /*@__PURE__*/ nodeProxyIntent( OperatorNode, '~' ).setParameterLength( 1 ).setName( 'bitNot' );
|
|
600
601
|
|
|
601
602
|
/**
|
|
602
603
|
* Performs bitwise OR on two nodes.
|
|
@@ -742,7 +743,7 @@ addMethodChaining( 'decrement', decrement );
|
|
|
742
743
|
*/
|
|
743
744
|
export const modInt = ( a, b ) => { // @deprecated, r175
|
|
744
745
|
|
|
745
|
-
|
|
746
|
+
warn( 'TSL: "modInt()" is deprecated. Use "mod( int( ... ) )" instead.' );
|
|
746
747
|
return mod( int( a ), int( b ) );
|
|
747
748
|
|
|
748
749
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Fn, int, float, vec2, vec3, vec4, If } from '../tsl/TSLBase.js';
|
|
2
|
-
import { cos, sin, abs, max, exp2, log2, clamp, fract, mix, floor, normalize, cross } from '../math/MathNode.js';
|
|
1
|
+
import { Fn, int, uint, float, vec2, vec3, vec4, If } from '../tsl/TSLBase.js';
|
|
2
|
+
import { cos, sin, abs, max, exp2, log2, clamp, fract, mix, floor, normalize, cross, dot, sqrt } from '../math/MathNode.js';
|
|
3
3
|
import { mul } from '../math/OperatorNode.js';
|
|
4
4
|
import { select } from '../math/ConditionalNode.js';
|
|
5
5
|
import { Loop, Break } from '../utils/LoopNode.js';
|
|
@@ -286,3 +286,118 @@ export const blur = /*@__PURE__*/ Fn( ( { n, latitudinal, poleAxis, outputDirect
|
|
|
286
286
|
return vec4( gl_FragColor, 1 );
|
|
287
287
|
|
|
288
288
|
} );
|
|
289
|
+
|
|
290
|
+
// GGX VNDF importance sampling functions
|
|
291
|
+
|
|
292
|
+
// Van der Corput radical inverse for generating quasi-random sequences
|
|
293
|
+
const radicalInverse_VdC = /*@__PURE__*/ Fn( ( [ bits_immutable ] ) => {
|
|
294
|
+
|
|
295
|
+
const bits = uint( bits_immutable ).toVar();
|
|
296
|
+
bits.assign( bits.shiftLeft( uint( 16 ) ).bitOr( bits.shiftRight( uint( 16 ) ) ) );
|
|
297
|
+
bits.assign( bits.bitAnd( uint( 0x55555555 ) ).shiftLeft( uint( 1 ) ).bitOr( bits.bitAnd( uint( 0xAAAAAAAA ) ).shiftRight( uint( 1 ) ) ) );
|
|
298
|
+
bits.assign( bits.bitAnd( uint( 0x33333333 ) ).shiftLeft( uint( 2 ) ).bitOr( bits.bitAnd( uint( 0xCCCCCCCC ) ).shiftRight( uint( 2 ) ) ) );
|
|
299
|
+
bits.assign( bits.bitAnd( uint( 0x0F0F0F0F ) ).shiftLeft( uint( 4 ) ).bitOr( bits.bitAnd( uint( 0xF0F0F0F0 ) ).shiftRight( uint( 4 ) ) ) );
|
|
300
|
+
bits.assign( bits.bitAnd( uint( 0x00FF00FF ) ).shiftLeft( uint( 8 ) ).bitOr( bits.bitAnd( uint( 0xFF00FF00 ) ).shiftRight( uint( 8 ) ) ) );
|
|
301
|
+
return float( bits ).mul( 2.3283064365386963e-10 ); // / 0x100000000
|
|
302
|
+
|
|
303
|
+
} );
|
|
304
|
+
|
|
305
|
+
// Hammersley sequence for quasi-Monte Carlo sampling
|
|
306
|
+
const hammersley = /*@__PURE__*/ Fn( ( [ i, N ] ) => {
|
|
307
|
+
|
|
308
|
+
return vec2( float( i ).div( float( N ) ), radicalInverse_VdC( i ) );
|
|
309
|
+
|
|
310
|
+
} );
|
|
311
|
+
|
|
312
|
+
// GGX VNDF importance sampling (Eric Heitz 2018)
|
|
313
|
+
// "Sampling the GGX Distribution of Visible Normals"
|
|
314
|
+
// https://jcgt.org/published/0007/04/01/
|
|
315
|
+
const importanceSampleGGX_VNDF = /*@__PURE__*/ Fn( ( [ Xi, V_immutable, roughness_immutable ] ) => {
|
|
316
|
+
|
|
317
|
+
const V = vec3( V_immutable ).toVar();
|
|
318
|
+
const roughness = float( roughness_immutable );
|
|
319
|
+
const alpha = roughness.mul( roughness ).toVar();
|
|
320
|
+
|
|
321
|
+
// Section 3.2: Transform view direction to hemisphere configuration
|
|
322
|
+
const Vh = normalize( vec3( alpha.mul( V.x ), alpha.mul( V.y ), V.z ) ).toVar();
|
|
323
|
+
|
|
324
|
+
// Section 4.1: Orthonormal basis
|
|
325
|
+
const lensq = Vh.x.mul( Vh.x ).add( Vh.y.mul( Vh.y ) );
|
|
326
|
+
const T1 = select( lensq.greaterThan( 0.0 ), vec3( Vh.y.negate(), Vh.x, 0.0 ).div( sqrt( lensq ) ), vec3( 1.0, 0.0, 0.0 ) ).toVar();
|
|
327
|
+
const T2 = cross( Vh, T1 ).toVar();
|
|
328
|
+
|
|
329
|
+
// Section 4.2: Parameterization of projected area
|
|
330
|
+
const r = sqrt( Xi.x );
|
|
331
|
+
const phi = mul( 2.0, 3.14159265359 ).mul( Xi.y );
|
|
332
|
+
const t1 = r.mul( cos( phi ) ).toVar();
|
|
333
|
+
const t2 = r.mul( sin( phi ) ).toVar();
|
|
334
|
+
const s = mul( 0.5, Vh.z.add( 1.0 ) );
|
|
335
|
+
t2.assign( s.oneMinus().mul( sqrt( t1.mul( t1 ).oneMinus() ) ).add( s.mul( t2 ) ) );
|
|
336
|
+
|
|
337
|
+
// Section 4.3: Reprojection onto hemisphere
|
|
338
|
+
const Nh = T1.mul( t1 ).add( T2.mul( t2 ) ).add( Vh.mul( sqrt( max( 0.0, t1.mul( t1 ).add( t2.mul( t2 ) ).oneMinus() ) ) ) );
|
|
339
|
+
|
|
340
|
+
// Section 3.4: Transform back to ellipsoid configuration
|
|
341
|
+
return normalize( vec3( alpha.mul( Nh.x ), alpha.mul( Nh.y ), max( 0.0, Nh.z ) ) );
|
|
342
|
+
|
|
343
|
+
} );
|
|
344
|
+
|
|
345
|
+
// GGX convolution using VNDF importance sampling
|
|
346
|
+
export const ggxConvolution = /*@__PURE__*/ Fn( ( { roughness, mipInt, envMap, N_immutable, GGX_SAMPLES, CUBEUV_TEXEL_WIDTH, CUBEUV_TEXEL_HEIGHT, CUBEUV_MAX_MIP } ) => {
|
|
347
|
+
|
|
348
|
+
const N = vec3( N_immutable ).toVar();
|
|
349
|
+
|
|
350
|
+
const prefilteredColor = vec3( 0.0 ).toVar();
|
|
351
|
+
const totalWeight = float( 0.0 ).toVar();
|
|
352
|
+
|
|
353
|
+
// For very low roughness, just sample the environment directly
|
|
354
|
+
If( roughness.lessThan( 0.001 ), () => {
|
|
355
|
+
|
|
356
|
+
prefilteredColor.assign( bilinearCubeUV( envMap, N, mipInt, CUBEUV_TEXEL_WIDTH, CUBEUV_TEXEL_HEIGHT, CUBEUV_MAX_MIP ) );
|
|
357
|
+
|
|
358
|
+
} ).Else( () => {
|
|
359
|
+
|
|
360
|
+
// Tangent space basis for VNDF sampling
|
|
361
|
+
const up = select( abs( N.z ).lessThan( 0.999 ), vec3( 0.0, 0.0, 1.0 ), vec3( 1.0, 0.0, 0.0 ) );
|
|
362
|
+
const tangent = normalize( cross( up, N ) ).toVar();
|
|
363
|
+
const bitangent = cross( N, tangent ).toVar();
|
|
364
|
+
|
|
365
|
+
Loop( { start: uint( 0 ), end: GGX_SAMPLES }, ( { i } ) => {
|
|
366
|
+
|
|
367
|
+
const Xi = hammersley( i, GGX_SAMPLES );
|
|
368
|
+
|
|
369
|
+
// For PMREM, V = N, so in tangent space V is always (0, 0, 1)
|
|
370
|
+
const H_tangent = importanceSampleGGX_VNDF( Xi, vec3( 0.0, 0.0, 1.0 ), roughness );
|
|
371
|
+
|
|
372
|
+
// Transform H back to world space
|
|
373
|
+
const H = normalize( tangent.mul( H_tangent.x ).add( bitangent.mul( H_tangent.y ) ).add( N.mul( H_tangent.z ) ) );
|
|
374
|
+
const L = normalize( H.mul( dot( N, H ).mul( 2.0 ) ).sub( N ) );
|
|
375
|
+
|
|
376
|
+
const NdotL = max( dot( N, L ), 0.0 );
|
|
377
|
+
|
|
378
|
+
If( NdotL.greaterThan( 0.0 ), () => {
|
|
379
|
+
|
|
380
|
+
// Sample environment at fixed mip level
|
|
381
|
+
// VNDF importance sampling handles the distribution filtering
|
|
382
|
+
const sampleColor = bilinearCubeUV( envMap, L, mipInt, CUBEUV_TEXEL_WIDTH, CUBEUV_TEXEL_HEIGHT, CUBEUV_MAX_MIP );
|
|
383
|
+
|
|
384
|
+
// Weight by NdotL for the split-sum approximation
|
|
385
|
+
// VNDF PDF naturally accounts for the visible microfacet distribution
|
|
386
|
+
prefilteredColor.addAssign( sampleColor.mul( NdotL ) );
|
|
387
|
+
totalWeight.addAssign( NdotL );
|
|
388
|
+
|
|
389
|
+
} );
|
|
390
|
+
|
|
391
|
+
} );
|
|
392
|
+
|
|
393
|
+
If( totalWeight.greaterThan( 0.0 ), () => {
|
|
394
|
+
|
|
395
|
+
prefilteredColor.assign( prefilteredColor.div( totalWeight ) );
|
|
396
|
+
|
|
397
|
+
} );
|
|
398
|
+
|
|
399
|
+
} );
|
|
400
|
+
|
|
401
|
+
return vec4( prefilteredColor, 1.0 );
|
|
402
|
+
|
|
403
|
+
} );
|
|
@@ -16,7 +16,7 @@ export const shapeCircle = Fn( ( [ coord = uv() ], { renderer, material } ) => {
|
|
|
16
16
|
|
|
17
17
|
let alpha;
|
|
18
18
|
|
|
19
|
-
if ( material.alphaToCoverage && renderer.
|
|
19
|
+
if ( material.alphaToCoverage && renderer.currentSamples > 0 ) {
|
|
20
20
|
|
|
21
21
|
const dlen = float( len2.fwidth() ).toVar();
|
|
22
22
|
|
package/src/nodes/tsl/TSLBase.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { warn } from '../../utils.js';
|
|
2
|
+
|
|
1
3
|
// Non-PURE exports list, side-effects are required here.
|
|
2
4
|
// TSL Base Syntax
|
|
3
5
|
|
|
@@ -17,7 +19,7 @@ export * from '../display/ColorSpaceNode.js'; // .toColorSpace()
|
|
|
17
19
|
export * from '../display/ToneMappingNode.js'; // .toToneMapping()
|
|
18
20
|
export * from '../accessors/BufferAttributeNode.js'; // .toAttribute()
|
|
19
21
|
export * from '../gpgpu/ComputeNode.js'; // .compute()
|
|
20
|
-
export * from '../core/
|
|
22
|
+
export * from '../core/IsolateNode.js'; // .isolate()
|
|
21
23
|
export * from '../core/BypassNode.js'; // .bypass()
|
|
22
24
|
export * from '../utils/RemapNode.js'; // .remap(), .remapClamp()
|
|
23
25
|
export * from '../code/ExpressionNode.js'; // expression()
|
|
@@ -25,9 +27,10 @@ export * from '../utils/Discard.js'; // Discard(), Return()
|
|
|
25
27
|
export * from '../display/RenderOutputNode.js'; // .renderOutput()
|
|
26
28
|
export * from '../utils/DebugNode.js'; // debug()
|
|
27
29
|
export * from '../core/SubBuildNode.js'; // subBuild()
|
|
30
|
+
export * from '../core/InspectorNode.js'; // inspector(), .toInspector()
|
|
28
31
|
|
|
29
32
|
export function addNodeElement( name/*, nodeElement*/ ) {
|
|
30
33
|
|
|
31
|
-
|
|
34
|
+
warn( 'TSL: AddNodeElement has been removed in favor of tree-shaking. Trying add', name );
|
|
32
35
|
|
|
33
36
|
}
|
package/src/nodes/tsl/TSLCore.js
CHANGED
|
@@ -8,6 +8,7 @@ import FlipNode from '../utils/FlipNode.js';
|
|
|
8
8
|
import ConstNode from '../core/ConstNode.js';
|
|
9
9
|
import MemberNode from '../utils/MemberNode.js';
|
|
10
10
|
import { getValueFromType, getValueType } from '../core/NodeUtils.js';
|
|
11
|
+
import { warn, error } from '../../utils.js';
|
|
11
12
|
|
|
12
13
|
let currentStack = null;
|
|
13
14
|
|
|
@@ -19,7 +20,7 @@ export function addMethodChaining( name, nodeElement ) {
|
|
|
19
20
|
|
|
20
21
|
if ( NodeElements.has( name ) ) {
|
|
21
22
|
|
|
22
|
-
|
|
23
|
+
warn( `TSL: Redefinition of method chaining '${ name }'.` );
|
|
23
24
|
return;
|
|
24
25
|
|
|
25
26
|
}
|
|
@@ -36,7 +37,7 @@ export function addMethodChaining( name, nodeElement ) {
|
|
|
36
37
|
|
|
37
38
|
//if ( name === 'toVarIntent' ) return this;
|
|
38
39
|
|
|
39
|
-
return this.isStackNode ? this.
|
|
40
|
+
return this.isStackNode ? this.addToStack( nodeElement( ...params ) ) : nodeElement( this, ...params );
|
|
40
41
|
|
|
41
42
|
};
|
|
42
43
|
|
|
@@ -65,7 +66,7 @@ Node.prototype.assign = function ( ...params ) {
|
|
|
65
66
|
|
|
66
67
|
} else {
|
|
67
68
|
|
|
68
|
-
|
|
69
|
+
error( 'TSL: No stack defined for assign operation. Make sure the assign is inside a Fn().' );
|
|
69
70
|
|
|
70
71
|
}
|
|
71
72
|
|
|
@@ -75,7 +76,7 @@ Node.prototype.assign = function ( ...params ) {
|
|
|
75
76
|
|
|
76
77
|
const nodeElement = NodeElements.get( 'assign' );
|
|
77
78
|
|
|
78
|
-
return this.
|
|
79
|
+
return this.addToStack( nodeElement( ...params ) );
|
|
79
80
|
|
|
80
81
|
}
|
|
81
82
|
|
|
@@ -373,13 +374,13 @@ const ShaderNodeProxy = function ( NodeClass, scope = null, factor = null, setti
|
|
|
373
374
|
|
|
374
375
|
if ( minParams !== undefined && params.length < minParams ) {
|
|
375
376
|
|
|
376
|
-
|
|
377
|
+
error( `TSL: "${ tslName }" parameter length is less than minimum required.` );
|
|
377
378
|
|
|
378
379
|
return params.concat( new Array( minParams - params.length ).fill( 0 ) );
|
|
379
380
|
|
|
380
381
|
} else if ( maxParams !== undefined && params.length > maxParams ) {
|
|
381
382
|
|
|
382
|
-
|
|
383
|
+
error( `TSL: "${ tslName }" parameter length exceeds limit.` );
|
|
383
384
|
|
|
384
385
|
return params.slice( 0, maxParams );
|
|
385
386
|
|
|
@@ -463,6 +464,12 @@ class ShaderCallNodeInternal extends Node {
|
|
|
463
464
|
|
|
464
465
|
}
|
|
465
466
|
|
|
467
|
+
getElementType( builder ) {
|
|
468
|
+
|
|
469
|
+
return this.getOutputNode( builder ).getElementType( builder );
|
|
470
|
+
|
|
471
|
+
}
|
|
472
|
+
|
|
466
473
|
getMemberType( builder, name ) {
|
|
467
474
|
|
|
468
475
|
return this.getOutputNode( builder ).getMemberType( builder, name );
|
|
@@ -487,8 +494,10 @@ class ShaderCallNodeInternal extends Node {
|
|
|
487
494
|
//
|
|
488
495
|
|
|
489
496
|
const previousSubBuildFn = builder.subBuildFn;
|
|
497
|
+
const previousFnCall = builder.fnCall;
|
|
490
498
|
|
|
491
499
|
builder.subBuildFn = subBuild;
|
|
500
|
+
builder.fnCall = this;
|
|
492
501
|
|
|
493
502
|
let result = null;
|
|
494
503
|
|
|
@@ -564,6 +573,7 @@ class ShaderCallNodeInternal extends Node {
|
|
|
564
573
|
}
|
|
565
574
|
|
|
566
575
|
builder.subBuildFn = previousSubBuildFn;
|
|
576
|
+
builder.fnCall = previousFnCall;
|
|
567
577
|
|
|
568
578
|
if ( shaderNode.once ) {
|
|
569
579
|
|
|
@@ -607,6 +617,10 @@ class ShaderCallNodeInternal extends Node {
|
|
|
607
617
|
const subBuildOutput = builder.getSubBuildOutput( this );
|
|
608
618
|
const outputNode = this.getOutputNode( builder );
|
|
609
619
|
|
|
620
|
+
const previousFnCall = builder.fnCall;
|
|
621
|
+
|
|
622
|
+
builder.fnCall = this;
|
|
623
|
+
|
|
610
624
|
if ( buildStage === 'setup' ) {
|
|
611
625
|
|
|
612
626
|
const subBuildInitialized = builder.getSubBuildProperty( 'initialized', this );
|
|
@@ -654,6 +668,8 @@ class ShaderCallNodeInternal extends Node {
|
|
|
654
668
|
|
|
655
669
|
}
|
|
656
670
|
|
|
671
|
+
builder.fnCall = previousFnCall;
|
|
672
|
+
|
|
657
673
|
return result;
|
|
658
674
|
|
|
659
675
|
}
|
|
@@ -787,9 +803,15 @@ class ShaderNodeInternal extends Node {
|
|
|
787
803
|
|
|
788
804
|
}
|
|
789
805
|
|
|
806
|
+
getLayout() {
|
|
807
|
+
|
|
808
|
+
return this.layout;
|
|
809
|
+
|
|
810
|
+
}
|
|
811
|
+
|
|
790
812
|
call( rawInputs = null ) {
|
|
791
813
|
|
|
792
|
-
return
|
|
814
|
+
return new ShaderCallNodeInternal( this, rawInputs );
|
|
793
815
|
|
|
794
816
|
}
|
|
795
817
|
|
|
@@ -849,7 +871,7 @@ const ConvertType = function ( type, cacheMap = null ) {
|
|
|
849
871
|
|
|
850
872
|
if ( param === undefined ) {
|
|
851
873
|
|
|
852
|
-
|
|
874
|
+
error( `TSL: Invalid parameter for the type "${ type }".` );
|
|
853
875
|
|
|
854
876
|
return nodeObject( new ConstNode( 0, type ) );
|
|
855
877
|
|
|
@@ -912,7 +934,7 @@ export const nodeObjects = ( val, altType = null ) => new ShaderNodeObjects( val
|
|
|
912
934
|
export const nodeArray = ( val, altType = null ) => new ShaderNodeArray( val, altType );
|
|
913
935
|
export const nodeProxy = ( NodeClass, scope = null, factor = null, settings = null ) => new ShaderNodeProxy( NodeClass, scope, factor, settings );
|
|
914
936
|
export const nodeImmutable = ( NodeClass, ...params ) => new ShaderNodeImmutable( NodeClass, ...params );
|
|
915
|
-
export const nodeProxyIntent = ( NodeClass, scope = null, factor = null, settings = {} ) => new ShaderNodeProxy( NodeClass, scope, factor, { intent: true
|
|
937
|
+
export const nodeProxyIntent = ( NodeClass, scope = null, factor = null, settings = {} ) => new ShaderNodeProxy( NodeClass, scope, factor, { ...settings, intent: true } );
|
|
916
938
|
|
|
917
939
|
let fnId = 0;
|
|
918
940
|
|
|
@@ -938,7 +960,7 @@ class FnNode extends Node {
|
|
|
938
960
|
|
|
939
961
|
} else {
|
|
940
962
|
|
|
941
|
-
|
|
963
|
+
error( 'TSL: Invalid layout type.' );
|
|
942
964
|
|
|
943
965
|
}
|
|
944
966
|
|
|
@@ -1022,7 +1044,7 @@ class FnNode extends Node {
|
|
|
1022
1044
|
|
|
1023
1045
|
const type = this.getNodeType( builder );
|
|
1024
1046
|
|
|
1025
|
-
|
|
1047
|
+
error( 'TSL: "Fn()" was declared but not invoked. Try calling it like "Fn()( ...params )".' );
|
|
1026
1048
|
|
|
1027
1049
|
return builder.generateConst( type );
|
|
1028
1050
|
|
|
@@ -1113,7 +1135,7 @@ export const Switch = ( ...params ) => currentStack.Switch( ...params );
|
|
|
1113
1135
|
*/
|
|
1114
1136
|
export function Stack( node ) {
|
|
1115
1137
|
|
|
1116
|
-
if ( currentStack ) currentStack.
|
|
1138
|
+
if ( currentStack ) currentStack.addToStack( node );
|
|
1117
1139
|
|
|
1118
1140
|
return node;
|
|
1119
1141
|
|
|
@@ -1194,15 +1216,14 @@ addMethodChaining( 'convert', convert );
|
|
|
1194
1216
|
*/
|
|
1195
1217
|
export const append = ( node ) => { // @deprecated, r176
|
|
1196
1218
|
|
|
1197
|
-
|
|
1219
|
+
warn( 'TSL: append() has been renamed to Stack().' );
|
|
1198
1220
|
return Stack( node );
|
|
1199
1221
|
|
|
1200
1222
|
};
|
|
1201
1223
|
|
|
1202
1224
|
addMethodChaining( 'append', ( node ) => { // @deprecated, r176
|
|
1203
1225
|
|
|
1204
|
-
|
|
1226
|
+
warn( 'TSL: .append() has been renamed to .toStack().' );
|
|
1205
1227
|
return Stack( node );
|
|
1206
1228
|
|
|
1207
1229
|
} );
|
|
1208
|
-
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import TempNode from '../core/TempNode.js';
|
|
2
2
|
import { addMethodChaining, nodeObject } from '../tsl/TSLCore.js';
|
|
3
|
+
import { log } from '../../utils.js';
|
|
3
4
|
|
|
4
5
|
class DebugNode extends TempNode {
|
|
5
6
|
|
|
@@ -56,7 +57,7 @@ class DebugNode extends TempNode {
|
|
|
56
57
|
|
|
57
58
|
} else {
|
|
58
59
|
|
|
59
|
-
|
|
60
|
+
log( code );
|
|
60
61
|
|
|
61
62
|
}
|
|
62
63
|
|
|
@@ -36,6 +36,14 @@ class EventNode extends Node {
|
|
|
36
36
|
|
|
37
37
|
this.updateType = NodeUpdateType.RENDER;
|
|
38
38
|
|
|
39
|
+
} else if ( eventType === EventNode.BEFORE_OBJECT ) {
|
|
40
|
+
|
|
41
|
+
this.updateBeforeType = NodeUpdateType.OBJECT;
|
|
42
|
+
|
|
43
|
+
} else if ( eventType === EventNode.BEFORE_MATERIAL ) {
|
|
44
|
+
|
|
45
|
+
this.updateBeforeType = NodeUpdateType.RENDER;
|
|
46
|
+
|
|
39
47
|
}
|
|
40
48
|
|
|
41
49
|
}
|
|
@@ -46,10 +54,18 @@ class EventNode extends Node {
|
|
|
46
54
|
|
|
47
55
|
}
|
|
48
56
|
|
|
57
|
+
updateBefore( frame ) {
|
|
58
|
+
|
|
59
|
+
this.callback( frame );
|
|
60
|
+
|
|
61
|
+
}
|
|
62
|
+
|
|
49
63
|
}
|
|
50
64
|
|
|
51
65
|
EventNode.OBJECT = 'object';
|
|
52
66
|
EventNode.MATERIAL = 'material';
|
|
67
|
+
EventNode.BEFORE_OBJECT = 'beforeObject';
|
|
68
|
+
EventNode.BEFORE_MATERIAL = 'beforeMaterial';
|
|
53
69
|
|
|
54
70
|
export default EventNode;
|
|
55
71
|
|
|
@@ -81,3 +97,23 @@ export const OnObjectUpdate = ( callback ) => createEvent( EventNode.OBJECT, cal
|
|
|
81
97
|
* @returns {EventNode}
|
|
82
98
|
*/
|
|
83
99
|
export const OnMaterialUpdate = ( callback ) => createEvent( EventNode.MATERIAL, callback );
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Creates an event that triggers a function before an object (Mesh|Sprite) is updated.
|
|
103
|
+
*
|
|
104
|
+
* The event will be bound to the declared TSL function `Fn()`; it must be declared within a `Fn()` or the JS function call must be inherited from one.
|
|
105
|
+
*
|
|
106
|
+
* @param {Function} callback - The callback function.
|
|
107
|
+
* @returns {EventNode}
|
|
108
|
+
*/
|
|
109
|
+
export const OnBeforeObjectUpdate = ( callback ) => createEvent( EventNode.BEFORE_OBJECT, callback );
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Creates an event that triggers a function before the material is updated.
|
|
113
|
+
*
|
|
114
|
+
* The event will be bound to the declared TSL function `Fn()`; it must be declared within a `Fn()` or the JS function call must be inherited from one.
|
|
115
|
+
*
|
|
116
|
+
* @param {Function} callback - The callback function.
|
|
117
|
+
* @returns {EventNode}
|
|
118
|
+
*/
|
|
119
|
+
export const OnBeforeMaterialUpdate = ( callback ) => createEvent( EventNode.BEFORE_MATERIAL, callback );
|
|
@@ -46,7 +46,7 @@ class FunctionOverloadingNode extends Node {
|
|
|
46
46
|
* @private
|
|
47
47
|
* @type {ShaderCallNodeInternal}
|
|
48
48
|
*/
|
|
49
|
-
this.
|
|
49
|
+
this._candidateFn = null;
|
|
50
50
|
|
|
51
51
|
/**
|
|
52
52
|
* This node is marked as global.
|
|
@@ -65,22 +65,30 @@ class FunctionOverloadingNode extends Node {
|
|
|
65
65
|
* @param {NodeBuilder} builder - The current node builder.
|
|
66
66
|
* @return {string} The node type.
|
|
67
67
|
*/
|
|
68
|
-
getNodeType() {
|
|
68
|
+
getNodeType( builder ) {
|
|
69
69
|
|
|
70
|
-
|
|
70
|
+
const candidateFn = this.getCandidateFn( builder );
|
|
71
|
+
|
|
72
|
+
return candidateFn.shaderNode.layout.type;
|
|
71
73
|
|
|
72
74
|
}
|
|
73
75
|
|
|
74
|
-
|
|
76
|
+
/**
|
|
77
|
+
* Returns the candidate function for the current parameters.
|
|
78
|
+
*
|
|
79
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
80
|
+
* @return {FunctionNode} The candidate function.
|
|
81
|
+
*/
|
|
82
|
+
getCandidateFn( builder ) {
|
|
75
83
|
|
|
76
84
|
const params = this.parametersNodes;
|
|
77
85
|
|
|
78
|
-
let
|
|
86
|
+
let candidateFn = this._candidateFn;
|
|
79
87
|
|
|
80
|
-
if (
|
|
88
|
+
if ( candidateFn === null ) {
|
|
81
89
|
|
|
82
|
-
let
|
|
83
|
-
let
|
|
90
|
+
let bestCandidateFn = null;
|
|
91
|
+
let bestScore = - 1;
|
|
84
92
|
|
|
85
93
|
for ( const functionNode of this.functionNodes ) {
|
|
86
94
|
|
|
@@ -97,7 +105,7 @@ class FunctionOverloadingNode extends Node {
|
|
|
97
105
|
|
|
98
106
|
if ( params.length === inputs.length ) {
|
|
99
107
|
|
|
100
|
-
let
|
|
108
|
+
let currentScore = 0;
|
|
101
109
|
|
|
102
110
|
for ( let i = 0; i < params.length; i ++ ) {
|
|
103
111
|
|
|
@@ -106,20 +114,16 @@ class FunctionOverloadingNode extends Node {
|
|
|
106
114
|
|
|
107
115
|
if ( param.getNodeType( builder ) === input.type ) {
|
|
108
116
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
} else {
|
|
112
|
-
|
|
113
|
-
score = 0;
|
|
117
|
+
currentScore ++;
|
|
114
118
|
|
|
115
119
|
}
|
|
116
120
|
|
|
117
121
|
}
|
|
118
122
|
|
|
119
|
-
if (
|
|
123
|
+
if ( currentScore > bestScore ) {
|
|
120
124
|
|
|
121
|
-
|
|
122
|
-
|
|
125
|
+
bestCandidateFn = functionNode;
|
|
126
|
+
bestScore = currentScore;
|
|
123
127
|
|
|
124
128
|
}
|
|
125
129
|
|
|
@@ -127,11 +131,25 @@ class FunctionOverloadingNode extends Node {
|
|
|
127
131
|
|
|
128
132
|
}
|
|
129
133
|
|
|
130
|
-
this.
|
|
134
|
+
this._candidateFn = candidateFn = bestCandidateFn;
|
|
131
135
|
|
|
132
136
|
}
|
|
133
137
|
|
|
134
|
-
return
|
|
138
|
+
return candidateFn;
|
|
139
|
+
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Sets up the node for the current parameters.
|
|
144
|
+
*
|
|
145
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
146
|
+
* @return {Node} The setup node.
|
|
147
|
+
*/
|
|
148
|
+
setup( builder ) {
|
|
149
|
+
|
|
150
|
+
const candidateFn = this.getCandidateFn( builder );
|
|
151
|
+
|
|
152
|
+
return candidateFn( ...this.parametersNodes );
|
|
135
153
|
|
|
136
154
|
}
|
|
137
155
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import TempNode from '../core/TempNode.js';
|
|
2
|
+
import { error } from '../../utils.js';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* This module is part of the TSL core and usually not used in app level code.
|
|
@@ -70,7 +71,7 @@ class JoinNode extends TempNode {
|
|
|
70
71
|
|
|
71
72
|
if ( length >= maxLength ) {
|
|
72
73
|
|
|
73
|
-
|
|
74
|
+
error( `TSL: Length of parameters exceeds maximum length of function '${ type }()' type.` );
|
|
74
75
|
break;
|
|
75
76
|
|
|
76
77
|
}
|
|
@@ -81,7 +82,7 @@ class JoinNode extends TempNode {
|
|
|
81
82
|
|
|
82
83
|
if ( length + inputTypeLength > maxLength ) {
|
|
83
84
|
|
|
84
|
-
|
|
85
|
+
error( `TSL: Length of '${ type }()' data exceeds maximum length of output type.` );
|
|
85
86
|
|
|
86
87
|
inputTypeLength = maxLength - length;
|
|
87
88
|
inputType = builder.getTypeFromLength( inputTypeLength );
|