super-three 0.167.0 → 0.169.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 +532 -173
- package/build/three.module.js +532 -174
- package/build/three.module.min.js +1 -1
- package/build/three.webgpu.js +18173 -14266
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +79941 -0
- package/build/three.webgpu.nodes.min.js +6 -0
- package/examples/jsm/Addons.js +0 -4
- package/examples/jsm/animation/AnimationClipCreator.js +1 -1
- package/examples/jsm/capabilities/WebGL.js +27 -21
- package/examples/jsm/controls/ArcballControls.js +174 -158
- package/examples/jsm/controls/DragControls.js +260 -132
- package/examples/jsm/controls/FirstPersonControls.js +175 -163
- package/examples/jsm/controls/FlyControls.js +194 -188
- package/examples/jsm/controls/OrbitControls.js +777 -786
- package/examples/jsm/controls/PointerLockControls.js +24 -15
- package/examples/jsm/controls/TrackballControls.js +469 -448
- package/examples/jsm/controls/TransformControls.js +97 -62
- package/examples/jsm/effects/AnaglyphEffect.js +6 -13
- package/examples/jsm/effects/ParallaxBarrierEffect.js +17 -11
- package/examples/jsm/effects/StereoEffect.js +6 -1
- package/examples/jsm/environments/RoomEnvironment.js +1 -1
- package/examples/jsm/exporters/DRACOExporter.js +4 -2
- package/examples/jsm/exporters/EXRExporter.js +19 -11
- package/examples/jsm/exporters/GLTFExporter.js +6 -1
- package/examples/jsm/exporters/KTX2Exporter.js +21 -13
- package/examples/jsm/exporters/OBJExporter.js +5 -1
- package/examples/jsm/exporters/PLYExporter.js +9 -7
- package/examples/jsm/exporters/USDZExporter.js +29 -8
- package/examples/jsm/geometries/DecalGeometry.js +4 -1
- package/examples/jsm/geometries/InstancedPointsGeometry.js +1 -1
- package/examples/jsm/helpers/LightProbeHelper.js +43 -44
- package/examples/jsm/helpers/LightProbeHelperGPU.js +65 -0
- package/examples/jsm/libs/basis/basis_transcoder.js +8 -10
- package/examples/jsm/libs/basis/basis_transcoder.wasm +0 -0
- package/examples/jsm/libs/ktx-parse.module.js +1 -1
- package/examples/jsm/lights/LightProbeGenerator.js +24 -10
- package/examples/jsm/loaders/ColladaLoader.js +9 -6
- package/examples/jsm/loaders/DRACOLoader.js +3 -1
- package/examples/jsm/loaders/FBXLoader.js +30 -20
- package/examples/jsm/loaders/GLTFLoader.js +5 -10
- package/examples/jsm/loaders/KTX2Loader.js +27 -12
- package/examples/jsm/loaders/MTLLoader.js +4 -3
- package/examples/jsm/loaders/MaterialXLoader.js +40 -14
- package/examples/jsm/loaders/OBJLoader.js +5 -3
- package/examples/jsm/loaders/PCDLoader.js +14 -13
- package/examples/jsm/loaders/PDBLoader.js +3 -2
- package/examples/jsm/loaders/PLYLoader.js +8 -5
- package/examples/jsm/loaders/STLLoader.js +3 -2
- package/examples/jsm/loaders/VRMLLoader.js +10 -10
- package/examples/jsm/loaders/VTKLoader.js +4 -3
- package/examples/jsm/loaders/XYZLoader.js +3 -2
- package/examples/jsm/misc/Timer.js +1 -1
- package/examples/jsm/modifiers/CurveModifierGPU.js +233 -0
- package/examples/jsm/objects/LensflareMesh.js +322 -0
- package/examples/jsm/objects/SkyMesh.js +187 -0
- package/examples/jsm/objects/Water2Mesh.js +158 -0
- package/examples/jsm/objects/WaterMesh.js +101 -0
- package/examples/jsm/physics/JoltPhysics.js +1 -1
- package/examples/jsm/physics/RapierPhysics.js +21 -1
- package/examples/jsm/postprocessing/OutlinePass.js +31 -46
- package/examples/jsm/postprocessing/SSAARenderPass.js +3 -1
- package/examples/jsm/shaders/BleachBypassShader.js +1 -2
- package/examples/jsm/shaders/OutputShader.js +1 -1
- package/examples/jsm/transpiler/GLSLDecoder.js +1 -1
- package/examples/jsm/transpiler/ShaderToyDecoder.js +2 -2
- package/examples/jsm/transpiler/TSLEncoder.js +8 -8
- package/examples/jsm/utils/GeometryCompressionUtils.js +37 -122
- package/examples/jsm/utils/ShadowMapViewer.js +3 -8
- package/examples/jsm/utils/ShadowMapViewerGPU.js +201 -0
- package/examples/jsm/utils/SkeletonUtils.js +84 -66
- package/examples/jsm/utils/TextureUtils.js +2 -1
- package/examples/jsm/utils/TextureUtilsGPU.js +63 -0
- package/examples/jsm/webxr/XRControllerModelFactory.js +1 -1
- package/package.json +3 -2
- package/src/Three.WebGPU.Nodes.js +200 -0
- package/src/Three.WebGPU.js +7 -0
- package/src/Three.js +1 -0
- package/src/audio/Audio.js +2 -2
- package/src/constants.js +1 -1
- package/src/core/BufferAttribute.js +0 -9
- package/src/core/Clock.js +1 -1
- package/src/core/InterleavedBuffer.js +0 -9
- package/src/extras/Controls.js +32 -0
- package/src/geometries/CylinderGeometry.js +11 -4
- package/src/loaders/MaterialLoader.js +7 -1
- package/src/loaders/ObjectLoader.js +3 -3
- package/src/{nodes/loaders → loaders/nodes}/NodeLoader.js +25 -5
- package/src/{nodes/loaders → loaders/nodes}/NodeMaterialLoader.js +21 -18
- package/src/{nodes/loaders → loaders/nodes}/NodeObjectLoader.js +19 -0
- package/src/materials/Material.js +4 -7
- package/src/materials/nodes/InstancedPointsNodeMaterial.js +156 -0
- package/src/{nodes/materials → materials/nodes}/Line2NodeMaterial.js +56 -59
- package/src/{nodes/materials → materials/nodes}/LineBasicNodeMaterial.js +8 -5
- package/src/{nodes/materials → materials/nodes}/LineDashedNodeMaterial.js +12 -10
- package/src/{nodes/materials → materials/nodes}/MeshBasicNodeMaterial.js +16 -12
- package/src/{nodes/materials → materials/nodes}/MeshLambertNodeMaterial.js +10 -6
- package/src/{nodes/materials → materials/nodes}/MeshMatcapNodeMaterial.js +13 -9
- package/src/{nodes/materials → materials/nodes}/MeshNormalNodeMaterial.js +13 -9
- package/src/{nodes/materials → materials/nodes}/MeshPhongNodeMaterial.js +14 -9
- package/src/{nodes/materials → materials/nodes}/MeshPhysicalNodeMaterial.js +22 -18
- package/src/{nodes/materials → materials/nodes}/MeshSSSNodeMaterial.js +10 -7
- package/src/{nodes/materials → materials/nodes}/MeshStandardNodeMaterial.js +22 -12
- package/src/{nodes/materials → materials/nodes}/MeshToonNodeMaterial.js +9 -5
- package/src/{nodes/materials → materials/nodes}/NodeMaterial.js +71 -115
- package/src/{nodes/materials/Materials.js → materials/nodes/NodeMaterials.js} +3 -1
- package/src/{nodes/materials → materials/nodes}/PointsNodeMaterial.js +8 -5
- package/src/{nodes/materials → materials/nodes}/ShadowNodeMaterial.js +9 -5
- package/src/{nodes/materials → materials/nodes}/SpriteNodeMaterial.js +47 -14
- package/src/{nodes/materials → materials/nodes}/VolumeNodeMaterial.js +24 -22
- package/src/materials/nodes/manager/NodeMaterialObserver.js +302 -0
- package/src/math/Triangle.js +24 -0
- package/src/nodes/Nodes.js +103 -159
- package/src/nodes/TSL.js +179 -0
- package/src/nodes/accessors/AccessorsUtils.js +8 -8
- package/src/nodes/accessors/BatchNode.js +53 -21
- package/src/nodes/accessors/{BitangentNode.js → Bitangent.js} +9 -9
- package/src/nodes/accessors/BufferAttributeNode.js +8 -5
- package/src/nodes/accessors/BufferNode.js +7 -4
- package/src/nodes/accessors/Camera.js +13 -0
- package/src/nodes/accessors/ClippingNode.js +19 -13
- package/src/nodes/accessors/CubeTextureNode.js +9 -8
- package/src/nodes/accessors/InstanceNode.js +19 -15
- package/src/nodes/accessors/InstancedPointsMaterialNode.js +8 -5
- package/src/nodes/accessors/Lights.js +51 -0
- package/src/nodes/accessors/MaterialNode.js +56 -55
- package/src/nodes/accessors/MaterialProperties.js +3 -0
- package/src/nodes/accessors/MaterialReferenceNode.js +9 -4
- package/src/nodes/accessors/ModelNode.js +47 -12
- package/src/nodes/accessors/ModelViewProjectionNode.js +12 -9
- package/src/nodes/accessors/MorphNode.js +17 -13
- package/src/nodes/accessors/Normal.js +88 -0
- package/src/nodes/accessors/Object3DNode.js +17 -33
- package/src/nodes/accessors/PointUVNode.js +9 -5
- package/src/nodes/accessors/Position.js +10 -0
- package/src/nodes/accessors/ReferenceBaseNode.js +171 -0
- package/src/nodes/accessors/ReferenceNode.js +50 -7
- package/src/nodes/accessors/ReflectVector.js +10 -0
- package/src/nodes/accessors/RendererReferenceNode.js +12 -6
- package/src/nodes/accessors/SceneNode.js +9 -6
- package/src/nodes/accessors/SkinningNode.js +88 -21
- package/src/nodes/accessors/StorageBufferNode.js +22 -5
- package/src/nodes/accessors/StorageTextureNode.js +9 -6
- package/src/nodes/accessors/Tangent.js +22 -0
- package/src/nodes/accessors/Texture3DNode.js +16 -13
- package/src/nodes/accessors/{TextureBicubicNode.js → TextureBicubic.js} +3 -32
- package/src/nodes/accessors/TextureNode.js +29 -23
- package/src/nodes/accessors/TextureSizeNode.js +10 -9
- package/src/nodes/accessors/{UniformsNode.js → UniformArrayNode.js} +26 -14
- package/src/nodes/accessors/UserDataNode.js +10 -7
- package/src/nodes/accessors/VelocityNode.js +134 -0
- package/src/nodes/accessors/VertexColorNode.js +7 -4
- package/src/nodes/code/CodeNode.js +9 -5
- package/src/nodes/code/ExpressionNode.js +10 -6
- package/src/nodes/code/FunctionCallNode.js +8 -5
- package/src/nodes/code/FunctionNode.js +8 -23
- package/src/nodes/code/ScriptableNode.js +13 -10
- package/src/nodes/code/ScriptableValueNode.js +9 -7
- package/src/nodes/core/AssignNode.js +12 -9
- package/src/nodes/core/AttributeNode.js +12 -21
- package/src/nodes/core/BypassNode.js +11 -7
- package/src/nodes/core/CacheNode.js +10 -6
- package/src/nodes/core/ConstNode.js +6 -3
- package/src/nodes/core/ContextNode.js +21 -11
- package/src/nodes/core/IndexNode.js +35 -8
- package/src/nodes/core/InputNode.js +7 -3
- package/src/nodes/core/MRTNode.js +16 -7
- package/src/nodes/core/Node.js +19 -40
- package/src/nodes/core/NodeBuilder.js +117 -38
- package/src/nodes/core/NodeUtils.js +49 -6
- package/src/nodes/core/OutputStructNode.js +10 -6
- package/src/nodes/core/ParameterNode.js +7 -4
- package/src/nodes/core/PropertyNode.js +36 -32
- package/src/nodes/core/StackNode.js +31 -11
- package/src/nodes/core/StructTypeNode.js +7 -3
- package/src/nodes/core/TempNode.js +8 -4
- package/src/nodes/core/UniformGroupNode.js +14 -11
- package/src/nodes/core/UniformNode.js +7 -4
- package/src/nodes/core/VarNode.js +12 -8
- package/src/nodes/core/VaryingNode.js +10 -6
- package/src/nodes/display/AfterImageNode.js +15 -9
- package/src/nodes/display/AnaglyphPassNode.js +67 -0
- package/src/nodes/display/AnamorphicNode.js +17 -11
- package/src/nodes/display/BleachBypass.js +26 -0
- package/src/nodes/display/BlendMode.js +54 -0
- package/src/nodes/display/BloomNode.js +27 -19
- package/src/nodes/display/BumpMapNode.js +13 -12
- package/src/nodes/display/ColorAdjustment.js +46 -0
- package/src/nodes/display/ColorSpaceFunctions.js +38 -0
- package/src/nodes/display/ColorSpaceNode.js +67 -61
- package/src/nodes/display/DenoiseNode.js +23 -17
- package/src/nodes/display/DepthOfFieldNode.js +12 -7
- package/src/nodes/display/DotScreenNode.js +13 -22
- package/src/nodes/display/FXAANode.js +21 -16
- package/src/nodes/display/FilmNode.js +11 -7
- package/src/nodes/display/FrontFacingNode.js +10 -6
- package/src/nodes/display/GTAONode.js +22 -15
- package/src/nodes/display/GaussianBlurNode.js +14 -8
- package/src/nodes/display/Lut3DNode.js +10 -6
- package/src/nodes/display/MotionBlur.js +25 -0
- package/src/nodes/display/NormalMapNode.js +13 -13
- package/src/nodes/display/ParallaxBarrierPassNode.js +58 -0
- package/src/nodes/display/PassNode.js +95 -8
- package/src/nodes/display/PixelationPassNode.js +20 -8
- package/src/nodes/display/PosterizeNode.js +8 -7
- package/src/nodes/display/RGBShiftNode.js +11 -7
- package/src/nodes/display/RenderOutputNode.js +15 -11
- package/src/nodes/display/SSAAPassNode.js +287 -0
- package/src/nodes/display/ScreenNode.js +181 -0
- package/src/nodes/display/Sepia.js +17 -0
- package/src/nodes/display/SobelOperatorNode.js +13 -8
- package/src/nodes/display/StereoCompositePassNode.js +110 -0
- package/src/nodes/display/StereoPassNode.js +83 -0
- package/src/nodes/display/ToneMappingFunctions.js +190 -0
- package/src/nodes/display/ToneMappingNode.js +15 -175
- package/src/nodes/display/ToonOutlinePassNode.js +111 -0
- package/src/nodes/display/TransitionNode.js +12 -8
- package/src/nodes/display/ViewportDepthNode.js +34 -29
- package/src/nodes/display/ViewportDepthTextureNode.js +10 -9
- package/src/nodes/display/ViewportSharedTextureNode.js +10 -9
- package/src/nodes/display/ViewportTextureNode.js +11 -11
- package/src/nodes/fog/FogExp2Node.js +8 -7
- package/src/nodes/fog/FogNode.js +10 -8
- package/src/nodes/fog/FogRangeNode.js +8 -7
- package/src/nodes/functions/BSDF/BRDF_GGX.js +4 -4
- package/src/nodes/functions/BSDF/BRDF_Lambert.js +2 -2
- package/src/nodes/functions/BSDF/BRDF_Sheen.js +6 -6
- package/src/nodes/functions/BSDF/DFGApprox.js +2 -2
- package/src/nodes/functions/BSDF/D_GGX.js +2 -2
- package/src/nodes/functions/BSDF/D_GGX_Anisotropic.js +3 -3
- package/src/nodes/functions/BSDF/EnvironmentBRDF.js +2 -2
- package/src/nodes/functions/BSDF/F_Schlick.js +2 -2
- package/src/nodes/functions/BSDF/LTC.js +6 -6
- package/src/nodes/functions/BSDF/Schlick_to_F0.js +2 -2
- package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated.js +2 -2
- package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +2 -2
- package/src/nodes/functions/BasicLightingModel.js +1 -1
- package/src/nodes/functions/PhongLightingModel.js +5 -5
- package/src/nodes/functions/PhysicalLightingModel.js +34 -33
- package/src/nodes/functions/ShadowMaskModel.js +1 -1
- package/src/nodes/functions/ToonLightingModel.js +3 -3
- package/src/nodes/functions/material/getGeometryRoughness.js +4 -4
- package/src/nodes/functions/material/getRoughness.js +2 -2
- package/src/nodes/functions/material/getShIrradianceAt.js +28 -0
- package/src/nodes/geometry/RangeNode.js +9 -5
- package/src/nodes/gpgpu/AtomicFunctionNode.js +99 -0
- package/src/nodes/gpgpu/BarrierNode.js +40 -0
- package/src/nodes/gpgpu/ComputeBuiltinNode.js +98 -0
- package/src/nodes/gpgpu/ComputeNode.js +10 -6
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +100 -0
- package/src/nodes/lighting/AONode.js +6 -3
- package/src/nodes/lighting/AmbientLightNode.js +6 -8
- package/src/nodes/lighting/AnalyticLightNode.js +225 -36
- package/src/nodes/lighting/BasicEnvironmentNode.js +8 -4
- package/src/nodes/lighting/BasicLightMapNode.js +7 -4
- package/src/nodes/lighting/DirectionalLightNode.js +7 -9
- package/src/nodes/lighting/EnvironmentNode.js +23 -19
- package/src/nodes/lighting/HemisphereLightNode.js +11 -11
- package/src/nodes/lighting/IESSpotLightNode.js +7 -9
- package/src/nodes/lighting/IrradianceNode.js +6 -3
- package/src/nodes/lighting/LightProbeNode.js +53 -0
- package/src/nodes/lighting/LightUtils.js +3 -3
- package/src/nodes/lighting/LightingContextNode.js +19 -18
- package/src/nodes/lighting/LightingNode.js +7 -3
- package/src/nodes/lighting/LightsNode.js +112 -75
- package/src/nodes/lighting/PointLightNode.js +12 -13
- package/src/nodes/lighting/RectAreaLightNode.js +11 -11
- package/src/nodes/lighting/SpotLightNode.js +14 -16
- package/src/nodes/materialx/MaterialXNodes.js +2 -2
- package/src/nodes/materialx/lib/mx_hsv.js +36 -31
- package/src/nodes/materialx/lib/mx_noise.js +96 -96
- package/src/nodes/materialx/lib/mx_transform_color.js +2 -2
- package/src/nodes/math/{CondNode.js → ConditionalNode.js} +38 -10
- package/src/nodes/math/Hash.js +13 -0
- package/src/nodes/math/MathNode.js +127 -124
- package/src/nodes/math/MathUtils.js +0 -7
- package/src/nodes/math/OperatorNode.js +97 -52
- package/src/nodes/math/TriNoise3D.js +19 -29
- package/src/nodes/pmrem/PMREMNode.js +61 -15
- package/src/nodes/pmrem/PMREMUtils.js +46 -46
- package/src/nodes/procedural/Checker.js +14 -0
- package/src/nodes/tsl/TSLBase.js +30 -0
- package/src/nodes/{shadernode/ShaderNode.js → tsl/TSLCore.js} +105 -97
- package/src/nodes/utils/ArrayElementNode.js +8 -4
- package/src/nodes/utils/ConvertNode.js +7 -3
- package/src/nodes/utils/CubeMapNode.js +160 -0
- package/src/nodes/utils/Discard.js +8 -0
- package/src/nodes/utils/EquirectUVNode.js +9 -6
- package/src/nodes/utils/FlipNode.js +68 -0
- package/src/nodes/utils/FunctionOverloadingNode.js +9 -5
- package/src/nodes/utils/JoinNode.js +6 -3
- package/src/nodes/utils/LoopNode.js +16 -6
- package/src/nodes/utils/MatcapUVNode.js +10 -7
- package/src/nodes/utils/MaxMipLevelNode.js +8 -5
- package/src/nodes/utils/OscNode.js +12 -8
- package/src/nodes/utils/Packing.js +4 -0
- package/src/nodes/utils/RTTNode.js +11 -8
- package/src/nodes/utils/ReflectorNode.js +12 -4
- package/src/nodes/utils/RemapNode.js +12 -8
- package/src/nodes/utils/RotateNode.js +8 -13
- package/src/nodes/utils/SetNode.js +7 -4
- package/src/nodes/utils/SplitNode.js +7 -3
- package/src/nodes/utils/SpriteSheetUVNode.js +10 -6
- package/src/nodes/utils/SpriteUtils.js +47 -0
- package/src/nodes/utils/StorageArrayElementNode.js +11 -12
- package/src/nodes/utils/TimerNode.js +8 -5
- package/src/nodes/utils/TriplanarTexturesNode.js +11 -9
- package/src/nodes/utils/UVUtils.js +19 -0
- package/src/nodes/utils/ViewportUtils.js +14 -0
- package/src/objects/BatchedMesh.js +78 -13
- package/src/objects/LOD.js +21 -0
- package/src/objects/Line.js +1 -0
- package/src/objects/Mesh.js +7 -23
- package/src/objects/Points.js +2 -0
- package/src/renderers/WebGLRenderer.js +88 -41
- package/src/renderers/common/Backend.js +2 -2
- package/src/renderers/common/Background.js +3 -1
- package/src/renderers/common/BindGroup.js +3 -1
- package/src/renderers/common/Bindings.js +13 -15
- package/src/renderers/common/BundleGroup.js +26 -0
- package/src/renderers/common/ClippingContext.js +15 -5
- package/src/renderers/common/CubeRenderTarget.js +9 -3
- package/src/renderers/common/PostProcessing.js +4 -1
- package/src/renderers/common/QuadMesh.js +2 -0
- package/src/renderers/common/RenderContext.js +23 -0
- package/src/renderers/common/RenderList.js +1 -1
- package/src/renderers/common/RenderObject.js +117 -6
- package/src/renderers/common/RenderObjects.js +8 -1
- package/src/renderers/common/Renderer.js +128 -94
- package/src/renderers/common/SampledTexture.js +12 -3
- package/src/renderers/common/Textures.js +8 -12
- package/src/renderers/common/extras/PMREMGenerator.js +19 -22
- package/src/renderers/common/nodes/NodeBuilderState.js +4 -4
- package/src/renderers/common/nodes/NodeLibrary.js +118 -0
- package/src/renderers/common/nodes/NodeSampledTexture.js +2 -2
- package/src/renderers/common/nodes/Nodes.js +65 -19
- package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +2 -2
- package/src/renderers/shaders/ShaderLib/sprite.glsl.js +2 -4
- package/src/renderers/webgl/WebGLAttributes.js +45 -14
- package/src/renderers/webgl/WebGLCapabilities.js +9 -0
- package/src/renderers/webgl/WebGLProgram.js +3 -1
- package/src/renderers/webgl/WebGLPrograms.js +21 -17
- package/src/renderers/webgl/WebGLProperties.js +7 -0
- package/src/renderers/webgl/WebGLState.js +21 -0
- package/src/renderers/webgl/WebGLTextures.js +83 -4
- package/src/renderers/webgl-fallback/WebGLBackend.js +135 -110
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +60 -12
- package/src/renderers/webgl-fallback/utils/WebGLAttributeUtils.js +6 -0
- package/src/renderers/webgl-fallback/utils/WebGLState.js +20 -2
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +89 -37
- package/src/renderers/webgpu/WebGPUBackend.js +112 -86
- package/src/renderers/webgpu/WebGPURenderer.Nodes.js +42 -0
- package/src/renderers/webgpu/WebGPURenderer.js +9 -6
- package/src/renderers/webgpu/nodes/BasicNodeLibrary.js +59 -0
- package/src/renderers/webgpu/nodes/StandardNodeLibrary.js +105 -0
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +189 -73
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +6 -16
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +45 -21
- package/src/renderers/webgpu/utils/WebGPUConstants.js +2 -1
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +7 -16
- package/src/renderers/webgpu/utils/WebGPUTexturePassUtils.js +62 -5
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +43 -26
- package/src/renderers/webgpu/utils/WebGPUUtils.js +19 -2
- package/src/renderers/webxr/WebXRManager.js +32 -25
- package/src/utils.js +33 -1
- package/examples/jsm/geometries/SDFGeometryGenerator.js +0 -144
- package/examples/jsm/loaders/LogLuvLoader.js +0 -606
- package/examples/jsm/loaders/TiltLoader.js +0 -520
- package/examples/jsm/utils/GPUStatsPanel.js +0 -95
- package/examples/jsm/utils/PackedPhongMaterial.js +0 -178
- package/src/nodes/accessors/CameraNode.js +0 -19
- package/src/nodes/accessors/NormalNode.js +0 -14
- package/src/nodes/accessors/PositionNode.js +0 -10
- package/src/nodes/accessors/ReflectVectorNode.js +0 -10
- package/src/nodes/accessors/TangentNode.js +0 -23
- package/src/nodes/core/NodeKeywords.js +0 -80
- package/src/nodes/display/BlendModeNode.js +0 -128
- package/src/nodes/display/ColorAdjustmentNode.js +0 -104
- package/src/nodes/display/ViewportNode.js +0 -137
- package/src/nodes/lighting/LightNode.js +0 -57
- package/src/nodes/materials/InstancedPointsNodeMaterial.js +0 -162
- package/src/nodes/math/HashNode.js +0 -34
- package/src/nodes/procedural/CheckerNode.js +0 -42
- package/src/nodes/utils/DiscardNode.js +0 -28
- package/src/nodes/utils/PackingNode.js +0 -55
- package/src/nodes/utils/RotateUVNode.js +0 -35
- /package/src/nodes/accessors/{UVNode.js → UV.js} +0 -0
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import TempNode from '../core/TempNode.js';
|
|
2
|
-
import {
|
|
3
|
-
import { addNodeElement, nodeObject } from '../shadernode/ShaderNode.js';
|
|
2
|
+
import { addMethodChaining, nodeObject } from '../tsl/TSLCore.js';
|
|
4
3
|
|
|
5
|
-
import {
|
|
4
|
+
import { NoColorSpace, NoToneMapping } from '../../constants.js';
|
|
5
|
+
import { ColorManagement } from '../../math/ColorManagement.js';
|
|
6
6
|
|
|
7
7
|
class RenderOutputNode extends TempNode {
|
|
8
8
|
|
|
9
|
+
static get type() {
|
|
10
|
+
|
|
11
|
+
return 'RenderOutputNode';
|
|
12
|
+
|
|
13
|
+
}
|
|
14
|
+
|
|
9
15
|
constructor( colorNode, toneMapping, outputColorSpace ) {
|
|
10
16
|
|
|
11
17
|
super( 'vec4' );
|
|
@@ -24,8 +30,8 @@ class RenderOutputNode extends TempNode {
|
|
|
24
30
|
|
|
25
31
|
// tone mapping
|
|
26
32
|
|
|
27
|
-
const toneMapping = this.toneMapping !== null ? this.toneMapping : context.toneMapping;
|
|
28
|
-
const outputColorSpace = this.outputColorSpace !== null ? this.outputColorSpace : context.outputColorSpace;
|
|
33
|
+
const toneMapping = ( this.toneMapping !== null ? this.toneMapping : context.toneMapping ) || NoToneMapping;
|
|
34
|
+
const outputColorSpace = ( this.outputColorSpace !== null ? this.outputColorSpace : context.outputColorSpace ) || NoColorSpace;
|
|
29
35
|
|
|
30
36
|
if ( toneMapping !== NoToneMapping ) {
|
|
31
37
|
|
|
@@ -33,11 +39,11 @@ class RenderOutputNode extends TempNode {
|
|
|
33
39
|
|
|
34
40
|
}
|
|
35
41
|
|
|
36
|
-
// output color space
|
|
42
|
+
// working to output color space
|
|
37
43
|
|
|
38
|
-
if ( outputColorSpace
|
|
44
|
+
if ( outputColorSpace !== NoColorSpace && outputColorSpace !== ColorManagement.workingColorSpace ) {
|
|
39
45
|
|
|
40
|
-
outputNode = outputNode.
|
|
46
|
+
outputNode = outputNode.workingToColorSpace( outputColorSpace );
|
|
41
47
|
|
|
42
48
|
}
|
|
43
49
|
|
|
@@ -51,6 +57,4 @@ export default RenderOutputNode;
|
|
|
51
57
|
|
|
52
58
|
export const renderOutput = ( color, toneMapping = null, outputColorSpace = null ) => nodeObject( new RenderOutputNode( nodeObject( color ), toneMapping, outputColorSpace ) );
|
|
53
59
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
addNodeClass( 'RenderOutputNode', RenderOutputNode );
|
|
60
|
+
addMethodChaining( 'renderOutput', renderOutput );
|
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
import { nodeObject } from '../tsl/TSLBase.js';
|
|
2
|
+
import PassNode from './PassNode.js';
|
|
3
|
+
import { Color } from '../../math/Color.js';
|
|
4
|
+
import { Vector2 } from '../../math/Vector2.js';
|
|
5
|
+
import { AdditiveBlending } from '../../constants.js';
|
|
6
|
+
import { uniform } from '../core/UniformNode.js';
|
|
7
|
+
import QuadMesh from '../../renderers/common/QuadMesh.js';
|
|
8
|
+
import { texture } from '../accessors/TextureNode.js';
|
|
9
|
+
import { mrt, getTextureIndex } from '../core/MRTNode.js';
|
|
10
|
+
import NodeMaterial from '../../materials/nodes/NodeMaterial.js';
|
|
11
|
+
|
|
12
|
+
const _size = /*@__PURE__*/ new Vector2();
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
*
|
|
16
|
+
* Supersample Anti-Aliasing Render Pass
|
|
17
|
+
*
|
|
18
|
+
* This manual approach to SSAA re-renders the scene ones for each sample with camera jitter and accumulates the results.
|
|
19
|
+
*
|
|
20
|
+
* References: https://en.wikipedia.org/wiki/Supersampling
|
|
21
|
+
*
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
class SSAAPassNode extends PassNode {
|
|
25
|
+
|
|
26
|
+
static get type() {
|
|
27
|
+
|
|
28
|
+
return 'SSAAPassNode';
|
|
29
|
+
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
constructor( scene, camera ) {
|
|
33
|
+
|
|
34
|
+
super( PassNode.COLOR, scene, camera );
|
|
35
|
+
|
|
36
|
+
this.isSSAAPassNode = true;
|
|
37
|
+
|
|
38
|
+
this.sampleLevel = 4; // specified as n, where the number of samples is 2^n, so sampleLevel = 4, is 2^4 samples, 16.
|
|
39
|
+
this.unbiased = true;
|
|
40
|
+
this.clearColor = new Color( 0x000000 );
|
|
41
|
+
this.clearAlpha = 0;
|
|
42
|
+
|
|
43
|
+
this._currentClearColor = new Color();
|
|
44
|
+
|
|
45
|
+
this.sampleWeight = uniform( 1 );
|
|
46
|
+
|
|
47
|
+
this.sampleRenderTarget = null;
|
|
48
|
+
|
|
49
|
+
this._quadMesh = new QuadMesh();
|
|
50
|
+
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
updateBefore( frame ) {
|
|
54
|
+
|
|
55
|
+
const { renderer } = frame;
|
|
56
|
+
const { scene, camera } = this;
|
|
57
|
+
|
|
58
|
+
this._pixelRatio = renderer.getPixelRatio();
|
|
59
|
+
|
|
60
|
+
const size = renderer.getSize( _size );
|
|
61
|
+
|
|
62
|
+
this.setSize( size.width, size.height );
|
|
63
|
+
this.sampleRenderTarget.setSize( this.renderTarget.width, this.renderTarget.height );
|
|
64
|
+
|
|
65
|
+
// save current renderer settings
|
|
66
|
+
|
|
67
|
+
renderer.getClearColor( this._currentClearColor );
|
|
68
|
+
const currentClearAlpha = renderer.getClearAlpha();
|
|
69
|
+
const currentRenderTarget = renderer.getRenderTarget();
|
|
70
|
+
const currentMRT = renderer.getMRT();
|
|
71
|
+
const currentAutoClear = renderer.autoClear;
|
|
72
|
+
|
|
73
|
+
//
|
|
74
|
+
|
|
75
|
+
this._cameraNear.value = camera.near;
|
|
76
|
+
this._cameraFar.value = camera.far;
|
|
77
|
+
|
|
78
|
+
renderer.setMRT( this.getMRT() );
|
|
79
|
+
renderer.autoClear = false;
|
|
80
|
+
|
|
81
|
+
const jitterOffsets = _JitterVectors[ Math.max( 0, Math.min( this.sampleLevel, 5 ) ) ];
|
|
82
|
+
|
|
83
|
+
const baseSampleWeight = 1.0 / jitterOffsets.length;
|
|
84
|
+
const roundingRange = 1 / 32;
|
|
85
|
+
|
|
86
|
+
const viewOffset = {
|
|
87
|
+
|
|
88
|
+
fullWidth: this.renderTarget.width,
|
|
89
|
+
fullHeight: this.renderTarget.height,
|
|
90
|
+
offsetX: 0,
|
|
91
|
+
offsetY: 0,
|
|
92
|
+
width: this.renderTarget.width,
|
|
93
|
+
height: this.renderTarget.height
|
|
94
|
+
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
const originalViewOffset = Object.assign( {}, camera.view );
|
|
98
|
+
|
|
99
|
+
if ( originalViewOffset.enabled ) Object.assign( viewOffset, originalViewOffset );
|
|
100
|
+
|
|
101
|
+
// render the scene multiple times, each slightly jitter offset from the last and accumulate the results.
|
|
102
|
+
|
|
103
|
+
for ( let i = 0; i < jitterOffsets.length; i ++ ) {
|
|
104
|
+
|
|
105
|
+
const jitterOffset = jitterOffsets[ i ];
|
|
106
|
+
|
|
107
|
+
if ( camera.setViewOffset ) {
|
|
108
|
+
|
|
109
|
+
camera.setViewOffset(
|
|
110
|
+
|
|
111
|
+
viewOffset.fullWidth, viewOffset.fullHeight,
|
|
112
|
+
|
|
113
|
+
viewOffset.offsetX + jitterOffset[ 0 ] * 0.0625, viewOffset.offsetY + jitterOffset[ 1 ] * 0.0625, // 0.0625 = 1 / 16
|
|
114
|
+
|
|
115
|
+
viewOffset.width, viewOffset.height
|
|
116
|
+
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
this.sampleWeight.value = baseSampleWeight;
|
|
122
|
+
|
|
123
|
+
if ( this.unbiased ) {
|
|
124
|
+
|
|
125
|
+
// the theory is that equal weights for each sample lead to an accumulation of rounding errors.
|
|
126
|
+
// The following equation varies the sampleWeight per sample so that it is uniformly distributed
|
|
127
|
+
// across a range of values whose rounding errors cancel each other out.
|
|
128
|
+
|
|
129
|
+
const uniformCenteredDistribution = ( - 0.5 + ( i + 0.5 ) / jitterOffsets.length );
|
|
130
|
+
this.sampleWeight.value += roundingRange * uniformCenteredDistribution;
|
|
131
|
+
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
renderer.setClearColor( this.clearColor, this.clearAlpha );
|
|
135
|
+
renderer.setRenderTarget( this.sampleRenderTarget );
|
|
136
|
+
renderer.clear();
|
|
137
|
+
renderer.render( scene, camera );
|
|
138
|
+
|
|
139
|
+
// accumulation
|
|
140
|
+
|
|
141
|
+
renderer.setRenderTarget( this.renderTarget );
|
|
142
|
+
|
|
143
|
+
if ( i === 0 ) {
|
|
144
|
+
|
|
145
|
+
renderer.setClearColor( 0x000000, 0.0 );
|
|
146
|
+
renderer.clear();
|
|
147
|
+
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
this._quadMesh.render( renderer );
|
|
151
|
+
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
renderer.copyTextureToTexture( this.sampleRenderTarget.depthTexture, this.renderTarget.depthTexture );
|
|
155
|
+
|
|
156
|
+
// restore
|
|
157
|
+
|
|
158
|
+
if ( camera.setViewOffset && originalViewOffset.enabled ) {
|
|
159
|
+
|
|
160
|
+
camera.setViewOffset(
|
|
161
|
+
|
|
162
|
+
originalViewOffset.fullWidth, originalViewOffset.fullHeight,
|
|
163
|
+
|
|
164
|
+
originalViewOffset.offsetX, originalViewOffset.offsetY,
|
|
165
|
+
|
|
166
|
+
originalViewOffset.width, originalViewOffset.height
|
|
167
|
+
|
|
168
|
+
);
|
|
169
|
+
|
|
170
|
+
} else if ( camera.clearViewOffset ) {
|
|
171
|
+
|
|
172
|
+
camera.clearViewOffset();
|
|
173
|
+
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
renderer.setRenderTarget( currentRenderTarget );
|
|
177
|
+
renderer.setMRT( currentMRT );
|
|
178
|
+
|
|
179
|
+
renderer.autoClear = currentAutoClear;
|
|
180
|
+
renderer.setClearColor( this._currentClearColor, currentClearAlpha );
|
|
181
|
+
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
setup( builder ) {
|
|
185
|
+
|
|
186
|
+
if ( this.sampleRenderTarget === null ) {
|
|
187
|
+
|
|
188
|
+
this.sampleRenderTarget = this.renderTarget.clone();
|
|
189
|
+
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
let sampleTexture;
|
|
193
|
+
|
|
194
|
+
const passMRT = this.getMRT();
|
|
195
|
+
|
|
196
|
+
if ( passMRT !== null ) {
|
|
197
|
+
|
|
198
|
+
const outputs = {};
|
|
199
|
+
|
|
200
|
+
for ( const name in passMRT.outputNodes ) {
|
|
201
|
+
|
|
202
|
+
const index = getTextureIndex( this.sampleRenderTarget.textures, name );
|
|
203
|
+
|
|
204
|
+
if ( index >= 0 ) {
|
|
205
|
+
|
|
206
|
+
outputs[ name ] = texture( this.sampleRenderTarget.textures[ index ] ).mul( this.sampleWeight );
|
|
207
|
+
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
sampleTexture = mrt( outputs );
|
|
213
|
+
|
|
214
|
+
} else {
|
|
215
|
+
|
|
216
|
+
sampleTexture = texture( this.sampleRenderTarget.texture ).mul( this.sampleWeight );
|
|
217
|
+
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
this._quadMesh.material = new NodeMaterial();
|
|
221
|
+
this._quadMesh.material.fragmentNode = sampleTexture;
|
|
222
|
+
this._quadMesh.material.transparent = true;
|
|
223
|
+
this._quadMesh.material.depthTest = false;
|
|
224
|
+
this._quadMesh.material.depthWrite = false;
|
|
225
|
+
this._quadMesh.material.premultipliedAlpha = true;
|
|
226
|
+
this._quadMesh.material.blending = AdditiveBlending;
|
|
227
|
+
this._quadMesh.material.normals = false;
|
|
228
|
+
this._quadMesh.material.name = 'SSAA';
|
|
229
|
+
|
|
230
|
+
return super.setup( builder );
|
|
231
|
+
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
dispose() {
|
|
235
|
+
|
|
236
|
+
super.dispose();
|
|
237
|
+
|
|
238
|
+
if ( this.sampleRenderTarget !== null ) {
|
|
239
|
+
|
|
240
|
+
this.sampleRenderTarget.dispose();
|
|
241
|
+
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
export default SSAAPassNode;
|
|
249
|
+
|
|
250
|
+
// These jitter vectors are specified in integers because it is easier.
|
|
251
|
+
// I am assuming a [-8,8) integer grid, but it needs to be mapped onto [-0.5,0.5)
|
|
252
|
+
// before being used, thus these integers need to be scaled by 1/16.
|
|
253
|
+
//
|
|
254
|
+
// Sample patterns reference: https://msdn.microsoft.com/en-us/library/windows/desktop/ff476218%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396
|
|
255
|
+
const _JitterVectors = [
|
|
256
|
+
[
|
|
257
|
+
[ 0, 0 ]
|
|
258
|
+
],
|
|
259
|
+
[
|
|
260
|
+
[ 4, 4 ], [ - 4, - 4 ]
|
|
261
|
+
],
|
|
262
|
+
[
|
|
263
|
+
[ - 2, - 6 ], [ 6, - 2 ], [ - 6, 2 ], [ 2, 6 ]
|
|
264
|
+
],
|
|
265
|
+
[
|
|
266
|
+
[ 1, - 3 ], [ - 1, 3 ], [ 5, 1 ], [ - 3, - 5 ],
|
|
267
|
+
[ - 5, 5 ], [ - 7, - 1 ], [ 3, 7 ], [ 7, - 7 ]
|
|
268
|
+
],
|
|
269
|
+
[
|
|
270
|
+
[ 1, 1 ], [ - 1, - 3 ], [ - 3, 2 ], [ 4, - 1 ],
|
|
271
|
+
[ - 5, - 2 ], [ 2, 5 ], [ 5, 3 ], [ 3, - 5 ],
|
|
272
|
+
[ - 2, 6 ], [ 0, - 7 ], [ - 4, - 6 ], [ - 6, 4 ],
|
|
273
|
+
[ - 8, 0 ], [ 7, - 4 ], [ 6, 7 ], [ - 7, - 8 ]
|
|
274
|
+
],
|
|
275
|
+
[
|
|
276
|
+
[ - 4, - 7 ], [ - 7, - 5 ], [ - 3, - 5 ], [ - 5, - 4 ],
|
|
277
|
+
[ - 1, - 4 ], [ - 2, - 2 ], [ - 6, - 1 ], [ - 4, 0 ],
|
|
278
|
+
[ - 7, 1 ], [ - 1, 2 ], [ - 6, 3 ], [ - 3, 3 ],
|
|
279
|
+
[ - 7, 6 ], [ - 3, 6 ], [ - 5, 7 ], [ - 1, 7 ],
|
|
280
|
+
[ 5, - 7 ], [ 1, - 6 ], [ 6, - 5 ], [ 4, - 4 ],
|
|
281
|
+
[ 2, - 3 ], [ 7, - 2 ], [ 1, - 1 ], [ 4, - 1 ],
|
|
282
|
+
[ 2, 1 ], [ 6, 2 ], [ 0, 4 ], [ 4, 4 ],
|
|
283
|
+
[ 2, 5 ], [ 7, 5 ], [ 5, 6 ], [ 3, 7 ]
|
|
284
|
+
]
|
|
285
|
+
];
|
|
286
|
+
|
|
287
|
+
export const ssaaPass = ( scene, camera ) => nodeObject( new SSAAPassNode( scene, camera ) );
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import Node from '../core/Node.js';
|
|
2
|
+
import { NodeUpdateType } from '../core/constants.js';
|
|
3
|
+
import { uniform } from '../core/UniformNode.js';
|
|
4
|
+
import { Fn, nodeImmutable, vec2 } from '../tsl/TSLBase.js';
|
|
5
|
+
|
|
6
|
+
import { Vector2 } from '../../math/Vector2.js';
|
|
7
|
+
import { Vector4 } from '../../math/Vector4.js';
|
|
8
|
+
|
|
9
|
+
let screenSizeVec, viewportVec;
|
|
10
|
+
|
|
11
|
+
class ScreenNode extends Node {
|
|
12
|
+
|
|
13
|
+
static get type() {
|
|
14
|
+
|
|
15
|
+
return 'ScreenNode';
|
|
16
|
+
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
constructor( scope ) {
|
|
20
|
+
|
|
21
|
+
super();
|
|
22
|
+
|
|
23
|
+
this.scope = scope;
|
|
24
|
+
|
|
25
|
+
this.isViewportNode = true;
|
|
26
|
+
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
getNodeType() {
|
|
30
|
+
|
|
31
|
+
if ( this.scope === ScreenNode.VIEWPORT ) return 'vec4';
|
|
32
|
+
else return 'vec2';
|
|
33
|
+
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
getUpdateType() {
|
|
37
|
+
|
|
38
|
+
let updateType = NodeUpdateType.NONE;
|
|
39
|
+
|
|
40
|
+
if ( this.scope === ScreenNode.SIZE || this.scope === ScreenNode.VIEWPORT ) {
|
|
41
|
+
|
|
42
|
+
updateType = NodeUpdateType.RENDER;
|
|
43
|
+
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
this.updateType = updateType;
|
|
47
|
+
|
|
48
|
+
return updateType;
|
|
49
|
+
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
update( { renderer } ) {
|
|
53
|
+
|
|
54
|
+
const renderTarget = renderer.getRenderTarget();
|
|
55
|
+
|
|
56
|
+
if ( this.scope === ScreenNode.VIEWPORT ) {
|
|
57
|
+
|
|
58
|
+
if ( renderTarget !== null ) {
|
|
59
|
+
|
|
60
|
+
viewportVec.copy( renderTarget.viewport );
|
|
61
|
+
|
|
62
|
+
} else {
|
|
63
|
+
|
|
64
|
+
renderer.getViewport( viewportVec );
|
|
65
|
+
|
|
66
|
+
viewportVec.multiplyScalar( renderer.getPixelRatio() );
|
|
67
|
+
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
} else {
|
|
71
|
+
|
|
72
|
+
if ( renderTarget !== null ) {
|
|
73
|
+
|
|
74
|
+
screenSizeVec.width = renderTarget.width;
|
|
75
|
+
screenSizeVec.height = renderTarget.height;
|
|
76
|
+
|
|
77
|
+
} else {
|
|
78
|
+
|
|
79
|
+
renderer.getDrawingBufferSize( screenSizeVec );
|
|
80
|
+
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
setup( /*builder*/ ) {
|
|
88
|
+
|
|
89
|
+
const scope = this.scope;
|
|
90
|
+
|
|
91
|
+
let output = null;
|
|
92
|
+
|
|
93
|
+
if ( scope === ScreenNode.SIZE ) {
|
|
94
|
+
|
|
95
|
+
output = uniform( screenSizeVec || ( screenSizeVec = new Vector2() ) );
|
|
96
|
+
|
|
97
|
+
} else if ( scope === ScreenNode.VIEWPORT ) {
|
|
98
|
+
|
|
99
|
+
output = uniform( viewportVec || ( viewportVec = new Vector4() ) );
|
|
100
|
+
|
|
101
|
+
} else {
|
|
102
|
+
|
|
103
|
+
output = vec2( screenCoordinate.div( screenSize ) );
|
|
104
|
+
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return output;
|
|
108
|
+
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
generate( builder ) {
|
|
112
|
+
|
|
113
|
+
if ( this.scope === ScreenNode.COORDINATE ) {
|
|
114
|
+
|
|
115
|
+
let coord = builder.getFragCoord();
|
|
116
|
+
|
|
117
|
+
if ( builder.isFlipY() ) {
|
|
118
|
+
|
|
119
|
+
// follow webgpu standards
|
|
120
|
+
|
|
121
|
+
const size = builder.getNodeProperties( screenSize ).outputNode.build( builder );
|
|
122
|
+
|
|
123
|
+
coord = `${ builder.getType( 'vec2' ) }( ${ coord }.x, ${ size }.y - ${ coord }.y )`;
|
|
124
|
+
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return coord;
|
|
128
|
+
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return super.generate( builder );
|
|
132
|
+
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
ScreenNode.COORDINATE = 'coordinate';
|
|
138
|
+
ScreenNode.VIEWPORT = 'viewport';
|
|
139
|
+
ScreenNode.SIZE = 'size';
|
|
140
|
+
ScreenNode.UV = 'uv';
|
|
141
|
+
|
|
142
|
+
export default ScreenNode;
|
|
143
|
+
|
|
144
|
+
// Screen
|
|
145
|
+
|
|
146
|
+
export const screenUV = /*@__PURE__*/ nodeImmutable( ScreenNode, ScreenNode.UV );
|
|
147
|
+
export const screenSize = /*@__PURE__*/ nodeImmutable( ScreenNode, ScreenNode.SIZE );
|
|
148
|
+
export const screenCoordinate = /*@__PURE__*/ nodeImmutable( ScreenNode, ScreenNode.COORDINATE );
|
|
149
|
+
|
|
150
|
+
// Viewport
|
|
151
|
+
|
|
152
|
+
export const viewport = /*@__PURE__*/ nodeImmutable( ScreenNode, ScreenNode.VIEWPORT );
|
|
153
|
+
export const viewportSize = viewport.zw;
|
|
154
|
+
export const viewportCoordinate = /*@__PURE__*/ screenCoordinate.sub( viewport.xy );
|
|
155
|
+
export const viewportUV = /*@__PURE__*/ viewportCoordinate.div( viewportSize );
|
|
156
|
+
|
|
157
|
+
// Deprecated
|
|
158
|
+
|
|
159
|
+
export const viewportResolution = /*@__PURE__*/ ( Fn( () => { // @deprecated, r169
|
|
160
|
+
|
|
161
|
+
console.warn( 'TSL.ViewportNode: "viewportResolution" is deprecated. Use "screenSize" instead.' );
|
|
162
|
+
|
|
163
|
+
return screenSize;
|
|
164
|
+
|
|
165
|
+
}, 'vec2' ).once() )();
|
|
166
|
+
|
|
167
|
+
export const viewportTopLeft = /*@__PURE__*/ ( Fn( () => { // @deprecated, r168
|
|
168
|
+
|
|
169
|
+
console.warn( 'TSL.ViewportNode: "viewportTopLeft" is deprecated. Use "screenUV" instead.' );
|
|
170
|
+
|
|
171
|
+
return screenUV;
|
|
172
|
+
|
|
173
|
+
}, 'vec2' ).once() )();
|
|
174
|
+
|
|
175
|
+
export const viewportBottomLeft = /*@__PURE__*/ ( Fn( () => { // @deprecated, r168
|
|
176
|
+
|
|
177
|
+
console.warn( 'TSL.ViewportNode: "viewportBottomLeft" is deprecated. Use "screenUV.flipY()" instead.' );
|
|
178
|
+
|
|
179
|
+
return screenUV.flipY();
|
|
180
|
+
|
|
181
|
+
}, 'vec2' ).once() )();
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Fn, vec3, vec4 } from '../tsl/TSLBase.js';
|
|
2
|
+
import { dot } from '../math/MathNode.js';
|
|
3
|
+
|
|
4
|
+
export const sepia = /*@__PURE__*/ Fn( ( [ color ] ) => {
|
|
5
|
+
|
|
6
|
+
const c = vec3( color );
|
|
7
|
+
|
|
8
|
+
// https://github.com/evanw/glfx.js/blob/master/src/filters/adjust/sepia.js
|
|
9
|
+
|
|
10
|
+
return vec4(
|
|
11
|
+
dot( c, vec3( 0.393, 0.769, 0.189 ) ),
|
|
12
|
+
dot( c, vec3( 0.349, 0.686, 0.168 ) ),
|
|
13
|
+
dot( c, vec3( 0.272, 0.534, 0.131 ) ),
|
|
14
|
+
color.a
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
} );
|
|
@@ -1,15 +1,22 @@
|
|
|
1
1
|
import TempNode from '../core/TempNode.js';
|
|
2
|
-
import { uv } from '../accessors/
|
|
3
|
-
import { luminance } from './
|
|
4
|
-
import {
|
|
2
|
+
import { uv } from '../accessors/UV.js';
|
|
3
|
+
import { luminance } from './ColorAdjustment.js';
|
|
4
|
+
import { Fn, nodeObject, vec2, vec3, vec4, mat3 } from '../tsl/TSLBase.js';
|
|
5
5
|
import { NodeUpdateType } from '../core/constants.js';
|
|
6
6
|
import { uniform } from '../core/UniformNode.js';
|
|
7
7
|
import { add } from '../math/OperatorNode.js';
|
|
8
|
+
import { convertToTexture } from '../utils/RTTNode.js';
|
|
8
9
|
|
|
9
10
|
import { Vector2 } from '../../math/Vector2.js';
|
|
10
11
|
|
|
11
12
|
class SobelOperatorNode extends TempNode {
|
|
12
13
|
|
|
14
|
+
static get type() {
|
|
15
|
+
|
|
16
|
+
return 'SobelOperatorNode';
|
|
17
|
+
|
|
18
|
+
}
|
|
19
|
+
|
|
13
20
|
constructor( textureNode ) {
|
|
14
21
|
|
|
15
22
|
super();
|
|
@@ -38,7 +45,7 @@ class SobelOperatorNode extends TempNode {
|
|
|
38
45
|
|
|
39
46
|
const sampleTexture = ( uv ) => textureNode.uv( uv );
|
|
40
47
|
|
|
41
|
-
const sobel =
|
|
48
|
+
const sobel = Fn( () => {
|
|
42
49
|
|
|
43
50
|
// Sobel Edge Detection (see https://youtu.be/uihBwtPIBxM)
|
|
44
51
|
|
|
@@ -114,8 +121,6 @@ class SobelOperatorNode extends TempNode {
|
|
|
114
121
|
|
|
115
122
|
}
|
|
116
123
|
|
|
117
|
-
export const sobel = ( node ) => nodeObject( new SobelOperatorNode( nodeObject( node ).toTexture() ) );
|
|
118
|
-
|
|
119
|
-
addNodeElement( 'sobel', sobel );
|
|
120
|
-
|
|
121
124
|
export default SobelOperatorNode;
|
|
125
|
+
|
|
126
|
+
export const sobel = ( node ) => nodeObject( new SobelOperatorNode( convertToTexture( node ) ) );
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
|
|
2
|
+
import PassNode from './PassNode.js';
|
|
3
|
+
import { StereoCamera } from '../../cameras/StereoCamera.js';
|
|
4
|
+
import { HalfFloatType, LinearFilter, NearestFilter } from '../../constants.js';
|
|
5
|
+
import { RenderTarget } from '../../core/RenderTarget.js';
|
|
6
|
+
import { texture } from '../accessors/TextureNode.js';
|
|
7
|
+
import { Vector2 } from '../../math/Vector2.js';
|
|
8
|
+
import QuadMesh from '../../renderers/common/QuadMesh.js';
|
|
9
|
+
|
|
10
|
+
const _size = /*@__PURE__*/ new Vector2();
|
|
11
|
+
const _quadMesh = /*@__PURE__*/ new QuadMesh();
|
|
12
|
+
|
|
13
|
+
class StereoCompositePassNode extends PassNode {
|
|
14
|
+
|
|
15
|
+
static get type() {
|
|
16
|
+
|
|
17
|
+
return 'StereoCompositePassNode';
|
|
18
|
+
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
constructor( scene, camera ) {
|
|
22
|
+
|
|
23
|
+
super( PassNode.COLOR, scene, camera );
|
|
24
|
+
|
|
25
|
+
this.isStereoCompositePassNode = true;
|
|
26
|
+
|
|
27
|
+
this.stereo = new StereoCamera();
|
|
28
|
+
const _params = { minFilter: LinearFilter, magFilter: NearestFilter, type: HalfFloatType };
|
|
29
|
+
|
|
30
|
+
this._renderTargetL = new RenderTarget( 1, 1, _params );
|
|
31
|
+
this._renderTargetR = new RenderTarget( 1, 1, _params );
|
|
32
|
+
|
|
33
|
+
this._mapLeft = texture( this._renderTargetL.texture );
|
|
34
|
+
this._mapRight = texture( this._renderTargetR.texture );
|
|
35
|
+
|
|
36
|
+
this._material = null;
|
|
37
|
+
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
updateStereoCamera( coordinateSystem ) {
|
|
41
|
+
|
|
42
|
+
this.stereo.cameraL.coordinateSystem = coordinateSystem;
|
|
43
|
+
this.stereo.cameraR.coordinateSystem = coordinateSystem;
|
|
44
|
+
this.stereo.update( this.camera );
|
|
45
|
+
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
setSize( width, height ) {
|
|
49
|
+
|
|
50
|
+
super.setSize( width, height );
|
|
51
|
+
|
|
52
|
+
this._renderTargetL.setSize( this.renderTarget.width, this.renderTarget.height );
|
|
53
|
+
this._renderTargetR.setSize( this.renderTarget.width, this.renderTarget.height );
|
|
54
|
+
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
updateBefore( frame ) {
|
|
58
|
+
|
|
59
|
+
const { renderer } = frame;
|
|
60
|
+
const { scene, stereo, renderTarget } = this;
|
|
61
|
+
|
|
62
|
+
this._pixelRatio = renderer.getPixelRatio();
|
|
63
|
+
|
|
64
|
+
this.updateStereoCamera( renderer.coordinateSystem );
|
|
65
|
+
|
|
66
|
+
const size = renderer.getSize( _size );
|
|
67
|
+
this.setSize( size.width, size.height );
|
|
68
|
+
|
|
69
|
+
const currentRenderTarget = renderer.getRenderTarget();
|
|
70
|
+
|
|
71
|
+
// left
|
|
72
|
+
|
|
73
|
+
renderer.setRenderTarget( this._renderTargetL );
|
|
74
|
+
renderer.render( scene, stereo.cameraL );
|
|
75
|
+
|
|
76
|
+
// right
|
|
77
|
+
|
|
78
|
+
renderer.setRenderTarget( this._renderTargetR );
|
|
79
|
+
renderer.render( scene, stereo.cameraR );
|
|
80
|
+
|
|
81
|
+
// composite
|
|
82
|
+
|
|
83
|
+
renderer.setRenderTarget( renderTarget );
|
|
84
|
+
_quadMesh.material = this._material;
|
|
85
|
+
_quadMesh.render( renderer );
|
|
86
|
+
|
|
87
|
+
// restore
|
|
88
|
+
|
|
89
|
+
renderer.setRenderTarget( currentRenderTarget );
|
|
90
|
+
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
dispose() {
|
|
94
|
+
|
|
95
|
+
super.dispose();
|
|
96
|
+
|
|
97
|
+
this._renderTargetL.dispose();
|
|
98
|
+
this._renderTargetR.dispose();
|
|
99
|
+
|
|
100
|
+
if ( this._material !== null ) {
|
|
101
|
+
|
|
102
|
+
this._material.dispose();
|
|
103
|
+
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export default StereoCompositePassNode;
|