@plastic-software/three 0.181.2 → 0.182.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/README.md +3 -4
- package/build/three.cjs +1192 -522
- package/build/three.core.js +345 -219
- package/build/three.core.min.js +1 -1
- package/build/three.module.js +864 -328
- package/build/three.module.min.js +1 -1
- package/build/three.tsl.js +15 -3
- package/build/three.tsl.min.js +1 -1
- package/build/three.webgpu.js +3660 -1545
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +3659 -1544
- package/build/three.webgpu.nodes.min.js +1 -1
- package/examples/jsm/controls/MapControls.js +55 -1
- package/examples/jsm/controls/OrbitControls.js +6 -6
- package/examples/jsm/controls/TrackballControls.js +6 -6
- package/examples/jsm/csm/CSM.js +2 -1
- package/examples/jsm/environments/RoomEnvironment.js +2 -0
- package/examples/jsm/geometries/DecalGeometry.js +1 -1
- package/examples/jsm/helpers/LightProbeHelperGPU.js +1 -1
- package/examples/jsm/helpers/TextureHelperGPU.js +1 -1
- package/examples/jsm/inspector/Inspector.js +53 -9
- package/examples/jsm/inspector/RendererInspector.js +12 -2
- package/examples/jsm/inspector/tabs/Console.js +2 -2
- package/examples/jsm/inspector/tabs/Parameters.js +2 -2
- package/examples/jsm/inspector/tabs/Performance.js +2 -2
- package/examples/jsm/inspector/tabs/Viewer.js +4 -4
- package/examples/jsm/inspector/ui/Profiler.js +1836 -31
- package/examples/jsm/inspector/ui/Style.js +948 -13
- package/examples/jsm/inspector/ui/Tab.js +188 -1
- package/examples/jsm/inspector/ui/Values.js +17 -1
- package/examples/jsm/loaders/3DMLoader.js +5 -4
- package/examples/jsm/loaders/DRACOLoader.js +5 -5
- package/examples/jsm/loaders/FBXLoader.js +0 -2
- package/examples/jsm/loaders/HDRLoader.js +0 -1
- package/examples/jsm/loaders/KTX2Loader.js +16 -0
- package/examples/jsm/loaders/LDrawLoader.js +2 -3
- package/examples/jsm/loaders/PCDLoader.js +1 -0
- package/examples/jsm/loaders/SVGLoader.js +1 -1
- package/examples/jsm/loaders/TDSLoader.js +0 -2
- package/examples/jsm/loaders/TGALoader.js +0 -2
- package/examples/jsm/loaders/UltraHDRLoader.js +110 -137
- package/examples/jsm/loaders/VOXLoader.js +660 -117
- package/examples/jsm/loaders/VRMLLoader.js +2 -2
- package/examples/jsm/loaders/usd/USDCParser.js +1 -1
- package/examples/jsm/materials/LDrawConditionalLineNodeMaterial.js +1 -1
- package/examples/jsm/materials/MeshGouraudMaterial.js +0 -1
- package/examples/jsm/materials/WoodNodeMaterial.js +11 -11
- package/examples/jsm/math/Octree.js +131 -1
- package/examples/jsm/misc/Volume.js +0 -1
- package/examples/jsm/misc/VolumeSlice.js +0 -1
- package/examples/jsm/objects/SkyMesh.js +13 -3
- package/examples/jsm/physics/AmmoPhysics.js +12 -7
- package/examples/jsm/physics/JoltPhysics.js +3 -1
- package/examples/jsm/physics/RapierPhysics.js +3 -1
- package/examples/jsm/postprocessing/OutputPass.js +9 -0
- package/examples/jsm/postprocessing/RenderPass.js +10 -0
- package/examples/jsm/postprocessing/UnrealBloomPass.js +48 -18
- package/examples/jsm/renderers/Projector.js +268 -30
- package/examples/jsm/renderers/SVGRenderer.js +191 -58
- package/examples/jsm/shaders/UnpackDepthRGBAShader.js +2 -4
- package/examples/jsm/transpiler/AST.js +44 -0
- package/examples/jsm/transpiler/GLSLDecoder.js +61 -4
- package/examples/jsm/transpiler/ShaderToyDecoder.js +2 -0
- package/examples/jsm/transpiler/TSLEncoder.js +46 -3
- package/examples/jsm/transpiler/TranspilerUtils.js +3 -3
- package/examples/jsm/transpiler/WGSLEncoder.js +27 -0
- package/examples/jsm/tsl/display/AnaglyphPassNode.js +2 -0
- package/examples/jsm/tsl/display/BloomNode.js +11 -1
- package/examples/jsm/tsl/display/GTAONode.js +3 -2
- package/examples/jsm/tsl/display/PixelationPassNode.js +2 -1
- package/examples/jsm/tsl/display/SSGINode.js +7 -19
- package/examples/jsm/tsl/display/SSRNode.js +1 -1
- package/examples/jsm/tsl/display/SSSNode.js +4 -2
- package/examples/jsm/tsl/display/StereoCompositePassNode.js +8 -1
- package/examples/jsm/tsl/display/TRAANode.js +265 -114
- package/examples/jsm/tsl/display/radialBlur.js +68 -0
- package/examples/jsm/utils/ShadowMapViewer.js +24 -10
- package/examples/jsm/utils/ShadowMapViewerGPU.js +1 -1
- package/examples/jsm/utils/WebGPUTextureUtils.js +1 -1
- package/package.json +14 -12
- package/src/Three.Core.js +1 -0
- package/src/Three.TSL.js +14 -2
- package/src/animation/AnimationUtils.js +1 -12
- package/src/animation/KeyframeTrack.js +1 -1
- package/src/animation/tracks/BooleanKeyframeTrack.js +1 -1
- package/src/animation/tracks/ColorKeyframeTrack.js +1 -1
- package/src/animation/tracks/NumberKeyframeTrack.js +1 -1
- package/src/animation/tracks/QuaternionKeyframeTrack.js +1 -1
- package/src/animation/tracks/StringKeyframeTrack.js +1 -1
- package/src/animation/tracks/VectorKeyframeTrack.js +1 -1
- package/src/constants.js +61 -5
- package/src/core/BufferGeometry.js +14 -2
- package/src/core/Raycaster.js +2 -2
- package/src/extras/PMREMGenerator.js +3 -10
- package/src/extras/TextureUtils.js +5 -1
- package/src/geometries/ExtrudeGeometry.js +2 -2
- package/src/geometries/PolyhedronGeometry.js +1 -1
- package/src/helpers/PointLightHelper.js +1 -1
- package/src/lights/DirectionalLight.js +13 -0
- package/src/lights/HemisphereLight.js +10 -0
- package/src/lights/Light.js +1 -11
- package/src/lights/LightProbe.js +0 -15
- package/src/lights/LightShadow.js +0 -3
- package/src/lights/PointLight.js +15 -0
- package/src/lights/PointLightShadow.js +0 -86
- package/src/lights/SpotLight.js +22 -1
- package/src/loaders/MaterialLoader.js +2 -1
- package/src/loaders/ObjectLoader.js +3 -1
- package/src/loaders/nodes/NodeLoader.js +2 -2
- package/src/materials/Material.js +2 -0
- package/src/materials/ShaderMaterial.js +20 -1
- package/src/materials/nodes/Line2NodeMaterial.js +2 -2
- package/src/materials/nodes/MeshPhysicalNodeMaterial.js +3 -2
- package/src/materials/nodes/MeshStandardNodeMaterial.js +5 -4
- package/src/materials/nodes/NodeMaterial.js +59 -3
- package/src/materials/nodes/manager/NodeMaterialObserver.js +1 -1
- package/src/math/Matrix4.js +40 -40
- package/src/math/Sphere.js +1 -1
- package/src/math/Vector3.js +0 -2
- package/src/nodes/TSL.js +4 -1
- package/src/nodes/accessors/BatchNode.js +10 -10
- package/src/nodes/accessors/BufferAttributeNode.js +98 -12
- package/src/nodes/accessors/BufferNode.js +29 -2
- package/src/nodes/accessors/ClippingNode.js +4 -4
- package/src/nodes/accessors/CubeTextureNode.js +20 -1
- package/src/nodes/accessors/InstanceNode.js +69 -29
- package/src/nodes/accessors/MaterialNode.js +9 -1
- package/src/nodes/accessors/MaterialReferenceNode.js +1 -2
- package/src/nodes/accessors/ModelNode.js +1 -1
- package/src/nodes/accessors/Normal.js +2 -2
- package/src/nodes/accessors/ReferenceBaseNode.js +4 -4
- package/src/nodes/accessors/ReferenceNode.js +4 -4
- package/src/nodes/accessors/RendererReferenceNode.js +1 -2
- package/src/nodes/accessors/SkinningNode.js +15 -2
- package/src/nodes/accessors/StorageBufferNode.js +4 -2
- package/src/nodes/accessors/Tangent.js +1 -11
- package/src/nodes/accessors/Texture3DNode.js +26 -1
- package/src/nodes/accessors/UniformArrayNode.js +2 -2
- package/src/nodes/accessors/UserDataNode.js +1 -2
- package/src/nodes/accessors/VertexColorNode.js +1 -2
- package/src/nodes/code/FunctionNode.js +1 -2
- package/src/nodes/core/ArrayNode.js +20 -1
- package/src/nodes/core/AssignNode.js +2 -2
- package/src/nodes/core/AttributeNode.js +2 -2
- package/src/nodes/core/ContextNode.js +103 -4
- package/src/nodes/core/NodeBuilder.js +56 -14
- package/src/nodes/core/NodeFrame.js +12 -4
- package/src/nodes/core/NodeUtils.js +5 -5
- package/src/nodes/core/ParameterNode.js +1 -2
- package/src/nodes/core/PropertyNode.js +19 -3
- package/src/nodes/core/StackNode.js +56 -8
- package/src/nodes/core/StructNode.js +1 -2
- package/src/nodes/core/StructTypeNode.js +11 -17
- package/src/nodes/core/UniformNode.js +19 -4
- package/src/nodes/core/VarNode.js +46 -21
- package/src/nodes/display/NormalMapNode.js +37 -2
- package/src/nodes/display/PassNode.js +77 -7
- package/src/nodes/display/ScreenNode.js +1 -0
- package/src/nodes/functions/BSDF/BRDF_GGX_Multiscatter.js +3 -3
- package/src/nodes/functions/BSDF/DFGLUT.js +56 -0
- package/src/nodes/functions/BSDF/EnvironmentBRDF.js +2 -2
- package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +1 -1
- package/src/nodes/functions/PhysicalLightingModel.js +102 -43
- package/src/nodes/gpgpu/ComputeBuiltinNode.js +1 -2
- package/src/nodes/gpgpu/SubgroupFunctionNode.js +1 -1
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +2 -3
- package/src/nodes/lighting/AnalyticLightNode.js +53 -0
- package/src/nodes/lighting/LightsNode.js +2 -2
- package/src/nodes/lighting/PointShadowNode.js +141 -140
- package/src/nodes/lighting/ShadowFilterNode.js +53 -37
- package/src/nodes/lighting/ShadowNode.js +53 -19
- package/src/nodes/math/BitcountNode.js +433 -0
- package/src/nodes/math/PackFloatNode.js +98 -0
- package/src/nodes/math/UnpackFloatNode.js +96 -0
- package/src/nodes/pmrem/PMREMNode.js +1 -1
- package/src/nodes/tsl/TSLCore.js +4 -4
- package/src/nodes/utils/ArrayElementNode.js +13 -0
- package/src/nodes/utils/EventNode.js +1 -2
- package/src/nodes/utils/Packing.js +13 -1
- package/src/nodes/utils/PostProcessingUtils.js +33 -1
- package/src/nodes/utils/ReflectorNode.js +1 -1
- package/src/nodes/utils/SampleNode.js +1 -1
- package/src/nodes/utils/UVUtils.js +26 -0
- package/src/objects/BatchedMesh.js +5 -2
- package/src/objects/Line.js +1 -1
- package/src/objects/Mesh.js +1 -1
- package/src/objects/Points.js +1 -1
- package/src/objects/Skeleton.js +9 -0
- package/src/renderers/WebGLRenderer.js +145 -33
- package/src/renderers/common/Backend.js +8 -0
- package/src/renderers/common/Background.js +19 -9
- package/src/renderers/common/Binding.js +11 -0
- package/src/renderers/common/Bindings.js +7 -7
- package/src/renderers/common/Buffer.js +40 -0
- package/src/renderers/common/ChainMap.js +30 -6
- package/src/renderers/common/Geometries.js +12 -0
- package/src/renderers/common/RenderContexts.js +8 -1
- package/src/renderers/common/RenderObject.js +14 -1
- package/src/renderers/common/Renderer.js +53 -35
- package/src/renderers/common/Textures.js +1 -1
- package/src/renderers/common/UniformsGroup.js +1 -0
- package/src/renderers/common/XRManager.js +1 -0
- package/src/renderers/common/extras/PMREMGenerator.js +2 -8
- package/src/renderers/common/nodes/NodeUniformBuffer.js +52 -0
- package/src/renderers/shaders/DFGLUTData.js +19 -34
- package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +5 -2
- package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +8 -4
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +90 -51
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +194 -186
- package/src/renderers/shaders/ShaderChunk/shadowmask_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/transmission_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk.js +3 -3
- package/src/renderers/shaders/ShaderLib/depth.glsl.js +3 -0
- package/src/renderers/shaders/ShaderLib/{distanceRGBA.glsl.js → distance.glsl.js} +1 -2
- package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +0 -1
- package/src/renderers/shaders/ShaderLib/meshnormal.glsl.js +1 -2
- package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +0 -1
- package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +4 -9
- package/src/renderers/shaders/ShaderLib/meshtoon.glsl.js +0 -1
- package/src/renderers/shaders/ShaderLib/shadow.glsl.js +0 -1
- package/src/renderers/shaders/ShaderLib/vsm.glsl.js +4 -6
- package/src/renderers/shaders/ShaderLib.js +3 -3
- package/src/renderers/webgl/WebGLCapabilities.js +3 -4
- package/src/renderers/webgl/WebGLLights.js +18 -1
- package/src/renderers/webgl/WebGLOutput.js +267 -0
- package/src/renderers/webgl/WebGLProgram.js +43 -107
- package/src/renderers/webgl/WebGLPrograms.js +35 -45
- package/src/renderers/webgl/WebGLShadowMap.js +188 -25
- package/src/renderers/webgl/WebGLState.js +20 -20
- package/src/renderers/webgl/WebGLTextures.js +89 -28
- package/src/renderers/webgl/WebGLUniforms.js +40 -3
- package/src/renderers/webgl/WebGLUtils.js +6 -2
- package/src/renderers/webgl-fallback/WebGLBackend.js +79 -13
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +59 -7
- package/src/renderers/webgl-fallback/utils/WebGLState.js +18 -3
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +5 -3
- package/src/renderers/webgl-fallback/utils/WebGLTimestampQueryPool.js +9 -9
- package/src/renderers/webgl-fallback/utils/WebGLUtils.js +6 -2
- package/src/renderers/webgpu/WebGPUBackend.js +61 -4
- package/src/renderers/webgpu/WebGPURenderer.js +1 -1
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +65 -23
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +4 -17
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +354 -186
- package/src/renderers/webgpu/utils/WebGPUConstants.js +2 -0
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +20 -7
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +40 -17
- package/src/renderers/webgpu/utils/WebGPUTimestampQueryPool.js +7 -7
- package/src/renderers/webgpu/utils/WebGPUUtils.js +7 -5
- package/src/textures/CubeDepthTexture.js +76 -0
- package/src/textures/Source.js +1 -1
- package/src/textures/Texture.js +1 -1
- package/src/utils.js +13 -1
- package/src/nodes/functions/BSDF/DFGApprox.js +0 -71
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
import BRDF_Lambert from './BSDF/BRDF_Lambert.js';
|
|
2
2
|
import BRDF_GGX from './BSDF/BRDF_GGX.js';
|
|
3
3
|
import BRDF_GGX_Multiscatter from './BSDF/BRDF_GGX_Multiscatter.js';
|
|
4
|
-
import
|
|
4
|
+
import DFGLUT from './BSDF/DFGLUT.js';
|
|
5
5
|
import EnvironmentBRDF from './BSDF/EnvironmentBRDF.js';
|
|
6
6
|
import F_Schlick from './BSDF/F_Schlick.js';
|
|
7
7
|
import Schlick_to_F0 from './BSDF/Schlick_to_F0.js';
|
|
8
8
|
import BRDF_Sheen from './BSDF/BRDF_Sheen.js';
|
|
9
9
|
import { LTC_Evaluate, LTC_Uv } from './BSDF/LTC.js';
|
|
10
10
|
import LightingModel from '../core/LightingModel.js';
|
|
11
|
-
import { diffuseColor, specularColor, specularF90, roughness, clearcoat, clearcoatRoughness, sheen, sheenRoughness, iridescence, iridescenceIOR, iridescenceThickness, ior, thickness, transmission, attenuationDistance, attenuationColor, dispersion } from '../core/PropertyNode.js';
|
|
11
|
+
import { diffuseColor, diffuseContribution, specularColor, specularColorBlended, specularF90, roughness, metalness, clearcoat, clearcoatRoughness, sheen, sheenRoughness, iridescence, iridescenceIOR, iridescenceThickness, ior, thickness, transmission, attenuationDistance, attenuationColor, dispersion } from '../core/PropertyNode.js';
|
|
12
12
|
import { normalView, clearcoatNormalView, normalWorld } from '../accessors/Normal.js';
|
|
13
13
|
import { positionViewDirection, positionView, positionWorld } from '../accessors/Position.js';
|
|
14
14
|
import { Fn, float, vec2, vec3, vec4, mat3, If } from '../tsl/TSLBase.js';
|
|
15
|
-
import { select } from '../math/ConditionalNode.js';
|
|
16
15
|
import { mix, normalize, refract, length, clamp, log2, log, exp, smoothstep } from '../math/MathNode.js';
|
|
17
16
|
import { div } from '../math/OperatorNode.js';
|
|
18
17
|
import { cameraPosition, cameraProjectionMatrix, cameraViewMatrix } from '../accessors/Camera.js';
|
|
@@ -313,29 +312,19 @@ const evalIridescence = /*@__PURE__*/ Fn( ( { outsideIOR, eta2, cosTheta1, thinF
|
|
|
313
312
|
//
|
|
314
313
|
|
|
315
314
|
// This is a curve-fit approximation to the "Charlie sheen" BRDF integrated over the hemisphere from
|
|
316
|
-
// Estevez and Kulla 2017, "Production Friendly Microfacet Sheen BRDF".
|
|
317
|
-
// in the Sheen section of https://drive.google.com/file/d/1T0D1VSyR4AllqIJTQAraEIzjlb5h4FKH/view?usp=sharing
|
|
315
|
+
// Estevez and Kulla 2017, "Production Friendly Microfacet Sheen BRDF".
|
|
318
316
|
const IBLSheenBRDF = /*@__PURE__*/ Fn( ( { normal, viewDir, roughness } ) => {
|
|
319
317
|
|
|
320
318
|
const dotNV = normal.dot( viewDir ).saturate();
|
|
319
|
+
const r2 = roughness.mul( roughness );
|
|
320
|
+
const rInv = roughness.add( 0.1 ).reciprocal();
|
|
321
321
|
|
|
322
|
-
const
|
|
322
|
+
const a = float( - 1.9362 ).add( roughness.mul( 1.0678 ) ).add( r2.mul( 0.4573 ) ).sub( rInv.mul( 0.8469 ) );
|
|
323
|
+
const b = float( - 0.6014 ).add( roughness.mul( 0.5538 ) ).sub( r2.mul( 0.4670 ) ).sub( rInv.mul( 0.1255 ) );
|
|
323
324
|
|
|
324
|
-
const
|
|
325
|
-
roughness.lessThan( 0.25 ),
|
|
326
|
-
float( - 339.2 ).mul( r2 ).add( float( 161.4 ).mul( roughness ) ).sub( 25.9 ),
|
|
327
|
-
float( - 8.48 ).mul( r2 ).add( float( 14.3 ).mul( roughness ) ).sub( 9.95 )
|
|
328
|
-
);
|
|
329
|
-
|
|
330
|
-
const b = select(
|
|
331
|
-
roughness.lessThan( 0.25 ),
|
|
332
|
-
float( 44.0 ).mul( r2 ).sub( float( 23.7 ).mul( roughness ) ).add( 3.26 ),
|
|
333
|
-
float( 1.97 ).mul( r2 ).sub( float( 3.27 ).mul( roughness ) ).add( 0.72 )
|
|
334
|
-
);
|
|
325
|
+
const DG = a.mul( dotNV ).add( b ).exp();
|
|
335
326
|
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
return DG.mul( 1.0 / Math.PI ).saturate();
|
|
327
|
+
return DG.saturate();
|
|
339
328
|
|
|
340
329
|
} );
|
|
341
330
|
|
|
@@ -468,6 +457,22 @@ class PhysicalLightingModel extends LightingModel {
|
|
|
468
457
|
*/
|
|
469
458
|
this.iridescenceF0 = null;
|
|
470
459
|
|
|
460
|
+
/**
|
|
461
|
+
* The iridescence F0 dielectric.
|
|
462
|
+
*
|
|
463
|
+
* @type {?Node}
|
|
464
|
+
* @default null
|
|
465
|
+
*/
|
|
466
|
+
this.iridescenceF0Dielectric = null;
|
|
467
|
+
|
|
468
|
+
/**
|
|
469
|
+
* The iridescence F0 metallic.
|
|
470
|
+
*
|
|
471
|
+
* @type {?Node}
|
|
472
|
+
* @default null
|
|
473
|
+
*/
|
|
474
|
+
this.iridescenceF0Metallic = null;
|
|
475
|
+
|
|
471
476
|
}
|
|
472
477
|
|
|
473
478
|
/**
|
|
@@ -497,7 +502,7 @@ class PhysicalLightingModel extends LightingModel {
|
|
|
497
502
|
|
|
498
503
|
const dotNVi = normalView.dot( positionViewDirection ).clamp();
|
|
499
504
|
|
|
500
|
-
|
|
505
|
+
const iridescenceFresnelDielectric = evalIridescence( {
|
|
501
506
|
outsideIOR: float( 1.0 ),
|
|
502
507
|
eta2: iridescenceIOR,
|
|
503
508
|
cosTheta1: dotNVi,
|
|
@@ -505,7 +510,20 @@ class PhysicalLightingModel extends LightingModel {
|
|
|
505
510
|
baseF0: specularColor
|
|
506
511
|
} );
|
|
507
512
|
|
|
508
|
-
|
|
513
|
+
const iridescenceFresnelMetallic = evalIridescence( {
|
|
514
|
+
outsideIOR: float( 1.0 ),
|
|
515
|
+
eta2: iridescenceIOR,
|
|
516
|
+
cosTheta1: dotNVi,
|
|
517
|
+
thinFilmThickness: iridescenceThickness,
|
|
518
|
+
baseF0: diffuseColor.rgb
|
|
519
|
+
} );
|
|
520
|
+
|
|
521
|
+
this.iridescenceFresnel = mix( iridescenceFresnelDielectric, iridescenceFresnelMetallic, metalness );
|
|
522
|
+
|
|
523
|
+
this.iridescenceF0Dielectric = Schlick_to_F0( { f: iridescenceFresnelDielectric, f90: 1.0, dotVH: dotNVi } );
|
|
524
|
+
this.iridescenceF0Metallic = Schlick_to_F0( { f: iridescenceFresnelMetallic, f90: 1.0, dotVH: dotNVi } );
|
|
525
|
+
|
|
526
|
+
this.iridescenceF0 = mix( this.iridescenceF0Dielectric, this.iridescenceF0Metallic, metalness );
|
|
509
527
|
|
|
510
528
|
}
|
|
511
529
|
|
|
@@ -521,8 +539,8 @@ class PhysicalLightingModel extends LightingModel {
|
|
|
521
539
|
n,
|
|
522
540
|
v,
|
|
523
541
|
roughness,
|
|
524
|
-
|
|
525
|
-
|
|
542
|
+
diffuseContribution,
|
|
543
|
+
specularColorBlended,
|
|
526
544
|
specularF90, // specularF90
|
|
527
545
|
position, // positionWorld
|
|
528
546
|
modelWorldMatrix, // modelMatrix
|
|
@@ -549,13 +567,13 @@ class PhysicalLightingModel extends LightingModel {
|
|
|
549
567
|
// Approximates multi-scattering in order to preserve energy.
|
|
550
568
|
// http://www.jcgt.org/published/0008/01/03/
|
|
551
569
|
|
|
552
|
-
computeMultiscattering( singleScatter, multiScatter, specularF90 ) {
|
|
570
|
+
computeMultiscattering( singleScatter, multiScatter, specularF90, f0, iridescenceF0 = null ) {
|
|
553
571
|
|
|
554
572
|
const dotNV = normalView.dot( positionViewDirection ).clamp(); // @ TODO: Move to core dotNV
|
|
555
573
|
|
|
556
|
-
const fab =
|
|
574
|
+
const fab = DFGLUT( { roughness, dotNV } );
|
|
557
575
|
|
|
558
|
-
const Fr =
|
|
576
|
+
const Fr = iridescenceF0 ? iridescence.mix( f0, iridescenceF0 ) : f0;
|
|
559
577
|
|
|
560
578
|
const FssEss = Fr.mul( fab.x ).add( specularF90.mul( fab.y ) );
|
|
561
579
|
|
|
@@ -579,12 +597,19 @@ class PhysicalLightingModel extends LightingModel {
|
|
|
579
597
|
direct( { lightDirection, lightColor, reflectedLight }, /* builder */ ) {
|
|
580
598
|
|
|
581
599
|
const dotNL = normalView.dot( lightDirection ).clamp();
|
|
582
|
-
const irradiance = dotNL.mul( lightColor );
|
|
600
|
+
const irradiance = dotNL.mul( lightColor ).toVar();
|
|
583
601
|
|
|
584
602
|
if ( this.sheen === true ) {
|
|
585
603
|
|
|
586
604
|
this.sheenSpecularDirect.addAssign( irradiance.mul( BRDF_Sheen( { lightDirection } ) ) );
|
|
587
605
|
|
|
606
|
+
const sheenAlbedoV = IBLSheenBRDF( { normal: normalView, viewDir: positionViewDirection, roughness: sheenRoughness } );
|
|
607
|
+
const sheenAlbedoL = IBLSheenBRDF( { normal: normalView, viewDir: lightDirection, roughness: sheenRoughness } );
|
|
608
|
+
|
|
609
|
+
const sheenEnergyComp = sheen.r.max( sheen.g ).max( sheen.b ).mul( sheenAlbedoV.max( sheenAlbedoL ) ).oneMinus();
|
|
610
|
+
|
|
611
|
+
irradiance.mulAssign( sheenEnergyComp );
|
|
612
|
+
|
|
588
613
|
}
|
|
589
614
|
|
|
590
615
|
if ( this.clearcoat === true ) {
|
|
@@ -596,9 +621,9 @@ class PhysicalLightingModel extends LightingModel {
|
|
|
596
621
|
|
|
597
622
|
}
|
|
598
623
|
|
|
599
|
-
reflectedLight.directDiffuse.addAssign( irradiance.mul( BRDF_Lambert( { diffuseColor:
|
|
624
|
+
reflectedLight.directDiffuse.addAssign( irradiance.mul( BRDF_Lambert( { diffuseColor: diffuseContribution } ) ) );
|
|
600
625
|
|
|
601
|
-
reflectedLight.directSpecular.addAssign( irradiance.mul( BRDF_GGX_Multiscatter( { lightDirection, f0:
|
|
626
|
+
reflectedLight.directSpecular.addAssign( irradiance.mul( BRDF_GGX_Multiscatter( { lightDirection, f0: specularColorBlended, f90: 1, roughness, f: this.iridescenceFresnel, USE_IRIDESCENCE: this.iridescence, USE_ANISOTROPY: this.anisotropy } ) ) );
|
|
602
627
|
|
|
603
628
|
}
|
|
604
629
|
|
|
@@ -633,11 +658,11 @@ class PhysicalLightingModel extends LightingModel {
|
|
|
633
658
|
|
|
634
659
|
// LTC Fresnel Approximation by Stephen Hill
|
|
635
660
|
// http://blog.selfshadow.com/publications/s2016-advances/s2016_ltc_fresnel.pdf
|
|
636
|
-
const fresnel =
|
|
661
|
+
const fresnel = specularColorBlended.mul( t2.x ).add( specularColorBlended.oneMinus().mul( t2.y ) ).toVar();
|
|
637
662
|
|
|
638
663
|
reflectedLight.directSpecular.addAssign( lightColor.mul( fresnel ).mul( LTC_Evaluate( { N, V, P, mInv, p0, p1, p2, p3 } ) ) );
|
|
639
664
|
|
|
640
|
-
reflectedLight.directDiffuse.addAssign( lightColor.mul(
|
|
665
|
+
reflectedLight.directDiffuse.addAssign( lightColor.mul( diffuseContribution ).mul( LTC_Evaluate( { N, V, P, mInv: mat3( 1, 0, 0, 0, 1, 0, 0, 0, 1 ), p0, p1, p2, p3 } ) ) );
|
|
641
666
|
|
|
642
667
|
}
|
|
643
668
|
|
|
@@ -663,7 +688,19 @@ class PhysicalLightingModel extends LightingModel {
|
|
|
663
688
|
|
|
664
689
|
const { irradiance, reflectedLight } = builder.context;
|
|
665
690
|
|
|
666
|
-
|
|
691
|
+
const diffuse = irradiance.mul( BRDF_Lambert( { diffuseColor: diffuseContribution } ) ).toVar();
|
|
692
|
+
|
|
693
|
+
if ( this.sheen === true ) {
|
|
694
|
+
|
|
695
|
+
const sheenAlbedo = IBLSheenBRDF( { normal: normalView, viewDir: positionViewDirection, roughness: sheenRoughness } );
|
|
696
|
+
|
|
697
|
+
const sheenEnergyComp = sheen.r.max( sheen.g ).max( sheen.b ).mul( sheenAlbedo ).oneMinus();
|
|
698
|
+
|
|
699
|
+
diffuse.mulAssign( sheenEnergyComp );
|
|
700
|
+
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
reflectedLight.indirectDiffuse.addAssign( diffuse );
|
|
667
704
|
|
|
668
705
|
}
|
|
669
706
|
|
|
@@ -705,21 +742,44 @@ class PhysicalLightingModel extends LightingModel {
|
|
|
705
742
|
}
|
|
706
743
|
|
|
707
744
|
// Both indirect specular and indirect diffuse light accumulate here
|
|
745
|
+
// Compute multiscattering separately for dielectric and metallic, then mix
|
|
746
|
+
|
|
747
|
+
const singleScatteringDielectric = vec3().toVar( 'singleScatteringDielectric' );
|
|
748
|
+
const multiScatteringDielectric = vec3().toVar( 'multiScatteringDielectric' );
|
|
749
|
+
const singleScatteringMetallic = vec3().toVar( 'singleScatteringMetallic' );
|
|
750
|
+
const multiScatteringMetallic = vec3().toVar( 'multiScatteringMetallic' );
|
|
751
|
+
|
|
752
|
+
this.computeMultiscattering( singleScatteringDielectric, multiScatteringDielectric, specularF90, specularColor, this.iridescenceF0Dielectric );
|
|
753
|
+
this.computeMultiscattering( singleScatteringMetallic, multiScatteringMetallic, specularF90, diffuseColor.rgb, this.iridescenceF0Metallic );
|
|
754
|
+
|
|
755
|
+
// Mix based on metalness
|
|
756
|
+
const singleScattering = mix( singleScatteringDielectric, singleScatteringMetallic, metalness );
|
|
757
|
+
const multiScattering = mix( multiScatteringDielectric, multiScatteringMetallic, metalness );
|
|
758
|
+
|
|
759
|
+
// Diffuse energy conservation uses dielectric path
|
|
760
|
+
const totalScatteringDielectric = singleScatteringDielectric.add( multiScatteringDielectric );
|
|
761
|
+
|
|
762
|
+
const diffuse = diffuseContribution.mul( totalScatteringDielectric.oneMinus() );
|
|
708
763
|
|
|
709
|
-
const singleScattering = vec3().toVar( 'singleScattering' );
|
|
710
|
-
const multiScattering = vec3().toVar( 'multiScattering' );
|
|
711
764
|
const cosineWeightedIrradiance = iblIrradiance.mul( 1 / Math.PI );
|
|
712
765
|
|
|
713
|
-
|
|
766
|
+
const indirectSpecular = radiance.mul( singleScattering ).add( multiScattering.mul( cosineWeightedIrradiance ) ).toVar();
|
|
767
|
+
const indirectDiffuse = diffuse.mul( cosineWeightedIrradiance ).toVar();
|
|
714
768
|
|
|
715
|
-
|
|
769
|
+
if ( this.sheen === true ) {
|
|
770
|
+
|
|
771
|
+
const sheenAlbedo = IBLSheenBRDF( { normal: normalView, viewDir: positionViewDirection, roughness: sheenRoughness } );
|
|
772
|
+
|
|
773
|
+
const sheenEnergyComp = sheen.r.max( sheen.g ).max( sheen.b ).mul( sheenAlbedo ).oneMinus();
|
|
716
774
|
|
|
717
|
-
|
|
775
|
+
indirectSpecular.mulAssign( sheenEnergyComp );
|
|
776
|
+
indirectDiffuse.mulAssign( sheenEnergyComp );
|
|
777
|
+
|
|
778
|
+
}
|
|
718
779
|
|
|
719
|
-
reflectedLight.indirectSpecular.addAssign(
|
|
720
|
-
reflectedLight.indirectSpecular.addAssign( multiScattering.mul( cosineWeightedIrradiance ) );
|
|
780
|
+
reflectedLight.indirectSpecular.addAssign( indirectSpecular );
|
|
721
781
|
|
|
722
|
-
reflectedLight.indirectDiffuse.addAssign(
|
|
782
|
+
reflectedLight.indirectDiffuse.addAssign( indirectDiffuse );
|
|
723
783
|
|
|
724
784
|
}
|
|
725
785
|
|
|
@@ -783,8 +843,7 @@ class PhysicalLightingModel extends LightingModel {
|
|
|
783
843
|
|
|
784
844
|
if ( this.sheen === true ) {
|
|
785
845
|
|
|
786
|
-
const
|
|
787
|
-
const sheenLight = outgoingLight.mul( sheenEnergyComp ).add( this.sheenSpecularDirect, this.sheenSpecularIndirect );
|
|
846
|
+
const sheenLight = outgoingLight.add( this.sheenSpecularDirect, this.sheenSpecularIndirect.mul( 1.0 / Math.PI ) );
|
|
788
847
|
|
|
789
848
|
outgoingLight.assign( sheenLight );
|
|
790
849
|
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import Node from '../core/Node.js';
|
|
2
|
-
import { nodeObject } from '../tsl/TSLBase.js';
|
|
3
2
|
import { warn } from '../../utils.js';
|
|
4
3
|
|
|
5
4
|
/**
|
|
@@ -149,7 +148,7 @@ export default ComputeBuiltinNode;
|
|
|
149
148
|
* @param {string} nodeType - The node type.
|
|
150
149
|
* @returns {ComputeBuiltinNode}
|
|
151
150
|
*/
|
|
152
|
-
const computeBuiltin = ( name, nodeType ) =>
|
|
151
|
+
const computeBuiltin = ( name, nodeType ) => new ComputeBuiltinNode( name, nodeType );
|
|
153
152
|
|
|
154
153
|
/**
|
|
155
154
|
* Represents the number of workgroups dispatched by the compute shader.
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import ArrayElementNode from '../utils/ArrayElementNode.js';
|
|
2
|
-
import { nodeObject } from '../tsl/TSLCore.js';
|
|
3
2
|
import Node from '../core/Node.js';
|
|
4
3
|
import { warn } from '../../utils.js';
|
|
5
4
|
|
|
@@ -203,7 +202,7 @@ class WorkgroupInfoNode extends Node {
|
|
|
203
202
|
*/
|
|
204
203
|
element( indexNode ) {
|
|
205
204
|
|
|
206
|
-
return
|
|
205
|
+
return new WorkgroupInfoElementNode( this, indexNode );
|
|
207
206
|
|
|
208
207
|
}
|
|
209
208
|
|
|
@@ -229,6 +228,6 @@ export default WorkgroupInfoNode;
|
|
|
229
228
|
* @param {number} [count=0] - The number of elements in the buffer.
|
|
230
229
|
* @returns {WorkgroupInfoNode}
|
|
231
230
|
*/
|
|
232
|
-
export const workgroupArray = ( type, count ) =>
|
|
231
|
+
export const workgroupArray = ( type, count ) => new WorkgroupInfoNode( 'Workgroup', type, count );
|
|
233
232
|
|
|
234
233
|
|
|
@@ -96,6 +96,53 @@ class AnalyticLightNode extends LightingNode {
|
|
|
96
96
|
*/
|
|
97
97
|
this.updateType = NodeUpdateType.FRAME;
|
|
98
98
|
|
|
99
|
+
if ( light && light.shadow ) {
|
|
100
|
+
|
|
101
|
+
this._shadowDisposeListener = () => {
|
|
102
|
+
|
|
103
|
+
this.disposeShadow();
|
|
104
|
+
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
light.addEventListener( 'dispose', this._shadowDisposeListener );
|
|
108
|
+
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
dispose() {
|
|
114
|
+
|
|
115
|
+
if ( this._shadowDisposeListener ) {
|
|
116
|
+
|
|
117
|
+
this.light.removeEventListener( 'dispose', this._shadowDisposeListener );
|
|
118
|
+
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
super.dispose();
|
|
122
|
+
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Frees internal resources related to shadows.
|
|
127
|
+
*/
|
|
128
|
+
disposeShadow() {
|
|
129
|
+
|
|
130
|
+
if ( this.shadowNode !== null ) {
|
|
131
|
+
|
|
132
|
+
this.shadowNode.dispose();
|
|
133
|
+
this.shadowNode = null;
|
|
134
|
+
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
this.shadowColorNode = null;
|
|
138
|
+
|
|
139
|
+
if ( this.baseColorNode !== null ) {
|
|
140
|
+
|
|
141
|
+
this.colorNode = this.baseColorNode;
|
|
142
|
+
this.baseColorNode = null;
|
|
143
|
+
|
|
144
|
+
}
|
|
145
|
+
|
|
99
146
|
}
|
|
100
147
|
|
|
101
148
|
getHash() {
|
|
@@ -188,6 +235,12 @@ class AnalyticLightNode extends LightingNode {
|
|
|
188
235
|
|
|
189
236
|
//
|
|
190
237
|
|
|
238
|
+
if ( builder.context.getShadow ) {
|
|
239
|
+
|
|
240
|
+
shadowColorNode = builder.context.getShadow( this, builder );
|
|
241
|
+
|
|
242
|
+
}
|
|
243
|
+
|
|
191
244
|
this.colorNode = shadowColorNode;
|
|
192
245
|
|
|
193
246
|
}
|
|
@@ -234,7 +234,7 @@ class LightsNode extends Node {
|
|
|
234
234
|
|
|
235
235
|
if ( ! _lightsNodeRef.has( light ) ) {
|
|
236
236
|
|
|
237
|
-
lightNode =
|
|
237
|
+
lightNode = new lightNodeClass( light );
|
|
238
238
|
_lightsNodeRef.set( light, lightNode );
|
|
239
239
|
|
|
240
240
|
} else {
|
|
@@ -450,4 +450,4 @@ export default LightsNode;
|
|
|
450
450
|
* @param {Array<Light>} lights - An array of lights.
|
|
451
451
|
* @return {LightsNode} The created lights node.
|
|
452
452
|
*/
|
|
453
|
-
export const lights = ( lights = [] ) =>
|
|
453
|
+
export const lights = ( lights = [] ) => new LightsNode().setLights( lights );
|