super-three 0.167.0 → 0.168.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.
Files changed (311) hide show
  1. package/build/three.cjs +165 -44
  2. package/build/three.module.js +165 -45
  3. package/build/three.module.min.js +1 -1
  4. package/build/three.webgpu.js +23600 -21931
  5. package/build/three.webgpu.min.js +1 -1
  6. package/examples/jsm/Addons.js +3 -1
  7. package/examples/jsm/animation/AnimationClipCreator.js +1 -1
  8. package/examples/jsm/capabilities/WebGL.js +27 -21
  9. package/examples/jsm/controls/ArcballControls.js +174 -158
  10. package/examples/jsm/controls/DragControls.js +260 -132
  11. package/examples/jsm/controls/FirstPersonControls.js +175 -163
  12. package/examples/jsm/controls/FlyControls.js +194 -188
  13. package/examples/jsm/controls/OrbitControls.js +777 -786
  14. package/examples/jsm/controls/PointerLockControls.js +24 -15
  15. package/examples/jsm/controls/TrackballControls.js +453 -452
  16. package/examples/jsm/effects/AnaglyphEffect.js +6 -13
  17. package/examples/jsm/effects/ParallaxBarrierEffect.js +17 -11
  18. package/examples/jsm/effects/StereoEffect.js +6 -1
  19. package/examples/jsm/environments/RoomEnvironment.js +1 -1
  20. package/examples/jsm/exporters/GLTFExporter.js +6 -1
  21. package/examples/jsm/exporters/USDZExporter.js +29 -8
  22. package/examples/jsm/helpers/LightProbeHelper.js +42 -43
  23. package/examples/jsm/loaders/KTX2Loader.js +19 -7
  24. package/examples/jsm/loaders/MaterialXLoader.js +11 -4
  25. package/examples/jsm/loaders/PCDLoader.js +9 -9
  26. package/examples/jsm/objects/SkyMesh.js +188 -0
  27. package/examples/jsm/objects/Water2Mesh.js +159 -0
  28. package/examples/jsm/objects/WaterMesh.js +102 -0
  29. package/examples/jsm/physics/RapierPhysics.js +20 -0
  30. package/examples/jsm/postprocessing/OutlinePass.js +31 -46
  31. package/examples/jsm/postprocessing/SSAARenderPass.js +3 -1
  32. package/examples/jsm/shaders/BleachBypassShader.js +1 -2
  33. package/examples/jsm/shaders/OutputShader.js +1 -1
  34. package/examples/jsm/transpiler/TSLEncoder.js +8 -8
  35. package/examples/jsm/utils/TextureUtils.js +1 -1
  36. package/package.json +2 -1
  37. package/src/Three.WebGPU.js +6 -0
  38. package/src/Three.js +1 -0
  39. package/src/constants.js +1 -1
  40. package/src/extras/Controls.js +32 -0
  41. package/src/loaders/ObjectLoader.js +3 -3
  42. package/src/{nodes/loaders → loaders/nodes}/NodeLoader.js +4 -4
  43. package/src/{nodes/loaders → loaders/nodes}/NodeMaterialLoader.js +1 -2
  44. package/src/materials/Material.js +4 -7
  45. package/src/{nodes/materials → materials/nodes}/InstancedPointsNodeMaterial.js +33 -24
  46. package/src/{nodes/materials → materials/nodes}/Line2NodeMaterial.js +34 -37
  47. package/src/{nodes/materials → materials/nodes}/LineBasicNodeMaterial.js +3 -4
  48. package/src/{nodes/materials → materials/nodes}/LineDashedNodeMaterial.js +7 -9
  49. package/src/{nodes/materials → materials/nodes}/MeshBasicNodeMaterial.js +11 -11
  50. package/src/{nodes/materials → materials/nodes}/MeshLambertNodeMaterial.js +5 -5
  51. package/src/{nodes/materials → materials/nodes}/MeshMatcapNodeMaterial.js +8 -8
  52. package/src/materials/nodes/MeshNormalNodeMaterial.js +40 -0
  53. package/src/{nodes/materials → materials/nodes}/MeshPhongNodeMaterial.js +9 -8
  54. package/src/{nodes/materials → materials/nodes}/MeshPhysicalNodeMaterial.js +18 -17
  55. package/src/{nodes/materials → materials/nodes}/MeshSSSNodeMaterial.js +6 -6
  56. package/src/{nodes/materials → materials/nodes}/MeshStandardNodeMaterial.js +17 -11
  57. package/src/{nodes/materials → materials/nodes}/MeshToonNodeMaterial.js +4 -4
  58. package/src/{nodes/materials → materials/nodes}/NodeMaterial.js +67 -86
  59. package/src/{nodes/materials/Materials.js → materials/nodes/NodeMaterials.js} +1 -1
  60. package/src/{nodes/materials → materials/nodes}/PointsNodeMaterial.js +3 -4
  61. package/src/{nodes/materials → materials/nodes}/ShadowNodeMaterial.js +4 -4
  62. package/src/{nodes/materials → materials/nodes}/SpriteNodeMaterial.js +11 -11
  63. package/src/{nodes/materials → materials/nodes}/VolumeNodeMaterial.js +14 -16
  64. package/src/nodes/Nodes.js +103 -159
  65. package/src/nodes/TSL.js +176 -0
  66. package/src/nodes/accessors/AccessorsUtils.js +8 -8
  67. package/src/nodes/accessors/BatchNode.js +48 -20
  68. package/src/nodes/accessors/{BitangentNode.js → Bitangent.js} +9 -9
  69. package/src/nodes/accessors/BufferAttributeNode.js +5 -5
  70. package/src/nodes/accessors/BufferNode.js +4 -4
  71. package/src/nodes/accessors/{CameraNode.js → Camera.js} +10 -10
  72. package/src/nodes/accessors/ClippingNode.js +16 -14
  73. package/src/nodes/accessors/CubeTextureNode.js +5 -7
  74. package/src/nodes/accessors/InstanceNode.js +17 -13
  75. package/src/nodes/accessors/InstancedPointsMaterialNode.js +4 -4
  76. package/src/nodes/accessors/MaterialNode.js +52 -55
  77. package/src/nodes/accessors/MaterialProperties.js +3 -0
  78. package/src/nodes/accessors/MaterialReferenceNode.js +6 -4
  79. package/src/nodes/accessors/ModelNode.js +11 -11
  80. package/src/nodes/accessors/ModelViewProjectionNode.js +6 -7
  81. package/src/nodes/accessors/MorphNode.js +12 -12
  82. package/src/nodes/accessors/Normal.js +62 -0
  83. package/src/nodes/accessors/Object3DNode.js +10 -10
  84. package/src/nodes/accessors/PointUVNode.js +4 -4
  85. package/src/nodes/accessors/Position.js +10 -0
  86. package/src/nodes/accessors/ReferenceBaseNode.js +143 -0
  87. package/src/nodes/accessors/ReferenceNode.js +13 -7
  88. package/src/nodes/accessors/ReflectVector.js +10 -0
  89. package/src/nodes/accessors/RendererReferenceNode.js +6 -6
  90. package/src/nodes/accessors/SceneNode.js +5 -6
  91. package/src/nodes/accessors/SkinningNode.js +84 -21
  92. package/src/nodes/accessors/StorageBufferNode.js +4 -5
  93. package/src/nodes/accessors/StorageTextureNode.js +5 -5
  94. package/src/nodes/accessors/Tangent.js +22 -0
  95. package/src/nodes/accessors/Texture3DNode.js +11 -11
  96. package/src/nodes/accessors/{TextureBicubicNode.js → TextureBicubic.js} +3 -32
  97. package/src/nodes/accessors/TextureNode.js +16 -21
  98. package/src/nodes/accessors/TextureSizeNode.js +4 -6
  99. package/src/nodes/accessors/{UniformsNode.js → UniformArrayNode.js} +17 -8
  100. package/src/nodes/accessors/UserDataNode.js +4 -4
  101. package/src/nodes/accessors/VelocityNode.js +83 -0
  102. package/src/nodes/accessors/VertexColorNode.js +4 -4
  103. package/src/nodes/code/CodeNode.js +5 -5
  104. package/src/nodes/code/ExpressionNode.js +4 -4
  105. package/src/nodes/code/FunctionCallNode.js +5 -5
  106. package/src/nodes/code/FunctionNode.js +5 -23
  107. package/src/nodes/code/ScriptableNode.js +4 -6
  108. package/src/nodes/code/ScriptableValueNode.js +4 -6
  109. package/src/nodes/core/AssignNode.js +5 -5
  110. package/src/nodes/core/AttributeNode.js +7 -20
  111. package/src/nodes/core/BypassNode.js +5 -5
  112. package/src/nodes/core/CacheNode.js +5 -5
  113. package/src/nodes/core/ConstNode.js +2 -2
  114. package/src/nodes/core/ContextNode.js +17 -11
  115. package/src/nodes/core/IndexNode.js +12 -7
  116. package/src/nodes/core/InputNode.js +2 -2
  117. package/src/nodes/core/MRTNode.js +12 -6
  118. package/src/nodes/core/Node.js +39 -19
  119. package/src/nodes/core/NodeBuilder.js +46 -33
  120. package/src/nodes/core/NodeUtils.js +1 -0
  121. package/src/nodes/core/OutputStructNode.js +4 -4
  122. package/src/nodes/core/ParameterNode.js +4 -4
  123. package/src/nodes/core/PropertyNode.js +32 -32
  124. package/src/nodes/core/StackNode.js +26 -10
  125. package/src/nodes/core/StructTypeNode.js +2 -2
  126. package/src/nodes/core/TempNode.js +2 -2
  127. package/src/nodes/core/UniformGroupNode.js +8 -9
  128. package/src/nodes/core/UniformNode.js +4 -4
  129. package/src/nodes/core/VarNode.js +6 -6
  130. package/src/nodes/core/VaryingNode.js +5 -5
  131. package/src/nodes/display/AfterImageNode.js +9 -9
  132. package/src/nodes/display/AnaglyphPassNode.js +61 -0
  133. package/src/nodes/display/AnamorphicNode.js +11 -11
  134. package/src/nodes/display/BleachBypass.js +26 -0
  135. package/src/nodes/display/BlendMode.js +54 -0
  136. package/src/nodes/display/BloomNode.js +21 -19
  137. package/src/nodes/display/BumpMapNode.js +7 -12
  138. package/src/nodes/display/ColorAdjustment.js +46 -0
  139. package/src/nodes/display/ColorSpaceFunctions.js +38 -0
  140. package/src/nodes/display/ColorSpaceNode.js +40 -63
  141. package/src/nodes/display/DenoiseNode.js +20 -17
  142. package/src/nodes/display/DepthOfFieldNode.js +8 -6
  143. package/src/nodes/display/DotScreenNode.js +10 -22
  144. package/src/nodes/display/FXAANode.js +17 -15
  145. package/src/nodes/display/FilmNode.js +7 -6
  146. package/src/nodes/display/FrontFacingNode.js +5 -5
  147. package/src/nodes/display/GTAONode.js +19 -15
  148. package/src/nodes/display/GaussianBlurNode.js +11 -8
  149. package/src/nodes/display/Lut3DNode.js +6 -5
  150. package/src/nodes/display/MotionBlur.js +25 -0
  151. package/src/nodes/display/NormalMapNode.js +8 -10
  152. package/src/nodes/display/ParallaxBarrierPassNode.js +55 -0
  153. package/src/nodes/display/PassNode.js +84 -8
  154. package/src/nodes/display/PixelationPassNode.js +12 -7
  155. package/src/nodes/display/PosterizeNode.js +4 -6
  156. package/src/nodes/display/RGBShiftNode.js +8 -7
  157. package/src/nodes/display/RenderOutputNode.js +9 -9
  158. package/src/nodes/display/SSAAPassNode.js +284 -0
  159. package/src/nodes/display/Sepia.js +17 -0
  160. package/src/nodes/display/SobelOperatorNode.js +9 -7
  161. package/src/nodes/display/StereoCompositePassNode.js +107 -0
  162. package/src/nodes/display/StereoPassNode.js +80 -0
  163. package/src/nodes/display/ToneMappingFunctions.js +190 -0
  164. package/src/nodes/display/ToneMappingNode.js +12 -173
  165. package/src/nodes/display/TransitionNode.js +9 -8
  166. package/src/nodes/display/ViewportDepthNode.js +30 -29
  167. package/src/nodes/display/ViewportDepthTextureNode.js +6 -8
  168. package/src/nodes/display/ViewportNode.js +26 -25
  169. package/src/nodes/display/ViewportSharedTextureNode.js +6 -8
  170. package/src/nodes/display/ViewportTextureNode.js +7 -10
  171. package/src/nodes/fog/FogExp2Node.js +4 -6
  172. package/src/nodes/fog/FogNode.js +5 -7
  173. package/src/nodes/fog/FogRangeNode.js +4 -6
  174. package/src/nodes/functions/BSDF/BRDF_GGX.js +4 -4
  175. package/src/nodes/functions/BSDF/BRDF_Lambert.js +2 -2
  176. package/src/nodes/functions/BSDF/BRDF_Sheen.js +6 -6
  177. package/src/nodes/functions/BSDF/DFGApprox.js +2 -2
  178. package/src/nodes/functions/BSDF/D_GGX.js +2 -2
  179. package/src/nodes/functions/BSDF/D_GGX_Anisotropic.js +3 -3
  180. package/src/nodes/functions/BSDF/EnvironmentBRDF.js +2 -2
  181. package/src/nodes/functions/BSDF/F_Schlick.js +2 -2
  182. package/src/nodes/functions/BSDF/LTC.js +6 -6
  183. package/src/nodes/functions/BSDF/Schlick_to_F0.js +2 -2
  184. package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated.js +2 -2
  185. package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +2 -2
  186. package/src/nodes/functions/BasicLightingModel.js +1 -1
  187. package/src/nodes/functions/PhongLightingModel.js +5 -5
  188. package/src/nodes/functions/PhysicalLightingModel.js +32 -31
  189. package/src/nodes/functions/ShadowMaskModel.js +1 -1
  190. package/src/nodes/functions/ToonLightingModel.js +3 -3
  191. package/src/nodes/functions/material/getGeometryRoughness.js +4 -4
  192. package/src/nodes/functions/material/getRoughness.js +2 -2
  193. package/src/nodes/geometry/RangeNode.js +4 -4
  194. package/src/nodes/gpgpu/ComputeNode.js +5 -5
  195. package/src/nodes/lighting/AONode.js +2 -2
  196. package/src/nodes/lighting/AmbientLightNode.js +2 -7
  197. package/src/nodes/lighting/AnalyticLightNode.js +34 -13
  198. package/src/nodes/lighting/BasicEnvironmentNode.js +4 -3
  199. package/src/nodes/lighting/BasicLightMapNode.js +3 -3
  200. package/src/nodes/lighting/DirectionalLightNode.js +2 -7
  201. package/src/nodes/lighting/EnvironmentNode.js +20 -19
  202. package/src/nodes/lighting/HemisphereLightNode.js +3 -7
  203. package/src/nodes/lighting/IESSpotLightNode.js +3 -8
  204. package/src/nodes/lighting/IrradianceNode.js +2 -2
  205. package/src/nodes/lighting/LightNode.js +5 -5
  206. package/src/nodes/lighting/LightProbeNode.js +76 -0
  207. package/src/nodes/lighting/LightUtils.js +3 -3
  208. package/src/nodes/lighting/LightingContextNode.js +15 -17
  209. package/src/nodes/lighting/LightingNode.js +2 -2
  210. package/src/nodes/lighting/LightsNode.js +94 -76
  211. package/src/nodes/lighting/PointLightNode.js +3 -8
  212. package/src/nodes/lighting/RectAreaLightNode.js +2 -6
  213. package/src/nodes/lighting/SpotLightNode.js +3 -8
  214. package/src/nodes/materialx/MaterialXNodes.js +2 -2
  215. package/src/nodes/materialx/lib/mx_hsv.js +36 -31
  216. package/src/nodes/materialx/lib/mx_noise.js +96 -96
  217. package/src/nodes/materialx/lib/mx_transform_color.js +2 -2
  218. package/src/nodes/math/{CondNode.js → ConditionalNode.js} +18 -7
  219. package/src/nodes/math/Hash.js +13 -0
  220. package/src/nodes/math/MathNode.js +124 -124
  221. package/src/nodes/math/MathUtils.js +0 -7
  222. package/src/nodes/math/OperatorNode.js +94 -52
  223. package/src/nodes/math/TriNoise3D.js +19 -29
  224. package/src/nodes/pmrem/PMREMNode.js +58 -15
  225. package/src/nodes/pmrem/PMREMUtils.js +46 -46
  226. package/src/nodes/procedural/Checker.js +14 -0
  227. package/src/nodes/tsl/TSLBase.js +30 -0
  228. package/src/nodes/{shadernode/ShaderNode.js → tsl/TSLCore.js} +105 -97
  229. package/src/nodes/utils/ArrayElementNode.js +2 -2
  230. package/src/nodes/utils/ConvertNode.js +2 -2
  231. package/src/nodes/utils/CubeMapNode.js +157 -0
  232. package/src/nodes/utils/Discard.js +8 -0
  233. package/src/nodes/utils/EquirectUVNode.js +5 -5
  234. package/src/nodes/utils/FlipNode.js +65 -0
  235. package/src/nodes/utils/FunctionOverloadingNode.js +5 -5
  236. package/src/nodes/utils/JoinNode.js +2 -2
  237. package/src/nodes/utils/LoopNode.js +12 -6
  238. package/src/nodes/utils/MatcapUVNode.js +6 -6
  239. package/src/nodes/utils/MaxMipLevelNode.js +4 -4
  240. package/src/nodes/utils/OscNode.js +7 -7
  241. package/src/nodes/utils/Packing.js +4 -0
  242. package/src/nodes/utils/RTTNode.js +8 -8
  243. package/src/nodes/utils/ReflectorNode.js +8 -3
  244. package/src/nodes/utils/RemapNode.js +7 -7
  245. package/src/nodes/utils/RotateNode.js +4 -12
  246. package/src/nodes/utils/SetNode.js +2 -2
  247. package/src/nodes/utils/SplitNode.js +2 -2
  248. package/src/nodes/utils/SpriteSheetUVNode.js +5 -5
  249. package/src/nodes/utils/SpriteUtils.js +47 -0
  250. package/src/nodes/utils/StorageArrayElementNode.js +4 -6
  251. package/src/nodes/utils/TimerNode.js +5 -5
  252. package/src/nodes/utils/TriplanarTexturesNode.js +7 -9
  253. package/src/nodes/utils/UVUtils.js +19 -0
  254. package/src/nodes/utils/ViewportUtils.js +14 -0
  255. package/src/objects/BatchedMesh.js +2 -3
  256. package/src/renderers/WebGLRenderer.js +24 -0
  257. package/src/renderers/common/Backend.js +2 -2
  258. package/src/renderers/common/Background.js +3 -1
  259. package/src/renderers/common/BindGroup.js +3 -1
  260. package/src/renderers/common/Bindings.js +13 -15
  261. package/src/renderers/common/ClippingContext.js +14 -5
  262. package/src/renderers/common/CubeRenderTarget.js +9 -3
  263. package/src/renderers/common/PostProcessing.js +4 -1
  264. package/src/renderers/common/QuadMesh.js +2 -0
  265. package/src/renderers/common/RenderContext.js +24 -0
  266. package/src/renderers/common/RenderList.js +1 -1
  267. package/src/renderers/common/RenderObject.js +2 -2
  268. package/src/renderers/common/Renderer.js +75 -49
  269. package/src/renderers/common/SampledTexture.js +12 -3
  270. package/src/renderers/common/StandardRenderer.js +18 -0
  271. package/src/renderers/common/Textures.js +8 -12
  272. package/src/renderers/common/extras/PMREMGenerator.js +12 -13
  273. package/src/renderers/common/nodes/NodeBuilderState.js +1 -1
  274. package/src/renderers/common/nodes/NodeLibrary.js +118 -0
  275. package/src/renderers/common/nodes/NodeSampledTexture.js +2 -2
  276. package/src/renderers/common/nodes/Nodes.js +36 -9
  277. package/src/renderers/common/nodes/StandardNodeLibrary.js +105 -0
  278. package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +2 -2
  279. package/src/renderers/webgl/WebGLProgram.js +1 -1
  280. package/src/renderers/webgl/WebGLProperties.js +7 -0
  281. package/src/renderers/webgl/WebGLTextures.js +61 -4
  282. package/src/renderers/webgl-fallback/WebGLBackend.js +88 -68
  283. package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +57 -9
  284. package/src/renderers/webgl-fallback/utils/WebGLState.js +21 -0
  285. package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +28 -21
  286. package/src/renderers/webgpu/WebGPUBackend.js +86 -68
  287. package/src/renderers/webgpu/WebGPURenderer.js +8 -8
  288. package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +99 -63
  289. package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +45 -21
  290. package/src/renderers/webgpu/utils/WebGPUConstants.js +2 -1
  291. package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +6 -15
  292. package/src/renderers/webgpu/utils/WebGPUTexturePassUtils.js +62 -5
  293. package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +36 -21
  294. package/src/renderers/webgpu/utils/WebGPUUtils.js +18 -1
  295. package/src/renderers/webxr/WebXRManager.js +32 -25
  296. package/examples/jsm/loaders/LogLuvLoader.js +0 -606
  297. package/src/nodes/accessors/NormalNode.js +0 -14
  298. package/src/nodes/accessors/PositionNode.js +0 -10
  299. package/src/nodes/accessors/ReflectVectorNode.js +0 -10
  300. package/src/nodes/accessors/TangentNode.js +0 -23
  301. package/src/nodes/core/NodeKeywords.js +0 -80
  302. package/src/nodes/display/BlendModeNode.js +0 -128
  303. package/src/nodes/display/ColorAdjustmentNode.js +0 -104
  304. package/src/nodes/materials/MeshNormalNodeMaterial.js +0 -40
  305. package/src/nodes/math/HashNode.js +0 -34
  306. package/src/nodes/procedural/CheckerNode.js +0 -42
  307. package/src/nodes/utils/DiscardNode.js +0 -28
  308. package/src/nodes/utils/PackingNode.js +0 -55
  309. package/src/nodes/utils/RotateUVNode.js +0 -35
  310. /package/src/{nodes/loaders → loaders/nodes}/NodeObjectLoader.js +0 -0
  311. /package/src/nodes/accessors/{UVNode.js → UV.js} +0 -0
