super-three 0.160.0 → 0.161.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/LICENSE +1 -1
- package/build/three.cjs +380 -109
- package/build/three.module.js +381 -109
- package/build/three.module.min.js +1 -1
- package/examples/jsm/Addons.js +5 -1
- package/examples/jsm/capabilities/WebGPU.js +13 -9
- package/examples/jsm/controls/OrbitControls.js +102 -13
- package/examples/jsm/curves/NURBSUtils.js +59 -4
- package/examples/jsm/curves/NURBSVolume.js +62 -0
- package/examples/jsm/exporters/USDZExporter.js +8 -7
- package/examples/jsm/helpers/TextureHelper.js +3 -3
- package/examples/jsm/loaders/3DMLoader.js +44 -43
- package/examples/jsm/loaders/DDSLoader.js +1 -0
- package/examples/jsm/loaders/KTX2Loader.js +20 -5
- package/examples/jsm/loaders/LUT3dlLoader.js +78 -46
- package/examples/jsm/loaders/LUTCubeLoader.js +81 -67
- package/examples/jsm/loaders/LUTImageLoader.js +3 -2
- package/examples/jsm/loaders/MaterialXLoader.js +115 -16
- package/examples/jsm/loaders/SVGLoader.js +4 -3
- package/examples/jsm/loaders/VRMLLoader.js +1 -1
- package/examples/jsm/materials/MeshPostProcessingMaterial.js +144 -0
- package/examples/jsm/misc/Timer.js +13 -4
- package/examples/jsm/nodes/Nodes.js +16 -5
- package/examples/jsm/nodes/accessors/BufferAttributeNode.js +5 -3
- package/examples/jsm/nodes/accessors/CameraNode.js +9 -4
- package/examples/jsm/nodes/accessors/CubeTextureNode.js +12 -1
- package/examples/jsm/nodes/accessors/StorageBufferNode.js +27 -0
- package/examples/jsm/nodes/accessors/TextureStoreNode.js +56 -3
- package/examples/jsm/nodes/accessors/VertexColorNode.js +70 -0
- package/examples/jsm/nodes/core/AttributeNode.js +1 -1
- package/examples/jsm/nodes/core/NodeBuilder.js +23 -18
- package/examples/jsm/nodes/core/NodeFrame.js +16 -8
- package/examples/jsm/nodes/core/constants.js +1 -0
- package/examples/jsm/nodes/display/AfterImageNode.js +148 -0
- package/examples/jsm/nodes/display/AnamorphicNode.js +148 -0
- package/examples/jsm/nodes/display/ColorAdjustmentNode.js +3 -0
- package/examples/jsm/nodes/display/GaussianBlurNode.js +33 -13
- package/examples/jsm/nodes/display/PassNode.js +3 -2
- package/examples/jsm/nodes/display/ToneMappingNode.js +46 -3
- package/examples/jsm/nodes/display/ViewportDepthTextureNode.js +1 -4
- package/examples/jsm/nodes/display/ViewportNode.js +0 -2
- package/examples/jsm/nodes/display/ViewportSharedTextureNode.js +4 -4
- package/examples/jsm/nodes/fog/FogNode.js +2 -1
- package/examples/jsm/nodes/lighting/AmbientLightNode.js +1 -1
- package/examples/jsm/nodes/lighting/AnalyticLightNode.js +13 -5
- package/examples/jsm/nodes/lighting/LightingContextNode.js +1 -1
- package/examples/jsm/nodes/lighting/LightsNode.js +1 -1
- package/examples/jsm/nodes/materials/Line2NodeMaterial.js +18 -30
- package/examples/jsm/nodes/materials/Materials.js +1 -0
- package/examples/jsm/nodes/materials/MeshSSSNodeMaterial.js +84 -0
- package/examples/jsm/nodes/materials/NodeMaterial.js +6 -4
- package/examples/jsm/nodes/materials/SpriteNodeMaterial.js +1 -7
- package/examples/jsm/nodes/math/MathNode.js +12 -2
- package/examples/jsm/nodes/math/MathUtils.js +15 -0
- package/examples/jsm/nodes/math/OperatorNode.js +13 -5
- package/examples/jsm/nodes/math/TriNoise3D.js +71 -0
- package/examples/jsm/nodes/shadernode/ShaderNode.js +10 -1
- package/examples/jsm/nodes/utils/ArrayElementNode.js +6 -0
- package/examples/jsm/nodes/utils/JoinNode.js +2 -2
- package/examples/jsm/nodes/utils/LoopNode.js +3 -3
- package/examples/jsm/nodes/utils/ReflectorNode.js +227 -0
- package/examples/jsm/nodes/utils/RotateNode.js +68 -0
- package/examples/jsm/nodes/utils/RotateUVNode.js +1 -9
- package/examples/jsm/nodes/utils/SplitNode.js +4 -4
- package/examples/jsm/objects/GroundedSkybox.js +50 -0
- package/examples/jsm/objects/QuadMesh.js +8 -2
- package/examples/jsm/objects/Water2.js +8 -8
- package/examples/jsm/postprocessing/GTAOPass.js +11 -1
- package/examples/jsm/renderers/common/Backend.js +14 -0
- package/examples/jsm/renderers/common/Bindings.js +1 -1
- package/examples/jsm/renderers/common/DataMap.js +1 -1
- package/examples/jsm/renderers/common/Info.js +25 -1
- package/examples/jsm/renderers/common/Pipelines.js +8 -8
- package/examples/jsm/renderers/common/PostProcessing.js +2 -2
- package/examples/jsm/renderers/common/ProgrammableStage.js +3 -1
- package/examples/jsm/renderers/common/RenderObject.js +2 -0
- package/examples/jsm/renderers/common/Renderer.js +238 -22
- package/examples/jsm/renderers/common/StorageBufferAttribute.js +17 -0
- package/examples/jsm/renderers/common/Textures.js +25 -5
- package/examples/jsm/renderers/common/nodes/NodeBuilderState.js +2 -1
- package/examples/jsm/renderers/common/nodes/Nodes.js +4 -2
- package/examples/jsm/renderers/webgl/WebGLBackend.js +631 -270
- package/examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js +37 -30
- package/examples/jsm/renderers/webgl/utils/WebGLAttributeUtils.js +89 -8
- package/examples/jsm/renderers/webgl/utils/WebGLConstants.js +11 -0
- package/examples/jsm/renderers/webgl/utils/WebGLState.js +197 -0
- package/examples/jsm/renderers/webgl/utils/WebGLTextureUtils.js +377 -11
- package/examples/jsm/renderers/webgl/utils/WebGLUtils.js +2 -2
- package/examples/jsm/renderers/webgl-legacy/nodes/GLSL1NodeBuilder.js +1 -21
- package/examples/jsm/renderers/webgl-legacy/nodes/WebGLNodeBuilder.js +2 -2
- package/examples/jsm/renderers/webgpu/WebGPUBackend.js +289 -102
- package/examples/jsm/renderers/webgpu/WebGPURenderer.js +7 -2
- package/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js +56 -39
- package/examples/jsm/renderers/webgpu/utils/WebGPUAttributeUtils.js +9 -1
- package/examples/jsm/renderers/webgpu/utils/WebGPUPipelineUtils.js +38 -4
- package/examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js +85 -12
- package/examples/jsm/transpiler/AST.js +1 -1
- package/examples/jsm/transpiler/GLSLDecoder.js +1 -1
- package/examples/jsm/transpiler/ShaderToyDecoder.js +1 -1
- package/examples/jsm/transpiler/TSLEncoder.js +1 -1
- package/examples/jsm/utils/BufferGeometryUtils.js +23 -27
- package/examples/jsm/utils/SortUtils.js +2 -0
- package/examples/jsm/webxr/ARButton.js +12 -2
- package/examples/jsm/webxr/VRButton.js +12 -2
- package/examples/jsm/webxr/XRButton.js +12 -2
- package/examples/jsm/webxr/XRControllerModelFactory.js +6 -1
- package/examples/jsm/webxr/XRHandMeshModel.js +3 -1
- package/package.json +2 -2
- package/src/audio/Audio.js +1 -3
- package/src/cameras/PerspectiveCamera.js +35 -0
- package/src/constants.js +1 -2
- package/src/core/BufferAttribute.js +2 -1
- package/src/core/InterleavedBuffer.js +2 -1
- package/src/core/InterleavedBufferAttribute.js +20 -0
- package/src/materials/ShaderMaterial.js +2 -1
- package/src/math/Triangle.js +0 -30
- package/src/objects/BatchedMesh.js +6 -7
- package/src/objects/SkinnedMesh.js +0 -8
- package/src/renderers/WebGLRenderer.js +6 -2
- package/src/renderers/shaders/ShaderChunk/alphatest_fragment.glsl.js +9 -0
- package/src/renderers/shaders/ShaderChunk/clipping_planes_fragment.glsl.js +56 -11
- package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +15 -7
- package/src/renderers/shaders/ShaderLib/depth.glsl.js +1 -2
- package/src/renderers/shaders/ShaderLib/distanceRGBA.glsl.js +1 -2
- package/src/renderers/shaders/ShaderLib/linedashed.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/meshbasic.glsl.js +1 -2
- package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/meshmatcap.glsl.js +1 -2
- package/src/renderers/shaders/ShaderLib/meshnormal.glsl.js +3 -1
- package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/meshtoon.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/points.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/sprite.glsl.js +1 -1
- package/src/renderers/webgl/WebGLAttributes.js +2 -2
- package/src/renderers/webgl/WebGLCubeMaps.js +1 -1
- package/src/renderers/webgl/WebGLProgram.js +30 -3
- package/src/renderers/webgl/WebGLPrograms.js +19 -11
- package/src/renderers/webgl/WebGLTextures.js +90 -16
- package/src/renderers/webxr/WebXRDepthSensing.js +105 -0
- package/src/renderers/webxr/WebXRManager.js +46 -0
- package/src/textures/Source.js +1 -0
- package/build/three.js +0 -54519
- package/build/three.min.js +0 -7
- package/examples/jsm/objects/GroundProjectedSkybox.js +0 -172
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { MeshPhysicalMaterial } from 'three';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The aim of this mesh material is to use information from a post processing pass in the diffuse color pass.
|
|
5
|
+
* This material is based on the MeshPhysicalMaterial.
|
|
6
|
+
*
|
|
7
|
+
* In the current state, only the information of a screen space AO pass can be used in the material.
|
|
8
|
+
* Actually, the output of any screen space AO (SSAO, GTAO) can be used,
|
|
9
|
+
* as it is only necessary to provide the AO in one color channel of a texture,
|
|
10
|
+
* however the AO pass must be rendered prior to the color pass,
|
|
11
|
+
* which makes the post-processing pass somewhat of a pre-processing pass.
|
|
12
|
+
* Fot this purpose a new map (`aoPassMap`) is added to the material.
|
|
13
|
+
* The value of the map is used the same way as the `aoMap` value.
|
|
14
|
+
*
|
|
15
|
+
* Motivation to use the outputs AO pass directly in the material:
|
|
16
|
+
* The incident light of a fragment is composed of ambient light, direct light and indirect light
|
|
17
|
+
* Ambient Occlusion only occludes ambient light and environment light, but not direct light.
|
|
18
|
+
* Direct light is only occluded by geometry that casts shadows.
|
|
19
|
+
* And of course the emitted light should not be darkened by ambient occlusion either.
|
|
20
|
+
* This cannot be achieved if the AO post processing pass is simply blended with the diffuse render pass.
|
|
21
|
+
*
|
|
22
|
+
* Further extension work might be to use the output of an SSR pass or an HBIL pass from a previous frame.
|
|
23
|
+
* This would then create the possibility of SSR and IR depending on material properties such as `roughness`, `metalness` and `reflectivity`.
|
|
24
|
+
**/
|
|
25
|
+
|
|
26
|
+
class MeshPostProcessingMaterial extends MeshPhysicalMaterial {
|
|
27
|
+
|
|
28
|
+
constructor( parameters ) {
|
|
29
|
+
|
|
30
|
+
const aoPassMap = parameters.aoPassMap;
|
|
31
|
+
const aoPassMapScale = parameters.aoPassMapScale || 1.0;
|
|
32
|
+
delete parameters.aoPassMap;
|
|
33
|
+
delete parameters.aoPassMapScale;
|
|
34
|
+
|
|
35
|
+
super( parameters );
|
|
36
|
+
|
|
37
|
+
this.onBeforeCompile = this._onBeforeCompile;
|
|
38
|
+
this.customProgramCacheKey = this._customProgramCacheKey;
|
|
39
|
+
this._aoPassMap = aoPassMap;
|
|
40
|
+
this.aoPassMapScale = aoPassMapScale;
|
|
41
|
+
this._shader = null;
|
|
42
|
+
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
get aoPassMap() {
|
|
46
|
+
|
|
47
|
+
return this._aoPassMap;
|
|
48
|
+
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
set aoPassMap( aoPassMap ) {
|
|
52
|
+
|
|
53
|
+
this._aoPassMap = aoPassMap;
|
|
54
|
+
this.needsUpdate = true;
|
|
55
|
+
this._setUniforms();
|
|
56
|
+
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
_customProgramCacheKey() {
|
|
60
|
+
|
|
61
|
+
return this._aoPassMap !== undefined && this._aoPassMap !== null ? 'aoPassMap' : '';
|
|
62
|
+
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
_onBeforeCompile( shader ) {
|
|
66
|
+
|
|
67
|
+
this._shader = shader;
|
|
68
|
+
|
|
69
|
+
if ( this._aoPassMap !== undefined && this._aoPassMap !== null ) {
|
|
70
|
+
|
|
71
|
+
shader.fragmentShader = shader.fragmentShader.replace(
|
|
72
|
+
'#include <aomap_pars_fragment>',
|
|
73
|
+
aomap_pars_fragment_replacement
|
|
74
|
+
);
|
|
75
|
+
shader.fragmentShader = shader.fragmentShader.replace(
|
|
76
|
+
'#include <aomap_fragment>',
|
|
77
|
+
aomap_fragment_replacement
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
this._setUniforms();
|
|
83
|
+
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
_setUniforms() {
|
|
87
|
+
|
|
88
|
+
if ( this._shader ) {
|
|
89
|
+
|
|
90
|
+
this._shader.uniforms.tAoPassMap = { value: this._aoPassMap };
|
|
91
|
+
this._shader.uniforms.aoPassMapScale = { value: this.aoPassMapScale };
|
|
92
|
+
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const aomap_pars_fragment_replacement = /* glsl */`
|
|
100
|
+
#ifdef USE_AOMAP
|
|
101
|
+
|
|
102
|
+
uniform sampler2D aoMap;
|
|
103
|
+
uniform float aoMapIntensity;
|
|
104
|
+
|
|
105
|
+
#endif
|
|
106
|
+
|
|
107
|
+
uniform sampler2D tAoPassMap;
|
|
108
|
+
uniform float aoPassMapScale;
|
|
109
|
+
`;
|
|
110
|
+
|
|
111
|
+
const aomap_fragment_replacement = /* glsl */`
|
|
112
|
+
#ifndef AOPASSMAP_SWIZZLE
|
|
113
|
+
#define AOPASSMAP_SWIZZLE r
|
|
114
|
+
#endif
|
|
115
|
+
float ambientOcclusion = texelFetch( tAoPassMap, ivec2( gl_FragCoord.xy * aoPassMapScale ), 0 ).AOPASSMAP_SWIZZLE;
|
|
116
|
+
|
|
117
|
+
#ifdef USE_AOMAP
|
|
118
|
+
|
|
119
|
+
// reads channel R, compatible with a combined OcclusionRoughnessMetallic (RGB) texture
|
|
120
|
+
ambientOcclusion = min( ambientOcclusion, texture2D( aoMap, vAoMapUv ).r );
|
|
121
|
+
ambientOcclusion *= ( ambientOcclusion - 1.0 ) * aoMapIntensity + 1.0;
|
|
122
|
+
|
|
123
|
+
#endif
|
|
124
|
+
|
|
125
|
+
reflectedLight.indirectDiffuse *= ambientOcclusion;
|
|
126
|
+
|
|
127
|
+
#if defined( USE_CLEARCOAT )
|
|
128
|
+
clearcoatSpecularIndirect *= ambientOcclusion;
|
|
129
|
+
#endif
|
|
130
|
+
|
|
131
|
+
#if defined( USE_SHEEN )
|
|
132
|
+
sheenSpecularIndirect *= ambientOcclusion;
|
|
133
|
+
#endif
|
|
134
|
+
|
|
135
|
+
#if defined( USE_ENVMAP ) && defined( STANDARD )
|
|
136
|
+
|
|
137
|
+
float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
|
|
138
|
+
|
|
139
|
+
reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
|
|
140
|
+
|
|
141
|
+
#endif
|
|
142
|
+
`;
|
|
143
|
+
|
|
144
|
+
export { MeshPostProcessingMaterial };
|
|
@@ -73,11 +73,20 @@ class Timer {
|
|
|
73
73
|
|
|
74
74
|
update( timestamp ) {
|
|
75
75
|
|
|
76
|
-
this._previousTime = this._currentTime;
|
|
77
|
-
this._currentTime = ( timestamp !== undefined ? timestamp : now() ) - this._startTime;
|
|
78
76
|
|
|
79
|
-
|
|
80
|
-
|
|
77
|
+
if ( this._usePageVisibilityAPI === true && document.hidden === true ) {
|
|
78
|
+
|
|
79
|
+
this._delta = 0;
|
|
80
|
+
|
|
81
|
+
} else {
|
|
82
|
+
|
|
83
|
+
this._previousTime = this._currentTime;
|
|
84
|
+
this._currentTime = ( timestamp !== undefined ? timestamp : now() ) - this._startTime;
|
|
85
|
+
|
|
86
|
+
this._delta = ( this._currentTime - this._previousTime ) * this._timescale;
|
|
87
|
+
this._elapsed += this._delta; // _elapsed is the accumulation of all previous deltas
|
|
88
|
+
|
|
89
|
+
}
|
|
81
90
|
|
|
82
91
|
return this;
|
|
83
92
|
|
|
@@ -39,11 +39,16 @@ import * as NodeUtils from './core/NodeUtils.js';
|
|
|
39
39
|
export { NodeUtils };
|
|
40
40
|
|
|
41
41
|
// math
|
|
42
|
-
export { default as MathNode, EPSILON, INFINITY, radians, degrees, exp, exp2, log, log2, sqrt, inverseSqrt, floor, ceil, normalize, fract, sin, cos, tan, asin, acos, atan, abs, sign, length, negate, oneMinus, dFdx, dFdy, round, reciprocal, trunc, fwidth, bitcast, atan2, min, max, mod, step, reflect, distance, difference, dot, cross, pow, pow2, pow3, pow4, transformDirection, mix, clamp, saturate, refract, smoothstep, faceForward } from './math/MathNode.js';
|
|
43
|
-
|
|
42
|
+
export { default as MathNode, PI, PI2, EPSILON, INFINITY, radians, degrees, exp, exp2, log, log2, sqrt, inverseSqrt, floor, ceil, normalize, fract, sin, cos, tan, asin, acos, atan, abs, sign, length, lengthSq, negate, oneMinus, dFdx, dFdy, round, reciprocal, trunc, fwidth, bitcast, atan2, min, max, mod, step, reflect, distance, difference, dot, cross, pow, pow2, pow3, pow4, transformDirection, mix, clamp, saturate, refract, smoothstep, faceForward, cbrt } from './math/MathNode.js';
|
|
43
|
+
|
|
44
|
+
export { default as OperatorNode, add, sub, mul, div, remainder, equal, lessThan, greaterThan, lessThanEqual, greaterThanEqual, and, or, not, xor, bitAnd, bitNot, bitOr, bitXor, shiftLeft, shiftRight } from './math/OperatorNode.js';
|
|
44
45
|
export { default as CondNode, cond } from './math/CondNode.js';
|
|
45
46
|
export { default as HashNode, hash } from './math/HashNode.js';
|
|
46
47
|
|
|
48
|
+
// math utils
|
|
49
|
+
export { parabola, gain, pcurve, sinc } from './math/MathUtils.js';
|
|
50
|
+
export { triNoise3D } from './math/TriNoise3D.js';
|
|
51
|
+
|
|
47
52
|
// utils
|
|
48
53
|
export { default as ArrayElementNode } from './utils/ArrayElementNode.js';
|
|
49
54
|
export { default as ConvertNode } from './utils/ConvertNode.js';
|
|
@@ -58,12 +63,14 @@ export { default as OscNode, oscSine, oscSquare, oscTriangle, oscSawtooth } from
|
|
|
58
63
|
export { default as PackingNode, directionToColor, colorToDirection } from './utils/PackingNode.js';
|
|
59
64
|
export { default as RemapNode, remap, remapClamp } from './utils/RemapNode.js';
|
|
60
65
|
export { default as RotateUVNode, rotateUV } from './utils/RotateUVNode.js';
|
|
66
|
+
export { default as RotateNode, rotate } from './utils/RotateNode.js';
|
|
61
67
|
export { default as SetNode } from './utils/SetNode.js';
|
|
62
68
|
export { default as SpecularMIPLevelNode, specularMIPLevel } from './utils/SpecularMIPLevelNode.js';
|
|
63
69
|
export { default as SplitNode } from './utils/SplitNode.js';
|
|
64
70
|
export { default as SpriteSheetUVNode, spritesheetUV } from './utils/SpriteSheetUVNode.js';
|
|
65
71
|
export { default as TimerNode, timerLocal, timerGlobal, timerDelta, frameId } from './utils/TimerNode.js';
|
|
66
72
|
export { default as TriplanarTexturesNode, triplanarTextures, triplanarTexture } from './utils/TriplanarTexturesNode.js';
|
|
73
|
+
export { default as ReflectorNode, reflector } from './utils/ReflectorNode.js';
|
|
67
74
|
|
|
68
75
|
// shadernode
|
|
69
76
|
export * from './shadernode/ShaderNode.js';
|
|
@@ -72,7 +79,8 @@ export * from './shadernode/ShaderNode.js';
|
|
|
72
79
|
export { default as BitangentNode, bitangentGeometry, bitangentLocal, bitangentView, bitangentWorld, transformedBitangentView, transformedBitangentWorld } from './accessors/BitangentNode.js';
|
|
73
80
|
export { default as BufferAttributeNode, bufferAttribute, dynamicBufferAttribute, instancedBufferAttribute, instancedDynamicBufferAttribute } from './accessors/BufferAttributeNode.js';
|
|
74
81
|
export { default as BufferNode, buffer } from './accessors/BufferNode.js';
|
|
75
|
-
export { default as CameraNode, cameraProjectionMatrix, cameraViewMatrix, cameraNormalMatrix, cameraWorldMatrix, cameraPosition, cameraNear, cameraFar, cameraLogDepth } from './accessors/CameraNode.js';
|
|
82
|
+
export { default as CameraNode, cameraProjectionMatrix, cameraProjectionMatrixInverse, cameraViewMatrix, cameraNormalMatrix, cameraWorldMatrix, cameraPosition, cameraNear, cameraFar, cameraLogDepth } from './accessors/CameraNode.js';
|
|
83
|
+
export { default as VertexColorNode, vertexColor } from './accessors/VertexColorNode.js';
|
|
76
84
|
export { default as CubeTextureNode, cubeTexture } from './accessors/CubeTextureNode.js';
|
|
77
85
|
export { default as InstanceNode, instance } from './accessors/InstanceNode.js';
|
|
78
86
|
export { default as MaterialNode, materialAlphaTest, materialColor, materialShininess, materialEmissive, materialOpacity, materialSpecularColor, materialSpecularStrength, materialReflectivity, materialRoughness, materialMetalness, materialNormal, materialClearcoat, materialClearcoatRoughness, materialClearcoatNormal, materialRotation, materialSheen, materialSheenRoughness, materialIridescence, materialIridescenceIOR, materialIridescenceThickness, materialLineScale, materialLineDashSize, materialLineGapSize, materialLineWidth, materialLineDashOffset, materialPointWidth } from './accessors/MaterialNode.js';
|
|
@@ -99,7 +107,7 @@ export { default as UserDataNode, userData } from './accessors/UserDataNode.js';
|
|
|
99
107
|
// display
|
|
100
108
|
export { default as BlendModeNode, burn, dodge, overlay, screen } from './display/BlendModeNode.js';
|
|
101
109
|
export { default as BumpMapNode, bumpMap } from './display/BumpMapNode.js';
|
|
102
|
-
export { default as ColorAdjustmentNode, saturation, vibrance, hue, lumaCoeffs, luminance } from './display/ColorAdjustmentNode.js';
|
|
110
|
+
export { default as ColorAdjustmentNode, saturation, vibrance, hue, lumaCoeffs, luminance, threshold } from './display/ColorAdjustmentNode.js';
|
|
103
111
|
export { default as ColorSpaceNode, linearToColorSpace, colorSpaceToLinear, linearTosRGB, sRGBToLinear } from './display/ColorSpaceNode.js';
|
|
104
112
|
export { default as FrontFacingNode, frontFacing, faceDirection } from './display/FrontFacingNode.js';
|
|
105
113
|
export { default as NormalMapNode, normalMap, TBNViewMatrix } from './display/NormalMapNode.js';
|
|
@@ -111,6 +119,9 @@ export { default as ViewportSharedTextureNode, viewportSharedTexture } from './d
|
|
|
111
119
|
export { default as ViewportDepthTextureNode, viewportDepthTexture } from './display/ViewportDepthTextureNode.js';
|
|
112
120
|
export { default as ViewportDepthNode, viewZToOrthographicDepth, orthographicDepthToViewZ, viewZToPerspectiveDepth, perspectiveDepthToViewZ, depth, depthTexture, depthPixel } from './display/ViewportDepthNode.js';
|
|
113
121
|
export { default as GaussianBlurNode, gaussianBlur } from './display/GaussianBlurNode.js';
|
|
122
|
+
export { default as AfterImageNode, afterImage } from './display/AfterImageNode.js';
|
|
123
|
+
export { default as AnamorphicNode, anamorphic } from './display/AnamorphicNode.js';
|
|
124
|
+
|
|
114
125
|
export { default as PassNode, pass, depthPass } from './display/PassNode.js';
|
|
115
126
|
|
|
116
127
|
// code
|
|
@@ -139,7 +150,7 @@ export { default as DirectionalLightNode } from './lighting/DirectionalLightNode
|
|
|
139
150
|
export { default as SpotLightNode } from './lighting/SpotLightNode.js';
|
|
140
151
|
export { default as IESSpotLightNode } from './lighting/IESSpotLightNode.js';
|
|
141
152
|
export { default as AmbientLightNode } from './lighting/AmbientLightNode.js';
|
|
142
|
-
export { default as LightsNode, lights,
|
|
153
|
+
export { default as LightsNode, lights, lightsNode, addLightNode } from './lighting/LightsNode.js';
|
|
143
154
|
export { default as LightingNode /* @TODO: lighting (abstract), light */ } from './lighting/LightingNode.js';
|
|
144
155
|
export { default as LightingContextNode, lightingContext } from './lighting/LightingContextNode.js';
|
|
145
156
|
export { default as HemisphereLightNode } from './lighting/HemisphereLightNode.js';
|
|
@@ -67,12 +67,14 @@ class BufferAttributeNode extends InputNode {
|
|
|
67
67
|
|
|
68
68
|
const nodeType = this.getNodeType( builder );
|
|
69
69
|
|
|
70
|
-
const
|
|
71
|
-
const propertyName = builder.getPropertyName(
|
|
70
|
+
const nodeAttribute = builder.getBufferAttributeFromNode( this, nodeType );
|
|
71
|
+
const propertyName = builder.getPropertyName( nodeAttribute );
|
|
72
72
|
|
|
73
73
|
let output = null;
|
|
74
74
|
|
|
75
|
-
if ( builder.shaderStage === 'vertex' ) {
|
|
75
|
+
if ( builder.shaderStage === 'vertex' || builder.shaderStage === 'compute' ) {
|
|
76
|
+
|
|
77
|
+
this.name = propertyName;
|
|
76
78
|
|
|
77
79
|
output = propertyName;
|
|
78
80
|
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import Object3DNode from './Object3DNode.js';
|
|
2
2
|
import { addNodeClass } from '../core/Node.js';
|
|
3
|
-
import { label } from '../core/ContextNode.js';
|
|
4
3
|
import { NodeUpdateType } from '../core/constants.js';
|
|
5
4
|
//import { sharedUniformGroup } from '../core/UniformGroupNode.js';
|
|
6
5
|
import { nodeImmutable } from '../shadernode/ShaderNode.js';
|
|
@@ -23,7 +22,7 @@ class CameraNode extends Object3DNode {
|
|
|
23
22
|
|
|
24
23
|
const scope = this.scope;
|
|
25
24
|
|
|
26
|
-
if ( scope === CameraNode.PROJECTION_MATRIX ) {
|
|
25
|
+
if ( scope === CameraNode.PROJECTION_MATRIX || scope === CameraNode.PROJECTION_MATRIX_INVERSE ) {
|
|
27
26
|
|
|
28
27
|
return 'mat4';
|
|
29
28
|
|
|
@@ -53,6 +52,10 @@ class CameraNode extends Object3DNode {
|
|
|
53
52
|
|
|
54
53
|
uniformNode.value = camera.projectionMatrix;
|
|
55
54
|
|
|
55
|
+
} else if ( scope === CameraNode.PROJECTION_MATRIX_INVERSE ) {
|
|
56
|
+
|
|
57
|
+
uniformNode.value = camera.projectionMatrixInverse;
|
|
58
|
+
|
|
56
59
|
} else if ( scope === CameraNode.NEAR ) {
|
|
57
60
|
|
|
58
61
|
uniformNode.value = camera.near;
|
|
@@ -79,7 +82,7 @@ class CameraNode extends Object3DNode {
|
|
|
79
82
|
|
|
80
83
|
const scope = this.scope;
|
|
81
84
|
|
|
82
|
-
if ( scope === CameraNode.PROJECTION_MATRIX ) {
|
|
85
|
+
if ( scope === CameraNode.PROJECTION_MATRIX || scope === CameraNode.PROJECTION_MATRIX_INVERSE ) {
|
|
83
86
|
|
|
84
87
|
this._uniformNode.nodeType = 'mat4';
|
|
85
88
|
|
|
@@ -96,13 +99,15 @@ class CameraNode extends Object3DNode {
|
|
|
96
99
|
}
|
|
97
100
|
|
|
98
101
|
CameraNode.PROJECTION_MATRIX = 'projectionMatrix';
|
|
102
|
+
CameraNode.PROJECTION_MATRIX_INVERSE = 'projectionMatrixInverse';
|
|
99
103
|
CameraNode.NEAR = 'near';
|
|
100
104
|
CameraNode.FAR = 'far';
|
|
101
105
|
CameraNode.LOG_DEPTH = 'logDepth';
|
|
102
106
|
|
|
103
107
|
export default CameraNode;
|
|
104
108
|
|
|
105
|
-
export const cameraProjectionMatrix =
|
|
109
|
+
export const cameraProjectionMatrix = nodeImmutable( CameraNode, CameraNode.PROJECTION_MATRIX );
|
|
110
|
+
export const cameraProjectionMatrixInverse = nodeImmutable( CameraNode, CameraNode.PROJECTION_MATRIX_INVERSE );
|
|
106
111
|
export const cameraNear = nodeImmutable( CameraNode, CameraNode.NEAR );
|
|
107
112
|
export const cameraFar = nodeImmutable( CameraNode, CameraNode.FAR );
|
|
108
113
|
export const cameraLogDepth = nodeImmutable( CameraNode, CameraNode.LOG_DEPTH );
|
|
@@ -2,6 +2,7 @@ import TextureNode from './TextureNode.js';
|
|
|
2
2
|
import { reflectVector } from './ReflectVectorNode.js';
|
|
3
3
|
import { addNodeClass } from '../core/Node.js';
|
|
4
4
|
import { addNodeElement, nodeProxy, vec3 } from '../shadernode/ShaderNode.js';
|
|
5
|
+
import { WebGPUCoordinateSystem } from 'three';
|
|
5
6
|
|
|
6
7
|
class CubeTextureNode extends TextureNode {
|
|
7
8
|
|
|
@@ -29,7 +30,17 @@ class CubeTextureNode extends TextureNode {
|
|
|
29
30
|
|
|
30
31
|
setupUV( builder, uvNode ) {
|
|
31
32
|
|
|
32
|
-
|
|
33
|
+
const texture = this.value;
|
|
34
|
+
|
|
35
|
+
if ( builder.renderer.coordinateSystem === WebGPUCoordinateSystem || ! texture.isRenderTargetTexture ) {
|
|
36
|
+
|
|
37
|
+
return vec3( uvNode.x.negate(), uvNode.yz );
|
|
38
|
+
|
|
39
|
+
} else {
|
|
40
|
+
|
|
41
|
+
return uvNode;
|
|
42
|
+
|
|
43
|
+
}
|
|
33
44
|
|
|
34
45
|
}
|
|
35
46
|
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import BufferNode from './BufferNode.js';
|
|
2
|
+
import { bufferAttribute } from './BufferAttributeNode.js';
|
|
2
3
|
import { addNodeClass } from '../core/Node.js';
|
|
3
4
|
import { nodeObject } from '../shadernode/ShaderNode.js';
|
|
5
|
+
import { varying } from '../core/VaryingNode.js';
|
|
4
6
|
|
|
5
7
|
class StorageBufferNode extends BufferNode {
|
|
6
8
|
|
|
@@ -10,6 +12,9 @@ class StorageBufferNode extends BufferNode {
|
|
|
10
12
|
|
|
11
13
|
this.isStorageBufferNode = true;
|
|
12
14
|
|
|
15
|
+
this._attribute = null;
|
|
16
|
+
this._varying = null;
|
|
17
|
+
|
|
13
18
|
}
|
|
14
19
|
|
|
15
20
|
getInputType( /*builder*/ ) {
|
|
@@ -18,6 +23,28 @@ class StorageBufferNode extends BufferNode {
|
|
|
18
23
|
|
|
19
24
|
}
|
|
20
25
|
|
|
26
|
+
generate( builder ) {
|
|
27
|
+
|
|
28
|
+
if ( builder.isAvailable( 'storageBuffer' ) ) return super.generate( builder );
|
|
29
|
+
|
|
30
|
+
const nodeType = this.getNodeType( builder );
|
|
31
|
+
|
|
32
|
+
if ( this._attribute === null ) {
|
|
33
|
+
|
|
34
|
+
this._attribute = bufferAttribute( this.value );
|
|
35
|
+
this._varying = varying( this._attribute );
|
|
36
|
+
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
const output = this._varying.build( builder, nodeType );
|
|
41
|
+
|
|
42
|
+
builder.registerTransform( output, this._attribute );
|
|
43
|
+
|
|
44
|
+
return output;
|
|
45
|
+
|
|
46
|
+
}
|
|
47
|
+
|
|
21
48
|
}
|
|
22
49
|
|
|
23
50
|
export default StorageBufferNode;
|
|
@@ -14,9 +14,52 @@ class TextureStoreNode extends TextureNode {
|
|
|
14
14
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
getInputType( /*builder*/ ) {
|
|
18
18
|
|
|
19
|
-
return '
|
|
19
|
+
return 'storageTexture';
|
|
20
|
+
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
setup( builder ) {
|
|
24
|
+
|
|
25
|
+
super.setup( builder );
|
|
26
|
+
|
|
27
|
+
const properties = builder.getNodeProperties( this );
|
|
28
|
+
properties.storeNode = this.storeNode;
|
|
29
|
+
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
generate( builder, output ) {
|
|
33
|
+
|
|
34
|
+
let snippet;
|
|
35
|
+
|
|
36
|
+
if ( this.storeNode !== null ) {
|
|
37
|
+
|
|
38
|
+
snippet = this.generateStore( builder );
|
|
39
|
+
|
|
40
|
+
} else {
|
|
41
|
+
|
|
42
|
+
snippet = super.generate( builder, output );
|
|
43
|
+
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return snippet;
|
|
47
|
+
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
generateStore( builder ) {
|
|
51
|
+
|
|
52
|
+
const properties = builder.getNodeProperties( this );
|
|
53
|
+
|
|
54
|
+
const { uvNode, storeNode } = properties;
|
|
55
|
+
|
|
56
|
+
const textureProperty = super.generate( builder, 'property' );
|
|
57
|
+
const uvSnippet = uvNode.build( builder, 'uvec2' );
|
|
58
|
+
const storeSnippet = storeNode.build( builder, 'vec4' );
|
|
59
|
+
|
|
60
|
+
const snippet = builder.generateTextureStore( builder, textureProperty, uvSnippet, storeSnippet );
|
|
61
|
+
|
|
62
|
+
builder.addLineFlowCode( snippet );
|
|
20
63
|
|
|
21
64
|
}
|
|
22
65
|
|
|
@@ -24,6 +67,16 @@ class TextureStoreNode extends TextureNode {
|
|
|
24
67
|
|
|
25
68
|
export default TextureStoreNode;
|
|
26
69
|
|
|
27
|
-
|
|
70
|
+
const textureStoreBase = nodeProxy( TextureStoreNode );
|
|
71
|
+
|
|
72
|
+
export const textureStore = ( value, uvNode, storeNode ) => {
|
|
73
|
+
|
|
74
|
+
const node = textureStoreBase( value, uvNode, storeNode );
|
|
75
|
+
|
|
76
|
+
if ( storeNode !== null ) node.append();
|
|
77
|
+
|
|
78
|
+
return node;
|
|
79
|
+
|
|
80
|
+
};
|
|
28
81
|
|
|
29
82
|
addNodeClass( 'TextureStoreNode', TextureStoreNode );
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { addNodeClass } from '../core/Node.js';
|
|
2
|
+
import AttributeNode from '../core/AttributeNode.js';
|
|
3
|
+
import { nodeObject } from '../shadernode/ShaderNode.js';
|
|
4
|
+
import { Vector4 } from 'three';
|
|
5
|
+
|
|
6
|
+
class VertexColorNode extends AttributeNode {
|
|
7
|
+
|
|
8
|
+
constructor( index = 0 ) {
|
|
9
|
+
|
|
10
|
+
super( null, 'vec4' );
|
|
11
|
+
|
|
12
|
+
this.isVertexColorNode = true;
|
|
13
|
+
|
|
14
|
+
this.index = index;
|
|
15
|
+
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
getAttributeName( /*builder*/ ) {
|
|
19
|
+
|
|
20
|
+
const index = this.index;
|
|
21
|
+
|
|
22
|
+
return 'color' + ( index > 0 ? index : '' );
|
|
23
|
+
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
generate( builder ) {
|
|
27
|
+
|
|
28
|
+
const attributeName = this.getAttributeName( builder );
|
|
29
|
+
const geometryAttribute = builder.hasGeometryAttribute( attributeName );
|
|
30
|
+
|
|
31
|
+
let result;
|
|
32
|
+
|
|
33
|
+
if ( geometryAttribute === true ) {
|
|
34
|
+
|
|
35
|
+
result = super.generate( builder );
|
|
36
|
+
|
|
37
|
+
} else {
|
|
38
|
+
|
|
39
|
+
// Vertex color fallback should be white
|
|
40
|
+
result = builder.generateConst( this.nodeType, new Vector4( 1, 1, 1, 1 ) );
|
|
41
|
+
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return result;
|
|
45
|
+
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
serialize( data ) {
|
|
49
|
+
|
|
50
|
+
super.serialize( data );
|
|
51
|
+
|
|
52
|
+
data.index = this.index;
|
|
53
|
+
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
deserialize( data ) {
|
|
57
|
+
|
|
58
|
+
super.deserialize( data );
|
|
59
|
+
|
|
60
|
+
this.index = data.index;
|
|
61
|
+
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export default VertexColorNode;
|
|
67
|
+
|
|
68
|
+
export const vertexColor = ( ...params ) => nodeObject( new VertexColorNode( ...params ) );
|
|
69
|
+
|
|
70
|
+
addNodeClass( 'VertexColorNode', VertexColorNode );
|
|
@@ -91,7 +91,7 @@ class AttributeNode extends Node {
|
|
|
91
91
|
|
|
92
92
|
} else {
|
|
93
93
|
|
|
94
|
-
console.warn( `AttributeNode:
|
|
94
|
+
console.warn( `AttributeNode: Vertex attribute "${ attributeName }" not found on geometry.` );
|
|
95
95
|
|
|
96
96
|
return builder.generateConst( nodeType );
|
|
97
97
|
|
|
@@ -7,7 +7,7 @@ import NodeKeywords from './NodeKeywords.js';
|
|
|
7
7
|
import NodeCache from './NodeCache.js';
|
|
8
8
|
import ParameterNode from './ParameterNode.js';
|
|
9
9
|
import FunctionNode from '../code/FunctionNode.js';
|
|
10
|
-
import { createNodeMaterialFromType } from '../materials/NodeMaterial.js';
|
|
10
|
+
import { createNodeMaterialFromType, default as NodeMaterial } from '../materials/NodeMaterial.js';
|
|
11
11
|
import { NodeUpdateType, defaultBuildStages, shaderStages } from './constants.js';
|
|
12
12
|
|
|
13
13
|
import {
|
|
@@ -462,7 +462,7 @@ class NodeBuilder {
|
|
|
462
462
|
|
|
463
463
|
isReference( type ) {
|
|
464
464
|
|
|
465
|
-
return type === 'void' || type === 'property' || type === 'sampler' || type === 'texture' || type === 'cubeTexture';
|
|
465
|
+
return type === 'void' || type === 'property' || type === 'sampler' || type === 'texture' || type === 'cubeTexture' || type === 'storageTexture';
|
|
466
466
|
|
|
467
467
|
}
|
|
468
468
|
|
|
@@ -523,7 +523,7 @@ class NodeBuilder {
|
|
|
523
523
|
getVectorType( type ) {
|
|
524
524
|
|
|
525
525
|
if ( type === 'color' ) return 'vec3';
|
|
526
|
-
if ( type === 'texture' ) return 'vec4';
|
|
526
|
+
if ( type === 'texture' || type === 'cubeTexture' || type === 'storageTexture' ) return 'vec4';
|
|
527
527
|
|
|
528
528
|
return type;
|
|
529
529
|
|
|
@@ -575,6 +575,7 @@ class NodeBuilder {
|
|
|
575
575
|
|
|
576
576
|
if ( vecNum !== null ) return Number( vecNum[ 1 ] );
|
|
577
577
|
if ( vecType === 'float' || vecType === 'bool' || vecType === 'int' || vecType === 'uint' ) return 1;
|
|
578
|
+
if ( /mat2/.test( type ) === true ) return 4;
|
|
578
579
|
if ( /mat3/.test( type ) === true ) return 9;
|
|
579
580
|
if ( /mat4/.test( type ) === true ) return 16;
|
|
580
581
|
|
|
@@ -1089,7 +1090,23 @@ class NodeBuilder {
|
|
|
1089
1090
|
|
|
1090
1091
|
}
|
|
1091
1092
|
|
|
1092
|
-
build() {
|
|
1093
|
+
build( convertMaterial = true ) {
|
|
1094
|
+
|
|
1095
|
+
const { object, material } = this;
|
|
1096
|
+
|
|
1097
|
+
if ( convertMaterial ) {
|
|
1098
|
+
|
|
1099
|
+
if ( material !== null ) {
|
|
1100
|
+
|
|
1101
|
+
NodeMaterial.fromMaterial( material ).build( this );
|
|
1102
|
+
|
|
1103
|
+
} else {
|
|
1104
|
+
|
|
1105
|
+
this.addFlow( 'compute', object );
|
|
1106
|
+
|
|
1107
|
+
}
|
|
1108
|
+
|
|
1109
|
+
}
|
|
1093
1110
|
|
|
1094
1111
|
// setup() -> stage 1: create possible new nodes and returns an output reference node
|
|
1095
1112
|
// analyze() -> stage 2: analyze nodes to possible optimization and validation
|
|
@@ -1155,24 +1172,12 @@ class NodeBuilder {
|
|
|
1155
1172
|
|
|
1156
1173
|
}
|
|
1157
1174
|
|
|
1158
|
-
createNodeMaterial( type ) {
|
|
1175
|
+
createNodeMaterial( type = 'NodeMaterial' ) {
|
|
1159
1176
|
|
|
1160
1177
|
return createNodeMaterialFromType( type );
|
|
1161
1178
|
|
|
1162
1179
|
}
|
|
1163
1180
|
|
|
1164
|
-
getPrimitiveType( type ) {
|
|
1165
|
-
|
|
1166
|
-
let primitiveType;
|
|
1167
|
-
|
|
1168
|
-
if ( type[ 0 ] === 'i' ) primitiveType = 'int';
|
|
1169
|
-
else if ( type[ 0 ] === 'u' ) primitiveType = 'uint';
|
|
1170
|
-
else primitiveType = 'float';
|
|
1171
|
-
|
|
1172
|
-
return primitiveType;
|
|
1173
|
-
|
|
1174
|
-
}
|
|
1175
|
-
|
|
1176
1181
|
format( snippet, fromType, toType ) {
|
|
1177
1182
|
|
|
1178
1183
|
fromType = this.getVectorType( fromType );
|
|
@@ -1232,7 +1237,7 @@ class NodeBuilder {
|
|
|
1232
1237
|
// convert a number value to vector type, e.g:
|
|
1233
1238
|
// vec3( 1u ) -> vec3( float( 1u ) )
|
|
1234
1239
|
|
|
1235
|
-
snippet = `${ this.getType( this.
|
|
1240
|
+
snippet = `${ this.getType( this.getComponentType( toType ) ) }( ${ snippet } )`;
|
|
1236
1241
|
|
|
1237
1242
|
}
|
|
1238
1243
|
|