super-three 0.158.0 → 0.160.1
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 +1720 -380
- package/build/three.js +1720 -380
- package/build/three.min.js +1 -1
- package/build/three.module.js +1719 -381
- package/build/three.module.min.js +1 -1
- package/examples/jsm/Addons.js +2 -1
- package/examples/jsm/controls/OrbitControls.js +50 -40
- package/examples/jsm/csm/CSMShader.js +52 -47
- package/examples/jsm/exporters/GLTFExporter.js +79 -1
- package/examples/jsm/exporters/USDZExporter.js +27 -19
- package/examples/jsm/helpers/TextureHelper.js +237 -0
- package/examples/jsm/interactive/HTMLMesh.js +9 -2
- package/examples/jsm/lines/LineMaterial.js +16 -33
- package/examples/jsm/loaders/ColladaLoader.js +0 -6
- package/examples/jsm/loaders/DRACOLoader.js +4 -3
- package/examples/jsm/loaders/FBXLoader.js +294 -124
- package/examples/jsm/loaders/GLTFLoader.js +71 -3
- package/examples/jsm/loaders/MaterialXLoader.js +73 -54
- package/examples/jsm/loaders/NRRDLoader.js +0 -13
- package/examples/jsm/loaders/SVGLoader.js +4 -4
- package/examples/jsm/loaders/USDZLoader.js +3 -17
- package/examples/jsm/math/Octree.js +15 -4
- package/examples/jsm/misc/Timer.js +119 -0
- package/examples/jsm/misc/TubePainter.js +3 -6
- package/examples/jsm/modifiers/CurveModifier.js +20 -2
- package/examples/jsm/nodes/Nodes.js +11 -7
- package/examples/jsm/nodes/accessors/CameraNode.js +18 -2
- package/examples/jsm/nodes/accessors/CubeTextureNode.js +5 -73
- package/examples/jsm/nodes/accessors/MaterialReferenceNode.js +11 -2
- package/examples/jsm/nodes/accessors/ModelNode.js +1 -1
- package/examples/jsm/nodes/accessors/ModelViewProjectionNode.js +12 -3
- package/examples/jsm/nodes/accessors/MorphNode.js +191 -16
- package/examples/jsm/nodes/accessors/ReferenceNode.js +25 -1
- package/examples/jsm/nodes/accessors/TextureNode.js +122 -36
- package/examples/jsm/nodes/code/CodeNode.js +3 -3
- package/examples/jsm/nodes/core/AttributeNode.js +7 -1
- package/examples/jsm/nodes/core/CacheNode.js +4 -1
- package/examples/jsm/nodes/core/ConstNode.js +1 -1
- package/examples/jsm/nodes/core/Node.js +6 -3
- package/examples/jsm/nodes/core/NodeBuilder.js +84 -27
- package/examples/jsm/nodes/core/NodeFrame.js +10 -8
- package/examples/jsm/nodes/core/NodeUniform.js +12 -0
- package/examples/jsm/nodes/core/NodeUtils.js +3 -7
- package/examples/jsm/nodes/core/OutputStructNode.js +3 -3
- package/examples/jsm/nodes/core/PropertyNode.js +17 -2
- package/examples/jsm/nodes/core/StructTypeNode.js +4 -4
- package/examples/jsm/nodes/core/UniformGroup.js +13 -0
- package/examples/jsm/nodes/core/UniformGroupNode.js +36 -0
- package/examples/jsm/nodes/core/UniformNode.js +17 -0
- package/examples/jsm/nodes/core/VarNode.js +2 -0
- package/examples/jsm/nodes/core/VaryingNode.js +1 -7
- package/examples/jsm/nodes/display/BumpMapNode.js +1 -1
- package/examples/jsm/nodes/display/ColorAdjustmentNode.js +6 -10
- package/examples/jsm/nodes/display/GaussianBlurNode.js +170 -0
- package/examples/jsm/nodes/display/PassNode.js +182 -0
- package/examples/jsm/nodes/display/ViewportDepthNode.js +31 -3
- package/examples/jsm/nodes/display/ViewportDepthTextureNode.js +2 -2
- package/examples/jsm/nodes/display/ViewportNode.js +5 -8
- package/examples/jsm/nodes/functions/PhysicalLightingModel.js +1 -1
- package/examples/jsm/nodes/lighting/AnalyticLightNode.js +52 -17
- package/examples/jsm/nodes/lighting/EnvironmentNode.js +8 -12
- package/examples/jsm/nodes/lighting/LightsNode.js +34 -32
- package/examples/jsm/nodes/materials/InstancedPointsNodeMaterial.js +1 -1
- package/examples/jsm/nodes/materials/Line2NodeMaterial.js +12 -12
- package/examples/jsm/nodes/materials/MeshBasicNodeMaterial.js +1 -0
- package/examples/jsm/nodes/materials/MeshNormalNodeMaterial.js +1 -1
- package/examples/jsm/nodes/materials/NodeMaterial.js +66 -41
- package/examples/jsm/nodes/materials/PointsNodeMaterial.js +0 -10
- package/examples/jsm/nodes/materials/SpriteNodeMaterial.js +0 -7
- package/examples/jsm/nodes/materialx/MaterialXNodes.js +10 -10
- package/examples/jsm/nodes/materialx/lib/mx_hsv.js +128 -54
- package/examples/jsm/nodes/materialx/lib/mx_noise.js +1430 -618
- package/examples/jsm/nodes/materialx/lib/mx_transform_color.js +24 -14
- package/examples/jsm/nodes/math/MathNode.js +2 -0
- package/examples/jsm/nodes/math/OperatorNode.js +19 -6
- package/examples/jsm/nodes/shadernode/ShaderNode.js +32 -3
- package/examples/jsm/nodes/utils/FunctionOverloadingNode.js +95 -0
- package/examples/jsm/nodes/utils/RemapNode.js +2 -2
- package/examples/jsm/nodes/utils/SplitNode.js +8 -2
- package/examples/jsm/nodes/utils/TriplanarTexturesNode.js +3 -3
- package/examples/jsm/objects/QuadMesh.js +60 -0
- package/examples/jsm/postprocessing/GTAOPass.js +572 -0
- package/examples/jsm/postprocessing/OutputPass.js +2 -0
- package/examples/jsm/renderers/common/Animation.js +10 -21
- package/examples/jsm/renderers/common/Backend.js +19 -3
- package/examples/jsm/renderers/common/Background.js +20 -22
- package/examples/jsm/renderers/common/Bindings.js +30 -21
- package/examples/jsm/renderers/common/ChainMap.js +3 -3
- package/examples/jsm/renderers/common/Color4.js +37 -0
- package/examples/jsm/renderers/common/Geometries.js +4 -4
- package/examples/jsm/renderers/common/Info.js +12 -2
- package/examples/jsm/renderers/common/Pipelines.js +3 -51
- package/examples/jsm/renderers/common/PostProcessing.js +25 -0
- package/examples/jsm/renderers/common/RenderContext.js +1 -1
- package/examples/jsm/renderers/common/RenderContexts.js +1 -1
- package/examples/jsm/renderers/common/RenderObject.js +13 -1
- package/examples/jsm/renderers/common/RenderObjects.js +4 -2
- package/examples/jsm/renderers/common/Renderer.js +137 -37
- package/examples/jsm/renderers/common/StorageTexture.js +1 -0
- package/examples/jsm/renderers/common/Textures.js +4 -1
- package/examples/jsm/renderers/common/nodes/NodeBuilderState.js +10 -2
- package/examples/jsm/renderers/common/nodes/NodeUniformsGroup.js +44 -0
- package/examples/jsm/renderers/common/nodes/Nodes.js +74 -7
- package/examples/jsm/renderers/webgl/WebGLBackend.js +91 -33
- package/examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js +100 -31
- package/examples/jsm/renderers/webgl/utils/WebGLAttributeUtils.js +57 -5
- package/examples/jsm/renderers/webgl/utils/WebGLCapabilities.js +36 -0
- package/examples/jsm/renderers/webgl/utils/WebGLExtensions.js +11 -1
- package/examples/jsm/renderers/webgl/utils/WebGLTextureUtils.js +71 -2
- package/examples/jsm/renderers/webgl/utils/WebGLUtils.js +42 -0
- package/examples/jsm/renderers/webgl-legacy/nodes/SlotNode.js +1 -1
- package/examples/jsm/renderers/webgl-legacy/nodes/WebGLNodeBuilder.js +33 -3
- package/examples/jsm/renderers/webgl-legacy/nodes/WebGLNodes.js +4 -14
- package/examples/jsm/renderers/webgpu/WebGPUBackend.js +186 -137
- package/examples/jsm/renderers/webgpu/WebGPURenderer.js +1 -1
- package/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js +209 -90
- package/examples/jsm/renderers/webgpu/utils/WebGPUAttributeUtils.js +15 -10
- package/examples/jsm/renderers/webgpu/utils/WebGPUBindingUtils.js +11 -3
- package/examples/jsm/renderers/webgpu/utils/WebGPUPipelineUtils.js +2 -3
- package/examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js +88 -6
- package/examples/jsm/shaders/FXAAShader.js +133 -133
- package/examples/jsm/shaders/GTAOShader.js +424 -0
- package/examples/jsm/shaders/OutputShader.js +4 -0
- package/examples/jsm/shaders/PoissonDenoiseShader.js +226 -0
- package/examples/jsm/shaders/SAOShader.js +2 -3
- package/examples/jsm/shaders/SSAOShader.js +2 -3
- package/examples/jsm/transpiler/AST.js +40 -1
- package/examples/jsm/transpiler/GLSLDecoder.js +50 -8
- package/examples/jsm/transpiler/ShaderToyDecoder.js +4 -4
- package/examples/jsm/transpiler/TSLEncoder.js +124 -20
- package/examples/jsm/utils/SortUtils.js +158 -0
- package/examples/jsm/utils/TextureUtils.js +33 -21
- package/examples/jsm/webxr/ARButton.js +14 -0
- package/examples/jsm/webxr/VRButton.js +23 -8
- package/examples/jsm/webxr/XRButton.js +25 -11
- package/package.json +5 -6
- package/src/Three.js +1 -0
- package/src/constants.js +2 -1
- package/src/core/BufferAttribute.js +21 -2
- package/src/core/InterleavedBuffer.js +21 -1
- package/src/core/Object3D.js +60 -12
- package/src/core/UniformsGroup.js +7 -1
- package/src/extras/curves/LineCurve3.js +4 -0
- package/src/loaders/AudioLoader.js +1 -1
- package/src/loaders/BufferGeometryLoader.js +0 -7
- package/src/loaders/ImageBitmapLoader.js +25 -1
- package/src/loaders/ObjectLoader.js +49 -0
- package/src/materials/ShaderMaterial.js +2 -1
- package/src/math/ColorManagement.js +0 -16
- package/src/math/Quaternion.js +5 -4
- package/src/math/Sphere.js +2 -0
- package/src/math/Triangle.js +17 -5
- package/src/objects/BatchedMesh.js +1020 -0
- package/src/objects/Skeleton.js +1 -3
- package/src/renderers/WebGL3DRenderTarget.js +2 -2
- package/src/renderers/WebGLArrayRenderTarget.js +2 -2
- package/src/renderers/WebGLRenderer.js +24 -19
- package/src/renderers/shaders/ShaderChunk/batching_pars_vertex.glsl.js +19 -0
- package/src/renderers/shaders/ShaderChunk/batching_vertex.glsl.js +5 -0
- package/src/renderers/shaders/ShaderChunk/cube_uv_reflection_fragment.glsl.js +0 -5
- package/src/renderers/shaders/ShaderChunk/defaultnormal_vertex.glsl.js +31 -4
- package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +9 -4
- package/src/renderers/shaders/ShaderChunk/project_vertex.glsl.js +6 -0
- package/src/renderers/shaders/ShaderChunk/skinning_pars_vertex.glsl.js +9 -17
- package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +84 -0
- package/src/renderers/shaders/ShaderChunk/worldpos_vertex.glsl.js +6 -0
- package/src/renderers/shaders/ShaderChunk.js +4 -0
- package/src/renderers/shaders/ShaderLib/depth.glsl.js +2 -0
- package/src/renderers/shaders/ShaderLib/distanceRGBA.glsl.js +2 -0
- package/src/renderers/shaders/ShaderLib/meshbasic.glsl.js +2 -0
- package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +2 -0
- package/src/renderers/shaders/ShaderLib/meshmatcap.glsl.js +3 -0
- package/src/renderers/shaders/ShaderLib/meshnormal.glsl.js +2 -0
- package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +2 -0
- package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +2 -0
- package/src/renderers/shaders/ShaderLib/meshtoon.glsl.js +2 -0
- package/src/renderers/shaders/ShaderLib/shadow.glsl.js +3 -0
- package/src/renderers/webgl/WebGLAttributes.js +39 -5
- package/src/renderers/webgl/WebGLBufferRenderer.js +31 -0
- package/src/renderers/webgl/WebGLCubeMaps.js +1 -1
- package/src/renderers/webgl/WebGLExtensions.js +1 -0
- package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +31 -0
- package/src/renderers/webgl/WebGLLights.js +11 -2
- package/src/renderers/webgl/WebGLProgram.js +20 -1
- package/src/renderers/webgl/WebGLPrograms.js +5 -0
- package/src/renderers/webgl/WebGLShadowMap.js +35 -0
- package/src/renderers/webgl/WebGLTextures.js +7 -11
- package/src/renderers/webgl/WebGLUniforms.js +11 -1
- package/src/renderers/webgl/WebGLUniformsGroups.js +72 -93
- package/src/renderers/webxr/WebXRManager.js +16 -0
- package/examples/jsm/objects/BatchedMesh.js +0 -586
package/src/objects/Skeleton.js
CHANGED
|
@@ -21,7 +21,6 @@ class Skeleton {
|
|
|
21
21
|
this.boneMatrices = null;
|
|
22
22
|
|
|
23
23
|
this.boneTexture = null;
|
|
24
|
-
this.boneTextureSize = 0;
|
|
25
24
|
|
|
26
25
|
this.init();
|
|
27
26
|
|
|
@@ -169,7 +168,7 @@ class Skeleton {
|
|
|
169
168
|
// 64x64 pixel texture max 1024 bones * 4 pixels = (64 * 64)
|
|
170
169
|
|
|
171
170
|
let size = Math.sqrt( this.bones.length * 4 ); // 4 pixels needed for 1 matrix
|
|
172
|
-
size =
|
|
171
|
+
size = Math.ceil( size / 4 ) * 4;
|
|
173
172
|
size = Math.max( size, 4 );
|
|
174
173
|
|
|
175
174
|
const boneMatrices = new Float32Array( size * size * 4 ); // 4 floats per RGBA pixel
|
|
@@ -180,7 +179,6 @@ class Skeleton {
|
|
|
180
179
|
|
|
181
180
|
this.boneMatrices = boneMatrices;
|
|
182
181
|
this.boneTexture = boneTexture;
|
|
183
|
-
this.boneTextureSize = size;
|
|
184
182
|
|
|
185
183
|
return this;
|
|
186
184
|
|
|
@@ -3,9 +3,9 @@ import { Data3DTexture } from '../textures/Data3DTexture.js';
|
|
|
3
3
|
|
|
4
4
|
class WebGL3DRenderTarget extends WebGLRenderTarget {
|
|
5
5
|
|
|
6
|
-
constructor( width = 1, height = 1, depth = 1 ) {
|
|
6
|
+
constructor( width = 1, height = 1, depth = 1, options = {} ) {
|
|
7
7
|
|
|
8
|
-
super( width, height );
|
|
8
|
+
super( width, height, options );
|
|
9
9
|
|
|
10
10
|
this.isWebGL3DRenderTarget = true;
|
|
11
11
|
|
|
@@ -3,9 +3,9 @@ import { DataArrayTexture } from '../textures/DataArrayTexture.js';
|
|
|
3
3
|
|
|
4
4
|
class WebGLArrayRenderTarget extends WebGLRenderTarget {
|
|
5
5
|
|
|
6
|
-
constructor( width = 1, height = 1, depth = 1 ) {
|
|
6
|
+
constructor( width = 1, height = 1, depth = 1, options = {} ) {
|
|
7
7
|
|
|
8
|
-
super( width, height );
|
|
8
|
+
super( width, height, options );
|
|
9
9
|
|
|
10
10
|
this.isWebGLArrayRenderTarget = true;
|
|
11
11
|
|
|
@@ -901,7 +901,11 @@ class WebGLRenderer {
|
|
|
901
901
|
|
|
902
902
|
}
|
|
903
903
|
|
|
904
|
-
if ( object.
|
|
904
|
+
if ( object.isBatchedMesh ) {
|
|
905
|
+
|
|
906
|
+
renderer.renderMultiDraw( object._multiDrawStarts, object._multiDrawCounts, object._multiDrawCount );
|
|
907
|
+
|
|
908
|
+
} else if ( object.isInstancedMesh ) {
|
|
905
909
|
|
|
906
910
|
renderer.renderInstances( drawStart, drawCount, object.count );
|
|
907
911
|
|
|
@@ -1737,6 +1741,7 @@ class WebGLRenderer {
|
|
|
1737
1741
|
const materialProperties = properties.get( material );
|
|
1738
1742
|
|
|
1739
1743
|
materialProperties.outputColorSpace = parameters.outputColorSpace;
|
|
1744
|
+
materialProperties.batching = parameters.batching;
|
|
1740
1745
|
materialProperties.instancing = parameters.instancing;
|
|
1741
1746
|
materialProperties.instancingColor = parameters.instancingColor;
|
|
1742
1747
|
materialProperties.skinning = parameters.skinning;
|
|
@@ -1820,6 +1825,14 @@ class WebGLRenderer {
|
|
|
1820
1825
|
|
|
1821
1826
|
needsProgramChange = true;
|
|
1822
1827
|
|
|
1828
|
+
} else if ( object.isBatchedMesh && materialProperties.batching === false ) {
|
|
1829
|
+
|
|
1830
|
+
needsProgramChange = true;
|
|
1831
|
+
|
|
1832
|
+
} else if ( ! object.isBatchedMesh && materialProperties.batching === true ) {
|
|
1833
|
+
|
|
1834
|
+
needsProgramChange = true;
|
|
1835
|
+
|
|
1823
1836
|
} else if ( object.isInstancedMesh && materialProperties.instancing === false ) {
|
|
1824
1837
|
|
|
1825
1838
|
needsProgramChange = true;
|
|
@@ -2009,7 +2022,6 @@ class WebGLRenderer {
|
|
|
2009
2022
|
if ( skeleton.boneTexture === null ) skeleton.computeBoneTexture();
|
|
2010
2023
|
|
|
2011
2024
|
p_uniforms.setValue( _gl, 'boneTexture', skeleton.boneTexture, textures );
|
|
2012
|
-
p_uniforms.setValue( _gl, 'boneTextureSize', skeleton.boneTextureSize );
|
|
2013
2025
|
|
|
2014
2026
|
} else {
|
|
2015
2027
|
|
|
@@ -2021,6 +2033,13 @@ class WebGLRenderer {
|
|
|
2021
2033
|
|
|
2022
2034
|
}
|
|
2023
2035
|
|
|
2036
|
+
if ( object.isBatchedMesh ) {
|
|
2037
|
+
|
|
2038
|
+
p_uniforms.setOptional( _gl, object, 'batchingTexture' );
|
|
2039
|
+
p_uniforms.setValue( _gl, 'batchingTexture', object._matricesTexture, textures );
|
|
2040
|
+
|
|
2041
|
+
}
|
|
2042
|
+
|
|
2024
2043
|
const morphAttributes = geometry.morphAttributes;
|
|
2025
2044
|
|
|
2026
2045
|
if ( morphAttributes.position !== undefined || morphAttributes.normal !== undefined || ( morphAttributes.color !== undefined && capabilities.isWebGL2 === true ) ) {
|
|
@@ -2216,7 +2235,7 @@ class WebGLRenderer {
|
|
|
2216
2235
|
|
|
2217
2236
|
renderTargetProperties.__autoAllocateDepthBuffer = depthTexture === undefined;
|
|
2218
2237
|
|
|
2219
|
-
if ( ! renderTargetProperties.__autoAllocateDepthBuffer && ! _currentRenderTarget.isWebGLMultiviewRenderTarget ) {
|
|
2238
|
+
if ( ! renderTargetProperties.__autoAllocateDepthBuffer && ( ! _currentRenderTarget || ! _currentRenderTarget.isWebGLMultiviewRenderTarget ) ) {
|
|
2220
2239
|
|
|
2221
2240
|
// The multisample_render_to_texture extension doesn't work properly if there
|
|
2222
2241
|
// are midframe flushes and an external depth buffer. Disable use of the extension.
|
|
@@ -2495,7 +2514,7 @@ class WebGLRenderer {
|
|
|
2495
2514
|
textures.setTexture3D( dstTexture, 0 );
|
|
2496
2515
|
glTarget = _gl.TEXTURE_3D;
|
|
2497
2516
|
|
|
2498
|
-
} else if ( dstTexture.isDataArrayTexture ) {
|
|
2517
|
+
} else if ( dstTexture.isDataArrayTexture || dstTexture.isCompressedArrayTexture ) {
|
|
2499
2518
|
|
|
2500
2519
|
textures.setTexture2DArray( dstTexture, 0 );
|
|
2501
2520
|
glTarget = _gl.TEXTURE_2D_ARRAY;
|
|
@@ -2517,7 +2536,7 @@ class WebGLRenderer {
|
|
|
2517
2536
|
const unpackSkipRows = _gl.getParameter( _gl.UNPACK_SKIP_ROWS );
|
|
2518
2537
|
const unpackSkipImages = _gl.getParameter( _gl.UNPACK_SKIP_IMAGES );
|
|
2519
2538
|
|
|
2520
|
-
const image = srcTexture.isCompressedTexture ? srcTexture.mipmaps[
|
|
2539
|
+
const image = srcTexture.isCompressedTexture ? srcTexture.mipmaps[ level ] : srcTexture.image;
|
|
2521
2540
|
|
|
2522
2541
|
_gl.pixelStorei( _gl.UNPACK_ROW_LENGTH, image.width );
|
|
2523
2542
|
_gl.pixelStorei( _gl.UNPACK_IMAGE_HEIGHT, image.height );
|
|
@@ -2622,20 +2641,6 @@ class WebGLRenderer {
|
|
|
2622
2641
|
|
|
2623
2642
|
}
|
|
2624
2643
|
|
|
2625
|
-
get physicallyCorrectLights() { // @deprecated, r150
|
|
2626
|
-
|
|
2627
|
-
console.warn( 'THREE.WebGLRenderer: The property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead.' );
|
|
2628
|
-
return ! this.useLegacyLights;
|
|
2629
|
-
|
|
2630
|
-
}
|
|
2631
|
-
|
|
2632
|
-
set physicallyCorrectLights( value ) { // @deprecated, r150
|
|
2633
|
-
|
|
2634
|
-
console.warn( 'THREE.WebGLRenderer: The property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead.' );
|
|
2635
|
-
this.useLegacyLights = ! value;
|
|
2636
|
-
|
|
2637
|
-
}
|
|
2638
|
-
|
|
2639
2644
|
get outputEncoding() { // @deprecated, r152
|
|
2640
2645
|
|
|
2641
2646
|
console.warn( 'THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead.' );
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export default /* glsl */`
|
|
2
|
+
#ifdef USE_BATCHING
|
|
3
|
+
attribute float batchId;
|
|
4
|
+
uniform highp sampler2D batchingTexture;
|
|
5
|
+
mat4 getBatchingMatrix( const in float i ) {
|
|
6
|
+
|
|
7
|
+
int size = textureSize( batchingTexture, 0 ).x;
|
|
8
|
+
int j = int( i ) * 4;
|
|
9
|
+
int x = j % size;
|
|
10
|
+
int y = j / size;
|
|
11
|
+
vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );
|
|
12
|
+
vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );
|
|
13
|
+
vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );
|
|
14
|
+
vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
|
|
15
|
+
return mat4( v1, v2, v3, v4 );
|
|
16
|
+
|
|
17
|
+
}
|
|
18
|
+
#endif
|
|
19
|
+
`;
|
|
@@ -119,19 +119,14 @@ export default /* glsl */`
|
|
|
119
119
|
// These defines must match with PMREMGenerator
|
|
120
120
|
|
|
121
121
|
#define cubeUV_r0 1.0
|
|
122
|
-
#define cubeUV_v0 0.339
|
|
123
122
|
#define cubeUV_m0 - 2.0
|
|
124
123
|
#define cubeUV_r1 0.8
|
|
125
|
-
#define cubeUV_v1 0.276
|
|
126
124
|
#define cubeUV_m1 - 1.0
|
|
127
125
|
#define cubeUV_r4 0.4
|
|
128
|
-
#define cubeUV_v4 0.046
|
|
129
126
|
#define cubeUV_m4 2.0
|
|
130
127
|
#define cubeUV_r5 0.305
|
|
131
|
-
#define cubeUV_v5 0.016
|
|
132
128
|
#define cubeUV_m5 3.0
|
|
133
129
|
#define cubeUV_r6 0.21
|
|
134
|
-
#define cubeUV_v6 0.0038
|
|
135
130
|
#define cubeUV_m6 4.0
|
|
136
131
|
|
|
137
132
|
float roughnessToMip( float roughness ) {
|
|
@@ -1,16 +1,43 @@
|
|
|
1
1
|
export default /* glsl */`
|
|
2
|
+
|
|
2
3
|
vec3 transformedNormal = objectNormal;
|
|
4
|
+
#ifdef USE_TANGENT
|
|
5
|
+
|
|
6
|
+
vec3 transformedTangent = objectTangent;
|
|
7
|
+
|
|
8
|
+
#endif
|
|
9
|
+
|
|
10
|
+
#ifdef USE_BATCHING
|
|
11
|
+
|
|
12
|
+
// this is in lieu of a per-instance normal-matrix
|
|
13
|
+
// shear transforms in the instance matrix are not supported
|
|
14
|
+
|
|
15
|
+
mat3 bm = mat3( batchingMatrix );
|
|
16
|
+
transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
|
|
17
|
+
transformedNormal = bm * transformedNormal;
|
|
18
|
+
|
|
19
|
+
#ifdef USE_TANGENT
|
|
20
|
+
|
|
21
|
+
transformedTangent = bm * transformedTangent;
|
|
22
|
+
|
|
23
|
+
#endif
|
|
24
|
+
|
|
25
|
+
#endif
|
|
3
26
|
|
|
4
27
|
#ifdef USE_INSTANCING
|
|
5
28
|
|
|
6
29
|
// this is in lieu of a per-instance normal-matrix
|
|
7
30
|
// shear transforms in the instance matrix are not supported
|
|
8
31
|
|
|
9
|
-
mat3
|
|
32
|
+
mat3 im = mat3( instanceMatrix );
|
|
33
|
+
transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
|
|
34
|
+
transformedNormal = im * transformedNormal;
|
|
10
35
|
|
|
11
|
-
|
|
36
|
+
#ifdef USE_TANGENT
|
|
12
37
|
|
|
13
|
-
|
|
38
|
+
transformedTangent = im * transformedTangent;
|
|
39
|
+
|
|
40
|
+
#endif
|
|
14
41
|
|
|
15
42
|
#endif
|
|
16
43
|
|
|
@@ -24,7 +51,7 @@ transformedNormal = normalMatrix * transformedNormal;
|
|
|
24
51
|
|
|
25
52
|
#ifdef USE_TANGENT
|
|
26
53
|
|
|
27
|
-
|
|
54
|
+
transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
|
|
28
55
|
|
|
29
56
|
#ifdef FLIP_SIDED
|
|
30
57
|
|
|
@@ -133,14 +133,19 @@ material.roughness = min( material.roughness, 1.0 );
|
|
|
133
133
|
#endif
|
|
134
134
|
|
|
135
135
|
material.anisotropy = length( anisotropyV );
|
|
136
|
-
|
|
137
|
-
material.anisotropy
|
|
136
|
+
|
|
137
|
+
if( material.anisotropy == 0.0 ) {
|
|
138
|
+
anisotropyV = vec2( 1.0, 0.0 );
|
|
139
|
+
} else {
|
|
140
|
+
anisotropyV /= material.anisotropy;
|
|
141
|
+
material.anisotropy = saturate( material.anisotropy );
|
|
142
|
+
}
|
|
138
143
|
|
|
139
144
|
// Roughness along the anisotropy bitangent is the material roughness, while the tangent roughness increases with anisotropy.
|
|
140
145
|
material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
|
|
141
146
|
|
|
142
|
-
material.anisotropyT = tbn[ 0 ] * anisotropyV.x
|
|
143
|
-
material.anisotropyB = tbn[ 1 ] * anisotropyV.x
|
|
147
|
+
material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
|
|
148
|
+
material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
|
|
144
149
|
|
|
145
150
|
#endif
|
|
146
151
|
`;
|
|
@@ -5,27 +5,19 @@ export default /* glsl */`
|
|
|
5
5
|
uniform mat4 bindMatrixInverse;
|
|
6
6
|
|
|
7
7
|
uniform highp sampler2D boneTexture;
|
|
8
|
-
uniform int boneTextureSize;
|
|
9
8
|
|
|
10
9
|
mat4 getBoneMatrix( const in float i ) {
|
|
11
10
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
int size = textureSize( boneTexture, 0 ).x;
|
|
12
|
+
int j = int( i ) * 4;
|
|
13
|
+
int x = j % size;
|
|
14
|
+
int y = j / size;
|
|
15
|
+
vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
|
|
16
|
+
vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
|
|
17
|
+
vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
|
|
18
|
+
vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
|
|
15
19
|
|
|
16
|
-
|
|
17
|
-
float dy = 1.0 / float( boneTextureSize );
|
|
18
|
-
|
|
19
|
-
y = dy * ( y + 0.5 );
|
|
20
|
-
|
|
21
|
-
vec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );
|
|
22
|
-
vec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );
|
|
23
|
-
vec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );
|
|
24
|
-
vec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );
|
|
25
|
-
|
|
26
|
-
mat4 bone = mat4( v1, v2, v3, v4 );
|
|
27
|
-
|
|
28
|
-
return bone;
|
|
20
|
+
return mat4( v1, v2, v3, v4 );
|
|
29
21
|
|
|
30
22
|
}
|
|
31
23
|
|
|
@@ -73,5 +73,89 @@ vec3 ACESFilmicToneMapping( vec3 color ) {
|
|
|
73
73
|
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
+
// Matrices for rec 2020 <> rec 709 color space conversion
|
|
77
|
+
// matrix provided in row-major order so it has been transposed
|
|
78
|
+
// https://www.itu.int/pub/R-REP-BT.2407-2017
|
|
79
|
+
const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(
|
|
80
|
+
vec3( 1.6605, - 0.1246, - 0.0182 ),
|
|
81
|
+
vec3( - 0.5876, 1.1329, - 0.1006 ),
|
|
82
|
+
vec3( - 0.0728, - 0.0083, 1.1187 )
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(
|
|
86
|
+
vec3( 0.6274, 0.0691, 0.0164 ),
|
|
87
|
+
vec3( 0.3293, 0.9195, 0.0880 ),
|
|
88
|
+
vec3( 0.0433, 0.0113, 0.8956 )
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
// https://iolite-engine.com/blog_posts/minimal_agx_implementation
|
|
92
|
+
// Mean error^2: 3.6705141e-06
|
|
93
|
+
vec3 agxDefaultContrastApprox( vec3 x ) {
|
|
94
|
+
|
|
95
|
+
vec3 x2 = x * x;
|
|
96
|
+
vec3 x4 = x2 * x2;
|
|
97
|
+
|
|
98
|
+
return + 15.5 * x4 * x2
|
|
99
|
+
- 40.14 * x4 * x
|
|
100
|
+
+ 31.96 * x4
|
|
101
|
+
- 6.868 * x2 * x
|
|
102
|
+
+ 0.4298 * x2
|
|
103
|
+
+ 0.1191 * x
|
|
104
|
+
- 0.00232;
|
|
105
|
+
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// Input and output encoded as Linear-sRGB.
|
|
109
|
+
vec3 AgXToneMapping( vec3 color ) {
|
|
110
|
+
|
|
111
|
+
// AgX constants
|
|
112
|
+
const mat3 AgXInsetMatrix = mat3(
|
|
113
|
+
vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),
|
|
114
|
+
vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),
|
|
115
|
+
vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
// explicit AgXOutsetMatrix generated from Filaments AgXOutsetMatrixInv
|
|
119
|
+
const mat3 AgXOutsetMatrix = mat3(
|
|
120
|
+
vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),
|
|
121
|
+
vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),
|
|
122
|
+
vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
const float AgxMinEv = - 12.47393; // log2(pow(2, LOG2_MIN) * MIDDLE_GRAY)
|
|
126
|
+
const float AgxMaxEv = 4.026069; // log2(pow(2, LOG2_MAX) * MIDDLE_GRAY)
|
|
127
|
+
|
|
128
|
+
// AGX Tone Mapping implementation based on Filament, which is in turn based
|
|
129
|
+
// on Blender's implementation for rec 2020 colors:
|
|
130
|
+
// https://github.com/google/filament/pull/7236
|
|
131
|
+
color = LINEAR_SRGB_TO_LINEAR_REC2020 * color;
|
|
132
|
+
color *= toneMappingExposure;
|
|
133
|
+
|
|
134
|
+
color = AgXInsetMatrix * color;
|
|
135
|
+
|
|
136
|
+
// Log2 encoding
|
|
137
|
+
color = max( color, 1e-10 ); // avoid 0 or negative numbers for log2
|
|
138
|
+
color = log2( color );
|
|
139
|
+
color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );
|
|
140
|
+
|
|
141
|
+
color = clamp( color, 0.0, 1.0 );
|
|
142
|
+
|
|
143
|
+
// Apply sigmoid
|
|
144
|
+
color = agxDefaultContrastApprox( color );
|
|
145
|
+
|
|
146
|
+
// Apply AgX look
|
|
147
|
+
// v = agxLook(v, look);
|
|
148
|
+
|
|
149
|
+
color = AgXOutsetMatrix * color;
|
|
150
|
+
|
|
151
|
+
// Linearize
|
|
152
|
+
color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );
|
|
153
|
+
|
|
154
|
+
color = LINEAR_REC2020_TO_LINEAR_SRGB * color;
|
|
155
|
+
|
|
156
|
+
return color;
|
|
157
|
+
|
|
158
|
+
}
|
|
159
|
+
|
|
76
160
|
vec3 CustomToneMapping( vec3 color ) { return color; }
|
|
77
161
|
`;
|
|
@@ -6,6 +6,8 @@ import alphatest_fragment from './ShaderChunk/alphatest_fragment.glsl.js';
|
|
|
6
6
|
import alphatest_pars_fragment from './ShaderChunk/alphatest_pars_fragment.glsl.js';
|
|
7
7
|
import aomap_fragment from './ShaderChunk/aomap_fragment.glsl.js';
|
|
8
8
|
import aomap_pars_fragment from './ShaderChunk/aomap_pars_fragment.glsl.js';
|
|
9
|
+
import batching_pars_vertex from './ShaderChunk/batching_pars_vertex.glsl.js';
|
|
10
|
+
import batching_vertex from './ShaderChunk/batching_vertex.glsl.js';
|
|
9
11
|
import begin_vertex from './ShaderChunk/begin_vertex.glsl.js';
|
|
10
12
|
import beginnormal_vertex from './ShaderChunk/beginnormal_vertex.glsl.js';
|
|
11
13
|
import bsdfs from './ShaderChunk/bsdfs.glsl.js';
|
|
@@ -131,6 +133,8 @@ export const ShaderChunk = {
|
|
|
131
133
|
alphatest_pars_fragment: alphatest_pars_fragment,
|
|
132
134
|
aomap_fragment: aomap_fragment,
|
|
133
135
|
aomap_pars_fragment: aomap_pars_fragment,
|
|
136
|
+
batching_pars_vertex: batching_pars_vertex,
|
|
137
|
+
batching_vertex: batching_vertex,
|
|
134
138
|
begin_vertex: begin_vertex,
|
|
135
139
|
beginnormal_vertex: beginnormal_vertex,
|
|
136
140
|
bsdfs: bsdfs,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export const vertex = /* glsl */`
|
|
2
2
|
#include <common>
|
|
3
|
+
#include <batching_pars_vertex>
|
|
3
4
|
#include <uv_pars_vertex>
|
|
4
5
|
#include <displacementmap_pars_vertex>
|
|
5
6
|
#include <morphtarget_pars_vertex>
|
|
@@ -16,6 +17,7 @@ void main() {
|
|
|
16
17
|
|
|
17
18
|
#include <uv_vertex>
|
|
18
19
|
|
|
20
|
+
#include <batching_vertex>
|
|
19
21
|
#include <skinbase_vertex>
|
|
20
22
|
|
|
21
23
|
#ifdef USE_DISPLACEMENTMAP
|
|
@@ -4,6 +4,7 @@ export const vertex = /* glsl */`
|
|
|
4
4
|
varying vec3 vWorldPosition;
|
|
5
5
|
|
|
6
6
|
#include <common>
|
|
7
|
+
#include <batching_pars_vertex>
|
|
7
8
|
#include <uv_pars_vertex>
|
|
8
9
|
#include <displacementmap_pars_vertex>
|
|
9
10
|
#include <morphtarget_pars_vertex>
|
|
@@ -14,6 +15,7 @@ void main() {
|
|
|
14
15
|
|
|
15
16
|
#include <uv_vertex>
|
|
16
17
|
|
|
18
|
+
#include <batching_vertex>
|
|
17
19
|
#include <skinbase_vertex>
|
|
18
20
|
|
|
19
21
|
#ifdef USE_DISPLACEMENTMAP
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export const vertex = /* glsl */`
|
|
2
2
|
#include <common>
|
|
3
|
+
#include <batching_pars_vertex>
|
|
3
4
|
#include <uv_pars_vertex>
|
|
4
5
|
#include <envmap_pars_vertex>
|
|
5
6
|
#include <color_pars_vertex>
|
|
@@ -14,6 +15,7 @@ void main() {
|
|
|
14
15
|
#include <uv_vertex>
|
|
15
16
|
#include <color_vertex>
|
|
16
17
|
#include <morphcolor_vertex>
|
|
18
|
+
#include <batching_vertex>
|
|
17
19
|
|
|
18
20
|
#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
|
|
19
21
|
|
|
@@ -4,6 +4,7 @@ export const vertex = /* glsl */`
|
|
|
4
4
|
varying vec3 vViewPosition;
|
|
5
5
|
|
|
6
6
|
#include <common>
|
|
7
|
+
#include <batching_pars_vertex>
|
|
7
8
|
#include <uv_pars_vertex>
|
|
8
9
|
#include <displacementmap_pars_vertex>
|
|
9
10
|
#include <envmap_pars_vertex>
|
|
@@ -21,6 +22,7 @@ void main() {
|
|
|
21
22
|
#include <uv_vertex>
|
|
22
23
|
#include <color_vertex>
|
|
23
24
|
#include <morphcolor_vertex>
|
|
25
|
+
#include <batching_vertex>
|
|
24
26
|
|
|
25
27
|
#include <beginnormal_vertex>
|
|
26
28
|
#include <morphnormal_vertex>
|
|
@@ -4,6 +4,7 @@ export const vertex = /* glsl */`
|
|
|
4
4
|
varying vec3 vViewPosition;
|
|
5
5
|
|
|
6
6
|
#include <common>
|
|
7
|
+
#include <batching_pars_vertex>
|
|
7
8
|
#include <uv_pars_vertex>
|
|
8
9
|
#include <color_pars_vertex>
|
|
9
10
|
#include <displacementmap_pars_vertex>
|
|
@@ -20,6 +21,8 @@ void main() {
|
|
|
20
21
|
#include <uv_vertex>
|
|
21
22
|
#include <color_vertex>
|
|
22
23
|
#include <morphcolor_vertex>
|
|
24
|
+
#include <batching_vertex>
|
|
25
|
+
|
|
23
26
|
#include <beginnormal_vertex>
|
|
24
27
|
#include <morphnormal_vertex>
|
|
25
28
|
#include <skinbase_vertex>
|
|
@@ -8,6 +8,7 @@ export const vertex = /* glsl */`
|
|
|
8
8
|
#endif
|
|
9
9
|
|
|
10
10
|
#include <common>
|
|
11
|
+
#include <batching_pars_vertex>
|
|
11
12
|
#include <uv_pars_vertex>
|
|
12
13
|
#include <displacementmap_pars_vertex>
|
|
13
14
|
#include <normal_pars_vertex>
|
|
@@ -19,6 +20,7 @@ export const vertex = /* glsl */`
|
|
|
19
20
|
void main() {
|
|
20
21
|
|
|
21
22
|
#include <uv_vertex>
|
|
23
|
+
#include <batching_vertex>
|
|
22
24
|
|
|
23
25
|
#include <beginnormal_vertex>
|
|
24
26
|
#include <morphnormal_vertex>
|
|
@@ -4,6 +4,7 @@ export const vertex = /* glsl */`
|
|
|
4
4
|
varying vec3 vViewPosition;
|
|
5
5
|
|
|
6
6
|
#include <common>
|
|
7
|
+
#include <batching_pars_vertex>
|
|
7
8
|
#include <uv_pars_vertex>
|
|
8
9
|
#include <displacementmap_pars_vertex>
|
|
9
10
|
#include <envmap_pars_vertex>
|
|
@@ -21,6 +22,7 @@ void main() {
|
|
|
21
22
|
#include <uv_vertex>
|
|
22
23
|
#include <color_vertex>
|
|
23
24
|
#include <morphcolor_vertex>
|
|
25
|
+
#include <batching_vertex>
|
|
24
26
|
|
|
25
27
|
#include <beginnormal_vertex>
|
|
26
28
|
#include <morphnormal_vertex>
|
|
@@ -10,6 +10,7 @@ varying vec3 vViewPosition;
|
|
|
10
10
|
#endif
|
|
11
11
|
|
|
12
12
|
#include <common>
|
|
13
|
+
#include <batching_pars_vertex>
|
|
13
14
|
#include <uv_pars_vertex>
|
|
14
15
|
#include <displacementmap_pars_vertex>
|
|
15
16
|
#include <color_pars_vertex>
|
|
@@ -26,6 +27,7 @@ void main() {
|
|
|
26
27
|
#include <uv_vertex>
|
|
27
28
|
#include <color_vertex>
|
|
28
29
|
#include <morphcolor_vertex>
|
|
30
|
+
#include <batching_vertex>
|
|
29
31
|
|
|
30
32
|
#include <beginnormal_vertex>
|
|
31
33
|
#include <morphnormal_vertex>
|
|
@@ -4,6 +4,7 @@ export const vertex = /* glsl */`
|
|
|
4
4
|
varying vec3 vViewPosition;
|
|
5
5
|
|
|
6
6
|
#include <common>
|
|
7
|
+
#include <batching_pars_vertex>
|
|
7
8
|
#include <uv_pars_vertex>
|
|
8
9
|
#include <displacementmap_pars_vertex>
|
|
9
10
|
#include <color_pars_vertex>
|
|
@@ -20,6 +21,7 @@ void main() {
|
|
|
20
21
|
#include <uv_vertex>
|
|
21
22
|
#include <color_vertex>
|
|
22
23
|
#include <morphcolor_vertex>
|
|
24
|
+
#include <batching_vertex>
|
|
23
25
|
|
|
24
26
|
#include <beginnormal_vertex>
|
|
25
27
|
#include <morphnormal_vertex>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export const vertex = /* glsl */`
|
|
2
2
|
#include <common>
|
|
3
|
+
#include <batching_pars_vertex>
|
|
3
4
|
#include <fog_pars_vertex>
|
|
4
5
|
#include <morphtarget_pars_vertex>
|
|
5
6
|
#include <skinning_pars_vertex>
|
|
@@ -8,6 +9,8 @@ export const vertex = /* glsl */`
|
|
|
8
9
|
|
|
9
10
|
void main() {
|
|
10
11
|
|
|
12
|
+
#include <batching_vertex>
|
|
13
|
+
|
|
11
14
|
#include <beginnormal_vertex>
|
|
12
15
|
#include <morphnormal_vertex>
|
|
13
16
|
#include <skinbase_vertex>
|