three-stdlib 2.8.9 → 2.8.10
Sign up to get free protection for your applications and to get access to all the features.
- package/Nodes-607e9ed8.js +471 -0
- package/Nodes-627a8bdf.js +1 -0
- package/index.cjs.js +1 -1
- package/index.d.ts +0 -75
- package/index.js +70 -76
- package/loaders/NodeMaterialLoader.cjs.js +1 -1
- package/loaders/NodeMaterialLoader.js +2 -136
- package/nodes/Nodes.cjs.js +1 -1
- package/nodes/Nodes.js +203 -76
- package/nodes/ShaderNode.cjs.js +1 -0
- package/nodes/ShaderNode.js +308 -0
- package/nodes/accessors/BufferNode.cjs.js +1 -0
- package/nodes/accessors/BufferNode.js +18 -0
- package/nodes/accessors/CameraNode.cjs.js +1 -1
- package/nodes/accessors/CameraNode.js +32 -138
- package/nodes/accessors/CubeTextureNode.cjs.js +1 -0
- package/nodes/accessors/CubeTextureNode.js +53 -0
- package/nodes/accessors/MaterialNode.cjs.js +1 -0
- package/nodes/accessors/MaterialNode.js +80 -0
- package/nodes/accessors/MaterialReferenceNode.cjs.js +1 -0
- package/nodes/accessors/MaterialReferenceNode.js +16 -0
- package/nodes/accessors/ModelNode.cjs.js +1 -0
- package/nodes/accessors/ModelNode.js +10 -0
- package/nodes/accessors/ModelViewProjectionNode.cjs.js +1 -0
- package/nodes/accessors/ModelViewProjectionNode.js +22 -0
- package/nodes/accessors/NormalNode.cjs.js +1 -1
- package/nodes/accessors/NormalNode.js +48 -78
- package/nodes/accessors/Object3DNode.cjs.js +1 -0
- package/nodes/accessors/Object3DNode.js +85 -0
- package/nodes/accessors/PointUVNode.cjs.js +1 -0
- package/nodes/accessors/PointUVNode.js +16 -0
- package/nodes/accessors/PositionNode.cjs.js +1 -1
- package/nodes/accessors/PositionNode.js +49 -87
- package/nodes/accessors/ReferenceNode.cjs.js +1 -0
- package/nodes/accessors/ReferenceNode.js +43 -0
- package/nodes/accessors/ReflectNode.cjs.js +1 -1
- package/nodes/accessors/ReflectNode.js +35 -98
- package/nodes/accessors/SkinningNode.cjs.js +1 -0
- package/nodes/accessors/SkinningNode.js +59 -0
- package/nodes/accessors/TextureNode.cjs.js +1 -0
- package/nodes/accessors/TextureNode.js +68 -0
- package/nodes/accessors/UVNode.cjs.js +1 -1
- package/nodes/accessors/UVNode.js +20 -38
- package/nodes/core/ArrayUniformNode.cjs.js +1 -0
- package/nodes/core/ArrayUniformNode.js +17 -0
- package/nodes/core/AttributeNode.cjs.js +1 -1
- package/nodes/core/AttributeNode.js +31 -40
- package/nodes/core/BypassNode.cjs.js +1 -0
- package/nodes/core/BypassNode.js +28 -0
- package/nodes/core/CodeNode.cjs.js +1 -0
- package/nodes/core/CodeNode.js +35 -0
- package/nodes/core/ConstNode.cjs.js +1 -1
- package/nodes/core/ConstNode.js +10 -78
- package/nodes/core/ContextNode.cjs.js +1 -0
- package/nodes/core/ContextNode.js +26 -0
- package/nodes/core/ExpressionNode.cjs.js +1 -1
- package/nodes/core/ExpressionNode.js +19 -8
- package/nodes/core/FunctionCallNode.cjs.js +1 -1
- package/nodes/core/FunctionCallNode.js +31 -60
- package/nodes/core/FunctionNode.cjs.js +1 -1
- package/nodes/core/FunctionNode.js +45 -166
- package/nodes/core/InputNode.cjs.js +1 -1
- package/nodes/core/InputNode.js +43 -57
- package/nodes/core/Node.cjs.js +1 -1
- package/nodes/core/Node.js +155 -113
- package/nodes/core/NodeAttribute.cjs.js +1 -0
- package/nodes/core/NodeAttribute.js +11 -0
- package/nodes/core/NodeBuilder.cjs.js +1 -1
- package/nodes/core/NodeBuilder.js +422 -548
- package/nodes/core/NodeCode.cjs.js +1 -0
- package/nodes/core/NodeCode.js +13 -0
- package/nodes/core/NodeFrame.cjs.js +1 -1
- package/nodes/core/NodeFrame.js +34 -27
- package/nodes/core/NodeFunction.cjs.js +1 -0
- package/nodes/core/NodeFunction.js +17 -0
- package/nodes/core/NodeFunctionInput.cjs.js +1 -0
- package/nodes/core/NodeFunctionInput.js +14 -0
- package/nodes/core/NodeKeywords.cjs.js +1 -0
- package/nodes/core/NodeKeywords.js +54 -0
- package/nodes/core/NodeParser.cjs.js +1 -0
- package/nodes/core/NodeParser.js +8 -0
- package/nodes/core/NodeUniform.cjs.js +1 -1
- package/nodes/core/NodeUniform.js +18 -17
- package/nodes/core/NodeUtils.cjs.js +1 -1
- package/nodes/core/NodeUtils.js +55 -35
- package/nodes/core/NodeVar.cjs.js +1 -0
- package/nodes/core/NodeVar.js +11 -0
- package/nodes/core/NodeVary.cjs.js +1 -0
- package/nodes/core/NodeVary.js +11 -0
- package/nodes/core/PropertyNode.cjs.js +1 -0
- package/nodes/core/PropertyNode.js +26 -0
- package/nodes/core/TempNode.cjs.js +1 -1
- package/nodes/core/TempNode.js +21 -88
- package/nodes/core/UniformNode.cjs.js +1 -0
- package/nodes/core/UniformNode.js +28 -0
- package/nodes/core/VarNode.cjs.js +1 -1
- package/nodes/core/VarNode.js +28 -35
- package/nodes/core/VaryNode.cjs.js +1 -0
- package/nodes/core/VaryNode.js +38 -0
- package/nodes/core/constants.cjs.js +1 -0
- package/nodes/core/constants.js +11 -0
- package/nodes/display/ColorSpaceNode.cjs.js +1 -0
- package/nodes/display/ColorSpaceNode.js +67 -0
- package/nodes/display/NormalMapNode.cjs.js +1 -0
- package/nodes/display/NormalMapNode.js +71 -0
- package/nodes/fog/FogNode.cjs.js +1 -0
- package/nodes/fog/FogNode.js +18 -0
- package/nodes/fog/FogRangeNode.cjs.js +1 -0
- package/nodes/fog/FogRangeNode.js +20 -0
- package/nodes/functions/BSDFs.cjs.js +1 -0
- package/nodes/functions/BSDFs.js +121 -0
- package/nodes/functions/PhysicalMaterialFunctions.cjs.js +1 -0
- package/nodes/functions/PhysicalMaterialFunctions.js +57 -0
- package/nodes/lights/LightContextNode.cjs.js +1 -0
- package/nodes/lights/LightContextNode.js +43 -0
- package/nodes/lights/LightNode.cjs.js +1 -0
- package/nodes/lights/LightNode.js +61 -0
- package/nodes/lights/LightsNode.cjs.js +1 -0
- package/nodes/lights/LightsNode.js +77 -0
- package/nodes/loaders/NodeLoader.cjs.js +1 -0
- package/nodes/loaders/NodeLoader.js +80 -0
- package/nodes/loaders/NodeMaterialLoader.cjs.js +1 -0
- package/nodes/loaders/NodeMaterialLoader.js +29 -0
- package/nodes/loaders/NodeObjectLoader.cjs.js +1 -0
- package/nodes/loaders/NodeObjectLoader.js +49 -0
- package/nodes/materials/LineBasicNodeMaterial.cjs.js +1 -0
- package/nodes/materials/LineBasicNodeMaterial.js +31 -0
- package/nodes/materials/Materials.cjs.js +1 -0
- package/nodes/materials/Materials.js +27 -0
- package/nodes/materials/MeshBasicNodeMaterial.cjs.js +1 -0
- package/nodes/materials/MeshBasicNodeMaterial.js +32 -0
- package/nodes/materials/MeshStandardNodeMaterial.cjs.js +1 -1
- package/nodes/materials/MeshStandardNodeMaterial.js +41 -13
- package/nodes/materials/NodeMaterial.cjs.js +1 -1
- package/nodes/materials/NodeMaterial.js +67 -140
- package/nodes/materials/PointsNodeMaterial.cjs.js +1 -0
- package/nodes/materials/PointsNodeMaterial.js +34 -0
- package/nodes/math/CondNode.cjs.js +1 -1
- package/nodes/math/CondNode.js +33 -74
- package/nodes/math/MathNode.cjs.js +1 -1
- package/nodes/math/MathNode.js +193 -193
- package/nodes/math/OperatorNode.cjs.js +1 -1
- package/nodes/math/OperatorNode.js +116 -52
- package/nodes/parsers/GLSLNodeFunction.cjs.js +1 -0
- package/nodes/parsers/GLSLNodeFunction.js +101 -0
- package/nodes/parsers/GLSLNodeParser.cjs.js +1 -0
- package/nodes/parsers/GLSLNodeParser.js +13 -0
- package/nodes/parsers/WGSLNodeFunction.cjs.js +1 -0
- package/nodes/parsers/WGSLNodeFunction.js +71 -0
- package/nodes/parsers/WGSLNodeParser.cjs.js +1 -0
- package/nodes/parsers/WGSLNodeParser.js +13 -0
- package/nodes/procedural/CheckerNode.cjs.js +1 -1
- package/nodes/procedural/CheckerNode.js +22 -40
- package/nodes/utils/ArrayElementNode.cjs.js +1 -0
- package/nodes/utils/ArrayElementNode.js +22 -0
- package/nodes/utils/ConvertNode.cjs.js +1 -0
- package/nodes/utils/ConvertNode.js +29 -0
- package/nodes/utils/JoinNode.cjs.js +1 -1
- package/nodes/utils/JoinNode.js +19 -69
- package/nodes/utils/MatcapUVNode.cjs.js +1 -0
- package/nodes/utils/MatcapUVNode.js +18 -0
- package/nodes/utils/OscNode.cjs.js +1 -0
- package/nodes/utils/OscNode.js +55 -0
- package/nodes/utils/SplitNode.cjs.js +1 -0
- package/nodes/utils/SplitNode.js +58 -0
- package/nodes/utils/SpriteSheetUVNode.cjs.js +1 -0
- package/nodes/utils/SpriteSheetUVNode.js +39 -0
- package/nodes/utils/TimerNode.cjs.js +1 -1
- package/nodes/utils/TimerNode.js +38 -56
- package/package.json +1 -1
- package/Nodes-894ac9dc.js +0 -1
- package/Nodes-af575af7.js +0 -157
- package/nodes/accessors/ColorsNode.cjs.js +0 -1
- package/nodes/accessors/ColorsNode.d.ts +0 -10
- package/nodes/accessors/ColorsNode.js +0 -40
- package/nodes/accessors/LightNode.cjs.js +0 -1
- package/nodes/accessors/LightNode.d.ts +0 -12
- package/nodes/accessors/LightNode.js +0 -41
- package/nodes/accessors/ResolutionNode.cjs.js +0 -1
- package/nodes/accessors/ResolutionNode.d.ts +0 -14
- package/nodes/accessors/ResolutionNode.js +0 -41
- package/nodes/accessors/ScreenUVNode.cjs.js +0 -1
- package/nodes/accessors/ScreenUVNode.d.ts +0 -11
- package/nodes/accessors/ScreenUVNode.js +0 -43
- package/nodes/core/NodeLib.cjs.js +0 -1
- package/nodes/core/NodeLib.d.ts +0 -22
- package/nodes/core/NodeLib.js +0 -37
- package/nodes/core/StructNode.cjs.js +0 -1
- package/nodes/core/StructNode.d.ts +0 -19
- package/nodes/core/StructNode.js +0 -72
- package/nodes/effects/BlurNode.cjs.js +0 -1
- package/nodes/effects/BlurNode.d.ts +0 -31
- package/nodes/effects/BlurNode.js +0 -100
- package/nodes/effects/ColorAdjustmentNode.cjs.js +0 -1
- package/nodes/effects/ColorAdjustmentNode.d.ts +0 -27
- package/nodes/effects/ColorAdjustmentNode.js +0 -73
- package/nodes/effects/LuminanceNode.cjs.js +0 -1
- package/nodes/effects/LuminanceNode.d.ts +0 -18
- package/nodes/effects/LuminanceNode.js +0 -46
- package/nodes/inputs/BoolNode.cjs.js +0 -1
- package/nodes/inputs/BoolNode.d.ts +0 -19
- package/nodes/inputs/BoolNode.js +0 -36
- package/nodes/inputs/ColorNode.cjs.js +0 -1
- package/nodes/inputs/ColorNode.d.ts +0 -21
- package/nodes/inputs/ColorNode.js +0 -41
- package/nodes/inputs/CubeTextureNode.cjs.js +0 -1
- package/nodes/inputs/CubeTextureNode.d.ts +0 -17
- package/nodes/inputs/CubeTextureNode.js +0 -79
- package/nodes/inputs/FloatNode.cjs.js +0 -1
- package/nodes/inputs/FloatNode.d.ts +0 -19
- package/nodes/inputs/FloatNode.js +0 -36
- package/nodes/inputs/IntNode.cjs.js +0 -1
- package/nodes/inputs/IntNode.d.ts +0 -19
- package/nodes/inputs/IntNode.js +0 -36
- package/nodes/inputs/Matrix3Node.cjs.js +0 -1
- package/nodes/inputs/Matrix3Node.d.ts +0 -22
- package/nodes/inputs/Matrix3Node.js +0 -46
- package/nodes/inputs/Matrix4Node.cjs.js +0 -1
- package/nodes/inputs/Matrix4Node.d.ts +0 -22
- package/nodes/inputs/Matrix4Node.js +0 -46
- package/nodes/inputs/PropertyNode.cjs.js +0 -1
- package/nodes/inputs/PropertyNode.d.ts +0 -10
- package/nodes/inputs/PropertyNode.js +0 -35
- package/nodes/inputs/RTTNode.cjs.js +0 -1
- package/nodes/inputs/RTTNode.d.ts +0 -27
- package/nodes/inputs/RTTNode.js +0 -103
- package/nodes/inputs/ReflectorNode.cjs.js +0 -1
- package/nodes/inputs/ReflectorNode.d.ts +0 -21
- package/nodes/inputs/ReflectorNode.js +0 -60
- package/nodes/inputs/ScreenNode.cjs.js +0 -1
- package/nodes/inputs/ScreenNode.d.ts +0 -11
- package/nodes/inputs/ScreenNode.js +0 -20
- package/nodes/inputs/TextureNode.cjs.js +0 -1
- package/nodes/inputs/TextureNode.d.ts +0 -20
- package/nodes/inputs/TextureNode.js +0 -83
- package/nodes/inputs/Vector2Node.cjs.js +0 -1
- package/nodes/inputs/Vector2Node.d.ts +0 -21
- package/nodes/inputs/Vector2Node.js +0 -40
- package/nodes/inputs/Vector3Node.cjs.js +0 -1
- package/nodes/inputs/Vector3Node.d.ts +0 -21
- package/nodes/inputs/Vector3Node.js +0 -41
- package/nodes/inputs/Vector4Node.cjs.js +0 -1
- package/nodes/inputs/Vector4Node.d.ts +0 -21
- package/nodes/inputs/Vector4Node.js +0 -42
- package/nodes/materials/BasicNodeMaterial.cjs.js +0 -1
- package/nodes/materials/BasicNodeMaterial.d.ts +0 -11
- package/nodes/materials/BasicNodeMaterial.js +0 -15
- package/nodes/materials/PhongNodeMaterial.cjs.js +0 -1
- package/nodes/materials/PhongNodeMaterial.d.ts +0 -21
- package/nodes/materials/PhongNodeMaterial.js +0 -15
- package/nodes/materials/SpriteNodeMaterial.cjs.js +0 -1
- package/nodes/materials/SpriteNodeMaterial.d.ts +0 -12
- package/nodes/materials/SpriteNodeMaterial.js +0 -15
- package/nodes/materials/StandardNodeMaterial.cjs.js +0 -1
- package/nodes/materials/StandardNodeMaterial.d.ts +0 -25
- package/nodes/materials/StandardNodeMaterial.js +0 -15
- package/nodes/materials/nodes/BasicNode.cjs.js +0 -1
- package/nodes/materials/nodes/BasicNode.d.ts +0 -15
- package/nodes/materials/nodes/BasicNode.js +0 -91
- package/nodes/materials/nodes/MeshStandardNode.cjs.js +0 -1
- package/nodes/materials/nodes/MeshStandardNode.d.ts +0 -25
- package/nodes/materials/nodes/MeshStandardNode.js +0 -81
- package/nodes/materials/nodes/PhongNode.cjs.js +0 -1
- package/nodes/materials/nodes/PhongNode.d.ts +0 -14
- package/nodes/materials/nodes/PhongNode.js +0 -212
- package/nodes/materials/nodes/RawNode.cjs.js +0 -1
- package/nodes/materials/nodes/RawNode.d.ts +0 -10
- package/nodes/materials/nodes/RawNode.js +0 -42
- package/nodes/materials/nodes/SpriteNode.cjs.js +0 -1
- package/nodes/materials/nodes/SpriteNode.d.ts +0 -13
- package/nodes/materials/nodes/SpriteNode.js +0 -113
- package/nodes/materials/nodes/StandardNode.cjs.js +0 -1
- package/nodes/materials/nodes/StandardNode.d.ts +0 -15
- package/nodes/materials/nodes/StandardNode.js +0 -336
- package/nodes/misc/BumpMapNode.cjs.js +0 -1
- package/nodes/misc/BumpMapNode.d.ts +0 -21
- package/nodes/misc/BumpMapNode.js +0 -80
- package/nodes/misc/NormalMapNode.cjs.js +0 -1
- package/nodes/misc/NormalMapNode.d.ts +0 -19
- package/nodes/misc/NormalMapNode.js +0 -102
- package/nodes/misc/TextureCubeNode.cjs.js +0 -1
- package/nodes/misc/TextureCubeNode.d.ts +0 -21
- package/nodes/misc/TextureCubeNode.js +0 -52
- package/nodes/misc/TextureCubeUVNode.cjs.js +0 -1
- package/nodes/misc/TextureCubeUVNode.d.ts +0 -18
- package/nodes/misc/TextureCubeUVNode.js +0 -229
- package/nodes/postprocessing/NodePass.cjs.js +0 -1
- package/nodes/postprocessing/NodePass.d.ts +0 -15
- package/nodes/postprocessing/NodePass.js +0 -61
- package/nodes/postprocessing/NodePostProcessing.cjs.js +0 -1
- package/nodes/postprocessing/NodePostProcessing.d.ts +0 -26
- package/nodes/postprocessing/NodePostProcessing.js +0 -91
- package/nodes/procedural/NoiseNode.cjs.js +0 -1
- package/nodes/procedural/NoiseNode.d.ts +0 -17
- package/nodes/procedural/NoiseNode.js +0 -43
- package/nodes/utils/BypassNode.cjs.js +0 -1
- package/nodes/utils/BypassNode.d.ts +0 -11
- package/nodes/utils/BypassNode.js +0 -55
- package/nodes/utils/ColorSpaceNode.cjs.js +0 -1
- package/nodes/utils/ColorSpaceNode.d.ts +0 -55
- package/nodes/utils/ColorSpaceNode.js +0 -106
- package/nodes/utils/MaxMIPLevelNode.cjs.js +0 -1
- package/nodes/utils/MaxMIPLevelNode.d.ts +0 -11
- package/nodes/utils/MaxMIPLevelNode.js +0 -38
- package/nodes/utils/SpecularMIPLevelNode.cjs.js +0 -1
- package/nodes/utils/SpecularMIPLevelNode.d.ts +0 -17
- package/nodes/utils/SpecularMIPLevelNode.js +0 -61
- package/nodes/utils/SubSlotNode.cjs.js +0 -1
- package/nodes/utils/SubSlotNode.js +0 -53
- package/nodes/utils/SwitchNode.cjs.js +0 -1
- package/nodes/utils/SwitchNode.d.ts +0 -11
- package/nodes/utils/SwitchNode.js +0 -69
- package/nodes/utils/UVTransformNode.cjs.js +0 -1
- package/nodes/utils/UVTransformNode.d.ts +0 -15
- package/nodes/utils/UVTransformNode.js +0 -46
- package/nodes/utils/VelocityNode.cjs.js +0 -1
- package/nodes/utils/VelocityNode.d.ts +0 -28
- package/nodes/utils/VelocityNode.js +0 -115
@@ -1,336 +0,0 @@
|
|
1
|
-
import { UniformsUtils, UniformsLib } from 'three';
|
2
|
-
import { Node } from '../../core/Node.js';
|
3
|
-
import { ExpressionNode } from '../../core/ExpressionNode.js';
|
4
|
-
import { ColorNode } from '../../inputs/ColorNode.js';
|
5
|
-
import { FloatNode } from '../../inputs/FloatNode.js';
|
6
|
-
import { SpecularMIPLevelNode } from '../../utils/SpecularMIPLevelNode.js';
|
7
|
-
|
8
|
-
function StandardNode() {
|
9
|
-
Node.call(this);
|
10
|
-
this.color = new ColorNode(0xffffff);
|
11
|
-
this.roughness = new FloatNode(1);
|
12
|
-
this.metalness = new FloatNode(0);
|
13
|
-
}
|
14
|
-
|
15
|
-
StandardNode.prototype = Object.create(Node.prototype);
|
16
|
-
StandardNode.prototype.constructor = StandardNode;
|
17
|
-
StandardNode.prototype.nodeType = 'Standard';
|
18
|
-
|
19
|
-
StandardNode.prototype.build = function (builder) {
|
20
|
-
var code;
|
21
|
-
builder.define('STANDARD');
|
22
|
-
var useClearcoat = this.clearcoat || this.clearcoatRoughness || this.clearCoatNormal;
|
23
|
-
|
24
|
-
if (useClearcoat) {
|
25
|
-
builder.define('CLEARCOAT');
|
26
|
-
}
|
27
|
-
|
28
|
-
builder.requires.lights = true;
|
29
|
-
builder.extensions.derivatives = true;
|
30
|
-
builder.extensions.shaderTextureLOD = true;
|
31
|
-
|
32
|
-
if (builder.isShader('vertex')) {
|
33
|
-
var position = this.position ? this.position.analyzeAndFlow(builder, 'v3', {
|
34
|
-
cache: 'position'
|
35
|
-
}) : undefined;
|
36
|
-
builder.mergeUniform(UniformsUtils.merge([UniformsLib.fog, UniformsLib.lights]));
|
37
|
-
|
38
|
-
if (UniformsLib.LTC_1) {
|
39
|
-
// add ltc data textures to material uniforms
|
40
|
-
builder.uniforms.ltc_1 = {
|
41
|
-
value: undefined
|
42
|
-
};
|
43
|
-
builder.uniforms.ltc_2 = {
|
44
|
-
value: undefined
|
45
|
-
};
|
46
|
-
}
|
47
|
-
|
48
|
-
builder.addParsCode(['varying vec3 vViewPosition;', '#ifndef FLAT_SHADED', ' varying vec3 vNormal;', '#endif', //"#include <encodings_pars_fragment>", // encoding functions
|
49
|
-
'#include <fog_pars_vertex>', '#include <morphtarget_pars_vertex>', '#include <skinning_pars_vertex>', '#include <shadowmap_pars_vertex>', '#include <logdepthbuf_pars_vertex>', '#include <clipping_planes_pars_vertex>'].join('\n'));
|
50
|
-
var output = ['#include <beginnormal_vertex>', '#include <morphnormal_vertex>', '#include <skinbase_vertex>', '#include <skinnormal_vertex>', '#include <defaultnormal_vertex>', '#ifndef FLAT_SHADED', // Normal computed with derivatives when FLAT_SHADED
|
51
|
-
' vNormal = normalize( transformedNormal );', '#endif', '#include <begin_vertex>'];
|
52
|
-
|
53
|
-
if (position) {
|
54
|
-
output.push(position.code, position.result ? 'transformed = ' + position.result + ';' : '');
|
55
|
-
}
|
56
|
-
|
57
|
-
output.push('#include <morphtarget_vertex>', '#include <skinning_vertex>', '#include <project_vertex>', '#include <fog_vertex>', '#include <logdepthbuf_vertex>', '#include <clipping_planes_vertex>', ' vViewPosition = - mvPosition.xyz;', '#include <worldpos_vertex>', '#include <shadowmap_vertex>');
|
58
|
-
code = output.join('\n');
|
59
|
-
} else {
|
60
|
-
var specularRoughness = new ExpressionNode('material.specularRoughness', 'f');
|
61
|
-
var clearcoatRoughness = new ExpressionNode('material.clearcoatRoughness', 'f');
|
62
|
-
var contextEnvironment = {
|
63
|
-
roughness: specularRoughness,
|
64
|
-
bias: new SpecularMIPLevelNode(specularRoughness),
|
65
|
-
viewNormal: new ExpressionNode('normal', 'v3'),
|
66
|
-
worldNormal: new ExpressionNode('inverseTransformDirection( geometry.normal, viewMatrix )', 'v3'),
|
67
|
-
gamma: true
|
68
|
-
};
|
69
|
-
var contextGammaOnly = {
|
70
|
-
gamma: true
|
71
|
-
};
|
72
|
-
var contextClearcoatEnvironment = {
|
73
|
-
roughness: clearcoatRoughness,
|
74
|
-
bias: new SpecularMIPLevelNode(clearcoatRoughness),
|
75
|
-
viewNormal: new ExpressionNode('clearcoatNormal', 'v3'),
|
76
|
-
worldNormal: new ExpressionNode('inverseTransformDirection( geometry.clearcoatNormal, viewMatrix )', 'v3'),
|
77
|
-
gamma: true
|
78
|
-
}; // analyze all nodes to reuse generate codes
|
79
|
-
|
80
|
-
if (this.mask) this.mask.analyze(builder);
|
81
|
-
this.color.analyze(builder, {
|
82
|
-
slot: 'color',
|
83
|
-
context: contextGammaOnly
|
84
|
-
});
|
85
|
-
this.roughness.analyze(builder);
|
86
|
-
this.metalness.analyze(builder);
|
87
|
-
if (this.alpha) this.alpha.analyze(builder);
|
88
|
-
if (this.normal) this.normal.analyze(builder);
|
89
|
-
if (this.clearcoat) this.clearcoat.analyze(builder);
|
90
|
-
if (this.clearcoatRoughness) this.clearcoatRoughness.analyze(builder);
|
91
|
-
if (this.clearcoatNormal) this.clearcoatNormal.analyze(builder);
|
92
|
-
if (this.reflectivity) this.reflectivity.analyze(builder);
|
93
|
-
if (this.light) this.light.analyze(builder, {
|
94
|
-
cache: 'light'
|
95
|
-
});
|
96
|
-
if (this.ao) this.ao.analyze(builder);
|
97
|
-
if (this.ambient) this.ambient.analyze(builder);
|
98
|
-
if (this.shadow) this.shadow.analyze(builder);
|
99
|
-
if (this.emissive) this.emissive.analyze(builder, {
|
100
|
-
slot: 'emissive'
|
101
|
-
});
|
102
|
-
|
103
|
-
if (this.environment) {
|
104
|
-
// isolate environment from others inputs ( see TextureNode, CubeTextureNode )
|
105
|
-
// environment.analyze will detect if there is a need of calculate irradiance
|
106
|
-
this.environment.analyze(builder, {
|
107
|
-
cache: 'radiance',
|
108
|
-
context: contextEnvironment,
|
109
|
-
slot: 'radiance'
|
110
|
-
});
|
111
|
-
|
112
|
-
if (builder.requires.irradiance) {
|
113
|
-
this.environment.analyze(builder, {
|
114
|
-
cache: 'irradiance',
|
115
|
-
context: contextEnvironment,
|
116
|
-
slot: 'irradiance'
|
117
|
-
});
|
118
|
-
}
|
119
|
-
}
|
120
|
-
|
121
|
-
if (this.sheen) this.sheen.analyze(builder); // build code
|
122
|
-
|
123
|
-
var mask = this.mask ? this.mask.flow(builder, 'b') : undefined;
|
124
|
-
var color = this.color.flow(builder, 'c', {
|
125
|
-
slot: 'color',
|
126
|
-
context: contextGammaOnly
|
127
|
-
});
|
128
|
-
var roughness = this.roughness.flow(builder, 'f');
|
129
|
-
var metalness = this.metalness.flow(builder, 'f');
|
130
|
-
var alpha = this.alpha ? this.alpha.flow(builder, 'f') : undefined;
|
131
|
-
var normal = this.normal ? this.normal.flow(builder, 'v3') : undefined;
|
132
|
-
var clearcoat = this.clearcoat ? this.clearcoat.flow(builder, 'f') : undefined;
|
133
|
-
var clearcoatRoughness = this.clearcoatRoughness ? this.clearcoatRoughness.flow(builder, 'f') : undefined;
|
134
|
-
var clearcoatNormal = this.clearcoatNormal ? this.clearcoatNormal.flow(builder, 'v3') : undefined;
|
135
|
-
var reflectivity = this.reflectivity ? this.reflectivity.flow(builder, 'f') : undefined;
|
136
|
-
var light = this.light ? this.light.flow(builder, 'v3', {
|
137
|
-
cache: 'light'
|
138
|
-
}) : undefined;
|
139
|
-
var ao = this.ao ? this.ao.flow(builder, 'f') : undefined;
|
140
|
-
var ambient = this.ambient ? this.ambient.flow(builder, 'c') : undefined;
|
141
|
-
var shadow = this.shadow ? this.shadow.flow(builder, 'c') : undefined;
|
142
|
-
var emissive = this.emissive ? this.emissive.flow(builder, 'c', {
|
143
|
-
slot: 'emissive'
|
144
|
-
}) : undefined;
|
145
|
-
var environment;
|
146
|
-
|
147
|
-
if (this.environment) {
|
148
|
-
environment = {
|
149
|
-
radiance: this.environment.flow(builder, 'c', {
|
150
|
-
cache: 'radiance',
|
151
|
-
context: contextEnvironment,
|
152
|
-
slot: 'radiance'
|
153
|
-
})
|
154
|
-
};
|
155
|
-
|
156
|
-
if (builder.requires.irradiance) {
|
157
|
-
environment.irradiance = this.environment.flow(builder, 'c', {
|
158
|
-
cache: 'irradiance',
|
159
|
-
context: contextEnvironment,
|
160
|
-
slot: 'irradiance'
|
161
|
-
});
|
162
|
-
}
|
163
|
-
}
|
164
|
-
|
165
|
-
var clearcoatEnv = useClearcoat && environment ? this.environment.flow(builder, 'c', {
|
166
|
-
cache: 'clearcoat',
|
167
|
-
context: contextClearcoatEnvironment,
|
168
|
-
slot: 'environment'
|
169
|
-
}) : undefined;
|
170
|
-
var sheen = this.sheen ? this.sheen.flow(builder, 'c') : undefined;
|
171
|
-
builder.requires.transparent = alpha !== undefined;
|
172
|
-
builder.addParsCode(['varying vec3 vViewPosition;', '#ifndef FLAT_SHADED', ' varying vec3 vNormal;', '#endif', '#include <dithering_pars_fragment>', '#include <fog_pars_fragment>', '#include <bsdfs>', '#include <lights_pars_begin>', '#include <lights_physical_pars_fragment>', '#include <shadowmap_pars_fragment>', '#include <logdepthbuf_pars_fragment>'].join('\n'));
|
173
|
-
var output = ['#include <clipping_planes_fragment>', // add before: prevent undeclared normal
|
174
|
-
' #include <normal_fragment_begin>', ' #include <clearcoat_normal_fragment_begin>', // add before: prevent undeclared material
|
175
|
-
' PhysicalMaterial material;', ' material.diffuseColor = vec3( 1.0 );'];
|
176
|
-
|
177
|
-
if (mask) {
|
178
|
-
output.push(mask.code, 'if ( ! ' + mask.result + ' ) discard;');
|
179
|
-
}
|
180
|
-
|
181
|
-
output.push(color.code, ' vec3 diffuseColor = ' + color.result + ';', ' ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );', '#include <logdepthbuf_fragment>', roughness.code, ' float roughnessFactor = ' + roughness.result + ';', metalness.code, ' float metalnessFactor = ' + metalness.result + ';');
|
182
|
-
|
183
|
-
if (alpha) {
|
184
|
-
output.push(alpha.code, '#ifdef ALPHATEST', ' if ( ' + alpha.result + ' <= ALPHATEST ) discard;', '#endif');
|
185
|
-
}
|
186
|
-
|
187
|
-
if (normal) {
|
188
|
-
output.push(normal.code, 'normal = ' + normal.result + ';');
|
189
|
-
}
|
190
|
-
|
191
|
-
if (clearcoatNormal) {
|
192
|
-
output.push(clearcoatNormal.code, 'clearcoatNormal = ' + clearcoatNormal.result + ';');
|
193
|
-
} // anti-aliasing code by @elalish
|
194
|
-
|
195
|
-
|
196
|
-
output.push('vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );', 'float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );'); // optimization for now
|
197
|
-
|
198
|
-
output.push('material.diffuseColor = ' + (light ? 'vec3( 1.0 )' : 'diffuseColor * ( 1.0 - metalnessFactor )') + ';', 'material.specularRoughness = max( roughnessFactor, 0.0525 );', 'material.specularRoughness += geometryRoughness;', 'material.specularRoughness = min( material.specularRoughness, 1.0 );', 'material.specularRoughness = clamp( roughnessFactor, 0.04, 1.0 );');
|
199
|
-
|
200
|
-
if (clearcoat) {
|
201
|
-
output.push(clearcoat.code, 'material.clearcoat = saturate( ' + clearcoat.result + ' );' // Burley clearcoat model
|
202
|
-
);
|
203
|
-
} else if (useClearcoat) {
|
204
|
-
output.push('material.clearcoat = 0.0;');
|
205
|
-
}
|
206
|
-
|
207
|
-
if (clearcoatRoughness) {
|
208
|
-
output.push(clearcoatRoughness.code, 'material.clearcoatRoughness = max( ' + clearcoatRoughness.result + ', 0.0525 );', 'material.clearcoatRoughness += geometryRoughness;', 'material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );');
|
209
|
-
} else if (useClearcoat) {
|
210
|
-
output.push('material.clearcoatRoughness = 0.0;');
|
211
|
-
}
|
212
|
-
|
213
|
-
if (sheen) {
|
214
|
-
output.push('material.sheenColor = ' + sheen.result + ';');
|
215
|
-
}
|
216
|
-
|
217
|
-
if (reflectivity) {
|
218
|
-
output.push(reflectivity.code, 'material.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( ' + reflectivity.result + ' ) ), diffuseColor, metalnessFactor );');
|
219
|
-
} else {
|
220
|
-
output.push('material.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor, metalnessFactor );');
|
221
|
-
}
|
222
|
-
|
223
|
-
output.push('#include <lights_fragment_begin>');
|
224
|
-
|
225
|
-
if (light) {
|
226
|
-
output.push(light.code, 'reflectedLight.directDiffuse = ' + light.result + ';'); // apply color
|
227
|
-
|
228
|
-
output.push('diffuseColor *= 1.0 - metalnessFactor;', 'reflectedLight.directDiffuse *= diffuseColor;', 'reflectedLight.indirectDiffuse *= diffuseColor;');
|
229
|
-
}
|
230
|
-
|
231
|
-
if (ao) {
|
232
|
-
output.push(ao.code, 'reflectedLight.indirectDiffuse *= ' + ao.result + ';', 'float dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );', 'reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ' + ao.result + ', material.specularRoughness );');
|
233
|
-
}
|
234
|
-
|
235
|
-
if (ambient) {
|
236
|
-
output.push(ambient.code, 'reflectedLight.indirectDiffuse += ' + ambient.result + ';');
|
237
|
-
}
|
238
|
-
|
239
|
-
if (shadow) {
|
240
|
-
output.push(shadow.code, 'reflectedLight.directDiffuse *= ' + shadow.result + ';', 'reflectedLight.directSpecular *= ' + shadow.result + ';');
|
241
|
-
}
|
242
|
-
|
243
|
-
if (emissive) {
|
244
|
-
output.push(emissive.code, 'reflectedLight.directDiffuse += ' + emissive.result + ';');
|
245
|
-
}
|
246
|
-
|
247
|
-
if (environment) {
|
248
|
-
output.push(environment.radiance.code);
|
249
|
-
|
250
|
-
if (builder.requires.irradiance) {
|
251
|
-
output.push(environment.irradiance.code);
|
252
|
-
}
|
253
|
-
|
254
|
-
if (clearcoatEnv) {
|
255
|
-
output.push(clearcoatEnv.code, 'clearcoatRadiance += ' + clearcoatEnv.result + ';');
|
256
|
-
}
|
257
|
-
|
258
|
-
output.push('radiance += ' + environment.radiance.result + ';');
|
259
|
-
|
260
|
-
if (builder.requires.irradiance) {
|
261
|
-
output.push('iblIrradiance += PI * ' + environment.irradiance.result + ';');
|
262
|
-
}
|
263
|
-
}
|
264
|
-
|
265
|
-
output.push('#include <lights_fragment_end>');
|
266
|
-
output.push('vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular;');
|
267
|
-
|
268
|
-
if (alpha) {
|
269
|
-
output.push('gl_FragColor = vec4( outgoingLight, ' + alpha.result + ' );');
|
270
|
-
} else {
|
271
|
-
output.push('gl_FragColor = vec4( outgoingLight, 1.0 );');
|
272
|
-
}
|
273
|
-
|
274
|
-
output.push('#include <tonemapping_fragment>', '#include <encodings_fragment>', '#include <fog_fragment>', '#include <premultiplied_alpha_fragment>', '#include <dithering_fragment>');
|
275
|
-
code = output.join('\n');
|
276
|
-
}
|
277
|
-
|
278
|
-
return code;
|
279
|
-
};
|
280
|
-
|
281
|
-
StandardNode.prototype.copy = function (source) {
|
282
|
-
Node.prototype.copy.call(this, source); // vertex
|
283
|
-
|
284
|
-
if (source.position) this.position = source.position; // fragment
|
285
|
-
|
286
|
-
this.color = source.color;
|
287
|
-
this.roughness = source.roughness;
|
288
|
-
this.metalness = source.metalness;
|
289
|
-
if (source.mask) this.mask = source.mask;
|
290
|
-
if (source.alpha) this.alpha = source.alpha;
|
291
|
-
if (source.normal) this.normal = source.normal;
|
292
|
-
if (source.clearcoat) this.clearcoat = source.clearcoat;
|
293
|
-
if (source.clearcoatRoughness) this.clearcoatRoughness = source.clearcoatRoughness;
|
294
|
-
if (source.clearcoatNormal) this.clearcoatNormal = source.clearcoatNormal;
|
295
|
-
if (source.reflectivity) this.reflectivity = source.reflectivity;
|
296
|
-
if (source.light) this.light = source.light;
|
297
|
-
if (source.shadow) this.shadow = source.shadow;
|
298
|
-
if (source.ao) this.ao = source.ao;
|
299
|
-
if (source.emissive) this.emissive = source.emissive;
|
300
|
-
if (source.ambient) this.ambient = source.ambient;
|
301
|
-
if (source.environment) this.environment = source.environment;
|
302
|
-
if (source.sheen) this.sheen = source.sheen;
|
303
|
-
return this;
|
304
|
-
};
|
305
|
-
|
306
|
-
StandardNode.prototype.toJSON = function (meta) {
|
307
|
-
var data = this.getJSONNode(meta);
|
308
|
-
|
309
|
-
if (!data) {
|
310
|
-
data = this.createJSONNode(meta); // vertex
|
311
|
-
|
312
|
-
if (this.position) data.position = this.position.toJSON(meta).uuid; // fragment
|
313
|
-
|
314
|
-
data.color = this.color.toJSON(meta).uuid;
|
315
|
-
data.roughness = this.roughness.toJSON(meta).uuid;
|
316
|
-
data.metalness = this.metalness.toJSON(meta).uuid;
|
317
|
-
if (this.mask) data.mask = this.mask.toJSON(meta).uuid;
|
318
|
-
if (this.alpha) data.alpha = this.alpha.toJSON(meta).uuid;
|
319
|
-
if (this.normal) data.normal = this.normal.toJSON(meta).uuid;
|
320
|
-
if (this.clearcoat) data.clearcoat = this.clearcoat.toJSON(meta).uuid;
|
321
|
-
if (this.clearcoatRoughness) data.clearcoatRoughness = this.clearcoatRoughness.toJSON(meta).uuid;
|
322
|
-
if (this.clearcoatNormal) data.clearcoatNormal = this.clearcoatNormal.toJSON(meta).uuid;
|
323
|
-
if (this.reflectivity) data.reflectivity = this.reflectivity.toJSON(meta).uuid;
|
324
|
-
if (this.light) data.light = this.light.toJSON(meta).uuid;
|
325
|
-
if (this.shadow) data.shadow = this.shadow.toJSON(meta).uuid;
|
326
|
-
if (this.ao) data.ao = this.ao.toJSON(meta).uuid;
|
327
|
-
if (this.emissive) data.emissive = this.emissive.toJSON(meta).uuid;
|
328
|
-
if (this.ambient) data.ambient = this.ambient.toJSON(meta).uuid;
|
329
|
-
if (this.environment) data.environment = this.environment.toJSON(meta).uuid;
|
330
|
-
if (this.sheen) data.sheen = this.sheen.toJSON(meta).uuid;
|
331
|
-
}
|
332
|
-
|
333
|
-
return data;
|
334
|
-
};
|
335
|
-
|
336
|
-
export { StandardNode };
|
@@ -1 +0,0 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("../core/TempNode.cjs.js"),o=require("../inputs/FloatNode.cjs.js"),r=require("../core/FunctionNode.cjs.js"),s=require("../accessors/NormalNode.cjs.js"),d=require("../accessors/PositionNode.cjs.js");function a(e,r){t.TempNode.call(this,"v3"),this.value=e,this.scale=r||new o.FloatNode(1),this.toNormalMap=!1}require("three"),require("../core/Node.cjs.js"),require("../core/InputNode.cjs.js"),require("../core/NodeLib.cjs.js"),a.Nodes={dHdxy_fwd:e=new r.FunctionNode(["vec2 dHdxy_fwd( sampler2D bumpMap, vec2 vUv, float bumpScale ) {","\tvec2 dSTdx = dFdx( vUv );","\tvec2 dSTdy = dFdy( vUv );","\tfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;","\tfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;","\tfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;","\treturn vec2( dBx, dBy );","}"].join("\n"),null,{derivatives:!0}),perturbNormalArb:new r.FunctionNode(["vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {","\tvec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );","\tvec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );","\tvec3 vN = surf_norm;","\tvec3 R1 = cross( vSigmaY, vN );","\tvec3 R2 = cross( vN, vSigmaX );","\tfloat fDet = dot( vSigmaX, R1 );","\tfDet *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );","\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );","\treturn normalize( abs( fDet ) * surf_norm - vGrad );","}"].join("\n"),[e],{derivatives:!0}),bumpToNormal:new r.FunctionNode(["vec3 bumpToNormal( sampler2D bumpMap, vec2 uv, float scale ) {","\tvec2 dSTdx = dFdx( uv );","\tvec2 dSTdy = dFdy( uv );","\tfloat Hll = texture2D( bumpMap, uv ).x;","\tfloat dBx = texture2D( bumpMap, uv + dSTdx ).x - Hll;","\tfloat dBy = texture2D( bumpMap, uv + dSTdy ).x - Hll;","\treturn vec3( .5 - ( dBx * scale ), .5 - ( dBy * scale ), 1.0 );","}"].join("\n"),null,{derivatives:!0})},a.prototype=Object.create(t.TempNode.prototype),a.prototype.constructor=a,a.prototype.nodeType="BumpMap",a.prototype.hashProperties=["toNormalMap"],a.prototype.generate=function(e,t){if(e.isShader("fragment")){if(this.toNormalMap){var o=e.include(a.Nodes.bumpToNormal);return e.format(o+"( "+this.value.build(e,"sampler2D")+", "+this.value.uv.build(e,"v2")+", "+this.scale.build(e,"f")+" )",this.getType(e),t)}var r=e.include(a.Nodes.dHdxy_fwd),u=e.include(a.Nodes.perturbNormalArb);this.normal=this.normal||new s.NormalNode,this.position=this.position||new d.PositionNode(d.PositionNode.VIEW);var i=r+"( "+this.value.build(e,"sampler2D")+", "+this.value.uv.build(e,"v2")+", "+this.scale.build(e,"f")+" )";return e.format(u+"( -"+this.position.build(e,"v3")+", "+this.normal.build(e,"v3")+", "+i+" )",this.getType(e),t)}return console.warn("THREE.BumpMapNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)},a.prototype.copy=function(e){return t.TempNode.prototype.copy.call(this,e),this.value=e.value,this.scale=e.scale,this},a.prototype.toJSON=function(e){var t=this.getJSONNode(e);return t||((t=this.createJSONNode(e)).value=this.value.toJSON(e).uuid,t.scale=this.scale.toJSON(e).uuid),t},exports.BumpMapNode=a;
|
@@ -1,21 +0,0 @@
|
|
1
|
-
import { TempNode } from '../core/TempNode';
|
2
|
-
import { FloatNode } from '../inputs/FloatNode';
|
3
|
-
import { FunctionNode } from '../core/FunctionNode';
|
4
|
-
import { TextureNode } from '../inputs/TextureNode';
|
5
|
-
|
6
|
-
export class BumpMapNode extends TempNode {
|
7
|
-
constructor(value: TextureNode, scale?: FloatNode);
|
8
|
-
|
9
|
-
value: TextureNode;
|
10
|
-
scale: FloatNode;
|
11
|
-
toNormalMap: boolean;
|
12
|
-
nodeType: string;
|
13
|
-
|
14
|
-
copy(source: BumpMapNode): this;
|
15
|
-
|
16
|
-
static Nodes: {
|
17
|
-
dHdxy_fwd: FunctionNode;
|
18
|
-
perturbNormalArb: FunctionNode;
|
19
|
-
bumpToNormal: FunctionNode;
|
20
|
-
};
|
21
|
-
}
|
@@ -1,80 +0,0 @@
|
|
1
|
-
import { TempNode } from '../core/TempNode.js';
|
2
|
-
import { FloatNode } from '../inputs/FloatNode.js';
|
3
|
-
import { FunctionNode } from '../core/FunctionNode.js';
|
4
|
-
import { NormalNode } from '../accessors/NormalNode.js';
|
5
|
-
import { PositionNode } from '../accessors/PositionNode.js';
|
6
|
-
|
7
|
-
function BumpMapNode(value, scale) {
|
8
|
-
TempNode.call(this, 'v3');
|
9
|
-
this.value = value;
|
10
|
-
this.scale = scale || new FloatNode(1);
|
11
|
-
this.toNormalMap = false;
|
12
|
-
}
|
13
|
-
|
14
|
-
BumpMapNode.Nodes = function () {
|
15
|
-
var dHdxy_fwd = new FunctionNode([// Bump Mapping Unparametrized Surfaces on the GPU by Morten S. Mikkelsen
|
16
|
-
// http://api.unrealengine.com/attachments/Engine/Rendering/LightingAndShadows/BumpMappingWithoutTangentSpace/mm_sfgrad_bump.pdf
|
17
|
-
// Evaluate the derivative of the height w.r.t. screen-space using forward differencing (listing 2)
|
18
|
-
'vec2 dHdxy_fwd( sampler2D bumpMap, vec2 vUv, float bumpScale ) {', // Workaround for Adreno 3XX dFd*( vec3 ) bug. See #9988
|
19
|
-
' vec2 dSTdx = dFdx( vUv );', ' vec2 dSTdy = dFdy( vUv );', ' float Hll = bumpScale * texture2D( bumpMap, vUv ).x;', ' float dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;', ' float dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;', ' return vec2( dBx, dBy );', '}'].join('\n'), null, {
|
20
|
-
derivatives: true
|
21
|
-
});
|
22
|
-
var perturbNormalArb = new FunctionNode(['vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {', // Workaround for Adreno 3XX dFd*( vec3 ) bug. See #9988
|
23
|
-
' vec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );', ' vec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );', ' vec3 vN = surf_norm;', // normalized
|
24
|
-
' vec3 R1 = cross( vSigmaY, vN );', ' vec3 R2 = cross( vN, vSigmaX );', ' float fDet = dot( vSigmaX, R1 );', ' fDet *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );', ' vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );', ' return normalize( abs( fDet ) * surf_norm - vGrad );', '}'].join('\n'), [dHdxy_fwd], {
|
25
|
-
derivatives: true
|
26
|
-
});
|
27
|
-
var bumpToNormal = new FunctionNode(['vec3 bumpToNormal( sampler2D bumpMap, vec2 uv, float scale ) {', ' vec2 dSTdx = dFdx( uv );', ' vec2 dSTdy = dFdy( uv );', ' float Hll = texture2D( bumpMap, uv ).x;', ' float dBx = texture2D( bumpMap, uv + dSTdx ).x - Hll;', ' float dBy = texture2D( bumpMap, uv + dSTdy ).x - Hll;', ' return vec3( .5 - ( dBx * scale ), .5 - ( dBy * scale ), 1.0 );', '}'].join('\n'), null, {
|
28
|
-
derivatives: true
|
29
|
-
});
|
30
|
-
return {
|
31
|
-
dHdxy_fwd: dHdxy_fwd,
|
32
|
-
perturbNormalArb: perturbNormalArb,
|
33
|
-
bumpToNormal: bumpToNormal
|
34
|
-
};
|
35
|
-
}();
|
36
|
-
|
37
|
-
BumpMapNode.prototype = Object.create(TempNode.prototype);
|
38
|
-
BumpMapNode.prototype.constructor = BumpMapNode;
|
39
|
-
BumpMapNode.prototype.nodeType = 'BumpMap';
|
40
|
-
BumpMapNode.prototype.hashProperties = ['toNormalMap'];
|
41
|
-
|
42
|
-
BumpMapNode.prototype.generate = function (builder, output) {
|
43
|
-
if (builder.isShader('fragment')) {
|
44
|
-
if (this.toNormalMap) {
|
45
|
-
var bumpToNormal = builder.include(BumpMapNode.Nodes.bumpToNormal);
|
46
|
-
return builder.format(bumpToNormal + '( ' + this.value.build(builder, 'sampler2D') + ', ' + this.value.uv.build(builder, 'v2') + ', ' + this.scale.build(builder, 'f') + ' )', this.getType(builder), output);
|
47
|
-
} else {
|
48
|
-
var derivativeHeight = builder.include(BumpMapNode.Nodes.dHdxy_fwd),
|
49
|
-
perturbNormalArb = builder.include(BumpMapNode.Nodes.perturbNormalArb);
|
50
|
-
this.normal = this.normal || new NormalNode();
|
51
|
-
this.position = this.position || new PositionNode(PositionNode.VIEW);
|
52
|
-
var derivativeHeightCode = derivativeHeight + '( ' + this.value.build(builder, 'sampler2D') + ', ' + this.value.uv.build(builder, 'v2') + ', ' + this.scale.build(builder, 'f') + ' )';
|
53
|
-
return builder.format(perturbNormalArb + '( -' + this.position.build(builder, 'v3') + ', ' + this.normal.build(builder, 'v3') + ', ' + derivativeHeightCode + ' )', this.getType(builder), output);
|
54
|
-
}
|
55
|
-
} else {
|
56
|
-
console.warn('THREE.BumpMapNode is not compatible with ' + builder.shader + ' shader.');
|
57
|
-
return builder.format('vec3( 0.0 )', this.getType(builder), output);
|
58
|
-
}
|
59
|
-
};
|
60
|
-
|
61
|
-
BumpMapNode.prototype.copy = function (source) {
|
62
|
-
TempNode.prototype.copy.call(this, source);
|
63
|
-
this.value = source.value;
|
64
|
-
this.scale = source.scale;
|
65
|
-
return this;
|
66
|
-
};
|
67
|
-
|
68
|
-
BumpMapNode.prototype.toJSON = function (meta) {
|
69
|
-
var data = this.getJSONNode(meta);
|
70
|
-
|
71
|
-
if (!data) {
|
72
|
-
data = this.createJSONNode(meta);
|
73
|
-
data.value = this.value.toJSON(meta).uuid;
|
74
|
-
data.scale = this.scale.toJSON(meta).uuid;
|
75
|
-
}
|
76
|
-
|
77
|
-
return data;
|
78
|
-
};
|
79
|
-
|
80
|
-
export { BumpMapNode };
|
@@ -1 +0,0 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("three"),t=require("../core/TempNode.cjs.js"),o=require("../inputs/Vector2Node.cjs.js"),r=require("../core/FunctionNode.cjs.js"),s=require("../accessors/UVNode.cjs.js"),n=require("../accessors/NormalNode.cjs.js"),i=require("../accessors/PositionNode.cjs.js");function a(e,r){t.TempNode.call(this,"v3"),this.value=e,this.scale=r||new o.Vector2Node(1,1)}require("../core/Node.cjs.js"),require("../core/InputNode.cjs.js"),require("../core/NodeUtils.cjs.js"),require("../core/NodeLib.cjs.js"),a.Nodes={perturbNormal2Arb:new r.FunctionNode("vec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 map, vec2 vUv, vec2 normalScale ) {\n\n\t\t// Workaround for Adreno 3XX dFd*( vec3 ) bug. See #9988\n\n\t\tvec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );\n\t\tvec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );\n\t\tvec2 st0 = dFdx( vUv.st );\n\t\tvec2 st1 = dFdy( vUv.st );\n\n\t\tfloat scale = sign( st1.t * st0.s - st0.t * st1.s ); // we do not care about the magnitude\n\n\t\tvec3 S = normalize( ( q0 * st1.t - q1 * st0.t ) * scale );\n\t\tvec3 T = normalize( ( - q0 * st1.s + q1 * st0.s ) * scale );\n\t\tvec3 N = normalize( surf_norm );\n\n\t\tvec3 mapN = map * 2.0 - 1.0;\n\n\t\tmapN.xy *= normalScale;\n\n\t\t#ifdef DOUBLE_SIDED\n\n\t\t\t// Workaround for Adreno GPUs gl_FrontFacing bug. See #15850 and #10331\n\n\t\t\tif ( dot( cross( S, T ), N ) < 0.0 ) mapN.xy *= - 1.0;\n\n\t\t#else\n\n\t\t\tmapN.xy *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\n\t\t#endif\n\n\t\tmat3 tsn = mat3( S, T, N );\n\t\treturn normalize( tsn * mapN );\n\n\t}",null,{derivatives:!0})},a.prototype=Object.create(t.TempNode.prototype),a.prototype.constructor=a,a.prototype.nodeType="NormalMap",a.prototype.generate=function(t,o){if(t.isShader("fragment")){var r=t.include(a.Nodes.perturbNormal2Arb);this.normal=this.normal||new n.NormalNode,this.position=this.position||new i.PositionNode(i.PositionNode.VIEW),this.uv=this.uv||new s.UVNode;var c=this.scale.build(t,"v2");return t.material.side===e.BackSide&&(c="-"+c),t.format(r+"( -"+this.position.build(t,"v3")+", "+this.normal.build(t,"v3")+", "+this.value.build(t,"v3")+", "+this.uv.build(t,"v2")+", "+c+" )",this.getType(t),o)}return console.warn("THREE.NormalMapNode is not compatible with "+t.shader+" shader."),t.format("vec3( 0.0 )",this.getType(t),o)},a.prototype.copy=function(e){return t.TempNode.prototype.copy.call(this,e),this.value=e.value,this.scale=e.scale,this},a.prototype.toJSON=function(e){var t=this.getJSONNode(e);return t||((t=this.createJSONNode(e)).value=this.value.toJSON(e).uuid,t.scale=this.scale.toJSON(e).uuid),t},exports.NormalMapNode=a;
|
@@ -1,19 +0,0 @@
|
|
1
|
-
import { TempNode } from '../core/TempNode';
|
2
|
-
import { FunctionNode } from '../core/FunctionNode';
|
3
|
-
import { TextureNode } from '../inputs/TextureNode';
|
4
|
-
import { Vector2Node } from '../inputs/Vector2Node';
|
5
|
-
|
6
|
-
export class NormalMapNode extends TempNode {
|
7
|
-
constructor(value: TextureNode, scale?: Vector2Node);
|
8
|
-
|
9
|
-
value: TextureNode;
|
10
|
-
scale: Vector2Node;
|
11
|
-
toNormalMap: boolean;
|
12
|
-
nodeType: string;
|
13
|
-
|
14
|
-
copy(source: NormalMapNode): this;
|
15
|
-
|
16
|
-
static Nodes: {
|
17
|
-
perturbNormal2Arb: FunctionNode;
|
18
|
-
};
|
19
|
-
}
|
@@ -1,102 +0,0 @@
|
|
1
|
-
import { BackSide } from 'three';
|
2
|
-
import { TempNode } from '../core/TempNode.js';
|
3
|
-
import { Vector2Node } from '../inputs/Vector2Node.js';
|
4
|
-
import { FunctionNode } from '../core/FunctionNode.js';
|
5
|
-
import { UVNode } from '../accessors/UVNode.js';
|
6
|
-
import { NormalNode } from '../accessors/NormalNode.js';
|
7
|
-
import { PositionNode } from '../accessors/PositionNode.js';
|
8
|
-
|
9
|
-
function NormalMapNode(value, scale) {
|
10
|
-
TempNode.call(this, 'v3');
|
11
|
-
this.value = value;
|
12
|
-
this.scale = scale || new Vector2Node(1, 1);
|
13
|
-
}
|
14
|
-
|
15
|
-
NormalMapNode.Nodes = function () {
|
16
|
-
var perturbNormal2Arb = new FunctionNode( // Per-Pixel Tangent Space Normal Mapping
|
17
|
-
// http://hacksoflife.blogspot.ch/2009/11/per-pixel-tangent-space-normal-mapping.html
|
18
|
-
`vec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 map, vec2 vUv, vec2 normalScale ) {
|
19
|
-
|
20
|
-
// Workaround for Adreno 3XX dFd*( vec3 ) bug. See #9988
|
21
|
-
|
22
|
-
vec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );
|
23
|
-
vec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );
|
24
|
-
vec2 st0 = dFdx( vUv.st );
|
25
|
-
vec2 st1 = dFdy( vUv.st );
|
26
|
-
|
27
|
-
float scale = sign( st1.t * st0.s - st0.t * st1.s ); // we do not care about the magnitude
|
28
|
-
|
29
|
-
vec3 S = normalize( ( q0 * st1.t - q1 * st0.t ) * scale );
|
30
|
-
vec3 T = normalize( ( - q0 * st1.s + q1 * st0.s ) * scale );
|
31
|
-
vec3 N = normalize( surf_norm );
|
32
|
-
|
33
|
-
vec3 mapN = map * 2.0 - 1.0;
|
34
|
-
|
35
|
-
mapN.xy *= normalScale;
|
36
|
-
|
37
|
-
#ifdef DOUBLE_SIDED
|
38
|
-
|
39
|
-
// Workaround for Adreno GPUs gl_FrontFacing bug. See #15850 and #10331
|
40
|
-
|
41
|
-
if ( dot( cross( S, T ), N ) < 0.0 ) mapN.xy *= - 1.0;
|
42
|
-
|
43
|
-
#else
|
44
|
-
|
45
|
-
mapN.xy *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );
|
46
|
-
|
47
|
-
#endif
|
48
|
-
|
49
|
-
mat3 tsn = mat3( S, T, N );
|
50
|
-
return normalize( tsn * mapN );
|
51
|
-
|
52
|
-
}`, null, {
|
53
|
-
derivatives: true
|
54
|
-
});
|
55
|
-
return {
|
56
|
-
perturbNormal2Arb: perturbNormal2Arb
|
57
|
-
};
|
58
|
-
}();
|
59
|
-
|
60
|
-
NormalMapNode.prototype = Object.create(TempNode.prototype);
|
61
|
-
NormalMapNode.prototype.constructor = NormalMapNode;
|
62
|
-
NormalMapNode.prototype.nodeType = 'NormalMap';
|
63
|
-
|
64
|
-
NormalMapNode.prototype.generate = function (builder, output) {
|
65
|
-
if (builder.isShader('fragment')) {
|
66
|
-
var perturbNormal2Arb = builder.include(NormalMapNode.Nodes.perturbNormal2Arb);
|
67
|
-
this.normal = this.normal || new NormalNode();
|
68
|
-
this.position = this.position || new PositionNode(PositionNode.VIEW);
|
69
|
-
this.uv = this.uv || new UVNode();
|
70
|
-
var scale = this.scale.build(builder, 'v2');
|
71
|
-
|
72
|
-
if (builder.material.side === BackSide) {
|
73
|
-
scale = '-' + scale;
|
74
|
-
}
|
75
|
-
|
76
|
-
return builder.format(perturbNormal2Arb + '( -' + this.position.build(builder, 'v3') + ', ' + this.normal.build(builder, 'v3') + ', ' + this.value.build(builder, 'v3') + ', ' + this.uv.build(builder, 'v2') + ', ' + scale + ' )', this.getType(builder), output);
|
77
|
-
} else {
|
78
|
-
console.warn('THREE.NormalMapNode is not compatible with ' + builder.shader + ' shader.');
|
79
|
-
return builder.format('vec3( 0.0 )', this.getType(builder), output);
|
80
|
-
}
|
81
|
-
};
|
82
|
-
|
83
|
-
NormalMapNode.prototype.copy = function (source) {
|
84
|
-
TempNode.prototype.copy.call(this, source);
|
85
|
-
this.value = source.value;
|
86
|
-
this.scale = source.scale;
|
87
|
-
return this;
|
88
|
-
};
|
89
|
-
|
90
|
-
NormalMapNode.prototype.toJSON = function (meta) {
|
91
|
-
var data = this.getJSONNode(meta);
|
92
|
-
|
93
|
-
if (!data) {
|
94
|
-
data = this.createJSONNode(meta);
|
95
|
-
data.value = this.value.toJSON(meta).uuid;
|
96
|
-
data.scale = this.scale.toJSON(meta).uuid;
|
97
|
-
}
|
98
|
-
|
99
|
-
return data;
|
100
|
-
};
|
101
|
-
|
102
|
-
export { NormalMapNode };
|
@@ -1 +0,0 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../core/TempNode.cjs.js"),r=require("../inputs/FloatNode.cjs.js"),o=require("./TextureCubeUVNode.cjs.js"),t=require("../accessors/ReflectNode.cjs.js"),s=require("../accessors/NormalNode.cjs.js");function i(i,c,u){e.TempNode.call(this,"v4"),this.value=i,this.radianceNode=new o.TextureCubeUVNode(this.value,c||new t.ReflectNode(t.ReflectNode.VECTOR),u),this.irradianceNode=new o.TextureCubeUVNode(this.value,new s.NormalNode(s.NormalNode.WORLD),new r.FloatNode(1).setReadonly(!0))}require("three"),require("../core/Node.cjs.js"),require("../core/InputNode.cjs.js"),require("../core/ConstNode.cjs.js"),require("../core/StructNode.cjs.js"),require("../core/FunctionNode.cjs.js"),require("../core/NodeLib.cjs.js"),require("../core/FunctionCallNode.cjs.js"),require("../core/ExpressionNode.cjs.js"),require("../math/OperatorNode.cjs.js"),require("../math/MathNode.cjs.js"),require("../utils/ColorSpaceNode.cjs.js"),require("../accessors/PositionNode.cjs.js"),i.prototype=Object.create(e.TempNode.prototype),i.prototype.constructor=i,i.prototype.nodeType="TextureCube",i.prototype.generate=function(e,r){return e.isShader("fragment")?(e.require("irradiance"),e.context.bias&&e.context.bias.setTexture(this.value),("irradiance"===e.slot?this.irradianceNode:this.radianceNode).build(e,r)):(console.warn("THREE.TextureCubeNode is not compatible with "+e.shader+" shader."),e.format("vec4( 0.0 )",this.getType(e),r))},i.prototype.copy=function(r){return e.TempNode.prototype.copy.call(this,r),this.value=r.value,this},i.prototype.toJSON=function(e){var r=this.getJSONNode(e);return r||((r=this.createJSONNode(e)).value=this.value.toJSON(e).uuid),r},exports.TextureCubeNode=i;
|
@@ -1,21 +0,0 @@
|
|
1
|
-
import { TempNode } from '../core/TempNode';
|
2
|
-
import { NodeBuilder } from '../core/NodeBuilder';
|
3
|
-
import { TextureNode } from '../inputs/TextureNode';
|
4
|
-
import { FloatNode } from '../inputs/FloatNode';
|
5
|
-
import { TextureCubeUVNode } from './TextureCubeUVNode';
|
6
|
-
|
7
|
-
export class TextureCubeNode extends TempNode {
|
8
|
-
constructor(value: TextureNode, textureSize?: FloatNode);
|
9
|
-
|
10
|
-
value: TextureNode;
|
11
|
-
textureSize: FloatNode;
|
12
|
-
radianceCache: {
|
13
|
-
uv: TextureCubeUVNode;
|
14
|
-
};
|
15
|
-
irradianceCache: {
|
16
|
-
uv: TextureCubeUVNode;
|
17
|
-
};
|
18
|
-
nodeType: string;
|
19
|
-
|
20
|
-
generateTextureCubeUV(builder: NodeBuilder, output: string): string;
|
21
|
-
}
|
@@ -1,52 +0,0 @@
|
|
1
|
-
import { TempNode } from '../core/TempNode.js';
|
2
|
-
import { FloatNode } from '../inputs/FloatNode.js';
|
3
|
-
import { TextureCubeUVNode } from './TextureCubeUVNode.js';
|
4
|
-
import { ReflectNode } from '../accessors/ReflectNode.js';
|
5
|
-
import { NormalNode } from '../accessors/NormalNode.js';
|
6
|
-
|
7
|
-
function TextureCubeNode(value, uv, bias) {
|
8
|
-
TempNode.call(this, 'v4');
|
9
|
-
this.value = value;
|
10
|
-
this.radianceNode = new TextureCubeUVNode(this.value, uv || new ReflectNode(ReflectNode.VECTOR), // bias should be replaced in builder.context in build process
|
11
|
-
bias);
|
12
|
-
this.irradianceNode = new TextureCubeUVNode(this.value, new NormalNode(NormalNode.WORLD), new FloatNode(1).setReadonly(true));
|
13
|
-
}
|
14
|
-
|
15
|
-
TextureCubeNode.prototype = Object.create(TempNode.prototype);
|
16
|
-
TextureCubeNode.prototype.constructor = TextureCubeNode;
|
17
|
-
TextureCubeNode.prototype.nodeType = 'TextureCube';
|
18
|
-
|
19
|
-
TextureCubeNode.prototype.generate = function (builder, output) {
|
20
|
-
if (builder.isShader('fragment')) {
|
21
|
-
builder.require('irradiance');
|
22
|
-
|
23
|
-
if (builder.context.bias) {
|
24
|
-
builder.context.bias.setTexture(this.value);
|
25
|
-
}
|
26
|
-
|
27
|
-
var scopeNode = builder.slot === 'irradiance' ? this.irradianceNode : this.radianceNode;
|
28
|
-
return scopeNode.build(builder, output);
|
29
|
-
} else {
|
30
|
-
console.warn('THREE.TextureCubeNode is not compatible with ' + builder.shader + ' shader.');
|
31
|
-
return builder.format('vec4( 0.0 )', this.getType(builder), output);
|
32
|
-
}
|
33
|
-
};
|
34
|
-
|
35
|
-
TextureCubeNode.prototype.copy = function (source) {
|
36
|
-
TempNode.prototype.copy.call(this, source);
|
37
|
-
this.value = source.value;
|
38
|
-
return this;
|
39
|
-
};
|
40
|
-
|
41
|
-
TextureCubeNode.prototype.toJSON = function (meta) {
|
42
|
-
var data = this.getJSONNode(meta);
|
43
|
-
|
44
|
-
if (!data) {
|
45
|
-
data = this.createJSONNode(meta);
|
46
|
-
data.value = this.value.toJSON(meta).uuid;
|
47
|
-
}
|
48
|
-
|
49
|
-
return data;
|
50
|
-
};
|
51
|
-
|
52
|
-
export { TextureCubeNode };
|