@@ -0,0 +1,38 @@
1
+ import { mix } from '../math/MathNode.js';
2
+ import { Fn } from '../tsl/TSLBase.js';
3
+
4
+ export const sRGBToLinear = /*@__PURE__*/ Fn( ( [ color ] ) => {
5
+
6
+ const a = color.mul( 0.9478672986 ).add( 0.0521327014 ).pow( 2.4 );
7
+ const b = color.mul( 0.0773993808 );
8
+ const factor = color.lessThanEqual( 0.04045 );
9
+
10
+ const rgbResult = mix( a, b, factor );
11
+
12
+ return rgbResult;
13
+
14
+ } ).setLayout( {
15
+ name: 'sRGBToLinear',
16
+ type: 'vec3',
17
+ inputs: [
18
+ { name: 'color', type: 'vec3' }
19
+ ]
20
+ } );
21
+
22
+ export const LinearTosRGB = /*@__PURE__*/ Fn( ( [ color ] ) => {
23
+
24
+ const a = color.pow( 0.41666 ).mul( 1.055 ).sub( 0.055 );
25
+ const b = color.mul( 12.92 );
26
+ const factor = color.lessThanEqual( 0.0031308 );
27
+
28
+ const rgbResult = mix( a, b, factor );
29
+
30
+ return rgbResult;
31
+
32
+ } ).setLayout( {
33
+ name: 'LinearTosRGB',
34
+ type: 'vec3',
35
+ inputs: [
36
+ { name: 'color', type: 'vec3' }
37
+ ]
38
+ } );
@@ -1,41 +1,10 @@
1
+ import { registerNode } from '../core/Node.js';
1
2
  import TempNode from '../core/TempNode.js';
