super-three 0.162.0 → 0.163.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/three.cjs +407 -1014
- package/build/three.module.js +406 -1013
- package/build/three.module.min.js +1 -1
- package/examples/jsm/controls/TransformControls.js +3 -3
- package/examples/jsm/exporters/GLTFExporter.js +21 -4
- package/examples/jsm/exporters/USDZExporter.js +15 -0
- package/examples/jsm/geometries/TextGeometry.js +10 -2
- package/examples/jsm/interactive/HTMLMesh.js +7 -9
- package/examples/jsm/libs/fflate.module.js +694 -496
- package/examples/jsm/lines/LineMaterial.js +0 -2
- package/examples/jsm/loaders/3MFLoader.js +2 -0
- package/examples/jsm/loaders/EXRLoader.js +89 -19
- package/examples/jsm/loaders/FBXLoader.js +1 -1
- package/examples/jsm/loaders/GLTFLoader.js +6 -0
- package/examples/jsm/loaders/KTX2Loader.js +2 -6
- package/examples/jsm/loaders/LUT3dlLoader.js +0 -15
- package/examples/jsm/loaders/LUTCubeLoader.js +0 -14
- package/examples/jsm/loaders/LUTImageLoader.js +0 -14
- package/examples/jsm/loaders/RGBMLoader.js +16 -0
- package/examples/jsm/misc/GPUComputationRenderer.js +0 -6
- package/examples/jsm/nodes/Nodes.js +6 -1
- package/examples/jsm/nodes/accessors/BatchNode.js +78 -0
- package/examples/jsm/nodes/accessors/InstanceNode.js +25 -2
- package/examples/jsm/nodes/accessors/MaterialReferenceNode.js +1 -1
- package/examples/jsm/nodes/accessors/MorphNode.js +13 -3
- package/examples/jsm/nodes/accessors/NormalNode.js +12 -2
- package/examples/jsm/nodes/accessors/ReferenceNode.js +1 -1
- package/examples/jsm/nodes/accessors/RendererReferenceNode.js +29 -0
- package/examples/jsm/nodes/accessors/TextureNode.js +30 -7
- package/examples/jsm/nodes/core/Node.js +55 -4
- package/examples/jsm/nodes/core/NodeBuilder.js +21 -16
- package/examples/jsm/nodes/core/NodeFrame.js +10 -10
- package/examples/jsm/nodes/core/NodeUtils.js +2 -2
- package/examples/jsm/nodes/core/UniformNode.js +20 -0
- package/examples/jsm/nodes/display/PassNode.js +17 -1
- package/examples/jsm/nodes/display/ToneMappingNode.js +8 -4
- package/examples/jsm/nodes/display/ViewportSharedTextureNode.js +6 -0
- package/examples/jsm/nodes/fog/FogExp2Node.js +4 -5
- package/examples/jsm/nodes/fog/FogNode.js +13 -3
- package/examples/jsm/nodes/fog/FogRangeNode.js +4 -3
- package/examples/jsm/nodes/lighting/AnalyticLightNode.js +1 -1
- package/examples/jsm/nodes/lighting/EnvironmentNode.js +12 -69
- package/examples/jsm/nodes/materials/NodeMaterial.js +33 -11
- package/examples/jsm/nodes/pmrem/PMREMNode.js +193 -0
- package/examples/jsm/nodes/pmrem/PMREMUtils.js +288 -0
- package/examples/jsm/nodes/shadernode/ShaderNode.js +1 -1
- package/examples/jsm/nodes/utils/EquirectUVNode.js +1 -1
- package/examples/jsm/objects/QuadMesh.js +7 -23
- package/examples/jsm/physics/RapierPhysics.js +4 -4
- package/examples/jsm/postprocessing/GlitchPass.js +0 -3
- package/examples/jsm/postprocessing/LUTPass.js +5 -71
- package/examples/jsm/postprocessing/SAOPass.js +0 -1
- package/examples/jsm/postprocessing/SSAOPass.js +0 -3
- package/examples/jsm/renderers/common/Animation.js +3 -0
- package/examples/jsm/renderers/common/Background.js +5 -5
- package/examples/jsm/renderers/common/Info.js +11 -19
- package/examples/jsm/renderers/common/PostProcessing.js +12 -4
- package/examples/jsm/renderers/common/RenderContext.js +1 -1
- package/examples/jsm/renderers/common/RenderObject.js +4 -4
- package/examples/jsm/renderers/common/RenderObjects.js +1 -1
- package/examples/jsm/renderers/common/Renderer.js +25 -8
- package/examples/jsm/renderers/common/extras/PMREMGenerator.js +777 -0
- package/examples/jsm/renderers/common/nodes/Nodes.js +5 -18
- package/examples/jsm/renderers/webgl/WebGLBackend.js +148 -24
- package/examples/jsm/renderers/webgl/WebGLBufferRenderer.js +141 -0
- package/examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js +3 -3
- package/examples/jsm/renderers/webgl/utils/WebGLAttributeUtils.js +1 -1
- package/examples/jsm/renderers/webgl/utils/WebGLConstants.js +1 -0
- package/examples/jsm/renderers/webgl/utils/WebGLTextureUtils.js +43 -0
- package/examples/jsm/renderers/webgl/utils/WebGLUtils.js +3 -2
- package/examples/jsm/renderers/webgl-legacy/nodes/GLSL1NodeBuilder.js +0 -2
- package/examples/jsm/renderers/webgl-legacy/nodes/WebGLNodeBuilder.js +0 -2
- package/examples/jsm/renderers/webgpu/WebGPUBackend.js +54 -25
- package/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js +5 -3
- package/examples/jsm/renderers/webgpu/utils/WebGPUAttributeUtils.js +25 -0
- package/examples/jsm/renderers/webgpu/utils/WebGPUBindingUtils.js +18 -4
- package/examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js +92 -18
- package/examples/jsm/utils/GPUStatsPanel.js +10 -45
- package/examples/jsm/utils/TextureUtils.js +1 -1
- package/package.json +1 -1
- package/src/Three.js +0 -1
- package/src/animation/AnimationClip.js +1 -1
- package/src/constants.js +3 -3
- package/src/core/Object3D.js +10 -7
- package/src/extras/PMREMGenerator.js +9 -0
- package/src/loaders/ObjectLoader.js +2 -0
- package/src/materials/ShaderMaterial.js +0 -4
- package/src/math/Spherical.js +4 -5
- package/src/objects/BatchedMesh.js +4 -3
- package/src/objects/InstancedMesh.js +10 -0
- package/src/renderers/WebGLRenderer.js +55 -114
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_fragment.glsl.js +2 -2
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_vertex.glsl.js +2 -10
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_vertex.glsl.js +2 -16
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +32 -22
- package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib.js +1 -1
- package/src/renderers/shaders/UniformsUtils.js +10 -1
- package/src/renderers/webgl/WebGLAttributes.js +6 -33
- package/src/renderers/webgl/WebGLBindingStates.js +14 -51
- package/src/renderers/webgl/WebGLBufferRenderer.js +3 -25
- package/src/renderers/webgl/WebGLCapabilities.js +2 -12
- package/src/renderers/webgl/WebGLCubeUVMaps.js +10 -6
- package/src/renderers/webgl/WebGLExtensions.js +4 -19
- package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +3 -25
- package/src/renderers/webgl/WebGLLights.js +6 -32
- package/src/renderers/webgl/WebGLMaterials.js +2 -3
- package/src/renderers/webgl/WebGLMorphtargets.js +79 -217
- package/src/renderers/webgl/WebGLProgram.js +18 -47
- package/src/renderers/webgl/WebGLPrograms.js +20 -32
- package/src/renderers/webgl/WebGLRenderStates.js +8 -6
- package/src/renderers/webgl/WebGLState.js +15 -59
- package/src/renderers/webgl/WebGLTextures.js +75 -237
- package/src/renderers/webgl/WebGLUniformsGroups.js +1 -1
- package/src/renderers/webgl/WebGLUtils.js +6 -57
- package/src/renderers/webxr/WebXRDepthSensing.js +2 -3
- package/src/renderers/webxr/WebXRManager.js +2 -2
- package/src/scenes/Scene.js +7 -1
- package/src/textures/Texture.js +11 -1
- package/examples/jsm/nodes/utils/SpecularMIPLevelNode.js +0 -37
- package/src/renderers/WebGL1Renderer.js +0 -7
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
import { tslFn, int, float, vec2, vec3, vec4, If } from '../shadernode/ShaderNode.js';
|
|
2
|
+
import { cos, sin, abs, max, exp2, log2, clamp, fract, mix, floor, normalize, cross, all } from '../math/MathNode.js';
|
|
3
|
+
import { mul } from '../math/OperatorNode.js';
|
|
4
|
+
import { cond } from '../math/CondNode.js';
|
|
5
|
+
import { loop, Break } from '../utils/LoopNode.js';
|
|
6
|
+
|
|
7
|
+
// These defines must match with PMREMGenerator
|
|
8
|
+
|
|
9
|
+
const cubeUV_r0 = float( 1.0 );
|
|
10
|
+
const cubeUV_m0 = float( - 2.0 );
|
|
11
|
+
const cubeUV_r1 = float( 0.8 );
|
|
12
|
+
const cubeUV_m1 = float( - 1.0 );
|
|
13
|
+
const cubeUV_r4 = float( 0.4 );
|
|
14
|
+
const cubeUV_m4 = float( 2.0 );
|
|
15
|
+
const cubeUV_r5 = float( 0.305 );
|
|
16
|
+
const cubeUV_m5 = float( 3.0 );
|
|
17
|
+
const cubeUV_r6 = float( 0.21 );
|
|
18
|
+
const cubeUV_m6 = float( 4.0 );
|
|
19
|
+
|
|
20
|
+
const cubeUV_minMipLevel = float( 4.0 );
|
|
21
|
+
const cubeUV_minTileSize = float( 16.0 );
|
|
22
|
+
|
|
23
|
+
// These shader functions convert between the UV coordinates of a single face of
|
|
24
|
+
// a cubemap, the 0-5 integer index of a cube face, and the direction vector for
|
|
25
|
+
// sampling a textureCube (not generally normalized ).
|
|
26
|
+
|
|
27
|
+
const getFace = tslFn( ( [ direction ] ) => {
|
|
28
|
+
|
|
29
|
+
const absDirection = vec3( abs( direction ) ).toVar();
|
|
30
|
+
const face = float( - 1.0 ).toVar();
|
|
31
|
+
|
|
32
|
+
If( absDirection.x.greaterThan( absDirection.z ), () => {
|
|
33
|
+
|
|
34
|
+
If( absDirection.x.greaterThan( absDirection.y ), () => {
|
|
35
|
+
|
|
36
|
+
face.assign( cond( direction.x.greaterThan( 0.0 ), 0.0, 3.0 ) );
|
|
37
|
+
|
|
38
|
+
} ).else( () => {
|
|
39
|
+
|
|
40
|
+
face.assign( cond( direction.y.greaterThan( 0.0 ), 1.0, 4.0 ) );
|
|
41
|
+
|
|
42
|
+
} );
|
|
43
|
+
|
|
44
|
+
} ).else( () => {
|
|
45
|
+
|
|
46
|
+
If( absDirection.z.greaterThan( absDirection.y ), () => {
|
|
47
|
+
|
|
48
|
+
face.assign( cond( direction.z.greaterThan( 0.0 ), 2.0, 5.0 ) );
|
|
49
|
+
|
|
50
|
+
} ).else( () => {
|
|
51
|
+
|
|
52
|
+
face.assign( cond( direction.y.greaterThan( 0.0 ), 1.0, 4.0 ) );
|
|
53
|
+
|
|
54
|
+
} );
|
|
55
|
+
|
|
56
|
+
} );
|
|
57
|
+
|
|
58
|
+
return face;
|
|
59
|
+
|
|
60
|
+
} ).setLayout( {
|
|
61
|
+
name: 'getFace',
|
|
62
|
+
type: 'float',
|
|
63
|
+
inputs: [
|
|
64
|
+
{ name: 'direction', type: 'vec3' }
|
|
65
|
+
]
|
|
66
|
+
} );
|
|
67
|
+
|
|
68
|
+
// RH coordinate system; PMREM face-indexing convention
|
|
69
|
+
const getUV = tslFn( ( [ direction, face ] ) => {
|
|
70
|
+
|
|
71
|
+
const uv = vec2().toVar();
|
|
72
|
+
|
|
73
|
+
If( face.equal( 0.0 ), () => {
|
|
74
|
+
|
|
75
|
+
uv.assign( vec2( direction.z, direction.y ).div( abs( direction.x ) ) ); // pos x
|
|
76
|
+
|
|
77
|
+
} ).elseif( face.equal( 1.0 ), () => {
|
|
78
|
+
|
|
79
|
+
uv.assign( vec2( direction.x.negate(), direction.z.negate() ).div( abs( direction.y ) ) ); // pos y
|
|
80
|
+
|
|
81
|
+
} ).elseif( face.equal( 2.0 ), () => {
|
|
82
|
+
|
|
83
|
+
uv.assign( vec2( direction.x.negate(), direction.y ).div( abs( direction.z ) ) ); // pos z
|
|
84
|
+
|
|
85
|
+
} ).elseif( face.equal( 3.0 ), () => {
|
|
86
|
+
|
|
87
|
+
uv.assign( vec2( direction.z.negate(), direction.y ).div( abs( direction.x ) ) ); // neg x
|
|
88
|
+
|
|
89
|
+
} ).elseif( face.equal( 4.0 ), () => {
|
|
90
|
+
|
|
91
|
+
uv.assign( vec2( direction.x.negate(), direction.z ).div( abs( direction.y ) ) ); // neg y
|
|
92
|
+
|
|
93
|
+
} ).else( () => {
|
|
94
|
+
|
|
95
|
+
uv.assign( vec2( direction.x, direction.y ).div( abs( direction.z ) ) ); // neg z
|
|
96
|
+
|
|
97
|
+
} );
|
|
98
|
+
|
|
99
|
+
return mul( 0.5, uv.add( 1.0 ) );
|
|
100
|
+
|
|
101
|
+
} ).setLayout( {
|
|
102
|
+
name: 'getUV',
|
|
103
|
+
type: 'vec2',
|
|
104
|
+
inputs: [
|
|
105
|
+
{ name: 'direction', type: 'vec3' },
|
|
106
|
+
{ name: 'face', type: 'float' }
|
|
107
|
+
]
|
|
108
|
+
} );
|
|
109
|
+
|
|
110
|
+
const roughnessToMip = tslFn( ( [ roughness ] ) => {
|
|
111
|
+
|
|
112
|
+
const mip = float( 0.0 ).toVar();
|
|
113
|
+
|
|
114
|
+
If( roughness.greaterThanEqual( cubeUV_r1 ), () => {
|
|
115
|
+
|
|
116
|
+
mip.assign( cubeUV_r0.sub( roughness ).mul( cubeUV_m1.sub( cubeUV_m0 ) ).div( cubeUV_r0.sub( cubeUV_r1 ) ).add( cubeUV_m0 ) );
|
|
117
|
+
|
|
118
|
+
} ).elseif( roughness.greaterThanEqual( cubeUV_r4 ), () => {
|
|
119
|
+
|
|
120
|
+
mip.assign( cubeUV_r1.sub( roughness ).mul( cubeUV_m4.sub( cubeUV_m1 ) ).div( cubeUV_r1.sub( cubeUV_r4 ) ).add( cubeUV_m1 ) );
|
|
121
|
+
|
|
122
|
+
} ).elseif( roughness.greaterThanEqual( cubeUV_r5 ), () => {
|
|
123
|
+
|
|
124
|
+
mip.assign( cubeUV_r4.sub( roughness ).mul( cubeUV_m5.sub( cubeUV_m4 ) ).div( cubeUV_r4.sub( cubeUV_r5 ) ).add( cubeUV_m4 ) );
|
|
125
|
+
|
|
126
|
+
} ).elseif( roughness.greaterThanEqual( cubeUV_r6 ), () => {
|
|
127
|
+
|
|
128
|
+
mip.assign( cubeUV_r5.sub( roughness ).mul( cubeUV_m6.sub( cubeUV_m5 ) ).div( cubeUV_r5.sub( cubeUV_r6 ) ).add( cubeUV_m5 ) );
|
|
129
|
+
|
|
130
|
+
} ).else( () => {
|
|
131
|
+
|
|
132
|
+
mip.assign( float( - 2.0 ).mul( log2( mul( 1.16, roughness ) ) ) ); // 1.16 = 1.79^0.25
|
|
133
|
+
|
|
134
|
+
} );
|
|
135
|
+
|
|
136
|
+
return mip;
|
|
137
|
+
|
|
138
|
+
} ).setLayout( {
|
|
139
|
+
name: 'roughnessToMip',
|
|
140
|
+
type: 'float',
|
|
141
|
+
inputs: [
|
|
142
|
+
{ name: 'roughness', type: 'float' }
|
|
143
|
+
]
|
|
144
|
+
} );
|
|
145
|
+
|
|
146
|
+
// RH coordinate system; PMREM face-indexing convention
|
|
147
|
+
export const getDirection = tslFn( ( [ uv_immutable, face ] ) => {
|
|
148
|
+
|
|
149
|
+
const uv = uv_immutable.toVar();
|
|
150
|
+
uv.assign( mul( 2.0, uv ).sub( 1.0 ) );
|
|
151
|
+
const direction = vec3( uv, 1.0 ).toVar();
|
|
152
|
+
|
|
153
|
+
If( face.equal( 0.0 ), () => {
|
|
154
|
+
|
|
155
|
+
direction.assign( direction.zyx ); // ( 1, v, u ) pos x
|
|
156
|
+
|
|
157
|
+
} ).elseif( face.equal( 1.0 ), () => {
|
|
158
|
+
|
|
159
|
+
direction.assign( direction.xzy );
|
|
160
|
+
direction.xz.mulAssign( - 1.0 ); // ( -u, 1, -v ) pos y
|
|
161
|
+
|
|
162
|
+
} ).elseif( face.equal( 2.0 ), () => {
|
|
163
|
+
|
|
164
|
+
direction.x.mulAssign( - 1.0 ); // ( -u, v, 1 ) pos z
|
|
165
|
+
|
|
166
|
+
} ).elseif( face.equal( 3.0 ), () => {
|
|
167
|
+
|
|
168
|
+
direction.assign( direction.zyx );
|
|
169
|
+
direction.xz.mulAssign( - 1.0 ); // ( -1, v, -u ) neg x
|
|
170
|
+
|
|
171
|
+
} ).elseif( face.equal( 4.0 ), () => {
|
|
172
|
+
|
|
173
|
+
direction.assign( direction.xzy );
|
|
174
|
+
direction.xy.mulAssign( - 1.0 ); // ( -u, -1, v ) neg y
|
|
175
|
+
|
|
176
|
+
} ).elseif( face.equal( 5.0 ), () => {
|
|
177
|
+
|
|
178
|
+
direction.z.mulAssign( - 1.0 ); // ( u, v, -1 ) neg zS
|
|
179
|
+
|
|
180
|
+
} );
|
|
181
|
+
|
|
182
|
+
return direction;
|
|
183
|
+
|
|
184
|
+
} ).setLayout( {
|
|
185
|
+
name: 'getDirection',
|
|
186
|
+
type: 'vec3',
|
|
187
|
+
inputs: [
|
|
188
|
+
{ name: 'uv', type: 'vec2' },
|
|
189
|
+
{ name: 'face', type: 'float' }
|
|
190
|
+
]
|
|
191
|
+
} );
|
|
192
|
+
|
|
193
|
+
//
|
|
194
|
+
|
|
195
|
+
export const textureCubeUV = tslFn( ( [ envMap, sampleDir_immutable, roughness_immutable, CUBEUV_TEXEL_WIDTH, CUBEUV_TEXEL_HEIGHT, CUBEUV_MAX_MIP ] ) => {
|
|
196
|
+
|
|
197
|
+
const roughness = float( roughness_immutable );
|
|
198
|
+
const sampleDir = vec3( sampleDir_immutable );
|
|
199
|
+
|
|
200
|
+
const mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
|
|
201
|
+
const mipF = fract( mip );
|
|
202
|
+
const mipInt = floor( mip );
|
|
203
|
+
const color0 = vec3( bilinearCubeUV( envMap, sampleDir, mipInt, CUBEUV_TEXEL_WIDTH, CUBEUV_TEXEL_HEIGHT, CUBEUV_MAX_MIP ) ).toVar();
|
|
204
|
+
|
|
205
|
+
If( mipF.notEqual( 0.0 ), () => {
|
|
206
|
+
|
|
207
|
+
const color1 = vec3( bilinearCubeUV( envMap, sampleDir, mipInt.add( 1.0 ), CUBEUV_TEXEL_WIDTH, CUBEUV_TEXEL_HEIGHT, CUBEUV_MAX_MIP ) ).toVar();
|
|
208
|
+
|
|
209
|
+
color0.assign( mix( color0, color1, mipF ) );
|
|
210
|
+
|
|
211
|
+
} );
|
|
212
|
+
|
|
213
|
+
return color0;
|
|
214
|
+
|
|
215
|
+
} );
|
|
216
|
+
|
|
217
|
+
const bilinearCubeUV = tslFn( ( [ envMap, direction_immutable, mipInt_immutable, CUBEUV_TEXEL_WIDTH, CUBEUV_TEXEL_HEIGHT, CUBEUV_MAX_MIP ] ) => {
|
|
218
|
+
|
|
219
|
+
const mipInt = float( mipInt_immutable ).toVar();
|
|
220
|
+
const direction = vec3( direction_immutable );
|
|
221
|
+
const face = float( getFace( direction ) ).toVar();
|
|
222
|
+
const filterInt = float( max( cubeUV_minMipLevel.sub( mipInt ), 0.0 ) ).toVar();
|
|
223
|
+
mipInt.assign( max( mipInt, cubeUV_minMipLevel ) );
|
|
224
|
+
const faceSize = float( exp2( mipInt ) ).toVar();
|
|
225
|
+
const uv = vec2( getUV( direction, face ).mul( faceSize.sub( 2.0 ) ).add( 1.0 ) ).toVar();
|
|
226
|
+
|
|
227
|
+
If( face.greaterThan( 2.0 ), () => {
|
|
228
|
+
|
|
229
|
+
uv.y.addAssign( faceSize );
|
|
230
|
+
face.subAssign( 3.0 );
|
|
231
|
+
|
|
232
|
+
} );
|
|
233
|
+
|
|
234
|
+
uv.x.addAssign( face.mul( faceSize ) );
|
|
235
|
+
uv.x.addAssign( filterInt.mul( mul( 3.0, cubeUV_minTileSize ) ) );
|
|
236
|
+
uv.y.addAssign( mul( 4.0, exp2( CUBEUV_MAX_MIP ).sub( faceSize ) ) );
|
|
237
|
+
uv.x.mulAssign( CUBEUV_TEXEL_WIDTH );
|
|
238
|
+
uv.y.mulAssign( CUBEUV_TEXEL_HEIGHT );
|
|
239
|
+
|
|
240
|
+
return envMap.uv( uv );
|
|
241
|
+
|
|
242
|
+
} );
|
|
243
|
+
|
|
244
|
+
const getSample = tslFn( ( { envMap, mipInt, outputDirection, theta, axis, CUBEUV_TEXEL_WIDTH, CUBEUV_TEXEL_HEIGHT, CUBEUV_MAX_MIP } ) => {
|
|
245
|
+
|
|
246
|
+
const cosTheta = cos( theta );
|
|
247
|
+
|
|
248
|
+
// Rodrigues' axis-angle rotation
|
|
249
|
+
const sampleDirection = outputDirection.mul( cosTheta )
|
|
250
|
+
.add( axis.cross( outputDirection ).mul( sin( theta ) ) )
|
|
251
|
+
.add( axis.mul( axis.dot( outputDirection ).mul( cosTheta.oneMinus() ) ) );
|
|
252
|
+
|
|
253
|
+
return bilinearCubeUV( envMap, sampleDirection, mipInt, CUBEUV_TEXEL_WIDTH, CUBEUV_TEXEL_HEIGHT, CUBEUV_MAX_MIP );
|
|
254
|
+
|
|
255
|
+
} );
|
|
256
|
+
|
|
257
|
+
export const blur = tslFn( ( { n, latitudinal, poleAxis, outputDirection, weights, samples, dTheta, mipInt, envMap, CUBEUV_TEXEL_WIDTH, CUBEUV_TEXEL_HEIGHT, CUBEUV_MAX_MIP } ) => {
|
|
258
|
+
|
|
259
|
+
const axis = vec3( cond( latitudinal, poleAxis, cross( poleAxis, outputDirection ) ) ).toVar();
|
|
260
|
+
|
|
261
|
+
If( all( axis.equals( vec3( 0.0 ) ) ), () => {
|
|
262
|
+
|
|
263
|
+
axis.assign( vec3( outputDirection.z, 0.0, outputDirection.x.negate() ) );
|
|
264
|
+
|
|
265
|
+
} );
|
|
266
|
+
|
|
267
|
+
axis.assign( normalize( axis ) );
|
|
268
|
+
|
|
269
|
+
const gl_FragColor = vec3().toVar();
|
|
270
|
+
gl_FragColor.addAssign( weights.element( int( 0 ) ).mul( getSample( { theta: 0.0, axis, outputDirection, mipInt, envMap, CUBEUV_TEXEL_WIDTH, CUBEUV_TEXEL_HEIGHT, CUBEUV_MAX_MIP } ) ) );
|
|
271
|
+
|
|
272
|
+
loop( { start: int( 1 ), end: n }, ( { i } ) => {
|
|
273
|
+
|
|
274
|
+
If( i.greaterThanEqual( samples ), () => {
|
|
275
|
+
|
|
276
|
+
Break();
|
|
277
|
+
|
|
278
|
+
} );
|
|
279
|
+
|
|
280
|
+
const theta = float( dTheta.mul( float( i ) ) ).toVar();
|
|
281
|
+
gl_FragColor.addAssign( weights.element( i ).mul( getSample( { theta: theta.mul( - 1.0 ), axis, outputDirection, mipInt, envMap, CUBEUV_TEXEL_WIDTH, CUBEUV_TEXEL_HEIGHT, CUBEUV_MAX_MIP } ) ) );
|
|
282
|
+
gl_FragColor.addAssign( weights.element( i ).mul( getSample( { theta, axis, outputDirection, mipInt, envMap, CUBEUV_TEXEL_WIDTH, CUBEUV_TEXEL_HEIGHT, CUBEUV_MAX_MIP } ) ) );
|
|
283
|
+
|
|
284
|
+
} );
|
|
285
|
+
|
|
286
|
+
return vec4( gl_FragColor, 1 );
|
|
287
|
+
|
|
288
|
+
} );
|
|
@@ -555,7 +555,7 @@ addNodeElement( 'append', append );
|
|
|
555
555
|
export const color = new ConvertType( 'color' );
|
|
556
556
|
|
|
557
557
|
export const float = new ConvertType( 'float', cacheMaps.float );
|
|
558
|
-
export const int = new ConvertType( 'int', cacheMaps.
|
|
558
|
+
export const int = new ConvertType( 'int', cacheMaps.ints );
|
|
559
559
|
export const uint = new ConvertType( 'uint', cacheMaps.uint );
|
|
560
560
|
export const bool = new ConvertType( 'bool', cacheMaps.bool );
|
|
561
561
|
|
|
@@ -18,7 +18,7 @@ class EquirectUVNode extends TempNode {
|
|
|
18
18
|
const dir = this.dirNode;
|
|
19
19
|
|
|
20
20
|
const u = dir.z.atan2( dir.x ).mul( 1 / ( Math.PI * 2 ) ).add( 0.5 );
|
|
21
|
-
const v = dir.y.
|
|
21
|
+
const v = dir.y.clamp( - 1.0, 1.0 ).asin().mul( 1 / Math.PI ).add( 0.5 );
|
|
22
22
|
|
|
23
23
|
return vec2( u, v );
|
|
24
24
|
|
|
@@ -23,41 +23,25 @@ class QuadGeometry extends BufferGeometry {
|
|
|
23
23
|
|
|
24
24
|
const _geometry = new QuadGeometry();
|
|
25
25
|
|
|
26
|
-
class QuadMesh {
|
|
26
|
+
class QuadMesh extends Mesh {
|
|
27
27
|
|
|
28
28
|
constructor( material = null ) {
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
super( _geometry, material );
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
dispose() {
|
|
35
|
-
|
|
36
|
-
this._mesh.geometry.dispose();
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
async renderAsync( renderer ) {
|
|
41
|
-
|
|
42
|
-
await renderer.renderAsync( this._mesh, _camera );
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
get material() {
|
|
47
|
-
|
|
48
|
-
return this._mesh.material;
|
|
32
|
+
this.camera = _camera;
|
|
49
33
|
|
|
50
34
|
}
|
|
51
35
|
|
|
52
|
-
|
|
36
|
+
renderAsync( renderer ) {
|
|
53
37
|
|
|
54
|
-
|
|
38
|
+
return renderer.renderAsync( this, _camera );
|
|
55
39
|
|
|
56
40
|
}
|
|
57
41
|
|
|
58
|
-
|
|
42
|
+
render( renderer ) {
|
|
59
43
|
|
|
60
|
-
|
|
44
|
+
renderer.render( this, _camera );
|
|
61
45
|
|
|
62
46
|
}
|
|
63
47
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Clock, Vector3, Quaternion, Matrix4 } from 'three';
|
|
2
2
|
|
|
3
|
-
const RAPIER_PATH = 'https://cdn.skypack.dev/@dimforge/rapier3d-compat@0.
|
|
3
|
+
const RAPIER_PATH = 'https://cdn.skypack.dev/@dimforge/rapier3d-compat@0.12.0';
|
|
4
4
|
|
|
5
5
|
const frameRate = 60;
|
|
6
6
|
|
|
@@ -9,7 +9,7 @@ const ZERO = new Vector3();
|
|
|
9
9
|
|
|
10
10
|
let RAPIER = null;
|
|
11
11
|
|
|
12
|
-
function
|
|
12
|
+
function getShape( geometry ) {
|
|
13
13
|
|
|
14
14
|
const parameters = geometry.parameters;
|
|
15
15
|
|
|
@@ -43,7 +43,7 @@ async function RapierPhysics() {
|
|
|
43
43
|
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
// Docs: https://rapier.rs/docs/api/javascript/JavaScript3D/
|
|
46
|
+
// Docs: https://rapier.rs/docs/api/javascript/JavaScript3D/
|
|
47
47
|
|
|
48
48
|
const gravity = new Vector3( 0.0, - 9.81, 0.0 );
|
|
49
49
|
const world = new RAPIER.World( gravity );
|
|
@@ -77,7 +77,7 @@ async function RapierPhysics() {
|
|
|
77
77
|
|
|
78
78
|
function addMesh( mesh, mass = 0, restitution = 0 ) {
|
|
79
79
|
|
|
80
|
-
const shape =
|
|
80
|
+
const shape = getShape( mesh.geometry );
|
|
81
81
|
|
|
82
82
|
if ( shape === null ) return;
|
|
83
83
|
|
|
@@ -3,7 +3,6 @@ import {
|
|
|
3
3
|
FloatType,
|
|
4
4
|
MathUtils,
|
|
5
5
|
RedFormat,
|
|
6
|
-
LuminanceFormat,
|
|
7
6
|
ShaderMaterial,
|
|
8
7
|
UniformsUtils
|
|
9
8
|
} from 'three';
|
|
@@ -40,8 +39,6 @@ class GlitchPass extends Pass {
|
|
|
40
39
|
|
|
41
40
|
render( renderer, writeBuffer, readBuffer /*, deltaTime, maskActive */ ) {
|
|
42
41
|
|
|
43
|
-
if ( renderer.capabilities.isWebGL2 === false ) this.uniforms[ 'tDisp' ].value.format = LuminanceFormat;
|
|
44
|
-
|
|
45
42
|
this.uniforms[ 'tDiffuse' ].value = readBuffer.texture;
|
|
46
43
|
this.uniforms[ 'seed' ].value = Math.random();//default seeding
|
|
47
44
|
this.uniforms[ 'byp' ].value = 0;
|
|
@@ -4,12 +4,7 @@ const LUTShader = {
|
|
|
4
4
|
|
|
5
5
|
name: 'LUTShader',
|
|
6
6
|
|
|
7
|
-
defines: {
|
|
8
|
-
USE_3DTEXTURE: 1,
|
|
9
|
-
},
|
|
10
|
-
|
|
11
7
|
uniforms: {
|
|
12
|
-
lut3d: { value: null },
|
|
13
8
|
|
|
14
9
|
lut: { value: null },
|
|
15
10
|
lutSize: { value: 0 },
|
|
@@ -34,45 +29,7 @@ const LUTShader = {
|
|
|
34
29
|
fragmentShader: /* glsl */`
|
|
35
30
|
|
|
36
31
|
uniform float lutSize;
|
|
37
|
-
|
|
38
|
-
precision highp sampler3D;
|
|
39
|
-
uniform sampler3D lut3d;
|
|
40
|
-
#else
|
|
41
|
-
uniform sampler2D lut;
|
|
42
|
-
|
|
43
|
-
vec3 lutLookup( sampler2D tex, float size, vec3 rgb ) {
|
|
44
|
-
|
|
45
|
-
float sliceHeight = 1.0 / size;
|
|
46
|
-
float yPixelHeight = 1.0 / ( size * size );
|
|
47
|
-
|
|
48
|
-
// Get the slices on either side of the sample
|
|
49
|
-
float slice = rgb.b * size;
|
|
50
|
-
float interp = fract( slice );
|
|
51
|
-
float slice0 = slice - interp;
|
|
52
|
-
float centeredInterp = interp - 0.5;
|
|
53
|
-
|
|
54
|
-
float slice1 = slice0 + sign( centeredInterp );
|
|
55
|
-
|
|
56
|
-
// Pull y sample in by half a pixel in each direction to avoid color
|
|
57
|
-
// bleeding from adjacent slices.
|
|
58
|
-
float greenOffset = clamp( rgb.g * sliceHeight, yPixelHeight * 0.5, sliceHeight - yPixelHeight * 0.5 );
|
|
59
|
-
|
|
60
|
-
vec2 uv0 = vec2(
|
|
61
|
-
rgb.r,
|
|
62
|
-
slice0 * sliceHeight + greenOffset
|
|
63
|
-
);
|
|
64
|
-
vec2 uv1 = vec2(
|
|
65
|
-
rgb.r,
|
|
66
|
-
slice1 * sliceHeight + greenOffset
|
|
67
|
-
);
|
|
68
|
-
|
|
69
|
-
vec3 sample0 = texture2D( tex, uv0 ).rgb;
|
|
70
|
-
vec3 sample1 = texture2D( tex, uv1 ).rgb;
|
|
71
|
-
|
|
72
|
-
return mix( sample0, sample1, abs( centeredInterp ) );
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
#endif
|
|
32
|
+
uniform sampler3D lut;
|
|
76
33
|
|
|
77
34
|
varying vec2 vUv;
|
|
78
35
|
uniform float intensity;
|
|
@@ -88,15 +45,8 @@ const LUTShader = {
|
|
|
88
45
|
float halfPixelWidth = 0.5 / lutSize;
|
|
89
46
|
vec3 uvw = vec3( halfPixelWidth ) + val.rgb * ( 1.0 - pixelWidth );
|
|
90
47
|
|
|
91
|
-
#if USE_3DTEXTURE
|
|
92
48
|
|
|
93
|
-
lutVal = vec4( texture(
|
|
94
|
-
|
|
95
|
-
#else
|
|
96
|
-
|
|
97
|
-
lutVal = vec4( lutLookup( lut, lutSize, uvw ), val.a );
|
|
98
|
-
|
|
99
|
-
#endif
|
|
49
|
+
lutVal = vec4( texture( lut, uvw ).rgb, val.a );
|
|
100
50
|
|
|
101
51
|
gl_FragColor = vec4( mix( val, lutVal, intensity ) );
|
|
102
52
|
|
|
@@ -111,31 +61,15 @@ class LUTPass extends ShaderPass {
|
|
|
111
61
|
set lut( v ) {
|
|
112
62
|
|
|
113
63
|
const material = this.material;
|
|
64
|
+
|
|
114
65
|
if ( v !== this.lut ) {
|
|
115
66
|
|
|
116
|
-
material.uniforms.lut3d.value = null;
|
|
117
67
|
material.uniforms.lut.value = null;
|
|
118
68
|
|
|
119
69
|
if ( v ) {
|
|
120
70
|
|
|
121
|
-
const is3dTextureDefine = v.isData3DTexture ? 1 : 0;
|
|
122
|
-
if ( is3dTextureDefine !== material.defines.USE_3DTEXTURE ) {
|
|
123
|
-
|
|
124
|
-
material.defines.USE_3DTEXTURE = is3dTextureDefine;
|
|
125
|
-
material.needsUpdate = true;
|
|
126
|
-
|
|
127
|
-
}
|
|
128
|
-
|
|
129
71
|
material.uniforms.lutSize.value = v.image.width;
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
material.uniforms.lut3d.value = v;
|
|
133
|
-
|
|
134
|
-
} else {
|
|
135
|
-
|
|
136
|
-
material.uniforms.lut.value = v;
|
|
137
|
-
|
|
138
|
-
}
|
|
72
|
+
material.uniforms.lut.value = v;
|
|
139
73
|
|
|
140
74
|
}
|
|
141
75
|
|
|
@@ -145,7 +79,7 @@ class LUTPass extends ShaderPass {
|
|
|
145
79
|
|
|
146
80
|
get lut() {
|
|
147
81
|
|
|
148
|
-
return this.material.uniforms.lut.value
|
|
82
|
+
return this.material.uniforms.lut.value;
|
|
149
83
|
|
|
150
84
|
}
|
|
151
85
|
|
|
@@ -81,7 +81,6 @@ class SAOPass extends Pass {
|
|
|
81
81
|
vertexShader: SAOShader.vertexShader,
|
|
82
82
|
uniforms: UniformsUtils.clone( SAOShader.uniforms )
|
|
83
83
|
} );
|
|
84
|
-
this.saoMaterial.extensions.derivatives = true;
|
|
85
84
|
this.saoMaterial.defines[ 'PERSPECTIVE_CAMERA' ] = this.camera.isPerspectiveCamera ? 1 : 0;
|
|
86
85
|
this.saoMaterial.uniforms[ 'tDepth' ].value = depthTexture;
|
|
87
86
|
this.saoMaterial.uniforms[ 'tNormal' ].value = this.normalRenderTarget.texture;
|
|
@@ -13,7 +13,6 @@ import {
|
|
|
13
13
|
NearestFilter,
|
|
14
14
|
NoBlending,
|
|
15
15
|
RedFormat,
|
|
16
|
-
LuminanceFormat,
|
|
17
16
|
DepthStencilFormat,
|
|
18
17
|
UnsignedInt248Type,
|
|
19
18
|
RepeatWrapping,
|
|
@@ -177,8 +176,6 @@ class SSAOPass extends Pass {
|
|
|
177
176
|
|
|
178
177
|
render( renderer, writeBuffer, readBuffer /*, deltaTime, maskActive */ ) {
|
|
179
178
|
|
|
180
|
-
if ( renderer.capabilities.isWebGL2 === false ) this.noiseTexture.format = LuminanceFormat;
|
|
181
|
-
|
|
182
179
|
// render normals and depth (honor only meshes, points and lines do not contribute to SSAO)
|
|
183
180
|
|
|
184
181
|
this.overrideVisibility();
|
|
@@ -18,6 +18,8 @@ class Animation {
|
|
|
18
18
|
|
|
19
19
|
this.requestId = self.requestAnimationFrame( update );
|
|
20
20
|
|
|
21
|
+
if ( this.info.autoReset === true ) this.info.reset();
|
|
22
|
+
|
|
21
23
|
this.nodes.nodeFrame.update();
|
|
22
24
|
|
|
23
25
|
this.info.frame = this.nodes.nodeFrame.frameId;
|
|
@@ -33,6 +35,7 @@ class Animation {
|
|
|
33
35
|
dispose() {
|
|
34
36
|
|
|
35
37
|
self.cancelAnimationFrame( this.requestId );
|
|
38
|
+
this.requestId = null;
|
|
36
39
|
|
|
37
40
|
}
|
|
38
41
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import DataMap from './DataMap.js';
|
|
2
2
|
import Color4 from './Color4.js';
|
|
3
3
|
import { Mesh, SphereGeometry, BackSide } from 'three';
|
|
4
|
-
import { vec4, context, normalWorld, backgroundBlurriness, backgroundIntensity, NodeMaterial, modelViewProjection
|
|
4
|
+
import { vec4, context, normalWorld, backgroundBlurriness, backgroundIntensity, NodeMaterial, modelViewProjection } from '../../nodes/Nodes.js';
|
|
5
5
|
|
|
6
6
|
const _clearColor = new Color4();
|
|
7
7
|
|
|
@@ -50,11 +50,11 @@ class Background extends DataMap {
|
|
|
50
50
|
|
|
51
51
|
if ( backgroundMesh === undefined ) {
|
|
52
52
|
|
|
53
|
-
const backgroundMeshNode = context( vec4( backgroundNode ), {
|
|
53
|
+
const backgroundMeshNode = context( vec4( backgroundNode ).mul( backgroundIntensity ), {
|
|
54
54
|
// @TODO: Add Texture2D support using node context
|
|
55
55
|
getUV: () => normalWorld,
|
|
56
|
-
getTextureLevel: (
|
|
57
|
-
} )
|
|
56
|
+
getTextureLevel: () => backgroundBlurriness
|
|
57
|
+
} );
|
|
58
58
|
|
|
59
59
|
let viewProj = modelViewProjection();
|
|
60
60
|
viewProj = viewProj.setZ( viewProj.w );
|
|
@@ -83,7 +83,7 @@ class Background extends DataMap {
|
|
|
83
83
|
|
|
84
84
|
if ( sceneData.backgroundCacheKey !== backgroundCacheKey ) {
|
|
85
85
|
|
|
86
|
-
sceneData.backgroundMeshNode.node = vec4( backgroundNode );
|
|
86
|
+
sceneData.backgroundMeshNode.node = vec4( backgroundNode ).mul( backgroundIntensity );
|
|
87
87
|
|
|
88
88
|
backgroundMesh.material.needsUpdate = true;
|
|
89
89
|
|
|
@@ -12,12 +12,14 @@ class Info {
|
|
|
12
12
|
drawCalls: 0,
|
|
13
13
|
triangles: 0,
|
|
14
14
|
points: 0,
|
|
15
|
-
lines: 0
|
|
15
|
+
lines: 0,
|
|
16
|
+
timestamp: 0
|
|
16
17
|
};
|
|
17
18
|
|
|
18
19
|
this.compute = {
|
|
19
20
|
calls: 0,
|
|
20
|
-
computeCalls: 0
|
|
21
|
+
computeCalls: 0,
|
|
22
|
+
timestamp: 0
|
|
21
23
|
};
|
|
22
24
|
|
|
23
25
|
this.memory = {
|
|
@@ -25,11 +27,6 @@ class Info {
|
|
|
25
27
|
textures: 0
|
|
26
28
|
};
|
|
27
29
|
|
|
28
|
-
this.timestamp = {
|
|
29
|
-
compute: 0,
|
|
30
|
-
render: 0
|
|
31
|
-
};
|
|
32
|
-
|
|
33
30
|
}
|
|
34
31
|
|
|
35
32
|
update( object, count, instanceCount ) {
|
|
@@ -62,26 +59,21 @@ class Info {
|
|
|
62
59
|
|
|
63
60
|
updateTimestamp( type, time ) {
|
|
64
61
|
|
|
65
|
-
this
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
resetCompute() {
|
|
70
|
-
|
|
71
|
-
this.compute.computeCalls = 0;
|
|
72
|
-
|
|
73
|
-
this.timestamp.compute = 0;
|
|
62
|
+
this[ type ].timestamp += time;
|
|
74
63
|
|
|
75
64
|
}
|
|
76
65
|
|
|
77
66
|
reset() {
|
|
78
67
|
|
|
79
68
|
this.render.drawCalls = 0;
|
|
69
|
+
this.compute.computeCalls = 0;
|
|
70
|
+
|
|
80
71
|
this.render.triangles = 0;
|
|
81
72
|
this.render.points = 0;
|
|
82
73
|
this.render.lines = 0;
|
|
83
74
|
|
|
84
|
-
this.timestamp
|
|
75
|
+
this.render.timestamp = 0;
|
|
76
|
+
this.compute.timestamp = 0;
|
|
85
77
|
|
|
86
78
|
}
|
|
87
79
|
|
|
@@ -94,8 +86,8 @@ class Info {
|
|
|
94
86
|
this.render.calls = 0;
|
|
95
87
|
this.compute.calls = 0;
|
|
96
88
|
|
|
97
|
-
this.timestamp
|
|
98
|
-
this.timestamp
|
|
89
|
+
this.render.timestamp = 0;
|
|
90
|
+
this.compute.timestamp = 0;
|
|
99
91
|
this.memory.geometries = 0;
|
|
100
92
|
this.memory.textures = 0;
|
|
101
93
|
|