super-three 0.155.0 → 0.157.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 +361 -324
- package/build/three.js +361 -324
- package/build/three.min.js +2 -2
- package/build/three.module.js +354 -323
- package/build/three.module.min.js +1 -1
- package/examples/jsm/capabilities/WebGL.js +17 -0
- package/examples/jsm/controls/DragControls.js +3 -2
- package/examples/jsm/controls/OrbitControls.js +13 -5
- package/examples/jsm/csm/CSMShader.js +59 -21
- package/examples/jsm/exporters/EXRExporter.js +102 -24
- package/examples/jsm/exporters/GLTFExporter.js +1 -1
- package/examples/jsm/libs/rhino3dm/rhino3dm.js +8726 -4
- package/examples/jsm/libs/rhino3dm/rhino3dm.module.js +8737 -4
- package/examples/jsm/libs/rhino3dm/rhino3dm.wasm +0 -0
- package/examples/jsm/libs/tween.module.js +790 -735
- package/examples/jsm/libs/utif.module.js +1644 -1558
- package/examples/jsm/lights/LightProbeGenerator.js +37 -3
- package/examples/jsm/lines/LineMaterial.js +90 -156
- package/examples/jsm/loaders/3DMLoader.js +378 -104
- package/examples/jsm/loaders/DDSLoader.js +46 -3
- package/examples/jsm/loaders/EXRLoader.js +4 -4
- package/examples/jsm/loaders/FBXLoader.js +2 -0
- package/examples/jsm/loaders/GLTFLoader.js +18 -8
- package/examples/jsm/loaders/KTX2Loader.js +126 -77
- package/examples/jsm/loaders/LDrawLoader.js +22 -16
- package/examples/jsm/loaders/LogLuvLoader.js +2 -2
- package/examples/jsm/loaders/MMDLoader.js +10 -7
- package/examples/jsm/loaders/RGBELoader.js +48 -66
- package/examples/jsm/loaders/STLLoader.js +7 -0
- package/examples/jsm/loaders/USDZLoader.js +215 -12
- package/examples/jsm/materials/MeshGouraudMaterial.js +22 -18
- package/examples/jsm/nodes/Nodes.js +8 -1
- package/examples/jsm/nodes/accessors/BitangentNode.js +1 -1
- package/examples/jsm/nodes/accessors/BufferAttributeNode.js +30 -4
- package/examples/jsm/nodes/accessors/BufferNode.js +1 -1
- package/examples/jsm/nodes/accessors/CameraNode.js +1 -1
- package/examples/jsm/nodes/accessors/CubeTextureNode.js +19 -4
- package/examples/jsm/nodes/accessors/ExtendedMaterialNode.js +4 -5
- package/examples/jsm/nodes/accessors/InstanceNode.js +2 -2
- package/examples/jsm/nodes/accessors/LineMaterialNode.js +29 -0
- package/examples/jsm/nodes/accessors/MaterialNode.js +23 -13
- package/examples/jsm/nodes/accessors/MaterialReferenceNode.js +12 -9
- package/examples/jsm/nodes/accessors/ModelNode.js +1 -1
- package/examples/jsm/nodes/accessors/ModelViewProjectionNode.js +5 -4
- package/examples/jsm/nodes/accessors/MorphNode.js +4 -4
- package/examples/jsm/nodes/accessors/NormalNode.js +1 -1
- package/examples/jsm/nodes/accessors/Object3DNode.js +3 -3
- package/examples/jsm/nodes/accessors/PointUVNode.js +1 -1
- package/examples/jsm/nodes/accessors/PositionNode.js +1 -1
- package/examples/jsm/nodes/accessors/ReferenceNode.js +13 -7
- package/examples/jsm/nodes/accessors/ReflectVectorNode.js +2 -2
- package/examples/jsm/nodes/accessors/SceneNode.js +2 -2
- package/examples/jsm/nodes/accessors/SkinningNode.js +2 -2
- package/examples/jsm/nodes/accessors/StorageBufferNode.js +1 -1
- package/examples/jsm/nodes/accessors/TangentNode.js +1 -1
- package/examples/jsm/nodes/accessors/TextureBicubicNode.js +2 -2
- package/examples/jsm/nodes/accessors/TextureNode.js +18 -8
- package/examples/jsm/nodes/accessors/TextureSizeNode.js +2 -2
- package/examples/jsm/nodes/accessors/TextureStoreNode.js +29 -0
- package/examples/jsm/nodes/accessors/UVNode.js +1 -1
- package/examples/jsm/nodes/accessors/UserDataNode.js +2 -2
- package/examples/jsm/nodes/code/CodeNode.js +1 -1
- package/examples/jsm/nodes/code/ExpressionNode.js +1 -1
- package/examples/jsm/nodes/code/FunctionCallNode.js +1 -1
- package/examples/jsm/nodes/code/FunctionNode.js +18 -7
- package/examples/jsm/nodes/code/ScriptableNode.js +2 -2
- package/examples/jsm/nodes/code/ScriptableValueNode.js +2 -2
- package/examples/jsm/nodes/core/ArrayUniformNode.js +1 -1
- package/examples/jsm/nodes/core/AttributeNode.js +3 -3
- package/examples/jsm/nodes/core/BypassNode.js +1 -1
- package/examples/jsm/nodes/core/CacheNode.js +1 -1
- package/examples/jsm/nodes/core/ConstNode.js +1 -1
- package/examples/jsm/nodes/core/ContextNode.js +2 -2
- package/examples/jsm/nodes/core/IndexNode.js +1 -1
- package/examples/jsm/nodes/core/InputNode.js +1 -1
- package/examples/jsm/nodes/core/Node.js +45 -14
- package/examples/jsm/nodes/core/NodeBuilder.js +83 -15
- package/examples/jsm/nodes/core/NodeFrame.js +37 -14
- package/examples/jsm/nodes/core/NodeUniform.js +1 -1
- package/examples/jsm/nodes/core/OutputStructNode.js +62 -0
- package/examples/jsm/nodes/core/PropertyNode.js +3 -1
- package/examples/jsm/nodes/core/StackNode.js +5 -5
- package/examples/jsm/nodes/core/StructTypeNode.js +24 -0
- package/examples/jsm/nodes/core/TempNode.js +1 -1
- package/examples/jsm/nodes/core/UniformNode.js +3 -1
- package/examples/jsm/nodes/core/VarNode.js +1 -1
- package/examples/jsm/nodes/core/VaryingNode.js +1 -1
- package/examples/jsm/nodes/core/constants.js +1 -1
- package/examples/jsm/nodes/display/BlendModeNode.js +2 -2
- package/examples/jsm/nodes/display/BumpMapNode.js +2 -2
- package/examples/jsm/nodes/display/ColorAdjustmentNode.js +2 -2
- package/examples/jsm/nodes/display/ColorSpaceNode.js +2 -2
- package/examples/jsm/nodes/display/FrontFacingNode.js +1 -1
- package/examples/jsm/nodes/display/NormalMapNode.js +2 -2
- package/examples/jsm/nodes/display/PosterizeNode.js +2 -2
- package/examples/jsm/nodes/display/ToneMappingNode.js +2 -2
- package/examples/jsm/nodes/display/ViewportDepthNode.js +2 -2
- package/examples/jsm/nodes/display/ViewportDepthTextureNode.js +1 -1
- package/examples/jsm/nodes/display/ViewportNode.js +21 -7
- package/examples/jsm/nodes/display/ViewportSharedTextureNode.js +1 -1
- package/examples/jsm/nodes/display/ViewportTextureNode.js +1 -1
- package/examples/jsm/nodes/fog/FogExp2Node.js +2 -2
- package/examples/jsm/nodes/fog/FogNode.js +2 -2
- package/examples/jsm/nodes/fog/FogRangeNode.js +2 -2
- package/examples/jsm/nodes/geometry/RangeNode.js +2 -2
- package/examples/jsm/nodes/gpgpu/ComputeNode.js +1 -1
- package/examples/jsm/nodes/lighting/AONode.js +2 -2
- package/examples/jsm/nodes/lighting/AmbientLightNode.js +3 -3
- package/examples/jsm/nodes/lighting/AnalyticLightNode.js +4 -4
- package/examples/jsm/nodes/lighting/DirectionalLightNode.js +4 -4
- package/examples/jsm/nodes/lighting/EnvironmentNode.js +2 -2
- package/examples/jsm/nodes/lighting/HemisphereLightNode.js +3 -3
- package/examples/jsm/nodes/lighting/IESSpotLightNode.js +2 -2
- package/examples/jsm/nodes/lighting/LightNode.js +2 -2
- package/examples/jsm/nodes/lighting/LightingContextNode.js +3 -3
- package/examples/jsm/nodes/lighting/LightingNode.js +1 -1
- package/examples/jsm/nodes/lighting/LightsNode.js +4 -4
- package/examples/jsm/nodes/lighting/PointLightNode.js +3 -3
- package/examples/jsm/nodes/lighting/SpotLightNode.js +4 -4
- package/examples/jsm/nodes/materials/Line2NodeMaterial.js +449 -0
- package/examples/jsm/nodes/materials/LineBasicNodeMaterial.js +1 -1
- package/examples/jsm/nodes/materials/LineDashedNodeMaterial.js +54 -0
- package/examples/jsm/nodes/materials/Materials.js +2 -0
- package/examples/jsm/nodes/materials/MeshBasicNodeMaterial.js +1 -1
- package/examples/jsm/nodes/materials/MeshLambertNodeMaterial.js +2 -2
- package/examples/jsm/nodes/materials/MeshNormalNodeMaterial.js +2 -2
- package/examples/jsm/nodes/materials/MeshPhongNodeMaterial.js +3 -3
- package/examples/jsm/nodes/materials/MeshPhysicalNodeMaterial.js +6 -6
- package/examples/jsm/nodes/materials/MeshStandardNodeMaterial.js +3 -3
- package/examples/jsm/nodes/materials/NodeMaterial.js +39 -29
- package/examples/jsm/nodes/materials/PointsNodeMaterial.js +1 -1
- package/examples/jsm/nodes/materials/SpriteNodeMaterial.js +2 -2
- package/examples/jsm/nodes/math/CondNode.js +1 -1
- package/examples/jsm/nodes/math/HashNode.js +34 -0
- package/examples/jsm/nodes/math/MathNode.js +2 -2
- package/examples/jsm/nodes/math/OperatorNode.js +1 -1
- package/examples/jsm/nodes/procedural/CheckerNode.js +3 -3
- package/examples/jsm/nodes/shadernode/ShaderNode.js +85 -28
- package/examples/jsm/nodes/utils/ArrayElementNode.js +1 -1
- package/examples/jsm/nodes/utils/ConvertNode.js +1 -1
- package/examples/jsm/nodes/utils/DiscardNode.js +1 -1
- package/examples/jsm/nodes/utils/EquirectUVNode.js +2 -2
- package/examples/jsm/nodes/utils/JoinNode.js +1 -1
- package/examples/jsm/nodes/utils/LoopNode.js +11 -11
- package/examples/jsm/nodes/utils/MatcapUVNode.js +2 -2
- package/examples/jsm/nodes/utils/MaxMipLevelNode.js +1 -1
- package/examples/jsm/nodes/utils/OscNode.js +2 -2
- package/examples/jsm/nodes/utils/PackingNode.js +2 -2
- package/examples/jsm/nodes/utils/RemapNode.js +2 -2
- package/examples/jsm/nodes/utils/RotateUVNode.js +2 -2
- package/examples/jsm/nodes/utils/SetNode.js +62 -0
- package/examples/jsm/nodes/utils/SpecularMIPLevelNode.js +2 -2
- package/examples/jsm/nodes/utils/SplitNode.js +2 -2
- package/examples/jsm/nodes/utils/SpriteSheetUVNode.js +2 -2
- package/examples/jsm/nodes/utils/TimerNode.js +2 -2
- package/examples/jsm/nodes/utils/TriplanarTexturesNode.js +2 -2
- package/examples/jsm/objects/Sky.js +1 -3
- package/examples/jsm/postprocessing/FilmPass.js +3 -5
- package/examples/jsm/postprocessing/OutputPass.js +3 -2
- package/examples/jsm/postprocessing/RenderPass.js +30 -12
- package/examples/jsm/postprocessing/SAOPass.js +23 -98
- package/examples/jsm/postprocessing/SSAOPass.js +10 -30
- package/examples/jsm/renderers/common/Backend.js +11 -8
- package/examples/jsm/renderers/common/Background.js +2 -2
- package/examples/jsm/renderers/common/Binding.js +6 -0
- package/examples/jsm/renderers/common/Bindings.js +4 -5
- package/examples/jsm/renderers/common/Pipelines.js +9 -9
- package/examples/jsm/renderers/common/RenderContext.js +3 -0
- package/examples/jsm/renderers/common/RenderContexts.js +26 -1
- package/examples/jsm/renderers/common/RenderList.js +12 -4
- package/examples/jsm/renderers/common/RenderObject.js +43 -15
- package/examples/jsm/renderers/common/RenderObjects.js +8 -14
- package/examples/jsm/renderers/common/Renderer.js +52 -16
- package/examples/jsm/renderers/common/SampledTexture.js +6 -3
- package/examples/jsm/renderers/common/Sampler.js +1 -1
- package/examples/jsm/renderers/common/StorageBuffer.js +1 -1
- package/examples/jsm/renderers/common/StorageTexture.js +19 -0
- package/examples/jsm/renderers/common/Textures.js +166 -21
- package/examples/jsm/renderers/common/nodes/NodeBuilderState.js +35 -0
- package/examples/jsm/renderers/common/nodes/NodeSampledTexture.js +21 -11
- package/examples/jsm/renderers/common/nodes/NodeSampler.js +1 -7
- package/examples/jsm/renderers/common/nodes/Nodes.js +79 -18
- package/examples/jsm/renderers/webgl/WebGLBackend.js +702 -0
- package/examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js +207 -20
- package/examples/jsm/renderers/webgl/utils/WebGLAttributeUtils.js +84 -0
- package/examples/jsm/renderers/webgl/utils/WebGLExtensions.js +26 -0
- package/examples/jsm/renderers/webgl/utils/WebGLState.js +529 -0
- package/examples/jsm/renderers/webgl/utils/WebGLTextureUtils.js +212 -0
- package/examples/jsm/renderers/webgl/utils/WebGLUtils.js +242 -0
- package/examples/jsm/renderers/webgl-legacy/nodes/GLSL1NodeBuilder.js +340 -0
- package/examples/jsm/renderers/{webgl → webgl-legacy}/nodes/WebGLNodeBuilder.js +4 -4
- package/examples/jsm/renderers/{webgl → webgl-legacy}/nodes/WebGLNodes.js +14 -2
- package/examples/jsm/renderers/webgpu/WebGPUBackend.js +282 -43
- package/examples/jsm/renderers/webgpu/WebGPURenderer.js +18 -2
- package/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js +93 -60
- package/examples/jsm/renderers/webgpu/nodes/WGSLNodeFunction.js +2 -2
- package/examples/jsm/renderers/webgpu/utils/WebGPUBindingUtils.js +15 -2
- package/examples/jsm/renderers/webgpu/utils/WebGPUPipelineUtils.js +39 -14
- package/examples/jsm/renderers/webgpu/utils/WebGPUTexturePassUtils.js +285 -0
- package/examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js +205 -284
- package/examples/jsm/renderers/webgpu/utils/WebGPUUtils.js +6 -5
- package/examples/jsm/shaders/FilmShader.js +11 -54
- package/examples/jsm/shaders/GammaCorrectionShader.js +1 -1
- package/examples/jsm/shaders/MMDToonShader.js +4 -4
- package/examples/jsm/shaders/OutputShader.js +2 -2
- package/examples/jsm/shaders/SAOShader.js +0 -13
- package/examples/jsm/shaders/SSAOShader.js +33 -26
- package/examples/jsm/shaders/SubsurfaceScatteringShader.js +6 -6
- package/examples/jsm/utils/BufferGeometryUtils.js +6 -4
- package/package.json +1 -1
- package/src/Three.js +1 -2
- package/src/animation/AnimationUtils.js +3 -20
- package/src/animation/KeyframeTrack.js +8 -8
- package/src/audio/Audio.js +6 -0
- package/src/cameras/Camera.js +1 -5
- package/src/cameras/CubeCamera.js +14 -8
- package/src/constants.js +10 -1
- package/src/core/Object3D.js +1 -14
- package/src/core/RenderTarget.js +16 -7
- package/src/core/UniformsGroup.js +2 -2
- package/src/extras/core/CurvePath.js +4 -1
- package/src/loaders/DataTextureLoader.js +0 -2
- package/src/loaders/MaterialLoader.js +1 -1
- package/src/loaders/ObjectLoader.js +6 -0
- package/src/materials/Material.js +10 -10
- package/src/math/Color.js +1 -5
- package/src/math/ColorManagement.js +82 -60
- package/src/math/Vector2.js +2 -2
- package/src/math/Vector3.js +3 -3
- package/src/math/Vector4.js +4 -4
- package/src/objects/Line.js +1 -1
- package/src/objects/Mesh.js +1 -1
- package/src/objects/Points.js +1 -1
- package/src/objects/Sprite.js +2 -2
- package/src/renderers/WebGLRenderer.js +42 -51
- package/src/renderers/shaders/ShaderChunk/aomap_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/clearcoat_normal_fragment_begin.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/colorspace_pars_fragment.glsl.js +35 -2
- package/src/renderers/shaders/ShaderChunk/common.glsl.js +0 -9
- package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +19 -15
- package/src/renderers/shaders/ShaderChunk/lights_fragment_end.glsl.js +2 -2
- package/src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js +4 -4
- package/src/renderers/shaders/ShaderChunk/lights_lambert_pars_fragment.glsl.js +3 -3
- package/src/renderers/shaders/ShaderChunk/lights_pars_begin.glsl.js +11 -6
- package/src/renderers/shaders/ShaderChunk/lights_phong_pars_fragment.glsl.js +4 -4
- package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +16 -16
- package/src/renderers/shaders/ShaderChunk/lights_toon_pars_fragment.glsl.js +3 -3
- package/src/renderers/shaders/ShaderChunk/map_fragment.glsl.js +11 -1
- package/src/renderers/shaders/ShaderChunk/normal_fragment_begin.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/background.glsl.js +8 -0
- package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +1 -1
- package/src/renderers/shaders/UniformsUtils.js +2 -2
- package/src/renderers/webgl/WebGLBackground.js +9 -17
- package/src/renderers/webgl/WebGLLights.js +14 -3
- package/src/renderers/webgl/WebGLProgram.js +36 -5
- package/src/renderers/webgl/WebGLPrograms.js +9 -1
- package/src/renderers/webgl/WebGLTextures.js +19 -8
- package/src/renderers/webgl/WebGLUtils.js +25 -20
- package/src/scenes/Fog.js +1 -0
- package/src/scenes/FogExp2.js +1 -0
- package/src/textures/Source.js +2 -2
- package/src/textures/Texture.js +2 -2
- package/src/utils.js +9 -1
- package/examples/jsm/renderers/webgpu/utils/WebGPUTextureMipmapUtils.js +0 -163
- package/src/lights/AmbientLightProbe.js +0 -21
- package/src/lights/HemisphereLightProbe.js +0 -30
- /package/examples/jsm/renderers/{webgl → webgl-legacy}/nodes/SlotNode.js +0 -0
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
|
|
5
5
|
import {
|
|
6
6
|
CubeTexture, Texture,
|
|
7
|
-
NearestFilter, NearestMipmapNearestFilter, NearestMipmapLinearFilter,
|
|
7
|
+
NearestFilter, NearestMipmapNearestFilter, NearestMipmapLinearFilter,
|
|
8
8
|
RepeatWrapping, MirroredRepeatWrapping,
|
|
9
9
|
RGB_ETC2_Format, RGBA_ETC2_EAC_Format,
|
|
10
10
|
RGBAFormat, RedFormat, RGFormat, RGBA_S3TC_DXT1_Format, RGBA_S3TC_DXT3_Format, RGBA_S3TC_DXT5_Format, UnsignedByteType, FloatType, HalfFloatType, SRGBColorSpace, DepthFormat, DepthStencilFormat,
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
|
|
16
16
|
import { CubeReflectionMapping, CubeRefractionMapping, EquirectangularReflectionMapping, EquirectangularRefractionMapping } from 'three';
|
|
17
17
|
|
|
18
|
-
import
|
|
18
|
+
import WebGPUTexturePassUtils from './WebGPUTexturePassUtils.js';
|
|
19
19
|
|
|
20
20
|
const _compareToWebGPU = {
|
|
21
21
|
[ NeverCompare ]: 'never',
|
|
@@ -28,13 +28,15 @@ const _compareToWebGPU = {
|
|
|
28
28
|
[ NotEqualCompare ]: 'not-equal'
|
|
29
29
|
};
|
|
30
30
|
|
|
31
|
+
const _flipMap = [ 0, 1, 3, 2, 4, 5 ];
|
|
32
|
+
|
|
31
33
|
class WebGPUTextureUtils {
|
|
32
34
|
|
|
33
35
|
constructor( backend ) {
|
|
34
36
|
|
|
35
37
|
this.backend = backend;
|
|
36
38
|
|
|
37
|
-
this.
|
|
39
|
+
this._passUtils = null;
|
|
38
40
|
|
|
39
41
|
this.defaultTexture = null;
|
|
40
42
|
this.defaultCubeTexture = null;
|
|
@@ -97,18 +99,26 @@ class WebGPUTextureUtils {
|
|
|
97
99
|
|
|
98
100
|
}
|
|
99
101
|
|
|
100
|
-
|
|
102
|
+
if ( options.needsMipmaps === undefined ) options.needsMipmaps = false;
|
|
103
|
+
if ( options.levels === undefined ) options.levels = 1;
|
|
104
|
+
if ( options.depth === undefined ) options.depth = 1;
|
|
105
|
+
|
|
106
|
+
const { width, height, depth, levels } = options;
|
|
101
107
|
|
|
102
|
-
const needsMipmaps = this._needsMipmaps( texture );
|
|
103
108
|
const dimension = this._getDimension( texture );
|
|
104
|
-
const
|
|
105
|
-
const format = texture.internalFormat || this._getFormat( texture );
|
|
109
|
+
const format = texture.internalFormat || getFormat( texture, this.device );
|
|
106
110
|
|
|
107
111
|
const sampleCount = options.sampleCount !== undefined ? options.sampleCount : 1;
|
|
108
112
|
const primarySampleCount = texture.isRenderTargetTexture ? 1 : sampleCount;
|
|
109
113
|
|
|
110
114
|
let usage = GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_DST | GPUTextureUsage.COPY_SRC;
|
|
111
115
|
|
|
116
|
+
if ( texture.isStorageTexture === true ) {
|
|
117
|
+
|
|
118
|
+
usage |= GPUTextureUsage.STORAGE_BINDING;
|
|
119
|
+
|
|
120
|
+
}
|
|
121
|
+
|
|
112
122
|
if ( texture.isCompressedTexture !== true ) {
|
|
113
123
|
|
|
114
124
|
usage |= GPUTextureUsage.RENDER_ATTACHMENT;
|
|
@@ -122,7 +132,7 @@ class WebGPUTextureUtils {
|
|
|
122
132
|
height: height,
|
|
123
133
|
depthOrArrayLayers: depth,
|
|
124
134
|
},
|
|
125
|
-
mipLevelCount:
|
|
135
|
+
mipLevelCount: levels,
|
|
126
136
|
sampleCount: primarySampleCount,
|
|
127
137
|
dimension: dimension,
|
|
128
138
|
format: format,
|
|
@@ -170,7 +180,6 @@ class WebGPUTextureUtils {
|
|
|
170
180
|
|
|
171
181
|
textureData.initialized = true;
|
|
172
182
|
|
|
173
|
-
textureData.needsMipmaps = needsMipmaps;
|
|
174
183
|
textureData.textureDescriptorGPU = textureDescriptorGPU;
|
|
175
184
|
|
|
176
185
|
}
|
|
@@ -217,20 +226,20 @@ class WebGPUTextureUtils {
|
|
|
217
226
|
|
|
218
227
|
}
|
|
219
228
|
|
|
220
|
-
updateTexture( texture ) {
|
|
229
|
+
updateTexture( texture, options ) {
|
|
221
230
|
|
|
222
231
|
const textureData = this.backend.get( texture );
|
|
223
232
|
|
|
224
|
-
const {
|
|
233
|
+
const { textureDescriptorGPU } = textureData;
|
|
225
234
|
|
|
226
|
-
if ( textureDescriptorGPU === undefined
|
|
235
|
+
if ( texture.isRenderTargetTexture || ( textureDescriptorGPU === undefined /* unsupported texture format */ ) )
|
|
227
236
|
return;
|
|
228
237
|
|
|
229
238
|
// transfer texture data
|
|
230
239
|
|
|
231
240
|
if ( texture.isDataTexture || texture.isDataArrayTexture || texture.isData3DTexture ) {
|
|
232
241
|
|
|
233
|
-
this._copyBufferToTexture(
|
|
242
|
+
this._copyBufferToTexture( options.image, textureData.texture, textureDescriptorGPU, 0, false );
|
|
234
243
|
|
|
235
244
|
} else if ( texture.isCompressedTexture ) {
|
|
236
245
|
|
|
@@ -238,15 +247,7 @@ class WebGPUTextureUtils {
|
|
|
238
247
|
|
|
239
248
|
} else if ( texture.isCubeTexture ) {
|
|
240
249
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
this._copyCubeMapToTexture( texture.image, texture, textureData.texture, textureDescriptorGPU, needsMipmaps );
|
|
244
|
-
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
} else if ( texture.isRenderTargetTexture ) {
|
|
248
|
-
|
|
249
|
-
if ( needsMipmaps === true ) this._generateMipmaps( textureData.texture, textureDescriptorGPU );
|
|
250
|
+
this._copyCubeMapToTexture( options.images, textureData.texture, textureDescriptorGPU, texture.flipY );
|
|
250
251
|
|
|
251
252
|
} else if ( texture.isVideoTexture ) {
|
|
252
253
|
|
|
@@ -254,13 +255,9 @@ class WebGPUTextureUtils {
|
|
|
254
255
|
|
|
255
256
|
textureData.externalTexture = video;
|
|
256
257
|
|
|
257
|
-
} else if ( texture.image !== null ) {
|
|
258
|
-
|
|
259
|
-
this._copyImageToTexture( texture.image, texture, textureData.texture, textureDescriptorGPU, needsMipmaps );
|
|
260
|
-
|
|
261
258
|
} else {
|
|
262
259
|
|
|
263
|
-
|
|
260
|
+
this._copyImageToTexture( options.image, textureData.texture, textureDescriptorGPU, 0, texture.flipY );
|
|
264
261
|
|
|
265
262
|
}
|
|
266
263
|
|
|
@@ -336,7 +333,7 @@ class WebGPUTextureUtils {
|
|
|
336
333
|
texture.minFilter = NearestFilter;
|
|
337
334
|
texture.magFilter = NearestFilter;
|
|
338
335
|
|
|
339
|
-
this.createTexture( texture );
|
|
336
|
+
this.createTexture( texture, { width: 1, height: 1 } );
|
|
340
337
|
|
|
341
338
|
this.defaultTexture = defaultTexture = texture;
|
|
342
339
|
|
|
@@ -356,7 +353,7 @@ class WebGPUTextureUtils {
|
|
|
356
353
|
texture.minFilter = NearestFilter;
|
|
357
354
|
texture.magFilter = NearestFilter;
|
|
358
355
|
|
|
359
|
-
this.createTexture( texture );
|
|
356
|
+
this.createTexture( texture, { width: 1, height: 1, depth: 6 } );
|
|
360
357
|
|
|
361
358
|
this.defaultCubeTexture = defaultCubeTexture = texture;
|
|
362
359
|
|
|
@@ -366,45 +363,21 @@ class WebGPUTextureUtils {
|
|
|
366
363
|
|
|
367
364
|
}
|
|
368
365
|
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
if ( this._isHTMLImage( image ) ) {
|
|
372
|
-
|
|
373
|
-
this._getImageBitmapFromHTML( image, texture ).then( imageBitmap => {
|
|
374
|
-
|
|
375
|
-
this._copyExternalImageToTexture( imageBitmap, textureGPU, textureDescriptorGPU, needsMipmaps, originDepth );
|
|
376
|
-
|
|
377
|
-
} );
|
|
378
|
-
|
|
379
|
-
} else {
|
|
380
|
-
|
|
381
|
-
// assume ImageBitmap
|
|
382
|
-
|
|
383
|
-
this._copyExternalImageToTexture( image, textureGPU, textureDescriptorGPU, needsMipmaps, originDepth );
|
|
384
|
-
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
_isHTMLImage( image ) {
|
|
390
|
-
|
|
391
|
-
return ( typeof HTMLImageElement !== 'undefined' && image instanceof HTMLImageElement ) || ( typeof HTMLCanvasElement !== 'undefined' && image instanceof HTMLCanvasElement );
|
|
392
|
-
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
_copyCubeMapToTexture( images, texture, textureGPU, textureDescriptorGPU, needsMipmaps ) {
|
|
366
|
+
_copyCubeMapToTexture( images, textureGPU, textureDescriptorGPU, flipY ) {
|
|
396
367
|
|
|
397
368
|
for ( let i = 0; i < 6; i ++ ) {
|
|
398
369
|
|
|
399
370
|
const image = images[ i ];
|
|
400
371
|
|
|
372
|
+
const flipIndex = flipY === true ? _flipMap[ i ] : i;
|
|
373
|
+
|
|
401
374
|
if ( image.isDataTexture ) {
|
|
402
375
|
|
|
403
|
-
this._copyBufferToTexture( image.image, textureGPU, textureDescriptorGPU,
|
|
376
|
+
this._copyBufferToTexture( image.image, textureGPU, textureDescriptorGPU, flipIndex, flipY );
|
|
404
377
|
|
|
405
378
|
} else {
|
|
406
379
|
|
|
407
|
-
this._copyImageToTexture( image,
|
|
380
|
+
this._copyImageToTexture( image, textureGPU, textureDescriptorGPU, flipIndex, flipY );
|
|
408
381
|
|
|
409
382
|
}
|
|
410
383
|
|
|
@@ -412,7 +385,7 @@ class WebGPUTextureUtils {
|
|
|
412
385
|
|
|
413
386
|
}
|
|
414
387
|
|
|
415
|
-
|
|
388
|
+
_copyImageToTexture( image, textureGPU, textureDescriptorGPU, originDepth, flipY ) {
|
|
416
389
|
|
|
417
390
|
const device = this.backend.device;
|
|
418
391
|
|
|
@@ -430,37 +403,41 @@ class WebGPUTextureUtils {
|
|
|
430
403
|
}
|
|
431
404
|
);
|
|
432
405
|
|
|
433
|
-
if (
|
|
406
|
+
if ( flipY === true ) {
|
|
407
|
+
|
|
408
|
+
this._flipY( textureGPU, textureDescriptorGPU, originDepth );
|
|
409
|
+
|
|
410
|
+
}
|
|
434
411
|
|
|
435
412
|
}
|
|
436
413
|
|
|
437
|
-
|
|
414
|
+
_getPassUtils() {
|
|
415
|
+
|
|
416
|
+
let passUtils = this._passUtils;
|
|
438
417
|
|
|
439
|
-
if (
|
|
418
|
+
if ( passUtils === null ) {
|
|
440
419
|
|
|
441
|
-
this.
|
|
420
|
+
this._passUtils = passUtils = new WebGPUTexturePassUtils( this.backend.device );
|
|
442
421
|
|
|
443
422
|
}
|
|
444
423
|
|
|
445
|
-
|
|
424
|
+
return passUtils;
|
|
446
425
|
|
|
447
426
|
}
|
|
448
427
|
|
|
449
|
-
|
|
428
|
+
_generateMipmaps( textureGPU, textureDescriptorGPU, baseArrayLayer = 0 ) {
|
|
450
429
|
|
|
451
|
-
|
|
452
|
-
const height = image.height;
|
|
430
|
+
this._getPassUtils().generateMipmaps( textureGPU, textureDescriptorGPU, baseArrayLayer );
|
|
453
431
|
|
|
454
|
-
|
|
432
|
+
}
|
|
455
433
|
|
|
456
|
-
|
|
457
|
-
options.premultiplyAlpha = ( texture.premultiplyAlpha === true ) ? 'premultiply' : 'default';
|
|
434
|
+
_flipY( textureGPU, textureDescriptorGPU, originDepth = 0 ) {
|
|
458
435
|
|
|
459
|
-
|
|
436
|
+
this._getPassUtils().flipY( textureGPU, textureDescriptorGPU, originDepth );
|
|
460
437
|
|
|
461
438
|
}
|
|
462
439
|
|
|
463
|
-
_copyBufferToTexture( image, textureGPU, textureDescriptorGPU,
|
|
440
|
+
_copyBufferToTexture( image, textureGPU, textureDescriptorGPU, originDepth, flipY ) {
|
|
464
441
|
|
|
465
442
|
// @TODO: Consider to use GPUCommandEncoder.copyBufferToTexture()
|
|
466
443
|
// @TODO: Consider to support valid buffer layouts with other formats like RGB
|
|
@@ -489,7 +466,11 @@ class WebGPUTextureUtils {
|
|
|
489
466
|
depthOrArrayLayers: ( image.depth !== undefined ) ? image.depth : 1
|
|
490
467
|
} );
|
|
491
468
|
|
|
492
|
-
if (
|
|
469
|
+
if ( flipY === true ) {
|
|
470
|
+
|
|
471
|
+
this._flipY( textureGPU, textureDescriptorGPU, originDepth );
|
|
472
|
+
|
|
473
|
+
}
|
|
493
474
|
|
|
494
475
|
}
|
|
495
476
|
|
|
@@ -600,44 +581,6 @@ class WebGPUTextureUtils {
|
|
|
600
581
|
|
|
601
582
|
}
|
|
602
583
|
|
|
603
|
-
_getSize( texture ) {
|
|
604
|
-
|
|
605
|
-
const image = texture.image;
|
|
606
|
-
|
|
607
|
-
let width, height, depth;
|
|
608
|
-
|
|
609
|
-
if ( texture.isCubeTexture ) {
|
|
610
|
-
|
|
611
|
-
const faceImage = image.length > 0 ? image[ 0 ].image || image[ 0 ] : null;
|
|
612
|
-
|
|
613
|
-
width = faceImage ? faceImage.width : 1;
|
|
614
|
-
height = faceImage ? faceImage.height : 1;
|
|
615
|
-
depth = 6; // one image for each side of the cube map
|
|
616
|
-
|
|
617
|
-
} else if ( image !== null ) {
|
|
618
|
-
|
|
619
|
-
width = image.width;
|
|
620
|
-
height = image.height;
|
|
621
|
-
depth = ( image.depth !== undefined ) ? image.depth : 1;
|
|
622
|
-
|
|
623
|
-
} else {
|
|
624
|
-
|
|
625
|
-
width = height = depth = 1;
|
|
626
|
-
|
|
627
|
-
}
|
|
628
|
-
|
|
629
|
-
return { width, height, depth };
|
|
630
|
-
|
|
631
|
-
}
|
|
632
|
-
|
|
633
|
-
_needsMipmaps( texture ) {
|
|
634
|
-
|
|
635
|
-
if ( this._isEnvironmentTexture( texture ) ) return true;
|
|
636
|
-
|
|
637
|
-
return ( texture.isCompressedTexture !== true ) /*&& ( texture.generateMipmaps === true )*/ && ( texture.minFilter !== NearestFilter ) && ( texture.minFilter !== LinearFilter );
|
|
638
|
-
|
|
639
|
-
}
|
|
640
|
-
|
|
641
584
|
_getBytesPerTexel( format ) {
|
|
642
585
|
|
|
643
586
|
if ( format === GPUTextureFormat.R8Unorm ) return 1;
|
|
@@ -706,259 +649,237 @@ class WebGPUTextureUtils {
|
|
|
706
649
|
|
|
707
650
|
}
|
|
708
651
|
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
let mipLevelCount;
|
|
712
|
-
|
|
713
|
-
if ( texture.isCompressedTexture ) {
|
|
714
|
-
|
|
715
|
-
mipLevelCount = texture.mipmaps.length;
|
|
716
|
-
|
|
717
|
-
} else if ( needsMipmaps ) {
|
|
718
|
-
|
|
719
|
-
mipLevelCount = Math.floor( Math.log2( Math.max( width, height ) ) ) + 1;
|
|
720
|
-
|
|
721
|
-
} else {
|
|
722
|
-
|
|
723
|
-
mipLevelCount = 1; // a texture without mipmaps has a base mip (mipLevel 0)
|
|
724
|
-
|
|
725
|
-
}
|
|
726
|
-
|
|
727
|
-
return mipLevelCount;
|
|
728
|
-
|
|
729
|
-
}
|
|
730
|
-
|
|
731
|
-
_getFormat( texture ) {
|
|
652
|
+
}
|
|
732
653
|
|
|
733
|
-
|
|
734
|
-
const type = texture.type;
|
|
735
|
-
const colorSpace = texture.colorSpace;
|
|
654
|
+
export function getFormat( texture, device = null ) {
|
|
736
655
|
|
|
737
|
-
|
|
656
|
+
const format = texture.format;
|
|
657
|
+
const type = texture.type;
|
|
658
|
+
const colorSpace = texture.colorSpace;
|
|
738
659
|
|
|
739
|
-
|
|
660
|
+
let formatGPU;
|
|
740
661
|
|
|
741
|
-
|
|
662
|
+
if ( /*texture.isRenderTargetTexture === true ||*/ texture.isFramebufferTexture === true ) {
|
|
742
663
|
|
|
743
|
-
|
|
664
|
+
formatGPU = GPUTextureFormat.BGRA8Unorm;
|
|
744
665
|
|
|
745
|
-
|
|
666
|
+
} else if ( texture.isCompressedTexture === true ) {
|
|
746
667
|
|
|
747
|
-
|
|
748
|
-
formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.BC1RGBAUnormSRGB : GPUTextureFormat.BC1RGBAUnorm;
|
|
749
|
-
break;
|
|
668
|
+
switch ( format ) {
|
|
750
669
|
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
670
|
+
case RGBA_S3TC_DXT1_Format:
|
|
671
|
+
formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.BC1RGBAUnormSRGB : GPUTextureFormat.BC1RGBAUnorm;
|
|
672
|
+
break;
|
|
754
673
|
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
674
|
+
case RGBA_S3TC_DXT3_Format:
|
|
675
|
+
formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.BC2RGBAUnormSRGB : GPUTextureFormat.BC2RGBAUnorm;
|
|
676
|
+
break;
|
|
758
677
|
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
678
|
+
case RGBA_S3TC_DXT5_Format:
|
|
679
|
+
formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.BC3RGBAUnormSRGB : GPUTextureFormat.BC3RGBAUnorm;
|
|
680
|
+
break;
|
|
762
681
|
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
682
|
+
case RGB_ETC2_Format:
|
|
683
|
+
formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ETC2RGB8UnormSRGB : GPUTextureFormat.ETC2RGB8Unorm;
|
|
684
|
+
break;
|
|
766
685
|
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
686
|
+
case RGBA_ETC2_EAC_Format:
|
|
687
|
+
formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ETC2RGBA8UnormSRGB : GPUTextureFormat.ETC2RGBA8Unorm;
|
|
688
|
+
break;
|
|
770
689
|
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
690
|
+
case RGBA_ASTC_4x4_Format:
|
|
691
|
+
formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ASTC4x4UnormSRGB : GPUTextureFormat.ASTC4x4Unorm;
|
|
692
|
+
break;
|
|
774
693
|
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
694
|
+
case RGBA_ASTC_5x4_Format:
|
|
695
|
+
formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ASTC5x4UnormSRGB : GPUTextureFormat.ASTC5x4Unorm;
|
|
696
|
+
break;
|
|
778
697
|
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
698
|
+
case RGBA_ASTC_5x5_Format:
|
|
699
|
+
formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ASTC5x5UnormSRGB : GPUTextureFormat.ASTC5x5Unorm;
|
|
700
|
+
break;
|
|
782
701
|
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
702
|
+
case RGBA_ASTC_6x5_Format:
|
|
703
|
+
formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ASTC6x5UnormSRGB : GPUTextureFormat.ASTC6x5Unorm;
|
|
704
|
+
break;
|
|
786
705
|
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
706
|
+
case RGBA_ASTC_6x6_Format:
|
|
707
|
+
formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ASTC6x6UnormSRGB : GPUTextureFormat.ASTC6x6Unorm;
|
|
708
|
+
break;
|
|
790
709
|
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
710
|
+
case RGBA_ASTC_8x5_Format:
|
|
711
|
+
formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ASTC8x5UnormSRGB : GPUTextureFormat.ASTC8x5Unorm;
|
|
712
|
+
break;
|
|
794
713
|
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
714
|
+
case RGBA_ASTC_8x6_Format:
|
|
715
|
+
formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ASTC8x6UnormSRGB : GPUTextureFormat.ASTC8x6Unorm;
|
|
716
|
+
break;
|
|
798
717
|
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
718
|
+
case RGBA_ASTC_8x8_Format:
|
|
719
|
+
formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ASTC8x8UnormSRGB : GPUTextureFormat.ASTC8x8Unorm;
|
|
720
|
+
break;
|
|
802
721
|
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
722
|
+
case RGBA_ASTC_10x5_Format:
|
|
723
|
+
formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ASTC10x5UnormSRGB : GPUTextureFormat.ASTC10x5Unorm;
|
|
724
|
+
break;
|
|
806
725
|
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
726
|
+
case RGBA_ASTC_10x6_Format:
|
|
727
|
+
formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ASTC10x6UnormSRGB : GPUTextureFormat.ASTC10x6Unorm;
|
|
728
|
+
break;
|
|
810
729
|
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
730
|
+
case RGBA_ASTC_10x8_Format:
|
|
731
|
+
formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ASTC10x8UnormSRGB : GPUTextureFormat.ASTC10x8Unorm;
|
|
732
|
+
break;
|
|
814
733
|
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
734
|
+
case RGBA_ASTC_10x10_Format:
|
|
735
|
+
formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ASTC10x10UnormSRGB : GPUTextureFormat.ASTC10x10Unorm;
|
|
736
|
+
break;
|
|
818
737
|
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
738
|
+
case RGBA_ASTC_12x10_Format:
|
|
739
|
+
formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ASTC12x10UnormSRGB : GPUTextureFormat.ASTC12x10Unorm;
|
|
740
|
+
break;
|
|
822
741
|
|
|
823
|
-
|
|
824
|
-
|
|
742
|
+
case RGBA_ASTC_12x12_Format:
|
|
743
|
+
formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ASTC12x12UnormSRGB : GPUTextureFormat.ASTC12x12Unorm;
|
|
744
|
+
break;
|
|
825
745
|
|
|
826
|
-
|
|
746
|
+
default:
|
|
747
|
+
console.error( 'WebGPURenderer: Unsupported texture format.', format );
|
|
827
748
|
|
|
828
|
-
}
|
|
749
|
+
}
|
|
829
750
|
|
|
830
|
-
|
|
751
|
+
} else {
|
|
831
752
|
|
|
832
|
-
|
|
753
|
+
switch ( format ) {
|
|
833
754
|
|
|
834
|
-
|
|
755
|
+
case RGBAFormat:
|
|
835
756
|
|
|
836
|
-
|
|
837
|
-
formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.RGBA8UnormSRGB : GPUTextureFormat.RGBA8Unorm;
|
|
838
|
-
break;
|
|
757
|
+
switch ( type ) {
|
|
839
758
|
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
759
|
+
case UnsignedByteType:
|
|
760
|
+
formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.RGBA8UnormSRGB : GPUTextureFormat.RGBA8Unorm;
|
|
761
|
+
break;
|
|
843
762
|
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
763
|
+
case HalfFloatType:
|
|
764
|
+
formatGPU = GPUTextureFormat.RGBA16Float;
|
|
765
|
+
break;
|
|
847
766
|
|
|
848
|
-
|
|
849
|
-
|
|
767
|
+
case FloatType:
|
|
768
|
+
formatGPU = GPUTextureFormat.RGBA32Float;
|
|
769
|
+
break;
|
|
850
770
|
|
|
851
|
-
|
|
771
|
+
default:
|
|
772
|
+
console.error( 'WebGPURenderer: Unsupported texture type with RGBAFormat.', type );
|
|
852
773
|
|
|
853
|
-
|
|
774
|
+
}
|
|
854
775
|
|
|
855
|
-
|
|
776
|
+
break;
|
|
856
777
|
|
|
857
|
-
|
|
778
|
+
case RedFormat:
|
|
858
779
|
|
|
859
|
-
|
|
860
|
-
formatGPU = GPUTextureFormat.R8Unorm;
|
|
861
|
-
break;
|
|
780
|
+
switch ( type ) {
|
|
862
781
|
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
782
|
+
case UnsignedByteType:
|
|
783
|
+
formatGPU = GPUTextureFormat.R8Unorm;
|
|
784
|
+
break;
|
|
866
785
|
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
786
|
+
case HalfFloatType:
|
|
787
|
+
formatGPU = GPUTextureFormat.R16Float;
|
|
788
|
+
break;
|
|
870
789
|
|
|
871
|
-
|
|
872
|
-
|
|
790
|
+
case FloatType:
|
|
791
|
+
formatGPU = GPUTextureFormat.R32Float;
|
|
792
|
+
break;
|
|
873
793
|
|
|
874
|
-
|
|
794
|
+
default:
|
|
795
|
+
console.error( 'WebGPURenderer: Unsupported texture type with RedFormat.', type );
|
|
875
796
|
|
|
876
|
-
|
|
797
|
+
}
|
|
877
798
|
|
|
878
|
-
|
|
799
|
+
break;
|
|
879
800
|
|
|
880
|
-
|
|
801
|
+
case RGFormat:
|
|
881
802
|
|
|
882
|
-
|
|
883
|
-
formatGPU = GPUTextureFormat.RG8Unorm;
|
|
884
|
-
break;
|
|
803
|
+
switch ( type ) {
|
|
885
804
|
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
805
|
+
case UnsignedByteType:
|
|
806
|
+
formatGPU = GPUTextureFormat.RG8Unorm;
|
|
807
|
+
break;
|
|
889
808
|
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
809
|
+
case HalfFloatType:
|
|
810
|
+
formatGPU = GPUTextureFormat.RG16Float;
|
|
811
|
+
break;
|
|
893
812
|
|
|
894
|
-
|
|
895
|
-
|
|
813
|
+
case FloatType:
|
|
814
|
+
formatGPU = GPUTextureFormat.RG32Float;
|
|
815
|
+
break;
|
|
896
816
|
|
|
897
|
-
|
|
817
|
+
default:
|
|
818
|
+
console.error( 'WebGPURenderer: Unsupported texture type with RGFormat.', type );
|
|
898
819
|
|
|
899
|
-
|
|
820
|
+
}
|
|
900
821
|
|
|
901
|
-
|
|
822
|
+
break;
|
|
902
823
|
|
|
903
|
-
|
|
824
|
+
case DepthFormat:
|
|
904
825
|
|
|
905
|
-
|
|
906
|
-
formatGPU = GPUTextureFormat.Depth16Unorm;
|
|
907
|
-
break;
|
|
826
|
+
switch ( type ) {
|
|
908
827
|
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
828
|
+
case UnsignedShortType:
|
|
829
|
+
formatGPU = GPUTextureFormat.Depth16Unorm;
|
|
830
|
+
break;
|
|
912
831
|
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
832
|
+
case UnsignedIntType:
|
|
833
|
+
formatGPU = GPUTextureFormat.Depth24Plus;
|
|
834
|
+
break;
|
|
916
835
|
|
|
917
|
-
|
|
918
|
-
|
|
836
|
+
case FloatType:
|
|
837
|
+
formatGPU = GPUTextureFormat.Depth32Float;
|
|
838
|
+
break;
|
|
919
839
|
|
|
920
|
-
|
|
840
|
+
default:
|
|
841
|
+
console.error( 'WebGPURenderer: Unsupported texture type with DepthFormat.', type );
|
|
921
842
|
|
|
922
|
-
|
|
843
|
+
}
|
|
923
844
|
|
|
924
|
-
|
|
845
|
+
break;
|
|
925
846
|
|
|
926
|
-
|
|
847
|
+
case DepthStencilFormat:
|
|
927
848
|
|
|
928
|
-
|
|
929
|
-
formatGPU = GPUTextureFormat.Depth24PlusStencil8;
|
|
930
|
-
break;
|
|
849
|
+
switch ( type ) {
|
|
931
850
|
|
|
932
|
-
|
|
851
|
+
case UnsignedInt248Type:
|
|
852
|
+
formatGPU = GPUTextureFormat.Depth24PlusStencil8;
|
|
853
|
+
break;
|
|
933
854
|
|
|
934
|
-
|
|
855
|
+
case FloatType:
|
|
935
856
|
|
|
936
|
-
|
|
857
|
+
if ( device && device.features.has( GPUFeatureName.Depth32FloatStencil8 ) === false ) {
|
|
937
858
|
|
|
938
|
-
|
|
859
|
+
console.error( 'WebGPURenderer: Depth textures with DepthStencilFormat + FloatType can only be used with the "depth32float-stencil8" GPU feature.' );
|
|
939
860
|
|
|
940
|
-
|
|
861
|
+
}
|
|
941
862
|
|
|
942
|
-
|
|
863
|
+
formatGPU = GPUTextureFormat.Depth32FloatStencil8;
|
|
943
864
|
|
|
944
|
-
|
|
945
|
-
console.error( 'WebGPURenderer: Unsupported texture type with DepthStencilFormat.', type );
|
|
865
|
+
break;
|
|
946
866
|
|
|
947
|
-
|
|
867
|
+
default:
|
|
868
|
+
console.error( 'WebGPURenderer: Unsupported texture type with DepthStencilFormat.', type );
|
|
948
869
|
|
|
949
|
-
|
|
870
|
+
}
|
|
950
871
|
|
|
951
|
-
|
|
952
|
-
console.error( 'WebGPURenderer: Unsupported texture format.', format );
|
|
872
|
+
break;
|
|
953
873
|
|
|
954
|
-
|
|
874
|
+
default:
|
|
875
|
+
console.error( 'WebGPURenderer: Unsupported texture format.', format );
|
|
955
876
|
|
|
956
877
|
}
|
|
957
878
|
|
|
958
|
-
return formatGPU;
|
|
959
|
-
|
|
960
879
|
}
|
|
961
880
|
|
|
881
|
+
return formatGPU;
|
|
882
|
+
|
|
962
883
|
}
|
|
963
884
|
|
|
964
885
|
export default WebGPUTextureUtils;
|