2
- import { mix } from '../math/MathNode.js';
3
- import { addNodeClass } from '../core/Node.js';
4
- import { addNodeElement, tslFn, nodeObject, nodeProxy, vec4 } from '../shadernode/ShaderNode.js';
3
+ import { addMethodChaining, nodeObject, vec4 } from '../tsl/TSLCore.js';
5
4
 
6
5
  import { LinearSRGBColorSpace, SRGBColorSpace } from '../../constants.js';
7
6
 
8
- const sRGBToLinearShader = tslFn( ( inputs ) => {
9
-
10
- const { value } = inputs;
11
- const { rgb } = value;
12
-
13
- const a = rgb.mul( 0.9478672986 ).add( 0.0521327014 ).pow( 2.4 );
14
- const b = rgb.mul( 0.0773993808 );
15
- const factor = rgb.lessThanEqual( 0.04045 );
16
-
17
- const rgbResult = mix( a, b, factor );
18
-
19
- return vec4( rgbResult, value.a );
20
-
21
- } );
22
-
23
- const LinearTosRGBShader = tslFn( ( inputs ) => {
24
-
25
- const { value } = inputs;
26
- const { rgb } = value;
27
-
28
- const a = rgb.pow( 0.41666 ).mul( 1.055 ).sub( 0.055 );
29
- const b = rgb.mul( 12.92 );
30
- const factor = rgb.lessThanEqual( 0.0031308 );
31
-
32
- const rgbResult = mix( a, b, factor );
33
-
34
- return vec4( rgbResult, value.a );
35
-
36
- } );
37
-
38
- const getColorSpaceMethod = ( colorSpace ) => {
7
+ const getColorSpaceName = ( colorSpace ) => {
39
8
 
40
9
  let method = null;
41
10
 
@@ -53,56 +22,64 @@ const getColorSpaceMethod = ( colorSpace ) => {
53
22
 
54
23
  };
55
24
 
56
- const getMethod = ( source, target ) => {
25
+ export const getColorSpaceMethod = ( source, target ) => {
57
26
 
58
- return getColorSpaceMethod( source ) + 'To' + getColorSpaceMethod( target );
27
+ return getColorSpaceName( source ) + 'To' + getColorSpaceName( target );
59
28
 
60
29
  };
61
30
 
62
31
  class ColorSpaceNode extends TempNode {
63
32
 
64
- constructor( method, node ) {
33
+ constructor( colorNode, target = null, source = null ) {
65
34
 
66
35
  super( 'vec4' );
67
36
 
68
- this.method = method;
69
- this.node = node;
37
+ this.colorNode = colorNode;
38
+ this.target = target;
39
+ this.source = source;
70
40
 
71
41
  }
72
42
 
73
- setup() {
43
+ setup( builder ) {
74
44
 
75
- const { method, node } = this;
45
+ const { renderer, context } = builder;
76
46
 
77
- if ( method === ColorSpaceNode.LINEAR_TO_LINEAR )
78
- return node;
47
+ const source = this.source || context.outputColorSpace || renderer.outputColorSpace;
48
+ const target = this.target || context.outputColorSpace || renderer.outputColorSpace;
49
+ const colorNode = this.colorNode;
79
50
 
80
- return Methods[ method ]( { value: node } );
51
+ if ( source === target ) return colorNode;
81
52
 
82
- }
53
+ const colorSpace = getColorSpaceMethod( source, target );
83
54
 
84
- }
55
+ let outputNode = null;
85
56
 
86
- ColorSpaceNode.LINEAR_TO_LINEAR = 'LinearToLinear';
87
- ColorSpaceNode.LINEAR_TO_sRGB = 'LinearTosRGB';
88
- ColorSpaceNode.sRGB_TO_LINEAR = 'sRGBToLinear';
57
+ const colorSpaceFn = renderer.nodes.library.getColorSpaceFunction( colorSpace );
89
58
 
90
- const Methods = {
91
- [ ColorSpaceNode.LINEAR_TO_sRGB ]: LinearTosRGBShader,
92
- [ ColorSpaceNode.sRGB_TO_LINEAR ]: sRGBToLinearShader
93
- };
59
+ if ( colorSpaceFn !== null ) {
94
60
 
95
- export default ColorSpaceNode;
61
+ outputNode = vec4( colorSpaceFn( colorNode.rgb ), colorNode.a );
62
+
63
+ } else {
64
+
65
+ console.error( 'ColorSpaceNode: Unsupported Color Space configuration.', colorSpace );
66
+
67
+ outputNode = colorNode;
68
+
69
+ }
96
70
 
97
- export const linearToColorSpace = ( node, colorSpace ) => nodeObject( new ColorSpaceNode( getMethod( LinearSRGBColorSpace, colorSpace ), nodeObject( node ) ) );
98
- export const colorSpaceToLinear = ( node, colorSpace ) => nodeObject( new ColorSpaceNode( getMethod( colorSpace, LinearSRGBColorSpace ), nodeObject( node ) ) );
71
+ return outputNode;
72
+
73
+ }
74
+
75
+ }
76
+
77
+ export default ColorSpaceNode;
99
78
 
100
- export const linearTosRGB = nodeProxy( ColorSpaceNode, ColorSpaceNode.LINEAR_TO_sRGB );
101
- export const sRGBToLinear = nodeProxy( ColorSpaceNode, ColorSpaceNode.sRGB_TO_LINEAR );
79
+ ColorSpaceNode.type = /*@__PURE__*/ registerNode( 'ColorSpace', ColorSpaceNode );
102
80
 
103
- addNodeElement( 'linearTosRGB', linearTosRGB );
104
- addNodeElement( 'sRGBToLinear', sRGBToLinear );
105
- addNodeElement( 'linearToColorSpace', linearToColorSpace );
106
- addNodeElement( 'colorSpaceToLinear', colorSpaceToLinear );
81
+ export const toOutputColorSpace = ( node, colorSpace = null ) => nodeObject( new ColorSpaceNode( nodeObject( node ), colorSpace, LinearSRGBColorSpace ) );
82
+ export const toWorkingColorSpace = ( node, colorSpace = null ) => nodeObject( new ColorSpaceNode( nodeObject( node ), LinearSRGBColorSpace, colorSpace ) );
107
83
 
108
- addNodeClass( 'ColorSpaceNode', ColorSpaceNode );
84
+ addMethodChaining( 'toOutputColorSpace', toOutputColorSpace );
85
+ addMethodChaining( 'toWorkingColorSpace', toWorkingColorSpace );
@@ -1,13 +1,16 @@
1
+ import { registerNode } from '../core/Node.js';
1
2
  import TempNode from '../core/TempNode.js';
2
- import { uv } from '../accessors/UVNode.js';
3
- import { addNodeElement, tslFn, nodeObject, float, int, vec2, vec3, vec4, mat2, If } from '../shadernode/ShaderNode.js';
3
+ import { uv } from '../accessors/UV.js';
4
+ import { Fn, nodeObject, float, int, vec2, vec3, vec4, mat2, If } from '../tsl/TSLBase.js';
4
5
  import { NodeUpdateType } from '../core/constants.js';
5
6
  import { uniform } from '../core/UniformNode.js';
6
- import { uniforms } from '../accessors/UniformsNode.js';
7
+ import { uniformArray } from '../accessors/UniformArrayNode.js';
7
8
  import { abs, dot, sin, cos, PI, pow, max } from '../math/MathNode.js';
8
- import { loop } from '../utils/LoopNode.js';
9
- import { luminance } from './ColorAdjustmentNode.js';
9
+ import { Loop } from '../utils/LoopNode.js';
10
+ import { luminance } from './ColorAdjustment.js';
10
11
  import { textureSize } from '../accessors/TextureSizeNode.js';
12
+ import { convertToTexture } from '../utils/RTTNode.js';
13
+
11
14
  import { Vector2 } from '../../math/Vector2.js';
12
15
  import { Vector3 } from '../../math/Vector3.js';
13
16
 
@@ -30,7 +33,7 @@ class DenoiseNode extends TempNode {
30
33
  this.index = uniform( 0 );
31
34
 
32
35
  this._resolution = uniform( new Vector2() );
33
- this._sampleVectors = uniforms( generatePdSamplePointInitializer( 16, 2, 1 ) );
36
+ this._sampleVectors = uniformArray( generatePdSamplePointInitializer( 16, 2, 1 ) );
34
37
 
35
38
  this.updateBeforeType = NodeUpdateType.RENDER;
36
39
 
@@ -53,7 +56,7 @@ class DenoiseNode extends TempNode {
53
56
  const sampleNormal = ( uv ) => this.normalNode.uv( uv );
54
57
  const sampleNoise = ( uv ) => this.noiseNode.uv( uv );
55
58
 
56
- const getViewPosition = tslFn( ( [ screenPosition, depth ] ) => {
59
+ const getViewPosition = Fn( ( [ screenPosition, depth ] ) => {
57
60
 
58
61
  screenPosition = vec2( screenPosition.x, screenPosition.y.oneMinus() ).mul( 2.0 ).sub( 1.0 );
59
62
 
@@ -64,7 +67,7 @@ class DenoiseNode extends TempNode {
64
67
 
65
68
  } );
66
69
 
67
- const denoiseSample = tslFn( ( [ center, viewNormal, viewPosition, sampleUv ] ) => {
70
+ const denoiseSample = Fn( ( [ center, viewNormal, viewPosition, sampleUv ] ) => {
68
71
 
69
72
  const texel = sampleTexture( sampleUv );
70
73
  const depth = sampleDepth( sampleUv );
@@ -84,7 +87,7 @@ class DenoiseNode extends TempNode {
84
87
 
85
88
  } );
86
89
 
87
- const denoise = tslFn( ( [ uvNode ] ) => {
90
+ const denoise = Fn( ( [ uvNode ] ) => {
88
91
 
89
92
  const depth = sampleDepth( uvNode );
90
93
  const viewNormal = sampleNormal( uvNode ).rgb.normalize();
@@ -115,7 +118,7 @@ class DenoiseNode extends TempNode {
115
118
  const totalWeight = float( 1.0 ).toVar();
116
119
  const denoised = vec3( texel.rgb ).toVar();
117
120
 
118
- loop( { start: int( 0 ), end: int( 16 ), type: 'int', condition: '<' }, ( { i } ) => {
121
+ Loop( { start: int( 0 ), end: int( 16 ), type: 'int', condition: '<' }, ( { i } ) => {
119
122
 
120
123
  const sampleDir = this._sampleVectors.element( i ).toVar();
121
124
  const offset = rotationMatrix.mul( sampleDir.xy.mul( float( 1.0 ).add( sampleDir.z.mul( this.radius.sub( 1 ) ) ) ) ).div( this._resolution ).toVar();
@@ -126,7 +129,7 @@ class DenoiseNode extends TempNode {
126
129
  denoised.addAssign( result.xyz );
127
130
  totalWeight.addAssign( result.w );
128
131
 
129
- } );
132
+ } );
130
133
 
131
134
  If( totalWeight.greaterThan( float( 0 ) ), () => {
132
135
 
@@ -144,7 +147,7 @@ class DenoiseNode extends TempNode {
144
147
  ]
145
148
  } );
146
149
 
147
- const output = tslFn( () => {
150
+ const output = Fn( () => {
148
151
 
149
152
  return denoise( uvNode );
150
153
 
@@ -158,6 +161,10 @@ class DenoiseNode extends TempNode {
158
161
 
159
162
  }
160
163
 
164
+ export default DenoiseNode;
165
+
166
+ DenoiseNode.type = /*@__PURE__*/ registerNode( 'Denoise', DenoiseNode );
167
+
161
168
  function generatePdSamplePointInitializer( samples, rings, radiusExponent ) {
162
169
 
163
170
  const poissonDisk = generateDenoiseSamples( samples, rings, radiusExponent );
@@ -191,8 +198,4 @@ function generateDenoiseSamples( numSamples, numRings, radiusExponent ) {
191
198
 
192
199
  }
193
200
 
194
- export const denoise = ( node, depthNode, normalNode, noiseNode, camera ) => nodeObject( new DenoiseNode( nodeObject( node ).toTexture(), nodeObject( depthNode ), nodeObject( normalNode ), nodeObject( noiseNode ), camera ) );
195
-
196
- addNodeElement( 'denoise', denoise );
197
-
198
- export default DenoiseNode;
201
+ export const denoise = ( node, depthNode, normalNode, noiseNode, camera ) => nodeObject( new DenoiseNode( convertToTexture( node ), nodeObject( depthNode ), nodeObject( normalNode ), nodeObject( noiseNode ), camera ) );
@@ -1,9 +1,11 @@
1
+ import { registerNode } from '../core/Node.js';
1
2
  import TempNode from '../core/TempNode.js';
2
- import { uv } from '../accessors/UVNode.js';
3
- import { addNodeElement, tslFn, nodeObject, vec2, vec4 } from '../shadernode/ShaderNode.js';
3
+ import { uv } from '../accessors/UV.js';
4
+ import { Fn, nodeObject, vec2, vec4 } from '../tsl/TSLBase.js';
4
5
  import { NodeUpdateType } from '../core/constants.js';
5
6
  import { uniform } from '../core/UniformNode.js';
6
7
  import { clamp } from '../math/MathNode.js';
8
+ import { convertToTexture } from '../utils/RTTNode.js';
7
9
 
8
10
  class DepthOfFieldNode extends TempNode {
9
11
 
@@ -39,7 +41,7 @@ class DepthOfFieldNode extends TempNode {
39
41
 
40
42
  const sampleTexture = ( uv ) => textureNode.uv( uv );
41
43
 
42
- const dof = tslFn( () => {
44
+ const dof = Fn( () => {
43
45
 
44
46
  const aspectcorrect = vec2( 1.0, this._aspect );
45
47
 
@@ -112,8 +114,8 @@ class DepthOfFieldNode extends TempNode {
112
114
 
113
115
  }
114
116
 
115
- export const dof = ( node, viewZNode, focus = 1, aperture = 0.025, maxblur = 1 ) => nodeObject( new DepthOfFieldNode( nodeObject( node ).toTexture(), nodeObject( viewZNode ), nodeObject( focus ), nodeObject( aperture ), nodeObject( maxblur ) ) );
117
+ export default DepthOfFieldNode;
116
118
 
117
- addNodeElement( 'dof', dof );
119
+ DepthOfFieldNode.type = /*@__PURE__*/ registerNode( 'DepthOfField', DepthOfFieldNode );
118
120
 
119
- export default DepthOfFieldNode;
121
+ export const dof = ( node, viewZNode, focus = 1, aperture = 0.025, maxblur = 1 ) => nodeObject( new DepthOfFieldNode( convertToTexture( node ), nodeObject( viewZNode ), nodeObject( focus ), nodeObject( aperture ), nodeObject( maxblur ) ) );
@@ -1,10 +1,11 @@
1
+ import { registerNode } from '../core/Node.js';
1
2
  import TempNode from '../core/TempNode.js';
2
- import { nodeObject, addNodeElement, tslFn, vec2, vec3, vec4 } from '../shadernode/ShaderNode.js';
3
+ import { nodeObject, Fn, vec2, vec3, vec4 } from '../tsl/TSLBase.js';
3
4
  import { uniform } from '../core/UniformNode.js';
4
- import { NodeUpdateType } from '../core/constants.js';
5
- import { uv } from '../accessors/UVNode.js';
5
+ import { uv } from '../accessors/UV.js';
6
6
  import { sin, cos } from '../math/MathNode.js';
7
7
  import { add } from '../math/OperatorNode.js';
8
+ import { viewportResolution } from '../display/ViewportNode.js';
8
9
 
9
10
  import { Vector2 } from '../../math/Vector2.js';
10
11
 
@@ -19,37 +20,25 @@ class DotScreenNode extends TempNode {
19
20
  this.angle = uniform( angle );
20
21
  this.scale = uniform( scale );
21
22
 
22
- this._size = uniform( new Vector2() );
23
-
24
- this.updateBeforeType = NodeUpdateType.RENDER;
25
-
26
- }
27
-
28
- updateBefore( frame ) {
29
-
30
- const { renderer } = frame;
31
-
32
- renderer.getDrawingBufferSize( this._size.value );
33
-
34
23
  }
35
24
 
36
25
  setup() {
37
26
 
38
27
  const inputNode = this.inputNode;
39
28
 
40
- const pattern = tslFn( () => {
29
+ const pattern = Fn( () => {
41
30
 
42
31
  const s = sin( this.angle );
43
32
  const c = cos( this.angle );
44
33
 
45
- const tex = uv().mul( this._size ).sub( this.center );
34
+ const tex = uv().mul( viewportResolution ).sub( this.center );
46
35
  const point = vec2( c.mul( tex.x ).sub( s.mul( tex.y ) ), s.mul( tex.x ).add( c.mul( tex.y ) ) ).mul( this.scale );
47
36
 
48
37
  return sin( point.x ).mul( sin( point.y ) ).mul( 4 );
49
38
 
50
39
  } );
51
40
 
52
- const dotScreen = tslFn( () => {
41
+ const dotScreen = Fn( () => {
53
42
 
54
43
  const color = inputNode;
55
44
 
@@ -67,9 +56,8 @@ class DotScreenNode extends TempNode {
67
56
 
68
57
  }
69
58
 
70
- export const dotScreen = ( node, center, angle, scale ) => nodeObject( new DotScreenNode( nodeObject( node ), center, angle, scale ) );
71
-
72
- addNodeElement( 'dotScreen', dotScreen );
73
-
74
59
  export default DotScreenNode;
75
60
 
61
+ DotScreenNode.type = /*@__PURE__*/ registerNode( 'DotScreen', DotScreenNode );
62
+
63
+ export const dotScreen = ( node, center, angle, scale ) => nodeObject( new DotScreenNode( nodeObject( node ), center, angle, scale ) );
@@ -1,11 +1,13 @@
1
+ import { registerNode } from '../core/Node.js';
1
2
  import TempNode from '../core/TempNode.js';
2
- import { uv } from '../accessors/UVNode.js';
3
- import { addNodeElement, tslFn, nodeObject, float, vec2, vec4, int, If } from '../shadernode/ShaderNode.js';
3
+ import { uv } from '../accessors/UV.js';
4
+ import { Fn, nodeObject, float, vec2, vec4, int, If } from '../tsl/TSLBase.js';
4
5
  import { NodeUpdateType } from '../core/constants.js';
5
6
  import { uniform } from '../core/UniformNode.js';
6
7
  import { abs, max, min, mix, pow } from '../math/MathNode.js';
7
8
  import { sub } from '../math/OperatorNode.js';
8
- import { loop, Break } from '../utils/LoopNode.js';
9
+ import { Loop, Break } from '../utils/LoopNode.js';
10
+ import { convertToTexture } from '../utils/RTTNode.js';
9
11
 
10
12
  import { Vector2 } from '../../math/Vector2.js';
11
13
 
@@ -77,7 +79,7 @@ class FXAANode extends TempNode {
77
79
 
78
80
  const NUM_SAMPLES = int( 5 );
79
81
 
80
- const contrast = tslFn( ( [ a_immutable, b_immutable ] ) => {
82
+ const contrast = Fn( ( [ a_immutable, b_immutable ] ) => {
81
83
 
82
84
  // assumes colors have premultipliedAlpha, so that the calculated color contrast is scaled by alpha
83
85
 
@@ -91,7 +93,7 @@ class FXAANode extends TempNode {
91
93
 
92
94
  // FXAA3 QUALITY - PC
93
95
 
94
- const FxaaPixelShader = tslFn( ( [ uv, fxaaQualityRcpFrame, fxaaQualityEdgeThreshold, fxaaQualityinvEdgeThreshold ] ) => {
96
+ const FxaaPixelShader = Fn( ( [ uv, fxaaQualityRcpFrame, fxaaQualityEdgeThreshold, fxaaQualityinvEdgeThreshold ] ) => {
95
97
 
96
98
  const rgbaM = FxaaTexTop( uv ).toVar();
97
99
  const rgbaS = FxaaTexOff( uv, vec2( 0.0, - 1.0 ), fxaaQualityRcpFrame.xy ).toVar();
@@ -130,8 +132,8 @@ class FXAANode extends TempNode {
130
132
 
131
133
  // locate the edge
132
134
 
133
- const x = contrastE.greaterThan( contrastW ).cond( 1, - 1 ).toVar();
134
- const y = contrastS.greaterThan( contrastN ).cond( 1, - 1 ).toVar();
135
+ const x = contrastE.greaterThan( contrastW ).select( 1, - 1 ).toVar();
136
+ const y = contrastS.greaterThan( contrastN ).select( 1, - 1 ).toVar();
135
137
 
136
138
  const dirToEdge = vec2( x, y ).toVar();
137
139
  // . 2 . . 1 .
@@ -184,7 +186,7 @@ class FXAANode extends TempNode {
184
186
  offNP.x.assign( 0 );
185
187
  offNP.y.assign( fxaaQualityRcpFrame.y );
186
188
 
187
- } ).else( () => {
189
+ } ).Else( () => {
188
190
 
189
191
  offNP.x.assign( fxaaQualityRcpFrame.x );
190
192
  offNP.y.assign( 0 );
@@ -212,7 +214,7 @@ class FXAANode extends TempNode {
212
214
  const iterationsUsedN = int( 0 ).toVar();
213
215
  const iterationsUsedP = int( 0 ).toVar();
214
216
 
215
- loop( NUM_SAMPLES, ( { i } ) => {
217
+ Loop( NUM_SAMPLES, ( { i } ) => {
216
218
 
217
219
  const increment = i.add( 1 ).toVar();
218
220
 
@@ -233,7 +235,7 @@ class FXAANode extends TempNode {
233
235
 
234
236
  iterationsUsedN.assign( i );
235
237
 
236
- } );
238
+ } );
237
239
 
238
240
  If( doneP.equal( 0 ), () => {
239
241
 
@@ -252,7 +254,7 @@ class FXAANode extends TempNode {
252
254
 
253
255
  iterationsUsedP.assign( i );
254
256
 
255
- } );
257
+ } );
256
258
 
257
259
  If( doneN.equal( 1 ).or( doneP.equal( 1 ) ), () => {
258
260
 
@@ -303,7 +305,7 @@ class FXAANode extends TempNode {
303
305
  ]
304
306
  } );
305
307
 
306
- const fxaa = tslFn( () => {
308
+ const fxaa = Fn( () => {
307
309
 
308
310
  const edgeDetectionQuality = float( 0.2 );
309
311
  const invEdgeDetectionQuality = float( 1 ).div( edgeDetectionQuality );
@@ -320,8 +322,8 @@ class FXAANode extends TempNode {
320
322
 
321
323
  }
322
324
 
323
- export const fxaa = ( node ) => nodeObject( new FXAANode( nodeObject( node ).toTexture() ) );
325
+ export default FXAANode;
324
326
 
325
- addNodeElement( 'fxaa', fxaa );
327
+ FXAANode.type = /*@__PURE__*/ registerNode( 'FXAA', FXAANode );
326
328
 
327
- export default FXAANode;
329
+ export const fxaa = ( node ) => nodeObject( new FXAANode( convertToTexture( node ) ) );
@@ -1,6 +1,7 @@
1
+ import { registerNode } from '../core/Node.js';
1
2
  import TempNode from '../core/TempNode.js';
2
- import { uv } from '../accessors/UVNode.js';
3
- import { addNodeElement, tslFn, nodeProxy, vec4 } from '../shadernode/ShaderNode.js';
3
+ import { uv } from '../accessors/UV.js';
4
+ import { Fn, nodeProxy, vec4 } from '../tsl/TSLBase.js';
4
5
  import { mix, fract, clamp, rand } from '../math/MathNode.js';
5
6
  import { timerLocal } from '../utils/TimerNode.js';
6
7
 
@@ -20,7 +21,7 @@ class FilmNode extends TempNode {
20
21
 
21
22
  const uvNode = this.uvNode || uv();
22
23
 
23
- const film = tslFn( () => {
24
+ const film = Fn( () => {
24
25
 
25
26
  const base = this.inputNode.rgb;
26
27
  const noise = rand( fract( uvNode.add( timerLocal() ) ) );
@@ -45,8 +46,8 @@ class FilmNode extends TempNode {
45
46
 
46
47
  }
47
48
 
48
- export const film = nodeProxy( FilmNode );
49
+ export default FilmNode;
49
50
 
50
- addNodeElement( 'film', film );
51
+ FilmNode.type = /*@__PURE__*/ registerNode( 'Film', FilmNode );
51
52
 
52
- export default FilmNode;
53
+ export const film = /*@__PURE__*/ nodeProxy( FilmNode );
@@ -1,5 +1,5 @@
1
- import Node, { addNodeClass } from '../core/Node.js';
2
- import { nodeImmutable, float } from '../shadernode/ShaderNode.js';
1
+ import Node, { registerNode } from '../core/Node.js';
2
+ import { nodeImmutable, float } from '../tsl/TSLBase.js';
3
3
 
4
4
  import { BackSide, WebGLCoordinateSystem } from '../../constants.js';
5
5
 
@@ -35,7 +35,7 @@ class FrontFacingNode extends Node {
35
35
 
36
36
  export default FrontFacingNode;
37
37
 
38
- export const frontFacing = nodeImmutable( FrontFacingNode );
39
- export const faceDirection = float( frontFacing ).mul( 2.0 ).sub( 1.0 );
38
+ FrontFacingNode.type = /*@__PURE__*/ registerNode( 'FrontFacing', FrontFacingNode );
40
39
 
41
- addNodeClass( 'FrontFacingNode', FrontFacingNode );
40
+ export const frontFacing = /*@__PURE__*/ nodeImmutable( FrontFacingNode );
41
+ export const faceDirection = /*@__PURE__*/ float( frontFacing ).mul( 2.0 ).sub( 1.0 );
@@ -1,8 +1,9 @@
1
+ import { registerNode } from '../core/Node.js';
1
2
  import TempNode from '../core/TempNode.js';
2
3
  import { texture } from '../accessors/TextureNode.js';
3
4
  import { textureSize } from '../accessors/TextureSizeNode.js';
4
- import { uv } from '../accessors/UVNode.js';
5
- import { addNodeElement, nodeObject, tslFn, mat3, vec2, vec3, vec4, float, int, If } from '../shadernode/ShaderNode.js';
5
+ import { uv } from '../accessors/UV.js';
6
+ import { nodeObject, Fn, mat3, vec2, vec3, vec4, float, int, If } from '../tsl/TSLBase.js';
6
7
  import { NodeUpdateType } from '../core/constants.js';
7
8
  import { uniform } from '../core/UniformNode.js';
8
9
  import { DataTexture } from '../../textures/DataTexture.js';
@@ -10,10 +11,12 @@ import { Vector2 } from '../../math/Vector2.js';
10
11
  import { Vector3 } from '../../math/Vector3.js';
11
12
  import { PI, cos, sin, pow, clamp, abs, max, mix, sqrt, acos, dot, normalize, cross } from '../math/MathNode.js';
12
13
  import { div, mul, add, sub } from '../math/OperatorNode.js';
13
- import { loop } from '../utils/LoopNode.js';
14
+ import { Loop } from '../utils/LoopNode.js';
14
15
  import { passTexture } from './PassNode.js';
15
16
  import { RepeatWrapping } from '../../constants.js';
16
17
  import QuadMesh from '../../renderers/common/QuadMesh.js';
18
+ import NodeMaterial from '../../materials/nodes/NodeMaterial.js';
19
+
17
20
  import { RenderTarget } from '../../core/RenderTarget.js';
18
21
  import { Color } from '../../math/Color.js';
19
22
 
@@ -106,7 +109,7 @@ class GTAONode extends TempNode {
106
109
  const sampleDepth = ( uv ) => this.depthNode.uv( uv ).x;
107
110
  const sampleNoise = ( uv ) => this.noiseNode.uv( uv );
108
111
 
109
- const getSceneUvAndDepth = tslFn( ( [ sampleViewPos ] )=> {
112
+ const getSceneUvAndDepth = Fn( ( [ sampleViewPos ] )=> {
110
113
 
111
114
  const sampleClipPos = this.cameraProjectionMatrix.mul( vec4( sampleViewPos, 1.0 ) );
112
115
  let sampleUv = sampleClipPos.xy.div( sampleClipPos.w ).mul( 0.5 ).add( 0.5 ).toVar();
@@ -116,7 +119,7 @@ class GTAONode extends TempNode {
116
119
 
117
120
  } );
118
121
 
119
- const getViewPosition = tslFn( ( [ screenPosition, depth ] ) => {
122
+ const getViewPosition = Fn( ( [ screenPosition, depth ] ) => {
120
123
 
121
124
  screenPosition = vec2( screenPosition.x, screenPosition.y.oneMinus() ).mul( 2.0 ).sub( 1.0 );
122
125
 
@@ -127,7 +130,7 @@ class GTAONode extends TempNode {
127
130
 
128
131
  } );
129
132
 
130
- const ao = tslFn( () => {
133
+ const ao = Fn( () => {
131
134
 
132
135
  const depth = sampleDepth( uvNode );
133
136
 
@@ -147,12 +150,12 @@ class GTAONode extends TempNode {
147
150
  const bitangent = vec3( tangent.y.mul( - 1.0 ), tangent.x, 0.0 );
148
151
  const kernelMatrix = mat3( tangent, bitangent, vec3( 0.0, 0.0, 1.0 ) );
149
152
 
150
- const DIRECTIONS = this.SAMPLES.lessThan( 30 ).cond( 3, 5 );
153
+ const DIRECTIONS = this.SAMPLES.lessThan( 30 ).select( 3, 5 );
151
154
  const STEPS = add( this.SAMPLES, DIRECTIONS.sub( 1 ) ).div( DIRECTIONS );
152
155
 
153
156
  const ao = float( 0 ).toVar();
154
157
 
155
- loop( { start: int( 0 ), end: DIRECTIONS, type: 'int', condition: '<' }, ( { i } ) => {
158
+ Loop( { start: int( 0 ), end: DIRECTIONS, type: 'int', condition: '<' }, ( { i } ) => {
156
159
 
157
160
  const angle = float( i ).div( float( DIRECTIONS ) ).mul( PI );
158
161
  const sampleDir = vec4( cos( angle ), sin( angle ), 0., add( 0.5, mul( 0.5, noiseTexel.w ) ) );
@@ -166,7 +169,7 @@ class GTAONode extends TempNode {
166
169
  const tangentToNormalInSlice = cross( normalInSlice, sliceBitangent );
167
170
  const cosHorizons = vec2( dot( viewDir, tangentToNormalInSlice ), dot( viewDir, tangentToNormalInSlice.negate() ) ).toVar();
168
171
 
169
- loop( { end: STEPS, type: 'int', name: 'j', condition: '<' }, ( { j } ) => {
172
+ Loop( { end: STEPS, type: 'int', name: 'j', condition: '<' }, ( { j } ) => {
170
173
 
171
174
  const sampleViewOffset = sampleDir.xyz.mul( radiusToUse ).mul( sampleDir.w ).mul( pow( div( float( j ).add( 1.0 ), float( STEPS ) ), this.distanceExponent ) );
172
175
 
@@ -206,7 +209,7 @@ class GTAONode extends TempNode {
206
209
  const occlusion = nx.mul( nxb ).add( ny.mul( nyb ) );
207
210
  ao.addAssign( occlusion );
208
211
 
209
- } );
212
+ } );
210
213
 
211
214
  ao.assign( clamp( ao.div( DIRECTIONS ), 0, 1 ) );
212
215
  ao.assign( pow( ao, this.scale ) );
@@ -215,8 +218,9 @@ class GTAONode extends TempNode {
215
218
 
216
219
  } );
217
220
 
218
- const material = this._material || ( this._material = builder.createNodeMaterial() );
221
+ const material = this._material || ( this._material = new NodeMaterial() );
219
222
  material.fragmentNode = ao().context( builder.getSharedContext() );
223
+ material.name = 'GTAO';
220
224
  material.needsUpdate = true;
221
225
 
222
226
  //
@@ -233,6 +237,10 @@ class GTAONode extends TempNode {
233
237
 
234
238
  }
235
239
 
240
+ export default GTAONode;
241
+
242
+ GTAONode.type = /*@__PURE__*/ registerNode( 'GTAO', GTAONode );
243
+
236
244
  function generateMagicSquareNoise( size = 5 ) {
237
245
 
238
246
  const noiseSize = Math.floor( size ) % 2 === 0 ? Math.floor( size ) + 1 : Math.floor( size );
@@ -318,7 +326,3 @@ function generateMagicSquare( size ) {
318
326
  }
319
327
 
320
328
  export const ao = ( depthNode, normalNode, camera ) => nodeObject( new GTAONode( nodeObject( depthNode ), nodeObject( normalNode ), camera ) );
321
-
322
- addNodeElement( 'ao', ao );
323
-
324
- export default GTAONode;