super-three 0.136.0 → 0.136.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/build/three.js +1634 -1608
- package/build/three.min.js +1 -1
- package/build/three.module.js +4630 -4534
- package/examples/js/animation/MMDPhysics.js +1 -1
- package/examples/js/cameras/CinematicCamera.js +2 -7
- package/examples/js/exporters/MMDExporter.js +1 -1
- package/examples/js/geometries/ConvexGeometry.js +1 -1
- package/examples/js/loaders/BasisTextureLoader.js +1 -0
- package/examples/js/loaders/EXRLoader.js +25 -19
- package/examples/js/loaders/GLTFLoader.js +2 -2
- package/examples/js/loaders/HDRCubeTextureLoader.js +0 -2
- package/examples/js/loaders/LDrawLoader.js +1131 -859
- package/examples/js/loaders/LUT3dlLoader.js +17 -10
- package/examples/js/loaders/LUTCubeLoader.js +3 -4
- package/examples/js/loaders/RGBELoader.js +6 -6
- package/examples/js/loaders/RGBMLoader.js +1 -1
- package/examples/js/loaders/SVGLoader.js +3 -1
- package/examples/js/loaders/VRMLLoader.js +9 -21
- package/examples/js/math/ConvexHull.js +7 -13
- package/examples/js/misc/Volume.js +2 -2
- package/examples/js/modifiers/CurveModifier.js +8 -7
- package/examples/js/modifiers/EdgeSplitModifier.js +1 -1
- package/examples/js/modifiers/SimplifyModifier.js +1 -1
- package/examples/js/objects/Reflector.js +1 -13
- package/examples/js/objects/ReflectorForSSRPass.js +0 -10
- package/examples/js/objects/Refractor.js +1 -13
- package/examples/js/objects/Water.js +1 -13
- package/examples/js/postprocessing/GlitchPass.js +4 -5
- package/examples/js/postprocessing/SMAAPass.js +2 -9
- package/examples/js/postprocessing/SSAOPass.js +9 -21
- package/examples/js/postprocessing/SavePass.js +1 -5
- package/examples/js/shaders/DigitalGlitch.js +3 -3
- package/examples/js/shaders/MMDToonShader.js +0 -1
- package/examples/js/shaders/SSAOShader.js +1 -1
- package/examples/jsm/animation/MMDPhysics.js +1 -1
- package/examples/jsm/cameras/CinematicCamera.js +2 -5
- package/examples/jsm/{WebGL.js → capabilities/WebGL.js} +2 -2
- package/examples/jsm/{renderers/webgpu → capabilities}/WebGPU.js +1 -1
- package/examples/jsm/exporters/GLTFExporter.js +8 -24
- package/examples/jsm/exporters/MMDExporter.js +1 -1
- package/examples/jsm/geometries/ConvexGeometry.js +1 -1
- package/examples/jsm/libs/lil-gui.module.min.js +2 -2
- package/examples/jsm/loaders/BasisTextureLoader.js +7 -0
- package/examples/jsm/loaders/EXRLoader.js +22 -19
- package/examples/jsm/loaders/GLTFLoader.js +1 -3
- package/examples/jsm/loaders/HDRCubeTextureLoader.js +1 -4
- package/examples/jsm/loaders/LDrawLoader.js +1147 -885
- package/examples/jsm/loaders/LUT3dlLoader.js +17 -12
- package/examples/jsm/loaders/LUTCubeLoader.js +3 -5
- package/examples/jsm/loaders/RGBELoader.js +7 -8
- package/examples/jsm/loaders/RGBMLoader.js +1 -1
- package/examples/jsm/loaders/SVGLoader.js +6 -1
- package/examples/jsm/loaders/VRMLLoader.js +9 -22
- package/examples/jsm/math/ConvexHull.js +7 -13
- package/examples/jsm/misc/Volume.js +2 -2
- package/examples/jsm/modifiers/CurveModifier.js +9 -8
- package/examples/jsm/modifiers/EdgeSplitModifier.js +1 -1
- package/examples/jsm/modifiers/SimplifyModifier.js +1 -1
- package/examples/jsm/node-editor/NodeEditor.js +21 -22
- package/examples/jsm/nodes/utils/ColorSpaceNode.js +4 -13
- package/examples/jsm/objects/Lensflare.js +4 -4
- package/examples/jsm/objects/Reflector.js +1 -16
- package/examples/jsm/objects/ReflectorForSSRPass.js +0 -12
- package/examples/jsm/objects/Refractor.js +1 -16
- package/examples/jsm/objects/Water.js +1 -16
- package/examples/jsm/postprocessing/GlitchPass.js +7 -6
- package/examples/jsm/postprocessing/SMAAPass.js +2 -11
- package/examples/jsm/postprocessing/SSAOPass.js +13 -25
- package/examples/jsm/postprocessing/SavePass.js +1 -3
- package/examples/jsm/renderers/nodes/Nodes.js +2 -0
- package/examples/jsm/renderers/nodes/ShaderNode.js +58 -31
- package/examples/jsm/renderers/nodes/display/ColorSpaceNode.js +9 -46
- package/examples/jsm/renderers/nodes/inputs/TextureNode.js +5 -10
- package/examples/jsm/renderers/nodes/math/MathNode.js +2 -1
- package/examples/jsm/renderers/webgpu/WebGPUObjects.js +1 -1
- package/examples/jsm/renderers/webgpu/WebGPURenderer.js +3 -5
- package/examples/jsm/renderers/webgpu/WebGPUTextures.js +1 -2
- package/examples/jsm/renderers/webgpu/nodes/WebGPUNodeBuilder.js +10 -4
- package/examples/jsm/shaders/DigitalGlitch.js +3 -3
- package/examples/jsm/shaders/MMDToonShader.js +0 -1
- package/examples/jsm/shaders/SSAOShader.js +1 -1
- package/examples/jsm/utils/LDrawUtils.js +195 -0
- package/examples/jsm/webxr/VRButton.js +24 -0
- package/examples/jsm/webxr/XREstimatedLight.js +2 -0
- package/package.json +4 -1
- package/src/animation/AnimationMixer.js +1 -0
- package/src/cameras/CubeCamera.js +2 -0
- package/src/constants.js +3 -16
- package/src/extras/ImageUtils.js +63 -0
- package/src/extras/PMREMGenerator.js +32 -82
- package/src/loaders/MaterialLoader.js +1 -1
- package/src/materials/Material.js +4 -4
- package/src/math/Color.js +1 -1
- package/src/math/Quaternion.js +1 -1
- package/src/renderers/WebGLCubeRenderTarget.js +0 -2
- package/src/renderers/WebGLRenderer.js +1 -67
- package/src/renderers/shaders/ShaderChunk/emissivemap_fragment.glsl.js +0 -2
- package/src/renderers/shaders/ShaderChunk/encodings_pars_fragment.glsl.js +0 -4
- package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +0 -2
- package/src/renderers/shaders/ShaderChunk/lightmap_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +2 -2
- package/src/renderers/shaders/ShaderChunk/map_fragment.glsl.js +10 -3
- package/src/renderers/shaders/ShaderChunk/map_particle_fragment.glsl.js +1 -2
- package/src/renderers/shaders/ShaderChunk/transmission_pars_fragment.glsl.js +8 -7
- package/src/renderers/shaders/ShaderLib/background.glsl.js +1 -3
- package/src/renderers/shaders/ShaderLib/equirect.glsl.js +1 -3
- package/src/renderers/shaders/ShaderLib/meshbasic.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/meshmatcap.glsl.js +1 -2
- package/src/renderers/shaders/ShaderLib.js +2 -2
- package/src/renderers/webgl/WebGLCubeMaps.js +0 -4
- package/src/renderers/webgl/WebGLCubeUVMaps.js +29 -16
- package/src/renderers/webgl/WebGLMorphtargets.js +12 -0
- package/src/renderers/webgl/WebGLProgram.js +4 -16
- package/src/renderers/webgl/WebGLPrograms.js +8 -47
- package/src/renderers/webgl/WebGLState.js +81 -0
- package/src/renderers/webgl/WebGLTextures.js +75 -22
- package/src/renderers/webgl/WebGLUtils.js +86 -28
- package/src/renderers/webxr/WebXRManager.js +3 -3
- package/src/textures/Texture.js +2 -1
- package/src/textures/VideoTexture.js +1 -3
- package/examples/js/WebGL.js +0 -90
- package/examples/js/utils/RoughnessMipmapper.js +0 -268
- package/examples/jsm/utils/RoughnessMipmapper.js +0 -288
|
@@ -2,7 +2,8 @@ import {
|
|
|
2
2
|
DataTexture,
|
|
3
3
|
FloatType,
|
|
4
4
|
MathUtils,
|
|
5
|
-
|
|
5
|
+
RedFormat,
|
|
6
|
+
LuminanceFormat,
|
|
6
7
|
ShaderMaterial,
|
|
7
8
|
UniformsUtils
|
|
8
9
|
} from 'three';
|
|
@@ -39,6 +40,8 @@ class GlitchPass extends Pass {
|
|
|
39
40
|
|
|
40
41
|
render( renderer, writeBuffer, readBuffer /*, deltaTime, maskActive */ ) {
|
|
41
42
|
|
|
43
|
+
if ( renderer.capabilities.isWebGL2 === false ) this.uniforms[ 'tDisp' ].value.format = LuminanceFormat;
|
|
44
|
+
|
|
42
45
|
this.uniforms[ 'tDiffuse' ].value = readBuffer.texture;
|
|
43
46
|
this.uniforms[ 'seed' ].value = Math.random();//default seeding
|
|
44
47
|
this.uniforms[ 'byp' ].value = 0;
|
|
@@ -94,19 +97,17 @@ class GlitchPass extends Pass {
|
|
|
94
97
|
|
|
95
98
|
generateHeightmap( dt_size ) {
|
|
96
99
|
|
|
97
|
-
const data_arr = new Float32Array( dt_size * dt_size
|
|
100
|
+
const data_arr = new Float32Array( dt_size * dt_size );
|
|
98
101
|
const length = dt_size * dt_size;
|
|
99
102
|
|
|
100
103
|
for ( let i = 0; i < length; i ++ ) {
|
|
101
104
|
|
|
102
105
|
const val = MathUtils.randFloat( 0, 1 );
|
|
103
|
-
data_arr[ i
|
|
104
|
-
data_arr[ i * 3 + 1 ] = val;
|
|
105
|
-
data_arr[ i * 3 + 2 ] = val;
|
|
106
|
+
data_arr[ i ] = val;
|
|
106
107
|
|
|
107
108
|
}
|
|
108
109
|
|
|
109
|
-
const texture = new DataTexture( data_arr, dt_size, dt_size,
|
|
110
|
+
const texture = new DataTexture( data_arr, dt_size, dt_size, RedFormat, FloatType );
|
|
110
111
|
texture.needsUpdate = true;
|
|
111
112
|
return texture;
|
|
112
113
|
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
LinearFilter,
|
|
3
3
|
NearestFilter,
|
|
4
|
-
RGBAFormat,
|
|
5
|
-
RGBFormat,
|
|
6
4
|
ShaderMaterial,
|
|
7
5
|
Texture,
|
|
8
6
|
UniformsUtils,
|
|
@@ -22,18 +20,12 @@ class SMAAPass extends Pass {
|
|
|
22
20
|
// render targets
|
|
23
21
|
|
|
24
22
|
this.edgesRT = new WebGLRenderTarget( width, height, {
|
|
25
|
-
depthBuffer: false
|
|
26
|
-
generateMipmaps: false,
|
|
27
|
-
minFilter: LinearFilter,
|
|
28
|
-
format: RGBFormat
|
|
23
|
+
depthBuffer: false
|
|
29
24
|
} );
|
|
30
25
|
this.edgesRT.texture.name = 'SMAAPass.edges';
|
|
31
26
|
|
|
32
27
|
this.weightsRT = new WebGLRenderTarget( width, height, {
|
|
33
|
-
depthBuffer: false
|
|
34
|
-
generateMipmaps: false,
|
|
35
|
-
minFilter: LinearFilter,
|
|
36
|
-
format: RGBAFormat
|
|
28
|
+
depthBuffer: false
|
|
37
29
|
} );
|
|
38
30
|
this.weightsRT.texture.name = 'SMAAPass.weights';
|
|
39
31
|
|
|
@@ -52,7 +44,6 @@ class SMAAPass extends Pass {
|
|
|
52
44
|
this.areaTexture = new Texture();
|
|
53
45
|
this.areaTexture.name = 'SMAAPass.area';
|
|
54
46
|
this.areaTexture.image = areaTextureImage;
|
|
55
|
-
this.areaTexture.format = RGBFormat;
|
|
56
47
|
this.areaTexture.minFilter = LinearFilter;
|
|
57
48
|
this.areaTexture.generateMipmaps = false;
|
|
58
49
|
this.areaTexture.flipY = false;
|
|
@@ -7,16 +7,17 @@ import {
|
|
|
7
7
|
DstAlphaFactor,
|
|
8
8
|
DstColorFactor,
|
|
9
9
|
FloatType,
|
|
10
|
-
LinearFilter,
|
|
11
10
|
MathUtils,
|
|
12
11
|
MeshNormalMaterial,
|
|
13
12
|
NearestFilter,
|
|
14
13
|
NoBlending,
|
|
15
|
-
|
|
14
|
+
RedFormat,
|
|
15
|
+
LuminanceFormat,
|
|
16
|
+
DepthStencilFormat,
|
|
17
|
+
UnsignedInt248Type,
|
|
16
18
|
RepeatWrapping,
|
|
17
19
|
ShaderMaterial,
|
|
18
20
|
UniformsUtils,
|
|
19
|
-
UnsignedShortType,
|
|
20
21
|
Vector3,
|
|
21
22
|
WebGLRenderTarget,
|
|
22
23
|
ZeroFactor
|
|
@@ -61,30 +62,22 @@ class SSAOPass extends Pass {
|
|
|
61
62
|
// beauty render target
|
|
62
63
|
|
|
63
64
|
const depthTexture = new DepthTexture();
|
|
64
|
-
depthTexture.
|
|
65
|
+
depthTexture.format = DepthStencilFormat;
|
|
66
|
+
depthTexture.type = UnsignedInt248Type;
|
|
65
67
|
|
|
66
|
-
this.beautyRenderTarget = new WebGLRenderTarget( this.width, this.height
|
|
67
|
-
minFilter: LinearFilter,
|
|
68
|
-
magFilter: LinearFilter,
|
|
69
|
-
format: RGBAFormat
|
|
70
|
-
} );
|
|
68
|
+
this.beautyRenderTarget = new WebGLRenderTarget( this.width, this.height );
|
|
71
69
|
|
|
72
70
|
// normal render target with depth buffer
|
|
73
71
|
|
|
74
72
|
this.normalRenderTarget = new WebGLRenderTarget( this.width, this.height, {
|
|
75
73
|
minFilter: NearestFilter,
|
|
76
74
|
magFilter: NearestFilter,
|
|
77
|
-
format: RGBAFormat,
|
|
78
75
|
depthTexture: depthTexture
|
|
79
76
|
} );
|
|
80
77
|
|
|
81
78
|
// ssao render target
|
|
82
79
|
|
|
83
|
-
this.ssaoRenderTarget = new WebGLRenderTarget( this.width, this.height
|
|
84
|
-
minFilter: LinearFilter,
|
|
85
|
-
magFilter: LinearFilter,
|
|
86
|
-
format: RGBAFormat
|
|
87
|
-
} );
|
|
80
|
+
this.ssaoRenderTarget = new WebGLRenderTarget( this.width, this.height );
|
|
88
81
|
|
|
89
82
|
this.blurRenderTarget = this.ssaoRenderTarget.clone();
|
|
90
83
|
|
|
@@ -191,6 +184,8 @@ class SSAOPass extends Pass {
|
|
|
191
184
|
|
|
192
185
|
render( renderer, writeBuffer /*, readBuffer, deltaTime, maskActive */ ) {
|
|
193
186
|
|
|
187
|
+
if ( renderer.capabilities.isWebGL2 === false ) this.noiseTexture.format = LuminanceFormat;
|
|
188
|
+
|
|
194
189
|
// render beauty
|
|
195
190
|
|
|
196
191
|
renderer.setRenderTarget( this.beautyRenderTarget );
|
|
@@ -391,26 +386,19 @@ class SSAOPass extends Pass {
|
|
|
391
386
|
const simplex = new SimplexNoise();
|
|
392
387
|
|
|
393
388
|
const size = width * height;
|
|
394
|
-
const data = new Float32Array( size
|
|
389
|
+
const data = new Float32Array( size );
|
|
395
390
|
|
|
396
391
|
for ( let i = 0; i < size; i ++ ) {
|
|
397
392
|
|
|
398
|
-
const stride = i * 4;
|
|
399
|
-
|
|
400
393
|
const x = ( Math.random() * 2 ) - 1;
|
|
401
394
|
const y = ( Math.random() * 2 ) - 1;
|
|
402
395
|
const z = 0;
|
|
403
396
|
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
data[ stride ] = noise;
|
|
407
|
-
data[ stride + 1 ] = noise;
|
|
408
|
-
data[ stride + 2 ] = noise;
|
|
409
|
-
data[ stride + 3 ] = 1;
|
|
397
|
+
data[ i ] = simplex.noise3d( x, y, z );
|
|
410
398
|
|
|
411
399
|
}
|
|
412
400
|
|
|
413
|
-
this.noiseTexture = new DataTexture( data, width, height,
|
|
401
|
+
this.noiseTexture = new DataTexture( data, width, height, RedFormat, FloatType );
|
|
414
402
|
this.noiseTexture.wrapS = RepeatWrapping;
|
|
415
403
|
this.noiseTexture.wrapT = RepeatWrapping;
|
|
416
404
|
this.noiseTexture.needsUpdate = true;
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import {
|
|
2
|
-
LinearFilter,
|
|
3
|
-
RGBFormat,
|
|
4
2
|
ShaderMaterial,
|
|
5
3
|
UniformsUtils,
|
|
6
4
|
WebGLRenderTarget
|
|
@@ -34,7 +32,7 @@ class SavePass extends Pass {
|
|
|
34
32
|
|
|
35
33
|
if ( this.renderTarget === undefined ) {
|
|
36
34
|
|
|
37
|
-
this.renderTarget = new WebGLRenderTarget( window.innerWidth, window.innerHeight
|
|
35
|
+
this.renderTarget = new WebGLRenderTarget( window.innerWidth, window.innerHeight );
|
|
38
36
|
this.renderTarget.texture.name = 'SavePass.rt';
|
|
39
37
|
|
|
40
38
|
}
|
|
@@ -55,6 +55,7 @@ import NormalMapNode from './display/NormalMapNode.js';
|
|
|
55
55
|
// math
|
|
56
56
|
import MathNode from './math/MathNode.js';
|
|
57
57
|
import OperatorNode from './math/OperatorNode.js';
|
|
58
|
+
import CondNode from './math/CondNode.js';
|
|
58
59
|
|
|
59
60
|
// lights
|
|
60
61
|
import LightContextNode from './lights/LightContextNode.js';
|
|
@@ -143,6 +144,7 @@ export {
|
|
|
143
144
|
// math
|
|
144
145
|
MathNode,
|
|
145
146
|
OperatorNode,
|
|
147
|
+
CondNode,
|
|
146
148
|
|
|
147
149
|
// lights
|
|
148
150
|
LightContextNode,
|
|
@@ -69,6 +69,8 @@ const NodeHandler = {
|
|
|
69
69
|
|
|
70
70
|
};
|
|
71
71
|
|
|
72
|
+
const nodeObjects = new WeakMap();
|
|
73
|
+
|
|
72
74
|
const ShaderNodeObject = ( obj ) => {
|
|
73
75
|
|
|
74
76
|
const type = typeof obj;
|
|
@@ -81,16 +83,17 @@ const ShaderNodeObject = ( obj ) => {
|
|
|
81
83
|
|
|
82
84
|
if ( obj.isNode === true ) {
|
|
83
85
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
if ( node.isProxyNode !== true ) {
|
|
86
|
+
let nodeObject = nodeObjects.get( obj );
|
|
87
87
|
|
|
88
|
-
|
|
88
|
+
if ( nodeObject === undefined ) {
|
|
89
89
|
|
|
90
|
-
|
|
90
|
+
nodeObject = new Proxy( obj, NodeHandler );
|
|
91
|
+
nodeObjects.set( obj, nodeObject );
|
|
91
92
|
|
|
92
93
|
}
|
|
93
94
|
|
|
95
|
+
return nodeObject;
|
|
96
|
+
|
|
94
97
|
}
|
|
95
98
|
|
|
96
99
|
}
|
|
@@ -183,27 +186,33 @@ export const uniform = new ShaderNode( ( inputNode ) => {
|
|
|
183
186
|
|
|
184
187
|
} );
|
|
185
188
|
|
|
189
|
+
export const nodeObject = ( val ) => {
|
|
190
|
+
|
|
191
|
+
return ShaderNodeObject( val );
|
|
192
|
+
|
|
193
|
+
};
|
|
194
|
+
|
|
186
195
|
export const float = ( val ) => {
|
|
187
196
|
|
|
188
|
-
return
|
|
197
|
+
return nodeObject( new FloatNode( val ).setConst( true ) );
|
|
189
198
|
|
|
190
199
|
};
|
|
191
200
|
|
|
192
201
|
export const color = ( ...params ) => {
|
|
193
202
|
|
|
194
|
-
return
|
|
203
|
+
return nodeObject( new ColorNode( new Color( ...params ) ).setConst( true ) );
|
|
195
204
|
|
|
196
205
|
};
|
|
197
206
|
|
|
198
207
|
export const join = ( ...params ) => {
|
|
199
208
|
|
|
200
|
-
return
|
|
209
|
+
return nodeObject( new JoinNode( ShaderNodeArray( params ) ) );
|
|
201
210
|
|
|
202
211
|
};
|
|
203
212
|
|
|
204
213
|
export const cond = ( ...params ) => {
|
|
205
214
|
|
|
206
|
-
return
|
|
215
|
+
return nodeObject( new CondNode( ...ShaderNodeArray( params ) ) );
|
|
207
216
|
|
|
208
217
|
};
|
|
209
218
|
|
|
@@ -211,7 +220,7 @@ export const vec2 = ( ...params ) => {
|
|
|
211
220
|
|
|
212
221
|
if ( params[ 0 ]?.isNode === true ) {
|
|
213
222
|
|
|
214
|
-
return
|
|
223
|
+
return nodeObject( new ConvertNode( params[ 0 ], 'vec2' ) );
|
|
215
224
|
|
|
216
225
|
} else {
|
|
217
226
|
|
|
@@ -223,7 +232,7 @@ export const vec2 = ( ...params ) => {
|
|
|
223
232
|
|
|
224
233
|
}
|
|
225
234
|
|
|
226
|
-
return
|
|
235
|
+
return nodeObject( new Vector2Node( new Vector2( ...params ) ).setConst( true ) );
|
|
227
236
|
|
|
228
237
|
}
|
|
229
238
|
|
|
@@ -233,7 +242,7 @@ export const vec3 = ( ...params ) => {
|
|
|
233
242
|
|
|
234
243
|
if ( params[ 0 ]?.isNode === true ) {
|
|
235
244
|
|
|
236
|
-
return
|
|
245
|
+
return nodeObject( new ConvertNode( params[ 0 ], 'vec3' ) );
|
|
237
246
|
|
|
238
247
|
} else {
|
|
239
248
|
|
|
@@ -245,7 +254,7 @@ export const vec3 = ( ...params ) => {
|
|
|
245
254
|
|
|
246
255
|
}
|
|
247
256
|
|
|
248
|
-
return
|
|
257
|
+
return nodeObject( new Vector3Node( new Vector3( ...params ) ).setConst( true ) );
|
|
249
258
|
|
|
250
259
|
}
|
|
251
260
|
|
|
@@ -255,7 +264,7 @@ export const vec4 = ( ...params ) => {
|
|
|
255
264
|
|
|
256
265
|
if ( params[ 0 ]?.isNode === true ) {
|
|
257
266
|
|
|
258
|
-
return
|
|
267
|
+
return nodeObject( new ConvertNode( params[ 0 ], 'vec4' ) );
|
|
259
268
|
|
|
260
269
|
} else {
|
|
261
270
|
|
|
@@ -267,7 +276,7 @@ export const vec4 = ( ...params ) => {
|
|
|
267
276
|
|
|
268
277
|
}
|
|
269
278
|
|
|
270
|
-
return
|
|
279
|
+
return nodeObject( new Vector4Node( new Vector4( ...params ) ).setConst( true ) );
|
|
271
280
|
|
|
272
281
|
}
|
|
273
282
|
|
|
@@ -277,7 +286,7 @@ export const addTo = ( varNode, ...params ) => {
|
|
|
277
286
|
|
|
278
287
|
varNode.node = add( varNode.node, ...ShaderNodeArray( params ) );
|
|
279
288
|
|
|
280
|
-
return
|
|
289
|
+
return nodeObject( varNode );
|
|
281
290
|
|
|
282
291
|
};
|
|
283
292
|
|
|
@@ -318,29 +327,47 @@ export const alphaTest = new PropertyNode( 'AlphaTest', 'float' );
|
|
|
318
327
|
export const specularColor = new PropertyNode( 'SpecularColor', 'color' );
|
|
319
328
|
|
|
320
329
|
export const abs = ShaderNodeProxy( MathNode, 'abs' );
|
|
321
|
-
export const
|
|
322
|
-
export const
|
|
323
|
-
export const
|
|
330
|
+
export const acos = ShaderNodeProxy( MathNode, 'acos' );
|
|
331
|
+
export const asin = ShaderNodeProxy( MathNode, 'asin' );
|
|
332
|
+
export const atan = ShaderNodeProxy( MathNode, 'atan' );
|
|
333
|
+
export const ceil = ShaderNodeProxy( MathNode, 'ceil' );
|
|
334
|
+
export const clamp = ShaderNodeProxy( MathNode, 'clamp' );
|
|
335
|
+
export const cos = ShaderNodeProxy( MathNode, 'cos' );
|
|
324
336
|
export const cross = ShaderNodeProxy( MathNode, 'cross' );
|
|
337
|
+
export const degrees = ShaderNodeProxy( MathNode, 'degrees' );
|
|
338
|
+
export const dFdx = ShaderNodeProxy( MathNode, 'dFdx' );
|
|
339
|
+
export const dFdy = ShaderNodeProxy( MathNode, 'dFdy' );
|
|
340
|
+
export const distance = ShaderNodeProxy( MathNode, 'distance' );
|
|
341
|
+
export const dot = ShaderNodeProxy( MathNode, 'dot' );
|
|
342
|
+
export const exp = ShaderNodeProxy( MathNode, 'exp' );
|
|
343
|
+
export const exp2 = ShaderNodeProxy( MathNode, 'exp2' );
|
|
344
|
+
export const faceforward = ShaderNodeProxy( MathNode, 'faceforward' );
|
|
345
|
+
export const floor = ShaderNodeProxy( MathNode, 'floor' );
|
|
325
346
|
export const fract = ShaderNodeProxy( MathNode, 'fract' );
|
|
326
|
-
export const
|
|
347
|
+
export const invert = ShaderNodeProxy( MathNode, 'invert' );
|
|
348
|
+
export const inversesqrt = ShaderNodeProxy( MathNode, 'inversesqrt' );
|
|
349
|
+
export const length = ShaderNodeProxy( MathNode, 'length' );
|
|
350
|
+
export const log = ShaderNodeProxy( MathNode, 'log' );
|
|
351
|
+
export const log2 = ShaderNodeProxy( MathNode, 'log2' );
|
|
327
352
|
export const max = ShaderNodeProxy( MathNode, 'max' );
|
|
328
353
|
export const min = ShaderNodeProxy( MathNode, 'min' );
|
|
329
|
-
export const
|
|
330
|
-
export const
|
|
331
|
-
export const
|
|
354
|
+
export const mix = ShaderNodeProxy( MathNode, 'mix' );
|
|
355
|
+
export const mod = ShaderNodeProxy( MathNode, 'mod' );
|
|
356
|
+
export const negate = ShaderNodeProxy( MathNode, 'negate' );
|
|
332
357
|
export const normalize = ShaderNodeProxy( MathNode, 'normalize' );
|
|
333
|
-
export const sqrt = ShaderNodeProxy( MathNode, 'sqrt' );
|
|
334
|
-
export const inversesqrt = ShaderNodeProxy( MathNode, 'inversesqrt' );
|
|
335
|
-
export const sign = ShaderNodeProxy( MathNode, 'sign' );
|
|
336
|
-
export const dFdx = ShaderNodeProxy( MathNode, 'dFdx' );
|
|
337
|
-
export const dFdy = ShaderNodeProxy( MathNode, 'dFdy' );
|
|
338
358
|
export const pow = ShaderNodeProxy( MathNode, 'pow' );
|
|
339
359
|
export const pow2 = ShaderNodeProxy( MathNode, 'pow', 2 );
|
|
340
360
|
export const pow3 = ShaderNodeProxy( MathNode, 'pow', 3 );
|
|
341
361
|
export const pow4 = ShaderNodeProxy( MathNode, 'pow', 4 );
|
|
342
|
-
export const
|
|
343
|
-
export const
|
|
344
|
-
export const
|
|
362
|
+
export const radians = ShaderNodeProxy( MathNode, 'radians' );
|
|
363
|
+
export const reflect = ShaderNodeProxy( MathNode, 'reflect' );
|
|
364
|
+
export const refract = ShaderNodeProxy( MathNode, 'refract' );
|
|
365
|
+
export const round = ShaderNodeProxy( MathNode, 'round' );
|
|
345
366
|
export const saturate = ShaderNodeProxy( MathNode, 'saturate' );
|
|
367
|
+
export const sign = ShaderNodeProxy( MathNode, 'sign' );
|
|
368
|
+
export const sin = ShaderNodeProxy( MathNode, 'sin' );
|
|
369
|
+
export const smoothstep = ShaderNodeProxy( MathNode, 'smoothstep' );
|
|
370
|
+
export const sqrt = ShaderNodeProxy( MathNode, 'sqrt' );
|
|
371
|
+
export const step = ShaderNodeProxy( MathNode, 'step' );
|
|
372
|
+
export const tan = ShaderNodeProxy( MathNode, 'tan' );
|
|
346
373
|
export const transformDirection = ShaderNodeProxy( MathNode, 'transformDirection' );
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import TempNode from '../core/Node.js';
|
|
2
2
|
import { ShaderNode,
|
|
3
3
|
vec3,
|
|
4
|
-
pow, mul,
|
|
4
|
+
pow, mul, sub, mix, join,
|
|
5
5
|
lessThanEqual } from '../ShaderNode.js';
|
|
6
6
|
|
|
7
7
|
import { LinearEncoding, sRGBEncoding } from 'three';
|
|
@@ -12,22 +12,6 @@ export const LinearToLinear = new ShaderNode( ( inputs ) => {
|
|
|
12
12
|
|
|
13
13
|
} );
|
|
14
14
|
|
|
15
|
-
export const sRGBToLinear = new ShaderNode( ( inputs ) => {
|
|
16
|
-
|
|
17
|
-
const { value } = inputs;
|
|
18
|
-
|
|
19
|
-
const rgb = value.rgb;
|
|
20
|
-
|
|
21
|
-
const a = pow( add( mul( rgb, 0.9478672986 ), vec3( 0.0521327014 ) ), vec3( 2.4 ) );
|
|
22
|
-
const b = mul( rgb, 0.0773993808 );
|
|
23
|
-
const factor = vec3( lessThanEqual( rgb, vec3( 0.04045 ) ) );
|
|
24
|
-
|
|
25
|
-
const rgbResult = mix( a, b, factor );
|
|
26
|
-
|
|
27
|
-
return join( rgbResult.r, rgbResult.g, rgbResult.b, value.a );
|
|
28
|
-
|
|
29
|
-
} );
|
|
30
|
-
|
|
31
15
|
export const LinearTosRGB = new ShaderNode( ( inputs ) => {
|
|
32
16
|
|
|
33
17
|
const { value } = inputs;
|
|
@@ -46,28 +30,12 @@ export const LinearTosRGB = new ShaderNode( ( inputs ) => {
|
|
|
46
30
|
|
|
47
31
|
const EncodingLib = {
|
|
48
32
|
LinearToLinear,
|
|
49
|
-
sRGBToLinear,
|
|
50
33
|
LinearTosRGB
|
|
51
34
|
};
|
|
52
35
|
|
|
53
|
-
function getEncodingComponents( encoding ) {
|
|
54
|
-
|
|
55
|
-
switch ( encoding ) {
|
|
56
|
-
|
|
57
|
-
case LinearEncoding:
|
|
58
|
-
return [ 'Linear' ];
|
|
59
|
-
case sRGBEncoding:
|
|
60
|
-
return [ 'sRGB' ];
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
|
|
66
36
|
class ColorSpaceNode extends TempNode {
|
|
67
37
|
|
|
68
38
|
static LINEAR_TO_LINEAR = 'LinearToLinear';
|
|
69
|
-
|
|
70
|
-
static SRGB_TO_LINEAR = 'sRGBToLinear';
|
|
71
39
|
static LINEAR_TO_SRGB = 'LinearTosRGB';
|
|
72
40
|
|
|
73
41
|
constructor( method, node ) {
|
|
@@ -77,27 +45,24 @@ class ColorSpaceNode extends TempNode {
|
|
|
77
45
|
this.method = method;
|
|
78
46
|
|
|
79
47
|
this.node = node;
|
|
80
|
-
this.factor = null;
|
|
81
48
|
|
|
82
49
|
}
|
|
83
50
|
|
|
84
51
|
fromEncoding( encoding ) {
|
|
85
52
|
|
|
86
|
-
|
|
53
|
+
let method = null;
|
|
87
54
|
|
|
88
|
-
|
|
89
|
-
this.factor = components[ 1 ];
|
|
55
|
+
if ( encoding === LinearEncoding ) {
|
|
90
56
|
|
|
91
|
-
|
|
57
|
+
method = 'Linear';
|
|
92
58
|
|
|
93
|
-
|
|
59
|
+
} else if ( encoding === sRGBEncoding ) {
|
|
94
60
|
|
|
95
|
-
|
|
61
|
+
method = 'sRGB';
|
|
96
62
|
|
|
97
|
-
|
|
63
|
+
}
|
|
98
64
|
|
|
99
|
-
this.method =
|
|
100
|
-
this.factor = components[ 1 ];
|
|
65
|
+
this.method = 'LinearTo' + method;
|
|
101
66
|
|
|
102
67
|
return this;
|
|
103
68
|
|
|
@@ -113,11 +78,9 @@ class ColorSpaceNode extends TempNode {
|
|
|
113
78
|
if ( method !== ColorSpaceNode.LINEAR_TO_LINEAR ) {
|
|
114
79
|
|
|
115
80
|
const encodingFunctionNode = EncodingLib[ method ];
|
|
116
|
-
const factor = this.factor;
|
|
117
81
|
|
|
118
82
|
return encodingFunctionNode( {
|
|
119
|
-
value: node
|
|
120
|
-
factor
|
|
83
|
+
value: node
|
|
121
84
|
} ).build( builder, type );
|
|
122
85
|
|
|
123
86
|
} else {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import InputNode from '../core/InputNode.js';
|
|
2
2
|
import ExpressionNode from '../core/ExpressionNode.js';
|
|
3
3
|
import UVNode from '../accessors/UVNode.js';
|
|
4
|
-
import ColorSpaceNode from '../display/ColorSpaceNode.js';
|
|
5
4
|
|
|
6
5
|
class TextureNode extends InputNode {
|
|
7
6
|
|
|
@@ -41,9 +40,9 @@ class TextureNode extends InputNode {
|
|
|
41
40
|
|
|
42
41
|
const nodeData = builder.getDataFromNode( this );
|
|
43
42
|
|
|
44
|
-
let
|
|
43
|
+
let snippet = nodeData.snippet;
|
|
45
44
|
|
|
46
|
-
if (
|
|
45
|
+
if ( snippet === undefined ) {
|
|
47
46
|
|
|
48
47
|
const uvSnippet = this.uv.build( builder, 'vec2' );
|
|
49
48
|
const bias = this.bias;
|
|
@@ -56,17 +55,13 @@ class TextureNode extends InputNode {
|
|
|
56
55
|
|
|
57
56
|
}
|
|
58
57
|
|
|
59
|
-
|
|
58
|
+
snippet = builder.getTexture( textureProperty, uvSnippet, biasSnippet );
|
|
60
59
|
|
|
61
|
-
|
|
62
|
-
colorSpace.node = new ExpressionNode( textureCallSnippet, 'vec4' );
|
|
63
|
-
colorSpace.fromDecoding( builder.getTextureEncodingFromMap( texture ) );
|
|
64
|
-
|
|
65
|
-
nodeData.colorSpace = colorSpace;
|
|
60
|
+
nodeData.snippet = snippet;
|
|
66
61
|
|
|
67
62
|
}
|
|
68
63
|
|
|
69
|
-
return
|
|
64
|
+
return builder.format( snippet, 'vec4', output );
|
|
70
65
|
|
|
71
66
|
}
|
|
72
67
|
|
|
@@ -17,7 +17,7 @@ class WebGPUObjects {
|
|
|
17
17
|
|
|
18
18
|
if ( geometry.isBufferGeometry !== true ) {
|
|
19
19
|
|
|
20
|
-
throw 'THREE.WebGPURenderer: This renderer only supports THREE.BufferGeometry for geometries.';
|
|
20
|
+
throw new Error( 'THREE.WebGPURenderer: This renderer only supports THREE.BufferGeometry for geometries.' );
|
|
21
21
|
|
|
22
22
|
}
|
|
23
23
|
|
|
@@ -92,7 +92,6 @@ class WebGPURenderer {
|
|
|
92
92
|
this._adapter = null;
|
|
93
93
|
this._device = null;
|
|
94
94
|
this._context = null;
|
|
95
|
-
this._swapChain = null;
|
|
96
95
|
this._colorBuffer = null;
|
|
97
96
|
this._depthBuffer = null;
|
|
98
97
|
|
|
@@ -166,15 +165,14 @@ class WebGPURenderer {
|
|
|
166
165
|
|
|
167
166
|
const context = ( parameters.context !== undefined ) ? parameters.context : this.domElement.getContext( 'webgpu' );
|
|
168
167
|
|
|
169
|
-
|
|
168
|
+
context.configure( {
|
|
170
169
|
device: device,
|
|
171
|
-
format: GPUTextureFormat.BGRA8Unorm // this is the only valid
|
|
170
|
+
format: GPUTextureFormat.BGRA8Unorm // this is the only valid context format right now (r121)
|
|
172
171
|
} );
|
|
173
172
|
|
|
174
173
|
this._adapter = adapter;
|
|
175
174
|
this._device = device;
|
|
176
175
|
this._context = context;
|
|
177
|
-
this._swapChain = swapChain;
|
|
178
176
|
|
|
179
177
|
this._info = new WebGPUInfo();
|
|
180
178
|
this._properties = new WebGPUProperties();
|
|
@@ -489,7 +487,7 @@ class WebGPURenderer {
|
|
|
489
487
|
|
|
490
488
|
} else {
|
|
491
489
|
|
|
492
|
-
format = GPUTextureFormat.BGRA8Unorm; // default
|
|
490
|
+
format = GPUTextureFormat.BGRA8Unorm; // default context format
|
|
493
491
|
|
|
494
492
|
}
|
|
495
493
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { GPUTextureFormat, GPUAddressMode, GPUFilterMode, GPUTextureDimension } from './constants.js';
|
|
2
2
|
import { CubeTexture, Texture, NearestFilter, NearestMipmapNearestFilter, NearestMipmapLinearFilter, LinearFilter, RepeatWrapping, MirroredRepeatWrapping,
|
|
3
|
-
|
|
3
|
+
RGBAFormat, RedFormat, RGFormat, RGBA_S3TC_DXT1_Format, RGBA_S3TC_DXT3_Format, RGBA_S3TC_DXT5_Format, UnsignedByteType, FloatType, HalfFloatType, sRGBEncoding
|
|
4
4
|
} from 'three';
|
|
5
5
|
import WebGPUTextureUtils from './WebGPUTextureUtils.js';
|
|
6
6
|
|
|
@@ -564,7 +564,6 @@ class WebGPUTextures {
|
|
|
564
564
|
formatGPU = ( encoding === sRGBEncoding ) ? GPUTextureFormat.BC3RGBAUnormSRGB : GPUTextureFormat.BC3RGBAUnorm;
|
|
565
565
|
break;
|
|
566
566
|
|
|
567
|
-
case RGBFormat:
|
|
568
567
|
case RGBAFormat:
|
|
569
568
|
|
|
570
569
|
switch ( type ) {
|
|
@@ -25,7 +25,7 @@ import ColorSpaceNode from '../../nodes/display/ColorSpaceNode.js';
|
|
|
25
25
|
import LightContextNode from '../../nodes/lights/LightContextNode.js';
|
|
26
26
|
import OperatorNode from '../../nodes/math/OperatorNode.js';
|
|
27
27
|
import WGSLNodeParser from '../../nodes/parsers/WGSLNodeParser.js';
|
|
28
|
-
import { vec4 } from '../../nodes/ShaderNode.js';
|
|
28
|
+
import { vec4, join, nodeObject } from '../../nodes/ShaderNode.js';
|
|
29
29
|
import { getRoughness } from '../../nodes/functions/PhysicalMaterialFunctions.js';
|
|
30
30
|
|
|
31
31
|
const wgslTypeLib = {
|
|
@@ -150,7 +150,7 @@ class WebGPUNodeBuilder extends NodeBuilder {
|
|
|
150
150
|
|
|
151
151
|
colorNode = this.addFlow( 'fragment', new VarNode( colorNode, 'Color', 'vec4' ) );
|
|
152
152
|
|
|
153
|
-
this.addFlow( 'fragment', new VarNode( colorNode, 'DiffuseColor', 'vec4' ) );
|
|
153
|
+
const diffuseColorNode = this.addFlow( 'fragment', new VarNode( colorNode, 'DiffuseColor', 'vec4' ) );
|
|
154
154
|
|
|
155
155
|
// OPACITY
|
|
156
156
|
|
|
@@ -254,7 +254,7 @@ class WebGPUNodeBuilder extends NodeBuilder {
|
|
|
254
254
|
|
|
255
255
|
// LIGHT
|
|
256
256
|
|
|
257
|
-
let outputNode =
|
|
257
|
+
let outputNode = diffuseColorNode;
|
|
258
258
|
|
|
259
259
|
if ( lightNode && lightNode.isNode ) {
|
|
260
260
|
|
|
@@ -266,11 +266,17 @@ class WebGPUNodeBuilder extends NodeBuilder {
|
|
|
266
266
|
|
|
267
267
|
// RESULT
|
|
268
268
|
|
|
269
|
+
const outputNodeObj = nodeObject( outputNode );
|
|
270
|
+
|
|
271
|
+
outputNode = join( outputNodeObj.x, outputNodeObj.y, outputNodeObj.z, nodeObject( diffuseColorNode ).w );
|
|
272
|
+
|
|
273
|
+
//
|
|
274
|
+
|
|
269
275
|
const outputEncoding = this.renderer.outputEncoding;
|
|
270
276
|
|
|
271
277
|
if ( outputEncoding !== LinearEncoding ) {
|
|
272
278
|
|
|
273
|
-
outputNode = new ColorSpaceNode( ColorSpaceNode.LINEAR_TO_LINEAR,
|
|
279
|
+
outputNode = new ColorSpaceNode( ColorSpaceNode.LINEAR_TO_LINEAR, outputNode );
|
|
274
280
|
outputNode.fromEncoding( outputEncoding );
|
|
275
281
|
|
|
276
282
|
}
|