@plastic-software/three 0.182.0 → 0.183.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/build/three.cjs +11521 -10878
- package/build/three.core.js +11732 -11340
- package/build/three.core.min.js +2 -2
- package/build/three.module.js +510 -263
- package/build/three.module.min.js +2 -2
- package/build/three.tsl.js +7 -11
- package/build/three.tsl.min.js +2 -2
- package/build/three.webgpu.js +3072 -2607
- package/build/three.webgpu.min.js +2 -2
- package/build/three.webgpu.nodes.js +3071 -2607
- package/build/three.webgpu.nodes.min.js +2 -2
- package/examples/jsm/Addons.js +0 -3
- package/examples/jsm/animation/CCDIKSolver.js +2 -2
- package/examples/jsm/controls/ArcballControls.js +3 -3
- package/examples/jsm/controls/OrbitControls.js +103 -0
- package/examples/jsm/effects/AnaglyphEffect.js +102 -7
- package/examples/jsm/environments/ColorEnvironment.js +59 -0
- package/examples/jsm/environments/RoomEnvironment.js +1 -0
- package/examples/jsm/exporters/EXRExporter.js +1 -1
- package/examples/jsm/exporters/GLTFExporter.js +131 -4
- package/examples/jsm/exporters/USDZExporter.js +22 -3
- package/examples/jsm/helpers/AnimationPathHelper.js +302 -0
- package/examples/jsm/helpers/ViewHelper.js +67 -8
- package/examples/jsm/inspector/Inspector.js +21 -5
- package/examples/jsm/inspector/tabs/Console.js +39 -5
- package/examples/jsm/inspector/tabs/Parameters.js +16 -0
- package/examples/jsm/inspector/ui/Style.js +25 -1
- package/examples/jsm/libs/meshopt_decoder.module.js +6 -5
- package/examples/jsm/lines/LineMaterial.js +6 -0
- package/examples/jsm/loaders/3MFLoader.js +2 -2
- package/examples/jsm/loaders/AMFLoader.js +2 -2
- package/examples/jsm/loaders/ColladaLoader.js +24 -4026
- package/examples/jsm/loaders/EXRLoader.js +5 -5
- package/examples/jsm/loaders/FBXLoader.js +2 -2
- package/examples/jsm/loaders/GCodeLoader.js +34 -8
- package/examples/jsm/loaders/GLTFLoader.js +122 -171
- package/examples/jsm/loaders/KMZLoader.js +5 -5
- package/examples/jsm/loaders/KTX2Loader.js +5 -5
- package/examples/jsm/loaders/LWOLoader.js +7 -39
- package/examples/jsm/loaders/NRRDLoader.js +2 -2
- package/examples/jsm/loaders/PCDLoader.js +3 -2
- package/examples/jsm/loaders/USDLoader.js +100 -40
- package/examples/jsm/loaders/UltraHDRLoader.js +182 -30
- package/examples/jsm/loaders/VRMLLoader.js +77 -0
- package/examples/jsm/loaders/VTKLoader.js +37 -24
- package/examples/jsm/loaders/collada/ColladaComposer.js +2950 -0
- package/examples/jsm/loaders/collada/ColladaParser.js +1962 -0
- package/examples/jsm/loaders/usd/USDAParser.js +447 -366
- package/examples/jsm/loaders/usd/USDCParser.js +1841 -6
- package/examples/jsm/loaders/usd/USDComposer.js +4041 -0
- package/examples/jsm/materials/LDrawConditionalLineNodeMaterial.js +2 -2
- package/examples/jsm/objects/LensflareMesh.js +1 -1
- package/examples/jsm/objects/Sky.js +76 -4
- package/examples/jsm/objects/SkyMesh.js +114 -7
- package/examples/jsm/objects/Water.js +4 -3
- package/examples/jsm/objects/Water2.js +5 -3
- package/examples/jsm/objects/WaterMesh.js +5 -7
- package/examples/jsm/physics/JoltPhysics.js +7 -5
- package/examples/jsm/physics/RapierPhysics.js +6 -4
- package/examples/jsm/postprocessing/EffectComposer.js +7 -5
- package/examples/jsm/postprocessing/RenderTransitionPass.js +1 -1
- package/examples/jsm/renderers/CSS3DRenderer.js +1 -1
- package/examples/jsm/renderers/SVGRenderer.js +2 -2
- package/examples/jsm/shaders/GTAOShader.js +19 -6
- package/examples/jsm/shaders/HalftoneShader.js +12 -1
- package/examples/jsm/shaders/PoissonDenoiseShader.js +6 -2
- package/examples/jsm/shaders/SAOShader.js +17 -4
- package/examples/jsm/shaders/SSAOShader.js +11 -1
- package/examples/jsm/shaders/SSRShader.js +6 -5
- package/examples/jsm/shaders/VignetteShader.js +1 -1
- package/examples/jsm/tsl/display/AfterImageNode.js +1 -1
- package/examples/jsm/tsl/display/AnaglyphPassNode.js +456 -16
- package/examples/jsm/tsl/display/AnamorphicNode.js +1 -1
- package/examples/jsm/tsl/display/BilateralBlurNode.js +364 -0
- package/examples/jsm/tsl/display/BloomNode.js +5 -5
- package/examples/jsm/tsl/display/CRT.js +150 -0
- package/examples/jsm/tsl/display/DenoiseNode.js +1 -1
- package/examples/jsm/tsl/display/DepthOfFieldNode.js +1 -1
- package/examples/jsm/tsl/display/DotScreenNode.js +1 -1
- package/examples/jsm/tsl/display/FXAANode.js +2 -2
- package/examples/jsm/tsl/display/GTAONode.js +2 -2
- package/examples/jsm/tsl/display/GaussianBlurNode.js +11 -2
- package/examples/jsm/tsl/display/GodraysNode.js +624 -0
- package/examples/jsm/tsl/display/LensflareNode.js +1 -1
- package/examples/jsm/tsl/display/Lut3DNode.js +1 -1
- package/examples/jsm/tsl/display/OutlineNode.js +3 -3
- package/examples/jsm/tsl/display/ParallaxBarrierPassNode.js +2 -2
- package/examples/jsm/tsl/display/PixelationPassNode.js +5 -5
- package/examples/jsm/tsl/display/RGBShiftNode.js +2 -2
- package/examples/jsm/tsl/display/RetroPassNode.js +263 -0
- package/examples/jsm/tsl/display/SMAANode.js +2 -2
- package/examples/jsm/tsl/display/SSAAPassNode.js +2 -2
- package/examples/jsm/tsl/display/SSGINode.js +2 -2
- package/examples/jsm/tsl/display/SSRNode.js +7 -7
- package/examples/jsm/tsl/display/SSSNode.js +2 -2
- package/examples/jsm/tsl/display/Shape.js +29 -0
- package/examples/jsm/tsl/display/SobelOperatorNode.js +2 -2
- package/examples/jsm/tsl/display/StereoPassNode.js +1 -2
- package/examples/jsm/tsl/display/TRAANode.js +9 -12
- package/examples/jsm/tsl/display/TransitionNode.js +1 -1
- package/examples/jsm/tsl/display/depthAwareBlend.js +80 -0
- package/examples/jsm/tsl/math/Bayer.js +40 -1
- package/examples/jsm/utils/LDrawUtils.js +1 -1
- package/package.json +11 -19
- package/src/Three.Core.js +1 -1
- package/src/Three.TSL.js +5 -9
- package/src/Three.WebGPU.Nodes.js +2 -0
- package/src/Three.WebGPU.js +3 -0
- package/src/Three.js +1 -0
- package/src/animation/AnimationAction.js +1 -1
- package/src/animation/AnimationClip.js +1 -1
- package/src/animation/AnimationMixer.js +6 -0
- package/src/animation/KeyframeTrack.js +46 -7
- package/src/animation/PropertyMixer.js +4 -4
- package/src/audio/Audio.js +1 -1
- package/src/audio/AudioListener.js +5 -3
- package/src/cameras/Camera.js +32 -2
- package/src/cameras/CubeCamera.js +20 -0
- package/src/constants.js +30 -1
- package/src/core/Clock.js +7 -0
- package/src/core/Object3D.js +56 -4
- package/src/core/RenderTarget.js +3 -4
- package/src/extras/PMREMGenerator.js +4 -8
- package/src/geometries/TorusGeometry.js +8 -3
- package/src/helpers/CameraHelper.js +3 -0
- package/src/helpers/DirectionalLightHelper.js +4 -1
- package/src/helpers/HemisphereLightHelper.js +3 -0
- package/src/helpers/PointLightHelper.js +0 -24
- package/src/helpers/SpotLightHelper.js +3 -0
- package/src/lights/LightShadow.js +15 -3
- package/src/lights/webgpu/IESSpotLight.js +2 -1
- package/src/loaders/Cache.js +28 -0
- package/src/loaders/FileLoader.js +1 -1
- package/src/loaders/ImageBitmapLoader.js +8 -3
- package/src/loaders/Loader.js +6 -0
- package/src/loaders/ObjectLoader.js +18 -1
- package/src/materials/MeshLambertMaterial.js +9 -0
- package/src/materials/MeshPhongMaterial.js +9 -0
- package/src/materials/nodes/Line2NodeMaterial.js +5 -5
- package/src/materials/nodes/MeshPhysicalNodeMaterial.js +2 -0
- package/src/materials/nodes/NodeMaterial.js +15 -24
- package/src/materials/nodes/manager/NodeMaterialObserver.js +9 -3
- package/src/math/Line3.js +3 -5
- package/src/math/MathUtils.js +10 -10
- package/src/math/Matrix4.js +35 -26
- package/src/math/Quaternion.js +3 -29
- package/src/math/Vector3.js +3 -3
- package/src/math/interpolants/BezierInterpolant.js +108 -0
- package/src/nodes/Nodes.js +87 -68
- package/src/nodes/TSL.js +2 -5
- package/src/nodes/accessors/Arrays.js +1 -1
- package/src/nodes/accessors/Bitangent.js +5 -5
- package/src/nodes/accessors/BufferAttributeNode.js +1 -1
- package/src/nodes/accessors/Camera.js +149 -28
- package/src/nodes/accessors/InstanceNode.js +105 -40
- package/src/nodes/accessors/Normal.js +9 -9
- package/src/nodes/accessors/Position.js +34 -2
- package/src/nodes/accessors/SceneProperties.js +53 -0
- package/src/nodes/accessors/SkinningNode.js +12 -24
- package/src/nodes/accessors/StorageBufferNode.js +0 -19
- package/src/nodes/accessors/StorageTextureNode.js +37 -1
- package/src/nodes/accessors/Tangent.js +3 -3
- package/src/nodes/accessors/Texture3DNode.js +6 -34
- package/src/nodes/accessors/TextureNode.js +58 -22
- package/src/nodes/accessors/UniformArrayNode.js +2 -0
- package/src/nodes/core/MRTNode.js +48 -2
- package/src/nodes/core/Node.js +29 -3
- package/src/nodes/core/NodeBuilder.js +115 -40
- package/src/nodes/core/NodeError.js +28 -0
- package/src/nodes/core/NodeUtils.js +5 -3
- package/src/nodes/core/OutputStructNode.js +12 -10
- package/src/nodes/core/ParameterNode.js +2 -1
- package/src/nodes/core/StackNode.js +9 -8
- package/src/nodes/core/StackTrace.js +139 -0
- package/src/nodes/core/StructNode.js +15 -0
- package/src/nodes/core/SubBuildNode.js +1 -1
- package/src/nodes/core/UniformNode.js +2 -1
- package/src/nodes/core/VarNode.js +1 -1
- package/src/nodes/core/VaryingNode.js +1 -18
- package/src/nodes/display/BlendModes.js +0 -64
- package/src/nodes/display/ColorAdjustment.js +17 -0
- package/src/nodes/display/ColorSpaceNode.js +3 -3
- package/src/nodes/display/NormalMapNode.js +2 -2
- package/src/nodes/display/PassNode.js +21 -2
- package/src/nodes/display/RenderOutputNode.js +3 -3
- package/src/nodes/display/ScreenNode.js +2 -1
- package/src/nodes/display/ToneMappingNode.js +1 -1
- package/src/nodes/display/ToonOutlinePassNode.js +2 -2
- package/src/nodes/display/ViewportDepthNode.js +52 -4
- package/src/nodes/display/ViewportTextureNode.js +21 -4
- package/src/nodes/fog/Fog.js +18 -35
- package/src/nodes/functions/PhysicalLightingModel.js +25 -3
- package/src/nodes/geometry/RangeNode.js +4 -2
- package/src/nodes/gpgpu/ComputeNode.js +5 -4
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +2 -1
- package/src/nodes/lighting/EnvironmentNode.js +28 -3
- package/src/nodes/lighting/PointShadowNode.js +24 -12
- package/src/nodes/lighting/ShadowFilterNode.js +15 -43
- package/src/nodes/lighting/ShadowNode.js +54 -32
- package/src/nodes/math/ConditionalNode.js +2 -2
- package/src/nodes/math/MathNode.js +3 -40
- package/src/nodes/math/OperatorNode.js +2 -1
- package/src/nodes/pmrem/PMREMUtils.js +9 -15
- package/src/nodes/tsl/TSLCore.js +13 -10
- package/src/nodes/utils/DebugNode.js +11 -11
- package/src/nodes/utils/JoinNode.js +2 -2
- package/src/nodes/utils/LoopNode.js +1 -1
- package/src/nodes/utils/MemberNode.js +1 -1
- package/src/nodes/utils/RTTNode.js +1 -1
- package/src/nodes/utils/ReflectorNode.js +2 -3
- package/src/nodes/utils/SpriteSheetUV.js +35 -0
- package/src/nodes/utils/UVUtils.js +4 -2
- package/src/objects/BatchedMesh.js +22 -12
- package/src/objects/InstancedMesh.js +11 -0
- package/src/renderers/WebGLRenderer.js +34 -60
- package/src/renderers/common/Backend.js +21 -0
- package/src/renderers/common/Background.js +7 -4
- package/src/renderers/common/BindGroup.js +1 -9
- package/src/renderers/common/Bindings.js +20 -5
- package/src/renderers/common/BlendMode.js +143 -0
- package/src/renderers/common/BundleGroup.js +1 -1
- package/src/renderers/common/CubeRenderTarget.js +50 -6
- package/src/renderers/common/Geometries.js +17 -3
- package/src/renderers/common/Lighting.js +5 -21
- package/src/renderers/common/Pipelines.js +4 -4
- package/src/renderers/common/PostProcessing.js +8 -206
- package/src/renderers/common/RenderBundles.js +2 -1
- package/src/renderers/common/RenderContext.js +16 -0
- package/src/renderers/common/RenderContexts.js +33 -56
- package/src/renderers/common/RenderLists.js +2 -1
- package/src/renderers/common/RenderObject.js +2 -3
- package/src/renderers/common/RenderObjectPipeline.js +40 -0
- package/src/renderers/common/RenderObjects.js +18 -2
- package/src/renderers/common/RenderPipeline.js +203 -17
- package/src/renderers/common/Renderer.js +207 -40
- package/src/renderers/common/Sampler.js +4 -4
- package/src/renderers/common/StorageBuffer.js +13 -1
- package/src/renderers/common/Textures.js +16 -0
- package/src/renderers/common/TimestampQueryPool.js +5 -3
- package/src/renderers/common/Uniform.js +8 -0
- package/src/renderers/common/UniformsGroup.js +60 -0
- package/src/renderers/common/XRManager.js +2 -2
- package/src/renderers/common/nodes/NodeBuilderState.js +1 -1
- package/src/renderers/common/nodes/{Nodes.js → NodeManager.js} +18 -6
- package/src/renderers/common/nodes/NodeStorageBuffer.js +13 -2
- package/src/renderers/shaders/ShaderChunk/batching_pars_vertex.glsl.js +2 -2
- package/src/renderers/shaders/ShaderChunk/color_fragment.glsl.js +1 -5
- package/src/renderers/shaders/ShaderChunk/color_pars_fragment.glsl.js +1 -5
- package/src/renderers/shaders/ShaderChunk/color_pars_vertex.glsl.js +1 -5
- package/src/renderers/shaders/ShaderChunk/color_vertex.glsl.js +8 -10
- package/src/renderers/shaders/ShaderChunk/cube_uv_reflection_fragment.glsl.js +4 -4
- package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +7 -11
- package/src/renderers/shaders/ShaderChunk/lights_fragment_end.glsl.js +6 -0
- package/src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js +6 -2
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +23 -1
- package/src/renderers/shaders/ShaderChunk/packing.glsl.js +20 -4
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +55 -24
- package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +2 -0
- package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +2 -0
- package/src/renderers/shaders/ShaderLib/shadow.glsl.js +1 -0
- package/src/renderers/shaders/ShaderLib.js +4 -2
- package/src/renderers/shaders/UniformsLib.js +0 -3
- package/src/renderers/webgl/WebGLBackground.js +2 -2
- package/src/renderers/webgl/WebGLBindingStates.js +99 -27
- package/src/renderers/webgl/WebGLEnvironments.js +228 -0
- package/src/renderers/webgl/WebGLGeometries.js +10 -7
- package/src/renderers/webgl/WebGLMaterials.js +12 -0
- package/src/renderers/webgl/WebGLObjects.js +3 -1
- package/src/renderers/webgl/WebGLProgram.js +2 -2
- package/src/renderers/webgl/WebGLPrograms.js +10 -4
- package/src/renderers/webgl/WebGLRenderLists.js +15 -0
- package/src/renderers/webgl/WebGLShadowMap.js +5 -4
- package/src/renderers/webgl/WebGLState.js +12 -17
- package/src/renderers/webgl-fallback/WebGLBackend.js +71 -7
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +98 -29
- package/src/renderers/webgl-fallback/utils/WebGLState.js +168 -7
- package/src/renderers/webgpu/WebGPUBackend.js +58 -9
- package/src/renderers/webgpu/WebGPURenderer.js +1 -0
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +257 -45
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +8 -19
- package/src/renderers/webgpu/utils/WebGPUConstants.js +1 -1
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +56 -31
- package/src/renderers/webgpu/utils/WebGPUTexturePassUtils.js +152 -200
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +25 -25
- package/src/renderers/webgpu/utils/WebGPUUtils.js +10 -6
- package/src/renderers/webxr/WebXRManager.js +2 -2
- package/src/textures/Texture.js +2 -2
- package/src/utils.js +246 -3
- package/examples/jsm/materials/MeshGouraudMaterial.js +0 -433
- package/examples/jsm/materials/MeshPostProcessingMaterial.js +0 -167
- package/examples/jsm/shaders/GodRaysShader.js +0 -333
- package/src/nodes/accessors/SceneNode.js +0 -145
- package/src/nodes/code/ScriptableNode.js +0 -726
- package/src/nodes/code/ScriptableValueNode.js +0 -253
- package/src/nodes/display/PosterizeNode.js +0 -65
- package/src/nodes/utils/SpriteSheetUVNode.js +0 -90
- package/src/renderers/webgl/WebGLCubeMaps.js +0 -99
- package/src/renderers/webgl/WebGLCubeUVMaps.js +0 -134
|
@@ -2,7 +2,7 @@ import Node from '../core/Node.js';
|
|
|
2
2
|
import { varyingProperty } from '../core/PropertyNode.js';
|
|
3
3
|
import { instancedBufferAttribute, instancedDynamicBufferAttribute } from './BufferAttributeNode.js';
|
|
4
4
|
import { normalLocal, transformNormal } from './Normal.js';
|
|
5
|
-
import { positionLocal } from './Position.js';
|
|
5
|
+
import { positionLocal, positionPrevious } from './Position.js';
|
|
6
6
|
import { nodeProxy, vec3, mat4 } from '../tsl/TSLBase.js';
|
|
7
7
|
import { NodeUpdateType } from '../core/constants.js';
|
|
8
8
|
import { buffer } from '../accessors/BufferNode.js';
|
|
@@ -99,6 +99,14 @@ class InstanceNode extends Node {
|
|
|
99
99
|
*/
|
|
100
100
|
this.bufferColor = null;
|
|
101
101
|
|
|
102
|
+
/**
|
|
103
|
+
* The previous instance matrices. Required for computing motion vectors.
|
|
104
|
+
*
|
|
105
|
+
* @type {?Node}
|
|
106
|
+
* @default null
|
|
107
|
+
*/
|
|
108
|
+
this.previousInstanceMatrixNode = null;
|
|
109
|
+
|
|
102
110
|
}
|
|
103
111
|
|
|
104
112
|
/**
|
|
@@ -136,51 +144,22 @@ class InstanceNode extends Node {
|
|
|
136
144
|
*/
|
|
137
145
|
setup( builder ) {
|
|
138
146
|
|
|
139
|
-
const { instanceMatrix, instanceColor, isStorageMatrix, isStorageColor } = this;
|
|
140
|
-
|
|
141
|
-
const { count } = instanceMatrix;
|
|
142
|
-
|
|
143
147
|
let { instanceMatrixNode, instanceColorNode } = this;
|
|
144
148
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
if ( isStorageMatrix ) {
|
|
148
|
-
|
|
149
|
-
instanceMatrixNode = storage( instanceMatrix, 'mat4', Math.max( count, 1 ) ).element( instanceIndex );
|
|
150
|
-
|
|
151
|
-
} else {
|
|
152
|
-
|
|
153
|
-
// Both backends have ~64kb UBO limit; fallback to attributes above 1000 matrices.
|
|
154
|
-
|
|
155
|
-
if ( count <= 1000 ) {
|
|
156
|
-
|
|
157
|
-
instanceMatrixNode = buffer( instanceMatrix.array, 'mat4', Math.max( count, 1 ) ).element( instanceIndex );
|
|
158
|
-
|
|
159
|
-
} else {
|
|
160
|
-
|
|
161
|
-
const interleaved = new InstancedInterleavedBuffer( instanceMatrix.array, 16, 1 );
|
|
162
|
-
|
|
163
|
-
this.buffer = interleaved;
|
|
149
|
+
// instance matrix
|
|
164
150
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
const instanceBuffers = [
|
|
168
|
-
bufferFn( interleaved, 'vec4', 16, 0 ),
|
|
169
|
-
bufferFn( interleaved, 'vec4', 16, 4 ),
|
|
170
|
-
bufferFn( interleaved, 'vec4', 16, 8 ),
|
|
171
|
-
bufferFn( interleaved, 'vec4', 16, 12 )
|
|
172
|
-
];
|
|
173
|
-
|
|
174
|
-
instanceMatrixNode = mat4( ...instanceBuffers );
|
|
175
|
-
|
|
176
|
-
}
|
|
151
|
+
if ( instanceMatrixNode === null ) {
|
|
177
152
|
|
|
178
|
-
|
|
153
|
+
instanceMatrixNode = this._createInstanceMatrixNode( true, builder );
|
|
179
154
|
|
|
180
155
|
this.instanceMatrixNode = instanceMatrixNode;
|
|
181
156
|
|
|
182
157
|
}
|
|
183
158
|
|
|
159
|
+
// instance color
|
|
160
|
+
|
|
161
|
+
const { instanceColor, isStorageColor } = this;
|
|
162
|
+
|
|
184
163
|
if ( instanceColor && instanceColorNode === null ) {
|
|
185
164
|
|
|
186
165
|
if ( isStorageColor ) {
|
|
@@ -208,6 +187,12 @@ class InstanceNode extends Node {
|
|
|
208
187
|
const instancePosition = instanceMatrixNode.mul( positionLocal ).xyz;
|
|
209
188
|
positionLocal.assign( instancePosition );
|
|
210
189
|
|
|
190
|
+
if ( builder.needsPreviousData() ) {
|
|
191
|
+
|
|
192
|
+
positionPrevious.assign( this.getPreviousInstancedPosition( builder ) );
|
|
193
|
+
|
|
194
|
+
}
|
|
195
|
+
|
|
211
196
|
// NORMAL
|
|
212
197
|
|
|
213
198
|
if ( builder.hasGeometryAttribute( 'normal' ) ) {
|
|
@@ -235,7 +220,7 @@ class InstanceNode extends Node {
|
|
|
235
220
|
*
|
|
236
221
|
* @param {NodeFrame} frame - The current node frame.
|
|
237
222
|
*/
|
|
238
|
-
update(
|
|
223
|
+
update( frame ) {
|
|
239
224
|
|
|
240
225
|
if ( this.buffer !== null && this.isStorageMatrix !== true ) {
|
|
241
226
|
|
|
@@ -244,7 +229,7 @@ class InstanceNode extends Node {
|
|
|
244
229
|
|
|
245
230
|
// update version if necessary
|
|
246
231
|
|
|
247
|
-
if ( this.instanceMatrix.
|
|
232
|
+
if ( this.instanceMatrix.version !== this.buffer.version ) {
|
|
248
233
|
|
|
249
234
|
this.buffer.version = this.instanceMatrix.version;
|
|
250
235
|
|
|
@@ -257,7 +242,7 @@ class InstanceNode extends Node {
|
|
|
257
242
|
this.bufferColor.clearUpdateRanges();
|
|
258
243
|
this.bufferColor.updateRanges.push( ... this.instanceColor.updateRanges );
|
|
259
244
|
|
|
260
|
-
if ( this.instanceColor.
|
|
245
|
+
if ( this.instanceColor.version !== this.bufferColor.version ) {
|
|
261
246
|
|
|
262
247
|
this.bufferColor.version = this.instanceColor.version;
|
|
263
248
|
|
|
@@ -265,6 +250,86 @@ class InstanceNode extends Node {
|
|
|
265
250
|
|
|
266
251
|
}
|
|
267
252
|
|
|
253
|
+
if ( this.previousInstanceMatrixNode !== null ) {
|
|
254
|
+
|
|
255
|
+
frame.object.previousInstanceMatrix.array.set( this.instanceMatrix.array );
|
|
256
|
+
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Computes the transformed/instanced vertex position of the previous frame.
|
|
263
|
+
*
|
|
264
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
265
|
+
* @return {Node<vec3>} The instanced position from the previous frame.
|
|
266
|
+
*/
|
|
267
|
+
getPreviousInstancedPosition( builder ) {
|
|
268
|
+
|
|
269
|
+
const instancedMesh = builder.object;
|
|
270
|
+
|
|
271
|
+
if ( this.previousInstanceMatrixNode === null ) {
|
|
272
|
+
|
|
273
|
+
instancedMesh.previousInstanceMatrix = this.instanceMatrix.clone();
|
|
274
|
+
|
|
275
|
+
this.previousInstanceMatrixNode = this._createInstanceMatrixNode( false, builder );
|
|
276
|
+
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
return this.previousInstanceMatrixNode.mul( positionPrevious ).xyz;
|
|
280
|
+
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* Creates a node representing the instance matrix data.
|
|
285
|
+
*
|
|
286
|
+
* @private
|
|
287
|
+
* @param {boolean} assignBuffer - Whether the created interleaved buffer should be assigned to the `buffer` member or not.
|
|
288
|
+
* @param {NodeBuilder} builder - A reference to the current node builder.
|
|
289
|
+
* @return {Node} The instance matrix node.
|
|
290
|
+
*/
|
|
291
|
+
_createInstanceMatrixNode( assignBuffer, builder ) {
|
|
292
|
+
|
|
293
|
+
let instanceMatrixNode;
|
|
294
|
+
|
|
295
|
+
const { instanceMatrix } = this;
|
|
296
|
+
const { count } = instanceMatrix;
|
|
297
|
+
|
|
298
|
+
if ( this.isStorageMatrix ) {
|
|
299
|
+
|
|
300
|
+
instanceMatrixNode = storage( instanceMatrix, 'mat4', Math.max( count, 1 ) ).element( instanceIndex );
|
|
301
|
+
|
|
302
|
+
} else {
|
|
303
|
+
|
|
304
|
+
const uniformBufferSize = count * 16 * 4; // count * 16 components * 4 bytes (float)
|
|
305
|
+
|
|
306
|
+
if ( uniformBufferSize <= builder.getUniformBufferLimit() ) {
|
|
307
|
+
|
|
308
|
+
instanceMatrixNode = buffer( instanceMatrix.array, 'mat4', Math.max( count, 1 ) ).element( instanceIndex );
|
|
309
|
+
|
|
310
|
+
} else {
|
|
311
|
+
|
|
312
|
+
const interleaved = new InstancedInterleavedBuffer( instanceMatrix.array, 16, 1 );
|
|
313
|
+
|
|
314
|
+
if ( assignBuffer === true ) this.buffer = interleaved;
|
|
315
|
+
|
|
316
|
+
const bufferFn = instanceMatrix.usage === DynamicDrawUsage ? instancedDynamicBufferAttribute : instancedBufferAttribute;
|
|
317
|
+
|
|
318
|
+
const instanceBuffers = [
|
|
319
|
+
bufferFn( interleaved, 'vec4', 16, 0 ),
|
|
320
|
+
bufferFn( interleaved, 'vec4', 16, 4 ),
|
|
321
|
+
bufferFn( interleaved, 'vec4', 16, 8 ),
|
|
322
|
+
bufferFn( interleaved, 'vec4', 16, 12 )
|
|
323
|
+
];
|
|
324
|
+
|
|
325
|
+
instanceMatrixNode = mat4( ...instanceBuffers );
|
|
326
|
+
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
return instanceMatrixNode;
|
|
332
|
+
|
|
268
333
|
}
|
|
269
334
|
|
|
270
335
|
}
|
|
@@ -52,7 +52,7 @@ export const normalViewGeometry = /*@__PURE__*/ ( Fn( ( builder ) => {
|
|
|
52
52
|
|
|
53
53
|
let node;
|
|
54
54
|
|
|
55
|
-
if ( builder.
|
|
55
|
+
if ( builder.isFlatShading() ) {
|
|
56
56
|
|
|
57
57
|
node = normalFlat;
|
|
58
58
|
|
|
@@ -76,7 +76,7 @@ export const normalWorldGeometry = /*@__PURE__*/ ( Fn( ( builder ) => {
|
|
|
76
76
|
|
|
77
77
|
let normal = normalViewGeometry.transformDirection( cameraViewMatrix );
|
|
78
78
|
|
|
79
|
-
if ( builder.
|
|
79
|
+
if ( builder.isFlatShading() !== true ) {
|
|
80
80
|
|
|
81
81
|
normal = normal.toVarying( 'v_normalWorldGeometry' );
|
|
82
82
|
|
|
@@ -92,15 +92,15 @@ export const normalWorldGeometry = /*@__PURE__*/ ( Fn( ( builder ) => {
|
|
|
92
92
|
* @tsl
|
|
93
93
|
* @type {Node<vec3>}
|
|
94
94
|
*/
|
|
95
|
-
export const normalView = /*@__PURE__*/ ( Fn( (
|
|
95
|
+
export const normalView = /*@__PURE__*/ ( Fn( ( builder ) => {
|
|
96
96
|
|
|
97
97
|
let node;
|
|
98
98
|
|
|
99
|
-
if ( subBuildFn === 'NORMAL' || subBuildFn === 'VERTEX' ) {
|
|
99
|
+
if ( builder.subBuildFn === 'NORMAL' || builder.subBuildFn === 'VERTEX' ) {
|
|
100
100
|
|
|
101
101
|
node = normalViewGeometry;
|
|
102
102
|
|
|
103
|
-
if (
|
|
103
|
+
if ( builder.isFlatShading() !== true ) {
|
|
104
104
|
|
|
105
105
|
node = directionToFaceDirection( node );
|
|
106
106
|
|
|
@@ -108,9 +108,9 @@ export const normalView = /*@__PURE__*/ ( Fn( ( { subBuildFn, material, context
|
|
|
108
108
|
|
|
109
109
|
} else {
|
|
110
110
|
|
|
111
|
-
// Use
|
|
111
|
+
// Use custom context to avoid side effects from nodes overwriting getUV, getTextureLevel in the context (e.g. EnvironmentNode)
|
|
112
112
|
|
|
113
|
-
node = context.setupNormal().context( { getUV: null } );
|
|
113
|
+
node = builder.context.setupNormal().context( { getUV: null, getTextureLevel: null } );
|
|
114
114
|
|
|
115
115
|
}
|
|
116
116
|
|
|
@@ -142,9 +142,9 @@ export const clearcoatNormalView = /*@__PURE__*/ ( Fn( ( { subBuildFn, context }
|
|
|
142
142
|
|
|
143
143
|
} else {
|
|
144
144
|
|
|
145
|
-
// Use
|
|
145
|
+
// Use custom context to avoid side effects from nodes overwriting getUV, getTextureLevel in the context (e.g. EnvironmentNode)
|
|
146
146
|
|
|
147
|
-
node = context.setupClearcoatNormal().context( { getUV: null } );
|
|
147
|
+
node = context.setupClearcoatNormal().context( { getUV: null, getTextureLevel: null } );
|
|
148
148
|
|
|
149
149
|
}
|
|
150
150
|
|
|
@@ -1,6 +1,28 @@
|
|
|
1
1
|
import { attribute } from '../core/AttributeNode.js';
|
|
2
|
-
import { Fn, vec3 } from '../tsl/TSLCore.js';
|
|
2
|
+
import { Fn, vec3, vec4 } from '../tsl/TSLCore.js';
|
|
3
3
|
import { modelWorldMatrix } from './ModelNode.js';
|
|
4
|
+
import { cameraProjectionMatrixInverse } from './Camera.js';
|
|
5
|
+
import { warnOnce } from '../../utils.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* TSL object that represents the clip space position of the current rendered object.
|
|
9
|
+
*
|
|
10
|
+
* @tsl
|
|
11
|
+
* @type {VaryingNode<vec4>}
|
|
12
|
+
*/
|
|
13
|
+
export const clipSpace = /*@__PURE__*/ ( Fn( ( builder ) => {
|
|
14
|
+
|
|
15
|
+
if ( builder.shaderStage !== 'fragment' ) {
|
|
16
|
+
|
|
17
|
+
warnOnce( 'TSL: `clipSpace` is only available in fragment stage.' );
|
|
18
|
+
|
|
19
|
+
return vec4();
|
|
20
|
+
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return builder.context.clipSpace.toVarying( 'v_clipSpace' );
|
|
24
|
+
|
|
25
|
+
} ).once() )();
|
|
4
26
|
|
|
5
27
|
/**
|
|
6
28
|
* TSL object that represents the position attribute of the current rendered object.
|
|
@@ -61,9 +83,19 @@ export const positionWorldDirection = /*@__PURE__*/ ( Fn( () => {
|
|
|
61
83
|
*/
|
|
62
84
|
export const positionView = /*@__PURE__*/ ( Fn( ( builder ) => {
|
|
63
85
|
|
|
86
|
+
if ( builder.shaderStage === 'fragment' && builder.material.vertexNode ) {
|
|
87
|
+
|
|
88
|
+
// reconstruct view position from clip space
|
|
89
|
+
|
|
90
|
+
const viewPos = cameraProjectionMatrixInverse.mul( clipSpace );
|
|
91
|
+
|
|
92
|
+
return viewPos.xyz.div( viewPos.w ).toVar( 'positionView' );
|
|
93
|
+
|
|
94
|
+
}
|
|
95
|
+
|
|
64
96
|
return builder.context.setupPositionView().toVarying( 'v_positionView' );
|
|
65
97
|
|
|
66
|
-
}, 'vec3' ).once( [ 'POSITION' ] ) )();
|
|
98
|
+
}, 'vec3' ).once( [ 'POSITION', 'VERTEX' ] ) )();
|
|
67
99
|
|
|
68
100
|
/**
|
|
69
101
|
* TSL object that represents the position view direction of the current rendered object.
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { UVMapping } from '../../constants.js';
|
|
2
|
+
import { Euler } from '../../math/Euler.js';
|
|
3
|
+
import { Matrix4 } from '../../math/Matrix4.js';
|
|
4
|
+
import { renderGroup } from '../core/UniformGroupNode.js';
|
|
5
|
+
import { uniform } from '../tsl/TSLBase.js';
|
|
6
|
+
|
|
7
|
+
const _e1 = /*@__PURE__*/ new Euler();
|
|
8
|
+
const _m1 = /*@__PURE__*/ new Matrix4();
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* TSL object that represents the scene's background blurriness.
|
|
12
|
+
*
|
|
13
|
+
* @tsl
|
|
14
|
+
* @type {Node<float>}
|
|
15
|
+
*/
|
|
16
|
+
export const backgroundBlurriness = /*@__PURE__*/ uniform( 0 ).setGroup( renderGroup ).onRenderUpdate( ( { scene } ) => scene.backgroundBlurriness );
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* TSL object that represents the scene's background intensity.
|
|
20
|
+
*
|
|
21
|
+
* @tsl
|
|
22
|
+
* @type {Node<float>}
|
|
23
|
+
*/
|
|
24
|
+
export const backgroundIntensity = /*@__PURE__*/ uniform( 1 ).setGroup( renderGroup ).onRenderUpdate( ( { scene } ) => scene.backgroundIntensity );
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* TSL object that represents the scene's background rotation.
|
|
28
|
+
*
|
|
29
|
+
* @tsl
|
|
30
|
+
* @type {Node<mat4>}
|
|
31
|
+
*/
|
|
32
|
+
export const backgroundRotation = /*@__PURE__*/ uniform( new Matrix4() ).setGroup( renderGroup ).onRenderUpdate( ( { scene } ) => {
|
|
33
|
+
|
|
34
|
+
const background = scene.background;
|
|
35
|
+
|
|
36
|
+
if ( background !== null && background.isTexture && background.mapping !== UVMapping ) {
|
|
37
|
+
|
|
38
|
+
_e1.copy( scene.backgroundRotation );
|
|
39
|
+
|
|
40
|
+
// accommodate left-handed frame
|
|
41
|
+
_e1.x *= - 1; _e1.y *= - 1; _e1.z *= - 1;
|
|
42
|
+
|
|
43
|
+
_m1.makeRotationFromEuler( _e1 );
|
|
44
|
+
|
|
45
|
+
} else {
|
|
46
|
+
|
|
47
|
+
_m1.identity();
|
|
48
|
+
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return _m1;
|
|
52
|
+
|
|
53
|
+
} );
|
|
@@ -9,7 +9,6 @@ import { positionLocal, positionPrevious } from './Position.js';
|
|
|
9
9
|
import { tangentLocal } from './Tangent.js';
|
|
10
10
|
import { uniform } from '../core/UniformNode.js';
|
|
11
11
|
import { buffer } from './BufferNode.js';
|
|
12
|
-
import { getDataFromObject } from '../core/NodeUtils.js';
|
|
13
12
|
import { storage } from './StorageBufferNode.js';
|
|
14
13
|
import { InstancedBufferAttribute } from '../../core/InstancedBufferAttribute.js';
|
|
15
14
|
import { instanceIndex } from '../core/IndexNode.js';
|
|
@@ -147,13 +146,14 @@ class SkinningNode extends Node {
|
|
|
147
146
|
}
|
|
148
147
|
|
|
149
148
|
/**
|
|
150
|
-
* Transforms the given vertex normal via skinning.
|
|
149
|
+
* Transforms the given vertex normal and tangent via skinning.
|
|
151
150
|
*
|
|
152
151
|
* @param {Node} [boneMatrices=this.boneMatricesNode] - The bone matrices
|
|
153
152
|
* @param {Node<vec3>} [normal=normalLocal] - The vertex normal in local space.
|
|
154
|
-
* @
|
|
153
|
+
* @param {Node<vec3>} [tangent=tangentLocal] - The vertex tangent in local space.
|
|
154
|
+
* @return {{skinNormal: Node<vec3>, skinTangent:Node<vec3>}} The transformed vertex normal and tangent.
|
|
155
155
|
*/
|
|
156
|
-
|
|
156
|
+
getSkinnedNormalAndTangent( boneMatrices = this.boneMatricesNode, normal = normalLocal, tangent = tangentLocal ) {
|
|
157
157
|
|
|
158
158
|
const { skinIndexNode, skinWeightNode, bindMatrixNode, bindMatrixInverseNode } = this;
|
|
159
159
|
|
|
@@ -162,7 +162,7 @@ class SkinningNode extends Node {
|
|
|
162
162
|
const boneMatZ = boneMatrices.element( skinIndexNode.z );
|
|
163
163
|
const boneMatW = boneMatrices.element( skinIndexNode.w );
|
|
164
164
|
|
|
165
|
-
// NORMAL
|
|
165
|
+
// NORMAL and TANGENT
|
|
166
166
|
|
|
167
167
|
let skinMatrix = add(
|
|
168
168
|
skinWeightNode.x.mul( boneMatX ),
|
|
@@ -173,7 +173,10 @@ class SkinningNode extends Node {
|
|
|
173
173
|
|
|
174
174
|
skinMatrix = bindMatrixInverseNode.mul( skinMatrix ).mul( bindMatrixNode );
|
|
175
175
|
|
|
176
|
-
|
|
176
|
+
const skinNormal = skinMatrix.transformDirection( normal ).xyz;
|
|
177
|
+
const skinTangent = skinMatrix.transformDirection( tangent ).xyz;
|
|
178
|
+
|
|
179
|
+
return { skinNormal, skinTangent };
|
|
177
180
|
|
|
178
181
|
}
|
|
179
182
|
|
|
@@ -199,21 +202,6 @@ class SkinningNode extends Node {
|
|
|
199
202
|
|
|
200
203
|
}
|
|
201
204
|
|
|
202
|
-
/**
|
|
203
|
-
* Returns `true` if bone matrices from the previous frame are required. Relevant
|
|
204
|
-
* when computing motion vectors with {@link VelocityNode}.
|
|
205
|
-
*
|
|
206
|
-
* @param {NodeBuilder} builder - The current node builder.
|
|
207
|
-
* @return {boolean} Whether bone matrices from the previous frame are required or not.
|
|
208
|
-
*/
|
|
209
|
-
needsPreviousBoneMatrices( builder ) {
|
|
210
|
-
|
|
211
|
-
const mrt = builder.renderer.getMRT();
|
|
212
|
-
|
|
213
|
-
return ( mrt && mrt.has( 'velocity' ) ) || getDataFromObject( builder.object ).useVelocity === true;
|
|
214
|
-
|
|
215
|
-
}
|
|
216
|
-
|
|
217
205
|
/**
|
|
218
206
|
* Setups the skinning node by assigning the transformed vertex data to predefined node variables.
|
|
219
207
|
*
|
|
@@ -222,7 +210,7 @@ class SkinningNode extends Node {
|
|
|
222
210
|
*/
|
|
223
211
|
setup( builder ) {
|
|
224
212
|
|
|
225
|
-
if (
|
|
213
|
+
if ( builder.needsPreviousData() ) {
|
|
226
214
|
|
|
227
215
|
positionPrevious.assign( this.getPreviousSkinnedPosition( builder ) );
|
|
228
216
|
|
|
@@ -236,13 +224,13 @@ class SkinningNode extends Node {
|
|
|
236
224
|
|
|
237
225
|
if ( builder.hasGeometryAttribute( 'normal' ) ) {
|
|
238
226
|
|
|
239
|
-
const skinNormal = this.
|
|
227
|
+
const { skinNormal, skinTangent } = this.getSkinnedNormalAndTangent();
|
|
240
228
|
|
|
241
229
|
normalLocal.assign( skinNormal );
|
|
242
230
|
|
|
243
231
|
if ( builder.hasGeometryAttribute( 'tangent' ) ) {
|
|
244
232
|
|
|
245
|
-
tangentLocal.assign(
|
|
233
|
+
tangentLocal.assign( skinTangent );
|
|
246
234
|
|
|
247
235
|
}
|
|
248
236
|
|
|
@@ -4,7 +4,6 @@ import { varying } from '../tsl/TSLBase.js';
|
|
|
4
4
|
import { storageElement } from '../utils/StorageArrayElementNode.js';
|
|
5
5
|
import { NodeAccess } from '../core/constants.js';
|
|
6
6
|
import { getTypeFromLength } from '../core/NodeUtils.js';
|
|
7
|
-
import { warn } from '../../utils.js';
|
|
8
7
|
|
|
9
8
|
/**
|
|
10
9
|
* This node is used in context of compute shaders and allows to define a
|
|
@@ -398,21 +397,3 @@ export default StorageBufferNode;
|
|
|
398
397
|
* @returns {StorageBufferNode}
|
|
399
398
|
*/
|
|
400
399
|
export const storage = ( value, type = null, count = 0 ) => new StorageBufferNode( value, type, count );
|
|
401
|
-
|
|
402
|
-
/**
|
|
403
|
-
* @tsl
|
|
404
|
-
* @function
|
|
405
|
-
* @deprecated since r171. Use `storage().setPBO( true )` instead.
|
|
406
|
-
*
|
|
407
|
-
* @param {StorageBufferAttribute|StorageInstancedBufferAttribute|BufferAttribute} value - The buffer data.
|
|
408
|
-
* @param {?string} type - The buffer type (e.g. `'vec3'`).
|
|
409
|
-
* @param {number} count - The buffer count.
|
|
410
|
-
* @returns {StorageBufferNode}
|
|
411
|
-
*/
|
|
412
|
-
export const storageObject = ( value, type, count ) => { // @deprecated, r171
|
|
413
|
-
|
|
414
|
-
warn( 'TSL: "storageObject()" is deprecated. Use "storage().setPBO( true )" instead.' );
|
|
415
|
-
|
|
416
|
-
return storage( value, type, count ).setPBO( true );
|
|
417
|
-
|
|
418
|
-
};
|
|
@@ -162,6 +162,28 @@ class StorageTextureNode extends TextureNode {
|
|
|
162
162
|
|
|
163
163
|
}
|
|
164
164
|
|
|
165
|
+
/**
|
|
166
|
+
* Generates the snippet for the storage texture.
|
|
167
|
+
*
|
|
168
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
169
|
+
* @param {string} textureProperty - The texture property.
|
|
170
|
+
* @param {string} uvSnippet - The uv snippet.
|
|
171
|
+
* @param {?string} levelSnippet - The level snippet.
|
|
172
|
+
* @param {?string} biasSnippet - The bias snippet.
|
|
173
|
+
* @param {?string} depthSnippet - The depth snippet.
|
|
174
|
+
* @param {?string} compareSnippet - The compare snippet.
|
|
175
|
+
* @param {?Array<string>} gradSnippet - The grad snippet.
|
|
176
|
+
* @param {?string} offsetSnippet - The offset snippet.
|
|
177
|
+
* @return {string} The generated code snippet.
|
|
178
|
+
*/
|
|
179
|
+
generateSnippet( builder, textureProperty, uvSnippet, levelSnippet, biasSnippet, depthSnippet, compareSnippet, gradSnippet, offsetSnippet ) {
|
|
180
|
+
|
|
181
|
+
const texture = this.value;
|
|
182
|
+
|
|
183
|
+
return builder.generateStorageTextureLoad( texture, textureProperty, uvSnippet, levelSnippet, depthSnippet, offsetSnippet );
|
|
184
|
+
|
|
185
|
+
}
|
|
186
|
+
|
|
165
187
|
/**
|
|
166
188
|
* Convenience method for configuring a read/write node access.
|
|
167
189
|
*
|
|
@@ -222,6 +244,7 @@ class StorageTextureNode extends TextureNode {
|
|
|
222
244
|
const newNode = super.clone();
|
|
223
245
|
newNode.storeNode = this.storeNode;
|
|
224
246
|
newNode.mipLevel = this.mipLevel;
|
|
247
|
+
newNode.access = this.access;
|
|
225
248
|
return newNode;
|
|
226
249
|
|
|
227
250
|
}
|
|
@@ -255,7 +278,20 @@ export const storageTexture = /*@__PURE__*/ nodeProxy( StorageTextureNode ).setP
|
|
|
255
278
|
*/
|
|
256
279
|
export const textureStore = ( value, uvNode, storeNode ) => {
|
|
257
280
|
|
|
258
|
-
|
|
281
|
+
let node;
|
|
282
|
+
|
|
283
|
+
if ( value.isStorageTextureNode === true ) {
|
|
284
|
+
|
|
285
|
+
// Derive new storage texture node from existing one
|
|
286
|
+
node = value.clone();
|
|
287
|
+
node.uvNode = uvNode;
|
|
288
|
+
node.storeNode = storeNode;
|
|
289
|
+
|
|
290
|
+
} else {
|
|
291
|
+
|
|
292
|
+
node = storageTexture( value, uvNode, storeNode );
|
|
293
|
+
|
|
294
|
+
}
|
|
259
295
|
|
|
260
296
|
if ( storeNode !== null ) node.toStack();
|
|
261
297
|
|
|
@@ -27,11 +27,11 @@ export const tangentLocal = /*@__PURE__*/ tangentGeometry.xyz.toVar( 'tangentLoc
|
|
|
27
27
|
* @tsl
|
|
28
28
|
* @type {Node<vec3>}
|
|
29
29
|
*/
|
|
30
|
-
export const tangentView = /*@__PURE__*/ ( Fn( (
|
|
30
|
+
export const tangentView = /*@__PURE__*/ ( Fn( ( builder ) => {
|
|
31
31
|
|
|
32
32
|
let node;
|
|
33
33
|
|
|
34
|
-
if ( subBuildFn === 'VERTEX' || geometry.hasAttribute( 'tangent' ) ) {
|
|
34
|
+
if ( builder.subBuildFn === 'VERTEX' || builder.geometry.hasAttribute( 'tangent' ) ) {
|
|
35
35
|
|
|
36
36
|
node = modelViewMatrix.mul( vec4( tangentLocal, 0 ) ).xyz.toVarying( 'v_tangentView' ).normalize();
|
|
37
37
|
|
|
@@ -41,7 +41,7 @@ export const tangentView = /*@__PURE__*/ ( Fn( ( { subBuildFn, geometry, materia
|
|
|
41
41
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
if (
|
|
44
|
+
if ( builder.isFlatShading() !== true ) {
|
|
45
45
|
|
|
46
46
|
node = directionToFaceDirection( node );
|
|
47
47
|
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import TextureNode from './TextureNode.js';
|
|
2
|
-
import { nodeProxy, vec3, Fn, If
|
|
3
|
-
import { textureSize } from './TextureSizeNode.js';
|
|
2
|
+
import { nodeProxy, vec3, Fn, If } from '../tsl/TSLBase.js';
|
|
4
3
|
|
|
5
4
|
const normal = Fn( ( { texture, uv } ) => {
|
|
6
5
|
|
|
@@ -115,35 +114,6 @@ class Texture3DNode extends TextureNode {
|
|
|
115
114
|
*/
|
|
116
115
|
setUpdateMatrix( /*value*/ ) { } // Ignore .updateMatrix for 3d TextureNode
|
|
117
116
|
|
|
118
|
-
/**
|
|
119
|
-
* Overwrites the default implementation to return the unmodified uv node.
|
|
120
|
-
*
|
|
121
|
-
* @param {NodeBuilder} builder - The current node builder.
|
|
122
|
-
* @param {Node} uvNode - The uv node to setup.
|
|
123
|
-
* @return {Node} The unmodified uv node.
|
|
124
|
-
*/
|
|
125
|
-
setupUV( builder, uvNode ) {
|
|
126
|
-
|
|
127
|
-
const texture = this.value;
|
|
128
|
-
|
|
129
|
-
if ( builder.isFlipY() && ( texture.isRenderTargetTexture === true || texture.isFramebufferTexture === true ) ) {
|
|
130
|
-
|
|
131
|
-
if ( this.sampler ) {
|
|
132
|
-
|
|
133
|
-
uvNode = uvNode.flipY();
|
|
134
|
-
|
|
135
|
-
} else {
|
|
136
|
-
|
|
137
|
-
uvNode = uvNode.setY( int( textureSize( this, this.levelNode ).y ).sub( uvNode.y ).sub( 1 ) );
|
|
138
|
-
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
return uvNode;
|
|
144
|
-
|
|
145
|
-
}
|
|
146
|
-
|
|
147
117
|
/**
|
|
148
118
|
* Generates the uv code snippet.
|
|
149
119
|
*
|
|
@@ -171,10 +141,12 @@ class Texture3DNode extends TextureNode {
|
|
|
171
141
|
}
|
|
172
142
|
|
|
173
143
|
/**
|
|
174
|
-
*
|
|
144
|
+
* Computes the normal for the given uv. These texture coordiantes represent a
|
|
145
|
+
* position inside the 3D texture. Unlike geometric normals, this normal
|
|
146
|
+
* represents a slope or gradient of scalar data inside the 3D texture.
|
|
175
147
|
*
|
|
176
|
-
* @param {Node<vec3>} uvNode - The uv node .
|
|
177
|
-
* @return {Node<vec3>}
|
|
148
|
+
* @param {Node<vec3>} uvNode - The uv node that defines a position in the 3D texture.
|
|
149
|
+
* @return {Node<vec3>} The normal representing the slope/gradient in the data.
|
|
178
150
|
*/
|
|
179
151
|
normal( uvNode ) {
|
|
180
152
|
|