super-three 0.163.0 → 0.165.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/README.md +3 -3
- package/build/three.cjs +1127 -452
- package/build/three.module.js +1127 -452
- package/build/three.module.min.js +2 -2
- package/examples/jsm/animation/CCDIKSolver.js +4 -2
- package/examples/jsm/controls/TransformControls.js +1 -1
- package/examples/jsm/environments/RoomEnvironment.js +1 -5
- package/examples/jsm/exporters/GLTFExporter.js +45 -1
- package/examples/jsm/exporters/USDZExporter.js +13 -5
- package/examples/jsm/helpers/ViewHelper.js +32 -67
- package/examples/jsm/libs/draco/README.md +2 -2
- package/examples/jsm/libs/tween.module.js +75 -64
- package/examples/jsm/lines/LineMaterial.js +1 -15
- package/examples/jsm/lines/LineSegments2.js +15 -0
- package/examples/jsm/lines/Wireframe.js +16 -1
- package/examples/jsm/loaders/DRACOLoader.js +1 -1
- package/examples/jsm/loaders/EXRLoader.js +283 -99
- package/examples/jsm/loaders/FBXLoader.js +24 -13
- package/examples/jsm/loaders/GLTFLoader.js +55 -0
- package/examples/jsm/loaders/KTX2Loader.js +3 -6
- package/examples/jsm/loaders/LDrawLoader.js +3 -2
- package/examples/jsm/loaders/MMDLoader.js +31 -12
- package/examples/jsm/loaders/VRMLLoader.js +1 -1
- package/examples/jsm/loaders/lwo/IFFParser.js +8 -5
- package/examples/jsm/materials/MeshGouraudMaterial.js +7 -1
- package/examples/jsm/math/Octree.js +26 -20
- package/examples/jsm/modifiers/CurveModifier.js +11 -9
- package/examples/jsm/nodes/Nodes.js +15 -13
- package/examples/jsm/nodes/accessors/AccessorsUtils.js +16 -1
- package/examples/jsm/nodes/accessors/BitangentNode.js +7 -83
- package/examples/jsm/nodes/accessors/BufferNode.js +6 -0
- package/examples/jsm/nodes/accessors/CameraNode.js +12 -119
- package/examples/jsm/nodes/accessors/ClippingNode.js +3 -2
- package/examples/jsm/nodes/accessors/MaterialNode.js +109 -3
- package/examples/jsm/nodes/accessors/ModelNode.js +3 -0
- package/examples/jsm/nodes/accessors/NormalNode.js +9 -101
- package/examples/jsm/nodes/accessors/PositionNode.js +6 -100
- package/examples/jsm/nodes/accessors/ReferenceNode.js +6 -0
- package/examples/jsm/nodes/accessors/ReflectVectorNode.js +2 -31
- package/examples/jsm/nodes/accessors/StorageBufferNode.js +9 -0
- package/examples/jsm/nodes/accessors/{TextureStoreNode.js → StorageTextureNode.js} +19 -6
- package/examples/jsm/nodes/accessors/TangentNode.js +11 -97
- package/examples/jsm/nodes/accessors/Texture3DNode.js +100 -0
- package/examples/jsm/nodes/accessors/TextureNode.js +21 -3
- package/examples/jsm/nodes/accessors/TextureSizeNode.js +1 -1
- package/examples/jsm/nodes/accessors/UVNode.js +2 -46
- package/examples/jsm/nodes/code/FunctionNode.js +0 -8
- package/examples/jsm/nodes/core/AttributeNode.js +15 -3
- package/examples/jsm/nodes/core/ContextNode.js +6 -0
- package/examples/jsm/nodes/core/Node.js +23 -2
- package/examples/jsm/nodes/core/NodeBuilder.js +25 -18
- package/examples/jsm/nodes/core/NodeKeywords.js +1 -1
- package/examples/jsm/nodes/core/OutputStructNode.js +3 -6
- package/examples/jsm/nodes/core/PropertyNode.js +11 -0
- package/examples/jsm/nodes/core/VaryingNode.js +40 -9
- package/examples/jsm/nodes/display/AfterImageNode.js +14 -2
- package/examples/jsm/nodes/display/BumpMapNode.js +7 -26
- package/examples/jsm/nodes/display/FrontFacingNode.js +13 -0
- package/examples/jsm/nodes/display/PassNode.js +3 -1
- package/examples/jsm/nodes/display/ViewportDepthNode.js +1 -1
- package/examples/jsm/nodes/display/ViewportNode.js +5 -3
- package/examples/jsm/nodes/display/ViewportTextureNode.js +4 -1
- package/examples/jsm/nodes/functions/BSDF/BRDF_GGX.js +26 -7
- package/examples/jsm/nodes/functions/BSDF/D_GGX_Anisotropic.js +28 -0
- package/examples/jsm/nodes/functions/BSDF/V_GGX_SmithCorrelated.js +1 -3
- package/examples/jsm/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +29 -0
- package/examples/jsm/nodes/functions/PhongLightingModel.js +1 -1
- package/examples/jsm/nodes/functions/PhysicalLightingModel.js +210 -12
- package/examples/jsm/nodes/functions/ShadowMaskModel.js +31 -0
- package/examples/jsm/nodes/functions/ToonLightingModel.js +49 -0
- package/examples/jsm/nodes/lighting/AnalyticLightNode.js +20 -5
- package/examples/jsm/nodes/lighting/DirectionalLightNode.js +2 -1
- package/examples/jsm/nodes/lighting/EnvironmentNode.js +11 -2
- package/examples/jsm/nodes/lighting/IrradianceNode.js +24 -0
- package/examples/jsm/nodes/lighting/LightsNode.js +28 -1
- package/examples/jsm/nodes/lighting/PointLightNode.js +2 -1
- package/examples/jsm/nodes/lighting/SpotLightNode.js +2 -1
- package/examples/jsm/nodes/materials/Line2NodeMaterial.js +11 -7
- package/examples/jsm/nodes/materials/Materials.js +4 -0
- package/examples/jsm/nodes/materials/MeshMatcapNodeMaterial.js +52 -0
- package/examples/jsm/nodes/materials/MeshNormalNodeMaterial.js +0 -2
- package/examples/jsm/nodes/materials/MeshPhongNodeMaterial.js +2 -2
- package/examples/jsm/nodes/materials/MeshPhysicalNodeMaterial.js +94 -6
- package/examples/jsm/nodes/materials/MeshStandardNodeMaterial.js +11 -4
- package/examples/jsm/nodes/materials/MeshToonNodeMaterial.js +34 -0
- package/examples/jsm/nodes/materials/NodeMaterial.js +43 -45
- package/examples/jsm/nodes/materials/ShadowNodeMaterial.js +34 -0
- package/examples/jsm/nodes/materials/VolumeNodeMaterial.js +106 -0
- package/examples/jsm/nodes/math/HashNode.js +2 -2
- package/examples/jsm/nodes/pmrem/PMREMUtils.js +1 -1
- package/examples/jsm/nodes/shadernode/ShaderNode.js +57 -41
- package/examples/jsm/nodes/utils/ArrayElementNode.js +1 -1
- package/examples/jsm/nodes/utils/MatcapUVNode.js +1 -1
- package/examples/jsm/nodes/utils/TimerNode.js +1 -1
- package/examples/jsm/objects/Lensflare.js +2 -2
- package/examples/jsm/physics/JoltPhysics.js +281 -0
- package/examples/jsm/postprocessing/RenderPass.js +1 -1
- package/examples/jsm/postprocessing/RenderTransitionPass.js +193 -0
- package/examples/jsm/renderers/CSS2DRenderer.js +25 -5
- package/examples/jsm/renderers/CSS3DRenderer.js +24 -3
- package/examples/jsm/renderers/common/Attributes.js +2 -0
- package/examples/jsm/renderers/common/Background.js +3 -3
- package/examples/jsm/renderers/common/Bindings.js +17 -0
- package/examples/jsm/renderers/common/ChainMap.js +18 -48
- package/examples/jsm/renderers/common/ClippingContext.js +5 -5
- package/examples/jsm/renderers/common/Pipelines.js +2 -2
- package/examples/jsm/renderers/common/RenderBundle.js +18 -0
- package/examples/jsm/renderers/common/RenderBundles.js +38 -0
- package/examples/jsm/renderers/common/RenderList.js +10 -1
- package/examples/jsm/renderers/common/RenderObject.js +49 -1
- package/examples/jsm/renderers/common/Renderer.js +268 -25
- package/examples/jsm/renderers/common/Textures.js +1 -1
- package/examples/jsm/renderers/common/Uniform.js +1 -1
- package/examples/jsm/renderers/common/extras/PMREMGenerator.js +13 -17
- package/examples/jsm/renderers/common/nodes/NodeSampledTexture.js +18 -4
- package/examples/jsm/renderers/common/nodes/NodeSampler.js +6 -0
- package/examples/jsm/renderers/common/nodes/Nodes.js +31 -47
- package/examples/jsm/renderers/webgl/WebGLBackend.js +7 -21
- package/examples/jsm/renderers/webgl/WebGLBufferRenderer.js +5 -1
- package/examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js +23 -5
- package/examples/jsm/renderers/webgl/utils/WebGLTextureUtils.js +114 -13
- package/examples/jsm/renderers/webgl/utils/WebGLUtils.js +3 -21
- package/examples/jsm/renderers/webgpu/WebGPUBackend.js +80 -46
- package/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js +85 -12
- package/examples/jsm/renderers/webgpu/utils/WebGPUAttributeUtils.js +4 -1
- package/examples/jsm/renderers/webgpu/utils/WebGPUBindingUtils.js +10 -1
- package/examples/jsm/renderers/webgpu/utils/WebGPUConstants.js +6 -0
- package/examples/jsm/renderers/webgpu/utils/WebGPUPipelineUtils.js +62 -19
- package/examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js +62 -3
- package/examples/jsm/transpiler/GLSLDecoder.js +1 -1
- package/examples/jsm/transpiler/ShaderToyDecoder.js +1 -1
- package/examples/jsm/utils/BufferGeometryUtils.js +18 -16
- package/examples/jsm/utils/GPUStatsPanel.js +2 -0
- package/examples/jsm/utils/SceneUtils.js +60 -1
- package/examples/jsm/utils/SortUtils.js +8 -5
- package/examples/jsm/webxr/OculusHandModel.js +3 -2
- package/examples/jsm/webxr/XRHandModelFactory.js +4 -2
- package/package.json +3 -2
- package/src/animation/tracks/BooleanKeyframeTrack.js +10 -1
- package/src/animation/tracks/QuaternionKeyframeTrack.js +1 -2
- package/src/animation/tracks/StringKeyframeTrack.js +10 -1
- package/src/constants.js +1 -1
- package/src/core/Object3D.js +2 -0
- package/src/core/Raycaster.js +6 -2
- package/src/core/RenderTarget.js +8 -0
- package/src/extras/PMREMGenerator.js +12 -11
- package/src/loaders/FileLoader.js +5 -1
- package/src/loaders/LoaderUtils.js +3 -1
- package/src/loaders/MaterialLoader.js +1 -0
- package/src/loaders/ObjectLoader.js +1 -0
- package/src/materials/Material.js +2 -0
- package/src/materials/MeshPhysicalMaterial.js +20 -0
- package/src/objects/BatchedMesh.js +114 -1
- package/src/objects/Line.js +66 -43
- package/src/renderers/WebGLRenderer.js +371 -109
- package/src/renderers/shaders/ShaderChunk/batching_pars_vertex.glsl.js +15 -0
- package/src/renderers/shaders/ShaderChunk/color_pars_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/color_vertex.glsl.js +9 -1
- package/src/renderers/shaders/ShaderChunk/lights_pars_begin.glsl.js +8 -22
- package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +6 -0
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +1 -0
- package/src/renderers/shaders/ShaderChunk/morphcolor_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/morphinstance_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/morphnormal_vertex.glsl.js +3 -14
- package/src/renderers/shaders/ShaderChunk/morphtarget_pars_vertex.glsl.js +10 -31
- package/src/renderers/shaders/ShaderChunk/morphtarget_vertex.glsl.js +3 -23
- package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +17 -9
- package/src/renderers/shaders/ShaderChunk/transmission_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/transmission_pars_fragment.glsl.js +47 -13
- package/src/renderers/shaders/ShaderChunk.js +0 -2
- package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +4 -0
- package/src/renderers/shaders/ShaderLib.js +1 -0
- package/src/renderers/webgl/WebGLBackground.js +24 -3
- package/src/renderers/webgl/WebGLBufferRenderer.js +36 -0
- package/src/renderers/webgl/WebGLCapabilities.js +33 -1
- package/src/renderers/webgl/WebGLExtensions.js +3 -1
- package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +36 -0
- package/src/renderers/webgl/WebGLLights.js +9 -12
- package/src/renderers/webgl/WebGLMaterials.js +7 -5
- package/src/renderers/webgl/WebGLMorphtargets.js +1 -2
- package/src/renderers/webgl/WebGLProgram.js +5 -36
- package/src/renderers/webgl/WebGLPrograms.js +19 -14
- package/src/renderers/webgl/WebGLRenderStates.js +8 -4
- package/src/renderers/webgl/WebGLShadowMap.js +25 -25
- package/src/renderers/webgl/WebGLTextures.js +206 -129
- package/src/renderers/webgl/WebGLUtils.js +3 -21
- package/src/renderers/webxr/WebXRDepthSensing.js +3 -3
- package/src/renderers/webxr/WebXRManager.js +8 -6
- package/src/textures/CompressedArrayTexture.js +14 -0
- package/src/textures/DataArrayTexture.js +14 -0
- package/src/textures/DepthTexture.js +1 -3
- package/src/utils.js +30 -1
- package/examples/jsm/renderers/webgl-legacy/nodes/GLSL1NodeBuilder.js +0 -318
- package/examples/jsm/renderers/webgl-legacy/nodes/SlotNode.js +0 -26
- package/examples/jsm/renderers/webgl-legacy/nodes/WebGLNodeBuilder.js +0 -792
- package/examples/jsm/renderers/webgl-legacy/nodes/WebGLNodes.js +0 -51
- package/src/renderers/shaders/ShaderChunk/lightmap_fragment.glsl.js +0 -10
package/build/three.module.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright 2010-
|
|
3
|
+
* Copyright 2010-2024 Three.js Authors
|
|
4
4
|
* SPDX-License-Identifier: MIT
|
|
5
5
|
*/
|
|
6
|
-
const REVISION = '
|
|
6
|
+
const REVISION = '165';
|
|
7
7
|
|
|
8
8
|
const MOUSE = { LEFT: 0, MIDDLE: 1, RIGHT: 2, ROTATE: 0, DOLLY: 1, PAN: 2 };
|
|
9
9
|
const TOUCH = { ROTATE: 0, PAN: 1, DOLLY_PAN: 2, DOLLY_ROTATE: 3 };
|
|
@@ -1560,6 +1560,35 @@ function warnOnce( message ) {
|
|
|
1560
1560
|
|
|
1561
1561
|
}
|
|
1562
1562
|
|
|
1563
|
+
function probeAsync( gl, sync, interval ) {
|
|
1564
|
+
|
|
1565
|
+
return new Promise( function ( resolve, reject ) {
|
|
1566
|
+
|
|
1567
|
+
function probe() {
|
|
1568
|
+
|
|
1569
|
+
switch ( gl.clientWaitSync( sync, gl.SYNC_FLUSH_COMMANDS_BIT, 0 ) ) {
|
|
1570
|
+
|
|
1571
|
+
case gl.WAIT_FAILED:
|
|
1572
|
+
reject();
|
|
1573
|
+
break;
|
|
1574
|
+
|
|
1575
|
+
case gl.TIMEOUT_EXPIRED:
|
|
1576
|
+
setTimeout( probe, interval );
|
|
1577
|
+
break;
|
|
1578
|
+
|
|
1579
|
+
default:
|
|
1580
|
+
resolve();
|
|
1581
|
+
|
|
1582
|
+
}
|
|
1583
|
+
|
|
1584
|
+
}
|
|
1585
|
+
|
|
1586
|
+
setTimeout( probe, interval );
|
|
1587
|
+
|
|
1588
|
+
} );
|
|
1589
|
+
|
|
1590
|
+
}
|
|
1591
|
+
|
|
1563
1592
|
/**
|
|
1564
1593
|
* Matrices converting P3 <-> Rec. 709 primaries, without gamut mapping
|
|
1565
1594
|
* or clipping. Based on W3C specifications for sRGB and Display P3,
|
|
@@ -2921,6 +2950,8 @@ class RenderTarget extends EventDispatcher {
|
|
|
2921
2950
|
minFilter: LinearFilter,
|
|
2922
2951
|
depthBuffer: true,
|
|
2923
2952
|
stencilBuffer: false,
|
|
2953
|
+
resolveDepthBuffer: true,
|
|
2954
|
+
resolveStencilBuffer: true,
|
|
2924
2955
|
depthTexture: null,
|
|
2925
2956
|
samples: 0,
|
|
2926
2957
|
count: 1
|
|
@@ -2945,6 +2976,9 @@ class RenderTarget extends EventDispatcher {
|
|
|
2945
2976
|
this.depthBuffer = options.depthBuffer;
|
|
2946
2977
|
this.stencilBuffer = options.stencilBuffer;
|
|
2947
2978
|
|
|
2979
|
+
this.resolveDepthBuffer = options.resolveDepthBuffer;
|
|
2980
|
+
this.resolveStencilBuffer = options.resolveStencilBuffer;
|
|
2981
|
+
|
|
2948
2982
|
this.depthTexture = options.depthTexture;
|
|
2949
2983
|
|
|
2950
2984
|
this.samples = options.samples;
|
|
@@ -3022,6 +3056,9 @@ class RenderTarget extends EventDispatcher {
|
|
|
3022
3056
|
this.depthBuffer = source.depthBuffer;
|
|
3023
3057
|
this.stencilBuffer = source.stencilBuffer;
|
|
3024
3058
|
|
|
3059
|
+
this.resolveDepthBuffer = source.resolveDepthBuffer;
|
|
3060
|
+
this.resolveStencilBuffer = source.resolveStencilBuffer;
|
|
3061
|
+
|
|
3025
3062
|
if ( source.depthTexture !== null ) this.depthTexture = source.depthTexture.clone();
|
|
3026
3063
|
|
|
3027
3064
|
this.samples = source.samples;
|
|
@@ -3069,6 +3106,20 @@ class DataArrayTexture extends Texture {
|
|
|
3069
3106
|
this.flipY = false;
|
|
3070
3107
|
this.unpackAlignment = 1;
|
|
3071
3108
|
|
|
3109
|
+
this.layerUpdates = new Set();
|
|
3110
|
+
|
|
3111
|
+
}
|
|
3112
|
+
|
|
3113
|
+
addLayerUpdate( layerIndex ) {
|
|
3114
|
+
|
|
3115
|
+
this.layerUpdates.add( layerIndex );
|
|
3116
|
+
|
|
3117
|
+
}
|
|
3118
|
+
|
|
3119
|
+
clearLayerUpdates() {
|
|
3120
|
+
|
|
3121
|
+
this.layerUpdates.clear();
|
|
3122
|
+
|
|
3072
3123
|
}
|
|
3073
3124
|
|
|
3074
3125
|
}
|
|
@@ -7838,6 +7889,8 @@ class Object3D extends EventDispatcher {
|
|
|
7838
7889
|
|
|
7839
7890
|
object.matricesTexture = this._matricesTexture.toJSON( meta );
|
|
7840
7891
|
|
|
7892
|
+
if ( this._colorsTexture !== null ) object.colorsTexture = this._colorsTexture.toJSON( meta );
|
|
7893
|
+
|
|
7841
7894
|
if ( this.boundingSphere !== null ) {
|
|
7842
7895
|
|
|
7843
7896
|
object.boundingSphere = {
|
|
@@ -9237,6 +9290,8 @@ class Material extends EventDispatcher {
|
|
|
9237
9290
|
|
|
9238
9291
|
}
|
|
9239
9292
|
|
|
9293
|
+
if ( this.dispersion !== undefined ) data.dispersion = this.dispersion;
|
|
9294
|
+
|
|
9240
9295
|
if ( this.iridescence !== undefined ) data.iridescence = this.iridescence;
|
|
9241
9296
|
if ( this.iridescenceIOR !== undefined ) data.iridescenceIOR = this.iridescenceIOR;
|
|
9242
9297
|
if ( this.iridescenceThicknessRange !== undefined ) data.iridescenceThicknessRange = this.iridescenceThicknessRange;
|
|
@@ -11785,7 +11840,7 @@ class Mesh extends Object3D {
|
|
|
11785
11840
|
|
|
11786
11841
|
}
|
|
11787
11842
|
|
|
11788
|
-
function checkIntersection( object, material, raycaster, ray, pA, pB, pC, point ) {
|
|
11843
|
+
function checkIntersection$1( object, material, raycaster, ray, pA, pB, pC, point ) {
|
|
11789
11844
|
|
|
11790
11845
|
let intersect;
|
|
11791
11846
|
|
|
@@ -11822,7 +11877,7 @@ function checkGeometryIntersection( object, material, raycaster, ray, uv, uv1, n
|
|
|
11822
11877
|
object.getVertexPosition( b, _vB$1 );
|
|
11823
11878
|
object.getVertexPosition( c, _vC$1 );
|
|
11824
11879
|
|
|
11825
|
-
const intersection = checkIntersection( object, material, raycaster, ray, _vA$1, _vB$1, _vC$1, _intersectionPoint );
|
|
11880
|
+
const intersection = checkIntersection$1( object, material, raycaster, ray, _vA$1, _vB$1, _vC$1, _intersectionPoint );
|
|
11826
11881
|
|
|
11827
11882
|
if ( intersection ) {
|
|
11828
11883
|
|
|
@@ -13748,7 +13803,7 @@ var aomap_fragment = "#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D(
|
|
|
13748
13803
|
|
|
13749
13804
|
var aomap_pars_fragment = "#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif";
|
|
13750
13805
|
|
|
13751
|
-
var batching_pars_vertex = "#ifdef USE_BATCHING\n\tattribute float batchId;\n\tuniform highp sampler2D batchingTexture;\n\tmat4 getBatchingMatrix( const in float i ) {\n\t\tint size = textureSize( batchingTexture, 0 ).x;\n\t\tint j = int( i ) * 4;\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\tvec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );\n\t\tvec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );\n\t\tvec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );\n\t\tvec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );\n\t\treturn mat4( v1, v2, v3, v4 );\n\t}\n#endif";
|
|
13806
|
+
var batching_pars_vertex = "#ifdef USE_BATCHING\n\tattribute float batchId;\n\tuniform highp sampler2D batchingTexture;\n\tmat4 getBatchingMatrix( const in float i ) {\n\t\tint size = textureSize( batchingTexture, 0 ).x;\n\t\tint j = int( i ) * 4;\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\tvec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );\n\t\tvec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );\n\t\tvec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );\n\t\tvec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );\n\t\treturn mat4( v1, v2, v3, v4 );\n\t}\n#endif\n#ifdef USE_BATCHING_COLOR\n\tuniform sampler2D batchingColorTexture;\n\tvec3 getBatchingColor( const in float i ) {\n\t\tint size = textureSize( batchingColorTexture, 0 ).x;\n\t\tint j = int( i );\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\treturn texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb;\n\t}\n#endif";
|
|
13752
13807
|
|
|
13753
13808
|
var batching_vertex = "#ifdef USE_BATCHING\n\tmat4 batchingMatrix = getBatchingMatrix( batchId );\n#endif";
|
|
13754
13809
|
|
|
@@ -13774,9 +13829,9 @@ var color_fragment = "#if defined( USE_COLOR_ALPHA )\n\tdiffuseColor *= vColor;\
|
|
|
13774
13829
|
|
|
13775
13830
|
var color_pars_fragment = "#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR )\n\tvarying vec3 vColor;\n#endif";
|
|
13776
13831
|
|
|
13777
|
-
var color_pars_vertex = "#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvarying vec3 vColor;\n#endif";
|
|
13832
|
+
var color_pars_vertex = "#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n\tvarying vec3 vColor;\n#endif";
|
|
13778
13833
|
|
|
13779
|
-
var color_vertex = "#if defined( USE_COLOR_ALPHA )\n\tvColor = vec4( 1.0 );\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvColor = vec3( 1.0 );\n#endif\n#ifdef USE_COLOR\n\tvColor *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n\tvColor.xyz *= instanceColor.xyz;\n#endif";
|
|
13834
|
+
var color_vertex = "#if defined( USE_COLOR_ALPHA )\n\tvColor = vec4( 1.0 );\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n\tvColor = vec3( 1.0 );\n#endif\n#ifdef USE_COLOR\n\tvColor *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n\tvColor.xyz *= instanceColor.xyz;\n#endif\n#ifdef USE_BATCHING_COLOR\n\tvec3 batchingColor = getBatchingColor( batchId );\n\tvColor.xyz *= batchingColor.xyz;\n#endif";
|
|
13780
13835
|
|
|
13781
13836
|
var common = "#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement( a ) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nvec3 pow2( const in vec3 x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }\nfloat average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract( sin( sn ) * c );\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\n#ifdef USE_ALPHAHASH\n\tvarying vec3 vPosition;\n#endif\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat luminance( const in vec3 rgb ) {\n\tconst vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );\n\treturn dot( weights, rgb );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\treturn vec2( u, v );\n}\nvec3 BRDF_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n}\nfloat F_Schlick( const in float f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n} // validated";
|
|
13782
13837
|
|
|
@@ -13816,15 +13871,13 @@ var fog_pars_fragment = "#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying flo
|
|
|
13816
13871
|
|
|
13817
13872
|
var gradientmap_pars_fragment = "#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn vec3( texture2D( gradientMap, coord ).r );\n\t#else\n\t\tvec2 fw = fwidth( coord ) * 0.5;\n\t\treturn mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );\n\t#endif\n}";
|
|
13818
13873
|
|
|
13819
|
-
var lightmap_fragment = "#ifdef USE_LIGHTMAP\n\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\treflectedLight.indirectDiffuse += lightMapIrradiance;\n#endif";
|
|
13820
|
-
|
|
13821
13874
|
var lightmap_pars_fragment = "#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif";
|
|
13822
13875
|
|
|
13823
13876
|
var lights_lambert_fragment = "LambertMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularStrength = specularStrength;";
|
|
13824
13877
|
|
|
13825
13878
|
var lights_lambert_pars_fragment = "varying vec3 vViewPosition;\nstruct LambertMaterial {\n\tvec3 diffuseColor;\n\tfloat specularStrength;\n};\nvoid RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Lambert\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Lambert";
|
|
13826
13879
|
|
|
13827
|
-
var lights_pars_begin = "uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\n#if defined( USE_LIGHT_PROBES )\n\tuniform vec3 lightProbe[ 9 ];\n#endif\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\treturn irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\
|
|
13880
|
+
var lights_pars_begin = "uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\n#if defined( USE_LIGHT_PROBES )\n\tuniform vec3 lightProbe[ 9 ];\n#endif\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\treturn irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\tif ( cutoffDistance > 0.0 ) {\n\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t}\n\treturn distanceFalloff;\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n\treturn smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {\n\t\tlight.color = directionalLight.color;\n\t\tlight.direction = directionalLight.direction;\n\t\tlight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {\n\t\tvec3 lVector = pointLight.position - geometryPosition;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tlight.color = pointLight.color;\n\t\tlight.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {\n\t\tvec3 lVector = spotLight.position - geometryPosition;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat angleCos = dot( light.direction, spotLight.direction );\n\t\tfloat spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\tif ( spotAttenuation > 0.0 ) {\n\t\t\tfloat lightDistance = length( lVector );\n\t\t\tlight.color = spotLight.color * spotAttenuation;\n\t\t\tlight.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t\t} else {\n\t\t\tlight.color = vec3( 0.0 );\n\t\t\tlight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n\t\tfloat dotNL = dot( normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\treturn irradiance;\n\t}\n#endif";
|
|
13828
13881
|
|
|
13829
13882
|
var envmap_physical_pars_fragment = "#ifdef USE_ENVMAP\n\tvec3 getIBLIrradiance( const in vec3 normal ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );\n\t\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\tvec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 reflectVec = reflect( - viewDir, normal );\n\t\t\treflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\t\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );\n\t\t\treturn envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\t#ifdef USE_ANISOTROPY\n\t\tvec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {\n\t\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\t\tvec3 bentNormal = cross( bitangent, viewDir );\n\t\t\t\tbentNormal = normalize( cross( bentNormal, bitangent ) );\n\t\t\t\tbentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );\n\t\t\t\treturn getIBLRadiance( viewDir, bentNormal, roughness );\n\t\t\t#else\n\t\t\t\treturn vec3( 0.0 );\n\t\t\t#endif\n\t\t}\n\t#endif\n#endif";
|
|
13830
13883
|
|
|
@@ -13836,9 +13889,9 @@ var lights_phong_fragment = "BlinnPhongMaterial material;\nmaterial.diffuseColor
|
|
|
13836
13889
|
|
|
13837
13890
|
var lights_phong_pars_fragment = "varying vec3 vViewPosition;\nstruct BlinnPhongMaterial {\n\tvec3 diffuseColor;\n\tvec3 specularColor;\n\tfloat specularShininess;\n\tfloat specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong";
|
|
13838
13891
|
|
|
13839
|
-
var lights_physical_fragment = "PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n\tmaterial.ior = ior;\n\t#ifdef USE_SPECULAR\n\t\tfloat specularIntensityFactor = specularIntensity;\n\t\tvec3 specularColorFactor = specularColor;\n\t\t#ifdef USE_SPECULAR_COLORMAP\n\t\t\tspecularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;\n\t\t#endif\n\t\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\t\tspecularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;\n\t\t#endif\n\t\tmaterial.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n\t#else\n\t\tfloat specularIntensityFactor = 1.0;\n\t\tvec3 specularColorFactor = vec3( 1.0 );\n\t\tmaterial.specularF90 = 1.0;\n\t#endif\n\tmaterial.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\tmaterial.clearcoatF0 = vec3( 0.04 );\n\tmaterial.clearcoatF90 = 1.0;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_IRIDESCENCE\n\tmaterial.iridescence = iridescence;\n\tmaterial.iridescenceIOR = iridescenceIOR;\n\t#ifdef USE_IRIDESCENCEMAP\n\t\tmaterial.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;\n\t#endif\n\t#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\t\tmaterial.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;\n\t#else\n\t\tmaterial.iridescenceThickness = iridescenceThicknessMaximum;\n\t#endif\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheenColor;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tmaterial.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;\n\t#endif\n\tmaterial.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tmaterial.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\t#ifdef USE_ANISOTROPYMAP\n\t\tmat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );\n\t\tvec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;\n\t\tvec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;\n\t#else\n\t\tvec2 anisotropyV = anisotropyVector;\n\t#endif\n\tmaterial.anisotropy = length( anisotropyV );\n\tif( material.anisotropy == 0.0 ) {\n\t\tanisotropyV = vec2( 1.0, 0.0 );\n\t} else {\n\t\tanisotropyV /= material.anisotropy;\n\t\tmaterial.anisotropy = saturate( material.anisotropy );\n\t}\n\tmaterial.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );\n\tmaterial.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;\n\tmaterial.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;\n#endif";
|
|
13892
|
+
var lights_physical_fragment = "PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n\tmaterial.ior = ior;\n\t#ifdef USE_SPECULAR\n\t\tfloat specularIntensityFactor = specularIntensity;\n\t\tvec3 specularColorFactor = specularColor;\n\t\t#ifdef USE_SPECULAR_COLORMAP\n\t\t\tspecularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;\n\t\t#endif\n\t\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\t\tspecularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;\n\t\t#endif\n\t\tmaterial.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n\t#else\n\t\tfloat specularIntensityFactor = 1.0;\n\t\tvec3 specularColorFactor = vec3( 1.0 );\n\t\tmaterial.specularF90 = 1.0;\n\t#endif\n\tmaterial.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\tmaterial.clearcoatF0 = vec3( 0.04 );\n\tmaterial.clearcoatF90 = 1.0;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_DISPERSION\n\tmaterial.dispersion = dispersion;\n#endif\n#ifdef USE_IRIDESCENCE\n\tmaterial.iridescence = iridescence;\n\tmaterial.iridescenceIOR = iridescenceIOR;\n\t#ifdef USE_IRIDESCENCEMAP\n\t\tmaterial.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;\n\t#endif\n\t#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\t\tmaterial.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;\n\t#else\n\t\tmaterial.iridescenceThickness = iridescenceThicknessMaximum;\n\t#endif\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheenColor;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tmaterial.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;\n\t#endif\n\tmaterial.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tmaterial.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\t#ifdef USE_ANISOTROPYMAP\n\t\tmat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );\n\t\tvec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;\n\t\tvec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;\n\t#else\n\t\tvec2 anisotropyV = anisotropyVector;\n\t#endif\n\tmaterial.anisotropy = length( anisotropyV );\n\tif( material.anisotropy == 0.0 ) {\n\t\tanisotropyV = vec2( 1.0, 0.0 );\n\t} else {\n\t\tanisotropyV /= material.anisotropy;\n\t\tmaterial.anisotropy = saturate( material.anisotropy );\n\t}\n\tmaterial.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );\n\tmaterial.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;\n\tmaterial.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;\n#endif";
|
|
13840
13893
|
|
|
13841
|
-
var lights_physical_pars_fragment = "struct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tfloat roughness;\n\tvec3 specularColor;\n\tfloat specularF90;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat clearcoat;\n\t\tfloat clearcoatRoughness;\n\t\tvec3 clearcoatF0;\n\t\tfloat clearcoatF90;\n\t#endif\n\t#ifdef USE_IRIDESCENCE\n\t\tfloat iridescence;\n\t\tfloat iridescenceIOR;\n\t\tfloat iridescenceThickness;\n\t\tvec3 iridescenceFresnel;\n\t\tvec3 iridescenceF0;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tvec3 sheenColor;\n\t\tfloat sheenRoughness;\n\t#endif\n\t#ifdef IOR\n\t\tfloat ior;\n\t#endif\n\t#ifdef USE_TRANSMISSION\n\t\tfloat transmission;\n\t\tfloat transmissionAlpha;\n\t\tfloat thickness;\n\t\tfloat attenuationDistance;\n\t\tvec3 attenuationColor;\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat anisotropy;\n\t\tfloat alphaT;\n\t\tvec3 anisotropyT;\n\t\tvec3 anisotropyB;\n\t#endif\n};\nvec3 clearcoatSpecularDirect = vec3( 0.0 );\nvec3 clearcoatSpecularIndirect = vec3( 0.0 );\nvec3 sheenSpecularDirect = vec3( 0.0 );\nvec3 sheenSpecularIndirect = vec3(0.0 );\nvec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {\n float x = clamp( 1.0 - dotVH, 0.0, 1.0 );\n float x2 = x * x;\n float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );\n return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );\n}\nfloat V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\n#ifdef USE_ANISOTROPY\n\tfloat V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {\n\t\tfloat gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );\n\t\tfloat gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );\n\t\tfloat v = 0.5 / ( gv + gl );\n\t\treturn saturate(v);\n\t}\n\tfloat D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {\n\t\tfloat a2 = alphaT * alphaB;\n\t\thighp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );\n\t\thighp float v2 = dot( v, v );\n\t\tfloat w2 = a2 / v2;\n\t\treturn RECIPROCAL_PI * a2 * pow2 ( w2 );\n\t}\n#endif\n#ifdef USE_CLEARCOAT\n\tvec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {\n\t\tvec3 f0 = material.clearcoatF0;\n\t\tfloat f90 = material.clearcoatF90;\n\t\tfloat roughness = material.clearcoatRoughness;\n\t\tfloat alpha = pow2( roughness );\n\t\tvec3 halfDir = normalize( lightDir + viewDir );\n\t\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\t\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\t\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\t\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\t\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t\treturn F * ( V * D );\n\t}\n#endif\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n\tvec3 f0 = material.specularColor;\n\tfloat f90 = material.specularF90;\n\tfloat roughness = material.roughness;\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t#ifdef USE_IRIDESCENCE\n\t\tF = mix( F, material.iridescenceFresnel, material.iridescence );\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat dotTL = dot( material.anisotropyT, lightDir );\n\t\tfloat dotTV = dot( material.anisotropyT, viewDir );\n\t\tfloat dotTH = dot( material.anisotropyT, halfDir );\n\t\tfloat dotBL = dot( material.anisotropyB, lightDir );\n\t\tfloat dotBV = dot( material.anisotropyB, viewDir );\n\t\tfloat dotBH = dot( material.anisotropyB, halfDir );\n\t\tfloat V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );\n\t\tfloat D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );\n\t#else\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t#endif\n\treturn F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n\tfloat alpha = pow2( roughness );\n\tfloat invAlpha = 1.0 / alpha;\n\tfloat cos2h = dotNH * dotNH;\n\tfloat sin2h = max( 1.0 - cos2h, 0.0078125 );\n\treturn ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n\treturn saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat D = D_Charlie( sheenRoughness, dotNH );\n\tfloat V = V_Neubelt( dotNV, dotNL );\n\treturn sheenColor * ( D * V );\n}\n#endif\nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat r2 = roughness * roughness;\n\tfloat a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;\n\tfloat b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;\n\tfloat DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );\n\treturn saturate( DG * RECIPROCAL_PI );\n}\nvec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;\n\treturn fab;\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\treturn specularColor * fab.x + specularF90 * fab.y;\n}\n#ifdef USE_IRIDESCENCE\nvoid computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#else\nvoid computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#endif\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\t#ifdef USE_IRIDESCENCE\n\t\tvec3 Fr = mix( specularColor, iridescenceF0, iridescence );\n\t#else\n\t\tvec3 Fr = specularColor;\n\t#endif\n\tvec3 FssEss = Fr * fab.x + specularF90 * fab.y;\n\tfloat Ess = fab.x + fab.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometryNormal;\n\t\tvec3 viewDir = geometryViewDir;\n\t\tvec3 position = geometryPosition;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.roughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );\n\t#endif\n\treflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n\t#endif\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\t#ifdef USE_IRIDESCENCE\n\t\tcomputeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );\n\t#else\n\t\tcomputeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );\n\t#endif\n\tvec3 totalScattering = singleScattering + multiScattering;\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );\n\treflectedLight.indirectSpecular += radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}";
|
|
13894
|
+
var lights_physical_pars_fragment = "struct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tfloat roughness;\n\tvec3 specularColor;\n\tfloat specularF90;\n\tfloat dispersion;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat clearcoat;\n\t\tfloat clearcoatRoughness;\n\t\tvec3 clearcoatF0;\n\t\tfloat clearcoatF90;\n\t#endif\n\t#ifdef USE_IRIDESCENCE\n\t\tfloat iridescence;\n\t\tfloat iridescenceIOR;\n\t\tfloat iridescenceThickness;\n\t\tvec3 iridescenceFresnel;\n\t\tvec3 iridescenceF0;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tvec3 sheenColor;\n\t\tfloat sheenRoughness;\n\t#endif\n\t#ifdef IOR\n\t\tfloat ior;\n\t#endif\n\t#ifdef USE_TRANSMISSION\n\t\tfloat transmission;\n\t\tfloat transmissionAlpha;\n\t\tfloat thickness;\n\t\tfloat attenuationDistance;\n\t\tvec3 attenuationColor;\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat anisotropy;\n\t\tfloat alphaT;\n\t\tvec3 anisotropyT;\n\t\tvec3 anisotropyB;\n\t#endif\n};\nvec3 clearcoatSpecularDirect = vec3( 0.0 );\nvec3 clearcoatSpecularIndirect = vec3( 0.0 );\nvec3 sheenSpecularDirect = vec3( 0.0 );\nvec3 sheenSpecularIndirect = vec3(0.0 );\nvec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {\n float x = clamp( 1.0 - dotVH, 0.0, 1.0 );\n float x2 = x * x;\n float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );\n return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );\n}\nfloat V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\n#ifdef USE_ANISOTROPY\n\tfloat V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {\n\t\tfloat gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );\n\t\tfloat gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );\n\t\tfloat v = 0.5 / ( gv + gl );\n\t\treturn saturate(v);\n\t}\n\tfloat D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {\n\t\tfloat a2 = alphaT * alphaB;\n\t\thighp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );\n\t\thighp float v2 = dot( v, v );\n\t\tfloat w2 = a2 / v2;\n\t\treturn RECIPROCAL_PI * a2 * pow2 ( w2 );\n\t}\n#endif\n#ifdef USE_CLEARCOAT\n\tvec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {\n\t\tvec3 f0 = material.clearcoatF0;\n\t\tfloat f90 = material.clearcoatF90;\n\t\tfloat roughness = material.clearcoatRoughness;\n\t\tfloat alpha = pow2( roughness );\n\t\tvec3 halfDir = normalize( lightDir + viewDir );\n\t\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\t\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\t\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\t\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\t\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t\treturn F * ( V * D );\n\t}\n#endif\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n\tvec3 f0 = material.specularColor;\n\tfloat f90 = material.specularF90;\n\tfloat roughness = material.roughness;\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t#ifdef USE_IRIDESCENCE\n\t\tF = mix( F, material.iridescenceFresnel, material.iridescence );\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat dotTL = dot( material.anisotropyT, lightDir );\n\t\tfloat dotTV = dot( material.anisotropyT, viewDir );\n\t\tfloat dotTH = dot( material.anisotropyT, halfDir );\n\t\tfloat dotBL = dot( material.anisotropyB, lightDir );\n\t\tfloat dotBV = dot( material.anisotropyB, viewDir );\n\t\tfloat dotBH = dot( material.anisotropyB, halfDir );\n\t\tfloat V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );\n\t\tfloat D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );\n\t#else\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t#endif\n\treturn F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n\tfloat alpha = pow2( roughness );\n\tfloat invAlpha = 1.0 / alpha;\n\tfloat cos2h = dotNH * dotNH;\n\tfloat sin2h = max( 1.0 - cos2h, 0.0078125 );\n\treturn ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n\treturn saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat D = D_Charlie( sheenRoughness, dotNH );\n\tfloat V = V_Neubelt( dotNV, dotNL );\n\treturn sheenColor * ( D * V );\n}\n#endif\nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat r2 = roughness * roughness;\n\tfloat a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;\n\tfloat b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;\n\tfloat DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );\n\treturn saturate( DG * RECIPROCAL_PI );\n}\nvec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;\n\treturn fab;\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\treturn specularColor * fab.x + specularF90 * fab.y;\n}\n#ifdef USE_IRIDESCENCE\nvoid computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#else\nvoid computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#endif\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\t#ifdef USE_IRIDESCENCE\n\t\tvec3 Fr = mix( specularColor, iridescenceF0, iridescence );\n\t#else\n\t\tvec3 Fr = specularColor;\n\t#endif\n\tvec3 FssEss = Fr * fab.x + specularF90 * fab.y;\n\tfloat Ess = fab.x + fab.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometryNormal;\n\t\tvec3 viewDir = geometryViewDir;\n\t\tvec3 position = geometryPosition;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.roughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );\n\t#endif\n\treflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n\t#endif\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\t#ifdef USE_IRIDESCENCE\n\t\tcomputeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );\n\t#else\n\t\tcomputeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );\n\t#endif\n\tvec3 totalScattering = singleScattering + multiScattering;\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );\n\treflectedLight.indirectSpecular += radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}";
|
|
13842
13895
|
|
|
13843
13896
|
var lights_fragment_begin = "\nvec3 geometryPosition = - vViewPosition;\nvec3 geometryNormal = normal;\nvec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\nvec3 geometryClearcoatNormal = vec3( 0.0 );\n#ifdef USE_CLEARCOAT\n\tgeometryClearcoatNormal = clearcoatNormal;\n#endif\n#ifdef USE_IRIDESCENCE\n\tfloat dotNVi = saturate( dot( normal, geometryViewDir ) );\n\tif ( material.iridescenceThickness == 0.0 ) {\n\t\tmaterial.iridescence = 0.0;\n\t} else {\n\t\tmaterial.iridescence = saturate( material.iridescence );\n\t}\n\tif ( material.iridescence > 0.0 ) {\n\t\tmaterial.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\n\t\tmaterial.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );\n\t}\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointLightInfo( pointLight, geometryPosition, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\tvec4 spotColor;\n\tvec3 spotLightCoord;\n\tbool inSpotLightMap;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotLightInfo( spotLight, geometryPosition, directLight );\n\t\t#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX\n\t\t#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS\n\t\t#else\n\t\t#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#endif\n\t\t#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )\n\t\t\tspotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;\n\t\t\tinSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );\n\t\t\tspotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );\n\t\t\tdirectLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;\n\t\t#endif\n\t\t#undef SPOT_LIGHT_MAP_INDEX\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalLightInfo( directionalLight, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\t#if defined( USE_LIGHT_PROBES )\n\t\tirradiance += getLightProbeIrradiance( lightProbe, geometryNormal );\n\t#endif\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif";
|
|
13844
13897
|
|
|
@@ -13866,15 +13919,15 @@ var metalnessmap_fragment = "float metalnessFactor = metalness;\n#ifdef USE_META
|
|
|
13866
13919
|
|
|
13867
13920
|
var metalnessmap_pars_fragment = "#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif";
|
|
13868
13921
|
|
|
13869
|
-
var morphinstance_vertex = "#ifdef USE_INSTANCING_MORPH\n\tfloat morphTargetInfluences[MORPHTARGETS_COUNT];\n\tfloat morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tmorphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;\n\t}\n#endif";
|
|
13922
|
+
var morphinstance_vertex = "#ifdef USE_INSTANCING_MORPH\n\tfloat morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\tfloat morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tmorphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;\n\t}\n#endif";
|
|
13870
13923
|
|
|
13871
|
-
var morphcolor_vertex = "#if defined( USE_MORPHCOLORS )
|
|
13924
|
+
var morphcolor_vertex = "#if defined( USE_MORPHCOLORS )\n\tvColor *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t#if defined( USE_COLOR_ALPHA )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];\n\t\t#elif defined( USE_COLOR )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];\n\t\t#endif\n\t}\n#endif";
|
|
13872
13925
|
|
|
13873
|
-
var morphnormal_vertex = "#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\
|
|
13926
|
+
var morphnormal_vertex = "#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tif ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];\n\t}\n#endif";
|
|
13874
13927
|
|
|
13875
|
-
var morphtarget_pars_vertex = "#ifdef USE_MORPHTARGETS\n\t#ifndef USE_INSTANCING_MORPH\n\t\tuniform float morphTargetBaseInfluence;\n\t
|
|
13928
|
+
var morphtarget_pars_vertex = "#ifdef USE_MORPHTARGETS\n\t#ifndef USE_INSTANCING_MORPH\n\t\tuniform float morphTargetBaseInfluence;\n\t\tuniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\t#endif\n\tuniform sampler2DArray morphTargetsTexture;\n\tuniform ivec2 morphTargetsTextureSize;\n\tvec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {\n\t\tint texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;\n\t\tint y = texelIndex / morphTargetsTextureSize.x;\n\t\tint x = texelIndex - y * morphTargetsTextureSize.x;\n\t\tivec3 morphUV = ivec3( x, y, morphTargetIndex );\n\t\treturn texelFetch( morphTargetsTexture, morphUV, 0 );\n\t}\n#endif";
|
|
13876
13929
|
|
|
13877
|
-
var morphtarget_vertex = "#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\
|
|
13930
|
+
var morphtarget_vertex = "#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tif ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];\n\t}\n#endif";
|
|
13878
13931
|
|
|
13879
13932
|
var normal_fragment_begin = "float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n\tvec3 fdx = dFdx( vViewPosition );\n\tvec3 fdy = dFdy( vViewPosition );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal *= faceDirection;\n\t#endif\n#endif\n#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn = getTangentFrame( - vViewPosition, normal,\n\t\t#if defined( USE_NORMALMAP )\n\t\t\tvNormalMapUv\n\t\t#elif defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tvClearcoatNormalMapUv\n\t\t#else\n\t\t\tvUv\n\t\t#endif\n\t\t);\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn[0] *= faceDirection;\n\t\ttbn[1] *= faceDirection;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn2[0] *= faceDirection;\n\t\ttbn2[1] *= faceDirection;\n\t#endif\n#endif\nvec3 nonPerturbedNormal = normal;";
|
|
13880
13933
|
|
|
@@ -13934,11 +13987,11 @@ var specularmap_pars_fragment = "#ifdef USE_SPECULARMAP\n\tuniform sampler2D spe
|
|
|
13934
13987
|
|
|
13935
13988
|
var tonemapping_fragment = "#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif";
|
|
13936
13989
|
|
|
13937
|
-
var tonemapping_pars_fragment = "#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn saturate( toneMappingExposure * color );\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3( 1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108, 1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605, 1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nconst mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(\n\tvec3( 1.6605, - 0.1246, - 0.0182 ),\n\tvec3( - 0.5876, 1.1329, - 0.1006 ),\n\tvec3( - 0.0728, - 0.0083, 1.1187 )\n);\nconst mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(\n\tvec3( 0.6274, 0.0691, 0.0164 ),\n\tvec3( 0.3293, 0.9195, 0.0880 ),\n\tvec3( 0.0433, 0.0113, 0.8956 )\n);\nvec3 agxDefaultContrastApprox( vec3 x ) {\n\tvec3 x2 = x * x;\n\tvec3 x4 = x2 * x2;\n\treturn + 15.5 * x4 * x2\n\t\t- 40.14 * x4 * x\n\t\t+ 31.96 * x4\n\t\t- 6.868 * x2 * x\n\t\t+ 0.4298 * x2\n\t\t+ 0.1191 * x\n\t\t- 0.00232;\n}\nvec3 AgXToneMapping( vec3 color ) {\n\tconst mat3 AgXInsetMatrix = mat3(\n\t\tvec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),\n\t\tvec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),\n\t\tvec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )\n\t);\n\tconst mat3 AgXOutsetMatrix = mat3(\n\t\tvec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),\n\t\tvec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),\n\t\tvec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )\n\t);\n\tconst float AgxMinEv = - 12.47393;\tconst float AgxMaxEv = 4.026069;\n\tcolor *= toneMappingExposure;\n\tcolor = LINEAR_SRGB_TO_LINEAR_REC2020 * color;\n\tcolor = AgXInsetMatrix * color;\n\tcolor = max( color, 1e-10 );\tcolor = log2( color );\n\tcolor = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );\n\tcolor = clamp( color, 0.0, 1.0 );\n\tcolor = agxDefaultContrastApprox( color );\n\tcolor = AgXOutsetMatrix * color;\n\tcolor = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );\n\tcolor = LINEAR_REC2020_TO_LINEAR_SRGB * color;\n\tcolor = clamp( color, 0.0, 1.0 );\n\treturn color;\n}\nvec3 NeutralToneMapping( vec3 color ) {\n\
|
|
13990
|
+
var tonemapping_pars_fragment = "#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn saturate( toneMappingExposure * color );\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3( 1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108, 1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605, 1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nconst mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(\n\tvec3( 1.6605, - 0.1246, - 0.0182 ),\n\tvec3( - 0.5876, 1.1329, - 0.1006 ),\n\tvec3( - 0.0728, - 0.0083, 1.1187 )\n);\nconst mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(\n\tvec3( 0.6274, 0.0691, 0.0164 ),\n\tvec3( 0.3293, 0.9195, 0.0880 ),\n\tvec3( 0.0433, 0.0113, 0.8956 )\n);\nvec3 agxDefaultContrastApprox( vec3 x ) {\n\tvec3 x2 = x * x;\n\tvec3 x4 = x2 * x2;\n\treturn + 15.5 * x4 * x2\n\t\t- 40.14 * x4 * x\n\t\t+ 31.96 * x4\n\t\t- 6.868 * x2 * x\n\t\t+ 0.4298 * x2\n\t\t+ 0.1191 * x\n\t\t- 0.00232;\n}\nvec3 AgXToneMapping( vec3 color ) {\n\tconst mat3 AgXInsetMatrix = mat3(\n\t\tvec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),\n\t\tvec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),\n\t\tvec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )\n\t);\n\tconst mat3 AgXOutsetMatrix = mat3(\n\t\tvec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),\n\t\tvec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),\n\t\tvec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )\n\t);\n\tconst float AgxMinEv = - 12.47393;\tconst float AgxMaxEv = 4.026069;\n\tcolor *= toneMappingExposure;\n\tcolor = LINEAR_SRGB_TO_LINEAR_REC2020 * color;\n\tcolor = AgXInsetMatrix * color;\n\tcolor = max( color, 1e-10 );\tcolor = log2( color );\n\tcolor = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );\n\tcolor = clamp( color, 0.0, 1.0 );\n\tcolor = agxDefaultContrastApprox( color );\n\tcolor = AgXOutsetMatrix * color;\n\tcolor = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );\n\tcolor = LINEAR_REC2020_TO_LINEAR_SRGB * color;\n\tcolor = clamp( color, 0.0, 1.0 );\n\treturn color;\n}\nvec3 NeutralToneMapping( vec3 color ) {\n\tconst float StartCompression = 0.8 - 0.04;\n\tconst float Desaturation = 0.15;\n\tcolor *= toneMappingExposure;\n\tfloat x = min( color.r, min( color.g, color.b ) );\n\tfloat offset = x < 0.08 ? x - 6.25 * x * x : 0.04;\n\tcolor -= offset;\n\tfloat peak = max( color.r, max( color.g, color.b ) );\n\tif ( peak < StartCompression ) return color;\n\tfloat d = 1. - StartCompression;\n\tfloat newPeak = 1. - d * d / ( peak + d - StartCompression );\n\tcolor *= newPeak / peak;\n\tfloat g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );\n\treturn mix( color, vec3( newPeak ), g );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }";
|
|
13938
13991
|
|
|
13939
|
-
var transmission_fragment = "#ifdef USE_TRANSMISSION\n\tmaterial.transmission = transmission;\n\tmaterial.transmissionAlpha = 1.0;\n\tmaterial.thickness = thickness;\n\tmaterial.attenuationDistance = attenuationDistance;\n\tmaterial.attenuationColor = attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tmaterial.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tmaterial.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;\n\t#endif\n\tvec3 pos = vWorldPosition;\n\tvec3 v = normalize( cameraPosition - pos );\n\tvec3 n = inverseTransformDirection( normal, viewMatrix );\n\tvec4 transmitted = getIBLVolumeRefraction(\n\t\tn, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,\n\t\tpos, modelMatrix, viewMatrix, projectionMatrix, material.ior, material.thickness,\n\t\tmaterial.attenuationColor, material.attenuationDistance );\n\tmaterial.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );\n\ttotalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );\n#endif";
|
|
13992
|
+
var transmission_fragment = "#ifdef USE_TRANSMISSION\n\tmaterial.transmission = transmission;\n\tmaterial.transmissionAlpha = 1.0;\n\tmaterial.thickness = thickness;\n\tmaterial.attenuationDistance = attenuationDistance;\n\tmaterial.attenuationColor = attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tmaterial.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tmaterial.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;\n\t#endif\n\tvec3 pos = vWorldPosition;\n\tvec3 v = normalize( cameraPosition - pos );\n\tvec3 n = inverseTransformDirection( normal, viewMatrix );\n\tvec4 transmitted = getIBLVolumeRefraction(\n\t\tn, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,\n\t\tpos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,\n\t\tmaterial.attenuationColor, material.attenuationDistance );\n\tmaterial.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );\n\ttotalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );\n#endif";
|
|
13940
13993
|
|
|
13941
|
-
var transmission_pars_fragment = "#ifdef USE_TRANSMISSION\n\tuniform float transmission;\n\tuniform float thickness;\n\tuniform float attenuationDistance;\n\tuniform vec3 attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tuniform sampler2D transmissionMap;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tuniform sampler2D thicknessMap;\n\t#endif\n\tuniform vec2 transmissionSamplerSize;\n\tuniform sampler2D transmissionSamplerMap;\n\tuniform mat4 modelMatrix;\n\tuniform mat4 projectionMatrix;\n\tvarying vec3 vWorldPosition;\n\tfloat w0( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );\n\t}\n\tfloat w1( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );\n\t}\n\tfloat w2( float a ){\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );\n\t}\n\tfloat w3( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * a );\n\t}\n\tfloat g0( float a ) {\n\t\treturn w0( a ) + w1( a );\n\t}\n\tfloat g1( float a ) {\n\t\treturn w2( a ) + w3( a );\n\t}\n\tfloat h0( float a ) {\n\t\treturn - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );\n\t}\n\tfloat h1( float a ) {\n\t\treturn 1.0 + w3( a ) / ( w2( a ) + w3( a ) );\n\t}\n\tvec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {\n\t\tuv = uv * texelSize.zw + 0.5;\n\t\tvec2 iuv = floor( uv );\n\t\tvec2 fuv = fract( uv );\n\t\tfloat g0x = g0( fuv.x );\n\t\tfloat g1x = g1( fuv.x );\n\t\tfloat h0x = h0( fuv.x );\n\t\tfloat h1x = h1( fuv.x );\n\t\tfloat h0y = h0( fuv.y );\n\t\tfloat h1y = h1( fuv.y );\n\t\tvec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\treturn g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +\n\t\t\tg1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );\n\t}\n\tvec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {\n\t\tvec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );\n\t\tvec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );\n\t\tvec2 fLodSizeInv = 1.0 / fLodSize;\n\t\tvec2 cLodSizeInv = 1.0 / cLodSize;\n\t\tvec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );\n\t\tvec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );\n\t\treturn mix( fSample, cSample, fract( lod ) );\n\t}\n\tvec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {\n\t\tvec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );\n\t\tvec3 modelScale;\n\t\tmodelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n\t\tmodelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n\t\tmodelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n\t\treturn normalize( refractionVector ) * thickness * modelScale;\n\t}\n\tfloat applyIorToRoughness( const in float roughness, const in float ior ) {\n\t\treturn roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n\t}\n\tvec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {\n\t\tfloat lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n\t\treturn textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );\n\t}\n\tvec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tif ( isinf( attenuationDistance ) ) {\n\t\t\treturn vec3( 1.0 );\n\t\t} else {\n\t\t\tvec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n\t\t\tvec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );\t\t\treturn transmittance;\n\t\t}\n\t}\n\tvec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,\n\t\tconst in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,\n\t\tconst in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness,\n\t\tconst in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness,
|
|
13994
|
+
var transmission_pars_fragment = "#ifdef USE_TRANSMISSION\n\tuniform float transmission;\n\tuniform float thickness;\n\tuniform float attenuationDistance;\n\tuniform vec3 attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tuniform sampler2D transmissionMap;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tuniform sampler2D thicknessMap;\n\t#endif\n\tuniform vec2 transmissionSamplerSize;\n\tuniform sampler2D transmissionSamplerMap;\n\tuniform mat4 modelMatrix;\n\tuniform mat4 projectionMatrix;\n\tvarying vec3 vWorldPosition;\n\tfloat w0( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );\n\t}\n\tfloat w1( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );\n\t}\n\tfloat w2( float a ){\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );\n\t}\n\tfloat w3( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * a );\n\t}\n\tfloat g0( float a ) {\n\t\treturn w0( a ) + w1( a );\n\t}\n\tfloat g1( float a ) {\n\t\treturn w2( a ) + w3( a );\n\t}\n\tfloat h0( float a ) {\n\t\treturn - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );\n\t}\n\tfloat h1( float a ) {\n\t\treturn 1.0 + w3( a ) / ( w2( a ) + w3( a ) );\n\t}\n\tvec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {\n\t\tuv = uv * texelSize.zw + 0.5;\n\t\tvec2 iuv = floor( uv );\n\t\tvec2 fuv = fract( uv );\n\t\tfloat g0x = g0( fuv.x );\n\t\tfloat g1x = g1( fuv.x );\n\t\tfloat h0x = h0( fuv.x );\n\t\tfloat h1x = h1( fuv.x );\n\t\tfloat h0y = h0( fuv.y );\n\t\tfloat h1y = h1( fuv.y );\n\t\tvec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\treturn g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +\n\t\t\tg1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );\n\t}\n\tvec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {\n\t\tvec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );\n\t\tvec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );\n\t\tvec2 fLodSizeInv = 1.0 / fLodSize;\n\t\tvec2 cLodSizeInv = 1.0 / cLodSize;\n\t\tvec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );\n\t\tvec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );\n\t\treturn mix( fSample, cSample, fract( lod ) );\n\t}\n\tvec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {\n\t\tvec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );\n\t\tvec3 modelScale;\n\t\tmodelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n\t\tmodelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n\t\tmodelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n\t\treturn normalize( refractionVector ) * thickness * modelScale;\n\t}\n\tfloat applyIorToRoughness( const in float roughness, const in float ior ) {\n\t\treturn roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n\t}\n\tvec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {\n\t\tfloat lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n\t\treturn textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );\n\t}\n\tvec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tif ( isinf( attenuationDistance ) ) {\n\t\t\treturn vec3( 1.0 );\n\t\t} else {\n\t\t\tvec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n\t\t\tvec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );\t\t\treturn transmittance;\n\t\t}\n\t}\n\tvec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,\n\t\tconst in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,\n\t\tconst in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,\n\t\tconst in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tvec4 transmittedLight;\n\t\tvec3 transmittance;\n\t\t#ifdef USE_DISPERSION\n\t\t\tfloat halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;\n\t\t\tvec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );\n\t\t\tfor ( int i = 0; i < 3; i ++ ) {\n\t\t\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );\n\t\t\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\t\n\t\t\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\t\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\t\t\trefractionCoords += 1.0;\n\t\t\t\trefractionCoords /= 2.0;\n\t\t\n\t\t\t\tvec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );\n\t\t\t\ttransmittedLight[ i ] = transmissionSample[ i ];\n\t\t\t\ttransmittedLight.a += transmissionSample.a;\n\t\t\t\ttransmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];\n\t\t\t}\n\t\t\ttransmittedLight.a /= 3.0;\n\t\t\n\t\t#else\n\t\t\n\t\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n\t\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\t\trefractionCoords += 1.0;\n\t\t\trefractionCoords /= 2.0;\n\t\t\ttransmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n\t\t\ttransmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );\n\t\t\n\t\t#endif\n\t\tvec3 attenuatedColor = transmittance * transmittedLight.rgb;\n\t\tvec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n\t\tfloat transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;\n\t\treturn vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );\n\t}\n#endif";
|
|
13942
13995
|
|
|
13943
13996
|
var uv_pars_fragment = "#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tvarying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif";
|
|
13944
13997
|
|
|
@@ -13998,7 +14051,7 @@ const fragment$6 = "#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;
|
|
|
13998
14051
|
|
|
13999
14052
|
const vertex$5 = "#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n\tvarying vec3 vWorldPosition;\n#endif\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n#ifdef USE_TRANSMISSION\n\tvWorldPosition = worldPosition.xyz;\n#endif\n}";
|
|
14000
14053
|
|
|
14001
|
-
const fragment$5 = "#define STANDARD\n#ifdef PHYSICAL\n\t#define IOR\n\t#define USE_SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\n\tuniform float ior;\n#endif\n#ifdef USE_SPECULAR\n\tuniform float specularIntensity;\n\tuniform vec3 specularColor;\n\t#ifdef USE_SPECULAR_COLORMAP\n\t\tuniform sampler2D specularColorMap;\n\t#endif\n\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\tuniform sampler2D specularIntensityMap;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_IRIDESCENCE\n\tuniform float iridescence;\n\tuniform float iridescenceIOR;\n\tuniform float iridescenceThicknessMinimum;\n\tuniform float iridescenceThicknessMaximum;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheenColor;\n\tuniform float sheenRoughness;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tuniform sampler2D sheenColorMap;\n\t#endif\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tuniform sampler2D sheenRoughnessMap;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\tuniform vec2 anisotropyVector;\n\t#ifdef USE_ANISOTROPYMAP\n\t\tuniform sampler2D anisotropyMap;\n\t#endif\n#endif\nvarying vec3 vViewPosition;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <iridescence_fragment>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_physical_pars_fragment>\n#include <transmission_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <clearcoat_pars_fragment>\n#include <iridescence_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <roughnessmap_fragment>\n\t#include <metalnessmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <clearcoat_normal_fragment_begin>\n\t#include <clearcoat_normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_physical_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t#include <transmission_fragment>\n\tvec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n\t#ifdef USE_SHEEN\n\t\tfloat sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );\n\t\toutgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );\n\t\tvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\t\toutgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;\n\t#endif\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}";
|
|
14054
|
+
const fragment$5 = "#define STANDARD\n#ifdef PHYSICAL\n\t#define IOR\n\t#define USE_SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\n\tuniform float ior;\n#endif\n#ifdef USE_SPECULAR\n\tuniform float specularIntensity;\n\tuniform vec3 specularColor;\n\t#ifdef USE_SPECULAR_COLORMAP\n\t\tuniform sampler2D specularColorMap;\n\t#endif\n\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\tuniform sampler2D specularIntensityMap;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_DISPERSION\n\tuniform float dispersion;\n#endif\n#ifdef USE_IRIDESCENCE\n\tuniform float iridescence;\n\tuniform float iridescenceIOR;\n\tuniform float iridescenceThicknessMinimum;\n\tuniform float iridescenceThicknessMaximum;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheenColor;\n\tuniform float sheenRoughness;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tuniform sampler2D sheenColorMap;\n\t#endif\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tuniform sampler2D sheenRoughnessMap;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\tuniform vec2 anisotropyVector;\n\t#ifdef USE_ANISOTROPYMAP\n\t\tuniform sampler2D anisotropyMap;\n\t#endif\n#endif\nvarying vec3 vViewPosition;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <iridescence_fragment>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_physical_pars_fragment>\n#include <transmission_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <clearcoat_pars_fragment>\n#include <iridescence_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <roughnessmap_fragment>\n\t#include <metalnessmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <clearcoat_normal_fragment_begin>\n\t#include <clearcoat_normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_physical_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t#include <transmission_fragment>\n\tvec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n\t#ifdef USE_SHEEN\n\t\tfloat sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );\n\t\toutgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );\n\t\tvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\t\toutgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;\n\t#endif\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}";
|
|
14002
14055
|
|
|
14003
14056
|
const vertex$4 = "#define TOON\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}";
|
|
14004
14057
|
|
|
@@ -14060,7 +14113,6 @@ const ShaderChunk = {
|
|
|
14060
14113
|
fog_fragment: fog_fragment,
|
|
14061
14114
|
fog_pars_fragment: fog_pars_fragment,
|
|
14062
14115
|
gradientmap_pars_fragment: gradientmap_pars_fragment,
|
|
14063
|
-
lightmap_fragment: lightmap_fragment,
|
|
14064
14116
|
lightmap_pars_fragment: lightmap_pars_fragment,
|
|
14065
14117
|
lights_lambert_fragment: lights_lambert_fragment,
|
|
14066
14118
|
lights_lambert_pars_fragment: lights_lambert_pars_fragment,
|
|
@@ -14696,6 +14748,7 @@ ShaderLib.physical = {
|
|
|
14696
14748
|
clearcoatRoughness: { value: 0 },
|
|
14697
14749
|
clearcoatRoughnessMap: { value: null },
|
|
14698
14750
|
clearcoatRoughnessMapTransform: { value: /*@__PURE__*/ new Matrix3() },
|
|
14751
|
+
dispersion: { value: 0 },
|
|
14699
14752
|
iridescence: { value: 0 },
|
|
14700
14753
|
iridescenceMap: { value: null },
|
|
14701
14754
|
iridescenceMapTransform: { value: /*@__PURE__*/ new Matrix3() },
|
|
@@ -14754,9 +14807,8 @@ function WebGLBackground( renderer, cubemaps, cubeuvmaps, state, objects, alpha,
|
|
|
14754
14807
|
let currentBackgroundVersion = 0;
|
|
14755
14808
|
let currentTonemapping = null;
|
|
14756
14809
|
|
|
14757
|
-
function
|
|
14810
|
+
function getBackground( scene ) {
|
|
14758
14811
|
|
|
14759
|
-
let forceClear = false;
|
|
14760
14812
|
let background = scene.isScene === true ? scene.background : null;
|
|
14761
14813
|
|
|
14762
14814
|
if ( background && background.isTexture ) {
|
|
@@ -14766,6 +14818,15 @@ function WebGLBackground( renderer, cubemaps, cubeuvmaps, state, objects, alpha,
|
|
|
14766
14818
|
|
|
14767
14819
|
}
|
|
14768
14820
|
|
|
14821
|
+
return background;
|
|
14822
|
+
|
|
14823
|
+
}
|
|
14824
|
+
|
|
14825
|
+
function render( scene ) {
|
|
14826
|
+
|
|
14827
|
+
let forceClear = false;
|
|
14828
|
+
const background = getBackground( scene );
|
|
14829
|
+
|
|
14769
14830
|
if ( background === null ) {
|
|
14770
14831
|
|
|
14771
14832
|
setClear( clearColor, clearAlpha );
|
|
@@ -14791,10 +14852,22 @@ function WebGLBackground( renderer, cubemaps, cubeuvmaps, state, objects, alpha,
|
|
|
14791
14852
|
|
|
14792
14853
|
if ( renderer.autoClear || forceClear ) {
|
|
14793
14854
|
|
|
14855
|
+
// buffers might not be writable which is required to ensure a correct clear
|
|
14856
|
+
|
|
14857
|
+
state.buffers.depth.setTest( true );
|
|
14858
|
+
state.buffers.depth.setMask( true );
|
|
14859
|
+
state.buffers.color.setMask( true );
|
|
14860
|
+
|
|
14794
14861
|
renderer.clear( renderer.autoClearColor, renderer.autoClearDepth, renderer.autoClearStencil );
|
|
14795
14862
|
|
|
14796
14863
|
}
|
|
14797
14864
|
|
|
14865
|
+
}
|
|
14866
|
+
|
|
14867
|
+
function addToRenderList( renderList, scene ) {
|
|
14868
|
+
|
|
14869
|
+
const background = getBackground( scene );
|
|
14870
|
+
|
|
14798
14871
|
if ( background && ( background.isCubeTexture || background.mapping === CubeUVReflectionMapping ) ) {
|
|
14799
14872
|
|
|
14800
14873
|
if ( boxMesh === undefined ) {
|
|
@@ -14975,7 +15048,8 @@ function WebGLBackground( renderer, cubemaps, cubeuvmaps, state, objects, alpha,
|
|
|
14975
15048
|
setClear( clearColor, clearAlpha );
|
|
14976
15049
|
|
|
14977
15050
|
},
|
|
14978
|
-
render: render
|
|
15051
|
+
render: render,
|
|
15052
|
+
addToRenderList: addToRenderList
|
|
14979
15053
|
|
|
14980
15054
|
};
|
|
14981
15055
|
|
|
@@ -15630,16 +15704,52 @@ function WebGLBufferRenderer( gl, extensions, info ) {
|
|
|
15630
15704
|
|
|
15631
15705
|
}
|
|
15632
15706
|
|
|
15707
|
+
function renderMultiDrawInstances( starts, counts, drawCount, primcount ) {
|
|
15708
|
+
|
|
15709
|
+
if ( drawCount === 0 ) return;
|
|
15710
|
+
|
|
15711
|
+
const extension = extensions.get( 'WEBGL_multi_draw' );
|
|
15712
|
+
|
|
15713
|
+
if ( extension === null ) {
|
|
15714
|
+
|
|
15715
|
+
for ( let i = 0; i < starts.length; i ++ ) {
|
|
15716
|
+
|
|
15717
|
+
renderInstances( starts[ i ], counts[ i ], primcount[ i ] );
|
|
15718
|
+
|
|
15719
|
+
}
|
|
15720
|
+
|
|
15721
|
+
} else {
|
|
15722
|
+
|
|
15723
|
+
extension.multiDrawArraysInstancedWEBGL( mode, starts, 0, counts, 0, primcount, 0, drawCount );
|
|
15724
|
+
|
|
15725
|
+
let elementCount = 0;
|
|
15726
|
+
for ( let i = 0; i < drawCount; i ++ ) {
|
|
15727
|
+
|
|
15728
|
+
elementCount += counts[ i ];
|
|
15729
|
+
|
|
15730
|
+
}
|
|
15731
|
+
|
|
15732
|
+
for ( let i = 0; i < primcount.length; i ++ ) {
|
|
15733
|
+
|
|
15734
|
+
info.update( elementCount, mode, primcount[ i ] );
|
|
15735
|
+
|
|
15736
|
+
}
|
|
15737
|
+
|
|
15738
|
+
}
|
|
15739
|
+
|
|
15740
|
+
}
|
|
15741
|
+
|
|
15633
15742
|
//
|
|
15634
15743
|
|
|
15635
15744
|
this.setMode = setMode;
|
|
15636
15745
|
this.render = render;
|
|
15637
15746
|
this.renderInstances = renderInstances;
|
|
15638
15747
|
this.renderMultiDraw = renderMultiDraw;
|
|
15748
|
+
this.renderMultiDrawInstances = renderMultiDrawInstances;
|
|
15639
15749
|
|
|
15640
15750
|
}
|
|
15641
15751
|
|
|
15642
|
-
function WebGLCapabilities( gl, extensions, parameters ) {
|
|
15752
|
+
function WebGLCapabilities( gl, extensions, parameters, utils ) {
|
|
15643
15753
|
|
|
15644
15754
|
let maxAnisotropy;
|
|
15645
15755
|
|
|
@@ -15663,6 +15773,33 @@ function WebGLCapabilities( gl, extensions, parameters ) {
|
|
|
15663
15773
|
|
|
15664
15774
|
}
|
|
15665
15775
|
|
|
15776
|
+
function textureFormatReadable( textureFormat ) {
|
|
15777
|
+
|
|
15778
|
+
if ( textureFormat !== RGBAFormat && utils.convert( textureFormat ) !== gl.getParameter( gl.IMPLEMENTATION_COLOR_READ_FORMAT ) ) {
|
|
15779
|
+
|
|
15780
|
+
return false;
|
|
15781
|
+
|
|
15782
|
+
}
|
|
15783
|
+
|
|
15784
|
+
return true;
|
|
15785
|
+
|
|
15786
|
+
}
|
|
15787
|
+
|
|
15788
|
+
function textureTypeReadable( textureType ) {
|
|
15789
|
+
|
|
15790
|
+
const halfFloatSupportedByExt = ( textureType === HalfFloatType ) && ( extensions.has( 'EXT_color_buffer_half_float' ) || extensions.has( 'EXT_color_buffer_float' ) );
|
|
15791
|
+
|
|
15792
|
+
if ( textureType !== UnsignedByteType && utils.convert( textureType ) !== gl.getParameter( gl.IMPLEMENTATION_COLOR_READ_TYPE ) && // Edge and Chrome Mac < 52 (#9513)
|
|
15793
|
+
textureType !== FloatType && ! halfFloatSupportedByExt ) {
|
|
15794
|
+
|
|
15795
|
+
return false;
|
|
15796
|
+
|
|
15797
|
+
}
|
|
15798
|
+
|
|
15799
|
+
return true;
|
|
15800
|
+
|
|
15801
|
+
}
|
|
15802
|
+
|
|
15666
15803
|
function getMaxPrecision( precision ) {
|
|
15667
15804
|
|
|
15668
15805
|
if ( precision === 'highp' ) {
|
|
@@ -15726,6 +15863,9 @@ function WebGLCapabilities( gl, extensions, parameters ) {
|
|
|
15726
15863
|
getMaxAnisotropy: getMaxAnisotropy,
|
|
15727
15864
|
getMaxPrecision: getMaxPrecision,
|
|
15728
15865
|
|
|
15866
|
+
textureFormatReadable: textureFormatReadable,
|
|
15867
|
+
textureTypeReadable: textureTypeReadable,
|
|
15868
|
+
|
|
15729
15869
|
precision: precision,
|
|
15730
15870
|
logarithmicDepthBuffer: logarithmicDepthBuffer,
|
|
15731
15871
|
|
|
@@ -16167,16 +16307,16 @@ const INV_PHI = 1 / PHI;
|
|
|
16167
16307
|
// Vertices of a dodecahedron (except the opposites, which represent the
|
|
16168
16308
|
// same axis), used as axis directions evenly spread on a sphere.
|
|
16169
16309
|
const _axisDirections = [
|
|
16170
|
-
/*@__PURE__*/ new Vector3(
|
|
16171
|
-
/*@__PURE__*/ new Vector3( - 1, 1, 1 ),
|
|
16172
|
-
/*@__PURE__*/ new Vector3( 1, 1, - 1 ),
|
|
16173
|
-
/*@__PURE__*/ new Vector3( - 1, 1, - 1 ),
|
|
16174
|
-
/*@__PURE__*/ new Vector3( 0, PHI, INV_PHI ),
|
|
16175
|
-
/*@__PURE__*/ new Vector3( 0, PHI, - INV_PHI ),
|
|
16176
|
-
/*@__PURE__*/ new Vector3( INV_PHI, 0, PHI ),
|
|
16177
|
-
/*@__PURE__*/ new Vector3( - INV_PHI, 0, PHI ),
|
|
16310
|
+
/*@__PURE__*/ new Vector3( - PHI, INV_PHI, 0 ),
|
|
16178
16311
|
/*@__PURE__*/ new Vector3( PHI, INV_PHI, 0 ),
|
|
16179
|
-
/*@__PURE__*/ new Vector3( -
|
|
16312
|
+
/*@__PURE__*/ new Vector3( - INV_PHI, 0, PHI ),
|
|
16313
|
+
/*@__PURE__*/ new Vector3( INV_PHI, 0, PHI ),
|
|
16314
|
+
/*@__PURE__*/ new Vector3( 0, PHI, - INV_PHI ),
|
|
16315
|
+
/*@__PURE__*/ new Vector3( 0, PHI, INV_PHI ),
|
|
16316
|
+
/*@__PURE__*/ new Vector3( - 1, 1, - 1 ),
|
|
16317
|
+
/*@__PURE__*/ new Vector3( 1, 1, - 1 ),
|
|
16318
|
+
/*@__PURE__*/ new Vector3( - 1, 1, 1 ),
|
|
16319
|
+
/*@__PURE__*/ new Vector3( 1, 1, 1 ) ];
|
|
16180
16320
|
|
|
16181
16321
|
/**
|
|
16182
16322
|
* This class generates a Prefiltered, Mipmapped Radiance Environment Map
|
|
@@ -16562,12 +16702,13 @@ class PMREMGenerator {
|
|
|
16562
16702
|
const renderer = this._renderer;
|
|
16563
16703
|
const autoClear = renderer.autoClear;
|
|
16564
16704
|
renderer.autoClear = false;
|
|
16705
|
+
const n = this._lodPlanes.length;
|
|
16565
16706
|
|
|
16566
|
-
for ( let i = 1; i <
|
|
16707
|
+
for ( let i = 1; i < n; i ++ ) {
|
|
16567
16708
|
|
|
16568
16709
|
const sigma = Math.sqrt( this._sigmas[ i ] * this._sigmas[ i ] - this._sigmas[ i - 1 ] * this._sigmas[ i - 1 ] );
|
|
16569
16710
|
|
|
16570
|
-
const poleAxis = _axisDirections[ ( i - 1 ) % _axisDirections.length ];
|
|
16711
|
+
const poleAxis = _axisDirections[ ( n - i - 1 ) % _axisDirections.length ];
|
|
16571
16712
|
|
|
16572
16713
|
this._blur( cubeUVRenderTarget, i - 1, i, sigma, poleAxis );
|
|
16573
16714
|
|
|
@@ -17230,7 +17371,7 @@ function WebGLExtensions( gl ) {
|
|
|
17230
17371
|
|
|
17231
17372
|
if ( extension === null ) {
|
|
17232
17373
|
|
|
17233
|
-
|
|
17374
|
+
warnOnce( 'THREE.WebGLRenderer: ' + name + ' extension not supported.' );
|
|
17234
17375
|
|
|
17235
17376
|
}
|
|
17236
17377
|
|
|
@@ -17516,6 +17657,41 @@ function WebGLIndexedBufferRenderer( gl, extensions, info ) {
|
|
|
17516
17657
|
|
|
17517
17658
|
}
|
|
17518
17659
|
|
|
17660
|
+
function renderMultiDrawInstances( starts, counts, drawCount, primcount ) {
|
|
17661
|
+
|
|
17662
|
+
if ( drawCount === 0 ) return;
|
|
17663
|
+
|
|
17664
|
+
const extension = extensions.get( 'WEBGL_multi_draw' );
|
|
17665
|
+
|
|
17666
|
+
if ( extension === null ) {
|
|
17667
|
+
|
|
17668
|
+
for ( let i = 0; i < starts.length; i ++ ) {
|
|
17669
|
+
|
|
17670
|
+
renderInstances( starts[ i ] / bytesPerElement, counts[ i ], primcount[ i ] );
|
|
17671
|
+
|
|
17672
|
+
}
|
|
17673
|
+
|
|
17674
|
+
} else {
|
|
17675
|
+
|
|
17676
|
+
extension.multiDrawElementsInstancedWEBGL( mode, counts, 0, type, starts, 0, primcount, 0, drawCount );
|
|
17677
|
+
|
|
17678
|
+
let elementCount = 0;
|
|
17679
|
+
for ( let i = 0; i < drawCount; i ++ ) {
|
|
17680
|
+
|
|
17681
|
+
elementCount += counts[ i ];
|
|
17682
|
+
|
|
17683
|
+
}
|
|
17684
|
+
|
|
17685
|
+
for ( let i = 0; i < primcount.length; i ++ ) {
|
|
17686
|
+
|
|
17687
|
+
info.update( elementCount, mode, primcount[ i ] );
|
|
17688
|
+
|
|
17689
|
+
}
|
|
17690
|
+
|
|
17691
|
+
}
|
|
17692
|
+
|
|
17693
|
+
}
|
|
17694
|
+
|
|
17519
17695
|
//
|
|
17520
17696
|
|
|
17521
17697
|
this.setMode = setMode;
|
|
@@ -17523,6 +17699,7 @@ function WebGLIndexedBufferRenderer( gl, extensions, info ) {
|
|
|
17523
17699
|
this.render = render;
|
|
17524
17700
|
this.renderInstances = renderInstances;
|
|
17525
17701
|
this.renderMultiDraw = renderMultiDraw;
|
|
17702
|
+
this.renderMultiDrawInstances = renderMultiDrawInstances;
|
|
17526
17703
|
|
|
17527
17704
|
}
|
|
17528
17705
|
|
|
@@ -17604,8 +17781,7 @@ function WebGLMorphtargets( gl, capabilities, textures ) {
|
|
|
17604
17781
|
|
|
17605
17782
|
const objectInfluences = object.morphTargetInfluences;
|
|
17606
17783
|
|
|
17607
|
-
//
|
|
17608
|
-
// into an array of data textures. Each layer represents a single morph target.
|
|
17784
|
+
// the following encodes morph targets into an array of data textures. Each layer represents a single morph target.
|
|
17609
17785
|
|
|
17610
17786
|
const morphAttribute = geometry.morphAttributes.position || geometry.morphAttributes.normal || geometry.morphAttributes.color;
|
|
17611
17787
|
const morphTargetsCount = ( morphAttribute !== undefined ) ? morphAttribute.length : 0;
|
|
@@ -17946,9 +18122,7 @@ function WebGLObjects( gl, geometries, attributes, info ) {
|
|
|
17946
18122
|
|
|
17947
18123
|
class DepthTexture extends Texture {
|
|
17948
18124
|
|
|
17949
|
-
constructor( width, height, type, mapping, wrapS, wrapT, magFilter, minFilter, anisotropy, format ) {
|
|
17950
|
-
|
|
17951
|
-
format = format !== undefined ? format : DepthFormat;
|
|
18125
|
+
constructor( width, height, type, mapping, wrapS, wrapT, magFilter, minFilter, anisotropy, format = DepthFormat ) {
|
|
17952
18126
|
|
|
17953
18127
|
if ( format !== DepthFormat && format !== DepthStencilFormat ) {
|
|
17954
18128
|
|
|
@@ -19398,11 +19572,7 @@ function resolveIncludes( string ) {
|
|
|
19398
19572
|
|
|
19399
19573
|
}
|
|
19400
19574
|
|
|
19401
|
-
const shaderChunkMap = new Map(
|
|
19402
|
-
[ 'encodings_fragment', 'colorspace_fragment' ], // @deprecated, r154
|
|
19403
|
-
[ 'encodings_pars_fragment', 'colorspace_pars_fragment' ], // @deprecated, r154
|
|
19404
|
-
[ 'output_fragment', 'opaque_fragment' ], // @deprecated, r154
|
|
19405
|
-
] );
|
|
19575
|
+
const shaderChunkMap = new Map();
|
|
19406
19576
|
|
|
19407
19577
|
function includeReplacer( match, include ) {
|
|
19408
19578
|
|
|
@@ -19682,6 +19852,7 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
|
|
|
19682
19852
|
|
|
19683
19853
|
parameters.extensionClipCullDistance ? '#define USE_CLIP_DISTANCE' : '',
|
|
19684
19854
|
parameters.batching ? '#define USE_BATCHING' : '',
|
|
19855
|
+
parameters.batchingColor ? '#define USE_BATCHING_COLOR' : '',
|
|
19685
19856
|
parameters.instancing ? '#define USE_INSTANCING' : '',
|
|
19686
19857
|
parameters.instancingColor ? '#define USE_INSTANCING_COLOR' : '',
|
|
19687
19858
|
parameters.instancingMorph ? '#define USE_INSTANCING_MORPH' : '',
|
|
@@ -19778,7 +19949,6 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
|
|
|
19778
19949
|
parameters.morphTargets ? '#define USE_MORPHTARGETS' : '',
|
|
19779
19950
|
parameters.morphNormals && parameters.flatShading === false ? '#define USE_MORPHNORMALS' : '',
|
|
19780
19951
|
( parameters.morphColors ) ? '#define USE_MORPHCOLORS' : '',
|
|
19781
|
-
( parameters.morphTargetsCount > 0 ) ? '#define MORPHTARGETS_TEXTURE' : '',
|
|
19782
19952
|
( parameters.morphTargetsCount > 0 ) ? '#define MORPHTARGETS_TEXTURE_STRIDE ' + parameters.morphTextureStride : '',
|
|
19783
19953
|
( parameters.morphTargetsCount > 0 ) ? '#define MORPHTARGETS_COUNT ' + parameters.morphTargetsCount : '',
|
|
19784
19954
|
parameters.doubleSided ? '#define DOUBLE_SIDED' : '',
|
|
@@ -19791,8 +19961,6 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
|
|
|
19791
19961
|
|
|
19792
19962
|
parameters.numLightProbes > 0 ? '#define USE_LIGHT_PROBES' : '',
|
|
19793
19963
|
|
|
19794
|
-
parameters.useLegacyLights ? '#define LEGACY_LIGHTS' : '',
|
|
19795
|
-
|
|
19796
19964
|
parameters.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '',
|
|
19797
19965
|
|
|
19798
19966
|
'uniform mat4 modelMatrix;',
|
|
@@ -19859,31 +20027,6 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
|
|
|
19859
20027
|
|
|
19860
20028
|
'#endif',
|
|
19861
20029
|
|
|
19862
|
-
'#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )',
|
|
19863
|
-
|
|
19864
|
-
' attribute vec3 morphTarget0;',
|
|
19865
|
-
' attribute vec3 morphTarget1;',
|
|
19866
|
-
' attribute vec3 morphTarget2;',
|
|
19867
|
-
' attribute vec3 morphTarget3;',
|
|
19868
|
-
|
|
19869
|
-
' #ifdef USE_MORPHNORMALS',
|
|
19870
|
-
|
|
19871
|
-
' attribute vec3 morphNormal0;',
|
|
19872
|
-
' attribute vec3 morphNormal1;',
|
|
19873
|
-
' attribute vec3 morphNormal2;',
|
|
19874
|
-
' attribute vec3 morphNormal3;',
|
|
19875
|
-
|
|
19876
|
-
' #else',
|
|
19877
|
-
|
|
19878
|
-
' attribute vec3 morphTarget4;',
|
|
19879
|
-
' attribute vec3 morphTarget5;',
|
|
19880
|
-
' attribute vec3 morphTarget6;',
|
|
19881
|
-
' attribute vec3 morphTarget7;',
|
|
19882
|
-
|
|
19883
|
-
' #endif',
|
|
19884
|
-
|
|
19885
|
-
'#endif',
|
|
19886
|
-
|
|
19887
20030
|
'#ifdef USE_SKINNING',
|
|
19888
20031
|
|
|
19889
20032
|
' attribute vec4 skinIndex;',
|
|
@@ -19933,6 +20076,8 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
|
|
|
19933
20076
|
parameters.clearcoatRoughnessMap ? '#define USE_CLEARCOAT_ROUGHNESSMAP' : '',
|
|
19934
20077
|
parameters.clearcoatNormalMap ? '#define USE_CLEARCOAT_NORMALMAP' : '',
|
|
19935
20078
|
|
|
20079
|
+
parameters.dispersion ? '#define USE_DISPERSION' : '',
|
|
20080
|
+
|
|
19936
20081
|
parameters.iridescence ? '#define USE_IRIDESCENCE' : '',
|
|
19937
20082
|
parameters.iridescenceMap ? '#define USE_IRIDESCENCEMAP' : '',
|
|
19938
20083
|
parameters.iridescenceThicknessMap ? '#define USE_IRIDESCENCE_THICKNESSMAP' : '',
|
|
@@ -19957,7 +20102,7 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
|
|
|
19957
20102
|
parameters.thicknessMap ? '#define USE_THICKNESSMAP' : '',
|
|
19958
20103
|
|
|
19959
20104
|
parameters.vertexTangents && parameters.flatShading === false ? '#define USE_TANGENT' : '',
|
|
19960
|
-
parameters.vertexColors || parameters.instancingColor ? '#define USE_COLOR' : '',
|
|
20105
|
+
parameters.vertexColors || parameters.instancingColor || parameters.batchingColor ? '#define USE_COLOR' : '',
|
|
19961
20106
|
parameters.vertexAlphas ? '#define USE_COLOR_ALPHA' : '',
|
|
19962
20107
|
parameters.vertexUv1s ? '#define USE_UV1' : '',
|
|
19963
20108
|
parameters.vertexUv2s ? '#define USE_UV2' : '',
|
|
@@ -19979,8 +20124,6 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
|
|
|
19979
20124
|
|
|
19980
20125
|
parameters.numLightProbes > 0 ? '#define USE_LIGHT_PROBES' : '',
|
|
19981
20126
|
|
|
19982
|
-
parameters.useLegacyLights ? '#define LEGACY_LIGHTS' : '',
|
|
19983
|
-
|
|
19984
20127
|
parameters.decodeVideoTexture ? '#define DECODE_VIDEO_TEXTURE' : '',
|
|
19985
20128
|
|
|
19986
20129
|
parameters.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '',
|
|
@@ -20538,6 +20681,7 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
|
|
|
20538
20681
|
|
|
20539
20682
|
const HAS_ANISOTROPY = material.anisotropy > 0;
|
|
20540
20683
|
const HAS_CLEARCOAT = material.clearcoat > 0;
|
|
20684
|
+
const HAS_DISPERSION = material.dispersion > 0;
|
|
20541
20685
|
const HAS_IRIDESCENCE = material.iridescence > 0;
|
|
20542
20686
|
const HAS_SHEEN = material.sheen > 0;
|
|
20543
20687
|
const HAS_TRANSMISSION = material.transmission > 0;
|
|
@@ -20602,6 +20746,7 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
|
|
|
20602
20746
|
precision: precision,
|
|
20603
20747
|
|
|
20604
20748
|
batching: IS_BATCHEDMESH,
|
|
20749
|
+
batchingColor: IS_BATCHEDMESH && object._colorsTexture !== null,
|
|
20605
20750
|
instancing: IS_INSTANCEDMESH,
|
|
20606
20751
|
instancingColor: IS_INSTANCEDMESH && object.instanceColor !== null,
|
|
20607
20752
|
instancingMorph: IS_INSTANCEDMESH && object.morphTexture !== null,
|
|
@@ -20637,6 +20782,8 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
|
|
|
20637
20782
|
clearcoatNormalMap: HAS_CLEARCOAT_NORMALMAP,
|
|
20638
20783
|
clearcoatRoughnessMap: HAS_CLEARCOAT_ROUGHNESSMAP,
|
|
20639
20784
|
|
|
20785
|
+
dispersion: HAS_DISPERSION,
|
|
20786
|
+
|
|
20640
20787
|
iridescence: HAS_IRIDESCENCE,
|
|
20641
20788
|
iridescenceMap: HAS_IRIDESCENCEMAP,
|
|
20642
20789
|
iridescenceThicknessMap: HAS_IRIDESCENCE_THICKNESSMAP,
|
|
@@ -20745,7 +20892,6 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
|
|
|
20745
20892
|
shadowMapType: renderer.shadowMap.type,
|
|
20746
20893
|
|
|
20747
20894
|
toneMapping: toneMapping,
|
|
20748
|
-
useLegacyLights: renderer._useLegacyLights,
|
|
20749
20895
|
|
|
20750
20896
|
decodeVideoTexture: HAS_MAP && ( material.map.isVideoTexture === true ) && ( ColorManagement.getTransfer( material.map.colorSpace ) === SRGBTransfer ),
|
|
20751
20897
|
|
|
@@ -20917,6 +21063,10 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
|
|
|
20917
21063
|
_programLayers.enable( 18 );
|
|
20918
21064
|
if ( parameters.batching )
|
|
20919
21065
|
_programLayers.enable( 19 );
|
|
21066
|
+
if ( parameters.dispersion )
|
|
21067
|
+
_programLayers.enable( 20 );
|
|
21068
|
+
if ( parameters.batchingColor )
|
|
21069
|
+
_programLayers.enable( 21 );
|
|
20920
21070
|
|
|
20921
21071
|
array.push( _programLayers.mask );
|
|
20922
21072
|
_programLayers.disableAll();
|
|
@@ -20941,30 +21091,28 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
|
|
|
20941
21091
|
_programLayers.enable( 8 );
|
|
20942
21092
|
if ( parameters.shadowMapEnabled )
|
|
20943
21093
|
_programLayers.enable( 9 );
|
|
20944
|
-
if ( parameters.useLegacyLights )
|
|
20945
|
-
_programLayers.enable( 10 );
|
|
20946
21094
|
if ( parameters.doubleSided )
|
|
20947
|
-
_programLayers.enable(
|
|
21095
|
+
_programLayers.enable( 10 );
|
|
20948
21096
|
if ( parameters.flipSided )
|
|
20949
|
-
_programLayers.enable(
|
|
21097
|
+
_programLayers.enable( 11 );
|
|
20950
21098
|
if ( parameters.useDepthPacking )
|
|
20951
|
-
_programLayers.enable(
|
|
21099
|
+
_programLayers.enable( 12 );
|
|
20952
21100
|
if ( parameters.dithering )
|
|
20953
|
-
_programLayers.enable(
|
|
21101
|
+
_programLayers.enable( 13 );
|
|
20954
21102
|
if ( parameters.transmission )
|
|
20955
|
-
_programLayers.enable(
|
|
21103
|
+
_programLayers.enable( 14 );
|
|
20956
21104
|
if ( parameters.sheen )
|
|
20957
|
-
_programLayers.enable(
|
|
21105
|
+
_programLayers.enable( 15 );
|
|
20958
21106
|
if ( parameters.opaque )
|
|
20959
|
-
_programLayers.enable(
|
|
21107
|
+
_programLayers.enable( 16 );
|
|
20960
21108
|
if ( parameters.pointsUvs )
|
|
20961
|
-
_programLayers.enable(
|
|
21109
|
+
_programLayers.enable( 17 );
|
|
20962
21110
|
if ( parameters.decodeVideoTexture )
|
|
20963
|
-
_programLayers.enable(
|
|
21111
|
+
_programLayers.enable( 18 );
|
|
20964
21112
|
if ( parameters.alphaToCoverage )
|
|
20965
|
-
_programLayers.enable(
|
|
21113
|
+
_programLayers.enable( 19 );
|
|
20966
21114
|
if ( parameters.numMultiviewViews )
|
|
20967
|
-
_programLayers.enable(
|
|
21115
|
+
_programLayers.enable( 20 );
|
|
20968
21116
|
|
|
20969
21117
|
array.push( _programLayers.mask );
|
|
20970
21118
|
|
|
@@ -21546,7 +21694,7 @@ function WebGLLights( extensions ) {
|
|
|
21546
21694
|
const matrix4 = new Matrix4();
|
|
21547
21695
|
const matrix42 = new Matrix4();
|
|
21548
21696
|
|
|
21549
|
-
function setup( lights
|
|
21697
|
+
function setup( lights ) {
|
|
21550
21698
|
|
|
21551
21699
|
let r = 0, g = 0, b = 0;
|
|
21552
21700
|
|
|
@@ -21569,9 +21717,6 @@ function WebGLLights( extensions ) {
|
|
|
21569
21717
|
// ordering : [shadow casting + map texturing, map texturing, shadow casting, none ]
|
|
21570
21718
|
lights.sort( shadowCastingAndTexturingLightsFirst );
|
|
21571
21719
|
|
|
21572
|
-
// artist-friendly light intensity scaling factor
|
|
21573
|
-
const scaleFactor = ( useLegacyLights === true ) ? Math.PI : 1;
|
|
21574
|
-
|
|
21575
21720
|
for ( let i = 0, l = lights.length; i < l; i ++ ) {
|
|
21576
21721
|
|
|
21577
21722
|
const light = lights[ i ];
|
|
@@ -21584,9 +21729,9 @@ function WebGLLights( extensions ) {
|
|
|
21584
21729
|
|
|
21585
21730
|
if ( light.isAmbientLight ) {
|
|
21586
21731
|
|
|
21587
|
-
r += color.r * intensity
|
|
21588
|
-
g += color.g * intensity
|
|
21589
|
-
b += color.b * intensity
|
|
21732
|
+
r += color.r * intensity;
|
|
21733
|
+
g += color.g * intensity;
|
|
21734
|
+
b += color.b * intensity;
|
|
21590
21735
|
|
|
21591
21736
|
} else if ( light.isLightProbe ) {
|
|
21592
21737
|
|
|
@@ -21602,7 +21747,7 @@ function WebGLLights( extensions ) {
|
|
|
21602
21747
|
|
|
21603
21748
|
const uniforms = cache.get( light );
|
|
21604
21749
|
|
|
21605
|
-
uniforms.color.copy( light.color ).multiplyScalar( light.intensity
|
|
21750
|
+
uniforms.color.copy( light.color ).multiplyScalar( light.intensity );
|
|
21606
21751
|
|
|
21607
21752
|
if ( light.castShadow ) {
|
|
21608
21753
|
|
|
@@ -21633,7 +21778,7 @@ function WebGLLights( extensions ) {
|
|
|
21633
21778
|
|
|
21634
21779
|
uniforms.position.setFromMatrixPosition( light.matrixWorld );
|
|
21635
21780
|
|
|
21636
|
-
uniforms.color.copy( color ).multiplyScalar( intensity
|
|
21781
|
+
uniforms.color.copy( color ).multiplyScalar( intensity );
|
|
21637
21782
|
uniforms.distance = distance;
|
|
21638
21783
|
|
|
21639
21784
|
uniforms.coneCos = Math.cos( light.angle );
|
|
@@ -21694,7 +21839,7 @@ function WebGLLights( extensions ) {
|
|
|
21694
21839
|
|
|
21695
21840
|
const uniforms = cache.get( light );
|
|
21696
21841
|
|
|
21697
|
-
uniforms.color.copy( light.color ).multiplyScalar( light.intensity
|
|
21842
|
+
uniforms.color.copy( light.color ).multiplyScalar( light.intensity );
|
|
21698
21843
|
uniforms.distance = light.distance;
|
|
21699
21844
|
uniforms.decay = light.decay;
|
|
21700
21845
|
|
|
@@ -21727,8 +21872,8 @@ function WebGLLights( extensions ) {
|
|
|
21727
21872
|
|
|
21728
21873
|
const uniforms = cache.get( light );
|
|
21729
21874
|
|
|
21730
|
-
uniforms.skyColor.copy( light.color ).multiplyScalar( intensity
|
|
21731
|
-
uniforms.groundColor.copy( light.groundColor ).multiplyScalar( intensity
|
|
21875
|
+
uniforms.skyColor.copy( light.color ).multiplyScalar( intensity );
|
|
21876
|
+
uniforms.groundColor.copy( light.groundColor ).multiplyScalar( intensity );
|
|
21732
21877
|
|
|
21733
21878
|
state.hemi[ hemiLength ] = uniforms;
|
|
21734
21879
|
|
|
@@ -21908,7 +22053,9 @@ function WebGLRenderState( extensions ) {
|
|
|
21908
22053
|
const lightsArray = [];
|
|
21909
22054
|
const shadowsArray = [];
|
|
21910
22055
|
|
|
21911
|
-
function init() {
|
|
22056
|
+
function init( camera ) {
|
|
22057
|
+
|
|
22058
|
+
state.camera = camera;
|
|
21912
22059
|
|
|
21913
22060
|
lightsArray.length = 0;
|
|
21914
22061
|
shadowsArray.length = 0;
|
|
@@ -21927,9 +22074,9 @@ function WebGLRenderState( extensions ) {
|
|
|
21927
22074
|
|
|
21928
22075
|
}
|
|
21929
22076
|
|
|
21930
|
-
function setupLights(
|
|
22077
|
+
function setupLights() {
|
|
21931
22078
|
|
|
21932
|
-
lights.setup( lightsArray
|
|
22079
|
+
lights.setup( lightsArray );
|
|
21933
22080
|
|
|
21934
22081
|
}
|
|
21935
22082
|
|
|
@@ -21943,9 +22090,11 @@ function WebGLRenderState( extensions ) {
|
|
|
21943
22090
|
lightsArray: lightsArray,
|
|
21944
22091
|
shadowsArray: shadowsArray,
|
|
21945
22092
|
|
|
22093
|
+
camera: null,
|
|
22094
|
+
|
|
21946
22095
|
lights: lights,
|
|
21947
22096
|
|
|
21948
|
-
transmissionRenderTarget:
|
|
22097
|
+
transmissionRenderTarget: {}
|
|
21949
22098
|
};
|
|
21950
22099
|
|
|
21951
22100
|
return {
|
|
@@ -22100,7 +22249,7 @@ const vertex = "void main() {\n\tgl_Position = vec4( position, 1.0 );\n}";
|
|
|
22100
22249
|
|
|
22101
22250
|
const fragment = "uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\n#include <packing>\nvoid main() {\n\tconst float samples = float( VSM_SAMPLES );\n\tfloat mean = 0.0;\n\tfloat squared_mean = 0.0;\n\tfloat uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );\n\tfloat uvStart = samples <= 1.0 ? 0.0 : - 1.0;\n\tfor ( float i = 0.0; i < samples; i ++ ) {\n\t\tfloat uvOffset = uvStart + i * uvStride;\n\t\t#ifdef HORIZONTAL_PASS\n\t\t\tvec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );\n\t\t\tmean += distribution.x;\n\t\t\tsquared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n\t\t#else\n\t\t\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );\n\t\t\tmean += depth;\n\t\t\tsquared_mean += depth * depth;\n\t\t#endif\n\t}\n\tmean = mean / samples;\n\tsquared_mean = squared_mean / samples;\n\tfloat std_dev = sqrt( squared_mean - mean * mean );\n\tgl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );\n}";
|
|
22102
22251
|
|
|
22103
|
-
function WebGLShadowMap(
|
|
22252
|
+
function WebGLShadowMap( renderer, objects, capabilities ) {
|
|
22104
22253
|
|
|
22105
22254
|
let _frustum = new Frustum();
|
|
22106
22255
|
|
|
@@ -22114,7 +22263,7 @@ function WebGLShadowMap( _renderer, _objects, _capabilities ) {
|
|
|
22114
22263
|
|
|
22115
22264
|
_materialCache = {},
|
|
22116
22265
|
|
|
22117
|
-
_maxTextureSize =
|
|
22266
|
+
_maxTextureSize = capabilities.maxTextureSize;
|
|
22118
22267
|
|
|
22119
22268
|
const shadowSide = { [ FrontSide ]: BackSide, [ BackSide ]: FrontSide, [ DoubleSide ]: DoubleSide };
|
|
22120
22269
|
|
|
@@ -22164,11 +22313,11 @@ function WebGLShadowMap( _renderer, _objects, _capabilities ) {
|
|
|
22164
22313
|
|
|
22165
22314
|
if ( lights.length === 0 ) return;
|
|
22166
22315
|
|
|
22167
|
-
const currentRenderTarget =
|
|
22168
|
-
const activeCubeFace =
|
|
22169
|
-
const activeMipmapLevel =
|
|
22316
|
+
const currentRenderTarget = renderer.getRenderTarget();
|
|
22317
|
+
const activeCubeFace = renderer.getActiveCubeFace();
|
|
22318
|
+
const activeMipmapLevel = renderer.getActiveMipmapLevel();
|
|
22170
22319
|
|
|
22171
|
-
const _state =
|
|
22320
|
+
const _state = renderer.state;
|
|
22172
22321
|
|
|
22173
22322
|
// Set GL state for depth map.
|
|
22174
22323
|
_state.setBlending( NoBlending );
|
|
@@ -22242,8 +22391,8 @@ function WebGLShadowMap( _renderer, _objects, _capabilities ) {
|
|
|
22242
22391
|
|
|
22243
22392
|
}
|
|
22244
22393
|
|
|
22245
|
-
|
|
22246
|
-
|
|
22394
|
+
renderer.setRenderTarget( shadow.map );
|
|
22395
|
+
renderer.clear();
|
|
22247
22396
|
|
|
22248
22397
|
const viewportCount = shadow.getViewportCount();
|
|
22249
22398
|
|
|
@@ -22284,13 +22433,13 @@ function WebGLShadowMap( _renderer, _objects, _capabilities ) {
|
|
|
22284
22433
|
|
|
22285
22434
|
scope.needsUpdate = false;
|
|
22286
22435
|
|
|
22287
|
-
|
|
22436
|
+
renderer.setRenderTarget( currentRenderTarget, activeCubeFace, activeMipmapLevel );
|
|
22288
22437
|
|
|
22289
22438
|
};
|
|
22290
22439
|
|
|
22291
22440
|
function VSMPass( shadow, camera ) {
|
|
22292
22441
|
|
|
22293
|
-
const geometry =
|
|
22442
|
+
const geometry = objects.update( fullScreenMesh );
|
|
22294
22443
|
|
|
22295
22444
|
if ( shadowMaterialVertical.defines.VSM_SAMPLES !== shadow.blurSamples ) {
|
|
22296
22445
|
|
|
@@ -22313,18 +22462,18 @@ function WebGLShadowMap( _renderer, _objects, _capabilities ) {
|
|
|
22313
22462
|
shadowMaterialVertical.uniforms.shadow_pass.value = shadow.map.texture;
|
|
22314
22463
|
shadowMaterialVertical.uniforms.resolution.value = shadow.mapSize;
|
|
22315
22464
|
shadowMaterialVertical.uniforms.radius.value = shadow.radius;
|
|
22316
|
-
|
|
22317
|
-
|
|
22318
|
-
|
|
22465
|
+
renderer.setRenderTarget( shadow.mapPass );
|
|
22466
|
+
renderer.clear();
|
|
22467
|
+
renderer.renderBufferDirect( camera, null, geometry, shadowMaterialVertical, fullScreenMesh, null );
|
|
22319
22468
|
|
|
22320
22469
|
// horizontal pass
|
|
22321
22470
|
|
|
22322
22471
|
shadowMaterialHorizontal.uniforms.shadow_pass.value = shadow.mapPass.texture;
|
|
22323
22472
|
shadowMaterialHorizontal.uniforms.resolution.value = shadow.mapSize;
|
|
22324
22473
|
shadowMaterialHorizontal.uniforms.radius.value = shadow.radius;
|
|
22325
|
-
|
|
22326
|
-
|
|
22327
|
-
|
|
22474
|
+
renderer.setRenderTarget( shadow.map );
|
|
22475
|
+
renderer.clear();
|
|
22476
|
+
renderer.renderBufferDirect( camera, null, geometry, shadowMaterialHorizontal, fullScreenMesh, null );
|
|
22328
22477
|
|
|
22329
22478
|
}
|
|
22330
22479
|
|
|
@@ -22342,7 +22491,7 @@ function WebGLShadowMap( _renderer, _objects, _capabilities ) {
|
|
|
22342
22491
|
|
|
22343
22492
|
result = ( light.isPointLight === true ) ? _distanceMaterial : _depthMaterial;
|
|
22344
22493
|
|
|
22345
|
-
if ( (
|
|
22494
|
+
if ( ( renderer.localClippingEnabled && material.clipShadows === true && Array.isArray( material.clippingPlanes ) && material.clippingPlanes.length !== 0 ) ||
|
|
22346
22495
|
( material.displacementMap && material.displacementScale !== 0 ) ||
|
|
22347
22496
|
( material.alphaMap && material.alphaTest > 0 ) ||
|
|
22348
22497
|
( material.map && material.alphaTest > 0 ) ) {
|
|
@@ -22407,7 +22556,7 @@ function WebGLShadowMap( _renderer, _objects, _capabilities ) {
|
|
|
22407
22556
|
|
|
22408
22557
|
if ( light.isPointLight === true && result.isMeshDistanceMaterial === true ) {
|
|
22409
22558
|
|
|
22410
|
-
const materialProperties =
|
|
22559
|
+
const materialProperties = renderer.properties.get( result );
|
|
22411
22560
|
materialProperties.light = light;
|
|
22412
22561
|
|
|
22413
22562
|
}
|
|
@@ -22428,7 +22577,7 @@ function WebGLShadowMap( _renderer, _objects, _capabilities ) {
|
|
|
22428
22577
|
|
|
22429
22578
|
object.modelViewMatrix.multiplyMatrices( shadowCamera.matrixWorldInverse, object.matrixWorld );
|
|
22430
22579
|
|
|
22431
|
-
const geometry =
|
|
22580
|
+
const geometry = objects.update( object );
|
|
22432
22581
|
const material = object.material;
|
|
22433
22582
|
|
|
22434
22583
|
if ( Array.isArray( material ) ) {
|
|
@@ -22444,11 +22593,11 @@ function WebGLShadowMap( _renderer, _objects, _capabilities ) {
|
|
|
22444
22593
|
|
|
22445
22594
|
const depthMaterial = getDepthMaterial( object, groupMaterial, light, type );
|
|
22446
22595
|
|
|
22447
|
-
object.onBeforeShadow(
|
|
22596
|
+
object.onBeforeShadow( renderer, object, camera, shadowCamera, geometry, depthMaterial, group );
|
|
22448
22597
|
|
|
22449
|
-
|
|
22598
|
+
renderer.renderBufferDirect( shadowCamera, null, geometry, depthMaterial, object, group );
|
|
22450
22599
|
|
|
22451
|
-
object.onAfterShadow(
|
|
22600
|
+
object.onAfterShadow( renderer, object, camera, shadowCamera, geometry, depthMaterial, group );
|
|
22452
22601
|
|
|
22453
22602
|
}
|
|
22454
22603
|
|
|
@@ -22458,11 +22607,11 @@ function WebGLShadowMap( _renderer, _objects, _capabilities ) {
|
|
|
22458
22607
|
|
|
22459
22608
|
const depthMaterial = getDepthMaterial( object, material, light, type );
|
|
22460
22609
|
|
|
22461
|
-
object.onBeforeShadow(
|
|
22610
|
+
object.onBeforeShadow( renderer, object, camera, shadowCamera, geometry, depthMaterial, null );
|
|
22462
22611
|
|
|
22463
|
-
|
|
22612
|
+
renderer.renderBufferDirect( shadowCamera, null, geometry, depthMaterial, object, null );
|
|
22464
22613
|
|
|
22465
|
-
object.onAfterShadow(
|
|
22614
|
+
object.onAfterShadow( renderer, object, camera, shadowCamera, geometry, depthMaterial, null );
|
|
22466
22615
|
|
|
22467
22616
|
}
|
|
22468
22617
|
|
|
@@ -23974,6 +24123,48 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
23974
24123
|
|
|
23975
24124
|
}
|
|
23976
24125
|
|
|
24126
|
+
function getInternalDepthFormat( useStencil, depthType ) {
|
|
24127
|
+
|
|
24128
|
+
let glInternalFormat;
|
|
24129
|
+
if ( useStencil ) {
|
|
24130
|
+
|
|
24131
|
+
if ( depthType === null || depthType === UnsignedIntType || depthType === UnsignedInt248Type ) {
|
|
24132
|
+
|
|
24133
|
+
glInternalFormat = _gl.DEPTH24_STENCIL8;
|
|
24134
|
+
|
|
24135
|
+
} else if ( depthType === FloatType ) {
|
|
24136
|
+
|
|
24137
|
+
glInternalFormat = _gl.DEPTH32F_STENCIL8;
|
|
24138
|
+
|
|
24139
|
+
} else if ( depthType === UnsignedShortType ) {
|
|
24140
|
+
|
|
24141
|
+
glInternalFormat = _gl.DEPTH24_STENCIL8;
|
|
24142
|
+
console.warn( 'DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.' );
|
|
24143
|
+
|
|
24144
|
+
}
|
|
24145
|
+
|
|
24146
|
+
} else {
|
|
24147
|
+
|
|
24148
|
+
if ( depthType === null || depthType === UnsignedIntType || depthType === UnsignedInt248Type ) {
|
|
24149
|
+
|
|
24150
|
+
glInternalFormat = _gl.DEPTH_COMPONENT24;
|
|
24151
|
+
|
|
24152
|
+
} else if ( depthType === FloatType ) {
|
|
24153
|
+
|
|
24154
|
+
glInternalFormat = _gl.DEPTH_COMPONENT32F;
|
|
24155
|
+
|
|
24156
|
+
} else if ( depthType === UnsignedShortType ) {
|
|
24157
|
+
|
|
24158
|
+
glInternalFormat = _gl.DEPTH_COMPONENT16;
|
|
24159
|
+
|
|
24160
|
+
}
|
|
24161
|
+
|
|
24162
|
+
}
|
|
24163
|
+
|
|
24164
|
+
return glInternalFormat;
|
|
24165
|
+
|
|
24166
|
+
}
|
|
24167
|
+
|
|
23977
24168
|
function getMipLevels( texture, image ) {
|
|
23978
24169
|
|
|
23979
24170
|
if ( textureNeedsGenerateMipmaps( texture ) === true || ( texture.isFramebufferTexture && texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter ) ) {
|
|
@@ -24521,30 +24712,14 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
24521
24712
|
let mipmap;
|
|
24522
24713
|
const mipmaps = texture.mipmaps;
|
|
24523
24714
|
|
|
24524
|
-
const useTexStorage = ( texture.isVideoTexture !== true
|
|
24715
|
+
const useTexStorage = ( texture.isVideoTexture !== true );
|
|
24525
24716
|
const allocateMemory = ( sourceProperties.__version === undefined ) || ( forceUpload === true );
|
|
24526
24717
|
const dataReady = source.dataReady;
|
|
24527
24718
|
const levels = getMipLevels( texture, image );
|
|
24528
24719
|
|
|
24529
24720
|
if ( texture.isDepthTexture ) {
|
|
24530
24721
|
|
|
24531
|
-
|
|
24532
|
-
|
|
24533
|
-
glInternalFormat = _gl.DEPTH_COMPONENT16;
|
|
24534
|
-
|
|
24535
|
-
if ( texture.type === FloatType ) {
|
|
24536
|
-
|
|
24537
|
-
glInternalFormat = _gl.DEPTH_COMPONENT32F;
|
|
24538
|
-
|
|
24539
|
-
} else if ( texture.type === UnsignedIntType ) {
|
|
24540
|
-
|
|
24541
|
-
glInternalFormat = _gl.DEPTH_COMPONENT24;
|
|
24542
|
-
|
|
24543
|
-
} else if ( texture.type === UnsignedInt248Type ) {
|
|
24544
|
-
|
|
24545
|
-
glInternalFormat = _gl.DEPTH24_STENCIL8;
|
|
24546
|
-
|
|
24547
|
-
}
|
|
24722
|
+
glInternalFormat = getInternalDepthFormat( texture.format === DepthStencilFormat, texture.type );
|
|
24548
24723
|
|
|
24549
24724
|
//
|
|
24550
24725
|
|
|
@@ -24644,7 +24819,22 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
24644
24819
|
|
|
24645
24820
|
if ( dataReady ) {
|
|
24646
24821
|
|
|
24647
|
-
|
|
24822
|
+
if ( texture.layerUpdates.size > 0 ) {
|
|
24823
|
+
|
|
24824
|
+
for ( const layerIndex of texture.layerUpdates ) {
|
|
24825
|
+
|
|
24826
|
+
const layerSize = mipmap.width * mipmap.height;
|
|
24827
|
+
state.compressedTexSubImage3D( _gl.TEXTURE_2D_ARRAY, i, 0, 0, layerIndex, mipmap.width, mipmap.height, 1, glFormat, mipmap.data.slice( layerSize * layerIndex, layerSize * ( layerIndex + 1 ) ), 0, 0 );
|
|
24828
|
+
|
|
24829
|
+
}
|
|
24830
|
+
|
|
24831
|
+
texture.clearLayerUpdates();
|
|
24832
|
+
|
|
24833
|
+
} else {
|
|
24834
|
+
|
|
24835
|
+
state.compressedTexSubImage3D( _gl.TEXTURE_2D_ARRAY, i, 0, 0, 0, mipmap.width, mipmap.height, image.depth, glFormat, mipmap.data, 0, 0 );
|
|
24836
|
+
|
|
24837
|
+
}
|
|
24648
24838
|
|
|
24649
24839
|
}
|
|
24650
24840
|
|
|
@@ -24750,7 +24940,72 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
24750
24940
|
|
|
24751
24941
|
if ( dataReady ) {
|
|
24752
24942
|
|
|
24753
|
-
|
|
24943
|
+
if ( texture.layerUpdates.size > 0 ) {
|
|
24944
|
+
|
|
24945
|
+
// When type is GL_UNSIGNED_BYTE, each of these bytes is
|
|
24946
|
+
// interpreted as one color component, depending on format. When
|
|
24947
|
+
// type is one of GL_UNSIGNED_SHORT_5_6_5,
|
|
24948
|
+
// GL_UNSIGNED_SHORT_4_4_4_4, GL_UNSIGNED_SHORT_5_5_5_1, each
|
|
24949
|
+
// unsigned value is interpreted as containing all the components
|
|
24950
|
+
// for a single pixel, with the color components arranged
|
|
24951
|
+
// according to format.
|
|
24952
|
+
//
|
|
24953
|
+
// See https://registry.khronos.org/OpenGL-Refpages/es1.1/xhtml/glTexImage2D.xml
|
|
24954
|
+
let texelSize;
|
|
24955
|
+
switch ( glType ) {
|
|
24956
|
+
|
|
24957
|
+
case _gl.UNSIGNED_BYTE:
|
|
24958
|
+
switch ( glFormat ) {
|
|
24959
|
+
|
|
24960
|
+
case _gl.ALPHA:
|
|
24961
|
+
texelSize = 1;
|
|
24962
|
+
break;
|
|
24963
|
+
case _gl.LUMINANCE:
|
|
24964
|
+
texelSize = 1;
|
|
24965
|
+
break;
|
|
24966
|
+
case _gl.LUMINANCE_ALPHA:
|
|
24967
|
+
texelSize = 2;
|
|
24968
|
+
break;
|
|
24969
|
+
case _gl.RGB:
|
|
24970
|
+
texelSize = 3;
|
|
24971
|
+
break;
|
|
24972
|
+
case _gl.RGBA:
|
|
24973
|
+
texelSize = 4;
|
|
24974
|
+
break;
|
|
24975
|
+
|
|
24976
|
+
default:
|
|
24977
|
+
throw new Error( `Unknown texel size for format ${glFormat}.` );
|
|
24978
|
+
|
|
24979
|
+
}
|
|
24980
|
+
|
|
24981
|
+
break;
|
|
24982
|
+
|
|
24983
|
+
case _gl.UNSIGNED_SHORT_4_4_4_4:
|
|
24984
|
+
case _gl.UNSIGNED_SHORT_5_5_5_1:
|
|
24985
|
+
case _gl.UNSIGNED_SHORT_5_6_5:
|
|
24986
|
+
texelSize = 1;
|
|
24987
|
+
break;
|
|
24988
|
+
|
|
24989
|
+
default:
|
|
24990
|
+
throw new Error( `Unknown texel size for type ${glType}.` );
|
|
24991
|
+
|
|
24992
|
+
}
|
|
24993
|
+
|
|
24994
|
+
const layerSize = image.width * image.height * texelSize;
|
|
24995
|
+
|
|
24996
|
+
for ( const layerIndex of texture.layerUpdates ) {
|
|
24997
|
+
|
|
24998
|
+
state.texSubImage3D( _gl.TEXTURE_2D_ARRAY, 0, 0, 0, layerIndex, image.width, image.height, 1, glFormat, glType, image.data.slice( layerSize * layerIndex, layerSize * ( layerIndex + 1 ) ) );
|
|
24999
|
+
|
|
25000
|
+
}
|
|
25001
|
+
|
|
25002
|
+
texture.clearLayerUpdates();
|
|
25003
|
+
|
|
25004
|
+
} else {
|
|
25005
|
+
|
|
25006
|
+
state.texSubImage3D( _gl.TEXTURE_2D_ARRAY, 0, 0, 0, 0, image.width, image.height, image.depth, glFormat, glType, image.data );
|
|
25007
|
+
|
|
25008
|
+
}
|
|
24754
25009
|
|
|
24755
25010
|
}
|
|
24756
25011
|
|
|
@@ -25194,7 +25449,6 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
25194
25449
|
|
|
25195
25450
|
}
|
|
25196
25451
|
|
|
25197
|
-
|
|
25198
25452
|
// Setup storage for internal depth/stencil buffers and bind to correct framebuffer
|
|
25199
25453
|
function setupRenderBufferStorage( renderbuffer, renderTarget, isMultisample ) {
|
|
25200
25454
|
|
|
@@ -25254,66 +25508,30 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
25254
25508
|
|
|
25255
25509
|
} else if ( renderTarget.depthBuffer && ! renderTarget.stencilBuffer ) {
|
|
25256
25510
|
|
|
25257
|
-
|
|
25258
|
-
|
|
25259
|
-
|
|
25260
|
-
|
|
25261
|
-
|
|
25262
|
-
|
|
25263
|
-
if ( depthTexture && depthTexture.isDepthTexture ) {
|
|
25264
|
-
|
|
25265
|
-
if ( depthTexture.type === FloatType ) {
|
|
25266
|
-
|
|
25267
|
-
glInternalFormat = _gl.DEPTH_COMPONENT32F;
|
|
25268
|
-
|
|
25269
|
-
} else if ( depthTexture.type === UnsignedIntType ) {
|
|
25270
|
-
|
|
25271
|
-
glInternalFormat = _gl.DEPTH_COMPONENT24;
|
|
25272
|
-
|
|
25273
|
-
}
|
|
25274
|
-
|
|
25275
|
-
}
|
|
25276
|
-
|
|
25277
|
-
const samples = getRenderTargetSamples( renderTarget );
|
|
25278
|
-
|
|
25279
|
-
if ( useMultisampledRTT( renderTarget ) ) {
|
|
25280
|
-
|
|
25281
|
-
multisampledRTTExt.renderbufferStorageMultisampleEXT( _gl.RENDERBUFFER, samples, glInternalFormat, renderTarget.width, renderTarget.height );
|
|
25282
|
-
|
|
25283
|
-
} else {
|
|
25284
|
-
|
|
25285
|
-
_gl.renderbufferStorageMultisample( _gl.RENDERBUFFER, samples, glInternalFormat, renderTarget.width, renderTarget.height );
|
|
25286
|
-
|
|
25287
|
-
}
|
|
25288
|
-
|
|
25289
|
-
} else {
|
|
25290
|
-
|
|
25291
|
-
_gl.renderbufferStorage( _gl.RENDERBUFFER, glInternalFormat, renderTarget.width, renderTarget.height );
|
|
25292
|
-
|
|
25293
|
-
}
|
|
25294
|
-
|
|
25295
|
-
_gl.framebufferRenderbuffer( _gl.FRAMEBUFFER, _gl.DEPTH_ATTACHMENT, _gl.RENDERBUFFER, renderbuffer );
|
|
25296
|
-
|
|
25297
|
-
} else if ( renderTarget.depthBuffer && renderTarget.stencilBuffer ) {
|
|
25511
|
+
// retrieve the depth attachment types
|
|
25512
|
+
const depthTexture = renderTarget.depthTexture;
|
|
25513
|
+
const depthType = depthTexture && depthTexture.isDepthTexture ? depthTexture.type : null;
|
|
25514
|
+
const glInternalFormat = getInternalDepthFormat( renderTarget.stencilBuffer, depthType );
|
|
25515
|
+
const glAttachmentType = renderTarget.stencilBuffer ? _gl.DEPTH_STENCIL_ATTACHMENT : _gl.DEPTH_ATTACHMENT;
|
|
25298
25516
|
|
|
25517
|
+
// set up the attachment
|
|
25299
25518
|
const samples = getRenderTargetSamples( renderTarget );
|
|
25519
|
+
const isUseMultisampledRTT = useMultisampledRTT( renderTarget );
|
|
25520
|
+
if ( isUseMultisampledRTT ) {
|
|
25300
25521
|
|
|
25301
|
-
|
|
25302
|
-
|
|
25303
|
-
_gl.renderbufferStorageMultisample( _gl.RENDERBUFFER, samples, _gl.DEPTH24_STENCIL8, renderTarget.width, renderTarget.height );
|
|
25522
|
+
multisampledRTTExt.renderbufferStorageMultisampleEXT( _gl.RENDERBUFFER, samples, glInternalFormat, renderTarget.width, renderTarget.height );
|
|
25304
25523
|
|
|
25305
|
-
} else if (
|
|
25524
|
+
} else if ( isMultisample ) {
|
|
25306
25525
|
|
|
25307
|
-
|
|
25526
|
+
_gl.renderbufferStorageMultisample( _gl.RENDERBUFFER, samples, glInternalFormat, renderTarget.width, renderTarget.height );
|
|
25308
25527
|
|
|
25309
25528
|
} else {
|
|
25310
25529
|
|
|
25311
|
-
_gl.renderbufferStorage( _gl.RENDERBUFFER,
|
|
25530
|
+
_gl.renderbufferStorage( _gl.RENDERBUFFER, glInternalFormat, renderTarget.width, renderTarget.height );
|
|
25312
25531
|
|
|
25313
25532
|
}
|
|
25314
25533
|
|
|
25315
|
-
|
|
25316
|
-
_gl.framebufferRenderbuffer( _gl.FRAMEBUFFER, _gl.DEPTH_STENCIL_ATTACHMENT, _gl.RENDERBUFFER, renderbuffer );
|
|
25534
|
+
_gl.framebufferRenderbuffer( _gl.FRAMEBUFFER, glAttachmentType, _gl.RENDERBUFFER, renderbuffer );
|
|
25317
25535
|
|
|
25318
25536
|
} else {
|
|
25319
25537
|
|
|
@@ -25778,112 +25996,120 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
25778
25996
|
|
|
25779
25997
|
}
|
|
25780
25998
|
|
|
25999
|
+
const invalidationArrayRead = [];
|
|
26000
|
+
const invalidationArrayDraw = [];
|
|
26001
|
+
|
|
25781
26002
|
function updateMultisampleRenderTarget( renderTarget ) {
|
|
25782
26003
|
|
|
25783
|
-
if (
|
|
26004
|
+
if ( renderTarget.samples > 0 ) {
|
|
25784
26005
|
|
|
25785
|
-
|
|
25786
|
-
const width = renderTarget.width;
|
|
25787
|
-
const height = renderTarget.height;
|
|
25788
|
-
let mask = _gl.COLOR_BUFFER_BIT;
|
|
25789
|
-
const invalidationArray = [];
|
|
25790
|
-
const depthStyle = renderTarget.stencilBuffer ? _gl.DEPTH_STENCIL_ATTACHMENT : _gl.DEPTH_ATTACHMENT;
|
|
25791
|
-
const renderTargetProperties = properties.get( renderTarget );
|
|
25792
|
-
const isMultipleRenderTargets = ( textures.length > 1 );
|
|
26006
|
+
if ( useMultisampledRTT( renderTarget ) === false ) {
|
|
25793
26007
|
|
|
25794
|
-
|
|
25795
|
-
|
|
26008
|
+
const textures = renderTarget.textures;
|
|
26009
|
+
const width = renderTarget.width;
|
|
26010
|
+
const height = renderTarget.height;
|
|
26011
|
+
let mask = _gl.COLOR_BUFFER_BIT;
|
|
26012
|
+
const depthStyle = renderTarget.stencilBuffer ? _gl.DEPTH_STENCIL_ATTACHMENT : _gl.DEPTH_ATTACHMENT;
|
|
26013
|
+
const renderTargetProperties = properties.get( renderTarget );
|
|
26014
|
+
const isMultipleRenderTargets = ( textures.length > 1 );
|
|
25796
26015
|
|
|
25797
|
-
|
|
26016
|
+
// If MRT we need to remove FBO attachments
|
|
26017
|
+
if ( isMultipleRenderTargets ) {
|
|
26018
|
+
|
|
26019
|
+
for ( let i = 0; i < textures.length; i ++ ) {
|
|
26020
|
+
|
|
26021
|
+
state.bindFramebuffer( _gl.FRAMEBUFFER, renderTargetProperties.__webglMultisampledFramebuffer );
|
|
26022
|
+
_gl.framebufferRenderbuffer( _gl.FRAMEBUFFER, _gl.COLOR_ATTACHMENT0 + i, _gl.RENDERBUFFER, null );
|
|
25798
26023
|
|
|
25799
|
-
|
|
25800
|
-
|
|
26024
|
+
state.bindFramebuffer( _gl.FRAMEBUFFER, renderTargetProperties.__webglFramebuffer );
|
|
26025
|
+
_gl.framebufferTexture2D( _gl.DRAW_FRAMEBUFFER, _gl.COLOR_ATTACHMENT0 + i, _gl.TEXTURE_2D, null, 0 );
|
|
25801
26026
|
|
|
25802
|
-
|
|
25803
|
-
_gl.framebufferTexture2D( _gl.DRAW_FRAMEBUFFER, _gl.COLOR_ATTACHMENT0 + i, _gl.TEXTURE_2D, null, 0 );
|
|
26027
|
+
}
|
|
25804
26028
|
|
|
25805
26029
|
}
|
|
25806
26030
|
|
|
25807
|
-
|
|
26031
|
+
state.bindFramebuffer( _gl.READ_FRAMEBUFFER, renderTargetProperties.__webglMultisampledFramebuffer );
|
|
26032
|
+
state.bindFramebuffer( _gl.DRAW_FRAMEBUFFER, renderTargetProperties.__webglFramebuffer );
|
|
25808
26033
|
|
|
25809
|
-
|
|
25810
|
-
state.bindFramebuffer( _gl.DRAW_FRAMEBUFFER, renderTargetProperties.__webglFramebuffer );
|
|
26034
|
+
for ( let i = 0; i < textures.length; i ++ ) {
|
|
25811
26035
|
|
|
25812
|
-
|
|
26036
|
+
if ( renderTarget.resolveDepthBuffer ) {
|
|
25813
26037
|
|
|
25814
|
-
|
|
26038
|
+
if ( renderTarget.depthBuffer ) mask |= _gl.DEPTH_BUFFER_BIT;
|
|
25815
26039
|
|
|
25816
|
-
|
|
26040
|
+
// resolving stencil is slow with a D3D backend. disable it for all transmission render targets (see #27799)
|
|
25817
26041
|
|
|
25818
|
-
|
|
26042
|
+
if ( renderTarget.stencilBuffer && renderTarget.resolveStencilBuffer ) mask |= _gl.STENCIL_BUFFER_BIT;
|
|
25819
26043
|
|
|
25820
|
-
|
|
26044
|
+
}
|
|
25821
26045
|
|
|
25822
|
-
|
|
26046
|
+
if ( isMultipleRenderTargets ) {
|
|
25823
26047
|
|
|
25824
|
-
|
|
26048
|
+
_gl.framebufferRenderbuffer( _gl.READ_FRAMEBUFFER, _gl.COLOR_ATTACHMENT0, _gl.RENDERBUFFER, renderTargetProperties.__webglColorRenderbuffer[ i ] );
|
|
25825
26049
|
|
|
25826
|
-
|
|
26050
|
+
const webglTexture = properties.get( textures[ i ] ).__webglTexture;
|
|
26051
|
+
_gl.framebufferTexture2D( _gl.DRAW_FRAMEBUFFER, _gl.COLOR_ATTACHMENT0, _gl.TEXTURE_2D, webglTexture, 0 );
|
|
25827
26052
|
|
|
25828
|
-
|
|
26053
|
+
}
|
|
25829
26054
|
|
|
25830
|
-
|
|
26055
|
+
_gl.blitFramebuffer( 0, 0, width, height, 0, 0, width, height, mask, _gl.NEAREST );
|
|
25831
26056
|
|
|
25832
|
-
|
|
26057
|
+
if ( supportsInvalidateFramebuffer === true ) {
|
|
25833
26058
|
|
|
25834
|
-
|
|
26059
|
+
invalidationArrayRead.length = 0;
|
|
26060
|
+
invalidationArrayDraw.length = 0;
|
|
25835
26061
|
|
|
25836
|
-
|
|
26062
|
+
invalidationArrayRead.push( _gl.COLOR_ATTACHMENT0 + i );
|
|
25837
26063
|
|
|
25838
|
-
|
|
26064
|
+
if ( renderTarget.depthBuffer && renderTarget.resolveDepthBuffer === false ) {
|
|
25839
26065
|
|
|
25840
|
-
|
|
26066
|
+
invalidationArrayRead.push( depthStyle );
|
|
26067
|
+
invalidationArrayDraw.push( depthStyle );
|
|
25841
26068
|
|
|
25842
|
-
|
|
25843
|
-
_gl.invalidateFramebuffer( _gl.DRAW_FRAMEBUFFER, [ depthStyle ] );
|
|
26069
|
+
_gl.invalidateFramebuffer( _gl.DRAW_FRAMEBUFFER, invalidationArrayDraw );
|
|
25844
26070
|
|
|
25845
|
-
|
|
26071
|
+
}
|
|
25846
26072
|
|
|
25847
|
-
|
|
26073
|
+
_gl.invalidateFramebuffer( _gl.READ_FRAMEBUFFER, invalidationArrayRead );
|
|
25848
26074
|
|
|
25849
|
-
|
|
25850
|
-
_gl.framebufferTexture2D( _gl.DRAW_FRAMEBUFFER, _gl.COLOR_ATTACHMENT0, _gl.TEXTURE_2D, webglTexture, 0 );
|
|
26075
|
+
}
|
|
25851
26076
|
|
|
25852
26077
|
}
|
|
25853
26078
|
|
|
25854
|
-
|
|
26079
|
+
state.bindFramebuffer( _gl.READ_FRAMEBUFFER, null );
|
|
26080
|
+
state.bindFramebuffer( _gl.DRAW_FRAMEBUFFER, null );
|
|
25855
26081
|
|
|
25856
|
-
|
|
26082
|
+
// If MRT since pre-blit we removed the FBO we need to reconstruct the attachments
|
|
26083
|
+
if ( isMultipleRenderTargets ) {
|
|
25857
26084
|
|
|
25858
|
-
|
|
26085
|
+
for ( let i = 0; i < textures.length; i ++ ) {
|
|
25859
26086
|
|
|
25860
|
-
|
|
26087
|
+
state.bindFramebuffer( _gl.FRAMEBUFFER, renderTargetProperties.__webglMultisampledFramebuffer );
|
|
26088
|
+
_gl.framebufferRenderbuffer( _gl.FRAMEBUFFER, _gl.COLOR_ATTACHMENT0 + i, _gl.RENDERBUFFER, renderTargetProperties.__webglColorRenderbuffer[ i ] );
|
|
25861
26089
|
|
|
26090
|
+
const webglTexture = properties.get( textures[ i ] ).__webglTexture;
|
|
25862
26091
|
|
|
25863
|
-
|
|
26092
|
+
state.bindFramebuffer( _gl.FRAMEBUFFER, renderTargetProperties.__webglFramebuffer );
|
|
26093
|
+
_gl.framebufferTexture2D( _gl.DRAW_FRAMEBUFFER, _gl.COLOR_ATTACHMENT0 + i, _gl.TEXTURE_2D, webglTexture, 0 );
|
|
25864
26094
|
|
|
25865
|
-
|
|
25866
|
-
state.bindFramebuffer( _gl.DRAW_FRAMEBUFFER, null );
|
|
26095
|
+
}
|
|
25867
26096
|
|
|
25868
|
-
|
|
25869
|
-
if ( isMultipleRenderTargets ) {
|
|
26097
|
+
}
|
|
25870
26098
|
|
|
25871
|
-
|
|
26099
|
+
state.bindFramebuffer( _gl.DRAW_FRAMEBUFFER, renderTargetProperties.__webglMultisampledFramebuffer );
|
|
25872
26100
|
|
|
25873
|
-
|
|
25874
|
-
|
|
26101
|
+
} else {
|
|
26102
|
+
|
|
26103
|
+
if ( renderTarget.depthBuffer && renderTarget.resolveDepthBuffer === false && supportsInvalidateFramebuffer ) {
|
|
25875
26104
|
|
|
25876
|
-
const
|
|
26105
|
+
const depthStyle = renderTarget.stencilBuffer ? _gl.DEPTH_STENCIL_ATTACHMENT : _gl.DEPTH_ATTACHMENT;
|
|
25877
26106
|
|
|
25878
|
-
|
|
25879
|
-
_gl.framebufferTexture2D( _gl.DRAW_FRAMEBUFFER, _gl.COLOR_ATTACHMENT0 + i, _gl.TEXTURE_2D, webglTexture, 0 );
|
|
26107
|
+
_gl.invalidateFramebuffer( _gl.DRAW_FRAMEBUFFER, [ depthStyle ] );
|
|
25880
26108
|
|
|
25881
26109
|
}
|
|
25882
26110
|
|
|
25883
26111
|
}
|
|
25884
26112
|
|
|
25885
|
-
state.bindFramebuffer( _gl.DRAW_FRAMEBUFFER, renderTargetProperties.__webglMultisampledFramebuffer );
|
|
25886
|
-
|
|
25887
26113
|
}
|
|
25888
26114
|
|
|
25889
26115
|
}
|
|
@@ -26099,33 +26325,15 @@ function WebGLUtils( gl, extensions ) {
|
|
|
26099
26325
|
|
|
26100
26326
|
}
|
|
26101
26327
|
|
|
26102
|
-
//
|
|
26103
|
-
|
|
26104
|
-
if ( p === RGB_ETC1_Format ) {
|
|
26105
|
-
|
|
26106
|
-
extension = extensions.get( 'WEBGL_compressed_texture_etc1' );
|
|
26107
|
-
|
|
26108
|
-
if ( extension !== null ) {
|
|
26109
|
-
|
|
26110
|
-
return extension.COMPRESSED_RGB_ETC1_WEBGL;
|
|
26111
|
-
|
|
26112
|
-
} else {
|
|
26113
|
-
|
|
26114
|
-
return null;
|
|
26115
|
-
|
|
26116
|
-
}
|
|
26117
|
-
|
|
26118
|
-
}
|
|
26328
|
+
// ETC
|
|
26119
26329
|
|
|
26120
|
-
|
|
26121
|
-
|
|
26122
|
-
if ( p === RGB_ETC2_Format || p === RGBA_ETC2_EAC_Format ) {
|
|
26330
|
+
if ( p === RGB_ETC1_Format || p === RGB_ETC2_Format || p === RGBA_ETC2_EAC_Format ) {
|
|
26123
26331
|
|
|
26124
26332
|
extension = extensions.get( 'WEBGL_compressed_texture_etc' );
|
|
26125
26333
|
|
|
26126
26334
|
if ( extension !== null ) {
|
|
26127
26335
|
|
|
26128
|
-
if ( p === RGB_ETC2_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB8_ETC2 : extension.COMPRESSED_RGB8_ETC2;
|
|
26336
|
+
if ( p === RGB_ETC1_Format || p === RGB_ETC2_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB8_ETC2 : extension.COMPRESSED_RGB8_ETC2;
|
|
26129
26337
|
if ( p === RGBA_ETC2_EAC_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC : extension.COMPRESSED_RGBA8_ETC2_EAC;
|
|
26130
26338
|
|
|
26131
26339
|
} else {
|
|
@@ -27234,7 +27442,7 @@ class WebXRDepthSensing {
|
|
|
27234
27442
|
|
|
27235
27443
|
}
|
|
27236
27444
|
|
|
27237
|
-
|
|
27445
|
+
getMesh( cameraXR ) {
|
|
27238
27446
|
|
|
27239
27447
|
if ( this.texture !== null ) {
|
|
27240
27448
|
|
|
@@ -27255,10 +27463,10 @@ class WebXRDepthSensing {
|
|
|
27255
27463
|
|
|
27256
27464
|
}
|
|
27257
27465
|
|
|
27258
|
-
renderer.render( this.mesh, cameraXR );
|
|
27259
|
-
|
|
27260
27466
|
}
|
|
27261
27467
|
|
|
27468
|
+
return this.mesh;
|
|
27469
|
+
|
|
27262
27470
|
}
|
|
27263
27471
|
|
|
27264
27472
|
reset() {
|
|
@@ -27618,7 +27826,8 @@ class WebXRManager extends EventDispatcher {
|
|
|
27618
27826
|
depthTexture: new DepthTexture( glProjLayer.textureWidth, glProjLayer.textureHeight, depthType, undefined, undefined, undefined, undefined, undefined, undefined, depthFormat ),
|
|
27619
27827
|
stencilBuffer: attributes.stencil,
|
|
27620
27828
|
colorSpace: renderer.outputColorSpace,
|
|
27621
|
-
samples: attributes.antialias ? 4 : 0
|
|
27829
|
+
samples: attributes.antialias ? 4 : 0,
|
|
27830
|
+
resolveDepthBuffer: ( glProjLayer.ignoreDepthValues === false )
|
|
27622
27831
|
};
|
|
27623
27832
|
|
|
27624
27833
|
if ( scope.isMultiview ) {
|
|
@@ -27638,9 +27847,6 @@ class WebXRManager extends EventDispatcher {
|
|
|
27638
27847
|
|
|
27639
27848
|
}
|
|
27640
27849
|
|
|
27641
|
-
const renderTargetProperties = renderer.properties.get( newRenderTarget );
|
|
27642
|
-
renderTargetProperties.__ignoreDepthValues = glProjLayer.ignoreDepthValues;
|
|
27643
|
-
|
|
27644
27850
|
}
|
|
27645
27851
|
|
|
27646
27852
|
newRenderTarget.isXRRenderTarget = true; // TODO Remove this when possible, see #23278
|
|
@@ -27984,6 +28190,12 @@ class WebXRManager extends EventDispatcher {
|
|
|
27984
28190
|
|
|
27985
28191
|
};
|
|
27986
28192
|
|
|
28193
|
+
this.getDepthSensingMesh = function () {
|
|
28194
|
+
|
|
28195
|
+
return depthSensing.getMesh( cameraXR );
|
|
28196
|
+
|
|
28197
|
+
};
|
|
28198
|
+
|
|
27987
28199
|
// Animation Loop
|
|
27988
28200
|
|
|
27989
28201
|
let onAnimationFrameCallback = null;
|
|
@@ -28109,8 +28321,6 @@ class WebXRManager extends EventDispatcher {
|
|
|
28109
28321
|
|
|
28110
28322
|
}
|
|
28111
28323
|
|
|
28112
|
-
depthSensing.render( renderer, cameraXR );
|
|
28113
|
-
|
|
28114
28324
|
if ( onAnimationFrameCallback ) onAnimationFrameCallback( time, frame );
|
|
28115
28325
|
|
|
28116
28326
|
if ( frame.detectedPlanes ) {
|
|
@@ -28385,11 +28595,7 @@ function WebGLMaterials( renderer, properties ) {
|
|
|
28385
28595
|
if ( material.lightMap ) {
|
|
28386
28596
|
|
|
28387
28597
|
uniforms.lightMap.value = material.lightMap;
|
|
28388
|
-
|
|
28389
|
-
// artist-friendly light intensity scaling factor
|
|
28390
|
-
const scaleFactor = ( renderer._useLegacyLights === true ) ? Math.PI : 1;
|
|
28391
|
-
|
|
28392
|
-
uniforms.lightMapIntensity.value = material.lightMapIntensity * scaleFactor;
|
|
28598
|
+
uniforms.lightMapIntensity.value = material.lightMapIntensity;
|
|
28393
28599
|
|
|
28394
28600
|
refreshTransformUniform( material.lightMap, uniforms.lightMapTransform );
|
|
28395
28601
|
|
|
@@ -28606,6 +28812,12 @@ function WebGLMaterials( renderer, properties ) {
|
|
|
28606
28812
|
|
|
28607
28813
|
}
|
|
28608
28814
|
|
|
28815
|
+
if ( material.dispersion > 0 ) {
|
|
28816
|
+
|
|
28817
|
+
uniforms.dispersion.value = material.dispersion;
|
|
28818
|
+
|
|
28819
|
+
}
|
|
28820
|
+
|
|
28609
28821
|
if ( material.iridescence > 0 ) {
|
|
28610
28822
|
|
|
28611
28823
|
uniforms.iridescence.value = material.iridescence;
|
|
@@ -29201,10 +29413,6 @@ class WebGLRenderer {
|
|
|
29201
29413
|
|
|
29202
29414
|
this._outputColorSpace = SRGBColorSpace;
|
|
29203
29415
|
|
|
29204
|
-
// physical lights
|
|
29205
|
-
|
|
29206
|
-
this._useLegacyLights = false;
|
|
29207
|
-
|
|
29208
29416
|
// tone mapping
|
|
29209
29417
|
|
|
29210
29418
|
this.toneMapping = NoToneMapping;
|
|
@@ -29258,11 +29466,12 @@ class WebGLRenderer {
|
|
|
29258
29466
|
|
|
29259
29467
|
const _projScreenMatrix = new Matrix4();
|
|
29260
29468
|
|
|
29261
|
-
const _vector2 = new Vector2();
|
|
29262
29469
|
const _vector3 = new Vector3();
|
|
29263
29470
|
|
|
29264
29471
|
const _emptyScene = { background: null, fog: null, environment: null, overrideMaterial: null, isScene: true };
|
|
29265
29472
|
|
|
29473
|
+
let _renderBackground = false;
|
|
29474
|
+
|
|
29266
29475
|
function getTargetPixelRatio() {
|
|
29267
29476
|
|
|
29268
29477
|
return _currentRenderTarget === null ? _pixelRatio : 1;
|
|
@@ -29275,10 +29484,7 @@ class WebGLRenderer {
|
|
|
29275
29484
|
|
|
29276
29485
|
function getContext( contextName, contextAttributes ) {
|
|
29277
29486
|
|
|
29278
|
-
|
|
29279
|
-
if ( context !== null ) return context;
|
|
29280
|
-
|
|
29281
|
-
return null;
|
|
29487
|
+
return canvas.getContext( contextName, contextAttributes );
|
|
29282
29488
|
|
|
29283
29489
|
}
|
|
29284
29490
|
|
|
@@ -29346,10 +29552,10 @@ class WebGLRenderer {
|
|
|
29346
29552
|
extensions = new WebGLExtensions( _gl );
|
|
29347
29553
|
extensions.init();
|
|
29348
29554
|
|
|
29349
|
-
capabilities = new WebGLCapabilities( _gl, extensions, parameters );
|
|
29350
|
-
|
|
29351
29555
|
utils = new WebGLUtils( _gl, extensions );
|
|
29352
29556
|
|
|
29557
|
+
capabilities = new WebGLCapabilities( _gl, extensions, parameters, utils );
|
|
29558
|
+
|
|
29353
29559
|
state = new WebGLState( _gl );
|
|
29354
29560
|
|
|
29355
29561
|
info = new WebGLInfo( _gl );
|
|
@@ -29915,7 +30121,15 @@ class WebGLRenderer {
|
|
|
29915
30121
|
|
|
29916
30122
|
if ( object.isBatchedMesh ) {
|
|
29917
30123
|
|
|
29918
|
-
|
|
30124
|
+
if ( object._multiDrawInstances !== null ) {
|
|
30125
|
+
|
|
30126
|
+
renderer.renderMultiDrawInstances( object._multiDrawStarts, object._multiDrawCounts, object._multiDrawCount, object._multiDrawInstances );
|
|
30127
|
+
|
|
30128
|
+
} else {
|
|
30129
|
+
|
|
30130
|
+
renderer.renderMultiDraw( object._multiDrawStarts, object._multiDrawCounts, object._multiDrawCount );
|
|
30131
|
+
|
|
30132
|
+
}
|
|
29919
30133
|
|
|
29920
30134
|
} else if ( object.isInstancedMesh ) {
|
|
29921
30135
|
|
|
@@ -29965,7 +30179,7 @@ class WebGLRenderer {
|
|
|
29965
30179
|
if ( targetScene === null ) targetScene = scene;
|
|
29966
30180
|
|
|
29967
30181
|
currentRenderState = renderStates.get( targetScene );
|
|
29968
|
-
currentRenderState.init();
|
|
30182
|
+
currentRenderState.init( camera );
|
|
29969
30183
|
|
|
29970
30184
|
renderStateStack.push( currentRenderState );
|
|
29971
30185
|
|
|
@@ -30007,7 +30221,7 @@ class WebGLRenderer {
|
|
|
30007
30221
|
|
|
30008
30222
|
}
|
|
30009
30223
|
|
|
30010
|
-
currentRenderState.setupLights(
|
|
30224
|
+
currentRenderState.setupLights();
|
|
30011
30225
|
|
|
30012
30226
|
// Only initialize materials in the new scene, not the targetScene.
|
|
30013
30227
|
|
|
@@ -30182,7 +30396,7 @@ class WebGLRenderer {
|
|
|
30182
30396
|
if ( scene.isScene === true ) scene.onBeforeRender( _this, scene, camera, _currentRenderTarget );
|
|
30183
30397
|
|
|
30184
30398
|
currentRenderState = renderStates.get( scene, renderStateStack.length );
|
|
30185
|
-
currentRenderState.init();
|
|
30399
|
+
currentRenderState.init( camera );
|
|
30186
30400
|
|
|
30187
30401
|
renderStateStack.push( currentRenderState );
|
|
30188
30402
|
|
|
@@ -30197,6 +30411,18 @@ class WebGLRenderer {
|
|
|
30197
30411
|
|
|
30198
30412
|
renderListStack.push( currentRenderList );
|
|
30199
30413
|
|
|
30414
|
+
if ( xr.enabled === true && xr.isPresenting === true ) {
|
|
30415
|
+
|
|
30416
|
+
const depthSensingMesh = _this.xr.getDepthSensingMesh();
|
|
30417
|
+
|
|
30418
|
+
if ( depthSensingMesh !== null ) {
|
|
30419
|
+
|
|
30420
|
+
projectObject( depthSensingMesh, camera, - Infinity, _this.sortObjects );
|
|
30421
|
+
|
|
30422
|
+
}
|
|
30423
|
+
|
|
30424
|
+
}
|
|
30425
|
+
|
|
30200
30426
|
projectObject( scene, camera, 0, _this.sortObjects );
|
|
30201
30427
|
|
|
30202
30428
|
currentRenderList.finish();
|
|
@@ -30207,6 +30433,13 @@ class WebGLRenderer {
|
|
|
30207
30433
|
|
|
30208
30434
|
}
|
|
30209
30435
|
|
|
30436
|
+
_renderBackground = xr.enabled === false || xr.isPresenting === false || xr.hasDepthSensing() === false;
|
|
30437
|
+
if ( _renderBackground ) {
|
|
30438
|
+
|
|
30439
|
+
background.addToRenderList( currentRenderList, scene );
|
|
30440
|
+
|
|
30441
|
+
}
|
|
30442
|
+
|
|
30210
30443
|
//
|
|
30211
30444
|
|
|
30212
30445
|
this.info.render.frame ++;
|
|
@@ -30223,20 +30456,30 @@ class WebGLRenderer {
|
|
|
30223
30456
|
|
|
30224
30457
|
if ( this.info.autoReset === true ) this.info.reset();
|
|
30225
30458
|
|
|
30459
|
+
// render scene
|
|
30226
30460
|
|
|
30227
|
-
|
|
30461
|
+
const opaqueObjects = currentRenderList.opaque;
|
|
30462
|
+
const transmissiveObjects = currentRenderList.transmissive;
|
|
30228
30463
|
|
|
30229
|
-
|
|
30464
|
+
currentRenderState.setupLights();
|
|
30230
30465
|
|
|
30231
|
-
|
|
30466
|
+
if ( camera.isArrayCamera ) {
|
|
30232
30467
|
|
|
30233
|
-
|
|
30468
|
+
const cameras = camera.cameras;
|
|
30234
30469
|
|
|
30235
|
-
|
|
30470
|
+
if ( transmissiveObjects.length > 0 ) {
|
|
30236
30471
|
|
|
30237
|
-
|
|
30472
|
+
for ( let i = 0, l = cameras.length; i < l; i ++ ) {
|
|
30238
30473
|
|
|
30239
|
-
|
|
30474
|
+
const camera2 = cameras[ i ];
|
|
30475
|
+
|
|
30476
|
+
renderTransmissionPass( opaqueObjects, transmissiveObjects, scene, camera2 );
|
|
30477
|
+
|
|
30478
|
+
}
|
|
30479
|
+
|
|
30480
|
+
}
|
|
30481
|
+
|
|
30482
|
+
if ( _renderBackground ) background.render( scene );
|
|
30240
30483
|
|
|
30241
30484
|
if ( xr.enabled && xr.isMultiview ) {
|
|
30242
30485
|
|
|
@@ -30246,8 +30489,6 @@ class WebGLRenderer {
|
|
|
30246
30489
|
|
|
30247
30490
|
} else {
|
|
30248
30491
|
|
|
30249
|
-
const cameras = camera.cameras;
|
|
30250
|
-
|
|
30251
30492
|
for ( let i = 0, l = cameras.length; i < l; i ++ ) {
|
|
30252
30493
|
|
|
30253
30494
|
const camera2 = cameras[ i ];
|
|
@@ -30260,6 +30501,10 @@ class WebGLRenderer {
|
|
|
30260
30501
|
|
|
30261
30502
|
} else {
|
|
30262
30503
|
|
|
30504
|
+
if ( transmissiveObjects.length > 0 ) renderTransmissionPass( opaqueObjects, transmissiveObjects, scene, camera );
|
|
30505
|
+
|
|
30506
|
+
if ( _renderBackground ) background.render( scene );
|
|
30507
|
+
|
|
30263
30508
|
renderScene( currentRenderList, scene, camera );
|
|
30264
30509
|
|
|
30265
30510
|
}
|
|
@@ -30301,6 +30546,8 @@ class WebGLRenderer {
|
|
|
30301
30546
|
|
|
30302
30547
|
currentRenderState = renderStateStack[ renderStateStack.length - 1 ];
|
|
30303
30548
|
|
|
30549
|
+
if ( _clippingEnabled === true ) clipping.setGlobalState( _this.clippingPlanes, currentRenderState.state.camera );
|
|
30550
|
+
|
|
30304
30551
|
} else {
|
|
30305
30552
|
|
|
30306
30553
|
currentRenderState = null;
|
|
@@ -30445,8 +30692,6 @@ class WebGLRenderer {
|
|
|
30445
30692
|
|
|
30446
30693
|
if ( _clippingEnabled === true ) clipping.setGlobalState( _this.clippingPlanes, camera );
|
|
30447
30694
|
|
|
30448
|
-
if ( transmissiveObjects.length > 0 ) renderTransmissionPass( opaqueObjects, transmissiveObjects, scene, camera );
|
|
30449
|
-
|
|
30450
30695
|
if ( viewport ) state.viewport( _currentViewport.copy( viewport ) );
|
|
30451
30696
|
|
|
30452
30697
|
if ( opaqueObjects.length > 0 ) renderObjects( opaqueObjects, scene, camera );
|
|
@@ -30473,19 +30718,19 @@ class WebGLRenderer {
|
|
|
30473
30718
|
|
|
30474
30719
|
}
|
|
30475
30720
|
|
|
30476
|
-
if ( currentRenderState.state.transmissionRenderTarget ===
|
|
30721
|
+
if ( currentRenderState.state.transmissionRenderTarget[ camera.id ] === undefined ) {
|
|
30477
30722
|
|
|
30478
|
-
currentRenderState.state.transmissionRenderTarget = new WebGLRenderTarget( 1, 1, {
|
|
30723
|
+
currentRenderState.state.transmissionRenderTarget[ camera.id ] = new WebGLRenderTarget( 1, 1, {
|
|
30479
30724
|
generateMipmaps: true,
|
|
30480
30725
|
type: ( extensions.has( 'EXT_color_buffer_half_float' ) || extensions.has( 'EXT_color_buffer_float' ) ) ? HalfFloatType : UnsignedByteType,
|
|
30481
30726
|
minFilter: LinearMipmapLinearFilter,
|
|
30482
30727
|
samples: 4,
|
|
30483
|
-
stencilBuffer: stencil
|
|
30728
|
+
stencilBuffer: stencil,
|
|
30729
|
+
resolveDepthBuffer: false,
|
|
30730
|
+
resolveStencilBuffer: false,
|
|
30731
|
+
colorSpace: ColorManagement.workingColorSpace,
|
|
30484
30732
|
} );
|
|
30485
30733
|
|
|
30486
|
-
const renderTargetProperties = properties.get( currentRenderState.state.transmissionRenderTarget );
|
|
30487
|
-
renderTargetProperties.__isTransmissionRenderTarget = true;
|
|
30488
|
-
|
|
30489
30734
|
// debug
|
|
30490
30735
|
|
|
30491
30736
|
/*
|
|
@@ -30498,10 +30743,10 @@ class WebGLRenderer {
|
|
|
30498
30743
|
|
|
30499
30744
|
}
|
|
30500
30745
|
|
|
30501
|
-
const transmissionRenderTarget = currentRenderState.state.transmissionRenderTarget;
|
|
30746
|
+
const transmissionRenderTarget = currentRenderState.state.transmissionRenderTarget[ camera.id ];
|
|
30502
30747
|
|
|
30503
|
-
|
|
30504
|
-
transmissionRenderTarget.setSize(
|
|
30748
|
+
const activeViewport = camera.viewport || _currentViewport;
|
|
30749
|
+
transmissionRenderTarget.setSize( activeViewport.z, activeViewport.w );
|
|
30505
30750
|
|
|
30506
30751
|
//
|
|
30507
30752
|
|
|
@@ -30512,51 +30757,72 @@ class WebGLRenderer {
|
|
|
30512
30757
|
_currentClearAlpha = _this.getClearAlpha();
|
|
30513
30758
|
if ( _currentClearAlpha < 1 ) _this.setClearColor( 0xffffff, 0.5 );
|
|
30514
30759
|
|
|
30515
|
-
|
|
30760
|
+
if ( _renderBackground ) {
|
|
30761
|
+
|
|
30762
|
+
background.render( scene );
|
|
30763
|
+
|
|
30764
|
+
} else {
|
|
30765
|
+
|
|
30766
|
+
_this.clear();
|
|
30767
|
+
|
|
30768
|
+
}
|
|
30516
30769
|
|
|
30517
30770
|
// Turn off the features which can affect the frag color for opaque objects pass.
|
|
30518
30771
|
// Otherwise they are applied twice in opaque objects pass and transmission objects pass.
|
|
30519
30772
|
const currentToneMapping = _this.toneMapping;
|
|
30520
30773
|
_this.toneMapping = NoToneMapping;
|
|
30521
30774
|
|
|
30775
|
+
// Remove viewport from camera to avoid nested render calls resetting viewport to it (e.g Reflector).
|
|
30776
|
+
// Transmission render pass requires viewport to match the transmissionRenderTarget.
|
|
30777
|
+
const currentCameraViewport = camera.viewport;
|
|
30778
|
+
if ( camera.viewport !== undefined ) camera.viewport = undefined;
|
|
30779
|
+
|
|
30780
|
+
currentRenderState.setupLightsView( camera );
|
|
30781
|
+
|
|
30782
|
+
if ( _clippingEnabled === true ) clipping.setGlobalState( _this.clippingPlanes, camera );
|
|
30783
|
+
|
|
30522
30784
|
renderObjects( opaqueObjects, scene, camera );
|
|
30523
30785
|
|
|
30524
30786
|
textures.updateMultisampleRenderTarget( transmissionRenderTarget );
|
|
30525
30787
|
textures.updateRenderTargetMipmap( transmissionRenderTarget );
|
|
30526
30788
|
|
|
30527
|
-
|
|
30789
|
+
if ( extensions.has( 'WEBGL_multisampled_render_to_texture' ) === false ) { // see #28131
|
|
30528
30790
|
|
|
30529
|
-
|
|
30791
|
+
let renderTargetNeedsUpdate = false;
|
|
30530
30792
|
|
|
30531
|
-
|
|
30793
|
+
for ( let i = 0, l = transmissiveObjects.length; i < l; i ++ ) {
|
|
30532
30794
|
|
|
30533
|
-
|
|
30534
|
-
const geometry = renderItem.geometry;
|
|
30535
|
-
const material = renderItem.material;
|
|
30536
|
-
const group = renderItem.group;
|
|
30795
|
+
const renderItem = transmissiveObjects[ i ];
|
|
30537
30796
|
|
|
30538
|
-
|
|
30797
|
+
const object = renderItem.object;
|
|
30798
|
+
const geometry = renderItem.geometry;
|
|
30799
|
+
const material = renderItem.material;
|
|
30800
|
+
const group = renderItem.group;
|
|
30539
30801
|
|
|
30540
|
-
|
|
30802
|
+
if ( material.side === DoubleSide && object.layers.test( camera.layers ) ) {
|
|
30541
30803
|
|
|
30542
|
-
|
|
30543
|
-
material.needsUpdate = true;
|
|
30804
|
+
const currentSide = material.side;
|
|
30544
30805
|
|
|
30545
|
-
|
|
30806
|
+
material.side = BackSide;
|
|
30807
|
+
material.needsUpdate = true;
|
|
30546
30808
|
|
|
30547
|
-
|
|
30548
|
-
material.needsUpdate = true;
|
|
30809
|
+
renderObject( object, scene, camera, geometry, material, group );
|
|
30549
30810
|
|
|
30550
|
-
|
|
30811
|
+
material.side = currentSide;
|
|
30812
|
+
material.needsUpdate = true;
|
|
30813
|
+
|
|
30814
|
+
renderTargetNeedsUpdate = true;
|
|
30815
|
+
|
|
30816
|
+
}
|
|
30551
30817
|
|
|
30552
30818
|
}
|
|
30553
30819
|
|
|
30554
|
-
|
|
30820
|
+
if ( renderTargetNeedsUpdate === true ) {
|
|
30555
30821
|
|
|
30556
|
-
|
|
30822
|
+
textures.updateMultisampleRenderTarget( transmissionRenderTarget );
|
|
30823
|
+
textures.updateRenderTargetMipmap( transmissionRenderTarget );
|
|
30557
30824
|
|
|
30558
|
-
|
|
30559
|
-
textures.updateRenderTargetMipmap( transmissionRenderTarget );
|
|
30825
|
+
}
|
|
30560
30826
|
|
|
30561
30827
|
}
|
|
30562
30828
|
|
|
@@ -30564,6 +30830,8 @@ class WebGLRenderer {
|
|
|
30564
30830
|
|
|
30565
30831
|
_this.setClearColor( _currentClearColor, _currentClearAlpha );
|
|
30566
30832
|
|
|
30833
|
+
if ( currentCameraViewport !== undefined ) camera.viewport = currentCameraViewport;
|
|
30834
|
+
|
|
30567
30835
|
_this.toneMapping = currentToneMapping;
|
|
30568
30836
|
|
|
30569
30837
|
}
|
|
@@ -30754,6 +31022,7 @@ class WebGLRenderer {
|
|
|
30754
31022
|
|
|
30755
31023
|
materialProperties.outputColorSpace = parameters.outputColorSpace;
|
|
30756
31024
|
materialProperties.batching = parameters.batching;
|
|
31025
|
+
materialProperties.batchingColor = parameters.batchingColor;
|
|
30757
31026
|
materialProperties.instancing = parameters.instancing;
|
|
30758
31027
|
materialProperties.instancingColor = parameters.instancingColor;
|
|
30759
31028
|
materialProperties.instancingMorph = parameters.instancingMorph;
|
|
@@ -30846,6 +31115,14 @@ class WebGLRenderer {
|
|
|
30846
31115
|
|
|
30847
31116
|
needsProgramChange = true;
|
|
30848
31117
|
|
|
31118
|
+
} else if ( object.isBatchedMesh && materialProperties.batchingColor === true && object.colorTexture === null ) {
|
|
31119
|
+
|
|
31120
|
+
needsProgramChange = true;
|
|
31121
|
+
|
|
31122
|
+
} else if ( object.isBatchedMesh && materialProperties.batchingColor === false && object.colorTexture !== null ) {
|
|
31123
|
+
|
|
31124
|
+
needsProgramChange = true;
|
|
31125
|
+
|
|
30849
31126
|
} else if ( object.isInstancedMesh && materialProperties.instancing === false ) {
|
|
30850
31127
|
|
|
30851
31128
|
needsProgramChange = true;
|
|
@@ -31051,6 +31328,13 @@ class WebGLRenderer {
|
|
|
31051
31328
|
p_uniforms.setOptional( _gl, object, 'batchingTexture' );
|
|
31052
31329
|
p_uniforms.setValue( _gl, 'batchingTexture', object._matricesTexture, textures );
|
|
31053
31330
|
|
|
31331
|
+
p_uniforms.setOptional( _gl, object, 'batchingColorTexture' );
|
|
31332
|
+
if ( object._colorsTexture !== null ) {
|
|
31333
|
+
|
|
31334
|
+
p_uniforms.setValue( _gl, 'batchingColorTexture', object._colorsTexture, textures );
|
|
31335
|
+
|
|
31336
|
+
}
|
|
31337
|
+
|
|
31054
31338
|
}
|
|
31055
31339
|
|
|
31056
31340
|
const morphAttributes = geometry.morphAttributes;
|
|
@@ -31111,7 +31395,7 @@ class WebGLRenderer {
|
|
|
31111
31395
|
|
|
31112
31396
|
}
|
|
31113
31397
|
|
|
31114
|
-
materials.refreshMaterialUniforms( m_uniforms, material, _pixelRatio, _height, currentRenderState.state.transmissionRenderTarget );
|
|
31398
|
+
materials.refreshMaterialUniforms( m_uniforms, material, _pixelRatio, _height, currentRenderState.state.transmissionRenderTarget[ camera.id ] );
|
|
31115
31399
|
|
|
31116
31400
|
WebGLUniforms.upload( _gl, getUniformList( materialProperties ), m_uniforms, textures );
|
|
31117
31401
|
|
|
@@ -31411,17 +31695,14 @@ class WebGLRenderer {
|
|
|
31411
31695
|
const textureFormat = texture.format;
|
|
31412
31696
|
const textureType = texture.type;
|
|
31413
31697
|
|
|
31414
|
-
if (
|
|
31698
|
+
if ( ! capabilities.textureFormatReadable( textureFormat ) ) {
|
|
31415
31699
|
|
|
31416
31700
|
console.error( 'THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.' );
|
|
31417
31701
|
return;
|
|
31418
31702
|
|
|
31419
31703
|
}
|
|
31420
31704
|
|
|
31421
|
-
|
|
31422
|
-
|
|
31423
|
-
if ( textureType !== UnsignedByteType && utils.convert( textureType ) !== _gl.getParameter( _gl.IMPLEMENTATION_COLOR_READ_TYPE ) && // Edge and Chrome Mac < 52 (#9513)
|
|
31424
|
-
textureType !== FloatType && ! halfFloatSupportedByExt ) {
|
|
31705
|
+
if ( ! capabilities.textureTypeReadable( textureType ) ) {
|
|
31425
31706
|
|
|
31426
31707
|
console.error( 'THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.' );
|
|
31427
31708
|
return;
|
|
@@ -31449,24 +31730,159 @@ class WebGLRenderer {
|
|
|
31449
31730
|
|
|
31450
31731
|
};
|
|
31451
31732
|
|
|
31452
|
-
this.
|
|
31733
|
+
this.readRenderTargetPixelsAsync = async function ( renderTarget, x, y, width, height, buffer, activeCubeFaceIndex ) {
|
|
31734
|
+
|
|
31735
|
+
if ( ! ( renderTarget && renderTarget.isWebGLRenderTarget ) ) {
|
|
31736
|
+
|
|
31737
|
+
throw new Error( 'THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.' );
|
|
31738
|
+
|
|
31739
|
+
}
|
|
31740
|
+
|
|
31741
|
+
let framebuffer = properties.get( renderTarget ).__webglFramebuffer;
|
|
31742
|
+
if ( renderTarget.isWebGLCubeRenderTarget && activeCubeFaceIndex !== undefined ) {
|
|
31743
|
+
|
|
31744
|
+
framebuffer = framebuffer[ activeCubeFaceIndex ];
|
|
31745
|
+
|
|
31746
|
+
}
|
|
31747
|
+
|
|
31748
|
+
if ( framebuffer ) {
|
|
31749
|
+
|
|
31750
|
+
state.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );
|
|
31751
|
+
|
|
31752
|
+
try {
|
|
31753
|
+
|
|
31754
|
+
const texture = renderTarget.texture;
|
|
31755
|
+
const textureFormat = texture.format;
|
|
31756
|
+
const textureType = texture.type;
|
|
31757
|
+
|
|
31758
|
+
if ( ! capabilities.textureFormatReadable( textureFormat ) ) {
|
|
31759
|
+
|
|
31760
|
+
throw new Error( 'THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.' );
|
|
31761
|
+
|
|
31762
|
+
}
|
|
31763
|
+
|
|
31764
|
+
if ( ! capabilities.textureTypeReadable( textureType ) ) {
|
|
31765
|
+
|
|
31766
|
+
throw new Error( 'THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.' );
|
|
31767
|
+
|
|
31768
|
+
}
|
|
31769
|
+
|
|
31770
|
+
// the following if statement ensures valid read requests (no out-of-bounds pixels, see #8604)
|
|
31771
|
+
if ( ( x >= 0 && x <= ( renderTarget.width - width ) ) && ( y >= 0 && y <= ( renderTarget.height - height ) ) ) {
|
|
31772
|
+
|
|
31773
|
+
const glBuffer = _gl.createBuffer();
|
|
31774
|
+
_gl.bindBuffer( _gl.PIXEL_PACK_BUFFER, glBuffer );
|
|
31775
|
+
_gl.bufferData( _gl.PIXEL_PACK_BUFFER, buffer.byteLength, _gl.STREAM_READ );
|
|
31776
|
+
_gl.readPixels( x, y, width, height, utils.convert( textureFormat ), utils.convert( textureType ), 0 );
|
|
31777
|
+
_gl.flush();
|
|
31778
|
+
|
|
31779
|
+
// check if the commands have finished every 8 ms
|
|
31780
|
+
const sync = _gl.fenceSync( _gl.SYNC_GPU_COMMANDS_COMPLETE, 0 );
|
|
31781
|
+
await probeAsync( _gl, sync, 4 );
|
|
31782
|
+
|
|
31783
|
+
try {
|
|
31784
|
+
|
|
31785
|
+
_gl.bindBuffer( _gl.PIXEL_PACK_BUFFER, glBuffer );
|
|
31786
|
+
_gl.getBufferSubData( _gl.PIXEL_PACK_BUFFER, 0, buffer );
|
|
31787
|
+
|
|
31788
|
+
} finally {
|
|
31789
|
+
|
|
31790
|
+
_gl.deleteBuffer( glBuffer );
|
|
31791
|
+
_gl.deleteSync( sync );
|
|
31792
|
+
|
|
31793
|
+
}
|
|
31794
|
+
|
|
31795
|
+
return buffer;
|
|
31796
|
+
|
|
31797
|
+
}
|
|
31798
|
+
|
|
31799
|
+
} finally {
|
|
31800
|
+
|
|
31801
|
+
// restore framebuffer of current render target if necessary
|
|
31802
|
+
|
|
31803
|
+
const framebuffer = ( _currentRenderTarget !== null ) ? properties.get( _currentRenderTarget ).__webglFramebuffer : null;
|
|
31804
|
+
state.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );
|
|
31805
|
+
|
|
31806
|
+
}
|
|
31807
|
+
|
|
31808
|
+
}
|
|
31809
|
+
|
|
31810
|
+
};
|
|
31811
|
+
|
|
31812
|
+
this.copyFramebufferToTexture = function ( texture, position = null, level = 0 ) {
|
|
31813
|
+
|
|
31814
|
+
// support previous signature with position first
|
|
31815
|
+
if ( texture.isTexture !== true ) {
|
|
31816
|
+
|
|
31817
|
+
// @deprecated, r165
|
|
31818
|
+
console.warn( 'WebGLRenderer: copyFramebufferToTexture function signature has changed.' );
|
|
31819
|
+
|
|
31820
|
+
position = arguments[ 0 ] || null;
|
|
31821
|
+
texture = arguments[ 1 ];
|
|
31822
|
+
|
|
31823
|
+
}
|
|
31453
31824
|
|
|
31454
31825
|
const levelScale = Math.pow( 2, - level );
|
|
31455
31826
|
const width = Math.floor( texture.image.width * levelScale );
|
|
31456
31827
|
const height = Math.floor( texture.image.height * levelScale );
|
|
31457
31828
|
|
|
31829
|
+
const x = position !== null ? position.x : 0;
|
|
31830
|
+
const y = position !== null ? position.y : 0;
|
|
31831
|
+
|
|
31458
31832
|
textures.setTexture2D( texture, 0 );
|
|
31459
31833
|
|
|
31460
|
-
_gl.copyTexSubImage2D( _gl.TEXTURE_2D, level, 0, 0,
|
|
31834
|
+
_gl.copyTexSubImage2D( _gl.TEXTURE_2D, level, 0, 0, x, y, width, height );
|
|
31461
31835
|
|
|
31462
31836
|
state.unbindTexture();
|
|
31463
31837
|
|
|
31464
31838
|
};
|
|
31465
31839
|
|
|
31466
|
-
this.copyTextureToTexture = function (
|
|
31840
|
+
this.copyTextureToTexture = function ( srcTexture, dstTexture, srcRegion = null, dstPosition = null, level = 0 ) {
|
|
31841
|
+
|
|
31842
|
+
// support previous signature with dstPosition first
|
|
31843
|
+
if ( srcTexture.isTexture !== true ) {
|
|
31844
|
+
|
|
31845
|
+
// @deprecated, r165
|
|
31846
|
+
console.warn( 'WebGLRenderer: copyTextureToTexture function signature has changed.' );
|
|
31847
|
+
|
|
31848
|
+
dstPosition = arguments[ 0 ] || null;
|
|
31849
|
+
srcTexture = arguments[ 1 ];
|
|
31850
|
+
dstTexture = arguments[ 2 ];
|
|
31851
|
+
level = arguments[ 3 ] || 0;
|
|
31852
|
+
srcRegion = null;
|
|
31853
|
+
|
|
31854
|
+
}
|
|
31855
|
+
|
|
31856
|
+
let width, height, minX, minY;
|
|
31857
|
+
let dstX, dstY;
|
|
31858
|
+
if ( srcRegion !== null ) {
|
|
31859
|
+
|
|
31860
|
+
width = srcRegion.max.x - srcRegion.min.x;
|
|
31861
|
+
height = srcRegion.max.y - srcRegion.min.y;
|
|
31862
|
+
minX = srcRegion.min.x;
|
|
31863
|
+
minY = srcRegion.min.y;
|
|
31864
|
+
|
|
31865
|
+
} else {
|
|
31866
|
+
|
|
31867
|
+
width = srcTexture.image.width;
|
|
31868
|
+
height = srcTexture.image.height;
|
|
31869
|
+
minX = 0;
|
|
31870
|
+
minY = 0;
|
|
31871
|
+
|
|
31872
|
+
}
|
|
31873
|
+
|
|
31874
|
+
if ( dstPosition !== null ) {
|
|
31875
|
+
|
|
31876
|
+
dstX = dstPosition.x;
|
|
31877
|
+
dstY = dstPosition.y;
|
|
31878
|
+
|
|
31879
|
+
} else {
|
|
31880
|
+
|
|
31881
|
+
dstX = 0;
|
|
31882
|
+
dstY = 0;
|
|
31883
|
+
|
|
31884
|
+
}
|
|
31467
31885
|
|
|
31468
|
-
const width = srcTexture.image.width;
|
|
31469
|
-
const height = srcTexture.image.height;
|
|
31470
31886
|
const glFormat = utils.convert( dstTexture.format );
|
|
31471
31887
|
const glType = utils.convert( dstTexture.type );
|
|
31472
31888
|
|
|
@@ -31478,24 +31894,43 @@ class WebGLRenderer {
|
|
|
31478
31894
|
_gl.pixelStorei( _gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, dstTexture.premultiplyAlpha );
|
|
31479
31895
|
_gl.pixelStorei( _gl.UNPACK_ALIGNMENT, dstTexture.unpackAlignment );
|
|
31480
31896
|
|
|
31897
|
+
const currentUnpackRowLen = _gl.getParameter( _gl.UNPACK_ROW_LENGTH );
|
|
31898
|
+
const currentUnpackImageHeight = _gl.getParameter( _gl.UNPACK_IMAGE_HEIGHT );
|
|
31899
|
+
const currentUnpackSkipPixels = _gl.getParameter( _gl.UNPACK_SKIP_PIXELS );
|
|
31900
|
+
const currentUnpackSkipRows = _gl.getParameter( _gl.UNPACK_SKIP_ROWS );
|
|
31901
|
+
const currentUnpackSkipImages = _gl.getParameter( _gl.UNPACK_SKIP_IMAGES );
|
|
31902
|
+
|
|
31903
|
+
const image = srcTexture.isCompressedTexture ? srcTexture.mipmaps[ level ] : srcTexture.image;
|
|
31904
|
+
|
|
31905
|
+
_gl.pixelStorei( _gl.UNPACK_ROW_LENGTH, image.width );
|
|
31906
|
+
_gl.pixelStorei( _gl.UNPACK_IMAGE_HEIGHT, image.height );
|
|
31907
|
+
_gl.pixelStorei( _gl.UNPACK_SKIP_PIXELS, minX );
|
|
31908
|
+
_gl.pixelStorei( _gl.UNPACK_SKIP_ROWS, minY );
|
|
31909
|
+
|
|
31481
31910
|
if ( srcTexture.isDataTexture ) {
|
|
31482
31911
|
|
|
31483
|
-
_gl.texSubImage2D( _gl.TEXTURE_2D, level,
|
|
31912
|
+
_gl.texSubImage2D( _gl.TEXTURE_2D, level, dstX, dstY, width, height, glFormat, glType, image.data );
|
|
31484
31913
|
|
|
31485
31914
|
} else {
|
|
31486
31915
|
|
|
31487
31916
|
if ( srcTexture.isCompressedTexture ) {
|
|
31488
31917
|
|
|
31489
|
-
_gl.compressedTexSubImage2D( _gl.TEXTURE_2D, level,
|
|
31918
|
+
_gl.compressedTexSubImage2D( _gl.TEXTURE_2D, level, dstX, dstY, image.width, image.height, glFormat, image.data );
|
|
31490
31919
|
|
|
31491
31920
|
} else {
|
|
31492
31921
|
|
|
31493
|
-
_gl.texSubImage2D( _gl.TEXTURE_2D, level,
|
|
31922
|
+
_gl.texSubImage2D( _gl.TEXTURE_2D, level, dstX, dstY, glFormat, glType, image );
|
|
31494
31923
|
|
|
31495
31924
|
}
|
|
31496
31925
|
|
|
31497
31926
|
}
|
|
31498
31927
|
|
|
31928
|
+
_gl.pixelStorei( _gl.UNPACK_ROW_LENGTH, currentUnpackRowLen );
|
|
31929
|
+
_gl.pixelStorei( _gl.UNPACK_IMAGE_HEIGHT, currentUnpackImageHeight );
|
|
31930
|
+
_gl.pixelStorei( _gl.UNPACK_SKIP_PIXELS, currentUnpackSkipPixels );
|
|
31931
|
+
_gl.pixelStorei( _gl.UNPACK_SKIP_ROWS, currentUnpackSkipRows );
|
|
31932
|
+
_gl.pixelStorei( _gl.UNPACK_SKIP_IMAGES, currentUnpackSkipImages );
|
|
31933
|
+
|
|
31499
31934
|
// Generate mipmaps only when copying level 0
|
|
31500
31935
|
if ( level === 0 && dstTexture.generateMipmaps ) _gl.generateMipmap( _gl.TEXTURE_2D );
|
|
31501
31936
|
|
|
@@ -31503,11 +31938,59 @@ class WebGLRenderer {
|
|
|
31503
31938
|
|
|
31504
31939
|
};
|
|
31505
31940
|
|
|
31506
|
-
this.copyTextureToTexture3D = function (
|
|
31941
|
+
this.copyTextureToTexture3D = function ( srcTexture, dstTexture, srcRegion = null, dstPosition = null, level = 0 ) {
|
|
31942
|
+
|
|
31943
|
+
// support previous signature with source box first
|
|
31944
|
+
if ( srcTexture.isTexture !== true ) {
|
|
31945
|
+
|
|
31946
|
+
// @deprecated, r165
|
|
31947
|
+
console.warn( 'WebGLRenderer: copyTextureToTexture3D function signature has changed.' );
|
|
31948
|
+
|
|
31949
|
+
srcRegion = arguments[ 0 ] || null;
|
|
31950
|
+
dstPosition = arguments[ 1 ] || null;
|
|
31951
|
+
srcTexture = arguments[ 2 ];
|
|
31952
|
+
dstTexture = arguments[ 3 ];
|
|
31953
|
+
level = arguments[ 4 ] || 0;
|
|
31954
|
+
|
|
31955
|
+
}
|
|
31956
|
+
|
|
31957
|
+
let width, height, depth, minX, minY, minZ;
|
|
31958
|
+
let dstX, dstY, dstZ;
|
|
31959
|
+
const image = srcTexture.isCompressedTexture ? srcTexture.mipmaps[ level ] : srcTexture.image;
|
|
31960
|
+
if ( srcRegion !== null ) {
|
|
31961
|
+
|
|
31962
|
+
width = srcRegion.max.x - srcRegion.min.x;
|
|
31963
|
+
height = srcRegion.max.y - srcRegion.min.y;
|
|
31964
|
+
depth = srcRegion.max.z - srcRegion.min.z;
|
|
31965
|
+
minX = srcRegion.min.x;
|
|
31966
|
+
minY = srcRegion.min.y;
|
|
31967
|
+
minZ = srcRegion.min.z;
|
|
31968
|
+
|
|
31969
|
+
} else {
|
|
31970
|
+
|
|
31971
|
+
width = image.width;
|
|
31972
|
+
height = image.height;
|
|
31973
|
+
depth = image.depth;
|
|
31974
|
+
minX = 0;
|
|
31975
|
+
minY = 0;
|
|
31976
|
+
minZ = 0;
|
|
31977
|
+
|
|
31978
|
+
}
|
|
31979
|
+
|
|
31980
|
+
if ( dstPosition !== null ) {
|
|
31981
|
+
|
|
31982
|
+
dstX = dstPosition.x;
|
|
31983
|
+
dstY = dstPosition.y;
|
|
31984
|
+
dstZ = dstPosition.z;
|
|
31985
|
+
|
|
31986
|
+
} else {
|
|
31987
|
+
|
|
31988
|
+
dstX = 0;
|
|
31989
|
+
dstY = 0;
|
|
31990
|
+
dstZ = 0;
|
|
31991
|
+
|
|
31992
|
+
}
|
|
31507
31993
|
|
|
31508
|
-
const width = Math.round( sourceBox.max.x - sourceBox.min.x );
|
|
31509
|
-
const height = Math.round( sourceBox.max.y - sourceBox.min.y );
|
|
31510
|
-
const depth = sourceBox.max.z - sourceBox.min.z + 1;
|
|
31511
31994
|
const glFormat = utils.convert( dstTexture.format );
|
|
31512
31995
|
const glType = utils.convert( dstTexture.type );
|
|
31513
31996
|
let glTarget;
|
|
@@ -31533,43 +32016,41 @@ class WebGLRenderer {
|
|
|
31533
32016
|
_gl.pixelStorei( _gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, dstTexture.premultiplyAlpha );
|
|
31534
32017
|
_gl.pixelStorei( _gl.UNPACK_ALIGNMENT, dstTexture.unpackAlignment );
|
|
31535
32018
|
|
|
31536
|
-
const
|
|
31537
|
-
const
|
|
31538
|
-
const
|
|
31539
|
-
const
|
|
31540
|
-
const
|
|
31541
|
-
|
|
31542
|
-
const image = srcTexture.isCompressedTexture ? srcTexture.mipmaps[ level ] : srcTexture.image;
|
|
32019
|
+
const currentUnpackRowLen = _gl.getParameter( _gl.UNPACK_ROW_LENGTH );
|
|
32020
|
+
const currentUnpackImageHeight = _gl.getParameter( _gl.UNPACK_IMAGE_HEIGHT );
|
|
32021
|
+
const currentUnpackSkipPixels = _gl.getParameter( _gl.UNPACK_SKIP_PIXELS );
|
|
32022
|
+
const currentUnpackSkipRows = _gl.getParameter( _gl.UNPACK_SKIP_ROWS );
|
|
32023
|
+
const currentUnpackSkipImages = _gl.getParameter( _gl.UNPACK_SKIP_IMAGES );
|
|
31543
32024
|
|
|
31544
32025
|
_gl.pixelStorei( _gl.UNPACK_ROW_LENGTH, image.width );
|
|
31545
32026
|
_gl.pixelStorei( _gl.UNPACK_IMAGE_HEIGHT, image.height );
|
|
31546
|
-
_gl.pixelStorei( _gl.UNPACK_SKIP_PIXELS,
|
|
31547
|
-
_gl.pixelStorei( _gl.UNPACK_SKIP_ROWS,
|
|
31548
|
-
_gl.pixelStorei( _gl.UNPACK_SKIP_IMAGES,
|
|
32027
|
+
_gl.pixelStorei( _gl.UNPACK_SKIP_PIXELS, minX );
|
|
32028
|
+
_gl.pixelStorei( _gl.UNPACK_SKIP_ROWS, minY );
|
|
32029
|
+
_gl.pixelStorei( _gl.UNPACK_SKIP_IMAGES, minZ );
|
|
31549
32030
|
|
|
31550
32031
|
if ( srcTexture.isDataTexture || srcTexture.isData3DTexture ) {
|
|
31551
32032
|
|
|
31552
|
-
_gl.texSubImage3D( glTarget, level,
|
|
32033
|
+
_gl.texSubImage3D( glTarget, level, dstX, dstY, dstZ, width, height, depth, glFormat, glType, image.data );
|
|
31553
32034
|
|
|
31554
32035
|
} else {
|
|
31555
32036
|
|
|
31556
32037
|
if ( dstTexture.isCompressedArrayTexture ) {
|
|
31557
32038
|
|
|
31558
|
-
_gl.compressedTexSubImage3D( glTarget, level,
|
|
32039
|
+
_gl.compressedTexSubImage3D( glTarget, level, dstX, dstY, dstZ, width, height, depth, glFormat, image.data );
|
|
31559
32040
|
|
|
31560
32041
|
} else {
|
|
31561
32042
|
|
|
31562
|
-
_gl.texSubImage3D( glTarget, level,
|
|
32043
|
+
_gl.texSubImage3D( glTarget, level, dstX, dstY, dstZ, width, height, depth, glFormat, glType, image );
|
|
31563
32044
|
|
|
31564
32045
|
}
|
|
31565
32046
|
|
|
31566
32047
|
}
|
|
31567
32048
|
|
|
31568
|
-
_gl.pixelStorei( _gl.UNPACK_ROW_LENGTH,
|
|
31569
|
-
_gl.pixelStorei( _gl.UNPACK_IMAGE_HEIGHT,
|
|
31570
|
-
_gl.pixelStorei( _gl.UNPACK_SKIP_PIXELS,
|
|
31571
|
-
_gl.pixelStorei( _gl.UNPACK_SKIP_ROWS,
|
|
31572
|
-
_gl.pixelStorei( _gl.UNPACK_SKIP_IMAGES,
|
|
32049
|
+
_gl.pixelStorei( _gl.UNPACK_ROW_LENGTH, currentUnpackRowLen );
|
|
32050
|
+
_gl.pixelStorei( _gl.UNPACK_IMAGE_HEIGHT, currentUnpackImageHeight );
|
|
32051
|
+
_gl.pixelStorei( _gl.UNPACK_SKIP_PIXELS, currentUnpackSkipPixels );
|
|
32052
|
+
_gl.pixelStorei( _gl.UNPACK_SKIP_ROWS, currentUnpackSkipRows );
|
|
32053
|
+
_gl.pixelStorei( _gl.UNPACK_SKIP_IMAGES, currentUnpackSkipImages );
|
|
31573
32054
|
|
|
31574
32055
|
// Generate mipmaps only when copying level 0
|
|
31575
32056
|
if ( level === 0 && dstTexture.generateMipmaps ) _gl.generateMipmap( glTarget );
|
|
@@ -31578,6 +32059,16 @@ class WebGLRenderer {
|
|
|
31578
32059
|
|
|
31579
32060
|
};
|
|
31580
32061
|
|
|
32062
|
+
this.initRenderTarget = function ( target ) {
|
|
32063
|
+
|
|
32064
|
+
if ( properties.get( target ).__webglFramebuffer === undefined ) {
|
|
32065
|
+
|
|
32066
|
+
textures.setupRenderTarget( target );
|
|
32067
|
+
|
|
32068
|
+
}
|
|
32069
|
+
|
|
32070
|
+
};
|
|
32071
|
+
|
|
31581
32072
|
this.initTexture = function ( texture ) {
|
|
31582
32073
|
|
|
31583
32074
|
if ( texture.isCubeTexture ) {
|
|
@@ -31643,20 +32134,6 @@ class WebGLRenderer {
|
|
|
31643
32134
|
|
|
31644
32135
|
}
|
|
31645
32136
|
|
|
31646
|
-
get useLegacyLights() { // @deprecated, r155
|
|
31647
|
-
|
|
31648
|
-
console.warn( 'THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733.' );
|
|
31649
|
-
return this._useLegacyLights;
|
|
31650
|
-
|
|
31651
|
-
}
|
|
31652
|
-
|
|
31653
|
-
set useLegacyLights( value ) { // @deprecated, r155
|
|
31654
|
-
|
|
31655
|
-
console.warn( 'THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733.' );
|
|
31656
|
-
this._useLegacyLights = value;
|
|
31657
|
-
|
|
31658
|
-
}
|
|
31659
|
-
|
|
31660
32137
|
}
|
|
31661
32138
|
|
|
31662
32139
|
class FogExp2 {
|
|
@@ -33645,11 +34122,14 @@ const ID_ATTR_NAME = 'batchId';
|
|
|
33645
34122
|
const _matrix$1 = /*@__PURE__*/ new Matrix4();
|
|
33646
34123
|
const _invMatrixWorld = /*@__PURE__*/ new Matrix4();
|
|
33647
34124
|
const _identityMatrix = /*@__PURE__*/ new Matrix4();
|
|
34125
|
+
const _whiteColor = /*@__PURE__*/ new Color( 1, 1, 1 );
|
|
33648
34126
|
const _projScreenMatrix$2 = /*@__PURE__*/ new Matrix4();
|
|
33649
34127
|
const _frustum = /*@__PURE__*/ new Frustum();
|
|
33650
34128
|
const _box$1 = /*@__PURE__*/ new Box3();
|
|
33651
34129
|
const _sphere$2 = /*@__PURE__*/ new Sphere();
|
|
33652
34130
|
const _vector$5 = /*@__PURE__*/ new Vector3();
|
|
34131
|
+
const _forward = /*@__PURE__*/ new Vector3();
|
|
34132
|
+
const _temp = /*@__PURE__*/ new Vector3();
|
|
33653
34133
|
const _renderList = /*@__PURE__*/ new MultiDrawRenderList();
|
|
33654
34134
|
const _mesh = /*@__PURE__*/ new Mesh();
|
|
33655
34135
|
const _batchIntersects = [];
|
|
@@ -33726,6 +34206,7 @@ class BatchedMesh extends Mesh {
|
|
|
33726
34206
|
this._multiDrawCounts = new Int32Array( maxGeometryCount );
|
|
33727
34207
|
this._multiDrawStarts = new Int32Array( maxGeometryCount );
|
|
33728
34208
|
this._multiDrawCount = 0;
|
|
34209
|
+
this._multiDrawInstances = null;
|
|
33729
34210
|
this._visibilityChanged = true;
|
|
33730
34211
|
|
|
33731
34212
|
// Local matrix per geometry by using data texture
|
|
@@ -33733,6 +34214,9 @@ class BatchedMesh extends Mesh {
|
|
|
33733
34214
|
|
|
33734
34215
|
this._initMatricesTexture();
|
|
33735
34216
|
|
|
34217
|
+
// Local color per geometry by using data texture
|
|
34218
|
+
this._colorsTexture = null;
|
|
34219
|
+
|
|
33736
34220
|
}
|
|
33737
34221
|
|
|
33738
34222
|
_initMatricesTexture() {
|
|
@@ -33755,6 +34239,20 @@ class BatchedMesh extends Mesh {
|
|
|
33755
34239
|
|
|
33756
34240
|
}
|
|
33757
34241
|
|
|
34242
|
+
_initColorsTexture() {
|
|
34243
|
+
|
|
34244
|
+
let size = Math.sqrt( this._maxGeometryCount );
|
|
34245
|
+
size = Math.ceil( size );
|
|
34246
|
+
|
|
34247
|
+
// 4 floats per RGBA pixel initialized to white
|
|
34248
|
+
const colorsArray = new Float32Array( size * size * 4 ).fill( 1 );
|
|
34249
|
+
const colorsTexture = new DataTexture( colorsArray, size, size, RGBAFormat, FloatType );
|
|
34250
|
+
colorsTexture.colorSpace = ColorManagement.workingColorSpace;
|
|
34251
|
+
|
|
34252
|
+
this._colorsTexture = colorsTexture;
|
|
34253
|
+
|
|
34254
|
+
}
|
|
34255
|
+
|
|
33758
34256
|
_initializeGeometry( reference ) {
|
|
33759
34257
|
|
|
33760
34258
|
const geometry = this.geometry;
|
|
@@ -33988,6 +34486,7 @@ class BatchedMesh extends Mesh {
|
|
|
33988
34486
|
const active = this._active;
|
|
33989
34487
|
const matricesTexture = this._matricesTexture;
|
|
33990
34488
|
const matricesArray = this._matricesTexture.image.data;
|
|
34489
|
+
const colorsTexture = this._colorsTexture;
|
|
33991
34490
|
|
|
33992
34491
|
// push new visibility states
|
|
33993
34492
|
visibility.push( true );
|
|
@@ -34001,6 +34500,14 @@ class BatchedMesh extends Mesh {
|
|
|
34001
34500
|
_identityMatrix.toArray( matricesArray, geometryId * 16 );
|
|
34002
34501
|
matricesTexture.needsUpdate = true;
|
|
34003
34502
|
|
|
34503
|
+
// initialize the color to white
|
|
34504
|
+
if ( colorsTexture !== null ) {
|
|
34505
|
+
|
|
34506
|
+
_whiteColor.toArray( colorsTexture.image.data, geometryId * 4 );
|
|
34507
|
+
colorsTexture.needsUpdate = true;
|
|
34508
|
+
|
|
34509
|
+
}
|
|
34510
|
+
|
|
34004
34511
|
// add the reserved range and draw range objects
|
|
34005
34512
|
reservedRanges.push( reservedRange );
|
|
34006
34513
|
drawRanges.push( {
|
|
@@ -34167,6 +34674,28 @@ class BatchedMesh extends Mesh {
|
|
|
34167
34674
|
|
|
34168
34675
|
}
|
|
34169
34676
|
|
|
34677
|
+
getInstanceCountAt( id ) {
|
|
34678
|
+
|
|
34679
|
+
if ( this._multiDrawInstances === null ) return null;
|
|
34680
|
+
|
|
34681
|
+
return this._multiDrawInstances[ id ];
|
|
34682
|
+
|
|
34683
|
+
}
|
|
34684
|
+
|
|
34685
|
+
setInstanceCountAt( id, instanceCount ) {
|
|
34686
|
+
|
|
34687
|
+
if ( this._multiDrawInstances === null ) {
|
|
34688
|
+
|
|
34689
|
+
this._multiDrawInstances = new Int32Array( this._maxGeometryCount ).fill( 1 );
|
|
34690
|
+
|
|
34691
|
+
}
|
|
34692
|
+
|
|
34693
|
+
this._multiDrawInstances[ id ] = instanceCount;
|
|
34694
|
+
|
|
34695
|
+
return id;
|
|
34696
|
+
|
|
34697
|
+
}
|
|
34698
|
+
|
|
34170
34699
|
// get bounding box and compute it if it doesn't exist
|
|
34171
34700
|
getBoundingBoxAt( id, target ) {
|
|
34172
34701
|
|
|
@@ -34297,6 +34826,49 @@ class BatchedMesh extends Mesh {
|
|
|
34297
34826
|
|
|
34298
34827
|
}
|
|
34299
34828
|
|
|
34829
|
+
setColorAt( geometryId, color ) {
|
|
34830
|
+
|
|
34831
|
+
if ( this._colorsTexture === null ) {
|
|
34832
|
+
|
|
34833
|
+
this._initColorsTexture();
|
|
34834
|
+
|
|
34835
|
+
}
|
|
34836
|
+
|
|
34837
|
+
// @TODO: Map geometryId to index of the arrays because
|
|
34838
|
+
// optimize() can make geometryId mismatch the index
|
|
34839
|
+
|
|
34840
|
+
const active = this._active;
|
|
34841
|
+
const colorsTexture = this._colorsTexture;
|
|
34842
|
+
const colorsArray = this._colorsTexture.image.data;
|
|
34843
|
+
const geometryCount = this._geometryCount;
|
|
34844
|
+
if ( geometryId >= geometryCount || active[ geometryId ] === false ) {
|
|
34845
|
+
|
|
34846
|
+
return this;
|
|
34847
|
+
|
|
34848
|
+
}
|
|
34849
|
+
|
|
34850
|
+
color.toArray( colorsArray, geometryId * 4 );
|
|
34851
|
+
colorsTexture.needsUpdate = true;
|
|
34852
|
+
|
|
34853
|
+
return this;
|
|
34854
|
+
|
|
34855
|
+
}
|
|
34856
|
+
|
|
34857
|
+
getColorAt( geometryId, color ) {
|
|
34858
|
+
|
|
34859
|
+
const active = this._active;
|
|
34860
|
+
const colorsArray = this._colorsTexture.image.data;
|
|
34861
|
+
const geometryCount = this._geometryCount;
|
|
34862
|
+
if ( geometryId >= geometryCount || active[ geometryId ] === false ) {
|
|
34863
|
+
|
|
34864
|
+
return null;
|
|
34865
|
+
|
|
34866
|
+
}
|
|
34867
|
+
|
|
34868
|
+
return color.fromArray( colorsArray, geometryId * 4 );
|
|
34869
|
+
|
|
34870
|
+
}
|
|
34871
|
+
|
|
34300
34872
|
setVisibleAt( geometryId, value ) {
|
|
34301
34873
|
|
|
34302
34874
|
const visibility = this._visibility;
|
|
@@ -34437,6 +35009,13 @@ class BatchedMesh extends Mesh {
|
|
|
34437
35009
|
this._matricesTexture = source._matricesTexture.clone();
|
|
34438
35010
|
this._matricesTexture.image.data = this._matricesTexture.image.slice();
|
|
34439
35011
|
|
|
35012
|
+
if ( this._colorsTexture !== null ) {
|
|
35013
|
+
|
|
35014
|
+
this._colorsTexture = source._colorsTexture.clone();
|
|
35015
|
+
this._colorsTexture.image.data = this._colorsTexture.image.slice();
|
|
35016
|
+
|
|
35017
|
+
}
|
|
35018
|
+
|
|
34440
35019
|
return this;
|
|
34441
35020
|
|
|
34442
35021
|
}
|
|
@@ -34448,6 +35027,14 @@ class BatchedMesh extends Mesh {
|
|
|
34448
35027
|
|
|
34449
35028
|
this._matricesTexture.dispose();
|
|
34450
35029
|
this._matricesTexture = null;
|
|
35030
|
+
|
|
35031
|
+
if ( this._colorsTexture !== null ) {
|
|
35032
|
+
|
|
35033
|
+
this._colorsTexture.dispose();
|
|
35034
|
+
this._colorsTexture = null;
|
|
35035
|
+
|
|
35036
|
+
}
|
|
35037
|
+
|
|
34451
35038
|
return this;
|
|
34452
35039
|
|
|
34453
35040
|
}
|
|
@@ -34493,6 +35080,7 @@ class BatchedMesh extends Mesh {
|
|
|
34493
35080
|
// get the camera position in the local frame
|
|
34494
35081
|
_invMatrixWorld.copy( this.matrixWorld ).invert();
|
|
34495
35082
|
_vector$5.setFromMatrixPosition( camera.matrixWorld ).applyMatrix4( _invMatrixWorld );
|
|
35083
|
+
_forward.set( 0, 0, - 1 ).transformDirection( camera.matrixWorld ).transformDirection( _invMatrixWorld );
|
|
34496
35084
|
|
|
34497
35085
|
for ( let i = 0, l = visibility.length; i < l; i ++ ) {
|
|
34498
35086
|
|
|
@@ -34513,7 +35101,7 @@ class BatchedMesh extends Mesh {
|
|
|
34513
35101
|
if ( ! culled ) {
|
|
34514
35102
|
|
|
34515
35103
|
// get the distance from camera used for sorting
|
|
34516
|
-
const z =
|
|
35104
|
+
const z = _temp.subVectors( _sphere$2.center, _vector$5 ).dot( _forward );
|
|
34517
35105
|
_renderList.push( drawRanges[ i ], z );
|
|
34518
35106
|
|
|
34519
35107
|
}
|
|
@@ -34636,12 +35224,16 @@ class LineBasicMaterial extends Material {
|
|
|
34636
35224
|
|
|
34637
35225
|
}
|
|
34638
35226
|
|
|
34639
|
-
const
|
|
34640
|
-
const
|
|
35227
|
+
const _vStart = /*@__PURE__*/ new Vector3();
|
|
35228
|
+
const _vEnd = /*@__PURE__*/ new Vector3();
|
|
35229
|
+
|
|
34641
35230
|
const _inverseMatrix$1 = /*@__PURE__*/ new Matrix4();
|
|
34642
35231
|
const _ray$1 = /*@__PURE__*/ new Ray();
|
|
34643
35232
|
const _sphere$1 = /*@__PURE__*/ new Sphere();
|
|
34644
35233
|
|
|
35234
|
+
const _intersectPointOnRay = /*@__PURE__*/ new Vector3();
|
|
35235
|
+
const _intersectPointOnSegment = /*@__PURE__*/ new Vector3();
|
|
35236
|
+
|
|
34645
35237
|
class Line extends Object3D {
|
|
34646
35238
|
|
|
34647
35239
|
constructor( geometry = new BufferGeometry(), material = new LineBasicMaterial() ) {
|
|
@@ -34683,11 +35275,11 @@ class Line extends Object3D {
|
|
|
34683
35275
|
|
|
34684
35276
|
for ( let i = 1, l = positionAttribute.count; i < l; i ++ ) {
|
|
34685
35277
|
|
|
34686
|
-
|
|
34687
|
-
|
|
35278
|
+
_vStart.fromBufferAttribute( positionAttribute, i - 1 );
|
|
35279
|
+
_vEnd.fromBufferAttribute( positionAttribute, i );
|
|
34688
35280
|
|
|
34689
35281
|
lineDistances[ i ] = lineDistances[ i - 1 ];
|
|
34690
|
-
lineDistances[ i ] +=
|
|
35282
|
+
lineDistances[ i ] += _vStart.distanceTo( _vEnd );
|
|
34691
35283
|
|
|
34692
35284
|
}
|
|
34693
35285
|
|
|
@@ -34728,10 +35320,6 @@ class Line extends Object3D {
|
|
|
34728
35320
|
const localThreshold = threshold / ( ( this.scale.x + this.scale.y + this.scale.z ) / 3 );
|
|
34729
35321
|
const localThresholdSq = localThreshold * localThreshold;
|
|
34730
35322
|
|
|
34731
|
-
const vStart = new Vector3();
|
|
34732
|
-
const vEnd = new Vector3();
|
|
34733
|
-
const interSegment = new Vector3();
|
|
34734
|
-
const interRay = new Vector3();
|
|
34735
35323
|
const step = this.isLineSegments ? 2 : 1;
|
|
34736
35324
|
|
|
34737
35325
|
const index = geometry.index;
|
|
@@ -34748,31 +35336,28 @@ class Line extends Object3D {
|
|
|
34748
35336
|
const a = index.getX( i );
|
|
34749
35337
|
const b = index.getX( i + 1 );
|
|
34750
35338
|
|
|
34751
|
-
|
|
34752
|
-
|
|
35339
|
+
const intersect = checkIntersection( this, raycaster, _ray$1, localThresholdSq, a, b );
|
|
35340
|
+
|
|
35341
|
+
if ( intersect ) {
|
|
34753
35342
|
|
|
34754
|
-
|
|
35343
|
+
intersects.push( intersect );
|
|
34755
35344
|
|
|
34756
|
-
|
|
35345
|
+
}
|
|
34757
35346
|
|
|
34758
|
-
|
|
35347
|
+
}
|
|
34759
35348
|
|
|
34760
|
-
|
|
35349
|
+
if ( this.isLineLoop ) {
|
|
34761
35350
|
|
|
34762
|
-
|
|
35351
|
+
const a = index.getX( end - 1 );
|
|
35352
|
+
const b = index.getX( start );
|
|
34763
35353
|
|
|
34764
|
-
|
|
35354
|
+
const intersect = checkIntersection( this, raycaster, _ray$1, localThresholdSq, a, b );
|
|
34765
35355
|
|
|
34766
|
-
|
|
34767
|
-
// What do we want? intersection point on the ray or on the segment??
|
|
34768
|
-
// point: raycaster.ray.at( distance ),
|
|
34769
|
-
point: interSegment.clone().applyMatrix4( this.matrixWorld ),
|
|
34770
|
-
index: i,
|
|
34771
|
-
face: null,
|
|
34772
|
-
faceIndex: null,
|
|
34773
|
-
object: this
|
|
35356
|
+
if ( intersect ) {
|
|
34774
35357
|
|
|
34775
|
-
|
|
35358
|
+
intersects.push( intersect );
|
|
35359
|
+
|
|
35360
|
+
}
|
|
34776
35361
|
|
|
34777
35362
|
}
|
|
34778
35363
|
|
|
@@ -34783,31 +35368,25 @@ class Line extends Object3D {
|
|
|
34783
35368
|
|
|
34784
35369
|
for ( let i = start, l = end - 1; i < l; i += step ) {
|
|
34785
35370
|
|
|
34786
|
-
|
|
34787
|
-
vEnd.fromBufferAttribute( positionAttribute, i + 1 );
|
|
35371
|
+
const intersect = checkIntersection( this, raycaster, _ray$1, localThresholdSq, i, i + 1 );
|
|
34788
35372
|
|
|
34789
|
-
|
|
35373
|
+
if ( intersect ) {
|
|
34790
35374
|
|
|
34791
|
-
|
|
35375
|
+
intersects.push( intersect );
|
|
34792
35376
|
|
|
34793
|
-
|
|
35377
|
+
}
|
|
34794
35378
|
|
|
34795
|
-
|
|
35379
|
+
}
|
|
34796
35380
|
|
|
34797
|
-
|
|
35381
|
+
if ( this.isLineLoop ) {
|
|
34798
35382
|
|
|
34799
|
-
|
|
35383
|
+
const intersect = checkIntersection( this, raycaster, _ray$1, localThresholdSq, end - 1, start );
|
|
34800
35384
|
|
|
34801
|
-
|
|
34802
|
-
// What do we want? intersection point on the ray or on the segment??
|
|
34803
|
-
// point: raycaster.ray.at( distance ),
|
|
34804
|
-
point: interSegment.clone().applyMatrix4( this.matrixWorld ),
|
|
34805
|
-
index: i,
|
|
34806
|
-
face: null,
|
|
34807
|
-
faceIndex: null,
|
|
34808
|
-
object: this
|
|
35385
|
+
if ( intersect ) {
|
|
34809
35386
|
|
|
34810
|
-
|
|
35387
|
+
intersects.push( intersect );
|
|
35388
|
+
|
|
35389
|
+
}
|
|
34811
35390
|
|
|
34812
35391
|
}
|
|
34813
35392
|
|
|
@@ -34848,6 +35427,38 @@ class Line extends Object3D {
|
|
|
34848
35427
|
|
|
34849
35428
|
}
|
|
34850
35429
|
|
|
35430
|
+
function checkIntersection( object, raycaster, ray, thresholdSq, a, b ) {
|
|
35431
|
+
|
|
35432
|
+
const positionAttribute = object.geometry.attributes.position;
|
|
35433
|
+
|
|
35434
|
+
_vStart.fromBufferAttribute( positionAttribute, a );
|
|
35435
|
+
_vEnd.fromBufferAttribute( positionAttribute, b );
|
|
35436
|
+
|
|
35437
|
+
const distSq = ray.distanceSqToSegment( _vStart, _vEnd, _intersectPointOnRay, _intersectPointOnSegment );
|
|
35438
|
+
|
|
35439
|
+
if ( distSq > thresholdSq ) return;
|
|
35440
|
+
|
|
35441
|
+
_intersectPointOnRay.applyMatrix4( object.matrixWorld ); // Move back to world space for distance calculation
|
|
35442
|
+
|
|
35443
|
+
const distance = raycaster.ray.origin.distanceTo( _intersectPointOnRay );
|
|
35444
|
+
|
|
35445
|
+
if ( distance < raycaster.near || distance > raycaster.far ) return;
|
|
35446
|
+
|
|
35447
|
+
return {
|
|
35448
|
+
|
|
35449
|
+
distance: distance,
|
|
35450
|
+
// What do we want? intersection point on the ray or on the segment??
|
|
35451
|
+
// point: raycaster.ray.at( distance ),
|
|
35452
|
+
point: _intersectPointOnSegment.clone().applyMatrix4( object.matrixWorld ),
|
|
35453
|
+
index: a,
|
|
35454
|
+
face: null,
|
|
35455
|
+
faceIndex: null,
|
|
35456
|
+
object: object
|
|
35457
|
+
|
|
35458
|
+
};
|
|
35459
|
+
|
|
35460
|
+
}
|
|
35461
|
+
|
|
34851
35462
|
const _start = /*@__PURE__*/ new Vector3();
|
|
34852
35463
|
const _end = /*@__PURE__*/ new Vector3();
|
|
34853
35464
|
|
|
@@ -35220,6 +35831,20 @@ class CompressedArrayTexture extends CompressedTexture {
|
|
|
35220
35831
|
this.image.depth = depth;
|
|
35221
35832
|
this.wrapR = ClampToEdgeWrapping;
|
|
35222
35833
|
|
|
35834
|
+
this.layerUpdates = new Set();
|
|
35835
|
+
|
|
35836
|
+
}
|
|
35837
|
+
|
|
35838
|
+
addLayerUpdates( layerIndex ) {
|
|
35839
|
+
|
|
35840
|
+
this.layerUpdates.add( layerIndex );
|
|
35841
|
+
|
|
35842
|
+
}
|
|
35843
|
+
|
|
35844
|
+
clearLayerUpdates() {
|
|
35845
|
+
|
|
35846
|
+
this.layerUpdates.clear();
|
|
35847
|
+
|
|
35223
35848
|
}
|
|
35224
35849
|
|
|
35225
35850
|
}
|
|
@@ -41485,6 +42110,7 @@ class MeshPhysicalMaterial extends MeshStandardMaterial {
|
|
|
41485
42110
|
|
|
41486
42111
|
this._anisotropy = 0;
|
|
41487
42112
|
this._clearcoat = 0;
|
|
42113
|
+
this._dispersion = 0;
|
|
41488
42114
|
this._iridescence = 0;
|
|
41489
42115
|
this._sheen = 0.0;
|
|
41490
42116
|
this._transmission = 0;
|
|
@@ -41547,6 +42173,24 @@ class MeshPhysicalMaterial extends MeshStandardMaterial {
|
|
|
41547
42173
|
|
|
41548
42174
|
}
|
|
41549
42175
|
|
|
42176
|
+
get dispersion() {
|
|
42177
|
+
|
|
42178
|
+
return this._dispersion;
|
|
42179
|
+
|
|
42180
|
+
}
|
|
42181
|
+
|
|
42182
|
+
set dispersion( value ) {
|
|
42183
|
+
|
|
42184
|
+
if ( this._dispersion > 0 !== value > 0 ) {
|
|
42185
|
+
|
|
42186
|
+
this.version ++;
|
|
42187
|
+
|
|
42188
|
+
}
|
|
42189
|
+
|
|
42190
|
+
this._dispersion = value;
|
|
42191
|
+
|
|
42192
|
+
}
|
|
42193
|
+
|
|
41550
42194
|
get sheen() {
|
|
41551
42195
|
|
|
41552
42196
|
return this._sheen;
|
|
@@ -41605,6 +42249,7 @@ class MeshPhysicalMaterial extends MeshStandardMaterial {
|
|
|
41605
42249
|
this.clearcoatNormalMap = source.clearcoatNormalMap;
|
|
41606
42250
|
this.clearcoatNormalScale.copy( source.clearcoatNormalScale );
|
|
41607
42251
|
|
|
42252
|
+
this.dispersion = source.dispersion;
|
|
41608
42253
|
this.ior = source.ior;
|
|
41609
42254
|
|
|
41610
42255
|
this.iridescence = source.iridescence;
|
|
@@ -43364,7 +44009,16 @@ KeyframeTrack.prototype.DefaultInterpolation = InterpolateLinear;
|
|
|
43364
44009
|
/**
|
|
43365
44010
|
* A Track of Boolean keyframe values.
|
|
43366
44011
|
*/
|
|
43367
|
-
class BooleanKeyframeTrack extends KeyframeTrack {
|
|
44012
|
+
class BooleanKeyframeTrack extends KeyframeTrack {
|
|
44013
|
+
|
|
44014
|
+
// No interpolation parameter because only InterpolateDiscrete is valid.
|
|
44015
|
+
constructor( name, times, values ) {
|
|
44016
|
+
|
|
44017
|
+
super( name, times, values );
|
|
44018
|
+
|
|
44019
|
+
}
|
|
44020
|
+
|
|
44021
|
+
}
|
|
43368
44022
|
|
|
43369
44023
|
BooleanKeyframeTrack.prototype.ValueTypeName = 'bool';
|
|
43370
44024
|
BooleanKeyframeTrack.prototype.ValueBufferType = Array;
|
|
@@ -43435,13 +44089,22 @@ class QuaternionKeyframeTrack extends KeyframeTrack {
|
|
|
43435
44089
|
|
|
43436
44090
|
QuaternionKeyframeTrack.prototype.ValueTypeName = 'quaternion';
|
|
43437
44091
|
// ValueBufferType is inherited
|
|
43438
|
-
|
|
44092
|
+
// DefaultInterpolation is inherited;
|
|
43439
44093
|
QuaternionKeyframeTrack.prototype.InterpolantFactoryMethodSmooth = undefined;
|
|
43440
44094
|
|
|
43441
44095
|
/**
|
|
43442
44096
|
* A Track that interpolates Strings
|
|
43443
44097
|
*/
|
|
43444
|
-
class StringKeyframeTrack extends KeyframeTrack {
|
|
44098
|
+
class StringKeyframeTrack extends KeyframeTrack {
|
|
44099
|
+
|
|
44100
|
+
// No interpolation parameter because only InterpolateDiscrete is valid.
|
|
44101
|
+
constructor( name, times, values ) {
|
|
44102
|
+
|
|
44103
|
+
super( name, times, values );
|
|
44104
|
+
|
|
44105
|
+
}
|
|
44106
|
+
|
|
44107
|
+
}
|
|
43445
44108
|
|
|
43446
44109
|
StringKeyframeTrack.prototype.ValueTypeName = 'string';
|
|
43447
44110
|
StringKeyframeTrack.prototype.ValueBufferType = Array;
|
|
@@ -44278,7 +44941,7 @@ class FileLoader extends Loader {
|
|
|
44278
44941
|
|
|
44279
44942
|
// Nginx needs X-File-Size check
|
|
44280
44943
|
// https://serverfault.com/questions/482875/why-does-nginx-remove-content-length-header-for-chunked-content
|
|
44281
|
-
const contentLength = response.headers.get( '
|
|
44944
|
+
const contentLength = response.headers.get( 'X-File-Size' ) || response.headers.get( 'Content-Length' );
|
|
44282
44945
|
const total = contentLength ? parseInt( contentLength ) : 0;
|
|
44283
44946
|
const lengthComputable = total !== 0;
|
|
44284
44947
|
let loaded = 0;
|
|
@@ -44314,6 +44977,10 @@ class FileLoader extends Loader {
|
|
|
44314
44977
|
|
|
44315
44978
|
}
|
|
44316
44979
|
|
|
44980
|
+
}, ( e ) => {
|
|
44981
|
+
|
|
44982
|
+
controller.error( e );
|
|
44983
|
+
|
|
44317
44984
|
} );
|
|
44318
44985
|
|
|
44319
44986
|
}
|
|
@@ -45879,6 +46546,7 @@ class MaterialLoader extends Loader {
|
|
|
45879
46546
|
if ( json.shininess !== undefined ) material.shininess = json.shininess;
|
|
45880
46547
|
if ( json.clearcoat !== undefined ) material.clearcoat = json.clearcoat;
|
|
45881
46548
|
if ( json.clearcoatRoughness !== undefined ) material.clearcoatRoughness = json.clearcoatRoughness;
|
|
46549
|
+
if ( json.dispersion !== undefined ) material.dispersion = json.dispersion;
|
|
45882
46550
|
if ( json.iridescence !== undefined ) material.iridescence = json.iridescence;
|
|
45883
46551
|
if ( json.iridescenceIOR !== undefined ) material.iridescenceIOR = json.iridescenceIOR;
|
|
45884
46552
|
if ( json.iridescenceThicknessRange !== undefined ) material.iridescenceThicknessRange = json.iridescenceThicknessRange;
|
|
@@ -46148,7 +46816,9 @@ class MaterialLoader extends Loader {
|
|
|
46148
46816
|
|
|
46149
46817
|
class LoaderUtils {
|
|
46150
46818
|
|
|
46151
|
-
static decodeText( array ) {
|
|
46819
|
+
static decodeText( array ) { // @deprecated, r165
|
|
46820
|
+
|
|
46821
|
+
console.warn( 'THREE.LoaderUtils: decodeText() has been deprecated with r165 and will be removed with r175. Use TextDecoder instead.' );
|
|
46152
46822
|
|
|
46153
46823
|
if ( typeof TextDecoder !== 'undefined' ) {
|
|
46154
46824
|
|
|
@@ -47359,6 +48029,7 @@ class ObjectLoader extends Loader {
|
|
|
47359
48029
|
object._geometryCount = data.geometryCount;
|
|
47360
48030
|
|
|
47361
48031
|
object._matricesTexture = getTexture( data.matricesTexture.uuid );
|
|
48032
|
+
if ( data.colorsTexture !== undefined ) object._colorsTexture = getTexture( data.colorsTexture.uuid );
|
|
47362
48033
|
|
|
47363
48034
|
break;
|
|
47364
48035
|
|
|
@@ -51821,13 +52492,17 @@ function ascSort( a, b ) {
|
|
|
51821
52492
|
|
|
51822
52493
|
function intersect( object, raycaster, intersects, recursive ) {
|
|
51823
52494
|
|
|
52495
|
+
let propagate = true;
|
|
52496
|
+
|
|
51824
52497
|
if ( object.layers.test( raycaster.layers ) ) {
|
|
51825
52498
|
|
|
51826
|
-
object.raycast( raycaster, intersects );
|
|
52499
|
+
const result = object.raycast( raycaster, intersects );
|
|
52500
|
+
|
|
52501
|
+
if ( result === false ) propagate = false;
|
|
51827
52502
|
|
|
51828
52503
|
}
|
|
51829
52504
|
|
|
51830
|
-
if ( recursive === true ) {
|
|
52505
|
+
if ( propagate === true && recursive === true ) {
|
|
51831
52506
|
|
|
51832
52507
|
const children = object.children;
|
|
51833
52508
|
|