super-three 0.162.0 → 0.164.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/three.cjs +847 -1226
- package/build/three.module.js +846 -1225
- package/build/three.module.min.js +2 -2
- package/examples/jsm/animation/CCDIKSolver.js +4 -2
- package/examples/jsm/controls/TransformControls.js +3 -3
- package/examples/jsm/exporters/GLTFExporter.js +66 -5
- package/examples/jsm/exporters/USDZExporter.js +22 -1
- package/examples/jsm/geometries/TextGeometry.js +10 -2
- package/examples/jsm/interactive/HTMLMesh.js +7 -9
- package/examples/jsm/libs/draco/README.md +2 -2
- package/examples/jsm/libs/fflate.module.js +694 -496
- package/examples/jsm/lines/LineMaterial.js +0 -2
- package/examples/jsm/loaders/3MFLoader.js +2 -0
- package/examples/jsm/loaders/EXRLoader.js +351 -97
- package/examples/jsm/loaders/FBXLoader.js +1 -1
- package/examples/jsm/loaders/GLTFLoader.js +59 -0
- package/examples/jsm/loaders/KTX2Loader.js +3 -10
- package/examples/jsm/loaders/LUT3dlLoader.js +0 -15
- package/examples/jsm/loaders/LUTCubeLoader.js +0 -14
- package/examples/jsm/loaders/LUTImageLoader.js +0 -14
- package/examples/jsm/loaders/RGBMLoader.js +16 -0
- package/examples/jsm/loaders/VRMLLoader.js +1 -1
- package/examples/jsm/loaders/lwo/IFFParser.js +8 -5
- package/examples/jsm/materials/MeshGouraudMaterial.js +7 -1
- package/examples/jsm/math/Octree.js +26 -20
- package/examples/jsm/misc/GPUComputationRenderer.js +0 -6
- package/examples/jsm/nodes/Nodes.js +10 -4
- package/examples/jsm/nodes/accessors/AccessorsUtils.js +16 -1
- package/examples/jsm/nodes/accessors/BatchNode.js +78 -0
- package/examples/jsm/nodes/accessors/ClippingNode.js +3 -2
- package/examples/jsm/nodes/accessors/InstanceNode.js +25 -2
- package/examples/jsm/nodes/accessors/MaterialNode.js +107 -3
- package/examples/jsm/nodes/accessors/MaterialReferenceNode.js +1 -1
- package/examples/jsm/nodes/accessors/MorphNode.js +13 -3
- package/examples/jsm/nodes/accessors/NormalNode.js +12 -2
- package/examples/jsm/nodes/accessors/ReferenceNode.js +1 -1
- package/examples/jsm/nodes/accessors/RendererReferenceNode.js +29 -0
- package/examples/jsm/nodes/accessors/StorageBufferNode.js +9 -0
- package/examples/jsm/nodes/accessors/TextureNode.js +51 -10
- package/examples/jsm/nodes/accessors/TextureSizeNode.js +1 -1
- package/examples/jsm/nodes/code/FunctionNode.js +0 -8
- package/examples/jsm/nodes/core/Node.js +63 -4
- package/examples/jsm/nodes/core/NodeBuilder.js +26 -25
- package/examples/jsm/nodes/core/NodeFrame.js +10 -10
- package/examples/jsm/nodes/core/NodeUtils.js +2 -2
- package/examples/jsm/nodes/core/OutputStructNode.js +2 -1
- package/examples/jsm/nodes/core/PropertyNode.js +10 -0
- package/examples/jsm/nodes/core/UniformNode.js +20 -0
- package/examples/jsm/nodes/display/BumpMapNode.js +7 -26
- package/examples/jsm/nodes/display/FrontFacingNode.js +13 -0
- package/examples/jsm/nodes/display/PassNode.js +17 -1
- package/examples/jsm/nodes/display/ToneMappingNode.js +8 -4
- package/examples/jsm/nodes/display/ViewportDepthNode.js +1 -1
- package/examples/jsm/nodes/display/ViewportNode.js +4 -2
- package/examples/jsm/nodes/display/ViewportSharedTextureNode.js +6 -0
- package/examples/jsm/nodes/display/ViewportTextureNode.js +4 -1
- package/examples/jsm/nodes/fog/FogExp2Node.js +4 -5
- package/examples/jsm/nodes/fog/FogNode.js +13 -3
- package/examples/jsm/nodes/fog/FogRangeNode.js +4 -3
- package/examples/jsm/nodes/functions/BSDF/BRDF_GGX.js +26 -7
- package/examples/jsm/nodes/functions/BSDF/D_GGX_Anisotropic.js +28 -0
- package/examples/jsm/nodes/functions/BSDF/V_GGX_SmithCorrelated.js +1 -3
- package/examples/jsm/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +29 -0
- package/examples/jsm/nodes/functions/PhongLightingModel.js +1 -1
- package/examples/jsm/nodes/functions/PhysicalLightingModel.js +164 -10
- package/examples/jsm/nodes/functions/ShadowMaskModel.js +31 -0
- package/examples/jsm/nodes/lighting/AnalyticLightNode.js +19 -5
- package/examples/jsm/nodes/lighting/DirectionalLightNode.js +2 -1
- package/examples/jsm/nodes/lighting/EnvironmentNode.js +22 -70
- package/examples/jsm/nodes/lighting/IrradianceNode.js +24 -0
- package/examples/jsm/nodes/lighting/LightsNode.js +11 -1
- package/examples/jsm/nodes/lighting/PointLightNode.js +2 -1
- package/examples/jsm/nodes/lighting/SpotLightNode.js +2 -1
- package/examples/jsm/nodes/materials/Line2NodeMaterial.js +10 -6
- package/examples/jsm/nodes/materials/Materials.js +1 -0
- package/examples/jsm/nodes/materials/MeshNormalNodeMaterial.js +0 -2
- package/examples/jsm/nodes/materials/MeshPhongNodeMaterial.js +2 -2
- package/examples/jsm/nodes/materials/MeshPhysicalNodeMaterial.js +76 -5
- package/examples/jsm/nodes/materials/MeshStandardNodeMaterial.js +11 -4
- package/examples/jsm/nodes/materials/NodeMaterial.js +55 -43
- package/examples/jsm/nodes/materials/ShadowNodeMaterial.js +34 -0
- package/examples/jsm/nodes/pmrem/PMREMNode.js +193 -0
- package/examples/jsm/nodes/pmrem/PMREMUtils.js +288 -0
- package/examples/jsm/nodes/shadernode/ShaderNode.js +3 -9
- package/examples/jsm/nodes/utils/EquirectUVNode.js +1 -1
- package/examples/jsm/objects/QuadMesh.js +7 -23
- package/examples/jsm/physics/JoltPhysics.js +281 -0
- package/examples/jsm/physics/RapierPhysics.js +4 -4
- package/examples/jsm/postprocessing/GlitchPass.js +0 -3
- package/examples/jsm/postprocessing/LUTPass.js +5 -71
- package/examples/jsm/postprocessing/RenderTransitionPass.js +193 -0
- package/examples/jsm/postprocessing/SAOPass.js +0 -1
- package/examples/jsm/postprocessing/SSAOPass.js +0 -3
- package/examples/jsm/renderers/common/Animation.js +3 -0
- package/examples/jsm/renderers/common/Background.js +8 -8
- package/examples/jsm/renderers/common/ClippingContext.js +1 -1
- package/examples/jsm/renderers/common/Info.js +11 -19
- package/examples/jsm/renderers/common/PostProcessing.js +12 -4
- package/examples/jsm/renderers/common/RenderContext.js +1 -1
- package/examples/jsm/renderers/common/RenderList.js +1 -1
- package/examples/jsm/renderers/common/RenderObject.js +47 -5
- package/examples/jsm/renderers/common/RenderObjects.js +1 -1
- package/examples/jsm/renderers/common/Renderer.js +153 -21
- package/examples/jsm/renderers/common/Textures.js +1 -1
- package/examples/jsm/renderers/common/extras/PMREMGenerator.js +773 -0
- package/examples/jsm/renderers/common/nodes/Nodes.js +34 -63
- package/examples/jsm/renderers/webgl/WebGLBackend.js +146 -36
- package/examples/jsm/renderers/webgl/WebGLBufferRenderer.js +145 -0
- package/examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js +9 -3
- package/examples/jsm/renderers/webgl/utils/WebGLAttributeUtils.js +1 -1
- package/examples/jsm/renderers/webgl/utils/WebGLConstants.js +1 -0
- package/examples/jsm/renderers/webgl/utils/WebGLTextureUtils.js +64 -7
- package/examples/jsm/renderers/webgl/utils/WebGLUtils.js +6 -23
- package/examples/jsm/renderers/webgpu/WebGPUBackend.js +77 -60
- package/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js +21 -4
- package/examples/jsm/renderers/webgpu/utils/WebGPUAttributeUtils.js +29 -1
- package/examples/jsm/renderers/webgpu/utils/WebGPUBindingUtils.js +18 -4
- package/examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js +92 -18
- package/examples/jsm/transpiler/GLSLDecoder.js +1 -1
- package/examples/jsm/transpiler/ShaderToyDecoder.js +1 -1
- package/examples/jsm/utils/GPUStatsPanel.js +10 -45
- package/examples/jsm/utils/SceneUtils.js +60 -1
- package/examples/jsm/utils/TextureUtils.js +1 -1
- package/examples/jsm/webxr/OculusHandModel.js +3 -2
- package/examples/jsm/webxr/XRHandModelFactory.js +4 -2
- package/package.json +1 -1
- package/src/Three.js +0 -1
- package/src/animation/AnimationClip.js +1 -1
- package/src/constants.js +3 -3
- package/src/core/Object3D.js +10 -7
- package/src/core/RenderTarget.js +8 -0
- package/src/extras/PMREMGenerator.js +21 -11
- package/src/loaders/FileLoader.js +1 -1
- package/src/loaders/MaterialLoader.js +1 -0
- package/src/loaders/ObjectLoader.js +2 -0
- package/src/materials/Material.js +2 -0
- package/src/materials/MeshPhysicalMaterial.js +20 -0
- package/src/materials/ShaderMaterial.js +0 -4
- package/src/math/Spherical.js +4 -5
- package/src/objects/BatchedMesh.js +27 -3
- package/src/objects/InstancedMesh.js +10 -0
- package/src/objects/Line.js +66 -43
- package/src/renderers/WebGLRenderer.js +130 -158
- package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +6 -0
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +1 -0
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_fragment.glsl.js +2 -2
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_vertex.glsl.js +2 -10
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_vertex.glsl.js +2 -16
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +32 -22
- package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +17 -9
- package/src/renderers/shaders/ShaderChunk/transmission_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/transmission_pars_fragment.glsl.js +47 -13
- package/src/renderers/shaders/ShaderChunk.js +0 -2
- package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +4 -0
- package/src/renderers/shaders/ShaderLib.js +2 -1
- package/src/renderers/shaders/UniformsUtils.js +10 -1
- package/src/renderers/webgl/WebGLAttributes.js +6 -33
- package/src/renderers/webgl/WebGLBackground.js +18 -3
- package/src/renderers/webgl/WebGLBindingStates.js +14 -51
- package/src/renderers/webgl/WebGLBufferRenderer.js +35 -21
- package/src/renderers/webgl/WebGLCapabilities.js +35 -13
- package/src/renderers/webgl/WebGLCubeUVMaps.js +10 -6
- package/src/renderers/webgl/WebGLExtensions.js +4 -19
- package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +35 -21
- package/src/renderers/webgl/WebGLLights.js +6 -32
- package/src/renderers/webgl/WebGLMaterials.js +8 -3
- package/src/renderers/webgl/WebGLMorphtargets.js +79 -217
- package/src/renderers/webgl/WebGLProgram.js +21 -52
- package/src/renderers/webgl/WebGLPrograms.js +24 -31
- package/src/renderers/webgl/WebGLRenderStates.js +13 -7
- package/src/renderers/webgl/WebGLShadowMap.js +25 -25
- package/src/renderers/webgl/WebGLState.js +15 -59
- package/src/renderers/webgl/WebGLTextures.js +138 -292
- package/src/renderers/webgl/WebGLUniformsGroups.js +1 -1
- package/src/renderers/webgl/WebGLUtils.js +9 -78
- package/src/renderers/webxr/WebXRDepthSensing.js +2 -3
- package/src/renderers/webxr/WebXRManager.js +4 -6
- package/src/scenes/Scene.js +7 -1
- package/src/textures/Texture.js +11 -1
- package/examples/jsm/nodes/utils/SpecularMIPLevelNode.js +0 -37
- package/examples/jsm/renderers/webgl-legacy/nodes/GLSL1NodeBuilder.js +0 -320
- package/examples/jsm/renderers/webgl-legacy/nodes/SlotNode.js +0 -26
- package/examples/jsm/renderers/webgl-legacy/nodes/WebGLNodeBuilder.js +0 -794
- package/examples/jsm/renderers/webgl-legacy/nodes/WebGLNodes.js +0 -51
- package/src/renderers/WebGL1Renderer.js +0 -7
- package/src/renderers/shaders/ShaderChunk/lightmap_fragment.glsl.js +0 -10
|
@@ -14,3 +14,4 @@ export { default as MeshPhysicalNodeMaterial } from './MeshPhysicalNodeMaterial.
|
|
|
14
14
|
export { default as MeshSSSNodeMaterial } from './MeshSSSNodeMaterial.js';
|
|
15
15
|
export { default as PointsNodeMaterial } from './PointsNodeMaterial.js';
|
|
16
16
|
export { default as SpriteNodeMaterial } from './SpriteNodeMaterial.js';
|
|
17
|
+
export { default as ShadowNodeMaterial } from './ShadowNodeMaterial.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import NodeMaterial, { addNodeMaterial } from './NodeMaterial.js';
|
|
2
2
|
import { shininess, specularColor } from '../core/PropertyNode.js';
|
|
3
|
-
import { materialShininess,
|
|
3
|
+
import { materialShininess, materialSpecular } from '../accessors/MaterialNode.js';
|
|
4
4
|
import { float } from '../shadernode/ShaderNode.js';
|
|
5
5
|
import PhongLightingModel from '../functions/PhongLightingModel.js';
|
|
6
6
|
|
|
@@ -43,7 +43,7 @@ class MeshPhongNodeMaterial extends NodeMaterial {
|
|
|
43
43
|
|
|
44
44
|
// SPECULAR COLOR
|
|
45
45
|
|
|
46
|
-
const specularNode = this.specularNode ||
|
|
46
|
+
const specularNode = this.specularNode || materialSpecular;
|
|
47
47
|
|
|
48
48
|
specularColor.assign( specularNode );
|
|
49
49
|
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { addNodeMaterial } from './NodeMaterial.js';
|
|
2
2
|
import { transformedClearcoatNormalView } from '../accessors/NormalNode.js';
|
|
3
|
-
import { clearcoat, clearcoatRoughness, sheen, sheenRoughness, iridescence, iridescenceIOR, iridescenceThickness } from '../core/PropertyNode.js';
|
|
4
|
-
import { materialClearcoat, materialClearcoatRoughness, materialClearcoatNormal, materialSheen, materialSheenRoughness, materialIridescence, materialIridescenceIOR, materialIridescenceThickness } from '../accessors/MaterialNode.js';
|
|
5
|
-
import { float, vec3 } from '../shadernode/ShaderNode.js';
|
|
3
|
+
import { clearcoat, clearcoatRoughness, sheen, sheenRoughness, iridescence, iridescenceIOR, iridescenceThickness, specularColor, specularF90, diffuseColor, metalness, roughness, anisotropy, alphaT, anisotropyT, anisotropyB, ior, transmission, thickness, attenuationDistance, attenuationColor } from '../core/PropertyNode.js';
|
|
4
|
+
import { materialClearcoat, materialClearcoatRoughness, materialClearcoatNormal, materialSheen, materialSheenRoughness, materialIridescence, materialIridescenceIOR, materialIridescenceThickness, materialSpecularIntensity, materialSpecularColor, materialAnisotropy, materialIOR, materialTransmission, materialThickness, materialAttenuationDistance, materialAttenuationColor } from '../accessors/MaterialNode.js';
|
|
5
|
+
import { float, vec2, vec3, If } from '../shadernode/ShaderNode.js';
|
|
6
|
+
import { TBNViewMatrix } from '../accessors/AccessorsUtils.js';
|
|
6
7
|
import PhysicalLightingModel from '../functions/PhysicalLightingModel.js';
|
|
7
8
|
import MeshStandardNodeMaterial from './MeshStandardNodeMaterial.js';
|
|
8
|
-
|
|
9
|
+
import { mix, pow2, min } from '../math/MathNode.js';
|
|
9
10
|
import { MeshPhysicalMaterial } from 'three';
|
|
10
11
|
|
|
11
12
|
const defaultValues = new MeshPhysicalMaterial();
|
|
@@ -32,11 +33,14 @@ class MeshPhysicalNodeMaterial extends MeshStandardNodeMaterial {
|
|
|
32
33
|
this.specularIntensityNode = null;
|
|
33
34
|
this.specularColorNode = null;
|
|
34
35
|
|
|
36
|
+
this.iorNode = null;
|
|
35
37
|
this.transmissionNode = null;
|
|
36
38
|
this.thicknessNode = null;
|
|
37
39
|
this.attenuationDistanceNode = null;
|
|
38
40
|
this.attenuationColorNode = null;
|
|
39
41
|
|
|
42
|
+
this.anisotropyNode = null;
|
|
43
|
+
|
|
40
44
|
this.setDefaultValues( defaultValues );
|
|
41
45
|
|
|
42
46
|
this.setValues( parameters );
|
|
@@ -61,9 +65,31 @@ class MeshPhysicalNodeMaterial extends MeshStandardNodeMaterial {
|
|
|
61
65
|
|
|
62
66
|
}
|
|
63
67
|
|
|
68
|
+
get useAnisotropy() {
|
|
69
|
+
|
|
70
|
+
return this.anisotropy > 0 || this.anisotropyNode !== null;
|
|
71
|
+
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
get useTransmission() {
|
|
75
|
+
|
|
76
|
+
return this.transmission > 0 || this.transmissionNode !== null;
|
|
77
|
+
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
setupSpecular() {
|
|
81
|
+
|
|
82
|
+
const iorNode = this.iorNode ? float( this.iorNode ) : materialIOR;
|
|
83
|
+
|
|
84
|
+
ior.assign( iorNode );
|
|
85
|
+
specularColor.assign( mix( min( pow2( ior.sub( 1.0 ).div( ior.add( 1.0 ) ) ).mul( materialSpecularColor ), vec3( 1.0 ) ).mul( materialSpecularIntensity ), diffuseColor.rgb, metalness ) );
|
|
86
|
+
specularF90.assign( mix( materialSpecularIntensity, 1.0, metalness ) );
|
|
87
|
+
|
|
88
|
+
}
|
|
89
|
+
|
|
64
90
|
setupLightingModel( /*builder*/ ) {
|
|
65
91
|
|
|
66
|
-
return new PhysicalLightingModel( this.useClearcoat, this.useSheen, this.useIridescence );
|
|
92
|
+
return new PhysicalLightingModel( this.useClearcoat, this.useSheen, this.useIridescence, this.useAnisotropy, this.useTransmission );
|
|
67
93
|
|
|
68
94
|
}
|
|
69
95
|
|
|
@@ -109,6 +135,49 @@ class MeshPhysicalNodeMaterial extends MeshStandardNodeMaterial {
|
|
|
109
135
|
|
|
110
136
|
}
|
|
111
137
|
|
|
138
|
+
// ANISOTROPY
|
|
139
|
+
|
|
140
|
+
if ( this.useAnisotropy ) {
|
|
141
|
+
|
|
142
|
+
const anisotropyV = ( this.anisotropyNode ? vec2( this.anisotropyNode ) : materialAnisotropy ).toVar();
|
|
143
|
+
|
|
144
|
+
anisotropy.assign( anisotropyV.length() );
|
|
145
|
+
|
|
146
|
+
If( anisotropy.equal( 0.0 ), () => {
|
|
147
|
+
|
|
148
|
+
anisotropyV.assign( vec2( 1.0, 0.0 ) );
|
|
149
|
+
|
|
150
|
+
} ).else( () => {
|
|
151
|
+
|
|
152
|
+
anisotropyV.divAssign( anisotropy );
|
|
153
|
+
anisotropy.assign( anisotropy.saturate() );
|
|
154
|
+
|
|
155
|
+
} );
|
|
156
|
+
|
|
157
|
+
// Roughness along the anisotropy bitangent is the material roughness, while the tangent roughness increases with anisotropy.
|
|
158
|
+
alphaT.assign( anisotropy.pow2().mix( roughness.pow2(), 1.0 ) );
|
|
159
|
+
|
|
160
|
+
anisotropyT.assign( TBNViewMatrix[ 0 ].mul( anisotropyV.x ).add( TBNViewMatrix[ 1 ].mul( anisotropyV.y ) ) );
|
|
161
|
+
anisotropyB.assign( TBNViewMatrix[ 1 ].mul( anisotropyV.x ).sub( TBNViewMatrix[ 0 ].mul( anisotropyV.y ) ) );
|
|
162
|
+
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// TRANSMISSION
|
|
166
|
+
|
|
167
|
+
if ( this.useTransmission ) {
|
|
168
|
+
|
|
169
|
+
const transmissionNode = this.transmissionNode ? float( this.transmissionNode ) : materialTransmission;
|
|
170
|
+
const thicknessNode = this.thicknessNode ? float( this.thicknessNode ) : materialThickness;
|
|
171
|
+
const attenuationDistanceNode = this.attenuationDistanceNode ? float( this.attenuationDistanceNode ) : materialAttenuationDistance;
|
|
172
|
+
const attenuationColorNode = this.attenuationColorNode ? vec3( this.attenuationColorNode ) : materialAttenuationColor;
|
|
173
|
+
|
|
174
|
+
transmission.assign( transmissionNode );
|
|
175
|
+
thickness.assign( thicknessNode );
|
|
176
|
+
attenuationDistance.assign( attenuationDistanceNode );
|
|
177
|
+
attenuationColor.assign( attenuationColorNode );
|
|
178
|
+
|
|
179
|
+
}
|
|
180
|
+
|
|
112
181
|
}
|
|
113
182
|
|
|
114
183
|
setupNormal( builder ) {
|
|
@@ -144,6 +213,8 @@ class MeshPhysicalNodeMaterial extends MeshStandardNodeMaterial {
|
|
|
144
213
|
this.attenuationDistanceNode = source.attenuationDistanceNode;
|
|
145
214
|
this.attenuationColorNode = source.attenuationColorNode;
|
|
146
215
|
|
|
216
|
+
this.anisotropyNode = source.anisotropyNode;
|
|
217
|
+
|
|
147
218
|
return super.copy( source );
|
|
148
219
|
|
|
149
220
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import NodeMaterial, { addNodeMaterial } from './NodeMaterial.js';
|
|
2
|
-
import { diffuseColor, metalness, roughness, specularColor } from '../core/PropertyNode.js';
|
|
2
|
+
import { diffuseColor, metalness, roughness, specularColor, specularF90 } from '../core/PropertyNode.js';
|
|
3
3
|
import { mix } from '../math/MathNode.js';
|
|
4
4
|
import { materialRoughness, materialMetalness } from '../accessors/MaterialNode.js';
|
|
5
5
|
import getRoughness from '../functions/material/getRoughness.js';
|
|
@@ -35,6 +35,15 @@ class MeshStandardNodeMaterial extends NodeMaterial {
|
|
|
35
35
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
+
setupSpecular() {
|
|
39
|
+
|
|
40
|
+
const specularColorNode = mix( vec3( 0.04 ), diffuseColor.rgb, metalness );
|
|
41
|
+
|
|
42
|
+
specularColor.assign( specularColorNode );
|
|
43
|
+
specularF90.assign( 1.0 );
|
|
44
|
+
|
|
45
|
+
}
|
|
46
|
+
|
|
38
47
|
setupVariants() {
|
|
39
48
|
|
|
40
49
|
// METALNESS
|
|
@@ -52,9 +61,7 @@ class MeshStandardNodeMaterial extends NodeMaterial {
|
|
|
52
61
|
|
|
53
62
|
// SPECULAR COLOR
|
|
54
63
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
specularColor.assign( specularColorNode );
|
|
64
|
+
this.setupSpecular();
|
|
58
65
|
|
|
59
66
|
// DIFFUSE COLOR
|
|
60
67
|
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import { Material, ShaderMaterial
|
|
1
|
+
import { Material, ShaderMaterial } from 'three';
|
|
2
2
|
import { getNodeChildren, getCacheKey } from '../core/NodeUtils.js';
|
|
3
3
|
import { attribute } from '../core/AttributeNode.js';
|
|
4
|
-
import { output, diffuseColor } from '../core/PropertyNode.js';
|
|
4
|
+
import { output, diffuseColor, varyingProperty } from '../core/PropertyNode.js';
|
|
5
5
|
import { materialAlphaTest, materialColor, materialOpacity, materialEmissive, materialNormal } from '../accessors/MaterialNode.js';
|
|
6
6
|
import { modelViewProjection } from '../accessors/ModelViewProjectionNode.js';
|
|
7
7
|
import { transformedNormalView } from '../accessors/NormalNode.js';
|
|
8
8
|
import { instance } from '../accessors/InstanceNode.js';
|
|
9
|
+
import { batch } from '../accessors/BatchNode.js';
|
|
10
|
+
import { materialReference } from '../accessors/MaterialReferenceNode.js';
|
|
9
11
|
import { positionLocal, positionView } from '../accessors/PositionNode.js';
|
|
10
12
|
import { skinningReference } from '../accessors/SkinningNode.js';
|
|
11
13
|
import { morphReference } from '../accessors/MorphNode.js';
|
|
@@ -17,6 +19,7 @@ import { float, vec3, vec4 } from '../shadernode/ShaderNode.js';
|
|
|
17
19
|
import AONode from '../lighting/AONode.js';
|
|
18
20
|
import { lightingContext } from '../lighting/LightingContextNode.js';
|
|
19
21
|
import EnvironmentNode from '../lighting/EnvironmentNode.js';
|
|
22
|
+
import IrradianceNode from '../lighting/IrradianceNode.js';
|
|
20
23
|
import { depthPixel } from '../display/ViewportDepthNode.js';
|
|
21
24
|
import { cameraLogDepth } from '../accessors/CameraNode.js';
|
|
22
25
|
import { clipping, clippingAlpha } from '../accessors/ClippingNode.js';
|
|
@@ -40,10 +43,9 @@ class NodeMaterial extends ShaderMaterial {
|
|
|
40
43
|
this.lights = true;
|
|
41
44
|
this.normals = true;
|
|
42
45
|
|
|
43
|
-
this.colorSpaced = true;
|
|
44
|
-
|
|
45
46
|
this.lightsNode = null;
|
|
46
47
|
this.envNode = null;
|
|
48
|
+
this.aoNode = null;
|
|
47
49
|
|
|
48
50
|
this.colorNode = null;
|
|
49
51
|
this.normalNode = null;
|
|
@@ -56,6 +58,7 @@ class NodeMaterial extends ShaderMaterial {
|
|
|
56
58
|
|
|
57
59
|
this.depthNode = null;
|
|
58
60
|
this.shadowNode = null;
|
|
61
|
+
this.shadowPositionNode = null;
|
|
59
62
|
|
|
60
63
|
this.outputNode = null;
|
|
61
64
|
|
|
@@ -94,9 +97,9 @@ class NodeMaterial extends ShaderMaterial {
|
|
|
94
97
|
|
|
95
98
|
const clippingNode = this.setupClipping( builder );
|
|
96
99
|
|
|
97
|
-
if ( this.
|
|
100
|
+
if ( this.depthWrite === true ) this.setupDepth( builder );
|
|
98
101
|
|
|
99
|
-
|
|
102
|
+
if ( this.fragmentNode === null ) {
|
|
100
103
|
|
|
101
104
|
if ( this.normals === true ) this.setupNormal( builder );
|
|
102
105
|
|
|
@@ -107,7 +110,11 @@ class NodeMaterial extends ShaderMaterial {
|
|
|
107
110
|
|
|
108
111
|
if ( clippingNode !== null ) builder.stack.add( clippingNode );
|
|
109
112
|
|
|
110
|
-
|
|
113
|
+
// force unsigned floats - useful for RenderTargets
|
|
114
|
+
|
|
115
|
+
const basicOutput = vec4( outgoingLightNode, diffuseColor.a ).max( 0 );
|
|
116
|
+
|
|
117
|
+
resultNode = this.setupOutput( builder, basicOutput );
|
|
111
118
|
|
|
112
119
|
// OUTPUT NODE
|
|
113
120
|
|
|
@@ -119,7 +126,15 @@ class NodeMaterial extends ShaderMaterial {
|
|
|
119
126
|
|
|
120
127
|
} else {
|
|
121
128
|
|
|
122
|
-
|
|
129
|
+
let fragmentNode = this.fragmentNode;
|
|
130
|
+
|
|
131
|
+
if ( fragmentNode.isOutputStructNode !== true ) {
|
|
132
|
+
|
|
133
|
+
fragmentNode = vec4( fragmentNode );
|
|
134
|
+
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
resultNode = this.setupOutput( builder, fragmentNode );
|
|
123
138
|
|
|
124
139
|
}
|
|
125
140
|
|
|
@@ -131,6 +146,8 @@ class NodeMaterial extends ShaderMaterial {
|
|
|
131
146
|
|
|
132
147
|
setupClipping( builder ) {
|
|
133
148
|
|
|
149
|
+
if ( builder.clippingContext === null ) return null;
|
|
150
|
+
|
|
134
151
|
const { globalClippingCount, localClippingCount } = builder.clippingContext;
|
|
135
152
|
|
|
136
153
|
let result = null;
|
|
@@ -199,6 +216,12 @@ class NodeMaterial extends ShaderMaterial {
|
|
|
199
216
|
|
|
200
217
|
}
|
|
201
218
|
|
|
219
|
+
if ( object.isBatchedMesh ) {
|
|
220
|
+
|
|
221
|
+
batch( object ).append();
|
|
222
|
+
|
|
223
|
+
}
|
|
224
|
+
|
|
202
225
|
if ( ( object.instanceMatrix && object.instanceMatrix.isInstancedBufferAttribute === true ) && builder.isAvailable( 'instance' ) === true ) {
|
|
203
226
|
|
|
204
227
|
instance( object ).append();
|
|
@@ -220,7 +243,7 @@ class NodeMaterial extends ShaderMaterial {
|
|
|
220
243
|
|
|
221
244
|
}
|
|
222
245
|
|
|
223
|
-
setupDiffuseColor( { geometry } ) {
|
|
246
|
+
setupDiffuseColor( { object, geometry } ) {
|
|
224
247
|
|
|
225
248
|
let colorNode = this.colorNode ? vec4( this.colorNode ) : materialColor;
|
|
226
249
|
|
|
@@ -232,6 +255,16 @@ class NodeMaterial extends ShaderMaterial {
|
|
|
232
255
|
|
|
233
256
|
}
|
|
234
257
|
|
|
258
|
+
// Instanced colors
|
|
259
|
+
|
|
260
|
+
if ( object.instanceColor ) {
|
|
261
|
+
|
|
262
|
+
const instanceColor = varyingProperty( 'vec3', 'vInstanceColor' );
|
|
263
|
+
|
|
264
|
+
colorNode = instanceColor.mul( colorNode );
|
|
265
|
+
|
|
266
|
+
}
|
|
267
|
+
|
|
235
268
|
// COLOR
|
|
236
269
|
|
|
237
270
|
diffuseColor.assign( colorNode );
|
|
@@ -315,9 +348,17 @@ class NodeMaterial extends ShaderMaterial {
|
|
|
315
348
|
|
|
316
349
|
}
|
|
317
350
|
|
|
318
|
-
if ( builder.material.
|
|
351
|
+
if ( builder.material.lightMap ) {
|
|
319
352
|
|
|
320
|
-
materialLightsNode.push( new
|
|
353
|
+
materialLightsNode.push( new IrradianceNode( materialReference( 'lightMap', 'texture' ) ) );
|
|
354
|
+
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
if ( this.aoNode !== null || builder.material.aoMap ) {
|
|
358
|
+
|
|
359
|
+
const aoNode = this.aoNode !== null ? this.aoNode : texture( builder.material.aoMap );
|
|
360
|
+
|
|
361
|
+
materialLightsNode.push( new AONode( aoNode ) );
|
|
321
362
|
|
|
322
363
|
}
|
|
323
364
|
|
|
@@ -378,41 +419,11 @@ class NodeMaterial extends ShaderMaterial {
|
|
|
378
419
|
|
|
379
420
|
setupOutput( builder, outputNode ) {
|
|
380
421
|
|
|
381
|
-
const renderer = builder.renderer;
|
|
382
|
-
|
|
383
|
-
// TONE MAPPING
|
|
384
|
-
|
|
385
|
-
const toneMappingNode = builder.toneMappingNode;
|
|
386
|
-
|
|
387
|
-
if ( this.toneMapped === true && toneMappingNode ) {
|
|
388
|
-
|
|
389
|
-
outputNode = vec4( toneMappingNode.context( { color: outputNode.rgb } ), outputNode.a );
|
|
390
|
-
|
|
391
|
-
}
|
|
392
|
-
|
|
393
422
|
// FOG
|
|
394
423
|
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
const fogNode = builder.fogNode;
|
|
424
|
+
const fogNode = builder.fogNode;
|
|
398
425
|
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
// ENCODING
|
|
404
|
-
|
|
405
|
-
if ( this.colorSpaced === true ) {
|
|
406
|
-
|
|
407
|
-
const outputColorSpace = renderer.currentColorSpace;
|
|
408
|
-
|
|
409
|
-
if ( outputColorSpace !== LinearSRGBColorSpace && outputColorSpace !== NoColorSpace ) {
|
|
410
|
-
|
|
411
|
-
outputNode = outputNode.linearToColorSpace( outputColorSpace );
|
|
412
|
-
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
}
|
|
426
|
+
if ( fogNode ) outputNode = vec4( fogNode.mix( outputNode.rgb, fogNode.colorNode ), outputNode.a );
|
|
416
427
|
|
|
417
428
|
return outputNode;
|
|
418
429
|
|
|
@@ -529,6 +540,7 @@ class NodeMaterial extends ShaderMaterial {
|
|
|
529
540
|
|
|
530
541
|
this.depthNode = source.depthNode;
|
|
531
542
|
this.shadowNode = source.shadowNode;
|
|
543
|
+
this.shadowPositionNode = source.shadowPositionNode;
|
|
532
544
|
|
|
533
545
|
this.outputNode = source.outputNode;
|
|
534
546
|
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import NodeMaterial, { addNodeMaterial } from './NodeMaterial.js';
|
|
2
|
+
import ShadowMaskModel from '../functions/ShadowMaskModel.js';
|
|
3
|
+
|
|
4
|
+
import { ShadowMaterial } from 'three';
|
|
5
|
+
|
|
6
|
+
const defaultValues = new ShadowMaterial();
|
|
7
|
+
|
|
8
|
+
class ShadowNodeMaterial extends NodeMaterial {
|
|
9
|
+
|
|
10
|
+
constructor( parameters ) {
|
|
11
|
+
|
|
12
|
+
super();
|
|
13
|
+
|
|
14
|
+
this.isShadowNodeMaterial = true;
|
|
15
|
+
|
|
16
|
+
this.lights = true;
|
|
17
|
+
|
|
18
|
+
this.setDefaultValues( defaultValues );
|
|
19
|
+
|
|
20
|
+
this.setValues( parameters );
|
|
21
|
+
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
setupLightingModel( /*builder*/ ) {
|
|
25
|
+
|
|
26
|
+
return new ShadowMaskModel();
|
|
27
|
+
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export default ShadowNodeMaterial;
|
|
33
|
+
|
|
34
|
+
addNodeMaterial( 'ShadowNodeMaterial', ShadowNodeMaterial );
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import TempNode from '../core/TempNode.js';
|
|
2
|
+
import { addNodeClass } from '../core/Node.js';
|
|
3
|
+
import { texture } from '../accessors/TextureNode.js';
|
|
4
|
+
import { textureCubeUV } from './PMREMUtils.js';
|
|
5
|
+
import { uniform } from '../core/UniformNode.js';
|
|
6
|
+
import { NodeUpdateType } from '../core/constants.js';
|
|
7
|
+
import { nodeProxy, vec3 } from '../shadernode/ShaderNode.js';
|
|
8
|
+
import { WebGLCoordinateSystem } from 'three';
|
|
9
|
+
|
|
10
|
+
let _generator = null;
|
|
11
|
+
|
|
12
|
+
const _cache = new WeakMap();
|
|
13
|
+
|
|
14
|
+
function _generateCubeUVSize( imageHeight ) {
|
|
15
|
+
|
|
16
|
+
const maxMip = Math.log2( imageHeight ) - 2;
|
|
17
|
+
|
|
18
|
+
const texelHeight = 1.0 / imageHeight;
|
|
19
|
+
|
|
20
|
+
const texelWidth = 1.0 / ( 3 * Math.max( Math.pow( 2, maxMip ), 7 * 16 ) );
|
|
21
|
+
|
|
22
|
+
return { texelWidth, texelHeight, maxMip };
|
|
23
|
+
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function _getPMREMFromTexture( texture ) {
|
|
27
|
+
|
|
28
|
+
let cacheTexture = _cache.get( texture );
|
|
29
|
+
|
|
30
|
+
const pmremVersion = cacheTexture !== undefined ? cacheTexture.pmremVersion : - 1;
|
|
31
|
+
|
|
32
|
+
if ( pmremVersion !== texture.pmremVersion ) {
|
|
33
|
+
|
|
34
|
+
if ( texture.isCubeTexture ) {
|
|
35
|
+
|
|
36
|
+
if ( texture.source.data.some( ( texture ) => texture === undefined ) ) {
|
|
37
|
+
|
|
38
|
+
throw new Error( 'PMREMNode: Undefined texture in CubeTexture. Use onLoad callback or async loader' );
|
|
39
|
+
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
cacheTexture = _generator.fromCubemap( texture, cacheTexture );
|
|
43
|
+
|
|
44
|
+
} else {
|
|
45
|
+
|
|
46
|
+
if ( texture.image === undefined ) {
|
|
47
|
+
|
|
48
|
+
throw new Error( 'PMREMNode: Undefined image in Texture. Use onLoad callback or async loader' );
|
|
49
|
+
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
cacheTexture = _generator.fromEquirectangular( texture, cacheTexture );
|
|
53
|
+
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
cacheTexture.pmremVersion = texture.pmremVersion;
|
|
57
|
+
|
|
58
|
+
_cache.set( texture, cacheTexture );
|
|
59
|
+
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return cacheTexture.texture;
|
|
63
|
+
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
class PMREMNode extends TempNode {
|
|
67
|
+
|
|
68
|
+
constructor( value, uvNode = null, levelNode = null ) {
|
|
69
|
+
|
|
70
|
+
super( 'vec3' );
|
|
71
|
+
|
|
72
|
+
this._value = value;
|
|
73
|
+
this._pmrem = null;
|
|
74
|
+
|
|
75
|
+
this.uvNode = uvNode;
|
|
76
|
+
this.levelNode = levelNode;
|
|
77
|
+
|
|
78
|
+
this._generator = null;
|
|
79
|
+
this._texture = texture( null );
|
|
80
|
+
this._width = uniform( 0 );
|
|
81
|
+
this._height = uniform( 0 );
|
|
82
|
+
this._maxMip = uniform( 0 );
|
|
83
|
+
|
|
84
|
+
this.updateBeforeType = NodeUpdateType.RENDER;
|
|
85
|
+
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
set value( value ) {
|
|
89
|
+
|
|
90
|
+
this._value = value;
|
|
91
|
+
this._pmrem = null;
|
|
92
|
+
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
get value() {
|
|
96
|
+
|
|
97
|
+
return this._value;
|
|
98
|
+
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
updateFromTexture( texture ) {
|
|
102
|
+
|
|
103
|
+
const cubeUVSize = _generateCubeUVSize( texture.image.height );
|
|
104
|
+
|
|
105
|
+
this._texture.value = texture;
|
|
106
|
+
this._width.value = cubeUVSize.texelWidth;
|
|
107
|
+
this._height.value = cubeUVSize.texelHeight;
|
|
108
|
+
this._maxMip.value = cubeUVSize.maxMip;
|
|
109
|
+
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
updateBefore() {
|
|
113
|
+
|
|
114
|
+
let pmrem = this._pmrem;
|
|
115
|
+
|
|
116
|
+
const pmremVersion = pmrem ? pmrem.pmremVersion : - 1;
|
|
117
|
+
const texture = this._value;
|
|
118
|
+
|
|
119
|
+
if ( pmremVersion !== texture.pmremVersion ) {
|
|
120
|
+
|
|
121
|
+
if ( texture.isPMREMTexture === true ) {
|
|
122
|
+
|
|
123
|
+
pmrem = texture;
|
|
124
|
+
|
|
125
|
+
} else {
|
|
126
|
+
|
|
127
|
+
pmrem = _getPMREMFromTexture( texture );
|
|
128
|
+
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
this._pmrem = pmrem;
|
|
132
|
+
|
|
133
|
+
this.updateFromTexture( pmrem );
|
|
134
|
+
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
setup( builder ) {
|
|
140
|
+
|
|
141
|
+
if ( _generator === null ) {
|
|
142
|
+
|
|
143
|
+
_generator = builder.createPMREMGenerator();
|
|
144
|
+
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
//
|
|
148
|
+
|
|
149
|
+
this.updateBefore( builder );
|
|
150
|
+
|
|
151
|
+
//
|
|
152
|
+
|
|
153
|
+
let uvNode = this.uvNode;
|
|
154
|
+
|
|
155
|
+
if ( uvNode === null && builder.context.getUV ) {
|
|
156
|
+
|
|
157
|
+
uvNode = builder.context.getUV( this );
|
|
158
|
+
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
//
|
|
162
|
+
|
|
163
|
+
const texture = this.value;
|
|
164
|
+
|
|
165
|
+
if ( builder.renderer.coordinateSystem === WebGLCoordinateSystem && texture.isPMREMTexture !== true && texture.isRenderTargetTexture === true ) {
|
|
166
|
+
|
|
167
|
+
uvNode = vec3( uvNode.x.negate(), uvNode.yz );
|
|
168
|
+
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
//
|
|
172
|
+
|
|
173
|
+
let levelNode = this.levelNode;
|
|
174
|
+
|
|
175
|
+
if ( levelNode === null && builder.context.getTextureLevel ) {
|
|
176
|
+
|
|
177
|
+
levelNode = builder.context.getTextureLevel( this );
|
|
178
|
+
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
//
|
|
182
|
+
|
|
183
|
+
return textureCubeUV( this._texture, uvNode, levelNode, this._width, this._height, this._maxMip );
|
|
184
|
+
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
export const pmremTexture = nodeProxy( PMREMNode );
|
|
190
|
+
|
|
191
|
+
addNodeClass( 'PMREMNode', PMREMNode );
|
|
192
|
+
|
|
193
|
+
export default PMREMNode;
|