super-three 0.152.0 → 0.154.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/build/three.cjs +779 -557
- package/build/three.js +779 -557
- package/build/three.min.js +2 -1
- package/build/three.module.js +770 -539
- package/build/three.module.min.js +2 -1
- package/examples/jsm/cameras/CinematicCamera.js +1 -2
- package/examples/jsm/capabilities/WebGPU.js +15 -1
- package/examples/jsm/controls/ArcballControls.js +2 -1
- package/examples/jsm/controls/FlyControls.js +25 -9
- package/examples/jsm/controls/OrbitControls.js +5 -1
- package/examples/jsm/csm/CSM.js +1 -3
- package/examples/jsm/effects/AnaglyphEffect.js +6 -20
- package/examples/jsm/effects/OutlineEffect.js +1 -1
- package/examples/jsm/effects/ParallaxBarrierEffect.js +3 -0
- package/examples/jsm/environments/RoomEnvironment.js +6 -2
- package/examples/jsm/exporters/GLTFExporter.js +74 -2
- package/examples/jsm/exporters/USDZExporter.js +170 -129
- package/examples/jsm/helpers/ViewHelper.js +1 -1
- package/examples/jsm/lines/LineMaterial.js +1 -1
- package/examples/jsm/loaders/3DMLoader.js +1 -1
- package/examples/jsm/loaders/3MFLoader.js +5 -1
- package/examples/jsm/loaders/AMFLoader.js +5 -1
- package/examples/jsm/loaders/ColladaLoader.js +4 -1
- package/examples/jsm/loaders/DRACOLoader.js +2 -0
- package/examples/jsm/loaders/FBXLoader.js +9 -2
- package/examples/jsm/loaders/GLTFLoader.js +230 -94
- package/examples/jsm/loaders/KTX2Loader.js +106 -47
- package/examples/jsm/loaders/LDrawLoader.js +4 -7
- package/examples/jsm/loaders/MMDLoader.js +40 -13
- package/examples/jsm/loaders/PCDLoader.js +25 -10
- package/examples/jsm/loaders/PDBLoader.js +7 -2
- package/examples/jsm/loaders/PLYLoader.js +30 -8
- package/examples/jsm/loaders/STLLoader.js +8 -3
- package/examples/jsm/loaders/VRMLLoader.js +55 -7
- package/examples/jsm/loaders/VTKLoader.js +12 -4
- package/examples/jsm/loaders/XYZLoader.js +9 -3
- package/examples/jsm/materials/MeshGouraudMaterial.js +2 -2
- package/examples/jsm/math/Lut.js +5 -4
- package/examples/jsm/math/MeshSurfaceSampler.js +82 -37
- package/examples/jsm/misc/GPUComputationRenderer.js +1 -0
- package/examples/jsm/misc/VolumeSlice.js +3 -1
- package/examples/jsm/nodes/Nodes.js +22 -16
- package/examples/jsm/nodes/accessors/BufferAttributeNode.js +99 -0
- package/examples/jsm/nodes/accessors/BufferNode.js +2 -2
- package/examples/jsm/nodes/accessors/CameraNode.js +25 -4
- package/examples/jsm/nodes/accessors/ExtendedMaterialNode.js +7 -1
- package/examples/jsm/nodes/accessors/InstanceNode.js +29 -12
- package/examples/jsm/nodes/accessors/MaterialNode.js +55 -47
- package/examples/jsm/nodes/accessors/MaterialReferenceNode.js +2 -2
- package/examples/jsm/nodes/accessors/ModelNode.js +3 -1
- package/examples/jsm/nodes/accessors/ModelViewProjectionNode.js +4 -9
- package/examples/jsm/nodes/accessors/MorphNode.js +70 -0
- package/examples/jsm/nodes/accessors/NormalNode.js +3 -2
- package/examples/jsm/nodes/accessors/Object3DNode.js +10 -2
- package/examples/jsm/nodes/accessors/ReferenceNode.js +2 -2
- package/examples/jsm/nodes/accessors/SceneNode.js +46 -0
- package/examples/jsm/nodes/accessors/SkinningNode.js +43 -62
- package/examples/jsm/nodes/accessors/StorageBufferNode.js +2 -2
- package/examples/jsm/nodes/accessors/TangentNode.js +2 -2
- package/examples/jsm/nodes/accessors/TextureBicubicNode.js +94 -0
- package/examples/jsm/nodes/accessors/TextureNode.js +68 -6
- package/examples/jsm/nodes/accessors/TextureSizeNode.js +35 -0
- package/examples/jsm/nodes/accessors/UVNode.js +1 -1
- package/examples/jsm/nodes/code/CodeNode.js +3 -0
- package/examples/jsm/nodes/code/FunctionNode.js +25 -4
- package/examples/jsm/nodes/core/AttributeNode.js +1 -1
- package/examples/jsm/nodes/core/BypassNode.js +2 -2
- package/examples/jsm/nodes/core/ContextNode.js +2 -0
- package/examples/jsm/nodes/core/IndexNode.js +66 -0
- package/examples/jsm/nodes/core/LightingModel.js +2 -1
- package/examples/jsm/nodes/core/Node.js +13 -16
- package/examples/jsm/nodes/core/NodeAttribute.js +2 -1
- package/examples/jsm/nodes/core/NodeBuilder.js +86 -8
- package/examples/jsm/nodes/core/NodeUtils.js +10 -0
- package/examples/jsm/nodes/core/PropertyNode.js +6 -2
- package/examples/jsm/nodes/core/StackNode.js +8 -1
- package/examples/jsm/nodes/core/UniformNode.js +1 -1
- package/examples/jsm/nodes/core/VarNode.js +1 -3
- package/examples/jsm/nodes/display/BlendModeNode.js +9 -9
- package/examples/jsm/nodes/display/ColorAdjustmentNode.js +7 -7
- package/examples/jsm/nodes/display/ColorSpaceNode.js +50 -49
- package/examples/jsm/nodes/display/NormalMapNode.js +3 -3
- package/examples/jsm/nodes/display/ToneMappingNode.js +24 -15
- package/examples/jsm/nodes/display/ViewportDepthNode.js +69 -0
- package/examples/jsm/nodes/display/ViewportDepthTextureNode.js +34 -0
- package/examples/jsm/nodes/display/ViewportSharedTextureNode.js +7 -6
- package/examples/jsm/nodes/display/ViewportTextureNode.js +33 -19
- package/examples/jsm/nodes/functions/BSDF/BRDF_BlinnPhong.js +5 -5
- package/examples/jsm/nodes/functions/BSDF/BRDF_GGX.js +10 -8
- package/examples/jsm/nodes/functions/BSDF/BRDF_Lambert.js +2 -2
- package/examples/jsm/nodes/functions/BSDF/BRDF_Sheen.js +43 -0
- package/examples/jsm/nodes/functions/BSDF/DFGApprox.js +4 -4
- package/examples/jsm/nodes/functions/BSDF/D_GGX.js +2 -2
- package/examples/jsm/nodes/functions/BSDF/EnvironmentBRDF.js +13 -0
- package/examples/jsm/nodes/functions/BSDF/F_Schlick.js +2 -4
- package/examples/jsm/nodes/functions/BSDF/V_GGX_SmithCorrelated.js +2 -2
- package/examples/jsm/nodes/functions/PhongLightingModel.js +7 -7
- package/examples/jsm/nodes/functions/PhysicalLightingModel.js +132 -19
- package/examples/jsm/nodes/functions/material/getGeometryRoughness.js +2 -2
- package/examples/jsm/nodes/functions/material/getRoughness.js +3 -3
- package/examples/jsm/nodes/geometry/RangeNode.js +33 -51
- package/examples/jsm/nodes/lighting/AnalyticLightNode.js +6 -3
- package/examples/jsm/nodes/lighting/DirectionalLightNode.js +2 -2
- package/examples/jsm/nodes/lighting/EnvironmentNode.js +107 -62
- package/examples/jsm/nodes/lighting/HemisphereLightNode.js +2 -2
- package/examples/jsm/nodes/lighting/LightUtils.js +2 -2
- package/examples/jsm/nodes/lighting/LightingContextNode.js +17 -15
- package/examples/jsm/nodes/lighting/PointLightNode.js +3 -3
- package/examples/jsm/nodes/lighting/SpotLightNode.js +3 -3
- package/examples/jsm/nodes/materials/LineBasicNodeMaterial.js +0 -15
- package/examples/jsm/nodes/materials/MeshBasicNodeMaterial.js +0 -15
- package/examples/jsm/nodes/materials/MeshNormalNodeMaterial.js +0 -10
- package/examples/jsm/nodes/materials/MeshPhongNodeMaterial.js +0 -9
- package/examples/jsm/nodes/materials/MeshPhysicalNodeMaterial.js +41 -0
- package/examples/jsm/nodes/materials/MeshStandardNodeMaterial.js +1 -14
- package/examples/jsm/nodes/materials/NodeMaterial.js +119 -29
- package/examples/jsm/nodes/materials/PointsNodeMaterial.js +0 -9
- package/examples/jsm/nodes/materials/SpriteNodeMaterial.js +0 -7
- package/examples/jsm/nodes/materialx/lib/mx_hsv.js +3 -3
- package/examples/jsm/nodes/materialx/lib/mx_noise.js +14 -14
- package/examples/jsm/nodes/materialx/lib/mx_transform_color.js +4 -4
- package/examples/jsm/nodes/math/MathNode.js +6 -0
- package/examples/jsm/nodes/math/OperatorNode.js +1 -1
- package/examples/jsm/nodes/procedural/CheckerNode.js +3 -3
- package/examples/jsm/nodes/shadernode/ShaderNode.js +60 -33
- package/examples/jsm/nodes/utils/EquirectUVNode.js +2 -3
- package/examples/jsm/nodes/utils/LoopNode.js +186 -0
- package/examples/jsm/nodes/utils/TriplanarTexturesNode.js +1 -1
- package/examples/jsm/objects/GroundProjectedSkybox.js +1 -1
- package/examples/jsm/objects/Lensflare.js +3 -4
- package/examples/jsm/objects/MarchingCubes.js +5 -1
- package/examples/jsm/objects/Reflector.js +4 -1
- package/examples/jsm/objects/Refractor.js +1 -1
- package/examples/jsm/objects/Sky.js +1 -1
- package/examples/jsm/objects/Water.js +2 -1
- package/examples/jsm/objects/Water2.js +1 -1
- package/examples/jsm/offscreen/scene.js +1 -0
- package/examples/jsm/physics/RapierPhysics.js +93 -133
- package/examples/jsm/postprocessing/AfterimagePass.js +3 -0
- package/examples/jsm/postprocessing/BloomPass.js +7 -2
- package/examples/jsm/postprocessing/BokehPass.js +3 -2
- package/examples/jsm/postprocessing/DotScreenPass.js +1 -0
- package/examples/jsm/postprocessing/EffectComposer.js +4 -1
- package/examples/jsm/postprocessing/FilmPass.js +1 -0
- package/examples/jsm/postprocessing/OutlinePass.js +8 -9
- package/examples/jsm/postprocessing/OutputPass.js +72 -0
- package/examples/jsm/postprocessing/RenderPixelatedPass.js +4 -3
- package/examples/jsm/postprocessing/SAOPass.js +4 -2
- package/examples/jsm/postprocessing/SMAAPass.js +5 -2
- package/examples/jsm/postprocessing/SSAARenderPass.js +5 -13
- package/examples/jsm/postprocessing/SSAOPass.js +4 -2
- package/examples/jsm/postprocessing/SSRPass.js +3 -1
- package/examples/jsm/postprocessing/SavePass.js +5 -2
- package/examples/jsm/postprocessing/ShaderPass.js +1 -0
- package/examples/jsm/postprocessing/TAARenderPass.js +17 -4
- package/examples/jsm/postprocessing/TexturePass.js +2 -1
- package/examples/jsm/postprocessing/UnrealBloomPass.js +13 -13
- package/examples/jsm/renderers/{webgpu/WebGPUAnimation.js → common/Animation.js} +2 -2
- package/examples/jsm/renderers/common/Attributes.js +75 -0
- package/examples/jsm/renderers/common/Backend.js +162 -0
- package/examples/jsm/renderers/common/Background.js +134 -0
- package/examples/jsm/renderers/common/Binding.js +11 -0
- package/examples/jsm/renderers/common/Bindings.js +169 -0
- package/examples/jsm/renderers/common/Buffer.js +38 -0
- package/examples/jsm/renderers/{webgpu/WebGPUBufferUtils.js → common/BufferUtils.js} +2 -2
- package/examples/jsm/renderers/{webgpu/WebGPUWeakMap.js → common/ChainMap.js} +11 -5
- package/examples/jsm/renderers/common/ComputePipeline.js +17 -0
- package/examples/jsm/renderers/common/Constants.js +14 -0
- package/examples/jsm/renderers/common/CubeRenderTarget.js +65 -0
- package/examples/jsm/renderers/common/DataMap.js +54 -0
- package/examples/jsm/renderers/{webgpu/WebGPUGeometries.js → common/Geometries.js} +38 -37
- package/examples/jsm/renderers/{webgpu/WebGPUInfo.js → common/Info.js} +2 -3
- package/examples/jsm/renderers/common/Pipeline.js +13 -0
- package/examples/jsm/renderers/common/Pipelines.js +321 -0
- package/examples/jsm/renderers/common/ProgrammableStage.js +18 -0
- package/examples/jsm/renderers/common/RenderContext.js +37 -0
- package/examples/jsm/renderers/common/RenderContexts.js +38 -0
- package/examples/jsm/renderers/{webgpu/WebGPURenderLists.js → common/RenderList.js} +2 -39
- package/examples/jsm/renderers/common/RenderLists.js +38 -0
- package/examples/jsm/renderers/common/RenderObject.js +113 -0
- package/examples/jsm/renderers/common/RenderObjects.js +92 -0
- package/examples/jsm/renderers/common/RenderPipeline.js +16 -0
- package/examples/jsm/renderers/{webgpu/WebGPURenderTarget.js → common/RenderTarget.js} +2 -2
- package/examples/jsm/renderers/common/Renderer.js +864 -0
- package/examples/jsm/renderers/common/SampledTexture.js +80 -0
- package/examples/jsm/renderers/common/Sampler.js +18 -0
- package/examples/jsm/renderers/common/StorageBuffer.js +17 -0
- package/examples/jsm/renderers/common/Textures.js +206 -0
- package/examples/jsm/renderers/{webgpu/WebGPUUniform.js → common/Uniform.js} +13 -9
- package/examples/jsm/renderers/common/UniformBuffer.js +15 -0
- package/examples/jsm/renderers/{webgpu/WebGPUUniformsGroup.js → common/UniformsGroup.js} +13 -13
- package/examples/jsm/renderers/{webgpu/nodes/WebGPUNodes.js → common/nodes/NodeRender.js} +3 -3
- package/examples/jsm/renderers/{webgpu/nodes/WebGPUNodeSampledTexture.js → common/nodes/NodeSampledTexture.js} +4 -4
- package/examples/jsm/renderers/{webgpu/nodes/WebGPUNodeSampler.js → common/nodes/NodeSampler.js} +3 -3
- package/examples/jsm/renderers/{webgpu/nodes/WebGPUNodeUniform.js → common/nodes/NodeUniform.js} +1 -1
- package/examples/jsm/renderers/common/nodes/Nodes.js +319 -0
- package/examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js +340 -0
- package/examples/jsm/renderers/webgl/nodes/WebGLNodeBuilder.js +23 -19
- package/examples/jsm/renderers/webgpu/WebGPUBackend.js +847 -0
- package/examples/jsm/renderers/webgpu/WebGPURenderer.js +15 -1131
- package/examples/jsm/renderers/webgpu/nodes/{WebGPUNodeBuilder.js → WGSLNodeBuilder.js} +75 -45
- package/examples/jsm/{nodes/parsers → renderers/webgpu/nodes}/WGSLNodeFunction.js +2 -2
- package/examples/jsm/{nodes/parsers → renderers/webgpu/nodes}/WGSLNodeParser.js +1 -1
- package/examples/jsm/renderers/webgpu/utils/WebGPUAttributeUtils.js +255 -0
- package/examples/jsm/renderers/webgpu/utils/WebGPUBindingUtils.js +145 -0
- package/examples/jsm/renderers/webgpu/{constants.js → utils/WebGPUConstants.js} +6 -7
- package/examples/jsm/renderers/webgpu/{WebGPURenderPipeline.js → utils/WebGPUPipelineUtils.js} +154 -247
- package/examples/jsm/renderers/webgpu/{WebGPUTextureUtils.js → utils/WebGPUTextureMipmapUtils.js} +3 -25
- package/examples/jsm/renderers/webgpu/{WebGPUTextures.js → utils/WebGPUTextureUtils.js} +392 -505
- package/examples/jsm/renderers/webgpu/utils/WebGPUUtils.js +92 -0
- package/examples/jsm/shaders/BleachBypassShader.js +2 -0
- package/examples/jsm/shaders/BlendShader.js +1 -2
- package/examples/jsm/shaders/BokehShader2.js +3 -0
- package/examples/jsm/shaders/ColorifyShader.js +2 -0
- package/examples/jsm/shaders/ConvolutionShader.js +2 -0
- package/examples/jsm/shaders/CopyShader.js +4 -2
- package/examples/jsm/shaders/DotScreenShader.js +2 -0
- package/examples/jsm/shaders/ExposureShader.js +44 -0
- package/examples/jsm/shaders/FilmShader.js +2 -0
- package/examples/jsm/shaders/GammaCorrectionShader.js +2 -0
- package/examples/jsm/shaders/HorizontalBlurShader.js +2 -0
- package/examples/jsm/shaders/OutputShader.js +61 -0
- package/examples/jsm/shaders/RGBShiftShader.js +2 -0
- package/examples/jsm/shaders/SepiaShader.js +2 -0
- package/examples/jsm/shaders/ToonShader.js +13 -5
- package/examples/jsm/shaders/VerticalBlurShader.js +2 -0
- package/examples/jsm/shaders/VignetteShader.js +2 -0
- package/examples/jsm/shaders/WaterRefractionShader.js +5 -2
- package/examples/jsm/utils/BufferGeometryUtils.js +17 -1
- package/examples/jsm/utils/TextureUtils.js +86 -0
- package/examples/jsm/webxr/OculusHandPointerModel.js +34 -13
- package/examples/jsm/webxr/XRHandPrimitiveModel.js +1 -0
- package/examples/jsm/webxr/XRPlanes.js +100 -0
- package/package.json +3 -1
- package/src/Three.Legacy.js +0 -228
- package/src/audio/PositionalAudio.js +8 -0
- package/src/cameras/Camera.js +5 -0
- package/src/cameras/CubeCamera.js +76 -13
- package/src/cameras/OrthographicCamera.js +1 -1
- package/src/cameras/PerspectiveCamera.js +1 -1
- package/src/constants.js +13 -1
- package/src/core/BufferAttribute.js +3 -25
- package/src/core/BufferGeometry.js +1 -8
- package/src/core/Object3D.js +1 -1
- package/src/extras/core/Curve.js +1 -1
- package/src/loaders/CubeTextureLoader.js +2 -0
- package/src/loaders/Loader.js +2 -0
- package/src/loaders/MaterialLoader.js +5 -0
- package/src/loaders/ObjectLoader.js +1 -0
- package/src/materials/Material.js +13 -1
- package/src/materials/MeshPhysicalMaterial.js +32 -6
- package/src/math/Color.js +16 -11
- package/src/math/Frustum.js +16 -2
- package/src/math/MathUtils.js +16 -0
- package/src/math/Matrix3.js +26 -6
- package/src/math/Matrix4.js +74 -19
- package/src/objects/InstancedMesh.js +3 -0
- package/src/objects/Mesh.js +14 -10
- package/src/objects/Skeleton.js +1 -3
- package/src/objects/SkinnedMesh.js +36 -8
- package/src/renderers/WebGLRenderer.js +126 -21
- package/src/renderers/shaders/ShaderChunk/alphahash_fragment.glsl.js +7 -0
- package/src/renderers/shaders/ShaderChunk/alphahash_pars_fragment.glsl.js +68 -0
- package/src/renderers/shaders/ShaderChunk/begin_vertex.glsl.js +6 -0
- package/src/renderers/shaders/ShaderChunk/common.glsl.js +6 -0
- package/src/renderers/shaders/ShaderChunk/envmap_physical_pars_fragment.glsl.js +26 -3
- package/src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js +9 -1
- package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +26 -0
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +52 -2
- package/src/renderers/shaders/ShaderChunk/normal_fragment_begin.glsl.js +10 -2
- package/src/renderers/shaders/ShaderChunk/normalmap_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/{output_fragment.glsl.js → opaque_fragment.glsl.js} +1 -2
- package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/transmission_fragment.glsl.js +3 -3
- package/src/renderers/shaders/ShaderChunk/transmission_pars_fragment.glsl.js +10 -5
- package/src/renderers/shaders/ShaderChunk/uv_pars_fragment.glsl.js +6 -1
- package/src/renderers/shaders/ShaderChunk/uv_pars_vertex.glsl.js +7 -1
- package/src/renderers/shaders/ShaderChunk/uv_vertex.glsl.js +6 -1
- package/src/renderers/shaders/ShaderChunk.js +10 -6
- package/src/renderers/shaders/ShaderLib/background.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/backgroundCube.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/cube.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/depth.glsl.js +2 -0
- package/src/renderers/shaders/ShaderLib/distanceRGBA.glsl.js +2 -0
- package/src/renderers/shaders/ShaderLib/equirect.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/linedashed.glsl.js +2 -2
- package/src/renderers/shaders/ShaderLib/meshbasic.glsl.js +4 -2
- package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +4 -2
- package/src/renderers/shaders/ShaderLib/meshmatcap.glsl.js +4 -2
- package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +4 -2
- package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +12 -2
- package/src/renderers/shaders/ShaderLib/meshtoon.glsl.js +4 -2
- package/src/renderers/shaders/ShaderLib/points.glsl.js +4 -2
- package/src/renderers/shaders/ShaderLib/shadow.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/sprite.glsl.js +4 -2
- package/src/renderers/shaders/ShaderLib.js +4 -1
- package/src/renderers/shaders/UniformsLib.js +2 -0
- package/src/renderers/webgl/WebGLBindingStates.js +13 -5
- package/src/renderers/webgl/WebGLGeometries.js +12 -0
- package/src/renderers/webgl/WebGLInfo.js +0 -1
- package/src/renderers/webgl/WebGLMaterials.js +18 -0
- package/src/renderers/webgl/WebGLObjects.js +23 -3
- package/src/renderers/webgl/WebGLProgram.js +43 -5
- package/src/renderers/webgl/WebGLPrograms.js +19 -7
- package/src/renderers/webgl/WebGLTextures.js +19 -1
- package/src/renderers/webvr/WebVRManager.js +12 -0
- package/src/renderers/webxr/WebXRManager.js +39 -99
- package/src/scenes/Scene.js +0 -14
- package/src/textures/DepthTexture.js +22 -0
- package/src/textures/FramebufferTexture.js +1 -3
- package/src/textures/Source.js +4 -0
- package/src/textures/Texture.js +1 -1
- package/examples/jsm/exporters/ColladaExporter.js +0 -725
- package/examples/jsm/geometries/LightningStrike.js +0 -1017
- package/examples/jsm/loaders/PRWMLoader.js +0 -299
- package/examples/jsm/nodes/core/InstanceIndexNode.js +0 -26
- package/examples/jsm/objects/LightningStorm.js +0 -245
- package/examples/jsm/postprocessing/AdaptiveToneMappingPass.js +0 -361
- package/examples/jsm/renderers/webgpu/WebGPUAttributes.js +0 -197
- package/examples/jsm/renderers/webgpu/WebGPUBackground.js +0 -190
- package/examples/jsm/renderers/webgpu/WebGPUBinding.js +0 -22
- package/examples/jsm/renderers/webgpu/WebGPUBindings.js +0 -270
- package/examples/jsm/renderers/webgpu/WebGPUBuffer.js +0 -43
- package/examples/jsm/renderers/webgpu/WebGPUComputePipelines.js +0 -78
- package/examples/jsm/renderers/webgpu/WebGPUProgrammableStage.js +0 -22
- package/examples/jsm/renderers/webgpu/WebGPUProperties.js +0 -44
- package/examples/jsm/renderers/webgpu/WebGPURenderObject.js +0 -40
- package/examples/jsm/renderers/webgpu/WebGPURenderObjects.js +0 -50
- package/examples/jsm/renderers/webgpu/WebGPURenderPipelines.js +0 -274
- package/examples/jsm/renderers/webgpu/WebGPURenderStates.js +0 -54
- package/examples/jsm/renderers/webgpu/WebGPUSampledTexture.js +0 -75
- package/examples/jsm/renderers/webgpu/WebGPUSampler.js +0 -29
- package/examples/jsm/renderers/webgpu/WebGPUStorageBuffer.js +0 -20
- package/examples/jsm/renderers/webgpu/WebGPUTextureRenderer.js +0 -38
- package/examples/jsm/renderers/webgpu/WebGPUUniformBuffer.js +0 -18
- package/examples/jsm/renderers/webgpu/WebGPUUtils.js +0 -88
- package/examples/jsm/shaders/ToneMapShader.js +0 -73
- /package/src/renderers/shaders/ShaderChunk/{encodings_fragment.glsl.js → colorspace_fragment.glsl.js} +0 -0
- /package/src/renderers/shaders/ShaderChunk/{encodings_pars_fragment.glsl.js → colorspace_pars_fragment.glsl.js} +0 -0
|
@@ -46,7 +46,7 @@ class MeshStandardNodeMaterial extends NodeMaterial {
|
|
|
46
46
|
// ROUGHNESS
|
|
47
47
|
|
|
48
48
|
let roughnessNode = this.roughnessNode ? float( this.roughnessNode ) : materialRoughness;
|
|
49
|
-
roughnessNode = getRoughness
|
|
49
|
+
roughnessNode = getRoughness( { roughness: roughnessNode } );
|
|
50
50
|
|
|
51
51
|
stack.assign( roughness, roughnessNode );
|
|
52
52
|
|
|
@@ -64,24 +64,11 @@ class MeshStandardNodeMaterial extends NodeMaterial {
|
|
|
64
64
|
|
|
65
65
|
copy( source ) {
|
|
66
66
|
|
|
67
|
-
this.colorNode = source.colorNode;
|
|
68
|
-
this.opacityNode = source.opacityNode;
|
|
69
|
-
|
|
70
|
-
this.alphaTestNode = source.alphaTestNode;
|
|
71
|
-
|
|
72
|
-
this.normalNode = source.normalNode;
|
|
73
|
-
|
|
74
67
|
this.emissiveNode = source.emissiveNode;
|
|
75
68
|
|
|
76
69
|
this.metalnessNode = source.metalnessNode;
|
|
77
70
|
this.roughnessNode = source.roughnessNode;
|
|
78
71
|
|
|
79
|
-
this.envNode = source.envNode;
|
|
80
|
-
|
|
81
|
-
this.lightsNode = source.lightsNode;
|
|
82
|
-
|
|
83
|
-
this.positionNode = source.positionNode;
|
|
84
|
-
|
|
85
72
|
return super.copy( source );
|
|
86
73
|
|
|
87
74
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Material, ShaderMaterial } from 'three';
|
|
1
|
+
import { Material, ShaderMaterial, NoColorSpace } from 'three';
|
|
2
2
|
import { getNodeChildren, getCacheKey } from '../core/NodeUtils.js';
|
|
3
3
|
import { attribute } from '../core/AttributeNode.js';
|
|
4
4
|
import { diffuseColor } from '../core/PropertyNode.js';
|
|
@@ -7,11 +7,13 @@ import { materialAlphaTest, materialColor, materialOpacity, materialEmissive } f
|
|
|
7
7
|
import { modelViewProjection } from '../accessors/ModelViewProjectionNode.js';
|
|
8
8
|
import { transformedNormalView } from '../accessors/NormalNode.js';
|
|
9
9
|
import { instance } from '../accessors/InstanceNode.js';
|
|
10
|
-
import { positionLocal } from '../accessors/PositionNode.js';
|
|
10
|
+
import { positionLocal, positionView } from '../accessors/PositionNode.js';
|
|
11
11
|
import { skinning } from '../accessors/SkinningNode.js';
|
|
12
|
+
import { morph } from '../accessors/MorphNode.js';
|
|
12
13
|
import { texture } from '../accessors/TextureNode.js';
|
|
14
|
+
import { cubeTexture } from '../accessors/CubeTextureNode.js';
|
|
13
15
|
import { lightsWithoutWrap } from '../lighting/LightsNode.js';
|
|
14
|
-
import { mix } from '../math/MathNode.js';
|
|
16
|
+
import { mix, dFdx, dFdy } from '../math/MathNode.js';
|
|
15
17
|
import { float, vec3, vec4 } from '../shadernode/ShaderNode.js';
|
|
16
18
|
import AONode from '../lighting/AONode.js';
|
|
17
19
|
import EnvironmentNode from '../lighting/EnvironmentNode.js';
|
|
@@ -28,6 +30,8 @@ class NodeMaterial extends ShaderMaterial {
|
|
|
28
30
|
|
|
29
31
|
this.type = this.constructor.name;
|
|
30
32
|
|
|
33
|
+
this.forceSinglePass = false;
|
|
34
|
+
|
|
31
35
|
this.lights = true;
|
|
32
36
|
this.normals = true;
|
|
33
37
|
|
|
@@ -42,12 +46,13 @@ class NodeMaterial extends ShaderMaterial {
|
|
|
42
46
|
this.alphaTestNode = null;
|
|
43
47
|
|
|
44
48
|
this.positionNode = null;
|
|
49
|
+
this.outputNode = null;
|
|
45
50
|
|
|
46
51
|
}
|
|
47
52
|
|
|
48
53
|
customProgramCacheKey() {
|
|
49
54
|
|
|
50
|
-
return getCacheKey( this );
|
|
55
|
+
return this.type + getCacheKey( this );
|
|
51
56
|
|
|
52
57
|
}
|
|
53
58
|
|
|
@@ -71,14 +76,22 @@ class NodeMaterial extends ShaderMaterial {
|
|
|
71
76
|
|
|
72
77
|
builder.addStack();
|
|
73
78
|
|
|
74
|
-
if ( this.
|
|
79
|
+
if ( this.isUnlit === false ) {
|
|
80
|
+
|
|
81
|
+
if ( this.normals === true ) this.constructNormal( builder );
|
|
82
|
+
|
|
83
|
+
this.constructDiffuseColor( builder );
|
|
84
|
+
this.constructVariants( builder );
|
|
85
|
+
|
|
86
|
+
const outgoingLightNode = this.constructLighting( builder );
|
|
75
87
|
|
|
76
|
-
|
|
77
|
-
this.constructVariants( builder );
|
|
88
|
+
builder.stack.outputNode = this.constructOutput( builder, vec4( outgoingLightNode, diffuseColor.a ) );
|
|
78
89
|
|
|
79
|
-
|
|
90
|
+
} else {
|
|
80
91
|
|
|
81
|
-
|
|
92
|
+
builder.stack.outputNode = this.constructOutput( builder, this.outputNode || vec4( 0, 0, 0, 1 ) );
|
|
93
|
+
|
|
94
|
+
}
|
|
82
95
|
|
|
83
96
|
builder.addFlow( 'fragment', builder.removeStack() );
|
|
84
97
|
|
|
@@ -87,28 +100,35 @@ class NodeMaterial extends ShaderMaterial {
|
|
|
87
100
|
constructPosition( builder ) {
|
|
88
101
|
|
|
89
102
|
const object = builder.object;
|
|
103
|
+
const geometry = object.geometry;
|
|
104
|
+
|
|
105
|
+
builder.addStack();
|
|
90
106
|
|
|
91
|
-
|
|
107
|
+
if ( geometry.morphAttributes.position || geometry.morphAttributes.normal || geometry.morphAttributes.color ) {
|
|
92
108
|
|
|
93
|
-
|
|
109
|
+
builder.stack.add( morph( object ) );
|
|
94
110
|
|
|
95
|
-
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if ( object.isSkinnedMesh === true ) {
|
|
114
|
+
|
|
115
|
+
builder.stack.add( skinning( object ) );
|
|
96
116
|
|
|
97
117
|
}
|
|
98
118
|
|
|
99
119
|
if ( ( object.instanceMatrix && object.instanceMatrix.isInstancedBufferAttribute === true ) && builder.isAvailable( 'instance' ) === true ) {
|
|
100
120
|
|
|
101
|
-
|
|
121
|
+
builder.stack.add( instance( object ) );
|
|
102
122
|
|
|
103
123
|
}
|
|
104
124
|
|
|
105
|
-
if (
|
|
125
|
+
if ( this.positionNode !== null ) {
|
|
106
126
|
|
|
107
|
-
|
|
127
|
+
builder.stack.assign( positionLocal, this.positionNode );
|
|
108
128
|
|
|
109
129
|
}
|
|
110
130
|
|
|
111
|
-
builder.context.vertex =
|
|
131
|
+
builder.context.vertex = builder.removeStack();
|
|
112
132
|
|
|
113
133
|
return modelViewProjection();
|
|
114
134
|
|
|
@@ -137,9 +157,9 @@ class NodeMaterial extends ShaderMaterial {
|
|
|
137
157
|
|
|
138
158
|
// ALPHA TEST
|
|
139
159
|
|
|
140
|
-
if ( this.alphaTestNode || this.alphaTest > 0 ) {
|
|
160
|
+
if ( this.alphaTestNode !== null || this.alphaTest > 0 ) {
|
|
141
161
|
|
|
142
|
-
const alphaTestNode = this.alphaTestNode ? float( this.alphaTestNode ) : materialAlphaTest;
|
|
162
|
+
const alphaTestNode = this.alphaTestNode !== null ? float( this.alphaTestNode ) : materialAlphaTest;
|
|
143
163
|
|
|
144
164
|
stack.add( diffuseColor.a.lessThanEqual( alphaTestNode ).discard() );
|
|
145
165
|
|
|
@@ -157,17 +177,51 @@ class NodeMaterial extends ShaderMaterial {
|
|
|
157
177
|
|
|
158
178
|
// NORMAL VIEW
|
|
159
179
|
|
|
160
|
-
|
|
180
|
+
if ( this.flatShading === true ) {
|
|
181
|
+
|
|
182
|
+
const fdx = dFdx( positionView );
|
|
183
|
+
const fdy = dFdy( positionView.negate() ); // use -positionView ?
|
|
184
|
+
const normalNode = fdx.cross( fdy ).normalize();
|
|
185
|
+
|
|
186
|
+
stack.assign( transformedNormalView, normalNode );
|
|
187
|
+
|
|
188
|
+
} else {
|
|
189
|
+
|
|
190
|
+
const normalNode = this.normalNode ? vec3( this.normalNode ) : materialNormal;
|
|
191
|
+
|
|
192
|
+
stack.assign( transformedNormalView, normalNode );
|
|
193
|
+
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
getEnvNode( builder ) {
|
|
199
|
+
|
|
200
|
+
let node = null;
|
|
201
|
+
|
|
202
|
+
if ( this.envNode ) {
|
|
161
203
|
|
|
162
|
-
|
|
204
|
+
node = this.envNode;
|
|
163
205
|
|
|
164
|
-
|
|
206
|
+
} else if ( this.envMap ) {
|
|
207
|
+
|
|
208
|
+
node = this.envMap.isCubeTexture ? cubeTexture( this.envMap ) : texture( this.envMap );
|
|
209
|
+
|
|
210
|
+
} else if ( builder.environmentNode ) {
|
|
211
|
+
|
|
212
|
+
node = builder.environmentNode;
|
|
213
|
+
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
return node;
|
|
165
217
|
|
|
166
218
|
}
|
|
167
219
|
|
|
168
220
|
constructLights( builder ) {
|
|
169
221
|
|
|
170
|
-
const envNode = this.
|
|
222
|
+
const envNode = this.getEnvNode( builder );
|
|
223
|
+
|
|
224
|
+
//
|
|
171
225
|
|
|
172
226
|
const materialLightsNode = [];
|
|
173
227
|
|
|
@@ -211,12 +265,13 @@ class NodeMaterial extends ShaderMaterial {
|
|
|
211
265
|
const lights = this.lights === true || this.lightsNode !== null;
|
|
212
266
|
|
|
213
267
|
const lightsNode = lights ? this.constructLights( builder ) : null;
|
|
214
|
-
const lightingModelNode = lightsNode ? this.constructLightingModel( builder ) : null;
|
|
215
268
|
|
|
216
269
|
let outgoingLightNode = diffuseColor.rgb;
|
|
217
270
|
|
|
218
271
|
if ( lightsNode && lightsNode.hasLight !== false ) {
|
|
219
272
|
|
|
273
|
+
const lightingModelNode = this.constructLightingModel( builder );
|
|
274
|
+
|
|
220
275
|
outgoingLightNode = lightsNode.lightingContext( lightingModelNode, backdropNode, backdropAlphaNode );
|
|
221
276
|
|
|
222
277
|
} else if ( backdropNode !== null ) {
|
|
@@ -237,7 +292,7 @@ class NodeMaterial extends ShaderMaterial {
|
|
|
237
292
|
|
|
238
293
|
}
|
|
239
294
|
|
|
240
|
-
constructOutput( builder,
|
|
295
|
+
constructOutput( builder, outputNode ) {
|
|
241
296
|
|
|
242
297
|
const renderer = builder.renderer;
|
|
243
298
|
|
|
@@ -247,17 +302,27 @@ class NodeMaterial extends ShaderMaterial {
|
|
|
247
302
|
|
|
248
303
|
if ( toneMappingNode ) {
|
|
249
304
|
|
|
250
|
-
|
|
305
|
+
outputNode = vec4( toneMappingNode.context( { color: outputNode.rgb } ), outputNode.a );
|
|
251
306
|
|
|
252
307
|
}
|
|
253
308
|
|
|
254
|
-
//
|
|
309
|
+
// ENCODING
|
|
310
|
+
|
|
311
|
+
const renderTarget = renderer.getRenderTarget();
|
|
255
312
|
|
|
256
|
-
let
|
|
313
|
+
let outputColorSpace;
|
|
257
314
|
|
|
258
|
-
|
|
315
|
+
if ( renderTarget !== null ) {
|
|
259
316
|
|
|
260
|
-
|
|
317
|
+
outputColorSpace = renderTarget.texture.colorSpace;
|
|
318
|
+
|
|
319
|
+
} else {
|
|
320
|
+
|
|
321
|
+
outputColorSpace = renderer.outputColorSpace;
|
|
322
|
+
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
if ( outputColorSpace !== NoColorSpace ) outputNode = outputNode.linearToColorSpace( outputColorSpace );
|
|
261
326
|
|
|
262
327
|
// FOG
|
|
263
328
|
|
|
@@ -364,6 +429,31 @@ class NodeMaterial extends ShaderMaterial {
|
|
|
364
429
|
|
|
365
430
|
}
|
|
366
431
|
|
|
432
|
+
get isUnlit() {
|
|
433
|
+
|
|
434
|
+
return this.constructor === NodeMaterial.prototype.constructor;
|
|
435
|
+
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
copy( source ) {
|
|
439
|
+
|
|
440
|
+
this.lightsNode = source.lightsNode;
|
|
441
|
+
this.envNode = source.envNode;
|
|
442
|
+
|
|
443
|
+
this.colorNode = source.colorNode;
|
|
444
|
+
this.normalNode = source.normalNode;
|
|
445
|
+
this.opacityNode = source.opacityNode;
|
|
446
|
+
this.backdropNode = source.backdropNode;
|
|
447
|
+
this.backdropAlphaNode = source.backdropAlphaNode;
|
|
448
|
+
this.alphaTestNode = source.alphaTestNode;
|
|
449
|
+
|
|
450
|
+
this.positionNode = source.positionNode;
|
|
451
|
+
this.outputNode = source.outputNode;
|
|
452
|
+
|
|
453
|
+
return super.copy( source );
|
|
454
|
+
|
|
455
|
+
}
|
|
456
|
+
|
|
367
457
|
static fromMaterial( material ) {
|
|
368
458
|
|
|
369
459
|
if ( material.isNodeMaterial === true ) { // is already a node material
|
|
@@ -36,17 +36,8 @@ class PointsNodeMaterial extends NodeMaterial {
|
|
|
36
36
|
|
|
37
37
|
copy( source ) {
|
|
38
38
|
|
|
39
|
-
this.colorNode = source.colorNode;
|
|
40
|
-
this.opacityNode = source.opacityNode;
|
|
41
|
-
|
|
42
|
-
this.alphaTestNode = source.alphaTestNode;
|
|
43
|
-
|
|
44
|
-
this.lightNode = source.lightNode;
|
|
45
|
-
|
|
46
39
|
this.sizeNode = source.sizeNode;
|
|
47
40
|
|
|
48
|
-
this.positionNode = source.positionNode;
|
|
49
|
-
|
|
50
41
|
return super.copy( source );
|
|
51
42
|
|
|
52
43
|
}
|
|
@@ -88,13 +88,6 @@ class SpriteNodeMaterial extends NodeMaterial {
|
|
|
88
88
|
|
|
89
89
|
copy( source ) {
|
|
90
90
|
|
|
91
|
-
this.colorNode = source.colorNode;
|
|
92
|
-
this.opacityNode = source.opacityNode;
|
|
93
|
-
|
|
94
|
-
this.alphaTestNode = source.alphaTestNode;
|
|
95
|
-
|
|
96
|
-
this.lightNode = source.lightNode;
|
|
97
|
-
|
|
98
91
|
this.positionNode = source.positionNode;
|
|
99
92
|
this.rotationNode = source.rotationNode;
|
|
100
93
|
this.scaleNode = source.scaleNode;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { glslFn } from '../../code/FunctionNode.js';
|
|
2
2
|
|
|
3
3
|
// Original shader code from:
|
|
4
4
|
// https://github.com/AcademySoftwareFoundation/MaterialX/blob/main/libraries/stdlib/genglsl/lib/mx_hsv.glsl
|
|
5
5
|
|
|
6
|
-
export const mx_hsvtorgb =
|
|
6
|
+
export const mx_hsvtorgb = glslFn( `vec3 mx_hsvtorgb(vec3 hsv)
|
|
7
7
|
{
|
|
8
8
|
// Reference for this technique: Foley & van Dam
|
|
9
9
|
float h = hsv.x; float s = hsv.y; float v = hsv.z;
|
|
@@ -30,7 +30,7 @@ export const mx_hsvtorgb = fn( `vec3 mx_hsvtorgb(vec3 hsv)
|
|
|
30
30
|
}
|
|
31
31
|
}` );
|
|
32
32
|
|
|
33
|
-
export const mx_rgbtohsv =
|
|
33
|
+
export const mx_rgbtohsv = glslFn( `vec3 mx_rgbtohsv(vec3 c)
|
|
34
34
|
{
|
|
35
35
|
// See Foley & van Dam
|
|
36
36
|
float r = c.x; float g = c.y; float b = c.z;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { glsl } from '../../code/CodeNode.js';
|
|
2
|
+
import { glslFn } from '../../code/FunctionNode.js';
|
|
3
3
|
|
|
4
4
|
// Original shader code from:
|
|
5
5
|
// https://github.com/AcademySoftwareFoundation/MaterialX/blob/main/libraries/stdlib/genglsl/lib/mx_noise.glsl
|
|
6
6
|
|
|
7
|
-
export const mx_noise =
|
|
7
|
+
export const mx_noise = glsl( `float mx_select(bool b, float t, float f)
|
|
8
8
|
{
|
|
9
9
|
return b ? t : f;
|
|
10
10
|
}
|
|
@@ -602,17 +602,17 @@ vec3 mx_worley_noise_vec3(vec3 p, float jitter, int metric)
|
|
|
602
602
|
|
|
603
603
|
const includes = [ mx_noise ];
|
|
604
604
|
|
|
605
|
-
export const mx_perlin_noise_float =
|
|
606
|
-
export const mx_perlin_noise_vec2 =
|
|
607
|
-
export const mx_perlin_noise_vec3 =
|
|
605
|
+
export const mx_perlin_noise_float = glslFn( 'float mx_perlin_noise_float( any p )', includes );
|
|
606
|
+
export const mx_perlin_noise_vec2 = glslFn( 'vec2 mx_perlin_noise_vec2( any p )', includes );
|
|
607
|
+
export const mx_perlin_noise_vec3 = glslFn( 'vec3 mx_perlin_noise_vec3( any p )', includes );
|
|
608
608
|
|
|
609
|
-
export const mx_cell_noise_float =
|
|
609
|
+
export const mx_cell_noise_float = glslFn( 'float mx_cell_noise_float( vec3 p )', includes );
|
|
610
610
|
|
|
611
|
-
export const mx_worley_noise_float =
|
|
612
|
-
export const mx_worley_noise_vec2 =
|
|
613
|
-
export const mx_worley_noise_vec3 =
|
|
611
|
+
export const mx_worley_noise_float = glslFn( 'float mx_worley_noise_float( any p, float jitter, int metric )', includes );
|
|
612
|
+
export const mx_worley_noise_vec2 = glslFn( 'float mx_worley_noise_vec2( any p, float jitter, int metric )', includes );
|
|
613
|
+
export const mx_worley_noise_vec3 = glslFn( 'float mx_worley_noise_vec3( any p, float jitter, int metric )', includes );
|
|
614
614
|
|
|
615
|
-
export const mx_fractal_noise_float =
|
|
616
|
-
export const mx_fractal_noise_vec2 =
|
|
617
|
-
export const mx_fractal_noise_vec3 =
|
|
618
|
-
export const mx_fractal_noise_vec4 =
|
|
615
|
+
export const mx_fractal_noise_float = glslFn( 'float mx_fractal_noise_float( vec3 p, int octaves, float lacunarity, float diminish )', includes );
|
|
616
|
+
export const mx_fractal_noise_vec2 = glslFn( 'float mx_fractal_noise_vec2( vec3 p, int octaves, float lacunarity, float diminish )', includes );
|
|
617
|
+
export const mx_fractal_noise_vec3 = glslFn( 'float mx_fractal_noise_vec3( vec3 p, int octaves, float lacunarity, float diminish )', includes );
|
|
618
|
+
export const mx_fractal_noise_vec4 = glslFn( 'float mx_fractal_noise_vec4( vec3 p, int octaves, float lacunarity, float diminish )', includes );
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { glsl } from '../../code/CodeNode.js';
|
|
2
|
+
import { glslFn } from '../../code/FunctionNode.js';
|
|
3
3
|
|
|
4
4
|
// Original shader code from:
|
|
5
5
|
// https://github.com/AcademySoftwareFoundation/MaterialX/blob/main/libraries/stdlib/genglsl/lib/mx_transform_color.glsl
|
|
6
6
|
|
|
7
|
-
export const mx_transform_color =
|
|
7
|
+
export const mx_transform_color = glsl( `#define M_AP1_TO_REC709 mat3(1.705079555511475, -0.1297005265951157, -0.02416634373366833, -0.6242334842681885, 1.138468623161316, -0.1246141716837883, -0.0808461606502533, -0.008768022060394287, 1.148780584335327)
|
|
8
8
|
|
|
9
9
|
vec3 mx_srgb_texture_to_lin_rec709(vec3 color)
|
|
10
10
|
{
|
|
@@ -16,4 +16,4 @@ vec3 mx_srgb_texture_to_lin_rec709(vec3 color)
|
|
|
16
16
|
|
|
17
17
|
const includes = [ mx_transform_color ];
|
|
18
18
|
|
|
19
|
-
export const mx_srgb_texture_to_lin_rec709 =
|
|
19
|
+
export const mx_srgb_texture_to_lin_rec709 = glslFn( 'vec3 mx_srgb_texture_to_lin_rec709( vec3 color )', includes );
|
|
@@ -218,6 +218,8 @@ MathNode.DFDX = 'dFdx';
|
|
|
218
218
|
MathNode.DFDY = 'dFdy';
|
|
219
219
|
MathNode.ROUND = 'round';
|
|
220
220
|
MathNode.RECIPROCAL = 'reciprocal';
|
|
221
|
+
MathNode.TRUNC = 'trunc';
|
|
222
|
+
MathNode.FWIDTH = 'fwidth';
|
|
221
223
|
|
|
222
224
|
// 2 inputs
|
|
223
225
|
|
|
@@ -274,6 +276,8 @@ export const dFdx = nodeProxy( MathNode, MathNode.DFDX );
|
|
|
274
276
|
export const dFdy = nodeProxy( MathNode, MathNode.DFDY );
|
|
275
277
|
export const round = nodeProxy( MathNode, MathNode.ROUND );
|
|
276
278
|
export const reciprocal = nodeProxy( MathNode, MathNode.RECIPROCAL );
|
|
279
|
+
export const trunc = nodeProxy( MathNode, MathNode.TRUNC );
|
|
280
|
+
export const fwidth = nodeProxy( MathNode, MathNode.FWIDTH );
|
|
277
281
|
|
|
278
282
|
export const atan2 = nodeProxy( MathNode, MathNode.ATAN2 );
|
|
279
283
|
export const min = nodeProxy( MathNode, MathNode.MIN );
|
|
@@ -328,6 +332,8 @@ addNodeElement( 'dFdx', dFdx );
|
|
|
328
332
|
addNodeElement( 'dFdy', dFdy );
|
|
329
333
|
addNodeElement( 'round', round );
|
|
330
334
|
addNodeElement( 'reciprocal', reciprocal );
|
|
335
|
+
addNodeElement( 'trunc', trunc );
|
|
336
|
+
addNodeElement( 'fwidth', fwidth );
|
|
331
337
|
addNodeElement( 'atan2', atan2 );
|
|
332
338
|
addNodeElement( 'min', min );
|
|
333
339
|
addNodeElement( 'max', max );
|
|
@@ -120,7 +120,7 @@ class OperatorNode extends TempNode {
|
|
|
120
120
|
|
|
121
121
|
typeB = typeA;
|
|
122
122
|
|
|
123
|
-
} else if ( op === '<' || op === '>' || op === '<=' || op === '>=' ) {
|
|
123
|
+
} else if ( op === '<' || op === '>' || op === '<=' || op === '>=' || op === '==' ) {
|
|
124
124
|
|
|
125
125
|
if ( builder.isVector( typeA ) ) {
|
|
126
126
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import TempNode from '../core/TempNode.js';
|
|
2
2
|
import { uv } from '../accessors/UVNode.js';
|
|
3
3
|
import { addNodeClass } from '../core/Node.js';
|
|
4
|
-
import { addNodeElement,
|
|
4
|
+
import { addNodeElement, tslFn, nodeProxy } from '../shadernode/ShaderNode.js';
|
|
5
5
|
|
|
6
|
-
const checkerShaderNode =
|
|
6
|
+
const checkerShaderNode = tslFn( ( inputs ) => {
|
|
7
7
|
|
|
8
8
|
const uv = inputs.uv.mul( 2.0 );
|
|
9
9
|
|
|
@@ -27,7 +27,7 @@ class CheckerNode extends TempNode {
|
|
|
27
27
|
|
|
28
28
|
generate( builder ) {
|
|
29
29
|
|
|
30
|
-
return checkerShaderNode
|
|
30
|
+
return checkerShaderNode( { uv: this.uvNode } ).build( builder );
|
|
31
31
|
|
|
32
32
|
}
|
|
33
33
|
|
|
@@ -79,7 +79,7 @@ const shaderNodeHandler = {
|
|
|
79
79
|
|
|
80
80
|
const nodeObjectsCacheMap = new WeakMap();
|
|
81
81
|
|
|
82
|
-
const ShaderNodeObject = function ( obj ) {
|
|
82
|
+
const ShaderNodeObject = function ( obj, altType = null ) {
|
|
83
83
|
|
|
84
84
|
const type = getValueType( obj );
|
|
85
85
|
|
|
@@ -97,13 +97,13 @@ const ShaderNodeObject = function ( obj ) {
|
|
|
97
97
|
|
|
98
98
|
return nodeObject;
|
|
99
99
|
|
|
100
|
-
} else if ( ( type === 'float' ) || ( type
|
|
100
|
+
} else if ( ( altType === null && ( type === 'float' || type === 'boolean' ) ) || ( type && type !== 'shader' && type !== 'string' ) ) {
|
|
101
101
|
|
|
102
|
-
return nodeObject(
|
|
102
|
+
return nodeObject( getConstNode( obj, altType ) );
|
|
103
103
|
|
|
104
|
-
} else if ( type
|
|
104
|
+
} else if ( type === 'shader' ) {
|
|
105
105
|
|
|
106
|
-
return
|
|
106
|
+
return tslFn( obj );
|
|
107
107
|
|
|
108
108
|
}
|
|
109
109
|
|
|
@@ -111,11 +111,11 @@ const ShaderNodeObject = function ( obj ) {
|
|
|
111
111
|
|
|
112
112
|
};
|
|
113
113
|
|
|
114
|
-
const ShaderNodeObjects = function ( objects ) {
|
|
114
|
+
const ShaderNodeObjects = function ( objects, altType = null ) {
|
|
115
115
|
|
|
116
116
|
for ( const name in objects ) {
|
|
117
117
|
|
|
118
|
-
objects[ name ] = nodeObject( objects[ name ] );
|
|
118
|
+
objects[ name ] = nodeObject( objects[ name ], altType );
|
|
119
119
|
|
|
120
120
|
}
|
|
121
121
|
|
|
@@ -123,13 +123,13 @@ const ShaderNodeObjects = function ( objects ) {
|
|
|
123
123
|
|
|
124
124
|
};
|
|
125
125
|
|
|
126
|
-
const ShaderNodeArray = function ( array ) {
|
|
126
|
+
const ShaderNodeArray = function ( array, altType = null ) {
|
|
127
127
|
|
|
128
128
|
const len = array.length;
|
|
129
129
|
|
|
130
130
|
for ( let i = 0; i < len; i ++ ) {
|
|
131
131
|
|
|
132
|
-
array[ i ] = nodeObject( array[ i ] );
|
|
132
|
+
array[ i ] = nodeObject( array[ i ], altType );
|
|
133
133
|
|
|
134
134
|
}
|
|
135
135
|
|
|
@@ -237,7 +237,7 @@ const cacheMaps = { bool: boolsCacheMap, uint: uintsCacheMap, ints: intsCacheMap
|
|
|
237
237
|
|
|
238
238
|
const constNodesCacheMap = new Map( [ ...boolsCacheMap, ...floatsCacheMap ] );
|
|
239
239
|
|
|
240
|
-
const
|
|
240
|
+
const getConstNode = ( value, type ) => {
|
|
241
241
|
|
|
242
242
|
if ( constNodesCacheMap.has( value ) ) {
|
|
243
243
|
|
|
@@ -249,46 +249,53 @@ const getAutoTypedConstNode = ( value ) => {
|
|
|
249
249
|
|
|
250
250
|
} else {
|
|
251
251
|
|
|
252
|
-
return new ConstNode( value );
|
|
252
|
+
return new ConstNode( value, type );
|
|
253
253
|
|
|
254
254
|
}
|
|
255
255
|
|
|
256
256
|
};
|
|
257
257
|
|
|
258
|
-
const
|
|
258
|
+
const safeGetNodeType = ( node ) => {
|
|
259
259
|
|
|
260
|
-
|
|
260
|
+
try {
|
|
261
261
|
|
|
262
|
-
|
|
262
|
+
return node.getNodeType();
|
|
263
263
|
|
|
264
|
-
|
|
264
|
+
} catch {
|
|
265
265
|
|
|
266
|
-
|
|
266
|
+
return undefined;
|
|
267
267
|
|
|
268
|
-
|
|
268
|
+
}
|
|
269
269
|
|
|
270
|
-
|
|
270
|
+
};
|
|
271
271
|
|
|
272
|
-
|
|
272
|
+
const ConvertType = function ( type, cacheMap = null ) {
|
|
273
|
+
|
|
274
|
+
return ( ...params ) => {
|
|
273
275
|
|
|
274
|
-
|
|
276
|
+
if ( params.length === 0 || ( ! [ 'bool', 'float', 'int', 'uint' ].includes( type ) && params.every( param => typeof param !== 'object' ) ) ) {
|
|
275
277
|
|
|
276
|
-
|
|
278
|
+
params = [ getValueFromType( type, ...params ) ];
|
|
277
279
|
|
|
278
|
-
|
|
280
|
+
}
|
|
279
281
|
|
|
280
|
-
|
|
282
|
+
if ( params.length === 1 && cacheMap !== null && cacheMap.has( params[ 0 ] ) ) {
|
|
281
283
|
|
|
282
|
-
|
|
284
|
+
return nodeObject( cacheMap.get( params[ 0 ] ) );
|
|
283
285
|
|
|
284
|
-
|
|
286
|
+
}
|
|
285
287
|
|
|
286
|
-
|
|
288
|
+
if ( params.length === 1 ) {
|
|
287
289
|
|
|
288
|
-
|
|
290
|
+
const node = getConstNode( params[ 0 ], type );
|
|
291
|
+
if ( safeGetNodeType( node ) === type ) return nodeObject( node );
|
|
292
|
+
return nodeObject( new ConvertNode( node, type ) );
|
|
289
293
|
|
|
290
294
|
}
|
|
291
295
|
|
|
296
|
+
const nodes = params.map( param => getConstNode( param ) );
|
|
297
|
+
return nodeObject( new JoinNode( nodes, type ) );
|
|
298
|
+
|
|
292
299
|
};
|
|
293
300
|
|
|
294
301
|
};
|
|
@@ -307,13 +314,33 @@ export function ShaderNode( jsFunc ) {
|
|
|
307
314
|
|
|
308
315
|
}
|
|
309
316
|
|
|
310
|
-
export const nodeObject = ( val ) => /* new */ ShaderNodeObject( val );
|
|
311
|
-
export const nodeObjects = ( val ) => new ShaderNodeObjects( val );
|
|
312
|
-
export const nodeArray = ( val ) => new ShaderNodeArray( val );
|
|
313
|
-
export const nodeProxy = ( ...
|
|
314
|
-
export const nodeImmutable = ( ...
|
|
317
|
+
export const nodeObject = ( val, altType = null ) => /* new */ ShaderNodeObject( val, altType );
|
|
318
|
+
export const nodeObjects = ( val, altType = null ) => new ShaderNodeObjects( val, altType );
|
|
319
|
+
export const nodeArray = ( val, altType = null ) => new ShaderNodeArray( val, altType );
|
|
320
|
+
export const nodeProxy = ( ...params ) => new ShaderNodeProxy( ...params );
|
|
321
|
+
export const nodeImmutable = ( ...params ) => new ShaderNodeImmutable( ...params );
|
|
322
|
+
|
|
323
|
+
export const shader = ( jsFunc ) => { // @deprecated, r154
|
|
315
324
|
|
|
316
|
-
|
|
325
|
+
console.warn( 'TSL: shader() is deprecated. Use fn() instead.' );
|
|
326
|
+
|
|
327
|
+
return new ShaderNode( jsFunc );
|
|
328
|
+
|
|
329
|
+
};
|
|
330
|
+
|
|
331
|
+
export const tslFn = ( jsFunc ) => {
|
|
332
|
+
|
|
333
|
+
let shaderNode = null;
|
|
334
|
+
|
|
335
|
+
return ( ...params ) => {
|
|
336
|
+
|
|
337
|
+
if ( shaderNode === null ) shaderNode = new ShaderNode( jsFunc );
|
|
338
|
+
|
|
339
|
+
return shaderNode.call( ...params );
|
|
340
|
+
|
|
341
|
+
};
|
|
342
|
+
|
|
343
|
+
};
|
|
317
344
|
|
|
318
345
|
addNodeClass( ShaderNode );
|
|
319
346
|
|