@needle-tools/three 0.153.0 → 0.154.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/build/three.cjs +112 -364
- package/build/three.js +112 -364
- package/build/three.min.js +1 -1
- package/build/three.module.js +113 -346
- package/build/three.module.min.js +1 -1
- package/examples/jsm/controls/ArcballControls.js +2 -1
- package/examples/jsm/controls/FlyControls.js +25 -9
- package/examples/jsm/controls/OrbitControls.js +7 -1
- package/examples/jsm/csm/CSM.js +1 -1
- package/examples/jsm/effects/AnaglyphEffect.js +1 -1
- package/examples/jsm/effects/OutlineEffect.js +1 -1
- package/examples/jsm/effects/ParallaxBarrierEffect.js +1 -1
- package/examples/jsm/environments/RoomEnvironment.js +6 -2
- package/examples/jsm/lines/LineMaterial.js +1 -1
- package/examples/jsm/loaders/3DMLoader.js +1 -1
- package/examples/jsm/loaders/3MFLoader.js +5 -1
- package/examples/jsm/loaders/AMFLoader.js +5 -1
- package/examples/jsm/loaders/ColladaLoader.js +4 -1
- package/examples/jsm/loaders/FBXLoader.js +9 -2
- package/examples/jsm/loaders/LDrawLoader.js +4 -7
- package/examples/jsm/loaders/PLYLoader.js +16 -6
- package/examples/jsm/loaders/VRMLLoader.js +16 -4
- package/examples/jsm/materials/MeshGouraudMaterial.js +2 -2
- package/examples/jsm/math/MeshSurfaceSampler.js +76 -35
- package/examples/jsm/nodes/Nodes.js +20 -15
- package/examples/jsm/nodes/accessors/BufferAttributeNode.js +21 -8
- package/examples/jsm/nodes/accessors/CameraNode.js +25 -4
- package/examples/jsm/nodes/accessors/ExtendedMaterialNode.js +7 -1
- package/examples/jsm/nodes/accessors/InstanceNode.js +2 -4
- package/examples/jsm/nodes/accessors/MaterialNode.js +55 -47
- package/examples/jsm/nodes/accessors/ModelNode.js +3 -1
- package/examples/jsm/nodes/accessors/MorphNode.js +70 -0
- package/examples/jsm/nodes/accessors/NormalNode.js +3 -2
- package/examples/jsm/nodes/accessors/Object3DNode.js +10 -2
- package/examples/jsm/nodes/accessors/SceneNode.js +46 -0
- package/examples/jsm/nodes/accessors/SkinningNode.js +43 -62
- package/examples/jsm/nodes/accessors/TangentNode.js +2 -2
- package/examples/jsm/nodes/accessors/TextureBicubicNode.js +94 -0
- package/examples/jsm/nodes/accessors/TextureNode.js +68 -6
- package/examples/jsm/nodes/accessors/TextureSizeNode.js +35 -0
- package/examples/jsm/nodes/accessors/UVNode.js +1 -1
- package/examples/jsm/nodes/code/CodeNode.js +3 -0
- package/examples/jsm/nodes/code/FunctionNode.js +25 -4
- package/examples/jsm/nodes/core/BypassNode.js +2 -2
- package/examples/jsm/nodes/core/ContextNode.js +2 -0
- package/examples/jsm/nodes/core/IndexNode.js +66 -0
- package/examples/jsm/nodes/core/LightingModel.js +2 -1
- package/examples/jsm/nodes/core/Node.js +12 -15
- package/examples/jsm/nodes/core/NodeBuilder.js +24 -5
- package/examples/jsm/nodes/core/PropertyNode.js +4 -0
- package/examples/jsm/nodes/core/StackNode.js +1 -1
- package/examples/jsm/nodes/core/UniformNode.js +1 -1
- package/examples/jsm/nodes/core/VarNode.js +1 -3
- package/examples/jsm/nodes/display/BlendModeNode.js +9 -9
- package/examples/jsm/nodes/display/ColorAdjustmentNode.js +7 -7
- package/examples/jsm/nodes/display/ColorSpaceNode.js +50 -49
- package/examples/jsm/nodes/display/NormalMapNode.js +3 -3
- package/examples/jsm/nodes/display/ToneMappingNode.js +8 -8
- package/examples/jsm/nodes/display/ViewportDepthNode.js +69 -0
- package/examples/jsm/nodes/display/ViewportDepthTextureNode.js +34 -0
- package/examples/jsm/nodes/display/ViewportSharedTextureNode.js +6 -5
- package/examples/jsm/nodes/display/ViewportTextureNode.js +23 -15
- package/examples/jsm/nodes/functions/BSDF/BRDF_BlinnPhong.js +5 -5
- package/examples/jsm/nodes/functions/BSDF/BRDF_GGX.js +10 -8
- package/examples/jsm/nodes/functions/BSDF/BRDF_Lambert.js +2 -2
- package/examples/jsm/nodes/functions/BSDF/BRDF_Sheen.js +43 -0
- package/examples/jsm/nodes/functions/BSDF/DFGApprox.js +4 -4
- package/examples/jsm/nodes/functions/BSDF/D_GGX.js +2 -2
- package/examples/jsm/nodes/functions/BSDF/EnvironmentBRDF.js +13 -0
- package/examples/jsm/nodes/functions/BSDF/F_Schlick.js +2 -4
- package/examples/jsm/nodes/functions/BSDF/V_GGX_SmithCorrelated.js +2 -2
- package/examples/jsm/nodes/functions/PhongLightingModel.js +7 -7
- package/examples/jsm/nodes/functions/PhysicalLightingModel.js +129 -18
- package/examples/jsm/nodes/functions/material/getGeometryRoughness.js +2 -2
- package/examples/jsm/nodes/functions/material/getRoughness.js +3 -3
- package/examples/jsm/nodes/geometry/RangeNode.js +1 -1
- package/examples/jsm/nodes/lighting/DirectionalLightNode.js +2 -2
- package/examples/jsm/nodes/lighting/EnvironmentNode.js +91 -62
- package/examples/jsm/nodes/lighting/LightUtils.js +2 -2
- package/examples/jsm/nodes/lighting/LightingContextNode.js +17 -15
- package/examples/jsm/nodes/lighting/PointLightNode.js +3 -3
- package/examples/jsm/nodes/lighting/SpotLightNode.js +3 -3
- package/examples/jsm/nodes/materials/LineBasicNodeMaterial.js +0 -15
- package/examples/jsm/nodes/materials/MeshBasicNodeMaterial.js +0 -15
- package/examples/jsm/nodes/materials/MeshNormalNodeMaterial.js +0 -10
- package/examples/jsm/nodes/materials/MeshPhongNodeMaterial.js +0 -9
- package/examples/jsm/nodes/materials/MeshPhysicalNodeMaterial.js +41 -0
- package/examples/jsm/nodes/materials/MeshStandardNodeMaterial.js +1 -14
- package/examples/jsm/nodes/materials/NodeMaterial.js +79 -28
- package/examples/jsm/nodes/materials/PointsNodeMaterial.js +0 -9
- package/examples/jsm/nodes/materials/SpriteNodeMaterial.js +0 -7
- package/examples/jsm/nodes/materialx/lib/mx_hsv.js +3 -3
- package/examples/jsm/nodes/materialx/lib/mx_noise.js +14 -14
- package/examples/jsm/nodes/materialx/lib/mx_transform_color.js +4 -4
- package/examples/jsm/nodes/math/MathNode.js +6 -0
- package/examples/jsm/nodes/math/OperatorNode.js +1 -1
- package/examples/jsm/nodes/procedural/CheckerNode.js +3 -3
- package/examples/jsm/nodes/shadernode/ShaderNode.js +24 -4
- package/examples/jsm/nodes/utils/LoopNode.js +1 -1
- package/examples/jsm/nodes/utils/TriplanarTexturesNode.js +1 -1
- package/examples/jsm/objects/GroundProjectedSkybox.js +1 -1
- package/examples/jsm/objects/Reflector.js +1 -1
- package/examples/jsm/objects/Refractor.js +1 -1
- package/examples/jsm/objects/Sky.js +1 -1
- package/examples/jsm/objects/Water.js +1 -1
- package/examples/jsm/objects/Water2.js +1 -1
- package/examples/jsm/offscreen/scene.js +1 -0
- package/examples/jsm/postprocessing/EffectComposer.js +2 -0
- package/examples/jsm/postprocessing/OutlinePass.js +1 -3
- package/examples/jsm/postprocessing/SSAARenderPass.js +3 -12
- package/examples/jsm/postprocessing/SavePass.js +3 -1
- package/examples/jsm/postprocessing/TAARenderPass.js +14 -2
- package/examples/jsm/postprocessing/TexturePass.js +2 -1
- package/examples/jsm/postprocessing/UnrealBloomPass.js +9 -10
- package/examples/jsm/renderers/common/Backend.js +2 -0
- package/examples/jsm/renderers/common/Background.js +7 -6
- package/examples/jsm/renderers/common/Pipelines.js +26 -14
- package/examples/jsm/renderers/common/RenderObject.js +18 -0
- package/examples/jsm/renderers/common/RenderObjects.js +29 -29
- package/examples/jsm/renderers/common/Renderer.js +48 -6
- package/examples/jsm/renderers/common/nodes/Nodes.js +1 -1
- package/examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js +340 -0
- package/examples/jsm/renderers/webgl/nodes/WebGLNodeBuilder.js +23 -19
- package/examples/jsm/renderers/webgpu/WebGPUBackend.js +123 -41
- package/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js +29 -9
- package/examples/jsm/renderers/webgpu/utils/WebGPUAttributeUtils.js +4 -0
- package/examples/jsm/renderers/webgpu/utils/WebGPUPipelineUtils.js +8 -13
- package/examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js +85 -3
- package/examples/jsm/renderers/webgpu/utils/WebGPUUtils.js +5 -1
- package/examples/jsm/shaders/BlendShader.js +1 -2
- package/examples/jsm/shaders/BokehShader2.js +1 -1
- package/examples/jsm/shaders/CopyShader.js +2 -2
- package/examples/jsm/shaders/ToonShader.js +4 -4
- package/examples/jsm/shaders/WaterRefractionShader.js +1 -1
- package/examples/jsm/webxr/OculusHandPointerModel.js +34 -13
- package/package.json +2 -1
- package/src/Three.Legacy.js +0 -228
- package/src/animation/PropertyBinding.js +1 -1
- package/src/constants.js +1 -1
- package/src/core/BufferAttribute.js +0 -24
- package/src/core/BufferGeometry.js +0 -7
- package/src/loaders/Loader.js +2 -0
- package/src/loaders/MaterialLoader.js +1 -0
- package/src/materials/Material.js +3 -0
- package/src/objects/Skeleton.js +0 -2
- package/src/renderers/WebGLRenderer.js +9 -21
- package/src/renderers/shaders/ShaderChunk/alphahash_fragment.glsl.js +7 -0
- package/src/renderers/shaders/ShaderChunk/alphahash_pars_fragment.glsl.js +68 -0
- package/src/renderers/shaders/ShaderChunk/begin_vertex.glsl.js +6 -0
- package/src/renderers/shaders/ShaderChunk/common.glsl.js +6 -0
- package/src/renderers/shaders/ShaderChunk/normal_fragment_begin.glsl.js +9 -1
- package/src/renderers/shaders/ShaderChunk/uv_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/uv_pars_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/uv_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk.js +10 -6
- package/src/renderers/shaders/ShaderLib/background.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/backgroundCube.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/cube.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/depth.glsl.js +2 -0
- package/src/renderers/shaders/ShaderLib/distanceRGBA.glsl.js +2 -0
- package/src/renderers/shaders/ShaderLib/equirect.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/linedashed.glsl.js +2 -2
- package/src/renderers/shaders/ShaderLib/meshbasic.glsl.js +4 -2
- package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +4 -2
- package/src/renderers/shaders/ShaderLib/meshmatcap.glsl.js +4 -2
- package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +4 -2
- package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +4 -2
- package/src/renderers/shaders/ShaderLib/meshtoon.glsl.js +4 -2
- package/src/renderers/shaders/ShaderLib/points.glsl.js +4 -2
- package/src/renderers/shaders/ShaderLib/shadow.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/sprite.glsl.js +4 -2
- package/src/renderers/webgl/WebGLObjects.js +23 -3
- package/src/renderers/webgl/WebGLProgram.js +24 -5
- package/src/renderers/webgl/WebGLPrograms.js +3 -0
- package/src/renderers/webxr/WebXRManager.js +11 -29
- package/src/scenes/Scene.js +0 -14
- package/examples/jsm/nodes/core/InstanceIndexNode.js +0 -45
- /package/src/renderers/shaders/ShaderChunk/{encodings_fragment.glsl.js → colorspace_fragment.glsl.js} +0 -0
- /package/src/renderers/shaders/ShaderChunk/{encodings_pars_fragment.glsl.js → colorspace_pars_fragment.glsl.js} +0 -0
- /package/src/renderers/shaders/ShaderChunk/{output_fragment.glsl.js → opaque_fragment.glsl.js} +0 -0
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import LightingNode from './LightingNode.js';
|
|
2
2
|
import { cache } from '../core/CacheNode.js';
|
|
3
3
|
import { context } from '../core/ContextNode.js';
|
|
4
|
-
import { roughness } from '../core/PropertyNode.js';
|
|
4
|
+
import { roughness, clearcoatRoughness } from '../core/PropertyNode.js';
|
|
5
5
|
import { equirectUV } from '../utils/EquirectUVNode.js';
|
|
6
6
|
import { specularMIPLevel } from '../utils/SpecularMIPLevelNode.js';
|
|
7
7
|
import { cameraViewMatrix } from '../accessors/CameraNode.js';
|
|
8
|
-
import { transformedNormalView, transformedNormalWorld } from '../accessors/NormalNode.js';
|
|
8
|
+
import { transformedClearcoatNormalView, transformedNormalView, transformedNormalWorld } from '../accessors/NormalNode.js';
|
|
9
9
|
import { positionViewDirection } from '../accessors/PositionNode.js';
|
|
10
10
|
import { addNodeClass } from '../core/Node.js';
|
|
11
11
|
import { float, vec2 } from '../shadernode/ShaderNode.js';
|
|
@@ -39,113 +39,142 @@ class EnvironmentNode extends LightingNode {
|
|
|
39
39
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
|
|
43
|
-
let radianceTextureUVNode;
|
|
44
|
-
let irradianceTextureUVNode;
|
|
42
|
+
//
|
|
45
43
|
|
|
46
|
-
const
|
|
47
|
-
getUVNode: ( textureNode ) => {
|
|
44
|
+
const intensity = reference( 'envMapIntensity', 'float', builder.material ); // @TODO: Add materialEnvIntensity in MaterialNode
|
|
48
45
|
|
|
49
|
-
|
|
46
|
+
const radiance = context( envNode, createRadianceContext( roughness, transformedNormalView ) ).mul( intensity );
|
|
47
|
+
const irradiance = context( envNode, createIrradianceContext( transformedNormalWorld ) ).mul( Math.PI ).mul( intensity );
|
|
50
48
|
|
|
51
|
-
|
|
49
|
+
const isolateRadiance = cache( radiance );
|
|
52
50
|
|
|
53
|
-
|
|
54
|
-
reflectVec = roughness.mul( roughness ).mix( reflectVec, transformedNormalView ).normalize();
|
|
55
|
-
reflectVec = reflectVec.transformDirection( cameraViewMatrix );
|
|
51
|
+
//
|
|
56
52
|
|
|
57
|
-
|
|
53
|
+
builder.context.radiance.addAssign( isolateRadiance );
|
|
58
54
|
|
|
59
|
-
|
|
55
|
+
builder.context.iblIrradiance.addAssign( irradiance );
|
|
60
56
|
|
|
61
|
-
|
|
57
|
+
//
|
|
62
58
|
|
|
63
|
-
|
|
59
|
+
let isolateClearcoatRadiance = null;
|
|
64
60
|
|
|
65
|
-
|
|
61
|
+
if ( builder.context.clearcoatRadiance ) {
|
|
66
62
|
|
|
67
|
-
|
|
63
|
+
const clearcoatRadiance = context( envNode, createRadianceContext( clearcoatRoughness, transformedClearcoatNormalView ) ).mul( intensity );
|
|
68
64
|
|
|
69
|
-
|
|
65
|
+
isolateClearcoatRadiance = cache( clearcoatRadiance );
|
|
70
66
|
|
|
71
|
-
|
|
67
|
+
builder.context.clearcoatRadiance.addAssign( isolateClearcoatRadiance );
|
|
72
68
|
|
|
73
|
-
|
|
69
|
+
}
|
|
74
70
|
|
|
75
|
-
|
|
71
|
+
//
|
|
76
72
|
|
|
77
|
-
|
|
73
|
+
properties.radiance = isolateRadiance;
|
|
74
|
+
properties.clearcoatRadiance = isolateClearcoatRadiance;
|
|
75
|
+
properties.irradiance = irradiance;
|
|
78
76
|
|
|
79
|
-
|
|
80
|
-
getSamplerLevelNode: () => {
|
|
77
|
+
}
|
|
81
78
|
|
|
82
|
-
|
|
79
|
+
}
|
|
83
80
|
|
|
84
|
-
|
|
85
|
-
getMIPLevelAlgorithmNode: ( textureNode, levelNode ) => {
|
|
81
|
+
const createRadianceContext = ( roughnessNode, normalViewNode ) => {
|
|
86
82
|
|
|
87
|
-
|
|
83
|
+
let reflectVec = null;
|
|
84
|
+
let textureUVNode = null;
|
|
88
85
|
|
|
89
|
-
|
|
90
|
-
|
|
86
|
+
return {
|
|
87
|
+
getUVNode: ( textureNode ) => {
|
|
91
88
|
|
|
92
|
-
|
|
93
|
-
getUVNode: ( textureNode ) => {
|
|
89
|
+
let node = null;
|
|
94
90
|
|
|
95
|
-
|
|
91
|
+
if ( reflectVec === null ) {
|
|
96
92
|
|
|
97
|
-
|
|
93
|
+
reflectVec = positionViewDirection.negate().reflect( normalViewNode );
|
|
94
|
+
reflectVec = roughnessNode.mul( roughnessNode ).mix( reflectVec, normalViewNode ).normalize();
|
|
95
|
+
reflectVec = reflectVec.transformDirection( cameraViewMatrix );
|
|
98
96
|
|
|
99
|
-
|
|
97
|
+
}
|
|
100
98
|
|
|
101
|
-
|
|
99
|
+
if ( textureNode.isCubeTextureNode ) {
|
|
102
100
|
|
|
103
|
-
|
|
101
|
+
node = reflectVec;
|
|
104
102
|
|
|
105
|
-
|
|
103
|
+
} else if ( textureNode.isTextureNode ) {
|
|
106
104
|
|
|
107
|
-
|
|
108
|
-
irradianceTextureUVNode = vec2( irradianceTextureUVNode.x, irradianceTextureUVNode.y.oneMinus() );
|
|
105
|
+
if ( textureUVNode === null ) {
|
|
109
106
|
|
|
110
|
-
|
|
107
|
+
// @TODO: Needed PMREM
|
|
111
108
|
|
|
112
|
-
|
|
109
|
+
textureUVNode = equirectUV( reflectVec );
|
|
113
110
|
|
|
114
111
|
}
|
|
115
112
|
|
|
116
|
-
|
|
113
|
+
node = textureUVNode;
|
|
117
114
|
|
|
118
|
-
}
|
|
119
|
-
getSamplerLevelNode: () => {
|
|
115
|
+
}
|
|
120
116
|
|
|
121
|
-
|
|
117
|
+
return node;
|
|
122
118
|
|
|
123
|
-
|
|
124
|
-
|
|
119
|
+
},
|
|
120
|
+
getSamplerLevelNode: () => {
|
|
125
121
|
|
|
126
|
-
|
|
122
|
+
return roughnessNode;
|
|
127
123
|
|
|
128
|
-
|
|
129
|
-
|
|
124
|
+
},
|
|
125
|
+
getMIPLevelAlgorithmNode: ( textureNode, levelNode ) => {
|
|
130
126
|
|
|
131
|
-
|
|
127
|
+
return specularMIPLevel( textureNode, levelNode );
|
|
132
128
|
|
|
133
|
-
|
|
129
|
+
}
|
|
130
|
+
};
|
|
134
131
|
|
|
135
|
-
|
|
132
|
+
};
|
|
136
133
|
|
|
137
|
-
|
|
134
|
+
const createIrradianceContext = ( normalWorldNode ) => {
|
|
138
135
|
|
|
139
|
-
|
|
136
|
+
let textureUVNode = null;
|
|
140
137
|
|
|
141
|
-
|
|
138
|
+
return {
|
|
139
|
+
getUVNode: ( textureNode ) => {
|
|
142
140
|
|
|
143
|
-
|
|
144
|
-
properties.irradianceContext = irradianceContext;
|
|
141
|
+
let node = null;
|
|
145
142
|
|
|
146
|
-
|
|
143
|
+
if ( textureNode.isCubeTextureNode ) {
|
|
147
144
|
|
|
148
|
-
|
|
145
|
+
node = normalWorldNode;
|
|
146
|
+
|
|
147
|
+
} else if ( textureNode.isTextureNode ) {
|
|
148
|
+
|
|
149
|
+
if ( textureUVNode === null ) {
|
|
150
|
+
|
|
151
|
+
// @TODO: Needed PMREM
|
|
152
|
+
|
|
153
|
+
textureUVNode = equirectUV( normalWorldNode );
|
|
154
|
+
textureUVNode = vec2( textureUVNode.x, textureUVNode.y.oneMinus() );
|
|
155
|
+
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
node = textureUVNode;
|
|
159
|
+
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
return node;
|
|
163
|
+
|
|
164
|
+
},
|
|
165
|
+
getSamplerLevelNode: () => {
|
|
166
|
+
|
|
167
|
+
return float( 1 );
|
|
168
|
+
|
|
169
|
+
},
|
|
170
|
+
getMIPLevelAlgorithmNode: ( textureNode, levelNode ) => {
|
|
171
|
+
|
|
172
|
+
return specularMIPLevel( textureNode, levelNode );
|
|
173
|
+
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
};
|
|
149
178
|
|
|
150
179
|
export default EnvironmentNode;
|
|
151
180
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { tslFn } from '../shadernode/ShaderNode.js';
|
|
2
2
|
|
|
3
|
-
export const getDistanceAttenuation =
|
|
3
|
+
export const getDistanceAttenuation = tslFn( ( inputs ) => {
|
|
4
4
|
|
|
5
5
|
const { lightDistance, cutoffDistance, decayExponent } = inputs;
|
|
6
6
|
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import ContextNode from '../core/ContextNode.js';
|
|
2
|
-
import { temp } from '../core/VarNode.js';
|
|
3
2
|
import { add } from '../math/OperatorNode.js';
|
|
4
3
|
import { mix } from '../math/MathNode.js';
|
|
5
4
|
import { addNodeClass } from '../core/Node.js';
|
|
@@ -30,10 +29,10 @@ class LightingContextNode extends ContextNode {
|
|
|
30
29
|
const context = this.context = {}; // reset context
|
|
31
30
|
const properties = builder.getNodeProperties( this );
|
|
32
31
|
|
|
33
|
-
const directDiffuse =
|
|
34
|
-
directSpecular =
|
|
35
|
-
indirectDiffuse =
|
|
36
|
-
indirectSpecular =
|
|
32
|
+
const directDiffuse = vec3().temp(),
|
|
33
|
+
directSpecular = vec3().temp(),
|
|
34
|
+
indirectDiffuse = vec3().temp(),
|
|
35
|
+
indirectSpecular = vec3().temp();
|
|
37
36
|
|
|
38
37
|
let totalDiffuse = add( directDiffuse, indirectDiffuse );
|
|
39
38
|
|
|
@@ -44,7 +43,7 @@ class LightingContextNode extends ContextNode {
|
|
|
44
43
|
}
|
|
45
44
|
|
|
46
45
|
const totalSpecular = add( directSpecular, indirectSpecular );
|
|
47
|
-
const total = add( totalDiffuse, totalSpecular );
|
|
46
|
+
const total = add( totalDiffuse, totalSpecular ).temp();
|
|
48
47
|
|
|
49
48
|
const reflectedLight = {
|
|
50
49
|
directDiffuse,
|
|
@@ -55,21 +54,24 @@ class LightingContextNode extends ContextNode {
|
|
|
55
54
|
};
|
|
56
55
|
|
|
57
56
|
const lighting = {
|
|
58
|
-
radiance:
|
|
59
|
-
irradiance:
|
|
60
|
-
iblIrradiance:
|
|
61
|
-
ambientOcclusion:
|
|
57
|
+
radiance: vec3().temp(),
|
|
58
|
+
irradiance: vec3().temp(),
|
|
59
|
+
iblIrradiance: vec3().temp(),
|
|
60
|
+
ambientOcclusion: float( 1 ).temp()
|
|
62
61
|
};
|
|
63
62
|
|
|
63
|
+
context.reflectedLight = reflectedLight;
|
|
64
|
+
context.lightingModelNode = lightingModelNode || context.lightingModelNode;
|
|
65
|
+
|
|
64
66
|
Object.assign( properties, reflectedLight, lighting );
|
|
65
67
|
Object.assign( context, lighting );
|
|
66
68
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
+
// @TODO: Call needed return a new node ( or rename the ShaderNodeInternal.call() function ), it's not moment to run
|
|
70
|
+
if ( lightingModelNode && lightingModelNode.init ) lightingModelNode.init( context, builder.stack, builder );
|
|
69
71
|
|
|
70
|
-
if ( lightingModelNode && lightingModelNode.indirectDiffuse ) lightingModelNode.indirectDiffuse
|
|
71
|
-
if ( lightingModelNode && lightingModelNode.indirectSpecular ) lightingModelNode.indirectSpecular
|
|
72
|
-
if ( lightingModelNode && lightingModelNode.ambientOcclusion ) lightingModelNode.ambientOcclusion
|
|
72
|
+
if ( lightingModelNode && lightingModelNode.indirectDiffuse ) lightingModelNode.indirectDiffuse( context, builder.stack, builder );
|
|
73
|
+
if ( lightingModelNode && lightingModelNode.indirectSpecular ) lightingModelNode.indirectSpecular( context, builder.stack, builder );
|
|
74
|
+
if ( lightingModelNode && lightingModelNode.ambientOcclusion ) lightingModelNode.ambientOcclusion( context, builder.stack, builder );
|
|
73
75
|
|
|
74
76
|
return super.construct( builder );
|
|
75
77
|
|
|
@@ -39,7 +39,7 @@ class PointLightNode extends AnalyticLightNode {
|
|
|
39
39
|
const lightDirection = lVector.normalize();
|
|
40
40
|
const lightDistance = lVector.length();
|
|
41
41
|
|
|
42
|
-
const lightAttenuation = getDistanceAttenuation
|
|
42
|
+
const lightAttenuation = getDistanceAttenuation( {
|
|
43
43
|
lightDistance,
|
|
44
44
|
cutoffDistance: cutoffDistanceNode,
|
|
45
45
|
decayExponent: decayExponentNode
|
|
@@ -52,11 +52,11 @@ class PointLightNode extends AnalyticLightNode {
|
|
|
52
52
|
|
|
53
53
|
if ( lightingModelFunctionNode && lightingModelFunctionNode.direct ) {
|
|
54
54
|
|
|
55
|
-
lightingModelFunctionNode.direct
|
|
55
|
+
lightingModelFunctionNode.direct( {
|
|
56
56
|
lightDirection,
|
|
57
57
|
lightColor,
|
|
58
58
|
reflectedLight
|
|
59
|
-
}
|
|
59
|
+
} );
|
|
60
60
|
|
|
61
61
|
}
|
|
62
62
|
|
|
@@ -60,7 +60,7 @@ class SpotLightNode extends AnalyticLightNode {
|
|
|
60
60
|
|
|
61
61
|
const lightDistance = lVector.length();
|
|
62
62
|
|
|
63
|
-
const lightAttenuation = getDistanceAttenuation
|
|
63
|
+
const lightAttenuation = getDistanceAttenuation( {
|
|
64
64
|
lightDistance,
|
|
65
65
|
cutoffDistance: cutoffDistanceNode,
|
|
66
66
|
decayExponent: decayExponentNode
|
|
@@ -73,11 +73,11 @@ class SpotLightNode extends AnalyticLightNode {
|
|
|
73
73
|
|
|
74
74
|
if ( lightingModelFunctionNode && lightingModelFunctionNode.direct ) {
|
|
75
75
|
|
|
76
|
-
lightingModelFunctionNode.direct
|
|
76
|
+
lightingModelFunctionNode.direct( {
|
|
77
77
|
lightDirection,
|
|
78
78
|
lightColor,
|
|
79
79
|
reflectedLight
|
|
80
|
-
}
|
|
80
|
+
} );
|
|
81
81
|
|
|
82
82
|
}
|
|
83
83
|
|
|
@@ -21,21 +21,6 @@ class LineBasicNodeMaterial extends NodeMaterial {
|
|
|
21
21
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
copy( source ) {
|
|
25
|
-
|
|
26
|
-
this.colorNode = source.colorNode;
|
|
27
|
-
this.opacityNode = source.opacityNode;
|
|
28
|
-
|
|
29
|
-
this.alphaTestNode = source.alphaTestNode;
|
|
30
|
-
|
|
31
|
-
this.lightNode = source.lightNode;
|
|
32
|
-
|
|
33
|
-
this.positionNode = source.positionNode;
|
|
34
|
-
|
|
35
|
-
return super.copy( source );
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
|
|
39
24
|
}
|
|
40
25
|
|
|
41
26
|
export default LineBasicNodeMaterial;
|
|
@@ -20,21 +20,6 @@ class MeshBasicNodeMaterial extends NodeMaterial {
|
|
|
20
20
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
copy( source ) {
|
|
24
|
-
|
|
25
|
-
this.colorNode = source.colorNode;
|
|
26
|
-
this.opacityNode = source.opacityNode;
|
|
27
|
-
|
|
28
|
-
this.alphaTestNode = source.alphaTestNode;
|
|
29
|
-
|
|
30
|
-
this.lightNode = source.lightNode;
|
|
31
|
-
|
|
32
|
-
this.positionNode = source.positionNode;
|
|
33
|
-
|
|
34
|
-
return super.copy( source );
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
|
|
38
23
|
}
|
|
39
24
|
|
|
40
25
|
export default MeshBasicNodeMaterial;
|
|
@@ -31,16 +31,6 @@ class MeshNormalNodeMaterial extends NodeMaterial {
|
|
|
31
31
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
copy( source ) {
|
|
35
|
-
|
|
36
|
-
this.opacityNode = source.opacityNode;
|
|
37
|
-
|
|
38
|
-
this.positionNode = source.positionNode;
|
|
39
|
-
|
|
40
|
-
return super.copy( source );
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
|
|
44
34
|
}
|
|
45
35
|
|
|
46
36
|
export default MeshNormalNodeMaterial;
|
|
@@ -51,18 +51,9 @@ class MeshPhongNodeMaterial extends NodeMaterial {
|
|
|
51
51
|
|
|
52
52
|
copy( source ) {
|
|
53
53
|
|
|
54
|
-
this.colorNode = source.colorNode;
|
|
55
|
-
this.opacityNode = source.opacityNode;
|
|
56
|
-
|
|
57
|
-
this.alphaTestNode = source.alphaTestNode;
|
|
58
|
-
|
|
59
54
|
this.shininessNode = source.shininessNode;
|
|
60
55
|
this.specularNode = source.specularNode;
|
|
61
56
|
|
|
62
|
-
this.lightNode = source.lightNode;
|
|
63
|
-
|
|
64
|
-
this.positionNode = source.positionNode;
|
|
65
|
-
|
|
66
57
|
return super.copy( source );
|
|
67
58
|
|
|
68
59
|
}
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import { addNodeMaterial } from './NodeMaterial.js';
|
|
2
|
+
import { transformedClearcoatNormalView } from '../accessors/NormalNode.js';
|
|
3
|
+
import { clearcoat, clearcoatRoughness, sheen, sheenRoughness } from '../core/PropertyNode.js';
|
|
4
|
+
import { materialClearcoatNormal } from '../accessors/ExtendedMaterialNode.js';
|
|
5
|
+
import { materialClearcoat, materialClearcoatRoughness, materialSheen, materialSheenRoughness } from '../accessors/MaterialNode.js';
|
|
6
|
+
import { float, vec3 } from '../shadernode/ShaderNode.js';
|
|
2
7
|
import MeshStandardNodeMaterial from './MeshStandardNodeMaterial.js';
|
|
3
8
|
|
|
4
9
|
import { MeshPhysicalMaterial } from 'three';
|
|
@@ -38,6 +43,42 @@ class MeshPhysicalNodeMaterial extends MeshStandardNodeMaterial {
|
|
|
38
43
|
|
|
39
44
|
}
|
|
40
45
|
|
|
46
|
+
constructVariants( builder ) {
|
|
47
|
+
|
|
48
|
+
super.constructVariants( builder );
|
|
49
|
+
|
|
50
|
+
const { stack } = builder;
|
|
51
|
+
|
|
52
|
+
// CLEARCOAT
|
|
53
|
+
|
|
54
|
+
const clearcoatNode = this.clearcoatNode ? float( this.clearcoatNode ) : materialClearcoat;
|
|
55
|
+
const clearcoatRoughnessNode = this.clearcoatRoughnessNode ? float( this.clearcoatRoughnessNode ) : materialClearcoatRoughness;
|
|
56
|
+
|
|
57
|
+
stack.assign( clearcoat, clearcoatNode );
|
|
58
|
+
stack.assign( clearcoatRoughness, clearcoatRoughnessNode );
|
|
59
|
+
|
|
60
|
+
// SHEEN
|
|
61
|
+
|
|
62
|
+
const sheenNode = this.sheenNode ? vec3( this.sheenNode ) : materialSheen;
|
|
63
|
+
const sheenRoughnessNode = this.sheenRoughnessNode ? float( this.sheenRoughnessNode ) : materialSheenRoughness;
|
|
64
|
+
|
|
65
|
+
stack.assign( sheen, sheenNode );
|
|
66
|
+
stack.assign( sheenRoughness, sheenRoughnessNode );
|
|
67
|
+
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
constructNormal( builder ) {
|
|
71
|
+
|
|
72
|
+
super.constructNormal( builder );
|
|
73
|
+
|
|
74
|
+
// CLEARCOAT NORMAL
|
|
75
|
+
|
|
76
|
+
const clearcoatNormalNode = this.clearcoatNormalNode ? vec3( this.clearcoatNormalNode ) : materialClearcoatNormal;
|
|
77
|
+
|
|
78
|
+
builder.stack.assign( transformedClearcoatNormalView, clearcoatNormalNode );
|
|
79
|
+
|
|
80
|
+
}
|
|
81
|
+
|
|
41
82
|
copy( source ) {
|
|
42
83
|
|
|
43
84
|
this.clearcoatNode = source.clearcoatNode;
|
|
@@ -46,7 +46,7 @@ class MeshStandardNodeMaterial extends NodeMaterial {
|
|
|
46
46
|
// ROUGHNESS
|
|
47
47
|
|
|
48
48
|
let roughnessNode = this.roughnessNode ? float( this.roughnessNode ) : materialRoughness;
|
|
49
|
-
roughnessNode = getRoughness
|
|
49
|
+
roughnessNode = getRoughness( { roughness: roughnessNode } );
|
|
50
50
|
|
|
51
51
|
stack.assign( roughness, roughnessNode );
|
|
52
52
|
|
|
@@ -64,24 +64,11 @@ class MeshStandardNodeMaterial extends NodeMaterial {
|
|
|
64
64
|
|
|
65
65
|
copy( source ) {
|
|
66
66
|
|
|
67
|
-
this.colorNode = source.colorNode;
|
|
68
|
-
this.opacityNode = source.opacityNode;
|
|
69
|
-
|
|
70
|
-
this.alphaTestNode = source.alphaTestNode;
|
|
71
|
-
|
|
72
|
-
this.normalNode = source.normalNode;
|
|
73
|
-
|
|
74
67
|
this.emissiveNode = source.emissiveNode;
|
|
75
68
|
|
|
76
69
|
this.metalnessNode = source.metalnessNode;
|
|
77
70
|
this.roughnessNode = source.roughnessNode;
|
|
78
71
|
|
|
79
|
-
this.envNode = source.envNode;
|
|
80
|
-
|
|
81
|
-
this.lightsNode = source.lightsNode;
|
|
82
|
-
|
|
83
|
-
this.positionNode = source.positionNode;
|
|
84
|
-
|
|
85
72
|
return super.copy( source );
|
|
86
73
|
|
|
87
74
|
}
|