super-three 0.154.0 → 0.155.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 +257 -40
- package/build/three.js +257 -40
- package/build/three.min.js +1 -2
- package/build/three.module.js +256 -41
- package/build/three.module.min.js +1 -2
- package/examples/jsm/controls/OrbitControls.js +143 -21
- package/examples/jsm/environments/RoomEnvironment.js +1 -1
- package/examples/jsm/exporters/USDZExporter.js +1 -0
- package/examples/jsm/interactive/SelectionHelper.js +7 -0
- package/examples/jsm/loaders/FBXLoader.js +1 -1
- package/examples/jsm/loaders/GLTFLoader.js +8 -3
- package/examples/jsm/loaders/KTX2Loader.js +4 -4
- package/examples/jsm/loaders/LDrawLoader.js +1 -1
- package/examples/jsm/loaders/NRRDLoader.js +3 -3
- package/examples/jsm/loaders/PLYLoader.js +1 -1
- package/examples/jsm/loaders/TGALoader.js +10 -10
- package/examples/jsm/loaders/VRMLLoader.js +1 -1
- package/examples/jsm/misc/GPUComputationRenderer.js +0 -9
- package/examples/jsm/misc/Volume.js +4 -6
- package/examples/jsm/nodes/Nodes.js +5 -6
- package/examples/jsm/nodes/accessors/BufferAttributeNode.js +1 -1
- package/examples/jsm/nodes/accessors/CubeTextureNode.js +2 -0
- package/examples/jsm/nodes/accessors/ExtendedMaterialNode.js +14 -1
- package/examples/jsm/nodes/accessors/InstanceNode.js +8 -8
- package/examples/jsm/nodes/accessors/MaterialNode.js +34 -44
- package/examples/jsm/nodes/accessors/SceneNode.js +6 -0
- package/examples/jsm/nodes/accessors/TextureNode.js +48 -7
- package/examples/jsm/nodes/core/LightingModel.js +7 -9
- package/examples/jsm/nodes/core/Node.js +11 -2
- package/examples/jsm/nodes/core/PropertyNode.js +4 -0
- package/examples/jsm/nodes/display/BumpMapNode.js +77 -0
- package/examples/jsm/nodes/display/NormalMapNode.js +2 -2
- package/examples/jsm/nodes/functions/BSDF/BRDF_GGX.js +10 -2
- package/examples/jsm/nodes/functions/BSDF/Schlick_to_F0.js +13 -0
- package/examples/jsm/nodes/functions/PhongLightingModel.js +53 -14
- package/examples/jsm/nodes/functions/PhysicalLightingModel.js +236 -97
- package/examples/jsm/nodes/geometry/RangeNode.js +2 -2
- package/examples/jsm/nodes/gpgpu/ComputeNode.js +13 -0
- package/examples/jsm/nodes/lighting/AONode.js +1 -1
- package/examples/jsm/nodes/lighting/AnalyticLightNode.js +58 -20
- package/examples/jsm/nodes/lighting/DirectionalLightNode.js +7 -10
- package/examples/jsm/nodes/lighting/EnvironmentNode.js +22 -12
- package/examples/jsm/nodes/lighting/HemisphereLightNode.js +1 -1
- package/examples/jsm/nodes/lighting/LightingContextNode.js +12 -9
- package/examples/jsm/nodes/lighting/PointLightNode.js +7 -10
- package/examples/jsm/nodes/lighting/SpotLightNode.js +7 -10
- package/examples/jsm/nodes/materials/Materials.js +1 -0
- package/examples/jsm/nodes/materials/MeshLambertNodeMaterial.js +34 -0
- package/examples/jsm/nodes/materials/MeshNormalNodeMaterial.js +2 -0
- package/examples/jsm/nodes/materials/MeshPhongNodeMaterial.js +2 -2
- package/examples/jsm/nodes/materials/MeshPhysicalNodeMaterial.js +19 -2
- package/examples/jsm/nodes/materials/MeshStandardNodeMaterial.js +2 -2
- package/examples/jsm/nodes/materials/NodeMaterial.js +50 -24
- package/examples/jsm/nodes/materials/SpriteNodeMaterial.js +2 -2
- package/examples/jsm/nodes/shadernode/ShaderNode.js +2 -2
- package/examples/jsm/objects/Reflector.js +1 -9
- package/examples/jsm/objects/Refractor.js +0 -8
- package/examples/jsm/offscreen/scene.js +0 -1
- package/examples/jsm/postprocessing/MaskPass.js +4 -1
- package/examples/jsm/postprocessing/OutputPass.js +33 -14
- package/examples/jsm/postprocessing/UnrealBloomPass.js +21 -17
- package/examples/jsm/renderers/common/Background.js +22 -20
- package/examples/jsm/renderers/common/Binding.js +8 -0
- package/examples/jsm/renderers/common/Bindings.js +2 -6
- package/examples/jsm/renderers/common/Geometries.js +1 -1
- package/examples/jsm/renderers/common/Pipelines.js +94 -45
- package/examples/jsm/renderers/common/RenderContext.js +1 -0
- package/examples/jsm/renderers/common/RenderContexts.js +16 -5
- package/examples/jsm/renderers/common/RenderObject.js +20 -4
- package/examples/jsm/renderers/common/RenderObjects.js +10 -7
- package/examples/jsm/renderers/common/Renderer.js +70 -39
- package/examples/jsm/renderers/common/Textures.js +20 -8
- package/examples/jsm/renderers/common/nodes/Nodes.js +15 -4
- package/examples/jsm/renderers/webgpu/WebGPUBackend.js +51 -54
- package/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js +33 -9
- package/examples/jsm/renderers/webgpu/utils/WebGPUAttributeUtils.js +55 -36
- package/examples/jsm/renderers/webgpu/utils/WebGPUBindingUtils.js +83 -5
- package/examples/jsm/renderers/webgpu/utils/WebGPUConstants.js +24 -22
- package/examples/jsm/renderers/webgpu/utils/WebGPUPipelineUtils.js +83 -130
- package/examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js +35 -8
- package/examples/jsm/renderers/webgpu/utils/WebGPUUtils.js +1 -1
- package/examples/jsm/shaders/OutputShader.js +19 -2
- package/examples/jsm/utils/BufferGeometryUtils.js +13 -4
- package/examples/jsm/webxr/OculusHandPointerModel.js +2 -2
- package/package.json +2 -2
- package/src/Three.js +2 -0
- package/src/animation/PropertyBinding.js +1 -1
- package/src/cameras/CubeCamera.js +1 -4
- package/src/constants.js +1 -1
- package/src/core/BufferAttribute.js +20 -0
- package/src/core/Object3D.js +1 -1
- package/src/core/RenderTarget.js +122 -0
- package/src/geometries/CapsuleGeometry.js +1 -1
- package/src/loaders/DataTextureLoader.js +21 -2
- package/src/renderers/WebGLMultipleRenderTargets.js +0 -2
- package/src/renderers/WebGLRenderTarget.js +3 -110
- package/src/renderers/WebGLRenderer.js +62 -8
- package/src/renderers/shaders/ShaderChunk/iridescence_fragment.glsl.js +1 -2
- package/src/renderers/webgl/WebGLGeometries.js +5 -1
- package/src/renderers/webgl/WebGLMaterials.js +1 -1
- package/src/renderers/webgl/WebGLPrograms.js +14 -2
- package/src/renderers/webgl/WebGLTextures.js +97 -12
- package/src/renderers/webxr/WebXRManager.js +1 -1
- package/src/textures/CompressedCubeTexture.js +19 -0
- package/examples/jsm/nodes/functions/BSDF/BRDF_BlinnPhong.js +0 -30
- package/examples/jsm/renderers/common/RenderTarget.js +0 -15
- package/examples/jsm/renderers/common/nodes/NodeRender.js +0 -302
|
@@ -12,6 +12,8 @@ import { float, vec2 } from '../shadernode/ShaderNode.js';
|
|
|
12
12
|
import { cubeTexture } from '../accessors/CubeTextureNode.js';
|
|
13
13
|
import { reference } from '../accessors/ReferenceNode.js';
|
|
14
14
|
|
|
15
|
+
const envNodeCache = new WeakMap();
|
|
16
|
+
|
|
15
17
|
class EnvironmentNode extends LightingNode {
|
|
16
18
|
|
|
17
19
|
constructor( envNode = null ) {
|
|
@@ -29,13 +31,23 @@ class EnvironmentNode extends LightingNode {
|
|
|
29
31
|
|
|
30
32
|
if ( envNode.isTextureNode && envNode.value.isCubeTexture !== true ) {
|
|
31
33
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
+
let cacheEnvNode = envNodeCache.get( envNode.value );
|
|
35
|
+
|
|
36
|
+
if ( cacheEnvNode === undefined ) {
|
|
37
|
+
|
|
38
|
+
const texture = envNode.value;
|
|
39
|
+
const renderer = builder.renderer;
|
|
40
|
+
|
|
41
|
+
// @TODO: Add dispose logic here
|
|
42
|
+
const cubeRTT = builder.getCubeRenderTarget( 512 ).fromEquirectangularTexture( renderer, texture );
|
|
34
43
|
|
|
35
|
-
|
|
36
|
-
const cubeRTT = builder.getCubeRenderTarget( 512 ).fromEquirectangularTexture( renderer, texture );
|
|
44
|
+
cacheEnvNode = cubeTexture( cubeRTT.texture );
|
|
37
45
|
|
|
38
|
-
|
|
46
|
+
envNodeCache.set( envNode.value, cacheEnvNode );
|
|
47
|
+
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
envNode = cacheEnvNode;
|
|
39
51
|
|
|
40
52
|
}
|
|
41
53
|
|
|
@@ -56,22 +68,20 @@ class EnvironmentNode extends LightingNode {
|
|
|
56
68
|
|
|
57
69
|
//
|
|
58
70
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
if ( builder.context.clearcoatRadiance ) {
|
|
71
|
+
const clearcoatRadiance = builder.context.lightingModel.clearcoatRadiance;
|
|
62
72
|
|
|
63
|
-
|
|
73
|
+
if ( clearcoatRadiance ) {
|
|
64
74
|
|
|
65
|
-
|
|
75
|
+
const clearcoatRadianceContext = context( envNode, createRadianceContext( clearcoatRoughness, transformedClearcoatNormalView ) ).mul( intensity );
|
|
76
|
+
const isolateClearcoatRadiance = cache( clearcoatRadianceContext );
|
|
66
77
|
|
|
67
|
-
|
|
78
|
+
clearcoatRadiance.addAssign( isolateClearcoatRadiance );
|
|
68
79
|
|
|
69
80
|
}
|
|
70
81
|
|
|
71
82
|
//
|
|
72
83
|
|
|
73
84
|
properties.radiance = isolateRadiance;
|
|
74
|
-
properties.clearcoatRadiance = isolateClearcoatRadiance;
|
|
75
85
|
properties.irradiance = irradiance;
|
|
76
86
|
|
|
77
87
|
}
|
|
@@ -6,11 +6,11 @@ import { addNodeElement, nodeProxy, float, vec3 } from '../shadernode/ShaderNode
|
|
|
6
6
|
|
|
7
7
|
class LightingContextNode extends ContextNode {
|
|
8
8
|
|
|
9
|
-
constructor( node,
|
|
9
|
+
constructor( node, lightingModel = null, backdropNode = null, backdropAlphaNode = null ) {
|
|
10
10
|
|
|
11
11
|
super( node );
|
|
12
12
|
|
|
13
|
-
this.
|
|
13
|
+
this.lightingModel = lightingModel;
|
|
14
14
|
this.backdropNode = backdropNode;
|
|
15
15
|
this.backdropAlphaNode = backdropAlphaNode;
|
|
16
16
|
|
|
@@ -24,7 +24,7 @@ class LightingContextNode extends ContextNode {
|
|
|
24
24
|
|
|
25
25
|
construct( builder ) {
|
|
26
26
|
|
|
27
|
-
const {
|
|
27
|
+
const { lightingModel, backdropNode, backdropAlphaNode } = this;
|
|
28
28
|
|
|
29
29
|
const context = this.context = {}; // reset context
|
|
30
30
|
const properties = builder.getNodeProperties( this );
|
|
@@ -61,17 +61,20 @@ class LightingContextNode extends ContextNode {
|
|
|
61
61
|
};
|
|
62
62
|
|
|
63
63
|
context.reflectedLight = reflectedLight;
|
|
64
|
-
context.
|
|
64
|
+
context.lightingModel = lightingModel || context.lightingModel;
|
|
65
65
|
|
|
66
66
|
Object.assign( properties, reflectedLight, lighting );
|
|
67
67
|
Object.assign( context, lighting );
|
|
68
68
|
|
|
69
|
-
|
|
70
|
-
if ( lightingModelNode && lightingModelNode.init ) lightingModelNode.init( context, builder.stack, builder );
|
|
69
|
+
if ( lightingModel ) {
|
|
71
70
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
71
|
+
lightingModel.init( context, builder.stack, builder );
|
|
72
|
+
|
|
73
|
+
lightingModel.indirectDiffuse( context, builder.stack, builder );
|
|
74
|
+
lightingModel.indirectSpecular( context, builder.stack, builder );
|
|
75
|
+
lightingModel.ambientOcclusion( context, builder.stack, builder );
|
|
76
|
+
|
|
77
|
+
}
|
|
75
78
|
|
|
76
79
|
return super.construct( builder );
|
|
77
80
|
|
|
@@ -34,6 +34,8 @@ class PointLightNode extends AnalyticLightNode {
|
|
|
34
34
|
|
|
35
35
|
const { colorNode, cutoffDistanceNode, decayExponentNode, light } = this;
|
|
36
36
|
|
|
37
|
+
const lightingModel = builder.context.lightingModel;
|
|
38
|
+
|
|
37
39
|
const lVector = objectViewPosition( light ).sub( positionView ); // @TODO: Add it into LightNode
|
|
38
40
|
|
|
39
41
|
const lightDirection = lVector.normalize();
|
|
@@ -47,18 +49,13 @@ class PointLightNode extends AnalyticLightNode {
|
|
|
47
49
|
|
|
48
50
|
const lightColor = colorNode.mul( lightAttenuation );
|
|
49
51
|
|
|
50
|
-
const lightingModelFunctionNode = builder.context.lightingModelNode;
|
|
51
52
|
const reflectedLight = builder.context.reflectedLight;
|
|
52
53
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
reflectedLight
|
|
59
|
-
} );
|
|
60
|
-
|
|
61
|
-
}
|
|
54
|
+
lightingModel.direct( {
|
|
55
|
+
lightDirection,
|
|
56
|
+
lightColor,
|
|
57
|
+
reflectedLight
|
|
58
|
+
} );
|
|
62
59
|
|
|
63
60
|
}
|
|
64
61
|
|
|
@@ -50,6 +50,8 @@ class SpotLightNode extends AnalyticLightNode {
|
|
|
50
50
|
|
|
51
51
|
super.construct( builder );
|
|
52
52
|
|
|
53
|
+
const lightingModel = builder.context.lightingModel;
|
|
54
|
+
|
|
53
55
|
const { colorNode, cutoffDistanceNode, decayExponentNode, light } = this;
|
|
54
56
|
|
|
55
57
|
const lVector = objectViewPosition( light ).sub( positionView ); // @TODO: Add it into LightNode
|
|
@@ -68,18 +70,13 @@ class SpotLightNode extends AnalyticLightNode {
|
|
|
68
70
|
|
|
69
71
|
const lightColor = colorNode.mul( spotAttenuation ).mul( lightAttenuation );
|
|
70
72
|
|
|
71
|
-
const lightingModelFunctionNode = builder.context.lightingModelNode;
|
|
72
73
|
const reflectedLight = builder.context.reflectedLight;
|
|
73
74
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
reflectedLight
|
|
80
|
-
} );
|
|
81
|
-
|
|
82
|
-
}
|
|
75
|
+
lightingModel.direct( {
|
|
76
|
+
lightDirection,
|
|
77
|
+
lightColor,
|
|
78
|
+
reflectedLight
|
|
79
|
+
} );
|
|
83
80
|
|
|
84
81
|
}
|
|
85
82
|
|
|
@@ -4,6 +4,7 @@ export { default as NodeMaterial, addNodeMaterial, createNodeMaterialFromType }
|
|
|
4
4
|
export { default as LineBasicNodeMaterial } from './LineBasicNodeMaterial.js';
|
|
5
5
|
export { default as MeshNormalNodeMaterial } from './MeshNormalNodeMaterial.js';
|
|
6
6
|
export { default as MeshBasicNodeMaterial } from './MeshBasicNodeMaterial.js';
|
|
7
|
+
export { default as MeshLambertNodeMaterial } from './MeshLambertNodeMaterial.js';
|
|
7
8
|
export { default as MeshPhongNodeMaterial } from './MeshPhongNodeMaterial.js';
|
|
8
9
|
export { default as MeshStandardNodeMaterial } from './MeshStandardNodeMaterial.js';
|
|
9
10
|
export { default as MeshPhysicalNodeMaterial } from './MeshPhysicalNodeMaterial.js';
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import NodeMaterial, { addNodeMaterial } from './NodeMaterial.js';
|
|
2
|
+
import PhongLightingModel from '../functions/PhongLightingModel.js';
|
|
3
|
+
|
|
4
|
+
import { MeshLambertMaterial } from 'three';
|
|
5
|
+
|
|
6
|
+
const defaultValues = new MeshLambertMaterial();
|
|
7
|
+
|
|
8
|
+
class MeshLambertNodeMaterial extends NodeMaterial {
|
|
9
|
+
|
|
10
|
+
constructor( parameters ) {
|
|
11
|
+
|
|
12
|
+
super();
|
|
13
|
+
|
|
14
|
+
this.isMeshLambertNodeMaterial = true;
|
|
15
|
+
|
|
16
|
+
this.lights = true;
|
|
17
|
+
|
|
18
|
+
this.setDefaultValues( defaultValues );
|
|
19
|
+
|
|
20
|
+
this.setValues( parameters );
|
|
21
|
+
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
constructLightingModel( /*builder*/ ) {
|
|
25
|
+
|
|
26
|
+
return new PhongLightingModel( false ); // ( specular ) -> force lambert
|
|
27
|
+
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export default MeshLambertNodeMaterial;
|
|
33
|
+
|
|
34
|
+
addNodeMaterial( MeshLambertNodeMaterial );
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import NodeMaterial, { addNodeMaterial } from './NodeMaterial.js';
|
|
2
2
|
import { shininess, specularColor } from '../core/PropertyNode.js';
|
|
3
3
|
import { materialShininess, materialSpecularColor } from '../accessors/MaterialNode.js';
|
|
4
|
-
import phongLightingModel from '../functions/PhongLightingModel.js';
|
|
5
4
|
import { float } from '../shadernode/ShaderNode.js';
|
|
5
|
+
import PhongLightingModel from '../functions/PhongLightingModel.js';
|
|
6
6
|
|
|
7
7
|
import { MeshPhongMaterial } from 'three';
|
|
8
8
|
|
|
@@ -29,7 +29,7 @@ class MeshPhongNodeMaterial extends NodeMaterial {
|
|
|
29
29
|
|
|
30
30
|
constructLightingModel( /*builder*/ ) {
|
|
31
31
|
|
|
32
|
-
return
|
|
32
|
+
return new PhongLightingModel();
|
|
33
33
|
|
|
34
34
|
}
|
|
35
35
|
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { addNodeMaterial } from './NodeMaterial.js';
|
|
2
2
|
import { transformedClearcoatNormalView } from '../accessors/NormalNode.js';
|
|
3
|
-
import { clearcoat, clearcoatRoughness, sheen, sheenRoughness } from '../core/PropertyNode.js';
|
|
3
|
+
import { clearcoat, clearcoatRoughness, sheen, sheenRoughness, iridescence, iridescenceIOR, iridescenceThickness } from '../core/PropertyNode.js';
|
|
4
4
|
import { materialClearcoatNormal } from '../accessors/ExtendedMaterialNode.js';
|
|
5
|
-
import { materialClearcoat, materialClearcoatRoughness, materialSheen, materialSheenRoughness } from '../accessors/MaterialNode.js';
|
|
5
|
+
import { materialClearcoat, materialClearcoatRoughness, materialSheen, materialSheenRoughness, materialIridescence, materialIridescenceIOR, materialIridescenceThickness } from '../accessors/MaterialNode.js';
|
|
6
6
|
import { float, vec3 } from '../shadernode/ShaderNode.js';
|
|
7
|
+
import PhysicalLightingModel from '../functions/PhysicalLightingModel.js';
|
|
7
8
|
import MeshStandardNodeMaterial from './MeshStandardNodeMaterial.js';
|
|
8
9
|
|
|
9
10
|
import { MeshPhysicalMaterial } from 'three';
|
|
@@ -43,6 +44,12 @@ class MeshPhysicalNodeMaterial extends MeshStandardNodeMaterial {
|
|
|
43
44
|
|
|
44
45
|
}
|
|
45
46
|
|
|
47
|
+
constructLightingModel( /*builder*/ ) {
|
|
48
|
+
|
|
49
|
+
return new PhysicalLightingModel(); // @TODO: Optimize shader using parameters.
|
|
50
|
+
|
|
51
|
+
}
|
|
52
|
+
|
|
46
53
|
constructVariants( builder ) {
|
|
47
54
|
|
|
48
55
|
super.constructVariants( builder );
|
|
@@ -65,6 +72,16 @@ class MeshPhysicalNodeMaterial extends MeshStandardNodeMaterial {
|
|
|
65
72
|
stack.assign( sheen, sheenNode );
|
|
66
73
|
stack.assign( sheenRoughness, sheenRoughnessNode );
|
|
67
74
|
|
|
75
|
+
// IRIDESCENCE
|
|
76
|
+
|
|
77
|
+
const iridescenceNode = this.iridescenceNode ? float( this.iridescenceNode ) : materialIridescence;
|
|
78
|
+
const iridescenceIORNode = this.iridescenceIORNode ? float( this.iridescenceIORNode ) : materialIridescenceIOR;
|
|
79
|
+
const iridescenceThicknessNode = this.iridescenceThicknessNode ? float( this.iridescenceThicknessNode ) : materialIridescenceThickness;
|
|
80
|
+
|
|
81
|
+
stack.assign( iridescence, iridescenceNode );
|
|
82
|
+
stack.assign( iridescenceIOR, iridescenceIORNode );
|
|
83
|
+
stack.assign( iridescenceThickness, iridescenceThicknessNode );
|
|
84
|
+
|
|
68
85
|
}
|
|
69
86
|
|
|
70
87
|
constructNormal( builder ) {
|
|
@@ -3,7 +3,7 @@ import { diffuseColor, metalness, roughness, specularColor } from '../core/Prope
|
|
|
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';
|
|
6
|
-
import
|
|
6
|
+
import PhysicalLightingModel from '../functions/PhysicalLightingModel.js';
|
|
7
7
|
import { float, vec3, vec4 } from '../shadernode/ShaderNode.js';
|
|
8
8
|
|
|
9
9
|
import { MeshStandardMaterial } from 'three';
|
|
@@ -31,7 +31,7 @@ class MeshStandardNodeMaterial extends NodeMaterial {
|
|
|
31
31
|
|
|
32
32
|
constructLightingModel( /*builder*/ ) {
|
|
33
33
|
|
|
34
|
-
return
|
|
34
|
+
return new PhysicalLightingModel( false, false ); // ( clearcoat, sheen ) -> standard
|
|
35
35
|
|
|
36
36
|
}
|
|
37
37
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Material, ShaderMaterial, NoColorSpace } from 'three';
|
|
1
|
+
import { Material, ShaderMaterial, NoColorSpace, LinearSRGBColorSpace } from 'three';
|
|
2
2
|
import { getNodeChildren, getCacheKey } from '../core/NodeUtils.js';
|
|
3
3
|
import { attribute } from '../core/AttributeNode.js';
|
|
4
|
-
import { diffuseColor } from '../core/PropertyNode.js';
|
|
4
|
+
import { output, diffuseColor } from '../core/PropertyNode.js';
|
|
5
5
|
import { materialNormal } from '../accessors/ExtendedMaterialNode.js';
|
|
6
6
|
import { materialAlphaTest, materialColor, materialOpacity, materialEmissive } from '../accessors/MaterialNode.js';
|
|
7
7
|
import { modelViewProjection } from '../accessors/ModelViewProjectionNode.js';
|
|
@@ -32,8 +32,12 @@ class NodeMaterial extends ShaderMaterial {
|
|
|
32
32
|
|
|
33
33
|
this.forceSinglePass = false;
|
|
34
34
|
|
|
35
|
+
this.unlit = this.constructor === NodeMaterial.prototype.constructor; // Extended materials are not unlit by default
|
|
36
|
+
|
|
37
|
+
this.fog = true;
|
|
35
38
|
this.lights = true;
|
|
36
39
|
this.normals = true;
|
|
40
|
+
this.colorSpace = true;
|
|
37
41
|
|
|
38
42
|
this.lightsNode = null;
|
|
39
43
|
this.envNode = null;
|
|
@@ -46,7 +50,9 @@ class NodeMaterial extends ShaderMaterial {
|
|
|
46
50
|
this.alphaTestNode = null;
|
|
47
51
|
|
|
48
52
|
this.positionNode = null;
|
|
49
|
-
|
|
53
|
+
|
|
54
|
+
this.outputNode = null; // @TODO: Rename to fragmentNode
|
|
55
|
+
this.vertexNode = null;
|
|
50
56
|
|
|
51
57
|
}
|
|
52
58
|
|
|
@@ -76,7 +82,9 @@ class NodeMaterial extends ShaderMaterial {
|
|
|
76
82
|
|
|
77
83
|
builder.addStack();
|
|
78
84
|
|
|
79
|
-
|
|
85
|
+
let outputNode;
|
|
86
|
+
|
|
87
|
+
if ( this.unlit === false ) {
|
|
80
88
|
|
|
81
89
|
if ( this.normals === true ) this.constructNormal( builder );
|
|
82
90
|
|
|
@@ -85,14 +93,24 @@ class NodeMaterial extends ShaderMaterial {
|
|
|
85
93
|
|
|
86
94
|
const outgoingLightNode = this.constructLighting( builder );
|
|
87
95
|
|
|
88
|
-
|
|
96
|
+
outputNode = this.constructOutput( builder, vec4( outgoingLightNode, diffuseColor.a ) );
|
|
97
|
+
|
|
98
|
+
// OUTPUT NODE
|
|
99
|
+
|
|
100
|
+
builder.stack.assign( output, outputNode );
|
|
101
|
+
|
|
102
|
+
//
|
|
103
|
+
|
|
104
|
+
if ( this.outputNode !== null ) outputNode = this.outputNode;
|
|
89
105
|
|
|
90
106
|
} else {
|
|
91
107
|
|
|
92
|
-
|
|
108
|
+
outputNode = this.constructOutput( builder, this.outputNode || vec4( 0, 0, 0, 1 ) );
|
|
93
109
|
|
|
94
110
|
}
|
|
95
111
|
|
|
112
|
+
builder.stack.outputNode = outputNode;
|
|
113
|
+
|
|
96
114
|
builder.addFlow( 'fragment', builder.removeStack() );
|
|
97
115
|
|
|
98
116
|
}
|
|
@@ -130,7 +148,7 @@ class NodeMaterial extends ShaderMaterial {
|
|
|
130
148
|
|
|
131
149
|
builder.context.vertex = builder.removeStack();
|
|
132
150
|
|
|
133
|
-
return modelViewProjection();
|
|
151
|
+
return this.vertexNode || modelViewProjection();
|
|
134
152
|
|
|
135
153
|
}
|
|
136
154
|
|
|
@@ -306,29 +324,41 @@ class NodeMaterial extends ShaderMaterial {
|
|
|
306
324
|
|
|
307
325
|
}
|
|
308
326
|
|
|
327
|
+
// FOG
|
|
328
|
+
|
|
329
|
+
if ( this.fog === true ) {
|
|
330
|
+
|
|
331
|
+
const fogNode = builder.fogNode;
|
|
332
|
+
|
|
333
|
+
if ( fogNode ) outputNode = vec4( fogNode.mixAssign( outputNode.rgb ), outputNode.a );
|
|
334
|
+
|
|
335
|
+
}
|
|
336
|
+
|
|
309
337
|
// ENCODING
|
|
310
338
|
|
|
311
|
-
|
|
339
|
+
if ( this.colorSpace === true ) {
|
|
312
340
|
|
|
313
|
-
|
|
341
|
+
const renderTarget = renderer.getRenderTarget();
|
|
314
342
|
|
|
315
|
-
|
|
343
|
+
let outputColorSpace;
|
|
316
344
|
|
|
317
|
-
|
|
345
|
+
if ( renderTarget !== null ) {
|
|
318
346
|
|
|
319
|
-
|
|
347
|
+
outputColorSpace = renderTarget.texture.colorSpace;
|
|
320
348
|
|
|
321
|
-
|
|
349
|
+
} else {
|
|
322
350
|
|
|
323
|
-
|
|
351
|
+
outputColorSpace = renderer.outputColorSpace;
|
|
324
352
|
|
|
325
|
-
|
|
353
|
+
}
|
|
326
354
|
|
|
327
|
-
|
|
355
|
+
if ( outputColorSpace !== LinearSRGBColorSpace && outputColorSpace !== NoColorSpace ) {
|
|
328
356
|
|
|
329
|
-
|
|
357
|
+
outputNode = outputNode.linearToColorSpace( outputColorSpace );
|
|
330
358
|
|
|
331
|
-
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
}
|
|
332
362
|
|
|
333
363
|
return outputNode;
|
|
334
364
|
|
|
@@ -429,12 +459,6 @@ class NodeMaterial extends ShaderMaterial {
|
|
|
429
459
|
|
|
430
460
|
}
|
|
431
461
|
|
|
432
|
-
get isUnlit() {
|
|
433
|
-
|
|
434
|
-
return this.constructor === NodeMaterial.prototype.constructor;
|
|
435
|
-
|
|
436
|
-
}
|
|
437
|
-
|
|
438
462
|
copy( source ) {
|
|
439
463
|
|
|
440
464
|
this.lightsNode = source.lightsNode;
|
|
@@ -448,7 +472,9 @@ class NodeMaterial extends ShaderMaterial {
|
|
|
448
472
|
this.alphaTestNode = source.alphaTestNode;
|
|
449
473
|
|
|
450
474
|
this.positionNode = source.positionNode;
|
|
475
|
+
|
|
451
476
|
this.outputNode = source.outputNode;
|
|
477
|
+
this.vertexNode = source.vertexNode;
|
|
452
478
|
|
|
453
479
|
return super.copy( source );
|
|
454
480
|
|
|
@@ -4,7 +4,7 @@ import { cameraProjectionMatrix } from '../accessors/CameraNode.js';
|
|
|
4
4
|
import { materialRotation } from '../accessors/MaterialNode.js';
|
|
5
5
|
import { modelViewMatrix, modelWorldMatrix } from '../accessors/ModelNode.js';
|
|
6
6
|
import { positionLocal } from '../accessors/PositionNode.js';
|
|
7
|
-
import { vec2, vec3, vec4 } from '../shadernode/ShaderNode.js';
|
|
7
|
+
import { float, vec2, vec3, vec4 } from '../shadernode/ShaderNode.js';
|
|
8
8
|
|
|
9
9
|
import { SpriteMaterial } from 'three';
|
|
10
10
|
|
|
@@ -66,7 +66,7 @@ class SpriteNodeMaterial extends NodeMaterial {
|
|
|
66
66
|
|
|
67
67
|
alignedPosition = alignedPosition.mul( scale );
|
|
68
68
|
|
|
69
|
-
const rotation = rotationNode || materialRotation;
|
|
69
|
+
const rotation = float( rotationNode || materialRotation );
|
|
70
70
|
|
|
71
71
|
const cosAngle = rotation.cos();
|
|
72
72
|
const sinAngle = rotation.sin();
|
|
@@ -261,7 +261,7 @@ const safeGetNodeType = ( node ) => {
|
|
|
261
261
|
|
|
262
262
|
return node.getNodeType();
|
|
263
263
|
|
|
264
|
-
} catch {
|
|
264
|
+
} catch ( _ ) {
|
|
265
265
|
|
|
266
266
|
return undefined;
|
|
267
267
|
|
|
@@ -322,7 +322,7 @@ export const nodeImmutable = ( ...params ) => new ShaderNodeImmutable( ...params
|
|
|
322
322
|
|
|
323
323
|
export const shader = ( jsFunc ) => { // @deprecated, r154
|
|
324
324
|
|
|
325
|
-
console.warn( 'TSL: shader() is deprecated. Use
|
|
325
|
+
console.warn( 'TSL: shader() is deprecated. Use tslFn() instead.' );
|
|
326
326
|
|
|
327
327
|
return new ShaderNode( jsFunc );
|
|
328
328
|
|
|
@@ -9,9 +9,7 @@ import {
|
|
|
9
9
|
Vector3,
|
|
10
10
|
Vector4,
|
|
11
11
|
WebGLRenderTarget,
|
|
12
|
-
HalfFloatType
|
|
13
|
-
NoToneMapping,
|
|
14
|
-
LinearSRGBColorSpace
|
|
12
|
+
HalfFloatType
|
|
15
13
|
} from 'three';
|
|
16
14
|
|
|
17
15
|
class Reflector extends Mesh {
|
|
@@ -147,13 +145,9 @@ class Reflector extends Mesh {
|
|
|
147
145
|
|
|
148
146
|
const currentXrEnabled = renderer.xr.enabled;
|
|
149
147
|
const currentShadowAutoUpdate = renderer.shadowMap.autoUpdate;
|
|
150
|
-
const currentOutputColorSpace = renderer.outputColorSpace;
|
|
151
|
-
const currentToneMapping = renderer.toneMapping;
|
|
152
148
|
|
|
153
149
|
renderer.xr.enabled = false; // Avoid camera modification
|
|
154
150
|
renderer.shadowMap.autoUpdate = false; // Avoid re-computing shadows
|
|
155
|
-
renderer.outputColorSpace = LinearSRGBColorSpace;
|
|
156
|
-
renderer.toneMapping = NoToneMapping;
|
|
157
151
|
|
|
158
152
|
renderer.setRenderTarget( renderTarget );
|
|
159
153
|
|
|
@@ -164,8 +158,6 @@ class Reflector extends Mesh {
|
|
|
164
158
|
|
|
165
159
|
renderer.xr.enabled = currentXrEnabled;
|
|
166
160
|
renderer.shadowMap.autoUpdate = currentShadowAutoUpdate;
|
|
167
|
-
renderer.outputColorSpace = currentOutputColorSpace;
|
|
168
|
-
renderer.toneMapping = currentToneMapping;
|
|
169
161
|
|
|
170
162
|
renderer.setRenderTarget( currentRenderTarget );
|
|
171
163
|
|
|
@@ -10,8 +10,6 @@ import {
|
|
|
10
10
|
Vector3,
|
|
11
11
|
Vector4,
|
|
12
12
|
WebGLRenderTarget,
|
|
13
|
-
LinearSRGBColorSpace,
|
|
14
|
-
NoToneMapping,
|
|
15
13
|
HalfFloatType
|
|
16
14
|
} from 'three';
|
|
17
15
|
|
|
@@ -194,13 +192,9 @@ class Refractor extends Mesh {
|
|
|
194
192
|
const currentRenderTarget = renderer.getRenderTarget();
|
|
195
193
|
const currentXrEnabled = renderer.xr.enabled;
|
|
196
194
|
const currentShadowAutoUpdate = renderer.shadowMap.autoUpdate;
|
|
197
|
-
const currentOutputColorSpace = renderer.outputColorSpace;
|
|
198
|
-
const currentToneMapping = renderer.toneMapping;
|
|
199
195
|
|
|
200
196
|
renderer.xr.enabled = false; // avoid camera modification
|
|
201
197
|
renderer.shadowMap.autoUpdate = false; // avoid re-computing shadows
|
|
202
|
-
renderer.outputColorSpace = LinearSRGBColorSpace;
|
|
203
|
-
renderer.toneMapping = NoToneMapping;
|
|
204
198
|
|
|
205
199
|
renderer.setRenderTarget( renderTarget );
|
|
206
200
|
if ( renderer.autoClear === false ) renderer.clear();
|
|
@@ -208,8 +202,6 @@ class Refractor extends Mesh {
|
|
|
208
202
|
|
|
209
203
|
renderer.xr.enabled = currentXrEnabled;
|
|
210
204
|
renderer.shadowMap.autoUpdate = currentShadowAutoUpdate;
|
|
211
|
-
renderer.outputColorSpace = currentOutputColorSpace;
|
|
212
|
-
renderer.toneMapping = currentToneMapping;
|
|
213
205
|
renderer.setRenderTarget( currentRenderTarget );
|
|
214
206
|
|
|
215
207
|
// restore viewport
|
|
@@ -45,7 +45,6 @@ function init( canvas, width, height, pixelRatio, path ) {
|
|
|
45
45
|
renderer = new THREE.WebGLRenderer( { antialias: true, canvas: canvas } );
|
|
46
46
|
renderer.setPixelRatio( pixelRatio );
|
|
47
47
|
renderer.setSize( width, height, false );
|
|
48
|
-
renderer.useLegacyLights = false;
|
|
49
48
|
|
|
50
49
|
animate();
|
|
51
50
|
|
|
@@ -63,11 +63,14 @@ class MaskPass extends Pass {
|
|
|
63
63
|
if ( this.clear ) renderer.clear();
|
|
64
64
|
renderer.render( this.scene, this.camera );
|
|
65
65
|
|
|
66
|
-
// unlock color and depth buffer for subsequent rendering
|
|
66
|
+
// unlock color and depth buffer and make them writable for subsequent rendering/clearing
|
|
67
67
|
|
|
68
68
|
state.buffers.color.setLocked( false );
|
|
69
69
|
state.buffers.depth.setLocked( false );
|
|
70
70
|
|
|
71
|
+
state.buffers.color.setMask( true );
|
|
72
|
+
state.buffers.depth.setMask( true );
|
|
73
|
+
|
|
71
74
|
// only render where stencil is set to 1
|
|
72
75
|
|
|
73
76
|
state.buffers.stencil.setLocked( false );
|