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
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { WebGLUniforms } from './WebGLUniforms.js';
|
|
2
2
|
import { WebGLShader } from './WebGLShader.js';
|
|
3
3
|
import { ShaderChunk } from '../shaders/ShaderChunk.js';
|
|
4
|
-
import { NoToneMapping, AddOperation, MixOperation, MultiplyOperation, CubeRefractionMapping, CubeUVReflectionMapping, CubeReflectionMapping, PCFSoftShadowMap, PCFShadowMap, VSMShadowMap, ACESFilmicToneMapping, CineonToneMapping, CustomToneMapping, ReinhardToneMapping, LinearToneMapping, GLSL3, LinearSRGBColorSpace, SRGBColorSpace } from '../../constants.js';
|
|
4
|
+
import { NoToneMapping, AddOperation, MixOperation, MultiplyOperation, CubeRefractionMapping, CubeUVReflectionMapping, CubeReflectionMapping, PCFSoftShadowMap, PCFShadowMap, VSMShadowMap, ACESFilmicToneMapping, CineonToneMapping, CustomToneMapping, ReinhardToneMapping, LinearToneMapping, GLSL3, LinearSRGBColorSpace, SRGBColorSpace, LinearDisplayP3ColorSpace, DisplayP3ColorSpace, P3Primaries, Rec709Primaries } from '../../constants.js';
|
|
5
|
+
import { ColorManagement } from '../../math/ColorManagement.js';
|
|
5
6
|
|
|
6
7
|
let programIdCount = 0;
|
|
7
8
|
|
|
@@ -26,15 +27,38 @@ function handleSource( string, errorLine ) {
|
|
|
26
27
|
|
|
27
28
|
function getEncodingComponents( colorSpace ) {
|
|
28
29
|
|
|
30
|
+
const workingPrimaries = ColorManagement.getPrimaries( ColorManagement.workingColorSpace );
|
|
31
|
+
const encodingPrimaries = ColorManagement.getPrimaries( colorSpace );
|
|
32
|
+
|
|
33
|
+
let gamutMapping;
|
|
34
|
+
|
|
35
|
+
if ( workingPrimaries === encodingPrimaries ) {
|
|
36
|
+
|
|
37
|
+
gamutMapping = '';
|
|
38
|
+
|
|
39
|
+
} else if ( workingPrimaries === P3Primaries && encodingPrimaries === Rec709Primaries ) {
|
|
40
|
+
|
|
41
|
+
gamutMapping = 'LinearDisplayP3ToLinearSRGB';
|
|
42
|
+
|
|
43
|
+
} else if ( workingPrimaries === Rec709Primaries && encodingPrimaries === P3Primaries ) {
|
|
44
|
+
|
|
45
|
+
gamutMapping = 'LinearSRGBToLinearDisplayP3';
|
|
46
|
+
|
|
47
|
+
}
|
|
48
|
+
|
|
29
49
|
switch ( colorSpace ) {
|
|
30
50
|
|
|
31
51
|
case LinearSRGBColorSpace:
|
|
32
|
-
|
|
52
|
+
case LinearDisplayP3ColorSpace:
|
|
53
|
+
return [ gamutMapping, 'LinearTransferOETF' ];
|
|
54
|
+
|
|
33
55
|
case SRGBColorSpace:
|
|
34
|
-
|
|
56
|
+
case DisplayP3ColorSpace:
|
|
57
|
+
return [ gamutMapping, 'sRGBTransferOETF' ];
|
|
58
|
+
|
|
35
59
|
default:
|
|
36
60
|
console.warn( 'THREE.WebGLProgram: Unsupported color space:', colorSpace );
|
|
37
|
-
return [
|
|
61
|
+
return [ gamutMapping, 'LinearTransferOETF' ];
|
|
38
62
|
|
|
39
63
|
}
|
|
40
64
|
|
|
@@ -67,7 +91,7 @@ function getShaderErrors( gl, shader, type ) {
|
|
|
67
91
|
function getTexelEncodingFunction( functionName, colorSpace ) {
|
|
68
92
|
|
|
69
93
|
const components = getEncodingComponents( colorSpace );
|
|
70
|
-
return
|
|
94
|
+
return `vec4 ${functionName}( vec4 value ) { return ${components[ 0 ]}( ${components[ 1 ]}( value ) ); }`;
|
|
71
95
|
|
|
72
96
|
}
|
|
73
97
|
|
|
@@ -494,6 +518,7 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
|
|
|
494
518
|
parameters.displacementMap ? '#define USE_DISPLACEMENTMAP' : '',
|
|
495
519
|
parameters.emissiveMap ? '#define USE_EMISSIVEMAP' : '',
|
|
496
520
|
|
|
521
|
+
parameters.anisotropy ? '#define USE_ANISOTROPY' : '',
|
|
497
522
|
parameters.anisotropyMap ? '#define USE_ANISOTROPYMAP' : '',
|
|
498
523
|
|
|
499
524
|
parameters.clearcoatMap ? '#define USE_CLEARCOATMAP' : '',
|
|
@@ -581,6 +606,8 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
|
|
|
581
606
|
|
|
582
607
|
parameters.sizeAttenuation ? '#define USE_SIZEATTENUATION' : '',
|
|
583
608
|
|
|
609
|
+
parameters.numLightProbes > 0 ? '#define USE_LIGHT_PROBES' : '',
|
|
610
|
+
|
|
584
611
|
parameters.useLegacyLights ? '#define LEGACY_LIGHTS' : '',
|
|
585
612
|
|
|
586
613
|
parameters.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '',
|
|
@@ -763,8 +790,12 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
|
|
|
763
790
|
|
|
764
791
|
parameters.premultipliedAlpha ? '#define PREMULTIPLIED_ALPHA' : '',
|
|
765
792
|
|
|
793
|
+
parameters.numLightProbes > 0 ? '#define USE_LIGHT_PROBES' : '',
|
|
794
|
+
|
|
766
795
|
parameters.useLegacyLights ? '#define LEGACY_LIGHTS' : '',
|
|
767
796
|
|
|
797
|
+
parameters.decodeVideoTexture ? '#define DECODE_VIDEO_TEXTURE' : '',
|
|
798
|
+
|
|
768
799
|
parameters.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '',
|
|
769
800
|
( parameters.logarithmicDepthBuffer && parameters.rendererExtensionFragDepth ) ? '#define USE_LOGDEPTHBUF_EXT' : '',
|
|
770
801
|
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { BackSide, DoubleSide, CubeUVReflectionMapping, ObjectSpaceNormalMap, TangentSpaceNormalMap, NoToneMapping, NormalBlending, LinearSRGBColorSpace } from '../../constants.js';
|
|
1
|
+
import { BackSide, DoubleSide, CubeUVReflectionMapping, ObjectSpaceNormalMap, TangentSpaceNormalMap, NoToneMapping, NormalBlending, LinearSRGBColorSpace, SRGBTransfer } from '../../constants.js';
|
|
2
2
|
import { Layers } from '../../core/Layers.js';
|
|
3
3
|
import { WebGLProgram } from './WebGLProgram.js';
|
|
4
4
|
import { WebGLShaderCache } from './WebGLShaderCache.js';
|
|
5
5
|
import { ShaderLib } from '../shaders/ShaderLib.js';
|
|
6
6
|
import { UniformsUtils } from '../shaders/UniformsUtils.js';
|
|
7
|
+
import { ColorManagement } from '../../math/ColorManagement.js';
|
|
7
8
|
|
|
8
9
|
function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities, bindingStates, clipping ) {
|
|
9
10
|
|
|
@@ -324,6 +325,8 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
|
|
|
324
325
|
numSpotLightShadows: lights.spotShadowMap.length,
|
|
325
326
|
numSpotLightShadowsWithMaps: lights.numSpotLightShadowsWithMaps,
|
|
326
327
|
|
|
328
|
+
numLightProbes: lights.numLightProbes,
|
|
329
|
+
|
|
327
330
|
numClippingPlanes: clipping.numPlanes,
|
|
328
331
|
numClipIntersection: clipping.numIntersection,
|
|
329
332
|
|
|
@@ -335,6 +338,8 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
|
|
|
335
338
|
toneMapping: toneMapping,
|
|
336
339
|
useLegacyLights: renderer._useLegacyLights,
|
|
337
340
|
|
|
341
|
+
decodeVideoTexture: HAS_MAP && ( material.map.isVideoTexture === true ) && ( ColorManagement.getTransfer( material.map.colorSpace ) === SRGBTransfer ),
|
|
342
|
+
|
|
338
343
|
premultipliedAlpha: material.premultipliedAlpha,
|
|
339
344
|
|
|
340
345
|
doubleSided: material.side === DoubleSide,
|
|
@@ -446,6 +451,7 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
|
|
|
446
451
|
array.push( parameters.numPointLightShadows );
|
|
447
452
|
array.push( parameters.numSpotLightShadows );
|
|
448
453
|
array.push( parameters.numSpotLightShadowsWithMaps );
|
|
454
|
+
array.push( parameters.numLightProbes );
|
|
449
455
|
array.push( parameters.shadowMapType );
|
|
450
456
|
array.push( parameters.toneMapping );
|
|
451
457
|
array.push( parameters.numClippingPlanes );
|
|
@@ -536,6 +542,8 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
|
|
|
536
542
|
_programLayers.enable( 17 );
|
|
537
543
|
if ( parameters.pointsUvs )
|
|
538
544
|
_programLayers.enable( 18 );
|
|
545
|
+
if ( parameters.decodeVideoTexture )
|
|
546
|
+
_programLayers.enable( 19 );
|
|
539
547
|
|
|
540
548
|
array.push( _programLayers.mask );
|
|
541
549
|
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { LinearFilter, LinearMipmapLinearFilter, LinearMipmapNearestFilter, NearestFilter, NearestMipmapLinearFilter, NearestMipmapNearestFilter, RGBAFormat, DepthFormat, DepthStencilFormat, UnsignedShortType, UnsignedIntType, UnsignedInt248Type, FloatType, HalfFloatType, MirroredRepeatWrapping, ClampToEdgeWrapping, RepeatWrapping, UnsignedByteType, _SRGBAFormat, NoColorSpace, LinearSRGBColorSpace,
|
|
1
|
+
import { LinearFilter, LinearMipmapLinearFilter, LinearMipmapNearestFilter, NearestFilter, NearestMipmapLinearFilter, NearestMipmapNearestFilter, RGBAFormat, DepthFormat, DepthStencilFormat, UnsignedShortType, UnsignedIntType, UnsignedInt248Type, FloatType, HalfFloatType, MirroredRepeatWrapping, ClampToEdgeWrapping, RepeatWrapping, UnsignedByteType, _SRGBAFormat, NoColorSpace, LinearSRGBColorSpace, NeverCompare, AlwaysCompare, LessCompare, LessEqualCompare, EqualCompare, GreaterEqualCompare, GreaterCompare, NotEqualCompare, SRGBTransfer, LinearTransfer } from '../../constants.js';
|
|
2
2
|
import * as MathUtils from '../../math/MathUtils.js';
|
|
3
3
|
import { ImageUtils } from '../../extras/ImageUtils.js';
|
|
4
4
|
import { createElementNS } from '../../utils.js';
|
|
5
|
+
import { ColorManagement } from '../../math/ColorManagement.js';
|
|
5
6
|
|
|
6
7
|
function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, info ) {
|
|
7
8
|
|
|
@@ -178,9 +179,11 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
178
179
|
|
|
179
180
|
if ( glFormat === _gl.RGBA ) {
|
|
180
181
|
|
|
182
|
+
const transfer = forceLinearTransfer ? LinearTransfer : ColorManagement.getTransfer( colorSpace );
|
|
183
|
+
|
|
181
184
|
if ( glType === _gl.FLOAT ) internalFormat = _gl.RGBA32F;
|
|
182
185
|
if ( glType === _gl.HALF_FLOAT ) internalFormat = _gl.RGBA16F;
|
|
183
|
-
if ( glType === _gl.UNSIGNED_BYTE ) internalFormat = (
|
|
186
|
+
if ( glType === _gl.UNSIGNED_BYTE ) internalFormat = ( transfer === SRGBTransfer ) ? _gl.SRGB8_ALPHA8 : _gl.RGBA8;
|
|
184
187
|
if ( glType === _gl.UNSIGNED_SHORT_4_4_4_4 ) internalFormat = _gl.RGBA4;
|
|
185
188
|
if ( glType === _gl.UNSIGNED_SHORT_5_5_5_1 ) internalFormat = _gl.RGB5_A1;
|
|
186
189
|
|
|
@@ -735,10 +738,14 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
735
738
|
|
|
736
739
|
state.activeTexture( _gl.TEXTURE0 + slot );
|
|
737
740
|
|
|
741
|
+
const workingPrimaries = ColorManagement.getPrimaries( ColorManagement.workingColorSpace );
|
|
742
|
+
const texturePrimaries = texture.colorSpace === NoColorSpace ? null : ColorManagement.getPrimaries( texture.colorSpace );
|
|
743
|
+
const unpackConversion = texture.colorSpace === NoColorSpace || workingPrimaries === texturePrimaries ? _gl.NONE : _gl.BROWSER_DEFAULT_WEBGL;
|
|
744
|
+
|
|
738
745
|
_gl.pixelStorei( _gl.UNPACK_FLIP_Y_WEBGL, texture.flipY );
|
|
739
746
|
_gl.pixelStorei( _gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, texture.premultiplyAlpha );
|
|
740
747
|
_gl.pixelStorei( _gl.UNPACK_ALIGNMENT, texture.unpackAlignment );
|
|
741
|
-
_gl.pixelStorei( _gl.UNPACK_COLORSPACE_CONVERSION_WEBGL,
|
|
748
|
+
_gl.pixelStorei( _gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, unpackConversion );
|
|
742
749
|
|
|
743
750
|
const needsPowerOfTwo = textureNeedsPowerOfTwo( texture ) && isPowerOfTwo( texture.image ) === false;
|
|
744
751
|
let image = resizeImage( texture.image, needsPowerOfTwo, false, maxTextureSize );
|
|
@@ -748,7 +755,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
748
755
|
glFormat = utils.convert( texture.format, texture.colorSpace );
|
|
749
756
|
|
|
750
757
|
let glType = utils.convert( texture.type ),
|
|
751
|
-
glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.colorSpace );
|
|
758
|
+
glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.colorSpace, texture.isVideoTexture );
|
|
752
759
|
|
|
753
760
|
setTextureParameters( textureType, texture, supportsMips );
|
|
754
761
|
|
|
@@ -1149,10 +1156,14 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1149
1156
|
|
|
1150
1157
|
state.activeTexture( _gl.TEXTURE0 + slot );
|
|
1151
1158
|
|
|
1159
|
+
const workingPrimaries = ColorManagement.getPrimaries( ColorManagement.workingColorSpace );
|
|
1160
|
+
const texturePrimaries = texture.colorSpace === NoColorSpace ? null : ColorManagement.getPrimaries( texture.colorSpace );
|
|
1161
|
+
const unpackConversion = texture.colorSpace === NoColorSpace || workingPrimaries === texturePrimaries ? _gl.NONE : _gl.BROWSER_DEFAULT_WEBGL;
|
|
1162
|
+
|
|
1152
1163
|
_gl.pixelStorei( _gl.UNPACK_FLIP_Y_WEBGL, texture.flipY );
|
|
1153
1164
|
_gl.pixelStorei( _gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, texture.premultiplyAlpha );
|
|
1154
1165
|
_gl.pixelStorei( _gl.UNPACK_ALIGNMENT, texture.unpackAlignment );
|
|
1155
|
-
_gl.pixelStorei( _gl.UNPACK_COLORSPACE_CONVERSION_WEBGL,
|
|
1166
|
+
_gl.pixelStorei( _gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, unpackConversion );
|
|
1156
1167
|
|
|
1157
1168
|
const isCompressed = ( texture.isCompressedTexture || texture.image[ 0 ].isCompressedTexture );
|
|
1158
1169
|
const isDataTexture = ( texture.image[ 0 ] && texture.image[ 0 ].isDataTexture );
|
|
@@ -1392,7 +1403,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1392
1403
|
|
|
1393
1404
|
if ( renderTarget.depthBuffer && ! renderTarget.stencilBuffer ) {
|
|
1394
1405
|
|
|
1395
|
-
let glInternalFormat = _gl.DEPTH_COMPONENT16;
|
|
1406
|
+
let glInternalFormat = ( isWebGL2 === true ) ? _gl.DEPTH_COMPONENT24 : _gl.DEPTH_COMPONENT16;
|
|
1396
1407
|
|
|
1397
1408
|
if ( isMultisample || useMultisampledRTT( renderTarget ) ) {
|
|
1398
1409
|
|
|
@@ -2027,13 +2038,13 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
2027
2038
|
const format = texture.format;
|
|
2028
2039
|
const type = texture.type;
|
|
2029
2040
|
|
|
2030
|
-
if ( texture.isCompressedTexture === true || texture.format === _SRGBAFormat ) return image;
|
|
2041
|
+
if ( texture.isCompressedTexture === true || texture.isVideoTexture === true || texture.format === _SRGBAFormat ) return image;
|
|
2031
2042
|
|
|
2032
2043
|
if ( colorSpace !== LinearSRGBColorSpace && colorSpace !== NoColorSpace ) {
|
|
2033
2044
|
|
|
2034
2045
|
// sRGB
|
|
2035
2046
|
|
|
2036
|
-
if ( colorSpace ===
|
|
2047
|
+
if ( ColorManagement.getTransfer( colorSpace ) === SRGBTransfer ) {
|
|
2037
2048
|
|
|
2038
2049
|
if ( isWebGL2 === false ) {
|
|
2039
2050
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { RGBA_ASTC_4x4_Format, RGBA_ASTC_5x4_Format, RGBA_ASTC_5x5_Format, RGBA_ASTC_6x5_Format, RGBA_ASTC_6x6_Format, RGBA_ASTC_8x5_Format, RGBA_ASTC_8x6_Format, RGBA_ASTC_8x8_Format, RGBA_ASTC_10x5_Format, RGBA_ASTC_10x6_Format, RGBA_ASTC_10x8_Format, RGBA_ASTC_10x10_Format, RGBA_ASTC_12x10_Format, RGBA_ASTC_12x12_Format, RGB_ETC1_Format, RGB_ETC2_Format, RGBA_ETC2_EAC_Format, RGBA_PVRTC_2BPPV1_Format, RGBA_PVRTC_4BPPV1_Format, RGB_PVRTC_2BPPV1_Format, RGB_PVRTC_4BPPV1_Format, RGBA_S3TC_DXT5_Format, RGBA_S3TC_DXT3_Format, RGBA_S3TC_DXT1_Format, RGB_S3TC_DXT1_Format, DepthFormat, DepthStencilFormat, LuminanceAlphaFormat, LuminanceFormat, RedFormat, RGBAFormat, AlphaFormat, RedIntegerFormat, RGFormat, RGIntegerFormat, RGBAIntegerFormat, HalfFloatType, FloatType, UnsignedIntType, IntType, UnsignedShortType, ShortType, ByteType, UnsignedInt248Type, UnsignedShort5551Type, UnsignedShort4444Type, UnsignedByteType, RGBA_BPTC_Format, _SRGBAFormat, RED_RGTC1_Format, SIGNED_RED_RGTC1_Format, RED_GREEN_RGTC2_Format, SIGNED_RED_GREEN_RGTC2_Format,
|
|
1
|
+
import { RGBA_ASTC_4x4_Format, RGBA_ASTC_5x4_Format, RGBA_ASTC_5x5_Format, RGBA_ASTC_6x5_Format, RGBA_ASTC_6x6_Format, RGBA_ASTC_8x5_Format, RGBA_ASTC_8x6_Format, RGBA_ASTC_8x8_Format, RGBA_ASTC_10x5_Format, RGBA_ASTC_10x6_Format, RGBA_ASTC_10x8_Format, RGBA_ASTC_10x10_Format, RGBA_ASTC_12x10_Format, RGBA_ASTC_12x12_Format, RGB_ETC1_Format, RGB_ETC2_Format, RGBA_ETC2_EAC_Format, RGBA_PVRTC_2BPPV1_Format, RGBA_PVRTC_4BPPV1_Format, RGB_PVRTC_2BPPV1_Format, RGB_PVRTC_4BPPV1_Format, RGBA_S3TC_DXT5_Format, RGBA_S3TC_DXT3_Format, RGBA_S3TC_DXT1_Format, RGB_S3TC_DXT1_Format, DepthFormat, DepthStencilFormat, LuminanceAlphaFormat, LuminanceFormat, RedFormat, RGBAFormat, AlphaFormat, RedIntegerFormat, RGFormat, RGIntegerFormat, RGBAIntegerFormat, HalfFloatType, FloatType, UnsignedIntType, IntType, UnsignedShortType, ShortType, ByteType, UnsignedInt248Type, UnsignedShort5551Type, UnsignedShort4444Type, UnsignedByteType, RGBA_BPTC_Format, RGB_BPTC_SIGNED_Format, RGB_BPTC_UNSIGNED_Format, _SRGBAFormat, RED_RGTC1_Format, SIGNED_RED_RGTC1_Format, RED_GREEN_RGTC2_Format, SIGNED_RED_GREEN_RGTC2_Format, NoColorSpace, SRGBTransfer } from '../../constants.js';
|
|
2
|
+
import { ColorManagement } from '../../math/ColorManagement.js';
|
|
2
3
|
|
|
3
4
|
function WebGLUtils( gl, extensions, capabilities ) {
|
|
4
5
|
|
|
@@ -8,6 +9,8 @@ function WebGLUtils( gl, extensions, capabilities ) {
|
|
|
8
9
|
|
|
9
10
|
let extension;
|
|
10
11
|
|
|
12
|
+
const transfer = ColorManagement.getTransfer( colorSpace );
|
|
13
|
+
|
|
11
14
|
if ( p === UnsignedByteType ) return gl.UNSIGNED_BYTE;
|
|
12
15
|
if ( p === UnsignedShort4444Type ) return gl.UNSIGNED_SHORT_4_4_4_4;
|
|
13
16
|
if ( p === UnsignedShort5551Type ) return gl.UNSIGNED_SHORT_5_5_5_1;
|
|
@@ -74,7 +77,7 @@ function WebGLUtils( gl, extensions, capabilities ) {
|
|
|
74
77
|
|
|
75
78
|
if ( p === RGB_S3TC_DXT1_Format || p === RGBA_S3TC_DXT1_Format || p === RGBA_S3TC_DXT3_Format || p === RGBA_S3TC_DXT5_Format ) {
|
|
76
79
|
|
|
77
|
-
if (
|
|
80
|
+
if ( transfer === SRGBTransfer ) {
|
|
78
81
|
|
|
79
82
|
extension = extensions.get( 'WEBGL_compressed_texture_s3tc_srgb' );
|
|
80
83
|
|
|
@@ -159,8 +162,8 @@ function WebGLUtils( gl, extensions, capabilities ) {
|
|
|
159
162
|
|
|
160
163
|
if ( extension !== null ) {
|
|
161
164
|
|
|
162
|
-
if ( p === RGB_ETC2_Format ) return (
|
|
163
|
-
if ( p === RGBA_ETC2_EAC_Format ) return (
|
|
165
|
+
if ( p === RGB_ETC2_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB8_ETC2 : extension.COMPRESSED_RGB8_ETC2;
|
|
166
|
+
if ( p === RGBA_ETC2_EAC_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC : extension.COMPRESSED_RGBA8_ETC2_EAC;
|
|
164
167
|
|
|
165
168
|
} else {
|
|
166
169
|
|
|
@@ -182,20 +185,20 @@ function WebGLUtils( gl, extensions, capabilities ) {
|
|
|
182
185
|
|
|
183
186
|
if ( extension !== null ) {
|
|
184
187
|
|
|
185
|
-
if ( p === RGBA_ASTC_4x4_Format ) return (
|
|
186
|
-
if ( p === RGBA_ASTC_5x4_Format ) return (
|
|
187
|
-
if ( p === RGBA_ASTC_5x5_Format ) return (
|
|
188
|
-
if ( p === RGBA_ASTC_6x5_Format ) return (
|
|
189
|
-
if ( p === RGBA_ASTC_6x6_Format ) return (
|
|
190
|
-
if ( p === RGBA_ASTC_8x5_Format ) return (
|
|
191
|
-
if ( p === RGBA_ASTC_8x6_Format ) return (
|
|
192
|
-
if ( p === RGBA_ASTC_8x8_Format ) return (
|
|
193
|
-
if ( p === RGBA_ASTC_10x5_Format ) return (
|
|
194
|
-
if ( p === RGBA_ASTC_10x6_Format ) return (
|
|
195
|
-
if ( p === RGBA_ASTC_10x8_Format ) return (
|
|
196
|
-
if ( p === RGBA_ASTC_10x10_Format ) return (
|
|
197
|
-
if ( p === RGBA_ASTC_12x10_Format ) return (
|
|
198
|
-
if ( p === RGBA_ASTC_12x12_Format ) return (
|
|
188
|
+
if ( p === RGBA_ASTC_4x4_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR : extension.COMPRESSED_RGBA_ASTC_4x4_KHR;
|
|
189
|
+
if ( p === RGBA_ASTC_5x4_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR : extension.COMPRESSED_RGBA_ASTC_5x4_KHR;
|
|
190
|
+
if ( p === RGBA_ASTC_5x5_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR : extension.COMPRESSED_RGBA_ASTC_5x5_KHR;
|
|
191
|
+
if ( p === RGBA_ASTC_6x5_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR : extension.COMPRESSED_RGBA_ASTC_6x5_KHR;
|
|
192
|
+
if ( p === RGBA_ASTC_6x6_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR : extension.COMPRESSED_RGBA_ASTC_6x6_KHR;
|
|
193
|
+
if ( p === RGBA_ASTC_8x5_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR : extension.COMPRESSED_RGBA_ASTC_8x5_KHR;
|
|
194
|
+
if ( p === RGBA_ASTC_8x6_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR : extension.COMPRESSED_RGBA_ASTC_8x6_KHR;
|
|
195
|
+
if ( p === RGBA_ASTC_8x8_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR : extension.COMPRESSED_RGBA_ASTC_8x8_KHR;
|
|
196
|
+
if ( p === RGBA_ASTC_10x5_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR : extension.COMPRESSED_RGBA_ASTC_10x5_KHR;
|
|
197
|
+
if ( p === RGBA_ASTC_10x6_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR : extension.COMPRESSED_RGBA_ASTC_10x6_KHR;
|
|
198
|
+
if ( p === RGBA_ASTC_10x8_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR : extension.COMPRESSED_RGBA_ASTC_10x8_KHR;
|
|
199
|
+
if ( p === RGBA_ASTC_10x10_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR : extension.COMPRESSED_RGBA_ASTC_10x10_KHR;
|
|
200
|
+
if ( p === RGBA_ASTC_12x10_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR : extension.COMPRESSED_RGBA_ASTC_12x10_KHR;
|
|
201
|
+
if ( p === RGBA_ASTC_12x12_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR : extension.COMPRESSED_RGBA_ASTC_12x12_KHR;
|
|
199
202
|
|
|
200
203
|
} else {
|
|
201
204
|
|
|
@@ -207,13 +210,15 @@ function WebGLUtils( gl, extensions, capabilities ) {
|
|
|
207
210
|
|
|
208
211
|
// BPTC
|
|
209
212
|
|
|
210
|
-
if ( p === RGBA_BPTC_Format ) {
|
|
213
|
+
if ( p === RGBA_BPTC_Format || p === RGB_BPTC_SIGNED_Format || p === RGB_BPTC_UNSIGNED_Format ) {
|
|
211
214
|
|
|
212
215
|
extension = extensions.get( 'EXT_texture_compression_bptc' );
|
|
213
216
|
|
|
214
217
|
if ( extension !== null ) {
|
|
215
218
|
|
|
216
|
-
if ( p === RGBA_BPTC_Format ) return (
|
|
219
|
+
if ( p === RGBA_BPTC_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT : extension.COMPRESSED_RGBA_BPTC_UNORM_EXT;
|
|
220
|
+
if ( p === RGB_BPTC_SIGNED_Format ) return extension.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;
|
|
221
|
+
if ( p === RGB_BPTC_UNSIGNED_Format ) return extension.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT;
|
|
217
222
|
|
|
218
223
|
} else {
|
|
219
224
|
|
package/src/scenes/Fog.js
CHANGED
package/src/scenes/FogExp2.js
CHANGED
package/src/textures/Source.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ImageUtils } from '../extras/ImageUtils.js';
|
|
2
2
|
import * as MathUtils from '../math/MathUtils.js';
|
|
3
3
|
|
|
4
|
-
let
|
|
4
|
+
let _sourceId = 0;
|
|
5
5
|
|
|
6
6
|
class Source {
|
|
7
7
|
|
|
@@ -9,7 +9,7 @@ class Source {
|
|
|
9
9
|
|
|
10
10
|
this.isSource = true;
|
|
11
11
|
|
|
12
|
-
Object.defineProperty( this, 'id', { value:
|
|
12
|
+
Object.defineProperty( this, 'id', { value: _sourceId ++ } );
|
|
13
13
|
|
|
14
14
|
this.uuid = MathUtils.generateUUID();
|
|
15
15
|
|
package/src/textures/Texture.js
CHANGED
|
@@ -19,7 +19,7 @@ import { Matrix3 } from '../math/Matrix3.js';
|
|
|
19
19
|
import { Source } from './Source.js';
|
|
20
20
|
import { warnOnce } from '../utils.js';
|
|
21
21
|
|
|
22
|
-
let
|
|
22
|
+
let _textureId = 0;
|
|
23
23
|
|
|
24
24
|
class Texture extends EventDispatcher {
|
|
25
25
|
|
|
@@ -29,7 +29,7 @@ class Texture extends EventDispatcher {
|
|
|
29
29
|
|
|
30
30
|
this.isTexture = true;
|
|
31
31
|
|
|
32
|
-
Object.defineProperty( this, 'id', { value:
|
|
32
|
+
Object.defineProperty( this, 'id', { value: _textureId ++ } );
|
|
33
33
|
|
|
34
34
|
this.uuid = MathUtils.generateUUID();
|
|
35
35
|
|
package/src/utils.js
CHANGED
|
@@ -68,6 +68,14 @@ function createElementNS( name ) {
|
|
|
68
68
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
+
function createCanvasElement() {
|
|
72
|
+
|
|
73
|
+
const canvas = createElementNS( 'canvas' );
|
|
74
|
+
canvas.style.display = 'block';
|
|
75
|
+
return canvas;
|
|
76
|
+
|
|
77
|
+
}
|
|
78
|
+
|
|
71
79
|
const _cache = {};
|
|
72
80
|
|
|
73
81
|
function warnOnce( message ) {
|
|
@@ -80,4 +88,4 @@ function warnOnce( message ) {
|
|
|
80
88
|
|
|
81
89
|
}
|
|
82
90
|
|
|
83
|
-
export { arrayMin, arrayMax, arrayNeedsUint32, getTypedArray, createElementNS, warnOnce };
|
|
91
|
+
export { arrayMin, arrayMax, arrayNeedsUint32, getTypedArray, createElementNS, createCanvasElement, warnOnce };
|
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
import { GPUTextureViewDimension, GPUIndexFormat, GPUFilterMode, GPUPrimitiveTopology, GPULoadOp, GPUStoreOp } from './WebGPUConstants.js';
|
|
2
|
-
|
|
3
|
-
class WebGPUTextureMipmapUtils {
|
|
4
|
-
|
|
5
|
-
constructor( device ) {
|
|
6
|
-
|
|
7
|
-
this.device = device;
|
|
8
|
-
|
|
9
|
-
const mipmapVertexSource = `
|
|
10
|
-
struct VarysStruct {
|
|
11
|
-
@builtin( position ) Position: vec4<f32>,
|
|
12
|
-
@location( 0 ) vTex : vec2<f32>
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
@vertex
|
|
16
|
-
fn main( @builtin( vertex_index ) vertexIndex : u32 ) -> VarysStruct {
|
|
17
|
-
|
|
18
|
-
var Varys : VarysStruct;
|
|
19
|
-
|
|
20
|
-
var pos = array< vec2<f32>, 4 >(
|
|
21
|
-
vec2<f32>( -1.0, 1.0 ),
|
|
22
|
-
vec2<f32>( 1.0, 1.0 ),
|
|
23
|
-
vec2<f32>( -1.0, -1.0 ),
|
|
24
|
-
vec2<f32>( 1.0, -1.0 )
|
|
25
|
-
);
|
|
26
|
-
|
|
27
|
-
var tex = array< vec2<f32>, 4 >(
|
|
28
|
-
vec2<f32>( 0.0, 0.0 ),
|
|
29
|
-
vec2<f32>( 1.0, 0.0 ),
|
|
30
|
-
vec2<f32>( 0.0, 1.0 ),
|
|
31
|
-
vec2<f32>( 1.0, 1.0 )
|
|
32
|
-
);
|
|
33
|
-
|
|
34
|
-
Varys.vTex = tex[ vertexIndex ];
|
|
35
|
-
Varys.Position = vec4<f32>( pos[ vertexIndex ], 0.0, 1.0 );
|
|
36
|
-
|
|
37
|
-
return Varys;
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
`;
|
|
41
|
-
|
|
42
|
-
const mipmapFragmentSource = `
|
|
43
|
-
@group( 0 ) @binding( 0 )
|
|
44
|
-
var imgSampler : sampler;
|
|
45
|
-
|
|
46
|
-
@group( 0 ) @binding( 1 )
|
|
47
|
-
var img : texture_2d<f32>;
|
|
48
|
-
|
|
49
|
-
@fragment
|
|
50
|
-
fn main( @location( 0 ) vTex : vec2<f32> ) -> @location( 0 ) vec4<f32> {
|
|
51
|
-
|
|
52
|
-
return textureSample( img, imgSampler, vTex );
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
`;
|
|
56
|
-
|
|
57
|
-
this.sampler = device.createSampler( { minFilter: GPUFilterMode.Linear } );
|
|
58
|
-
|
|
59
|
-
// We'll need a new pipeline for every texture format used.
|
|
60
|
-
this.pipelines = {};
|
|
61
|
-
|
|
62
|
-
this.mipmapVertexShaderModule = device.createShaderModule( {
|
|
63
|
-
label: 'mipmapVertex',
|
|
64
|
-
code: mipmapVertexSource
|
|
65
|
-
} );
|
|
66
|
-
|
|
67
|
-
this.mipmapFragmentShaderModule = device.createShaderModule( {
|
|
68
|
-
label: 'mipmapFragment',
|
|
69
|
-
code: mipmapFragmentSource
|
|
70
|
-
} );
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
getMipmapPipeline( format ) {
|
|
75
|
-
|
|
76
|
-
let pipeline = this.pipelines[ format ];
|
|
77
|
-
|
|
78
|
-
if ( pipeline === undefined ) {
|
|
79
|
-
|
|
80
|
-
pipeline = this.device.createRenderPipeline( {
|
|
81
|
-
vertex: {
|
|
82
|
-
module: this.mipmapVertexShaderModule,
|
|
83
|
-
entryPoint: 'main'
|
|
84
|
-
},
|
|
85
|
-
fragment: {
|
|
86
|
-
module: this.mipmapFragmentShaderModule,
|
|
87
|
-
entryPoint: 'main',
|
|
88
|
-
targets: [ { format } ]
|
|
89
|
-
},
|
|
90
|
-
primitive: {
|
|
91
|
-
topology: GPUPrimitiveTopology.TriangleStrip,
|
|
92
|
-
stripIndexFormat: GPUIndexFormat.Uint32
|
|
93
|
-
},
|
|
94
|
-
layout: 'auto'
|
|
95
|
-
} );
|
|
96
|
-
|
|
97
|
-
this.pipelines[ format ] = pipeline;
|
|
98
|
-
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
return pipeline;
|
|
102
|
-
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
generateMipmaps( textureGPU, textureGPUDescriptor, baseArrayLayer = 0 ) {
|
|
106
|
-
|
|
107
|
-
const pipeline = this.getMipmapPipeline( textureGPUDescriptor.format );
|
|
108
|
-
|
|
109
|
-
const commandEncoder = this.device.createCommandEncoder( {} );
|
|
110
|
-
const bindGroupLayout = pipeline.getBindGroupLayout( 0 ); // @TODO: Consider making this static.
|
|
111
|
-
|
|
112
|
-
let srcView = textureGPU.createView( {
|
|
113
|
-
baseMipLevel: 0,
|
|
114
|
-
mipLevelCount: 1,
|
|
115
|
-
dimension: GPUTextureViewDimension.TwoD,
|
|
116
|
-
baseArrayLayer
|
|
117
|
-
} );
|
|
118
|
-
|
|
119
|
-
for ( let i = 1; i < textureGPUDescriptor.mipLevelCount; i ++ ) {
|
|
120
|
-
|
|
121
|
-
const dstView = textureGPU.createView( {
|
|
122
|
-
baseMipLevel: i,
|
|
123
|
-
mipLevelCount: 1,
|
|
124
|
-
dimension: GPUTextureViewDimension.TwoD,
|
|
125
|
-
baseArrayLayer
|
|
126
|
-
} );
|
|
127
|
-
|
|
128
|
-
const passEncoder = commandEncoder.beginRenderPass( {
|
|
129
|
-
colorAttachments: [ {
|
|
130
|
-
view: dstView,
|
|
131
|
-
loadOp: GPULoadOp.Clear,
|
|
132
|
-
storeOp: GPUStoreOp.Store,
|
|
133
|
-
clearValue: [ 0, 0, 0, 0 ]
|
|
134
|
-
} ]
|
|
135
|
-
} );
|
|
136
|
-
|
|
137
|
-
const bindGroup = this.device.createBindGroup( {
|
|
138
|
-
layout: bindGroupLayout,
|
|
139
|
-
entries: [ {
|
|
140
|
-
binding: 0,
|
|
141
|
-
resource: this.sampler
|
|
142
|
-
}, {
|
|
143
|
-
binding: 1,
|
|
144
|
-
resource: srcView
|
|
145
|
-
} ]
|
|
146
|
-
} );
|
|
147
|
-
|
|
148
|
-
passEncoder.setPipeline( pipeline );
|
|
149
|
-
passEncoder.setBindGroup( 0, bindGroup );
|
|
150
|
-
passEncoder.draw( 4, 1, 0, 0 );
|
|
151
|
-
passEncoder.end();
|
|
152
|
-
|
|
153
|
-
srcView = dstView;
|
|
154
|
-
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
this.device.queue.submit( [ commandEncoder.finish() ] );
|
|
158
|
-
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
export default WebGPUTextureMipmapUtils;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { Color } from '../math/Color.js';
|
|
2
|
-
import { LightProbe } from './LightProbe.js';
|
|
3
|
-
|
|
4
|
-
class AmbientLightProbe extends LightProbe {
|
|
5
|
-
|
|
6
|
-
constructor( color, intensity = 1 ) {
|
|
7
|
-
|
|
8
|
-
super( undefined, intensity );
|
|
9
|
-
|
|
10
|
-
this.isAmbientLightProbe = true;
|
|
11
|
-
|
|
12
|
-
const color1 = new Color().set( color );
|
|
13
|
-
|
|
14
|
-
// without extra factor of PI in the shader, would be 2 / Math.sqrt( Math.PI );
|
|
15
|
-
this.sh.coefficients[ 0 ].set( color1.r, color1.g, color1.b ).multiplyScalar( 2 * Math.sqrt( Math.PI ) );
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export { AmbientLightProbe };
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { Color } from '../math/Color.js';
|
|
2
|
-
import { Vector3 } from '../math/Vector3.js';
|
|
3
|
-
import { LightProbe } from './LightProbe.js';
|
|
4
|
-
|
|
5
|
-
class HemisphereLightProbe extends LightProbe {
|
|
6
|
-
|
|
7
|
-
constructor( skyColor, groundColor, intensity = 1 ) {
|
|
8
|
-
|
|
9
|
-
super( undefined, intensity );
|
|
10
|
-
|
|
11
|
-
this.isHemisphereLightProbe = true;
|
|
12
|
-
|
|
13
|
-
const color1 = new Color().set( skyColor );
|
|
14
|
-
const color2 = new Color().set( groundColor );
|
|
15
|
-
|
|
16
|
-
const sky = new Vector3( color1.r, color1.g, color1.b );
|
|
17
|
-
const ground = new Vector3( color2.r, color2.g, color2.b );
|
|
18
|
-
|
|
19
|
-
// without extra factor of PI in the shader, should = 1 / Math.sqrt( Math.PI );
|
|
20
|
-
const c0 = Math.sqrt( Math.PI );
|
|
21
|
-
const c1 = c0 * Math.sqrt( 0.75 );
|
|
22
|
-
|
|
23
|
-
this.sh.coefficients[ 0 ].copy( sky ).add( ground ).multiplyScalar( c0 );
|
|
24
|
-
this.sh.coefficients[ 1 ].copy( sky ).sub( ground ).multiplyScalar( c1 );
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export { HemisphereLightProbe };
|
|
File without changes
|