super-three 0.169.1 → 0.170.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 +974 -562
- package/build/three.module.js +975 -559
- package/build/three.module.min.js +1 -1
- package/build/three.webgpu.js +8398 -9842
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +8398 -9842
- package/build/three.webgpu.nodes.min.js +1 -1
- package/examples/jsm/Addons.js +3 -3
- package/examples/jsm/animation/MMDAnimationHelper.js +2 -0
- package/examples/jsm/animation/MMDPhysics.js +2 -0
- package/examples/jsm/controls/TransformControls.js +22 -6
- package/examples/jsm/csm/CSM.js +2 -2
- package/examples/jsm/csm/CSMFrustum.js +7 -4
- package/examples/jsm/csm/CSMHelper.js +2 -0
- package/examples/jsm/csm/CSMShadowNode.js +435 -0
- package/examples/jsm/curves/NURBSCurve.js +34 -3
- package/examples/jsm/exporters/GLTFExporter.js +138 -71
- package/examples/jsm/exporters/KTX2Exporter.js +35 -12
- package/examples/jsm/exporters/MMDExporter.js +6 -0
- package/examples/jsm/exporters/USDZExporter.js +21 -3
- package/examples/jsm/geometries/DecalGeometry.js +65 -20
- package/examples/jsm/geometries/InstancedPointsGeometry.js +2 -0
- package/examples/jsm/helpers/TextureHelperGPU.js +175 -0
- package/examples/jsm/interactive/HTMLMesh.js +1 -0
- package/examples/jsm/lighting/TiledLighting.js +18 -0
- package/examples/jsm/lights/RectAreaLightTexturesLib.js +1 -1
- package/examples/jsm/lines/LineMaterial.js +7 -2
- package/examples/jsm/lines/LineSegmentsGeometry.js +2 -0
- package/examples/jsm/lines/webgpu/LineSegments2.js +0 -15
- package/examples/jsm/lines/webgpu/Wireframe.js +56 -0
- package/examples/jsm/loaders/3DMLoader.js +1 -0
- package/examples/jsm/loaders/3MFLoader.js +91 -0
- package/examples/jsm/loaders/FBXLoader.js +12 -2
- package/examples/jsm/loaders/GLTFLoader.js +2 -0
- package/examples/jsm/loaders/KTX2Loader.js +140 -49
- package/examples/jsm/loaders/LDrawLoader.js +22 -136
- package/examples/jsm/loaders/LottieLoader.js +1 -0
- package/examples/jsm/loaders/MMDLoader.js +9 -2
- package/examples/jsm/materials/LDrawConditionalLineMaterial.js +143 -0
- package/examples/jsm/materials/LDrawConditionalLineNodeMaterial.js +114 -0
- package/examples/jsm/materials/MeshGouraudMaterial.js +6 -2
- package/examples/jsm/math/ColorSpaces.js +76 -0
- package/examples/jsm/misc/ProgressiveLightMap.js +52 -40
- package/examples/jsm/misc/ProgressiveLightMapGPU.js +293 -0
- package/examples/jsm/misc/VolumeSlice.js +1 -0
- package/examples/jsm/objects/WaterMesh.js +8 -8
- package/examples/jsm/postprocessing/AfterimagePass.js +14 -3
- package/examples/jsm/postprocessing/SSRPass.js +6 -0
- package/examples/jsm/renderers/CSS2DRenderer.js +6 -3
- package/examples/jsm/renderers/CSS3DRenderer.js +7 -4
- package/examples/jsm/shaders/FXAAShader.js +225 -224
- package/examples/jsm/transpiler/ShaderToyDecoder.js +1 -1
- package/{src/nodes → examples/jsm/tsl}/display/AfterImageNode.js +17 -20
- package/{src/nodes → examples/jsm/tsl}/display/AnaglyphPassNode.js +2 -6
- package/{src/nodes → examples/jsm/tsl}/display/AnamorphicNode.js +12 -18
- package/{src/nodes → examples/jsm/tsl}/display/BleachBypass.js +1 -3
- package/{src/nodes → examples/jsm/tsl}/display/BloomNode.js +11 -40
- package/{src/nodes → examples/jsm/tsl}/display/DenoiseNode.js +18 -41
- package/{src/nodes → examples/jsm/tsl}/display/DepthOfFieldNode.js +2 -8
- package/{src/nodes → examples/jsm/tsl}/display/DotScreenNode.js +2 -9
- package/examples/jsm/tsl/display/FXAANode.js +316 -0
- package/{src/nodes → examples/jsm/tsl}/display/FilmNode.js +2 -6
- package/{src/nodes → examples/jsm/tsl}/display/GTAONode.js +30 -70
- package/{src/nodes → examples/jsm/tsl}/display/GaussianBlurNode.js +74 -36
- package/examples/jsm/tsl/display/LensflareNode.js +161 -0
- package/{src/nodes → examples/jsm/tsl}/display/Lut3DNode.js +1 -4
- package/{src/nodes → examples/jsm/tsl}/display/MotionBlur.js +2 -3
- package/examples/jsm/tsl/display/OutlineNode.js +434 -0
- package/{src/nodes → examples/jsm/tsl}/display/ParallaxBarrierPassNode.js +1 -5
- package/{src/nodes → examples/jsm/tsl}/display/PixelationPassNode.js +3 -15
- package/{src/nodes → examples/jsm/tsl}/display/RGBShiftNode.js +1 -6
- package/examples/jsm/tsl/display/SMAANode.js +620 -0
- package/{src/nodes → examples/jsm/tsl}/display/SSAAPassNode.js +10 -25
- package/examples/jsm/tsl/display/SSRNode.js +343 -0
- package/{src/nodes → examples/jsm/tsl}/display/Sepia.js +1 -2
- package/{src/nodes → examples/jsm/tsl}/display/SobelOperatorNode.js +3 -11
- package/{src/nodes → examples/jsm/tsl}/display/StereoCompositePassNode.js +9 -11
- package/{src/nodes → examples/jsm/tsl}/display/StereoPassNode.js +10 -11
- package/examples/jsm/tsl/display/TRAAPassNode.js +355 -0
- package/{src/nodes → examples/jsm/tsl}/display/TransitionNode.js +1 -6
- package/examples/jsm/tsl/display/hashBlur.js +24 -0
- package/examples/jsm/tsl/lighting/TiledLightsNode.js +392 -0
- package/examples/jsm/utils/{TextureUtilsGPU.js → WebGPUTextureUtils.js} +2 -1
- package/examples/jsm/webxr/OculusHandPointerModel.js +21 -21
- package/examples/jsm/webxr/Text2D.js +6 -6
- package/package.json +2 -2
- package/src/Three.WebGPU.Nodes.js +4 -0
- package/src/Three.WebGPU.js +4 -0
- package/src/constants.js +1 -6
- package/src/core/BufferGeometry.js +44 -6
- package/src/geometries/CylinderGeometry.js +2 -2
- package/src/materials/LineBasicMaterial.js +6 -2
- package/src/materials/LineDashedMaterial.js +6 -2
- package/src/materials/Material.js +14 -1
- package/src/materials/MeshBasicMaterial.js +6 -2
- package/src/materials/MeshDepthMaterial.js +6 -2
- package/src/materials/MeshDistanceMaterial.js +6 -2
- package/src/materials/MeshLambertMaterial.js +6 -2
- package/src/materials/MeshMatcapMaterial.js +6 -2
- package/src/materials/MeshNormalMaterial.js +6 -2
- package/src/materials/MeshPhongMaterial.js +6 -2
- package/src/materials/MeshPhysicalMaterial.js +6 -2
- package/src/materials/MeshStandardMaterial.js +6 -2
- package/src/materials/MeshToonMaterial.js +6 -2
- package/src/materials/PointsMaterial.js +6 -2
- package/src/materials/RawShaderMaterial.js +6 -2
- package/src/materials/ShaderMaterial.js +6 -2
- package/src/materials/ShadowMaterial.js +6 -2
- package/src/materials/SpriteMaterial.js +6 -2
- package/src/materials/nodes/NodeMaterial.js +31 -9
- package/src/materials/nodes/SpriteNodeMaterial.js +11 -2
- package/src/materials/nodes/manager/NodeMaterialObserver.js +111 -2
- package/src/math/ColorManagement.js +118 -85
- package/src/math/Vector4.js +11 -0
- package/src/nodes/Nodes.js +1 -21
- package/src/nodes/TSL.js +6 -24
- package/src/nodes/accessors/Camera.js +0 -1
- package/src/nodes/accessors/SceneNode.js +35 -1
- package/src/nodes/accessors/StorageBufferNode.js +32 -10
- package/src/nodes/accessors/VelocityNode.js +13 -3
- package/src/nodes/code/FunctionCallNode.js +16 -5
- package/src/nodes/code/ScriptableNode.js +4 -4
- package/src/nodes/core/Node.js +1 -0
- package/src/nodes/core/NodeBuilder.js +29 -5
- package/src/nodes/core/VarNode.js +15 -3
- package/src/nodes/display/ColorAdjustment.js +53 -4
- package/src/nodes/display/ColorSpaceFunctions.js +5 -5
- package/src/nodes/display/ColorSpaceNode.js +27 -39
- package/src/nodes/display/PassNode.js +6 -4
- package/src/nodes/display/ToneMappingNode.js +1 -1
- package/src/nodes/display/ViewportDepthNode.js +33 -1
- package/src/nodes/functions/PhysicalLightingModel.js +21 -15
- package/src/nodes/functions/material/getAlphaHashThreshold.js +64 -0
- package/src/nodes/functions/material/getGeometryRoughness.js +8 -2
- package/src/nodes/functions/material/getParallaxCorrectNormal.js +22 -0
- package/src/nodes/gpgpu/ComputeNode.js +9 -1
- package/src/nodes/lighting/AnalyticLightNode.js +12 -416
- package/src/nodes/lighting/LightsNode.js +24 -12
- package/src/nodes/lighting/PointLightNode.js +36 -26
- package/src/nodes/lighting/RectAreaLightNode.js +3 -0
- package/src/nodes/lighting/ShadowNode.js +484 -0
- package/src/nodes/utils/LoopNode.js +2 -2
- package/src/nodes/utils/Oscillators.js +6 -0
- package/src/nodes/utils/PostProcessingUtils.js +89 -0
- package/src/nodes/utils/ReflectorNode.js +101 -15
- package/src/nodes/utils/Timer.js +29 -0
- package/src/objects/BatchedMesh.js +458 -241
- package/src/renderers/WebGLRenderer.js +120 -117
- package/src/renderers/common/Attributes.js +4 -0
- package/src/renderers/common/Backend.js +2 -0
- package/src/renderers/common/Background.js +14 -4
- package/src/renderers/common/Bindings.js +3 -2
- package/src/renderers/common/Constants.js +2 -1
- package/src/renderers/common/Geometries.js +20 -0
- package/src/renderers/common/IndirectStorageBufferAttribute.js +15 -0
- package/src/renderers/common/Lighting.js +45 -0
- package/src/renderers/common/PostProcessingUtils.js +86 -0
- package/src/renderers/common/RenderList.js +39 -11
- package/src/renderers/common/RenderLists.js +4 -2
- package/src/renderers/common/RenderObject.js +18 -1
- package/src/renderers/common/Renderer.js +165 -26
- package/src/renderers/common/Textures.js +30 -14
- package/src/renderers/common/nodes/NodeLibrary.js +1 -14
- package/src/renderers/common/nodes/Nodes.js +2 -2
- package/src/renderers/shaders/ShaderChunk/colorspace_pars_fragment.glsl.js +4 -24
- package/src/renderers/shaders/ShaderChunk/emissivemap_fragment.glsl.js +8 -0
- package/src/renderers/shaders/ShaderChunk/map_fragment.glsl.js +2 -2
- package/src/renderers/webgl/WebGLBufferRenderer.js +2 -6
- package/src/renderers/webgl/WebGLCapabilities.js +0 -7
- package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +2 -6
- package/src/renderers/webgl/WebGLProgram.js +24 -28
- package/src/renderers/webgl/WebGLPrograms.js +5 -2
- package/src/renderers/webgl/WebGLState.js +37 -1
- package/src/renderers/webgl/WebGLTextures.js +29 -12
- package/src/renderers/webgl-fallback/WebGLBackend.js +98 -31
- package/src/renderers/webgl-fallback/WebGLBufferRenderer.js +2 -7
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +33 -8
- package/src/renderers/webgpu/WebGPUBackend.js +105 -25
- package/src/renderers/webgpu/WebGPURenderer.Nodes.js +1 -1
- package/src/renderers/webgpu/WebGPURenderer.js +1 -1
- package/src/renderers/webgpu/nodes/BasicNodeLibrary.js +0 -8
- package/src/renderers/webgpu/nodes/StandardNodeLibrary.js +0 -8
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +10 -20
- package/src/renderers/webgpu/nodes/WGSLNodeFunction.js +12 -4
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +29 -9
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +24 -6
- package/src/renderers/webgpu/utils/WebGPUUtils.js +0 -1
- package/src/renderers/webxr/WebXRManager.js +4 -4
- package/examples/jsm/cameras/CinematicCamera.js +0 -208
- package/src/nodes/display/FXAANode.js +0 -332
- package/src/nodes/utils/OscNode.js +0 -85
- package/src/nodes/utils/TimerNode.js +0 -97
- /package/examples/jsm/utils/{TextureUtils.js → WebGLTextureUtils.js} +0 -0
|
@@ -57,19 +57,8 @@ const wgslTypeLib = {
|
|
|
57
57
|
bvec4: 'vec4<bool>',
|
|
58
58
|
|
|
59
59
|
mat2: 'mat2x2<f32>',
|
|
60
|
-
imat2: 'mat2x2<i32>',
|
|
61
|
-
umat2: 'mat2x2<u32>',
|
|
62
|
-
bmat2: 'mat2x2<bool>',
|
|
63
|
-
|
|
64
60
|
mat3: 'mat3x3<f32>',
|
|
65
|
-
|
|
66
|
-
umat3: 'mat3x3<u32>',
|
|
67
|
-
bmat3: 'mat3x3<bool>',
|
|
68
|
-
|
|
69
|
-
mat4: 'mat4x4<f32>',
|
|
70
|
-
imat4: 'mat4x4<i32>',
|
|
71
|
-
umat4: 'mat4x4<u32>',
|
|
72
|
-
bmat4: 'mat4x4<bool>'
|
|
61
|
+
mat4: 'mat4x4<f32>'
|
|
73
62
|
};
|
|
74
63
|
|
|
75
64
|
const wgslPolyfill = {
|
|
@@ -82,7 +71,7 @@ const wgslPolyfill = {
|
|
|
82
71
|
equals_bvec2: new CodeNode( 'fn tsl_equals_bvec2( a : vec2f, b : vec2f ) -> vec2<bool> { return vec2<bool>( a.x == b.x, a.y == b.y ); }' ),
|
|
83
72
|
equals_bvec3: new CodeNode( 'fn tsl_equals_bvec3( a : vec3f, b : vec3f ) -> vec3<bool> { return vec3<bool>( a.x == b.x, a.y == b.y, a.z == b.z ); }' ),
|
|
84
73
|
equals_bvec4: new CodeNode( 'fn tsl_equals_bvec4( a : vec4f, b : vec4f ) -> vec4<bool> { return vec4<bool>( a.x == b.x, a.y == b.y, a.z == b.z, a.w == b.w ); }' ),
|
|
85
|
-
repeatWrapping: new CodeNode(
|
|
74
|
+
repeatWrapping: new CodeNode( /* wgsl */`
|
|
86
75
|
fn tsl_repeatWrapping( uv : vec2<f32>, dimension : vec2<u32> ) -> vec2<u32> {
|
|
87
76
|
|
|
88
77
|
let uvScaled = vec2<u32>( uv * vec2<f32>( dimension ) );
|
|
@@ -91,7 +80,7 @@ fn tsl_repeatWrapping( uv : vec2<f32>, dimension : vec2<u32> ) -> vec2<u32> {
|
|
|
91
80
|
|
|
92
81
|
}
|
|
93
82
|
` ),
|
|
94
|
-
biquadraticTexture: new CodeNode(
|
|
83
|
+
biquadraticTexture: new CodeNode( /* wgsl */`
|
|
95
84
|
fn tsl_biquadraticTexture( map : texture_2d<f32>, coord : vec2f, level : i32 ) -> vec4f {
|
|
96
85
|
|
|
97
86
|
let iRes = vec2i( textureDimensions( map, level ) );
|
|
@@ -152,7 +141,7 @@ if ( /Windows/g.test( navigator.userAgent ) ) {
|
|
|
152
141
|
|
|
153
142
|
let diagnostics = '';
|
|
154
143
|
|
|
155
|
-
if ( /Firefox/g.test( navigator.userAgent ) !== true ) {
|
|
144
|
+
if ( /Firefox|Deno/g.test( navigator.userAgent ) !== true ) {
|
|
156
145
|
|
|
157
146
|
diagnostics += 'diagnostic( off, derivative_uniformity );\n';
|
|
158
147
|
|
|
@@ -386,7 +375,7 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
386
375
|
|
|
387
376
|
return name;
|
|
388
377
|
|
|
389
|
-
} else if ( type === 'buffer' || type === 'storageBuffer' ) {
|
|
378
|
+
} else if ( type === 'buffer' || type === 'storageBuffer' || type === 'indirectStorageBuffer' ) {
|
|
390
379
|
|
|
391
380
|
return `NodeBuffer_${ node.id }.${name}`;
|
|
392
381
|
|
|
@@ -525,9 +514,10 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
525
514
|
|
|
526
515
|
}
|
|
527
516
|
|
|
528
|
-
} else if ( type === 'buffer' || type === 'storageBuffer' ) {
|
|
517
|
+
} else if ( type === 'buffer' || type === 'storageBuffer' || type === 'indirectStorageBuffer' ) {
|
|
518
|
+
|
|
519
|
+
const bufferClass = type === 'buffer' ? NodeUniformBuffer : NodeStorageBuffer;
|
|
529
520
|
|
|
530
|
-
const bufferClass = type === 'storageBuffer' ? NodeStorageBuffer : NodeUniformBuffer;
|
|
531
521
|
const buffer = new bufferClass( node, group );
|
|
532
522
|
buffer.setVisibility( gpuShaderStageLib[ shaderStage ] );
|
|
533
523
|
|
|
@@ -1067,13 +1057,13 @@ ${ flowData.code }
|
|
|
1067
1057
|
|
|
1068
1058
|
bindingSnippets.push( `@binding( ${ uniformIndexes.binding ++ } ) @group( ${ uniformIndexes.group } ) var ${ uniform.name } : ${ textureType };` );
|
|
1069
1059
|
|
|
1070
|
-
} else if ( uniform.type === 'buffer' || uniform.type === 'storageBuffer' ) {
|
|
1060
|
+
} else if ( uniform.type === 'buffer' || uniform.type === 'storageBuffer' || uniform.type === 'indirectStorageBuffer' ) {
|
|
1071
1061
|
|
|
1072
1062
|
const bufferNode = uniform.node;
|
|
1073
1063
|
const bufferType = this.getType( bufferNode.bufferType );
|
|
1074
1064
|
const bufferCount = bufferNode.bufferCount;
|
|
1075
1065
|
|
|
1076
|
-
const bufferCountSnippet = bufferCount > 0 ? ', ' + bufferCount : '';
|
|
1066
|
+
const bufferCountSnippet = bufferCount > 0 && uniform.type === 'buffer' ? ', ' + bufferCount : '';
|
|
1077
1067
|
const bufferTypeSnippet = bufferNode.isAtomic ? `atomic<${bufferType}>` : `${bufferType}`;
|
|
1078
1068
|
const bufferSnippet = `\t${ uniform.name } : array< ${ bufferTypeSnippet }${ bufferCountSnippet } >\n`;
|
|
1079
1069
|
const bufferAccessMode = bufferNode.isStorageBufferNode ? `storage, ${ this.getStorageAccess( bufferNode ) }` : 'uniform';
|
|
@@ -97,13 +97,21 @@ const parse = ( source ) => {
|
|
|
97
97
|
|
|
98
98
|
let resolvedType = type;
|
|
99
99
|
|
|
100
|
-
if ( resolvedType.startsWith( '
|
|
100
|
+
if ( resolvedType.startsWith( 'ptr' ) ) {
|
|
101
101
|
|
|
102
|
-
resolvedType =
|
|
102
|
+
resolvedType = 'pointer';
|
|
103
103
|
|
|
104
|
-
}
|
|
104
|
+
} else {
|
|
105
|
+
|
|
106
|
+
if ( resolvedType.startsWith( 'texture' ) ) {
|
|
107
|
+
|
|
108
|
+
resolvedType = type.split( '<' )[ 0 ];
|
|
105
109
|
|
|
106
|
-
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
resolvedType = wgslTypeLib[ resolvedType ];
|
|
113
|
+
|
|
114
|
+
}
|
|
107
115
|
|
|
108
116
|
inputs.push( new NodeFunctionInput( resolvedType, name ) );
|
|
109
117
|
|
|
@@ -127,15 +127,6 @@ class WebGPUPipelineUtils {
|
|
|
127
127
|
vertex: Object.assign( {}, vertexModule, { buffers: vertexBuffers } ),
|
|
128
128
|
fragment: Object.assign( {}, fragmentModule, { targets } ),
|
|
129
129
|
primitive: primitiveState,
|
|
130
|
-
depthStencil: {
|
|
131
|
-
format: depthStencilFormat,
|
|
132
|
-
depthWriteEnabled: material.depthWrite,
|
|
133
|
-
depthCompare: depthCompare,
|
|
134
|
-
stencilFront: stencilFront,
|
|
135
|
-
stencilBack: {}, // three.js does not provide an API to configure the back function (gl.stencilFuncSeparate() was never used)
|
|
136
|
-
stencilReadMask: material.stencilFuncMask,
|
|
137
|
-
stencilWriteMask: material.stencilWriteMask
|
|
138
|
-
},
|
|
139
130
|
multisample: {
|
|
140
131
|
count: sampleCount,
|
|
141
132
|
alphaToCoverageEnabled: material.alphaToCoverage && sampleCount > 1
|
|
@@ -145,6 +136,35 @@ class WebGPUPipelineUtils {
|
|
|
145
136
|
} )
|
|
146
137
|
};
|
|
147
138
|
|
|
139
|
+
|
|
140
|
+
const depthStencil = {};
|
|
141
|
+
const renderDepth = renderObject.context.depth;
|
|
142
|
+
const renderStencil = renderObject.context.stencil;
|
|
143
|
+
|
|
144
|
+
if ( renderDepth === true || renderStencil === true ) {
|
|
145
|
+
|
|
146
|
+
if ( renderDepth === true ) {
|
|
147
|
+
|
|
148
|
+
depthStencil.format = depthStencilFormat;
|
|
149
|
+
depthStencil.depthWriteEnabled = material.depthWrite;
|
|
150
|
+
depthStencil.depthCompare = depthCompare;
|
|
151
|
+
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
if ( renderStencil === true ) {
|
|
155
|
+
|
|
156
|
+
depthStencil.stencilFront = stencilFront;
|
|
157
|
+
depthStencil.stencilBack = {}; // three.js does not provide an API to configure the back function (gl.stencilFuncSeparate() was never used)
|
|
158
|
+
depthStencil.stencilReadMask = material.stencilFuncMask;
|
|
159
|
+
depthStencil.stencilWriteMask = material.stencilWriteMask;
|
|
160
|
+
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
pipelineDescriptor.depthStencil = depthStencil;
|
|
164
|
+
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
|
|
148
168
|
if ( promises === null ) {
|
|
149
169
|
|
|
150
170
|
pipelineData.pipeline = device.createRenderPipeline( pipelineDescriptor );
|
|
@@ -65,9 +65,17 @@ class WebGPUTextureUtils {
|
|
|
65
65
|
magFilter: this._convertFilterMode( texture.magFilter ),
|
|
66
66
|
minFilter: this._convertFilterMode( texture.minFilter ),
|
|
67
67
|
mipmapFilter: this._convertFilterMode( texture.minFilter ),
|
|
68
|
-
maxAnisotropy:
|
|
68
|
+
maxAnisotropy: 1
|
|
69
69
|
};
|
|
70
70
|
|
|
71
|
+
// anisotropy can only be used when all filter modes are set to linear.
|
|
72
|
+
|
|
73
|
+
if ( samplerDescriptorGPU.magFilter === GPUFilterMode.Linear && samplerDescriptorGPU.minFilter === GPUFilterMode.Linear && samplerDescriptorGPU.mipmapFilter === GPUFilterMode.Linear ) {
|
|
74
|
+
|
|
75
|
+
samplerDescriptorGPU.maxAnisotropy = texture.anisotropy;
|
|
76
|
+
|
|
77
|
+
}
|
|
78
|
+
|
|
71
79
|
if ( texture.isDepthTexture && texture.compareFunction !== null ) {
|
|
72
80
|
|
|
73
81
|
samplerDescriptorGPU.compare = _compareToWebGPU[ texture.compareFunction ];
|
|
@@ -119,6 +127,20 @@ class WebGPUTextureUtils {
|
|
|
119
127
|
|
|
120
128
|
const { width, height, depth, levels } = options;
|
|
121
129
|
|
|
130
|
+
if ( texture.isFramebufferTexture ) {
|
|
131
|
+
|
|
132
|
+
if ( options.renderTarget ) {
|
|
133
|
+
|
|
134
|
+
options.format = this.backend.utils.getCurrentColorFormat( options.renderTarget );
|
|
135
|
+
|
|
136
|
+
} else {
|
|
137
|
+
|
|
138
|
+
options.format = this.backend.utils.getPreferredCanvasFormat();
|
|
139
|
+
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
}
|
|
143
|
+
|
|
122
144
|
const dimension = this._getDimension( texture );
|
|
123
145
|
const format = texture.internalFormat || options.format || getFormat( texture, backend.device );
|
|
124
146
|
|
|
@@ -850,11 +872,7 @@ export function getFormat( texture, device = null ) {
|
|
|
850
872
|
|
|
851
873
|
let formatGPU;
|
|
852
874
|
|
|
853
|
-
if ( texture.
|
|
854
|
-
|
|
855
|
-
formatGPU = GPUTextureFormat.BGRA8Unorm;
|
|
856
|
-
|
|
857
|
-
} else if ( texture.isCompressedTexture === true || texture.isCompressedArrayTexture === true ) {
|
|
875
|
+
if ( texture.isCompressedTexture === true || texture.isCompressedArrayTexture === true ) {
|
|
858
876
|
|
|
859
877
|
switch ( format ) {
|
|
860
878
|
|
|
@@ -55,18 +55,14 @@ class WebXRManager extends EventDispatcher {
|
|
|
55
55
|
//
|
|
56
56
|
|
|
57
57
|
const cameraL = new PerspectiveCamera();
|
|
58
|
-
cameraL.layers.enable( 1 );
|
|
59
58
|
cameraL.viewport = new Vector4();
|
|
60
59
|
|
|
61
60
|
const cameraR = new PerspectiveCamera();
|
|
62
|
-
cameraR.layers.enable( 2 );
|
|
63
61
|
cameraR.viewport = new Vector4();
|
|
64
62
|
|
|
65
63
|
const cameras = [ cameraL, cameraR ];
|
|
66
64
|
|
|
67
65
|
const cameraXR = new ArrayCamera();
|
|
68
|
-
cameraXR.layers.enable( 1 );
|
|
69
|
-
cameraXR.layers.enable( 2 );
|
|
70
66
|
|
|
71
67
|
let _currentDepthNear = null;
|
|
72
68
|
let _currentDepthFar = null;
|
|
@@ -632,6 +628,10 @@ class WebXRManager extends EventDispatcher {
|
|
|
632
628
|
|
|
633
629
|
}
|
|
634
630
|
|
|
631
|
+
cameraL.layers.mask = camera.layers.mask | 0b010;
|
|
632
|
+
cameraR.layers.mask = camera.layers.mask | 0b100;
|
|
633
|
+
cameraXR.layers.mask = cameraL.layers.mask | cameraR.layers.mask;
|
|
634
|
+
|
|
635
635
|
const cameras = cameraXR.cameras;
|
|
636
636
|
var object = poseTarget || camera;
|
|
637
637
|
const parent = object.parent;
|
|
@@ -1,208 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Mesh,
|
|
3
|
-
OrthographicCamera,
|
|
4
|
-
PerspectiveCamera,
|
|
5
|
-
PlaneGeometry,
|
|
6
|
-
Scene,
|
|
7
|
-
ShaderMaterial,
|
|
8
|
-
UniformsUtils,
|
|
9
|
-
WebGLRenderTarget
|
|
10
|
-
} from 'three';
|
|
11
|
-
|
|
12
|
-
import { BokehShader, BokehDepthShader } from '../shaders/BokehShader2.js';
|
|
13
|
-
|
|
14
|
-
class CinematicCamera extends PerspectiveCamera {
|
|
15
|
-
|
|
16
|
-
constructor( fov, aspect, near, far ) {
|
|
17
|
-
|
|
18
|
-
super( fov, aspect, near, far );
|
|
19
|
-
|
|
20
|
-
this.type = 'CinematicCamera';
|
|
21
|
-
|
|
22
|
-
this.postprocessing = { enabled: true };
|
|
23
|
-
this.shaderSettings = {
|
|
24
|
-
rings: 3,
|
|
25
|
-
samples: 4
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
const depthShader = BokehDepthShader;
|
|
29
|
-
|
|
30
|
-
this.materialDepth = new ShaderMaterial( {
|
|
31
|
-
uniforms: depthShader.uniforms,
|
|
32
|
-
vertexShader: depthShader.vertexShader,
|
|
33
|
-
fragmentShader: depthShader.fragmentShader
|
|
34
|
-
} );
|
|
35
|
-
|
|
36
|
-
this.materialDepth.uniforms[ 'mNear' ].value = near;
|
|
37
|
-
this.materialDepth.uniforms[ 'mFar' ].value = far;
|
|
38
|
-
|
|
39
|
-
// In case of cinematicCamera, having a default lens set is important
|
|
40
|
-
this.setLens();
|
|
41
|
-
|
|
42
|
-
this.initPostProcessing();
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// providing fnumber and coc(Circle of Confusion) as extra arguments
|
|
47
|
-
// In case of cinematicCamera, having a default lens set is important
|
|
48
|
-
// if fnumber and coc are not provided, cinematicCamera tries to act as a basic PerspectiveCamera
|
|
49
|
-
setLens( focalLength = 35, filmGauge = 35, fNumber = 8, coc = 0.019 ) {
|
|
50
|
-
|
|
51
|
-
this.filmGauge = filmGauge;
|
|
52
|
-
|
|
53
|
-
this.setFocalLength( focalLength );
|
|
54
|
-
|
|
55
|
-
this.fNumber = fNumber;
|
|
56
|
-
this.coc = coc;
|
|
57
|
-
|
|
58
|
-
// fNumber is focalLength by aperture
|
|
59
|
-
this.aperture = focalLength / this.fNumber;
|
|
60
|
-
|
|
61
|
-
// hyperFocal is required to calculate depthOfField when a lens tries to focus at a distance with given fNumber and focalLength
|
|
62
|
-
this.hyperFocal = ( focalLength * focalLength ) / ( this.aperture * this.coc );
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
linearize( depth ) {
|
|
67
|
-
|
|
68
|
-
const zfar = this.far;
|
|
69
|
-
const znear = this.near;
|
|
70
|
-
return - zfar * znear / ( depth * ( zfar - znear ) - zfar );
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
smoothstep( near, far, depth ) {
|
|
75
|
-
|
|
76
|
-
const x = this.saturate( ( depth - near ) / ( far - near ) );
|
|
77
|
-
return x * x * ( 3 - 2 * x );
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
saturate( x ) {
|
|
82
|
-
|
|
83
|
-
return Math.max( 0, Math.min( 1, x ) );
|
|
84
|
-
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
// function for focusing at a distance from the camera
|
|
88
|
-
focusAt( focusDistance = 20 ) {
|
|
89
|
-
|
|
90
|
-
const focalLength = this.getFocalLength();
|
|
91
|
-
|
|
92
|
-
// distance from the camera (normal to frustrum) to focus on
|
|
93
|
-
this.focus = focusDistance;
|
|
94
|
-
|
|
95
|
-
// the nearest point from the camera which is in focus (unused)
|
|
96
|
-
this.nearPoint = ( this.hyperFocal * this.focus ) / ( this.hyperFocal + ( this.focus - focalLength ) );
|
|
97
|
-
|
|
98
|
-
// the farthest point from the camera which is in focus (unused)
|
|
99
|
-
this.farPoint = ( this.hyperFocal * this.focus ) / ( this.hyperFocal - ( this.focus - focalLength ) );
|
|
100
|
-
|
|
101
|
-
// the gap or width of the space in which is everything is in focus (unused)
|
|
102
|
-
this.depthOfField = this.farPoint - this.nearPoint;
|
|
103
|
-
|
|
104
|
-
// Considering minimum distance of focus for a standard lens (unused)
|
|
105
|
-
if ( this.depthOfField < 0 ) this.depthOfField = 0;
|
|
106
|
-
|
|
107
|
-
this.sdistance = this.smoothstep( this.near, this.far, this.focus );
|
|
108
|
-
|
|
109
|
-
this.ldistance = this.linearize( 1 - this.sdistance );
|
|
110
|
-
|
|
111
|
-
this.postprocessing.bokeh_uniforms[ 'focalDepth' ].value = this.ldistance;
|
|
112
|
-
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
initPostProcessing() {
|
|
116
|
-
|
|
117
|
-
if ( this.postprocessing.enabled ) {
|
|
118
|
-
|
|
119
|
-
this.postprocessing.scene = new Scene();
|
|
120
|
-
|
|
121
|
-
this.postprocessing.camera = new OrthographicCamera( window.innerWidth / - 2, window.innerWidth / 2, window.innerHeight / 2, window.innerHeight / - 2, - 10000, 10000 );
|
|
122
|
-
|
|
123
|
-
this.postprocessing.scene.add( this.postprocessing.camera );
|
|
124
|
-
|
|
125
|
-
this.postprocessing.rtTextureDepth = new WebGLRenderTarget( window.innerWidth, window.innerHeight );
|
|
126
|
-
this.postprocessing.rtTextureColor = new WebGLRenderTarget( window.innerWidth, window.innerHeight );
|
|
127
|
-
|
|
128
|
-
const bokeh_shader = BokehShader;
|
|
129
|
-
|
|
130
|
-
this.postprocessing.bokeh_uniforms = UniformsUtils.clone( bokeh_shader.uniforms );
|
|
131
|
-
|
|
132
|
-
this.postprocessing.bokeh_uniforms[ 'tColor' ].value = this.postprocessing.rtTextureColor.texture;
|
|
133
|
-
this.postprocessing.bokeh_uniforms[ 'tDepth' ].value = this.postprocessing.rtTextureDepth.texture;
|
|
134
|
-
|
|
135
|
-
this.postprocessing.bokeh_uniforms[ 'manualdof' ].value = 0;
|
|
136
|
-
this.postprocessing.bokeh_uniforms[ 'shaderFocus' ].value = 0;
|
|
137
|
-
|
|
138
|
-
this.postprocessing.bokeh_uniforms[ 'fstop' ].value = 2.8;
|
|
139
|
-
|
|
140
|
-
this.postprocessing.bokeh_uniforms[ 'showFocus' ].value = 1;
|
|
141
|
-
|
|
142
|
-
this.postprocessing.bokeh_uniforms[ 'focalDepth' ].value = 0.1;
|
|
143
|
-
|
|
144
|
-
//console.log( this.postprocessing.bokeh_uniforms[ "focalDepth" ].value );
|
|
145
|
-
|
|
146
|
-
this.postprocessing.bokeh_uniforms[ 'znear' ].value = this.near;
|
|
147
|
-
this.postprocessing.bokeh_uniforms[ 'zfar' ].value = this.near;
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
this.postprocessing.bokeh_uniforms[ 'textureWidth' ].value = window.innerWidth;
|
|
151
|
-
|
|
152
|
-
this.postprocessing.bokeh_uniforms[ 'textureHeight' ].value = window.innerHeight;
|
|
153
|
-
|
|
154
|
-
this.postprocessing.materialBokeh = new ShaderMaterial( {
|
|
155
|
-
uniforms: this.postprocessing.bokeh_uniforms,
|
|
156
|
-
vertexShader: bokeh_shader.vertexShader,
|
|
157
|
-
fragmentShader: bokeh_shader.fragmentShader,
|
|
158
|
-
defines: {
|
|
159
|
-
RINGS: this.shaderSettings.rings,
|
|
160
|
-
SAMPLES: this.shaderSettings.samples,
|
|
161
|
-
DEPTH_PACKING: 1
|
|
162
|
-
}
|
|
163
|
-
} );
|
|
164
|
-
|
|
165
|
-
this.postprocessing.quad = new Mesh( new PlaneGeometry( window.innerWidth, window.innerHeight ), this.postprocessing.materialBokeh );
|
|
166
|
-
this.postprocessing.quad.position.z = - 500;
|
|
167
|
-
this.postprocessing.scene.add( this.postprocessing.quad );
|
|
168
|
-
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
renderCinematic( scene, renderer ) {
|
|
174
|
-
|
|
175
|
-
if ( this.postprocessing.enabled ) {
|
|
176
|
-
|
|
177
|
-
const currentRenderTarget = renderer.getRenderTarget();
|
|
178
|
-
|
|
179
|
-
renderer.clear();
|
|
180
|
-
|
|
181
|
-
// Render scene into texture
|
|
182
|
-
|
|
183
|
-
scene.overrideMaterial = null;
|
|
184
|
-
renderer.setRenderTarget( this.postprocessing.rtTextureColor );
|
|
185
|
-
renderer.clear();
|
|
186
|
-
renderer.render( scene, this );
|
|
187
|
-
|
|
188
|
-
// Render depth into texture
|
|
189
|
-
|
|
190
|
-
scene.overrideMaterial = this.materialDepth;
|
|
191
|
-
renderer.setRenderTarget( this.postprocessing.rtTextureDepth );
|
|
192
|
-
renderer.clear();
|
|
193
|
-
renderer.render( scene, this );
|
|
194
|
-
|
|
195
|
-
// Render bokeh composite
|
|
196
|
-
|
|
197
|
-
renderer.setRenderTarget( null );
|
|
198
|
-
renderer.render( this.postprocessing.scene, this.postprocessing.camera );
|
|
199
|
-
|
|
200
|
-
renderer.setRenderTarget( currentRenderTarget );
|
|
201
|
-
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
export { CinematicCamera };
|