super-three 0.133.2 → 0.135.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.js +619 -538
- package/build/three.min.js +1 -1
- package/build/three.module.js +763 -616
- package/examples/fonts/open-sans/open-sans-v15-cyrillic-ext_greek_greek-ext_cyrillic_latin_latin-ext_vietnamese-regular.woff +0 -0
- package/examples/fonts/open-sans/open-sans-v15-cyrillic-ext_greek_greek-ext_cyrillic_latin_latin-ext_vietnamese-regular.woff2 +0 -0
- package/examples/fonts/open-sans/open-sans.css +9 -0
- package/examples/fonts/tabler-icons/fonts/tabler-icons.eot +0 -0
- package/examples/fonts/tabler-icons/fonts/tabler-icons.ttf +0 -0
- package/examples/fonts/tabler-icons/fonts/tabler-icons.woff +0 -0
- package/examples/fonts/tabler-icons/fonts/tabler-icons.woff2 +0 -0
- package/examples/fonts/tabler-icons/tabler-icons.min.css +4 -0
- package/examples/js/controls/ArcballControls.js +68 -27
- package/examples/js/controls/DragControls.js +7 -0
- package/examples/js/controls/OrbitControls.js +5 -36
- package/examples/js/controls/TrackballControls.js +3 -2
- package/examples/js/csm/CSM.js +2 -2
- package/examples/js/csm/CSMFrustum.js +133 -0
- package/examples/js/exporters/GLTFExporter.js +147 -63
- package/examples/js/exporters/USDZExporter.js +45 -26
- package/examples/js/lines/LineMaterial.js +58 -20
- package/examples/js/lines/LineSegments2.js +29 -24
- package/examples/js/loaders/3DMLoader.js +24 -11
- package/examples/js/loaders/3MFLoader.js +2 -2
- package/examples/js/loaders/ColladaLoader.js +61 -3
- package/examples/js/loaders/FBXLoader.js +1 -1
- package/examples/js/loaders/GLTFLoader.js +94 -31
- package/examples/js/loaders/KTX2Loader.js +12 -0
- package/examples/js/loaders/LWOLoader.js +8 -6
- package/examples/js/loaders/LogLuvLoader.js +766 -0
- package/examples/js/loaders/PLYLoader.js +32 -7
- package/examples/js/loaders/RGBELoader.js +2 -1
- package/examples/js/loaders/SVGLoader.js +7 -3
- package/examples/js/loaders/TDSLoader.js +237 -271
- package/examples/js/loaders/lwo/LWO2Parser.js +1 -0
- package/examples/js/loaders/lwo/LWO3Parser.js +4 -2
- package/examples/js/objects/MarchingCubes.js +42 -128
- package/examples/js/renderers/CSS2DRenderer.js +4 -4
- package/examples/js/renderers/CSS3DRenderer.js +4 -4
- package/examples/js/utils/RoughnessMipmapper.js +1 -0
- package/examples/jsm/controls/ArcballControls.js +61 -29
- package/examples/jsm/controls/DragControls.js +7 -0
- package/examples/jsm/controls/OrbitControls.js +9 -51
- package/examples/jsm/controls/TrackballControls.js +1 -1
- package/examples/jsm/csm/CSM.js +3 -3
- package/examples/jsm/csm/{Frustum.js → CSMFrustum.js} +3 -3
- package/examples/jsm/exporters/GLTFExporter.js +160 -74
- package/examples/jsm/exporters/USDZExporter.js +47 -26
- package/examples/jsm/libs/flow.module.js +3218 -0
- package/examples/jsm/libs/lil-gui.module.min.js +8 -0
- package/examples/jsm/libs/rhino3dm/rhino3dm.wasm +0 -0
- package/examples/jsm/lines/LineMaterial.js +59 -23
- package/examples/jsm/lines/LineSegments2.js +22 -18
- package/examples/jsm/loaders/3DMLoader.js +18 -12
- package/examples/jsm/loaders/3MFLoader.js +2 -2
- package/examples/jsm/loaders/ColladaLoader.js +61 -3
- package/examples/jsm/loaders/FBXLoader.js +1 -1
- package/examples/jsm/loaders/GLTFLoader.js +99 -35
- package/examples/jsm/loaders/KTX2Loader.js +19 -0
- package/examples/jsm/loaders/LWOLoader.js +8 -6
- package/examples/jsm/loaders/LogLuvLoader.js +606 -0
- package/examples/jsm/loaders/PLYLoader.js +33 -7
- package/examples/jsm/loaders/SVGLoader.js +7 -4
- package/examples/jsm/loaders/TDSLoader.js +225 -285
- package/examples/jsm/loaders/lwo/LWO2Parser.js +1 -0
- package/examples/jsm/loaders/lwo/LWO3Parser.js +2 -2
- package/examples/jsm/node-editor/NodeEditor.js +455 -0
- package/examples/jsm/node-editor/accessors/NormalEditor.js +30 -0
- package/examples/jsm/node-editor/accessors/PositionEditor.js +30 -0
- package/examples/jsm/node-editor/accessors/UVEditor.js +26 -0
- package/examples/jsm/node-editor/display/BlendEditor.js +43 -0
- package/examples/jsm/node-editor/examples/animate-uv.json +1 -0
- package/examples/jsm/node-editor/examples/fake-top-light.json +1 -0
- package/examples/jsm/node-editor/examples/oscillator-color.json +1 -0
- package/examples/jsm/node-editor/examples/rim.json +1 -0
- package/examples/jsm/node-editor/inputs/ColorEditor.js +91 -0
- package/examples/jsm/node-editor/inputs/FloatEditor.js +24 -0
- package/examples/jsm/node-editor/inputs/SliderEditor.js +68 -0
- package/examples/jsm/node-editor/inputs/Vector2Editor.js +28 -0
- package/examples/jsm/node-editor/inputs/Vector3Editor.js +30 -0
- package/examples/jsm/node-editor/inputs/Vector4Editor.js +37 -0
- package/examples/jsm/node-editor/materials/StandardMaterialEditor.js +69 -0
- package/examples/jsm/node-editor/math/DotEditor.js +36 -0
- package/examples/jsm/node-editor/math/InvertEditor.js +38 -0
- package/examples/jsm/node-editor/math/LimiterEditor.js +48 -0
- package/examples/jsm/node-editor/math/NormalizeEditor.js +26 -0
- package/examples/jsm/node-editor/math/OperatorEditor.js +50 -0
- package/examples/jsm/node-editor/math/PowerEditor.js +34 -0
- package/examples/jsm/node-editor/math/TrigonometryEditor.js +39 -0
- package/examples/jsm/node-editor/procedural/CheckerEditor.js +26 -0
- package/examples/jsm/node-editor/utils/OscillatorEditor.js +42 -0
- package/examples/jsm/node-editor/utils/TimerEditor.js +57 -0
- package/examples/jsm/nodes/materials/StandardNodeMaterial.js +1 -1
- package/examples/jsm/nodes/materials/nodes/StandardNode.js +6 -6
- package/examples/jsm/nodes/utils/ColorSpaceNode.js +1 -49
- package/examples/jsm/objects/MarchingCubes.js +46 -152
- package/examples/jsm/postprocessing/AdaptiveToneMappingPass.js +1 -1
- package/examples/jsm/postprocessing/AfterimagePass.js +1 -1
- package/examples/jsm/postprocessing/BloomPass.js +1 -1
- package/examples/jsm/postprocessing/BokehPass.js +1 -1
- package/examples/jsm/postprocessing/ClearPass.js +1 -1
- package/examples/jsm/postprocessing/CubeTexturePass.js +1 -1
- package/examples/jsm/postprocessing/DotScreenPass.js +1 -1
- package/examples/jsm/postprocessing/EffectComposer.js +3 -3
- package/examples/jsm/postprocessing/FilmPass.js +1 -1
- package/examples/jsm/postprocessing/GlitchPass.js +1 -1
- package/examples/jsm/postprocessing/HalftonePass.js +1 -1
- package/examples/jsm/postprocessing/MaskPass.js +1 -1
- package/examples/jsm/postprocessing/OutlinePass.js +1 -1
- package/examples/jsm/postprocessing/RenderPass.js +1 -1
- package/examples/jsm/postprocessing/SAOPass.js +1 -1
- package/examples/jsm/postprocessing/SMAAPass.js +1 -1
- package/examples/jsm/postprocessing/SSAARenderPass.js +1 -1
- package/examples/jsm/postprocessing/SSAOPass.js +1 -1
- package/examples/jsm/postprocessing/SSRPass.js +1 -1
- package/examples/jsm/postprocessing/SSRrPass.js +1 -1
- package/examples/jsm/postprocessing/SavePass.js +1 -1
- package/examples/jsm/postprocessing/ShaderPass.js +1 -1
- package/examples/jsm/postprocessing/TAARenderPass.js +1 -1
- package/examples/jsm/postprocessing/TexturePass.js +1 -1
- package/examples/jsm/postprocessing/UnrealBloomPass.js +1 -1
- package/examples/jsm/renderers/CSS2DRenderer.js +5 -4
- package/examples/jsm/renderers/CSS3DRenderer.js +5 -4
- package/examples/jsm/renderers/nodes/Nodes.js +14 -13
- package/examples/jsm/renderers/nodes/ShaderNode.js +193 -41
- package/examples/jsm/renderers/nodes/accessors/MaterialNode.js +6 -6
- package/examples/jsm/renderers/nodes/accessors/ModelViewProjectionNode.js +5 -5
- package/examples/jsm/renderers/nodes/accessors/NormalNode.js +14 -3
- package/examples/jsm/renderers/nodes/accessors/PointUVNode.js +3 -3
- package/examples/jsm/renderers/nodes/accessors/PositionNode.js +15 -5
- package/examples/jsm/renderers/nodes/accessors/SkinningNode.js +107 -0
- package/examples/jsm/renderers/nodes/accessors/UVNode.js +7 -5
- package/examples/jsm/renderers/nodes/core/ArrayInputNode.js +3 -3
- package/examples/jsm/renderers/nodes/core/AttributeNode.js +6 -0
- package/examples/jsm/renderers/nodes/core/BypassNode.js +38 -0
- package/examples/jsm/renderers/nodes/core/CodeNode.js +3 -3
- package/examples/jsm/renderers/nodes/core/ContextNode.js +4 -19
- package/examples/jsm/renderers/nodes/core/ExpressionNode.js +13 -2
- package/examples/jsm/renderers/nodes/core/FunctionNode.js +19 -132
- package/examples/jsm/renderers/nodes/core/InputNode.js +13 -3
- package/examples/jsm/renderers/nodes/core/Node.js +32 -10
- package/examples/jsm/renderers/nodes/core/NodeBuilder.js +146 -128
- package/examples/jsm/renderers/nodes/core/NodeFunction.js +22 -0
- package/examples/jsm/renderers/nodes/core/NodeFunctionInput.js +4 -4
- package/examples/jsm/renderers/nodes/core/NodeKeywords.js +18 -179
- package/examples/jsm/renderers/nodes/core/NodeParser.js +11 -0
- package/examples/jsm/renderers/nodes/core/NodeVar.js +2 -2
- package/examples/jsm/renderers/nodes/core/PropertyNode.js +14 -2
- package/examples/jsm/renderers/nodes/core/TempNode.js +10 -13
- package/examples/jsm/renderers/nodes/core/VarNode.js +12 -7
- package/examples/jsm/renderers/nodes/core/VaryNode.js +23 -8
- package/examples/jsm/renderers/nodes/core/constants.js +2 -0
- package/examples/jsm/renderers/nodes/display/ColorSpaceNode.js +47 -25
- package/examples/jsm/renderers/nodes/display/NormalMapNode.js +21 -22
- package/examples/jsm/renderers/nodes/functions/BSDFs.js +64 -101
- package/examples/jsm/renderers/nodes/inputs/BufferNode.js +25 -0
- package/examples/jsm/renderers/nodes/inputs/IntNode.js +17 -0
- package/examples/jsm/renderers/nodes/inputs/TextureNode.js +10 -2
- package/examples/jsm/renderers/nodes/lights/LightContextNode.js +20 -14
- package/examples/jsm/renderers/nodes/lights/LightNode.js +32 -36
- package/examples/jsm/renderers/nodes/math/CondNode.js +60 -0
- package/examples/jsm/renderers/nodes/math/MathNode.js +87 -36
- package/examples/jsm/renderers/nodes/math/OperatorNode.js +124 -31
- package/examples/jsm/renderers/nodes/parsers/GLSLNodeFunction.js +137 -0
- package/examples/jsm/renderers/nodes/parsers/GLSLNodeParser.js +14 -0
- package/examples/jsm/renderers/nodes/parsers/WGSLNodeFunction.js +89 -0
- package/examples/jsm/renderers/nodes/parsers/WGSLNodeParser.js +14 -0
- package/examples/jsm/renderers/nodes/procedural/CheckerNode.js +7 -9
- package/examples/jsm/renderers/nodes/utils/ArrayElementNode.js +31 -0
- package/examples/jsm/renderers/nodes/utils/ConvertNode.js +33 -0
- package/examples/jsm/renderers/nodes/utils/JoinNode.js +7 -7
- package/examples/jsm/renderers/nodes/utils/OscNode.js +58 -0
- package/examples/jsm/renderers/nodes/utils/SplitNode.js +18 -8
- package/examples/jsm/renderers/nodes/utils/SpriteSheetUVNode.js +7 -7
- package/examples/jsm/renderers/webgl/nodes/SlotNode.js +22 -0
- package/examples/jsm/renderers/webgl/nodes/WebGLNodeBuilder.js +191 -94
- package/examples/jsm/renderers/webgl/nodes/WebGLNodes.js +2 -2
- package/examples/jsm/renderers/webgl/nodes/WebGLPhysicalContextNode.js +2 -2
- package/examples/jsm/renderers/webgpu/WebGPUBackground.js +1 -1
- package/examples/jsm/renderers/webgpu/WebGPUBindings.js +3 -3
- package/examples/jsm/renderers/webgpu/WebGPUComputePipelines.js +2 -4
- package/examples/jsm/renderers/webgpu/WebGPUProgrammableStage.js +2 -4
- package/examples/jsm/renderers/webgpu/WebGPURenderPipeline.js +15 -23
- package/examples/jsm/renderers/webgpu/WebGPURenderPipelines.js +3 -5
- package/examples/jsm/renderers/webgpu/WebGPURenderer.js +11 -27
- package/examples/jsm/renderers/webgpu/WebGPUTextureUtils.js +62 -28
- package/examples/jsm/renderers/webgpu/WebGPUTextures.js +34 -27
- package/examples/jsm/renderers/webgpu/constants.js +2 -2
- package/examples/jsm/renderers/webgpu/nodes/WebGPUNodeBuilder.js +430 -98
- package/examples/jsm/renderers/webgpu/nodes/WebGPUNodes.js +1 -1
- package/examples/jsm/utils/RoughnessMipmapper.js +1 -0
- package/examples/jsm/webxr/OculusHandPointerModel.js +6 -6
- package/package.json +10 -10
- package/src/Three.Legacy.js +6 -0
- package/src/Three.js +0 -1
- package/src/cameras/StereoCamera.js +8 -7
- package/src/constants.js +1 -2
- package/src/core/Layers.js +7 -1
- package/src/core/Object3D.js +2 -0
- package/src/extras/PMREMGenerator.js +11 -6
- package/src/loaders/FileLoader.js +89 -152
- package/src/loaders/ImageLoader.js +9 -4
- package/src/loaders/LoaderUtils.js +26 -0
- package/src/loaders/MaterialLoader.js +7 -4
- package/src/loaders/ObjectLoader.js +2 -0
- package/src/materials/Material.js +4 -4
- package/src/materials/MeshPhysicalMaterial.js +20 -14
- package/src/math/MathUtils.js +5 -16
- package/src/renderers/WebGLMultisampleRenderTarget.js +7 -1
- package/src/renderers/WebGLRenderer.js +83 -117
- package/src/renderers/shaders/ShaderChunk/bsdfs.glsl.js +2 -2
- package/src/renderers/shaders/ShaderChunk/encodings_pars_fragment.glsl.js +0 -27
- package/src/renderers/shaders/ShaderChunk/envmap_common_pars_fragment.glsl.js +0 -1
- package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +19 -6
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +2 -2
- package/src/renderers/shaders/ShaderChunk/transmission_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/transmission_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +13 -5
- package/src/renderers/shaders/ShaderLib/vsm.glsl.js +2 -1
- package/src/renderers/shaders/ShaderLib.js +6 -4
- package/src/renderers/shaders/UniformsLib.js +1 -2
- package/src/renderers/webgl/WebGLExtensions.js +1 -0
- package/src/renderers/webgl/WebGLMaterials.js +27 -15
- package/src/renderers/webgl/WebGLProgram.js +10 -6
- package/src/renderers/webgl/WebGLPrograms.js +17 -12
- package/src/renderers/webgl/WebGLShadowMap.js +14 -5
- package/src/renderers/webgl/WebGLState.js +31 -17
- package/src/renderers/webgl/WebGLTextures.js +188 -51
- package/src/renderers/webgl/WebGLUniforms.js +45 -1
- package/src/renderers/webxr/WebXRManager.js +71 -110
- package/src/textures/Texture.js +6 -0
- package/src/utils.js +37 -1
- package/examples/js/controls/DeviceOrientationControls.js +0 -147
- package/examples/js/libs/dat.gui.min.js +0 -14
- package/examples/jsm/controls/DeviceOrientationControls.js +0 -153
- package/examples/jsm/libs/dat.gui.module.js +0 -3575
- package/examples/jsm/libs/glslang.js +0 -78
- package/examples/jsm/libs/glslang.wasm +0 -0
- package/examples/jsm/renderers/nodes/consts/MathConsts.js +0 -7
- package/examples/jsm/renderers/nodes/core/ConstNode.js +0 -39
- package/examples/jsm/renderers/nodes/core/NodeSlot.js +0 -13
- package/examples/jsm/renderers/nodes/core/StructNode.js +0 -80
- package/examples/jsm/renderers/nodes/core/StructVarNode.js +0 -75
- package/examples/jsm/renderers/nodes/functions/EncodingFunctions.js +0 -99
- package/examples/jsm/renderers/nodes/functions/MathFunctions.js +0 -47
- package/examples/jsm/renderers/webgpu/nodes/ShaderLib.js +0 -152
- package/src/extras/objects/ImmediateRenderObject.js +0 -31
|
@@ -12,8 +12,6 @@ import WebGPUTextures from './WebGPUTextures.js';
|
|
|
12
12
|
import WebGPUBackground from './WebGPUBackground.js';
|
|
13
13
|
import WebGPUNodes from './nodes/WebGPUNodes.js';
|
|
14
14
|
|
|
15
|
-
import glslang from '../../libs/glslang.js';
|
|
16
|
-
|
|
17
15
|
import { Frustum, Matrix4, Vector3, Color, LinearEncoding } from 'three';
|
|
18
16
|
|
|
19
17
|
console.info( 'THREE.WebGPURenderer: Modified Matrix4.makePerspective() and Matrix4.makeOrtographic() to work with WebGPU, see https://github.com/mrdoob/three.js/issues/20276.' );
|
|
@@ -166,13 +164,11 @@ class WebGPURenderer {
|
|
|
166
164
|
|
|
167
165
|
const device = await adapter.requestDevice( deviceDescriptor );
|
|
168
166
|
|
|
169
|
-
const compiler = await glslang();
|
|
170
|
-
|
|
171
167
|
const context = ( parameters.context !== undefined ) ? parameters.context : this.domElement.getContext( 'webgpu' );
|
|
172
168
|
|
|
173
169
|
const swapChain = context.configure( {
|
|
174
170
|
device: device,
|
|
175
|
-
format: GPUTextureFormat.
|
|
171
|
+
format: GPUTextureFormat.BGRA8Unorm // this is the only valid swap chain format right now (r121)
|
|
176
172
|
} );
|
|
177
173
|
|
|
178
174
|
this._adapter = adapter;
|
|
@@ -184,11 +180,11 @@ class WebGPURenderer {
|
|
|
184
180
|
this._properties = new WebGPUProperties();
|
|
185
181
|
this._attributes = new WebGPUAttributes( device );
|
|
186
182
|
this._geometries = new WebGPUGeometries( this._attributes, this._info );
|
|
187
|
-
this._textures = new WebGPUTextures( device, this._properties, this._info
|
|
183
|
+
this._textures = new WebGPUTextures( device, this._properties, this._info );
|
|
188
184
|
this._objects = new WebGPUObjects( this._geometries, this._info );
|
|
189
185
|
this._nodes = new WebGPUNodes( this );
|
|
190
|
-
this._renderPipelines = new WebGPURenderPipelines( this, this._properties, device,
|
|
191
|
-
this._computePipelines = new WebGPUComputePipelines( device
|
|
186
|
+
this._renderPipelines = new WebGPURenderPipelines( this, this._properties, device, parameters.sampleCount, this._nodes );
|
|
187
|
+
this._computePipelines = new WebGPUComputePipelines( device );
|
|
192
188
|
this._bindings = new WebGPUBindings( device, this._info, this._properties, this._textures, this._renderPipelines, this._computePipelines, this._attributes, this._nodes );
|
|
193
189
|
this._renderLists = new WebGPURenderLists();
|
|
194
190
|
this._background = new WebGPUBackground( this );
|
|
@@ -493,7 +489,7 @@ class WebGPURenderer {
|
|
|
493
489
|
|
|
494
490
|
} else {
|
|
495
491
|
|
|
496
|
-
format = GPUTextureFormat.
|
|
492
|
+
format = GPUTextureFormat.BGRA8Unorm; // default swap chain format
|
|
497
493
|
|
|
498
494
|
}
|
|
499
495
|
|
|
@@ -639,7 +635,6 @@ class WebGPURenderer {
|
|
|
639
635
|
|
|
640
636
|
_projectObject( object, camera, groupOrder ) {
|
|
641
637
|
|
|
642
|
-
const info = this._info;
|
|
643
638
|
const currentRenderList = this._currentRenderList;
|
|
644
639
|
|
|
645
640
|
if ( object.visible === false ) return;
|
|
@@ -693,19 +688,6 @@ class WebGPURenderer {
|
|
|
693
688
|
|
|
694
689
|
} else if ( object.isMesh || object.isLine || object.isPoints ) {
|
|
695
690
|
|
|
696
|
-
if ( object.isSkinnedMesh ) {
|
|
697
|
-
|
|
698
|
-
// update skeleton only once in a frame
|
|
699
|
-
|
|
700
|
-
if ( object.skeleton.frame !== info.render.frame ) {
|
|
701
|
-
|
|
702
|
-
object.skeleton.update();
|
|
703
|
-
object.skeleton.frame = info.render.frame;
|
|
704
|
-
|
|
705
|
-
}
|
|
706
|
-
|
|
707
|
-
}
|
|
708
|
-
|
|
709
691
|
if ( ! object.frustumCulled || _frustum.intersectsObject( object ) ) {
|
|
710
692
|
|
|
711
693
|
if ( this.sortObjects === true ) {
|
|
@@ -791,7 +773,7 @@ class WebGPURenderer {
|
|
|
791
773
|
passEncoder.setViewport( vp.x, vp.y, vp.width, vp.height, minDepth, maxDepth );
|
|
792
774
|
|
|
793
775
|
this._nodes.update( object, camera2 );
|
|
794
|
-
this._bindings.update( object
|
|
776
|
+
this._bindings.update( object );
|
|
795
777
|
this._renderObject( object, passEncoder );
|
|
796
778
|
|
|
797
779
|
}
|
|
@@ -801,7 +783,7 @@ class WebGPURenderer {
|
|
|
801
783
|
} else {
|
|
802
784
|
|
|
803
785
|
this._nodes.update( object, camera );
|
|
804
|
-
this._bindings.update( object
|
|
786
|
+
this._bindings.update( object );
|
|
805
787
|
this._renderObject( object, passEncoder );
|
|
806
788
|
|
|
807
789
|
}
|
|
@@ -914,7 +896,7 @@ class WebGPURenderer {
|
|
|
914
896
|
depthOrArrayLayers: 1
|
|
915
897
|
},
|
|
916
898
|
sampleCount: this._parameters.sampleCount,
|
|
917
|
-
format: GPUTextureFormat.
|
|
899
|
+
format: GPUTextureFormat.BGRA8Unorm,
|
|
918
900
|
usage: GPUTextureUsage.RENDER_ATTACHMENT
|
|
919
901
|
} );
|
|
920
902
|
|
|
@@ -953,7 +935,7 @@ class WebGPURenderer {
|
|
|
953
935
|
|
|
954
936
|
this._context.configure( {
|
|
955
937
|
device: device,
|
|
956
|
-
format: GPUTextureFormat.
|
|
938
|
+
format: GPUTextureFormat.BGRA8Unorm,
|
|
957
939
|
usage: GPUTextureUsage.RENDER_ATTACHMENT,
|
|
958
940
|
size: {
|
|
959
941
|
width: Math.floor( this._width * this._pixelRatio ),
|
|
@@ -976,4 +958,6 @@ class WebGPURenderer {
|
|
|
976
958
|
|
|
977
959
|
}
|
|
978
960
|
|
|
961
|
+
WebGPURenderer.prototype.isWebGPURenderer = true;
|
|
962
|
+
|
|
979
963
|
export default WebGPURenderer;
|
|
@@ -24,28 +24,60 @@ import { GPUIndexFormat, GPUFilterMode, GPUPrimitiveTopology } from './constants
|
|
|
24
24
|
|
|
25
25
|
class WebGPUTextureUtils {
|
|
26
26
|
|
|
27
|
-
constructor( device
|
|
27
|
+
constructor( device ) {
|
|
28
28
|
|
|
29
29
|
this.device = device;
|
|
30
30
|
|
|
31
|
-
const mipmapVertexSource =
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
31
|
+
const mipmapVertexSource = `
|
|
32
|
+
[[ block ]]
|
|
33
|
+
struct VarysStruct {
|
|
34
|
+
|
|
35
|
+
[[ builtin( position ) ]] Position: vec4<f32>;
|
|
36
|
+
[[ location( 0 ) ]] vTex : vec2<f32>;
|
|
37
|
+
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
[[ stage( vertex ) ]]
|
|
41
|
+
fn main( [[ builtin( vertex_index ) ]] vertexIndex : u32 ) -> VarysStruct {
|
|
42
|
+
|
|
43
|
+
var Varys: VarysStruct;
|
|
44
|
+
|
|
45
|
+
var pos = array< vec2<f32>, 4 >(
|
|
46
|
+
vec2<f32>( -1.0, 1.0 ),
|
|
47
|
+
vec2<f32>( 1.0, 1.0 ),
|
|
48
|
+
vec2<f32>( -1.0, -1.0 ),
|
|
49
|
+
vec2<f32>( 1.0, -1.0 )
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
var tex = array< vec2<f32>, 4 >(
|
|
53
|
+
vec2<f32>( 0.0, 0.0 ),
|
|
54
|
+
vec2<f32>( 1.0, 0.0 ),
|
|
55
|
+
vec2<f32>( 0.0, 1.0 ),
|
|
56
|
+
vec2<f32>( 1.0, 1.0 )
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
Varys.vTex = tex[ vertexIndex ];
|
|
60
|
+
Varys.Position = vec4<f32>( pos[ vertexIndex ], 0.0, 1.0 );
|
|
61
|
+
|
|
62
|
+
return Varys;
|
|
63
|
+
|
|
64
|
+
}
|
|
65
|
+
`;
|
|
66
|
+
|
|
67
|
+
const mipmapFragmentSource = `
|
|
68
|
+
[[ group( 0 ), binding( 0 ) ]]
|
|
69
|
+
var imgSampler : sampler;
|
|
70
|
+
|
|
71
|
+
[[ group( 0 ), binding( 1 ) ]]
|
|
72
|
+
var img : texture_2d<f32>;
|
|
73
|
+
|
|
74
|
+
[[ stage( fragment ) ]]
|
|
75
|
+
fn main( [[ location( 0 ) ]] vTex : vec2<f32> ) -> [[ location( 0 ) ]] vec4<f32> {
|
|
76
|
+
|
|
77
|
+
return textureSample( img, imgSampler, vTex );
|
|
78
|
+
|
|
79
|
+
}
|
|
80
|
+
`;
|
|
49
81
|
|
|
50
82
|
this.sampler = device.createSampler( { minFilter: GPUFilterMode.Linear } );
|
|
51
83
|
|
|
@@ -53,10 +85,11 @@ class WebGPUTextureUtils {
|
|
|
53
85
|
this.pipelines = {};
|
|
54
86
|
|
|
55
87
|
this.mipmapVertexShaderModule = device.createShaderModule( {
|
|
56
|
-
code:
|
|
88
|
+
code: mipmapVertexSource
|
|
57
89
|
} );
|
|
90
|
+
|
|
58
91
|
this.mipmapFragmentShaderModule = device.createShaderModule( {
|
|
59
|
-
code:
|
|
92
|
+
code: mipmapFragmentSource
|
|
60
93
|
} );
|
|
61
94
|
|
|
62
95
|
}
|
|
@@ -82,6 +115,7 @@ class WebGPUTextureUtils {
|
|
|
82
115
|
stripIndexFormat: GPUIndexFormat.Uint32
|
|
83
116
|
}
|
|
84
117
|
} );
|
|
118
|
+
|
|
85
119
|
this.pipelines[ format ] = pipeline;
|
|
86
120
|
|
|
87
121
|
}
|
|
@@ -99,32 +133,32 @@ class WebGPUTextureUtils {
|
|
|
99
133
|
|
|
100
134
|
let srcView = textureGPU.createView( {
|
|
101
135
|
baseMipLevel: 0,
|
|
102
|
-
mipLevelCount: 1
|
|
136
|
+
mipLevelCount: 1
|
|
103
137
|
} );
|
|
104
138
|
|
|
105
139
|
for ( let i = 1; i < textureGPUDescriptor.mipLevelCount; i ++ ) {
|
|
106
140
|
|
|
107
141
|
const dstView = textureGPU.createView( {
|
|
108
142
|
baseMipLevel: i,
|
|
109
|
-
mipLevelCount: 1
|
|
143
|
+
mipLevelCount: 1
|
|
110
144
|
} );
|
|
111
145
|
|
|
112
146
|
const passEncoder = commandEncoder.beginRenderPass( {
|
|
113
147
|
colorAttachments: [ {
|
|
114
148
|
view: dstView,
|
|
115
|
-
loadValue: [ 0, 0, 0, 0 ]
|
|
116
|
-
} ]
|
|
149
|
+
loadValue: [ 0, 0, 0, 0 ]
|
|
150
|
+
} ]
|
|
117
151
|
} );
|
|
118
152
|
|
|
119
153
|
const bindGroup = this.device.createBindGroup( {
|
|
120
154
|
layout: bindGroupLayout,
|
|
121
155
|
entries: [ {
|
|
122
156
|
binding: 0,
|
|
123
|
-
resource: this.sampler
|
|
157
|
+
resource: this.sampler
|
|
124
158
|
}, {
|
|
125
159
|
binding: 1,
|
|
126
|
-
resource: srcView
|
|
127
|
-
} ]
|
|
160
|
+
resource: srcView
|
|
161
|
+
} ]
|
|
128
162
|
} );
|
|
129
163
|
|
|
130
164
|
passEncoder.setPipeline( pipeline );
|
|
@@ -6,12 +6,11 @@ import WebGPUTextureUtils from './WebGPUTextureUtils.js';
|
|
|
6
6
|
|
|
7
7
|
class WebGPUTextures {
|
|
8
8
|
|
|
9
|
-
constructor( device, properties, info
|
|
9
|
+
constructor( device, properties, info ) {
|
|
10
10
|
|
|
11
11
|
this.device = device;
|
|
12
12
|
this.properties = properties;
|
|
13
13
|
this.info = info;
|
|
14
|
-
this.glslang = glslang;
|
|
15
14
|
|
|
16
15
|
this.defaultTexture = null;
|
|
17
16
|
this.defaultCubeTexture = null;
|
|
@@ -42,7 +41,9 @@ class WebGPUTextures {
|
|
|
42
41
|
texture.minFilter = NearestFilter;
|
|
43
42
|
texture.magFilter = NearestFilter;
|
|
44
43
|
|
|
45
|
-
this.
|
|
44
|
+
this._uploadTexture( texture );
|
|
45
|
+
|
|
46
|
+
this.defaultTexture = this.getTextureGPU( texture );
|
|
46
47
|
|
|
47
48
|
}
|
|
48
49
|
|
|
@@ -58,7 +59,9 @@ class WebGPUTextures {
|
|
|
58
59
|
texture.minFilter = NearestFilter;
|
|
59
60
|
texture.magFilter = NearestFilter;
|
|
60
61
|
|
|
61
|
-
this.
|
|
62
|
+
this._uploadTexture( texture );
|
|
63
|
+
|
|
64
|
+
this.defaultCubeTexture = this.getTextureGPU( texture );
|
|
62
65
|
|
|
63
66
|
}
|
|
64
67
|
|
|
@@ -84,7 +87,7 @@ class WebGPUTextures {
|
|
|
84
87
|
|
|
85
88
|
updateTexture( texture ) {
|
|
86
89
|
|
|
87
|
-
let
|
|
90
|
+
let needsUpdate = false;
|
|
88
91
|
|
|
89
92
|
const textureProperties = this.properties.get( texture );
|
|
90
93
|
|
|
@@ -117,21 +120,9 @@ class WebGPUTextures {
|
|
|
117
120
|
|
|
118
121
|
}
|
|
119
122
|
|
|
120
|
-
//
|
|
121
|
-
|
|
122
|
-
if ( textureProperties.textureGPU !== undefined ) {
|
|
123
|
+
//
|
|
123
124
|
|
|
124
|
-
|
|
125
|
-
// are updated, a buffer upload should be sufficient. However, if the user changes
|
|
126
|
-
// the dimensions of the texture, format or usage, a new instance of GPUTexture is required.
|
|
127
|
-
|
|
128
|
-
textureProperties.textureGPU.destroy();
|
|
129
|
-
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
textureProperties.textureGPU = this._createTexture( texture );
|
|
133
|
-
textureProperties.version = texture.version;
|
|
134
|
-
forceUpdate = true;
|
|
125
|
+
needsUpdate = this._uploadTexture( texture );
|
|
135
126
|
|
|
136
127
|
}
|
|
137
128
|
|
|
@@ -143,11 +134,11 @@ class WebGPUTextures {
|
|
|
143
134
|
if ( textureProperties.initializedRTT === false ) {
|
|
144
135
|
|
|
145
136
|
textureProperties.initializedRTT = true;
|
|
146
|
-
|
|
137
|
+
needsUpdate = true;
|
|
147
138
|
|
|
148
139
|
}
|
|
149
140
|
|
|
150
|
-
return
|
|
141
|
+
return needsUpdate;
|
|
151
142
|
|
|
152
143
|
}
|
|
153
144
|
|
|
@@ -305,11 +296,15 @@ class WebGPUTextures {
|
|
|
305
296
|
|
|
306
297
|
}
|
|
307
298
|
|
|
308
|
-
|
|
299
|
+
_uploadTexture( texture ) {
|
|
300
|
+
|
|
301
|
+
let needsUpdate = false;
|
|
309
302
|
|
|
310
303
|
const device = this.device;
|
|
311
304
|
const image = texture.image;
|
|
312
305
|
|
|
306
|
+
const textureProperties = this.properties.get( texture );
|
|
307
|
+
|
|
313
308
|
const { width, height, depth } = this._getSize( texture );
|
|
314
309
|
const needsMipmaps = this._needsMipmaps( texture );
|
|
315
310
|
const dimension = this._getDimension( texture );
|
|
@@ -326,8 +321,6 @@ class WebGPUTextures {
|
|
|
326
321
|
|
|
327
322
|
}
|
|
328
323
|
|
|
329
|
-
// texture creation
|
|
330
|
-
|
|
331
324
|
const textureGPUDescriptor = {
|
|
332
325
|
size: {
|
|
333
326
|
width: width,
|
|
@@ -340,7 +333,19 @@ class WebGPUTextures {
|
|
|
340
333
|
format: format,
|
|
341
334
|
usage: usage
|
|
342
335
|
};
|
|
343
|
-
|
|
336
|
+
|
|
337
|
+
// texture creation
|
|
338
|
+
|
|
339
|
+
let textureGPU = textureProperties.textureGPU;
|
|
340
|
+
|
|
341
|
+
if ( textureGPU === undefined ) {
|
|
342
|
+
|
|
343
|
+
textureGPU = device.createTexture( textureGPUDescriptor );
|
|
344
|
+
textureProperties.textureGPU = textureGPU;
|
|
345
|
+
|
|
346
|
+
needsUpdate = true;
|
|
347
|
+
|
|
348
|
+
}
|
|
344
349
|
|
|
345
350
|
// transfer texture data
|
|
346
351
|
|
|
@@ -376,7 +381,9 @@ class WebGPUTextures {
|
|
|
376
381
|
|
|
377
382
|
}
|
|
378
383
|
|
|
379
|
-
|
|
384
|
+
textureProperties.version = texture.version;
|
|
385
|
+
|
|
386
|
+
return needsUpdate;
|
|
380
387
|
|
|
381
388
|
}
|
|
382
389
|
|
|
@@ -481,7 +488,7 @@ class WebGPUTextures {
|
|
|
481
488
|
|
|
482
489
|
if ( this.utils === null ) {
|
|
483
490
|
|
|
484
|
-
this.utils = new WebGPUTextureUtils( this.device
|
|
491
|
+
this.utils = new WebGPUTextureUtils( this.device ); // only create this helper if necessary
|
|
485
492
|
|
|
486
493
|
}
|
|
487
494
|
|
|
@@ -107,8 +107,8 @@ export const GPUTextureFormat = {
|
|
|
107
107
|
RGBA8Snorm: 'rgba8snorm',
|
|
108
108
|
RGBA8Uint: 'rgba8uint',
|
|
109
109
|
RGBA8Sint: 'rgba8sint',
|
|
110
|
-
|
|
111
|
-
|
|
110
|
+
BGRA8Unorm: 'bgra8unorm',
|
|
111
|
+
BGRA8UnormSRGB: 'bgra8unorm-srgb',
|
|
112
112
|
// Packed 32-bit formats
|
|
113
113
|
RGB9E5UFloat: 'rgb9e5ufloat',
|
|
114
114
|
RGB10A2Unorm: 'rgb10a2unorm',
|