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.cjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright 2010-
|
|
3
|
+
* Copyright 2010-2024 Three.js Authors
|
|
4
4
|
* SPDX-License-Identifier: MIT
|
|
5
5
|
*/
|
|
6
6
|
'use strict';
|
|
7
7
|
|
|
8
|
-
const REVISION = '
|
|
8
|
+
const REVISION = '165';
|
|
9
9
|
|
|
10
10
|
const MOUSE = { LEFT: 0, MIDDLE: 1, RIGHT: 2, ROTATE: 0, DOLLY: 1, PAN: 2 };
|
|
11
11
|
const TOUCH = { ROTATE: 0, PAN: 1, DOLLY_PAN: 2, DOLLY_ROTATE: 3 };
|
|
@@ -1562,6 +1562,35 @@ function warnOnce( message ) {
|
|
|
1562
1562
|
|
|
1563
1563
|
}
|
|
1564
1564
|
|
|
1565
|
+
function probeAsync( gl, sync, interval ) {
|
|
1566
|
+
|
|
1567
|
+
return new Promise( function ( resolve, reject ) {
|
|
1568
|
+
|
|
1569
|
+
function probe() {
|
|
1570
|
+
|
|
1571
|
+
switch ( gl.clientWaitSync( sync, gl.SYNC_FLUSH_COMMANDS_BIT, 0 ) ) {
|
|
1572
|
+
|
|
1573
|
+
case gl.WAIT_FAILED:
|
|
1574
|
+
reject();
|
|
1575
|
+
break;
|
|
1576
|
+
|
|
1577
|
+
case gl.TIMEOUT_EXPIRED:
|
|
1578
|
+
setTimeout( probe, interval );
|
|
1579
|
+
break;
|
|
1580
|
+
|
|
1581
|
+
default:
|
|
1582
|
+
resolve();
|
|
1583
|
+
|
|
1584
|
+
}
|
|
1585
|
+
|
|
1586
|
+
}
|
|
1587
|
+
|
|
1588
|
+
setTimeout( probe, interval );
|
|
1589
|
+
|
|
1590
|
+
} );
|
|
1591
|
+
|
|
1592
|
+
}
|
|
1593
|
+
|
|
1565
1594
|
/**
|
|
1566
1595
|
* Matrices converting P3 <-> Rec. 709 primaries, without gamut mapping
|
|
1567
1596
|
* or clipping. Based on W3C specifications for sRGB and Display P3,
|
|
@@ -2923,6 +2952,8 @@ class RenderTarget extends EventDispatcher {
|
|
|
2923
2952
|
minFilter: LinearFilter,
|
|
2924
2953
|
depthBuffer: true,
|
|
2925
2954
|
stencilBuffer: false,
|
|
2955
|
+
resolveDepthBuffer: true,
|
|
2956
|
+
resolveStencilBuffer: true,
|
|
2926
2957
|
depthTexture: null,
|
|
2927
2958
|
samples: 0,
|
|
2928
2959
|
count: 1
|
|
@@ -2947,6 +2978,9 @@ class RenderTarget extends EventDispatcher {
|
|
|
2947
2978
|
this.depthBuffer = options.depthBuffer;
|
|
2948
2979
|
this.stencilBuffer = options.stencilBuffer;
|
|
2949
2980
|
|
|
2981
|
+
this.resolveDepthBuffer = options.resolveDepthBuffer;
|
|
2982
|
+
this.resolveStencilBuffer = options.resolveStencilBuffer;
|
|
2983
|
+
|
|
2950
2984
|
this.depthTexture = options.depthTexture;
|
|
2951
2985
|
|
|
2952
2986
|
this.samples = options.samples;
|
|
@@ -3024,6 +3058,9 @@ class RenderTarget extends EventDispatcher {
|
|
|
3024
3058
|
this.depthBuffer = source.depthBuffer;
|
|
3025
3059
|
this.stencilBuffer = source.stencilBuffer;
|
|
3026
3060
|
|
|
3061
|
+
this.resolveDepthBuffer = source.resolveDepthBuffer;
|
|
3062
|
+
this.resolveStencilBuffer = source.resolveStencilBuffer;
|
|
3063
|
+
|
|
3027
3064
|
if ( source.depthTexture !== null ) this.depthTexture = source.depthTexture.clone();
|
|
3028
3065
|
|
|
3029
3066
|
this.samples = source.samples;
|
|
@@ -3071,6 +3108,20 @@ class DataArrayTexture extends Texture {
|
|
|
3071
3108
|
this.flipY = false;
|
|
3072
3109
|
this.unpackAlignment = 1;
|
|
3073
3110
|
|
|
3111
|
+
this.layerUpdates = new Set();
|
|
3112
|
+
|
|
3113
|
+
}
|
|
3114
|
+
|
|
3115
|
+
addLayerUpdate( layerIndex ) {
|
|
3116
|
+
|
|
3117
|
+
this.layerUpdates.add( layerIndex );
|
|
3118
|
+
|
|
3119
|
+
}
|
|
3120
|
+
|
|
3121
|
+
clearLayerUpdates() {
|
|
3122
|
+
|
|
3123
|
+
this.layerUpdates.clear();
|
|
3124
|
+
|
|
3074
3125
|
}
|
|
3075
3126
|
|
|
3076
3127
|
}
|
|
@@ -7840,6 +7891,8 @@ class Object3D extends EventDispatcher {
|
|
|
7840
7891
|
|
|
7841
7892
|
object.matricesTexture = this._matricesTexture.toJSON( meta );
|
|
7842
7893
|
|
|
7894
|
+
if ( this._colorsTexture !== null ) object.colorsTexture = this._colorsTexture.toJSON( meta );
|
|
7895
|
+
|
|
7843
7896
|
if ( this.boundingSphere !== null ) {
|
|
7844
7897
|
|
|
7845
7898
|
object.boundingSphere = {
|
|
@@ -9239,6 +9292,8 @@ class Material extends EventDispatcher {
|
|
|
9239
9292
|
|
|
9240
9293
|
}
|
|
9241
9294
|
|
|
9295
|
+
if ( this.dispersion !== undefined ) data.dispersion = this.dispersion;
|
|
9296
|
+
|
|
9242
9297
|
if ( this.iridescence !== undefined ) data.iridescence = this.iridescence;
|
|
9243
9298
|
if ( this.iridescenceIOR !== undefined ) data.iridescenceIOR = this.iridescenceIOR;
|
|
9244
9299
|
if ( this.iridescenceThicknessRange !== undefined ) data.iridescenceThicknessRange = this.iridescenceThicknessRange;
|
|
@@ -11787,7 +11842,7 @@ class Mesh extends Object3D {
|
|
|
11787
11842
|
|
|
11788
11843
|
}
|
|
11789
11844
|
|
|
11790
|
-
function checkIntersection( object, material, raycaster, ray, pA, pB, pC, point ) {
|
|
11845
|
+
function checkIntersection$1( object, material, raycaster, ray, pA, pB, pC, point ) {
|
|
11791
11846
|
|
|
11792
11847
|
let intersect;
|
|
11793
11848
|
|
|
@@ -11824,7 +11879,7 @@ function checkGeometryIntersection( object, material, raycaster, ray, uv, uv1, n
|
|
|
11824
11879
|
object.getVertexPosition( b, _vB$1 );
|
|
11825
11880
|
object.getVertexPosition( c, _vC$1 );
|
|
11826
11881
|
|
|
11827
|
-
const intersection = checkIntersection( object, material, raycaster, ray, _vA$1, _vB$1, _vC$1, _intersectionPoint );
|
|
11882
|
+
const intersection = checkIntersection$1( object, material, raycaster, ray, _vA$1, _vB$1, _vC$1, _intersectionPoint );
|
|
11828
11883
|
|
|
11829
11884
|
if ( intersection ) {
|
|
11830
11885
|
|
|
@@ -13750,7 +13805,7 @@ var aomap_fragment = "#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D(
|
|
|
13750
13805
|
|
|
13751
13806
|
var aomap_pars_fragment = "#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif";
|
|
13752
13807
|
|
|
13753
|
-
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";
|
|
13808
|
+
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";
|
|
13754
13809
|
|
|
13755
13810
|
var batching_vertex = "#ifdef USE_BATCHING\n\tmat4 batchingMatrix = getBatchingMatrix( batchId );\n#endif";
|
|
13756
13811
|
|
|
@@ -13776,9 +13831,9 @@ var color_fragment = "#if defined( USE_COLOR_ALPHA )\n\tdiffuseColor *= vColor;\
|
|
|
13776
13831
|
|
|
13777
13832
|
var color_pars_fragment = "#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR )\n\tvarying vec3 vColor;\n#endif";
|
|
13778
13833
|
|
|
13779
|
-
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";
|
|
13834
|
+
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";
|
|
13780
13835
|
|
|
13781
|
-
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";
|
|
13836
|
+
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";
|
|
13782
13837
|
|
|
13783
13838
|
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";
|
|
13784
13839
|
|
|
@@ -13818,15 +13873,13 @@ var fog_pars_fragment = "#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying flo
|
|
|
13818
13873
|
|
|
13819
13874
|
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}";
|
|
13820
13875
|
|
|
13821
|
-
var lightmap_fragment = "#ifdef USE_LIGHTMAP\n\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\treflectedLight.indirectDiffuse += lightMapIrradiance;\n#endif";
|
|
13822
|
-
|
|
13823
13876
|
var lightmap_pars_fragment = "#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif";
|
|
13824
13877
|
|
|
13825
13878
|
var lights_lambert_fragment = "LambertMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularStrength = specularStrength;";
|
|
13826
13879
|
|
|
13827
13880
|
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";
|
|
13828
13881
|
|
|
13829
|
-
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\
|
|
13882
|
+
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";
|
|
13830
13883
|
|
|
13831
13884
|
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";
|
|
13832
13885
|
|
|
@@ -13838,9 +13891,9 @@ var lights_phong_fragment = "BlinnPhongMaterial material;\nmaterial.diffuseColor
|
|
|
13838
13891
|
|
|
13839
13892
|
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";
|
|
13840
13893
|
|
|
13841
|
-
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";
|
|
13894
|
+
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";
|
|
13842
13895
|
|
|
13843
|
-
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}";
|
|
13896
|
+
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}";
|
|
13844
13897
|
|
|
13845
13898
|
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";
|
|
13846
13899
|
|
|
@@ -13868,15 +13921,15 @@ var metalnessmap_fragment = "float metalnessFactor = metalness;\n#ifdef USE_META
|
|
|
13868
13921
|
|
|
13869
13922
|
var metalnessmap_pars_fragment = "#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif";
|
|
13870
13923
|
|
|
13871
|
-
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";
|
|
13924
|
+
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";
|
|
13872
13925
|
|
|
13873
|
-
var morphcolor_vertex = "#if defined( USE_MORPHCOLORS )
|
|
13926
|
+
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";
|
|
13874
13927
|
|
|
13875
|
-
var morphnormal_vertex = "#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\
|
|
13928
|
+
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";
|
|
13876
13929
|
|
|
13877
|
-
var morphtarget_pars_vertex = "#ifdef USE_MORPHTARGETS\n\t#ifndef USE_INSTANCING_MORPH\n\t\tuniform float morphTargetBaseInfluence;\n\t
|
|
13930
|
+
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";
|
|
13878
13931
|
|
|
13879
|
-
var morphtarget_vertex = "#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\
|
|
13932
|
+
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";
|
|
13880
13933
|
|
|
13881
13934
|
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;";
|
|
13882
13935
|
|
|
@@ -13936,11 +13989,11 @@ var specularmap_pars_fragment = "#ifdef USE_SPECULARMAP\n\tuniform sampler2D spe
|
|
|
13936
13989
|
|
|
13937
13990
|
var tonemapping_fragment = "#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif";
|
|
13938
13991
|
|
|
13939
|
-
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\
|
|
13992
|
+
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; }";
|
|
13940
13993
|
|
|
13941
|
-
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";
|
|
13994
|
+
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";
|
|
13942
13995
|
|
|
13943
|
-
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,
|
|
13996
|
+
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";
|
|
13944
13997
|
|
|
13945
13998
|
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";
|
|
13946
13999
|
|
|
@@ -14000,7 +14053,7 @@ const fragment$6 = "#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;
|
|
|
14000
14053
|
|
|
14001
14054
|
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}";
|
|
14002
14055
|
|
|
14003
|
-
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}";
|
|
14056
|
+
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}";
|
|
14004
14057
|
|
|
14005
14058
|
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}";
|
|
14006
14059
|
|
|
@@ -14062,7 +14115,6 @@ const ShaderChunk = {
|
|
|
14062
14115
|
fog_fragment: fog_fragment,
|
|
14063
14116
|
fog_pars_fragment: fog_pars_fragment,
|
|
14064
14117
|
gradientmap_pars_fragment: gradientmap_pars_fragment,
|
|
14065
|
-
lightmap_fragment: lightmap_fragment,
|
|
14066
14118
|
lightmap_pars_fragment: lightmap_pars_fragment,
|
|
14067
14119
|
lights_lambert_fragment: lights_lambert_fragment,
|
|
14068
14120
|
lights_lambert_pars_fragment: lights_lambert_pars_fragment,
|
|
@@ -14698,6 +14750,7 @@ ShaderLib.physical = {
|
|
|
14698
14750
|
clearcoatRoughness: { value: 0 },
|
|
14699
14751
|
clearcoatRoughnessMap: { value: null },
|
|
14700
14752
|
clearcoatRoughnessMapTransform: { value: /*@__PURE__*/ new Matrix3() },
|
|
14753
|
+
dispersion: { value: 0 },
|
|
14701
14754
|
iridescence: { value: 0 },
|
|
14702
14755
|
iridescenceMap: { value: null },
|
|
14703
14756
|
iridescenceMapTransform: { value: /*@__PURE__*/ new Matrix3() },
|
|
@@ -14756,9 +14809,8 @@ function WebGLBackground( renderer, cubemaps, cubeuvmaps, state, objects, alpha,
|
|
|
14756
14809
|
let currentBackgroundVersion = 0;
|
|
14757
14810
|
let currentTonemapping = null;
|
|
14758
14811
|
|
|
14759
|
-
function
|
|
14812
|
+
function getBackground( scene ) {
|
|
14760
14813
|
|
|
14761
|
-
let forceClear = false;
|
|
14762
14814
|
let background = scene.isScene === true ? scene.background : null;
|
|
14763
14815
|
|
|
14764
14816
|
if ( background && background.isTexture ) {
|
|
@@ -14768,6 +14820,15 @@ function WebGLBackground( renderer, cubemaps, cubeuvmaps, state, objects, alpha,
|
|
|
14768
14820
|
|
|
14769
14821
|
}
|
|
14770
14822
|
|
|
14823
|
+
return background;
|
|
14824
|
+
|
|
14825
|
+
}
|
|
14826
|
+
|
|
14827
|
+
function render( scene ) {
|
|
14828
|
+
|
|
14829
|
+
let forceClear = false;
|
|
14830
|
+
const background = getBackground( scene );
|
|
14831
|
+
|
|
14771
14832
|
if ( background === null ) {
|
|
14772
14833
|
|
|
14773
14834
|
setClear( clearColor, clearAlpha );
|
|
@@ -14793,10 +14854,22 @@ function WebGLBackground( renderer, cubemaps, cubeuvmaps, state, objects, alpha,
|
|
|
14793
14854
|
|
|
14794
14855
|
if ( renderer.autoClear || forceClear ) {
|
|
14795
14856
|
|
|
14857
|
+
// buffers might not be writable which is required to ensure a correct clear
|
|
14858
|
+
|
|
14859
|
+
state.buffers.depth.setTest( true );
|
|
14860
|
+
state.buffers.depth.setMask( true );
|
|
14861
|
+
state.buffers.color.setMask( true );
|
|
14862
|
+
|
|
14796
14863
|
renderer.clear( renderer.autoClearColor, renderer.autoClearDepth, renderer.autoClearStencil );
|
|
14797
14864
|
|
|
14798
14865
|
}
|
|
14799
14866
|
|
|
14867
|
+
}
|
|
14868
|
+
|
|
14869
|
+
function addToRenderList( renderList, scene ) {
|
|
14870
|
+
|
|
14871
|
+
const background = getBackground( scene );
|
|
14872
|
+
|
|
14800
14873
|
if ( background && ( background.isCubeTexture || background.mapping === CubeUVReflectionMapping ) ) {
|
|
14801
14874
|
|
|
14802
14875
|
if ( boxMesh === undefined ) {
|
|
@@ -14977,7 +15050,8 @@ function WebGLBackground( renderer, cubemaps, cubeuvmaps, state, objects, alpha,
|
|
|
14977
15050
|
setClear( clearColor, clearAlpha );
|
|
14978
15051
|
|
|
14979
15052
|
},
|
|
14980
|
-
render: render
|
|
15053
|
+
render: render,
|
|
15054
|
+
addToRenderList: addToRenderList
|
|
14981
15055
|
|
|
14982
15056
|
};
|
|
14983
15057
|
|
|
@@ -15632,16 +15706,52 @@ function WebGLBufferRenderer( gl, extensions, info ) {
|
|
|
15632
15706
|
|
|
15633
15707
|
}
|
|
15634
15708
|
|
|
15709
|
+
function renderMultiDrawInstances( starts, counts, drawCount, primcount ) {
|
|
15710
|
+
|
|
15711
|
+
if ( drawCount === 0 ) return;
|
|
15712
|
+
|
|
15713
|
+
const extension = extensions.get( 'WEBGL_multi_draw' );
|
|
15714
|
+
|
|
15715
|
+
if ( extension === null ) {
|
|
15716
|
+
|
|
15717
|
+
for ( let i = 0; i < starts.length; i ++ ) {
|
|
15718
|
+
|
|
15719
|
+
renderInstances( starts[ i ], counts[ i ], primcount[ i ] );
|
|
15720
|
+
|
|
15721
|
+
}
|
|
15722
|
+
|
|
15723
|
+
} else {
|
|
15724
|
+
|
|
15725
|
+
extension.multiDrawArraysInstancedWEBGL( mode, starts, 0, counts, 0, primcount, 0, drawCount );
|
|
15726
|
+
|
|
15727
|
+
let elementCount = 0;
|
|
15728
|
+
for ( let i = 0; i < drawCount; i ++ ) {
|
|
15729
|
+
|
|
15730
|
+
elementCount += counts[ i ];
|
|
15731
|
+
|
|
15732
|
+
}
|
|
15733
|
+
|
|
15734
|
+
for ( let i = 0; i < primcount.length; i ++ ) {
|
|
15735
|
+
|
|
15736
|
+
info.update( elementCount, mode, primcount[ i ] );
|
|
15737
|
+
|
|
15738
|
+
}
|
|
15739
|
+
|
|
15740
|
+
}
|
|
15741
|
+
|
|
15742
|
+
}
|
|
15743
|
+
|
|
15635
15744
|
//
|
|
15636
15745
|
|
|
15637
15746
|
this.setMode = setMode;
|
|
15638
15747
|
this.render = render;
|
|
15639
15748
|
this.renderInstances = renderInstances;
|
|
15640
15749
|
this.renderMultiDraw = renderMultiDraw;
|
|
15750
|
+
this.renderMultiDrawInstances = renderMultiDrawInstances;
|
|
15641
15751
|
|
|
15642
15752
|
}
|
|
15643
15753
|
|
|
15644
|
-
function WebGLCapabilities( gl, extensions, parameters ) {
|
|
15754
|
+
function WebGLCapabilities( gl, extensions, parameters, utils ) {
|
|
15645
15755
|
|
|
15646
15756
|
let maxAnisotropy;
|
|
15647
15757
|
|
|
@@ -15665,6 +15775,33 @@ function WebGLCapabilities( gl, extensions, parameters ) {
|
|
|
15665
15775
|
|
|
15666
15776
|
}
|
|
15667
15777
|
|
|
15778
|
+
function textureFormatReadable( textureFormat ) {
|
|
15779
|
+
|
|
15780
|
+
if ( textureFormat !== RGBAFormat && utils.convert( textureFormat ) !== gl.getParameter( gl.IMPLEMENTATION_COLOR_READ_FORMAT ) ) {
|
|
15781
|
+
|
|
15782
|
+
return false;
|
|
15783
|
+
|
|
15784
|
+
}
|
|
15785
|
+
|
|
15786
|
+
return true;
|
|
15787
|
+
|
|
15788
|
+
}
|
|
15789
|
+
|
|
15790
|
+
function textureTypeReadable( textureType ) {
|
|
15791
|
+
|
|
15792
|
+
const halfFloatSupportedByExt = ( textureType === HalfFloatType ) && ( extensions.has( 'EXT_color_buffer_half_float' ) || extensions.has( 'EXT_color_buffer_float' ) );
|
|
15793
|
+
|
|
15794
|
+
if ( textureType !== UnsignedByteType && utils.convert( textureType ) !== gl.getParameter( gl.IMPLEMENTATION_COLOR_READ_TYPE ) && // Edge and Chrome Mac < 52 (#9513)
|
|
15795
|
+
textureType !== FloatType && ! halfFloatSupportedByExt ) {
|
|
15796
|
+
|
|
15797
|
+
return false;
|
|
15798
|
+
|
|
15799
|
+
}
|
|
15800
|
+
|
|
15801
|
+
return true;
|
|
15802
|
+
|
|
15803
|
+
}
|
|
15804
|
+
|
|
15668
15805
|
function getMaxPrecision( precision ) {
|
|
15669
15806
|
|
|
15670
15807
|
if ( precision === 'highp' ) {
|
|
@@ -15728,6 +15865,9 @@ function WebGLCapabilities( gl, extensions, parameters ) {
|
|
|
15728
15865
|
getMaxAnisotropy: getMaxAnisotropy,
|
|
15729
15866
|
getMaxPrecision: getMaxPrecision,
|
|
15730
15867
|
|
|
15868
|
+
textureFormatReadable: textureFormatReadable,
|
|
15869
|
+
textureTypeReadable: textureTypeReadable,
|
|
15870
|
+
|
|
15731
15871
|
precision: precision,
|
|
15732
15872
|
logarithmicDepthBuffer: logarithmicDepthBuffer,
|
|
15733
15873
|
|
|
@@ -16169,16 +16309,16 @@ const INV_PHI = 1 / PHI;
|
|
|
16169
16309
|
// Vertices of a dodecahedron (except the opposites, which represent the
|
|
16170
16310
|
// same axis), used as axis directions evenly spread on a sphere.
|
|
16171
16311
|
const _axisDirections = [
|
|
16172
|
-
/*@__PURE__*/ new Vector3(
|
|
16173
|
-
/*@__PURE__*/ new Vector3( - 1, 1, 1 ),
|
|
16174
|
-
/*@__PURE__*/ new Vector3( 1, 1, - 1 ),
|
|
16175
|
-
/*@__PURE__*/ new Vector3( - 1, 1, - 1 ),
|
|
16176
|
-
/*@__PURE__*/ new Vector3( 0, PHI, INV_PHI ),
|
|
16177
|
-
/*@__PURE__*/ new Vector3( 0, PHI, - INV_PHI ),
|
|
16178
|
-
/*@__PURE__*/ new Vector3( INV_PHI, 0, PHI ),
|
|
16179
|
-
/*@__PURE__*/ new Vector3( - INV_PHI, 0, PHI ),
|
|
16312
|
+
/*@__PURE__*/ new Vector3( - PHI, INV_PHI, 0 ),
|
|
16180
16313
|
/*@__PURE__*/ new Vector3( PHI, INV_PHI, 0 ),
|
|
16181
|
-
/*@__PURE__*/ new Vector3( -
|
|
16314
|
+
/*@__PURE__*/ new Vector3( - INV_PHI, 0, PHI ),
|
|
16315
|
+
/*@__PURE__*/ new Vector3( INV_PHI, 0, PHI ),
|
|
16316
|
+
/*@__PURE__*/ new Vector3( 0, PHI, - INV_PHI ),
|
|
16317
|
+
/*@__PURE__*/ new Vector3( 0, PHI, INV_PHI ),
|
|
16318
|
+
/*@__PURE__*/ new Vector3( - 1, 1, - 1 ),
|
|
16319
|
+
/*@__PURE__*/ new Vector3( 1, 1, - 1 ),
|
|
16320
|
+
/*@__PURE__*/ new Vector3( - 1, 1, 1 ),
|
|
16321
|
+
/*@__PURE__*/ new Vector3( 1, 1, 1 ) ];
|
|
16182
16322
|
|
|
16183
16323
|
/**
|
|
16184
16324
|
* This class generates a Prefiltered, Mipmapped Radiance Environment Map
|
|
@@ -16564,12 +16704,13 @@ class PMREMGenerator {
|
|
|
16564
16704
|
const renderer = this._renderer;
|
|
16565
16705
|
const autoClear = renderer.autoClear;
|
|
16566
16706
|
renderer.autoClear = false;
|
|
16707
|
+
const n = this._lodPlanes.length;
|
|
16567
16708
|
|
|
16568
|
-
for ( let i = 1; i <
|
|
16709
|
+
for ( let i = 1; i < n; i ++ ) {
|
|
16569
16710
|
|
|
16570
16711
|
const sigma = Math.sqrt( this._sigmas[ i ] * this._sigmas[ i ] - this._sigmas[ i - 1 ] * this._sigmas[ i - 1 ] );
|
|
16571
16712
|
|
|
16572
|
-
const poleAxis = _axisDirections[ ( i - 1 ) % _axisDirections.length ];
|
|
16713
|
+
const poleAxis = _axisDirections[ ( n - i - 1 ) % _axisDirections.length ];
|
|
16573
16714
|
|
|
16574
16715
|
this._blur( cubeUVRenderTarget, i - 1, i, sigma, poleAxis );
|
|
16575
16716
|
|
|
@@ -17232,7 +17373,7 @@ function WebGLExtensions( gl ) {
|
|
|
17232
17373
|
|
|
17233
17374
|
if ( extension === null ) {
|
|
17234
17375
|
|
|
17235
|
-
|
|
17376
|
+
warnOnce( 'THREE.WebGLRenderer: ' + name + ' extension not supported.' );
|
|
17236
17377
|
|
|
17237
17378
|
}
|
|
17238
17379
|
|
|
@@ -17518,6 +17659,41 @@ function WebGLIndexedBufferRenderer( gl, extensions, info ) {
|
|
|
17518
17659
|
|
|
17519
17660
|
}
|
|
17520
17661
|
|
|
17662
|
+
function renderMultiDrawInstances( starts, counts, drawCount, primcount ) {
|
|
17663
|
+
|
|
17664
|
+
if ( drawCount === 0 ) return;
|
|
17665
|
+
|
|
17666
|
+
const extension = extensions.get( 'WEBGL_multi_draw' );
|
|
17667
|
+
|
|
17668
|
+
if ( extension === null ) {
|
|
17669
|
+
|
|
17670
|
+
for ( let i = 0; i < starts.length; i ++ ) {
|
|
17671
|
+
|
|
17672
|
+
renderInstances( starts[ i ] / bytesPerElement, counts[ i ], primcount[ i ] );
|
|
17673
|
+
|
|
17674
|
+
}
|
|
17675
|
+
|
|
17676
|
+
} else {
|
|
17677
|
+
|
|
17678
|
+
extension.multiDrawElementsInstancedWEBGL( mode, counts, 0, type, starts, 0, primcount, 0, drawCount );
|
|
17679
|
+
|
|
17680
|
+
let elementCount = 0;
|
|
17681
|
+
for ( let i = 0; i < drawCount; i ++ ) {
|
|
17682
|
+
|
|
17683
|
+
elementCount += counts[ i ];
|
|
17684
|
+
|
|
17685
|
+
}
|
|
17686
|
+
|
|
17687
|
+
for ( let i = 0; i < primcount.length; i ++ ) {
|
|
17688
|
+
|
|
17689
|
+
info.update( elementCount, mode, primcount[ i ] );
|
|
17690
|
+
|
|
17691
|
+
}
|
|
17692
|
+
|
|
17693
|
+
}
|
|
17694
|
+
|
|
17695
|
+
}
|
|
17696
|
+
|
|
17521
17697
|
//
|
|
17522
17698
|
|
|
17523
17699
|
this.setMode = setMode;
|
|
@@ -17525,6 +17701,7 @@ function WebGLIndexedBufferRenderer( gl, extensions, info ) {
|
|
|
17525
17701
|
this.render = render;
|
|
17526
17702
|
this.renderInstances = renderInstances;
|
|
17527
17703
|
this.renderMultiDraw = renderMultiDraw;
|
|
17704
|
+
this.renderMultiDrawInstances = renderMultiDrawInstances;
|
|
17528
17705
|
|
|
17529
17706
|
}
|
|
17530
17707
|
|
|
@@ -17606,8 +17783,7 @@ function WebGLMorphtargets( gl, capabilities, textures ) {
|
|
|
17606
17783
|
|
|
17607
17784
|
const objectInfluences = object.morphTargetInfluences;
|
|
17608
17785
|
|
|
17609
|
-
//
|
|
17610
|
-
// into an array of data textures. Each layer represents a single morph target.
|
|
17786
|
+
// the following encodes morph targets into an array of data textures. Each layer represents a single morph target.
|
|
17611
17787
|
|
|
17612
17788
|
const morphAttribute = geometry.morphAttributes.position || geometry.morphAttributes.normal || geometry.morphAttributes.color;
|
|
17613
17789
|
const morphTargetsCount = ( morphAttribute !== undefined ) ? morphAttribute.length : 0;
|
|
@@ -17948,9 +18124,7 @@ function WebGLObjects( gl, geometries, attributes, info ) {
|
|
|
17948
18124
|
|
|
17949
18125
|
class DepthTexture extends Texture {
|
|
17950
18126
|
|
|
17951
|
-
constructor( width, height, type, mapping, wrapS, wrapT, magFilter, minFilter, anisotropy, format ) {
|
|
17952
|
-
|
|
17953
|
-
format = format !== undefined ? format : DepthFormat;
|
|
18127
|
+
constructor( width, height, type, mapping, wrapS, wrapT, magFilter, minFilter, anisotropy, format = DepthFormat ) {
|
|
17954
18128
|
|
|
17955
18129
|
if ( format !== DepthFormat && format !== DepthStencilFormat ) {
|
|
17956
18130
|
|
|
@@ -19400,11 +19574,7 @@ function resolveIncludes( string ) {
|
|
|
19400
19574
|
|
|
19401
19575
|
}
|
|
19402
19576
|
|
|
19403
|
-
const shaderChunkMap = new Map(
|
|
19404
|
-
[ 'encodings_fragment', 'colorspace_fragment' ], // @deprecated, r154
|
|
19405
|
-
[ 'encodings_pars_fragment', 'colorspace_pars_fragment' ], // @deprecated, r154
|
|
19406
|
-
[ 'output_fragment', 'opaque_fragment' ], // @deprecated, r154
|
|
19407
|
-
] );
|
|
19577
|
+
const shaderChunkMap = new Map();
|
|
19408
19578
|
|
|
19409
19579
|
function includeReplacer( match, include ) {
|
|
19410
19580
|
|
|
@@ -19684,6 +19854,7 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
|
|
|
19684
19854
|
|
|
19685
19855
|
parameters.extensionClipCullDistance ? '#define USE_CLIP_DISTANCE' : '',
|
|
19686
19856
|
parameters.batching ? '#define USE_BATCHING' : '',
|
|
19857
|
+
parameters.batchingColor ? '#define USE_BATCHING_COLOR' : '',
|
|
19687
19858
|
parameters.instancing ? '#define USE_INSTANCING' : '',
|
|
19688
19859
|
parameters.instancingColor ? '#define USE_INSTANCING_COLOR' : '',
|
|
19689
19860
|
parameters.instancingMorph ? '#define USE_INSTANCING_MORPH' : '',
|
|
@@ -19780,7 +19951,6 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
|
|
|
19780
19951
|
parameters.morphTargets ? '#define USE_MORPHTARGETS' : '',
|
|
19781
19952
|
parameters.morphNormals && parameters.flatShading === false ? '#define USE_MORPHNORMALS' : '',
|
|
19782
19953
|
( parameters.morphColors ) ? '#define USE_MORPHCOLORS' : '',
|
|
19783
|
-
( parameters.morphTargetsCount > 0 ) ? '#define MORPHTARGETS_TEXTURE' : '',
|
|
19784
19954
|
( parameters.morphTargetsCount > 0 ) ? '#define MORPHTARGETS_TEXTURE_STRIDE ' + parameters.morphTextureStride : '',
|
|
19785
19955
|
( parameters.morphTargetsCount > 0 ) ? '#define MORPHTARGETS_COUNT ' + parameters.morphTargetsCount : '',
|
|
19786
19956
|
parameters.doubleSided ? '#define DOUBLE_SIDED' : '',
|
|
@@ -19793,8 +19963,6 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
|
|
|
19793
19963
|
|
|
19794
19964
|
parameters.numLightProbes > 0 ? '#define USE_LIGHT_PROBES' : '',
|
|
19795
19965
|
|
|
19796
|
-
parameters.useLegacyLights ? '#define LEGACY_LIGHTS' : '',
|
|
19797
|
-
|
|
19798
19966
|
parameters.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '',
|
|
19799
19967
|
|
|
19800
19968
|
'uniform mat4 modelMatrix;',
|
|
@@ -19861,31 +20029,6 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
|
|
|
19861
20029
|
|
|
19862
20030
|
'#endif',
|
|
19863
20031
|
|
|
19864
|
-
'#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )',
|
|
19865
|
-
|
|
19866
|
-
' attribute vec3 morphTarget0;',
|
|
19867
|
-
' attribute vec3 morphTarget1;',
|
|
19868
|
-
' attribute vec3 morphTarget2;',
|
|
19869
|
-
' attribute vec3 morphTarget3;',
|
|
19870
|
-
|
|
19871
|
-
' #ifdef USE_MORPHNORMALS',
|
|
19872
|
-
|
|
19873
|
-
' attribute vec3 morphNormal0;',
|
|
19874
|
-
' attribute vec3 morphNormal1;',
|
|
19875
|
-
' attribute vec3 morphNormal2;',
|
|
19876
|
-
' attribute vec3 morphNormal3;',
|
|
19877
|
-
|
|
19878
|
-
' #else',
|
|
19879
|
-
|
|
19880
|
-
' attribute vec3 morphTarget4;',
|
|
19881
|
-
' attribute vec3 morphTarget5;',
|
|
19882
|
-
' attribute vec3 morphTarget6;',
|
|
19883
|
-
' attribute vec3 morphTarget7;',
|
|
19884
|
-
|
|
19885
|
-
' #endif',
|
|
19886
|
-
|
|
19887
|
-
'#endif',
|
|
19888
|
-
|
|
19889
20032
|
'#ifdef USE_SKINNING',
|
|
19890
20033
|
|
|
19891
20034
|
' attribute vec4 skinIndex;',
|
|
@@ -19935,6 +20078,8 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
|
|
|
19935
20078
|
parameters.clearcoatRoughnessMap ? '#define USE_CLEARCOAT_ROUGHNESSMAP' : '',
|
|
19936
20079
|
parameters.clearcoatNormalMap ? '#define USE_CLEARCOAT_NORMALMAP' : '',
|
|
19937
20080
|
|
|
20081
|
+
parameters.dispersion ? '#define USE_DISPERSION' : '',
|
|
20082
|
+
|
|
19938
20083
|
parameters.iridescence ? '#define USE_IRIDESCENCE' : '',
|
|
19939
20084
|
parameters.iridescenceMap ? '#define USE_IRIDESCENCEMAP' : '',
|
|
19940
20085
|
parameters.iridescenceThicknessMap ? '#define USE_IRIDESCENCE_THICKNESSMAP' : '',
|
|
@@ -19959,7 +20104,7 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
|
|
|
19959
20104
|
parameters.thicknessMap ? '#define USE_THICKNESSMAP' : '',
|
|
19960
20105
|
|
|
19961
20106
|
parameters.vertexTangents && parameters.flatShading === false ? '#define USE_TANGENT' : '',
|
|
19962
|
-
parameters.vertexColors || parameters.instancingColor ? '#define USE_COLOR' : '',
|
|
20107
|
+
parameters.vertexColors || parameters.instancingColor || parameters.batchingColor ? '#define USE_COLOR' : '',
|
|
19963
20108
|
parameters.vertexAlphas ? '#define USE_COLOR_ALPHA' : '',
|
|
19964
20109
|
parameters.vertexUv1s ? '#define USE_UV1' : '',
|
|
19965
20110
|
parameters.vertexUv2s ? '#define USE_UV2' : '',
|
|
@@ -19981,8 +20126,6 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
|
|
|
19981
20126
|
|
|
19982
20127
|
parameters.numLightProbes > 0 ? '#define USE_LIGHT_PROBES' : '',
|
|
19983
20128
|
|
|
19984
|
-
parameters.useLegacyLights ? '#define LEGACY_LIGHTS' : '',
|
|
19985
|
-
|
|
19986
20129
|
parameters.decodeVideoTexture ? '#define DECODE_VIDEO_TEXTURE' : '',
|
|
19987
20130
|
|
|
19988
20131
|
parameters.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '',
|
|
@@ -20540,6 +20683,7 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
|
|
|
20540
20683
|
|
|
20541
20684
|
const HAS_ANISOTROPY = material.anisotropy > 0;
|
|
20542
20685
|
const HAS_CLEARCOAT = material.clearcoat > 0;
|
|
20686
|
+
const HAS_DISPERSION = material.dispersion > 0;
|
|
20543
20687
|
const HAS_IRIDESCENCE = material.iridescence > 0;
|
|
20544
20688
|
const HAS_SHEEN = material.sheen > 0;
|
|
20545
20689
|
const HAS_TRANSMISSION = material.transmission > 0;
|
|
@@ -20604,6 +20748,7 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
|
|
|
20604
20748
|
precision: precision,
|
|
20605
20749
|
|
|
20606
20750
|
batching: IS_BATCHEDMESH,
|
|
20751
|
+
batchingColor: IS_BATCHEDMESH && object._colorsTexture !== null,
|
|
20607
20752
|
instancing: IS_INSTANCEDMESH,
|
|
20608
20753
|
instancingColor: IS_INSTANCEDMESH && object.instanceColor !== null,
|
|
20609
20754
|
instancingMorph: IS_INSTANCEDMESH && object.morphTexture !== null,
|
|
@@ -20639,6 +20784,8 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
|
|
|
20639
20784
|
clearcoatNormalMap: HAS_CLEARCOAT_NORMALMAP,
|
|
20640
20785
|
clearcoatRoughnessMap: HAS_CLEARCOAT_ROUGHNESSMAP,
|
|
20641
20786
|
|
|
20787
|
+
dispersion: HAS_DISPERSION,
|
|
20788
|
+
|
|
20642
20789
|
iridescence: HAS_IRIDESCENCE,
|
|
20643
20790
|
iridescenceMap: HAS_IRIDESCENCEMAP,
|
|
20644
20791
|
iridescenceThicknessMap: HAS_IRIDESCENCE_THICKNESSMAP,
|
|
@@ -20747,7 +20894,6 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
|
|
|
20747
20894
|
shadowMapType: renderer.shadowMap.type,
|
|
20748
20895
|
|
|
20749
20896
|
toneMapping: toneMapping,
|
|
20750
|
-
useLegacyLights: renderer._useLegacyLights,
|
|
20751
20897
|
|
|
20752
20898
|
decodeVideoTexture: HAS_MAP && ( material.map.isVideoTexture === true ) && ( ColorManagement.getTransfer( material.map.colorSpace ) === SRGBTransfer ),
|
|
20753
20899
|
|
|
@@ -20919,6 +21065,10 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
|
|
|
20919
21065
|
_programLayers.enable( 18 );
|
|
20920
21066
|
if ( parameters.batching )
|
|
20921
21067
|
_programLayers.enable( 19 );
|
|
21068
|
+
if ( parameters.dispersion )
|
|
21069
|
+
_programLayers.enable( 20 );
|
|
21070
|
+
if ( parameters.batchingColor )
|
|
21071
|
+
_programLayers.enable( 21 );
|
|
20922
21072
|
|
|
20923
21073
|
array.push( _programLayers.mask );
|
|
20924
21074
|
_programLayers.disableAll();
|
|
@@ -20943,30 +21093,28 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
|
|
|
20943
21093
|
_programLayers.enable( 8 );
|
|
20944
21094
|
if ( parameters.shadowMapEnabled )
|
|
20945
21095
|
_programLayers.enable( 9 );
|
|
20946
|
-
if ( parameters.useLegacyLights )
|
|
20947
|
-
_programLayers.enable( 10 );
|
|
20948
21096
|
if ( parameters.doubleSided )
|
|
20949
|
-
_programLayers.enable(
|
|
21097
|
+
_programLayers.enable( 10 );
|
|
20950
21098
|
if ( parameters.flipSided )
|
|
20951
|
-
_programLayers.enable(
|
|
21099
|
+
_programLayers.enable( 11 );
|
|
20952
21100
|
if ( parameters.useDepthPacking )
|
|
20953
|
-
_programLayers.enable(
|
|
21101
|
+
_programLayers.enable( 12 );
|
|
20954
21102
|
if ( parameters.dithering )
|
|
20955
|
-
_programLayers.enable(
|
|
21103
|
+
_programLayers.enable( 13 );
|
|
20956
21104
|
if ( parameters.transmission )
|
|
20957
|
-
_programLayers.enable(
|
|
21105
|
+
_programLayers.enable( 14 );
|
|
20958
21106
|
if ( parameters.sheen )
|
|
20959
|
-
_programLayers.enable(
|
|
21107
|
+
_programLayers.enable( 15 );
|
|
20960
21108
|
if ( parameters.opaque )
|
|
20961
|
-
_programLayers.enable(
|
|
21109
|
+
_programLayers.enable( 16 );
|
|
20962
21110
|
if ( parameters.pointsUvs )
|
|
20963
|
-
_programLayers.enable(
|
|
21111
|
+
_programLayers.enable( 17 );
|
|
20964
21112
|
if ( parameters.decodeVideoTexture )
|
|
20965
|
-
_programLayers.enable(
|
|
21113
|
+
_programLayers.enable( 18 );
|
|
20966
21114
|
if ( parameters.alphaToCoverage )
|
|
20967
|
-
_programLayers.enable(
|
|
21115
|
+
_programLayers.enable( 19 );
|
|
20968
21116
|
if ( parameters.numMultiviewViews )
|
|
20969
|
-
_programLayers.enable(
|
|
21117
|
+
_programLayers.enable( 20 );
|
|
20970
21118
|
|
|
20971
21119
|
array.push( _programLayers.mask );
|
|
20972
21120
|
|
|
@@ -21548,7 +21696,7 @@ function WebGLLights( extensions ) {
|
|
|
21548
21696
|
const matrix4 = new Matrix4();
|
|
21549
21697
|
const matrix42 = new Matrix4();
|
|
21550
21698
|
|
|
21551
|
-
function setup( lights
|
|
21699
|
+
function setup( lights ) {
|
|
21552
21700
|
|
|
21553
21701
|
let r = 0, g = 0, b = 0;
|
|
21554
21702
|
|
|
@@ -21571,9 +21719,6 @@ function WebGLLights( extensions ) {
|
|
|
21571
21719
|
// ordering : [shadow casting + map texturing, map texturing, shadow casting, none ]
|
|
21572
21720
|
lights.sort( shadowCastingAndTexturingLightsFirst );
|
|
21573
21721
|
|
|
21574
|
-
// artist-friendly light intensity scaling factor
|
|
21575
|
-
const scaleFactor = ( useLegacyLights === true ) ? Math.PI : 1;
|
|
21576
|
-
|
|
21577
21722
|
for ( let i = 0, l = lights.length; i < l; i ++ ) {
|
|
21578
21723
|
|
|
21579
21724
|
const light = lights[ i ];
|
|
@@ -21586,9 +21731,9 @@ function WebGLLights( extensions ) {
|
|
|
21586
21731
|
|
|
21587
21732
|
if ( light.isAmbientLight ) {
|
|
21588
21733
|
|
|
21589
|
-
r += color.r * intensity
|
|
21590
|
-
g += color.g * intensity
|
|
21591
|
-
b += color.b * intensity
|
|
21734
|
+
r += color.r * intensity;
|
|
21735
|
+
g += color.g * intensity;
|
|
21736
|
+
b += color.b * intensity;
|
|
21592
21737
|
|
|
21593
21738
|
} else if ( light.isLightProbe ) {
|
|
21594
21739
|
|
|
@@ -21604,7 +21749,7 @@ function WebGLLights( extensions ) {
|
|
|
21604
21749
|
|
|
21605
21750
|
const uniforms = cache.get( light );
|
|
21606
21751
|
|
|
21607
|
-
uniforms.color.copy( light.color ).multiplyScalar( light.intensity
|
|
21752
|
+
uniforms.color.copy( light.color ).multiplyScalar( light.intensity );
|
|
21608
21753
|
|
|
21609
21754
|
if ( light.castShadow ) {
|
|
21610
21755
|
|
|
@@ -21635,7 +21780,7 @@ function WebGLLights( extensions ) {
|
|
|
21635
21780
|
|
|
21636
21781
|
uniforms.position.setFromMatrixPosition( light.matrixWorld );
|
|
21637
21782
|
|
|
21638
|
-
uniforms.color.copy( color ).multiplyScalar( intensity
|
|
21783
|
+
uniforms.color.copy( color ).multiplyScalar( intensity );
|
|
21639
21784
|
uniforms.distance = distance;
|
|
21640
21785
|
|
|
21641
21786
|
uniforms.coneCos = Math.cos( light.angle );
|
|
@@ -21696,7 +21841,7 @@ function WebGLLights( extensions ) {
|
|
|
21696
21841
|
|
|
21697
21842
|
const uniforms = cache.get( light );
|
|
21698
21843
|
|
|
21699
|
-
uniforms.color.copy( light.color ).multiplyScalar( light.intensity
|
|
21844
|
+
uniforms.color.copy( light.color ).multiplyScalar( light.intensity );
|
|
21700
21845
|
uniforms.distance = light.distance;
|
|
21701
21846
|
uniforms.decay = light.decay;
|
|
21702
21847
|
|
|
@@ -21729,8 +21874,8 @@ function WebGLLights( extensions ) {
|
|
|
21729
21874
|
|
|
21730
21875
|
const uniforms = cache.get( light );
|
|
21731
21876
|
|
|
21732
|
-
uniforms.skyColor.copy( light.color ).multiplyScalar( intensity
|
|
21733
|
-
uniforms.groundColor.copy( light.groundColor ).multiplyScalar( intensity
|
|
21877
|
+
uniforms.skyColor.copy( light.color ).multiplyScalar( intensity );
|
|
21878
|
+
uniforms.groundColor.copy( light.groundColor ).multiplyScalar( intensity );
|
|
21734
21879
|
|
|
21735
21880
|
state.hemi[ hemiLength ] = uniforms;
|
|
21736
21881
|
|
|
@@ -21910,7 +22055,9 @@ function WebGLRenderState( extensions ) {
|
|
|
21910
22055
|
const lightsArray = [];
|
|
21911
22056
|
const shadowsArray = [];
|
|
21912
22057
|
|
|
21913
|
-
function init() {
|
|
22058
|
+
function init( camera ) {
|
|
22059
|
+
|
|
22060
|
+
state.camera = camera;
|
|
21914
22061
|
|
|
21915
22062
|
lightsArray.length = 0;
|
|
21916
22063
|
shadowsArray.length = 0;
|
|
@@ -21929,9 +22076,9 @@ function WebGLRenderState( extensions ) {
|
|
|
21929
22076
|
|
|
21930
22077
|
}
|
|
21931
22078
|
|
|
21932
|
-
function setupLights(
|
|
22079
|
+
function setupLights() {
|
|
21933
22080
|
|
|
21934
|
-
lights.setup( lightsArray
|
|
22081
|
+
lights.setup( lightsArray );
|
|
21935
22082
|
|
|
21936
22083
|
}
|
|
21937
22084
|
|
|
@@ -21945,9 +22092,11 @@ function WebGLRenderState( extensions ) {
|
|
|
21945
22092
|
lightsArray: lightsArray,
|
|
21946
22093
|
shadowsArray: shadowsArray,
|
|
21947
22094
|
|
|
22095
|
+
camera: null,
|
|
22096
|
+
|
|
21948
22097
|
lights: lights,
|
|
21949
22098
|
|
|
21950
|
-
transmissionRenderTarget:
|
|
22099
|
+
transmissionRenderTarget: {}
|
|
21951
22100
|
};
|
|
21952
22101
|
|
|
21953
22102
|
return {
|
|
@@ -22102,7 +22251,7 @@ const vertex = "void main() {\n\tgl_Position = vec4( position, 1.0 );\n}";
|
|
|
22102
22251
|
|
|
22103
22252
|
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}";
|
|
22104
22253
|
|
|
22105
|
-
function WebGLShadowMap(
|
|
22254
|
+
function WebGLShadowMap( renderer, objects, capabilities ) {
|
|
22106
22255
|
|
|
22107
22256
|
let _frustum = new Frustum();
|
|
22108
22257
|
|
|
@@ -22116,7 +22265,7 @@ function WebGLShadowMap( _renderer, _objects, _capabilities ) {
|
|
|
22116
22265
|
|
|
22117
22266
|
_materialCache = {},
|
|
22118
22267
|
|
|
22119
|
-
_maxTextureSize =
|
|
22268
|
+
_maxTextureSize = capabilities.maxTextureSize;
|
|
22120
22269
|
|
|
22121
22270
|
const shadowSide = { [ FrontSide ]: BackSide, [ BackSide ]: FrontSide, [ DoubleSide ]: DoubleSide };
|
|
22122
22271
|
|
|
@@ -22166,11 +22315,11 @@ function WebGLShadowMap( _renderer, _objects, _capabilities ) {
|
|
|
22166
22315
|
|
|
22167
22316
|
if ( lights.length === 0 ) return;
|
|
22168
22317
|
|
|
22169
|
-
const currentRenderTarget =
|
|
22170
|
-
const activeCubeFace =
|
|
22171
|
-
const activeMipmapLevel =
|
|
22318
|
+
const currentRenderTarget = renderer.getRenderTarget();
|
|
22319
|
+
const activeCubeFace = renderer.getActiveCubeFace();
|
|
22320
|
+
const activeMipmapLevel = renderer.getActiveMipmapLevel();
|
|
22172
22321
|
|
|
22173
|
-
const _state =
|
|
22322
|
+
const _state = renderer.state;
|
|
22174
22323
|
|
|
22175
22324
|
// Set GL state for depth map.
|
|
22176
22325
|
_state.setBlending( NoBlending );
|
|
@@ -22244,8 +22393,8 @@ function WebGLShadowMap( _renderer, _objects, _capabilities ) {
|
|
|
22244
22393
|
|
|
22245
22394
|
}
|
|
22246
22395
|
|
|
22247
|
-
|
|
22248
|
-
|
|
22396
|
+
renderer.setRenderTarget( shadow.map );
|
|
22397
|
+
renderer.clear();
|
|
22249
22398
|
|
|
22250
22399
|
const viewportCount = shadow.getViewportCount();
|
|
22251
22400
|
|
|
@@ -22286,13 +22435,13 @@ function WebGLShadowMap( _renderer, _objects, _capabilities ) {
|
|
|
22286
22435
|
|
|
22287
22436
|
scope.needsUpdate = false;
|
|
22288
22437
|
|
|
22289
|
-
|
|
22438
|
+
renderer.setRenderTarget( currentRenderTarget, activeCubeFace, activeMipmapLevel );
|
|
22290
22439
|
|
|
22291
22440
|
};
|
|
22292
22441
|
|
|
22293
22442
|
function VSMPass( shadow, camera ) {
|
|
22294
22443
|
|
|
22295
|
-
const geometry =
|
|
22444
|
+
const geometry = objects.update( fullScreenMesh );
|
|
22296
22445
|
|
|
22297
22446
|
if ( shadowMaterialVertical.defines.VSM_SAMPLES !== shadow.blurSamples ) {
|
|
22298
22447
|
|
|
@@ -22315,18 +22464,18 @@ function WebGLShadowMap( _renderer, _objects, _capabilities ) {
|
|
|
22315
22464
|
shadowMaterialVertical.uniforms.shadow_pass.value = shadow.map.texture;
|
|
22316
22465
|
shadowMaterialVertical.uniforms.resolution.value = shadow.mapSize;
|
|
22317
22466
|
shadowMaterialVertical.uniforms.radius.value = shadow.radius;
|
|
22318
|
-
|
|
22319
|
-
|
|
22320
|
-
|
|
22467
|
+
renderer.setRenderTarget( shadow.mapPass );
|
|
22468
|
+
renderer.clear();
|
|
22469
|
+
renderer.renderBufferDirect( camera, null, geometry, shadowMaterialVertical, fullScreenMesh, null );
|
|
22321
22470
|
|
|
22322
22471
|
// horizontal pass
|
|
22323
22472
|
|
|
22324
22473
|
shadowMaterialHorizontal.uniforms.shadow_pass.value = shadow.mapPass.texture;
|
|
22325
22474
|
shadowMaterialHorizontal.uniforms.resolution.value = shadow.mapSize;
|
|
22326
22475
|
shadowMaterialHorizontal.uniforms.radius.value = shadow.radius;
|
|
22327
|
-
|
|
22328
|
-
|
|
22329
|
-
|
|
22476
|
+
renderer.setRenderTarget( shadow.map );
|
|
22477
|
+
renderer.clear();
|
|
22478
|
+
renderer.renderBufferDirect( camera, null, geometry, shadowMaterialHorizontal, fullScreenMesh, null );
|
|
22330
22479
|
|
|
22331
22480
|
}
|
|
22332
22481
|
|
|
@@ -22344,7 +22493,7 @@ function WebGLShadowMap( _renderer, _objects, _capabilities ) {
|
|
|
22344
22493
|
|
|
22345
22494
|
result = ( light.isPointLight === true ) ? _distanceMaterial : _depthMaterial;
|
|
22346
22495
|
|
|
22347
|
-
if ( (
|
|
22496
|
+
if ( ( renderer.localClippingEnabled && material.clipShadows === true && Array.isArray( material.clippingPlanes ) && material.clippingPlanes.length !== 0 ) ||
|
|
22348
22497
|
( material.displacementMap && material.displacementScale !== 0 ) ||
|
|
22349
22498
|
( material.alphaMap && material.alphaTest > 0 ) ||
|
|
22350
22499
|
( material.map && material.alphaTest > 0 ) ) {
|
|
@@ -22409,7 +22558,7 @@ function WebGLShadowMap( _renderer, _objects, _capabilities ) {
|
|
|
22409
22558
|
|
|
22410
22559
|
if ( light.isPointLight === true && result.isMeshDistanceMaterial === true ) {
|
|
22411
22560
|
|
|
22412
|
-
const materialProperties =
|
|
22561
|
+
const materialProperties = renderer.properties.get( result );
|
|
22413
22562
|
materialProperties.light = light;
|
|
22414
22563
|
|
|
22415
22564
|
}
|
|
@@ -22430,7 +22579,7 @@ function WebGLShadowMap( _renderer, _objects, _capabilities ) {
|
|
|
22430
22579
|
|
|
22431
22580
|
object.modelViewMatrix.multiplyMatrices( shadowCamera.matrixWorldInverse, object.matrixWorld );
|
|
22432
22581
|
|
|
22433
|
-
const geometry =
|
|
22582
|
+
const geometry = objects.update( object );
|
|
22434
22583
|
const material = object.material;
|
|
22435
22584
|
|
|
22436
22585
|
if ( Array.isArray( material ) ) {
|
|
@@ -22446,11 +22595,11 @@ function WebGLShadowMap( _renderer, _objects, _capabilities ) {
|
|
|
22446
22595
|
|
|
22447
22596
|
const depthMaterial = getDepthMaterial( object, groupMaterial, light, type );
|
|
22448
22597
|
|
|
22449
|
-
object.onBeforeShadow(
|
|
22598
|
+
object.onBeforeShadow( renderer, object, camera, shadowCamera, geometry, depthMaterial, group );
|
|
22450
22599
|
|
|
22451
|
-
|
|
22600
|
+
renderer.renderBufferDirect( shadowCamera, null, geometry, depthMaterial, object, group );
|
|
22452
22601
|
|
|
22453
|
-
object.onAfterShadow(
|
|
22602
|
+
object.onAfterShadow( renderer, object, camera, shadowCamera, geometry, depthMaterial, group );
|
|
22454
22603
|
|
|
22455
22604
|
}
|
|
22456
22605
|
|
|
@@ -22460,11 +22609,11 @@ function WebGLShadowMap( _renderer, _objects, _capabilities ) {
|
|
|
22460
22609
|
|
|
22461
22610
|
const depthMaterial = getDepthMaterial( object, material, light, type );
|
|
22462
22611
|
|
|
22463
|
-
object.onBeforeShadow(
|
|
22612
|
+
object.onBeforeShadow( renderer, object, camera, shadowCamera, geometry, depthMaterial, null );
|
|
22464
22613
|
|
|
22465
|
-
|
|
22614
|
+
renderer.renderBufferDirect( shadowCamera, null, geometry, depthMaterial, object, null );
|
|
22466
22615
|
|
|
22467
|
-
object.onAfterShadow(
|
|
22616
|
+
object.onAfterShadow( renderer, object, camera, shadowCamera, geometry, depthMaterial, null );
|
|
22468
22617
|
|
|
22469
22618
|
}
|
|
22470
22619
|
|
|
@@ -23976,6 +24125,48 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
23976
24125
|
|
|
23977
24126
|
}
|
|
23978
24127
|
|
|
24128
|
+
function getInternalDepthFormat( useStencil, depthType ) {
|
|
24129
|
+
|
|
24130
|
+
let glInternalFormat;
|
|
24131
|
+
if ( useStencil ) {
|
|
24132
|
+
|
|
24133
|
+
if ( depthType === null || depthType === UnsignedIntType || depthType === UnsignedInt248Type ) {
|
|
24134
|
+
|
|
24135
|
+
glInternalFormat = _gl.DEPTH24_STENCIL8;
|
|
24136
|
+
|
|
24137
|
+
} else if ( depthType === FloatType ) {
|
|
24138
|
+
|
|
24139
|
+
glInternalFormat = _gl.DEPTH32F_STENCIL8;
|
|
24140
|
+
|
|
24141
|
+
} else if ( depthType === UnsignedShortType ) {
|
|
24142
|
+
|
|
24143
|
+
glInternalFormat = _gl.DEPTH24_STENCIL8;
|
|
24144
|
+
console.warn( 'DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.' );
|
|
24145
|
+
|
|
24146
|
+
}
|
|
24147
|
+
|
|
24148
|
+
} else {
|
|
24149
|
+
|
|
24150
|
+
if ( depthType === null || depthType === UnsignedIntType || depthType === UnsignedInt248Type ) {
|
|
24151
|
+
|
|
24152
|
+
glInternalFormat = _gl.DEPTH_COMPONENT24;
|
|
24153
|
+
|
|
24154
|
+
} else if ( depthType === FloatType ) {
|
|
24155
|
+
|
|
24156
|
+
glInternalFormat = _gl.DEPTH_COMPONENT32F;
|
|
24157
|
+
|
|
24158
|
+
} else if ( depthType === UnsignedShortType ) {
|
|
24159
|
+
|
|
24160
|
+
glInternalFormat = _gl.DEPTH_COMPONENT16;
|
|
24161
|
+
|
|
24162
|
+
}
|
|
24163
|
+
|
|
24164
|
+
}
|
|
24165
|
+
|
|
24166
|
+
return glInternalFormat;
|
|
24167
|
+
|
|
24168
|
+
}
|
|
24169
|
+
|
|
23979
24170
|
function getMipLevels( texture, image ) {
|
|
23980
24171
|
|
|
23981
24172
|
if ( textureNeedsGenerateMipmaps( texture ) === true || ( texture.isFramebufferTexture && texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter ) ) {
|
|
@@ -24523,30 +24714,14 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
24523
24714
|
let mipmap;
|
|
24524
24715
|
const mipmaps = texture.mipmaps;
|
|
24525
24716
|
|
|
24526
|
-
const useTexStorage = ( texture.isVideoTexture !== true
|
|
24717
|
+
const useTexStorage = ( texture.isVideoTexture !== true );
|
|
24527
24718
|
const allocateMemory = ( sourceProperties.__version === undefined ) || ( forceUpload === true );
|
|
24528
24719
|
const dataReady = source.dataReady;
|
|
24529
24720
|
const levels = getMipLevels( texture, image );
|
|
24530
24721
|
|
|
24531
24722
|
if ( texture.isDepthTexture ) {
|
|
24532
24723
|
|
|
24533
|
-
|
|
24534
|
-
|
|
24535
|
-
glInternalFormat = _gl.DEPTH_COMPONENT16;
|
|
24536
|
-
|
|
24537
|
-
if ( texture.type === FloatType ) {
|
|
24538
|
-
|
|
24539
|
-
glInternalFormat = _gl.DEPTH_COMPONENT32F;
|
|
24540
|
-
|
|
24541
|
-
} else if ( texture.type === UnsignedIntType ) {
|
|
24542
|
-
|
|
24543
|
-
glInternalFormat = _gl.DEPTH_COMPONENT24;
|
|
24544
|
-
|
|
24545
|
-
} else if ( texture.type === UnsignedInt248Type ) {
|
|
24546
|
-
|
|
24547
|
-
glInternalFormat = _gl.DEPTH24_STENCIL8;
|
|
24548
|
-
|
|
24549
|
-
}
|
|
24724
|
+
glInternalFormat = getInternalDepthFormat( texture.format === DepthStencilFormat, texture.type );
|
|
24550
24725
|
|
|
24551
24726
|
//
|
|
24552
24727
|
|
|
@@ -24646,7 +24821,22 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
24646
24821
|
|
|
24647
24822
|
if ( dataReady ) {
|
|
24648
24823
|
|
|
24649
|
-
|
|
24824
|
+
if ( texture.layerUpdates.size > 0 ) {
|
|
24825
|
+
|
|
24826
|
+
for ( const layerIndex of texture.layerUpdates ) {
|
|
24827
|
+
|
|
24828
|
+
const layerSize = mipmap.width * mipmap.height;
|
|
24829
|
+
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 );
|
|
24830
|
+
|
|
24831
|
+
}
|
|
24832
|
+
|
|
24833
|
+
texture.clearLayerUpdates();
|
|
24834
|
+
|
|
24835
|
+
} else {
|
|
24836
|
+
|
|
24837
|
+
state.compressedTexSubImage3D( _gl.TEXTURE_2D_ARRAY, i, 0, 0, 0, mipmap.width, mipmap.height, image.depth, glFormat, mipmap.data, 0, 0 );
|
|
24838
|
+
|
|
24839
|
+
}
|
|
24650
24840
|
|
|
24651
24841
|
}
|
|
24652
24842
|
|
|
@@ -24752,7 +24942,72 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
24752
24942
|
|
|
24753
24943
|
if ( dataReady ) {
|
|
24754
24944
|
|
|
24755
|
-
|
|
24945
|
+
if ( texture.layerUpdates.size > 0 ) {
|
|
24946
|
+
|
|
24947
|
+
// When type is GL_UNSIGNED_BYTE, each of these bytes is
|
|
24948
|
+
// interpreted as one color component, depending on format. When
|
|
24949
|
+
// type is one of GL_UNSIGNED_SHORT_5_6_5,
|
|
24950
|
+
// GL_UNSIGNED_SHORT_4_4_4_4, GL_UNSIGNED_SHORT_5_5_5_1, each
|
|
24951
|
+
// unsigned value is interpreted as containing all the components
|
|
24952
|
+
// for a single pixel, with the color components arranged
|
|
24953
|
+
// according to format.
|
|
24954
|
+
//
|
|
24955
|
+
// See https://registry.khronos.org/OpenGL-Refpages/es1.1/xhtml/glTexImage2D.xml
|
|
24956
|
+
let texelSize;
|
|
24957
|
+
switch ( glType ) {
|
|
24958
|
+
|
|
24959
|
+
case _gl.UNSIGNED_BYTE:
|
|
24960
|
+
switch ( glFormat ) {
|
|
24961
|
+
|
|
24962
|
+
case _gl.ALPHA:
|
|
24963
|
+
texelSize = 1;
|
|
24964
|
+
break;
|
|
24965
|
+
case _gl.LUMINANCE:
|
|
24966
|
+
texelSize = 1;
|
|
24967
|
+
break;
|
|
24968
|
+
case _gl.LUMINANCE_ALPHA:
|
|
24969
|
+
texelSize = 2;
|
|
24970
|
+
break;
|
|
24971
|
+
case _gl.RGB:
|
|
24972
|
+
texelSize = 3;
|
|
24973
|
+
break;
|
|
24974
|
+
case _gl.RGBA:
|
|
24975
|
+
texelSize = 4;
|
|
24976
|
+
break;
|
|
24977
|
+
|
|
24978
|
+
default:
|
|
24979
|
+
throw new Error( `Unknown texel size for format ${glFormat}.` );
|
|
24980
|
+
|
|
24981
|
+
}
|
|
24982
|
+
|
|
24983
|
+
break;
|
|
24984
|
+
|
|
24985
|
+
case _gl.UNSIGNED_SHORT_4_4_4_4:
|
|
24986
|
+
case _gl.UNSIGNED_SHORT_5_5_5_1:
|
|
24987
|
+
case _gl.UNSIGNED_SHORT_5_6_5:
|
|
24988
|
+
texelSize = 1;
|
|
24989
|
+
break;
|
|
24990
|
+
|
|
24991
|
+
default:
|
|
24992
|
+
throw new Error( `Unknown texel size for type ${glType}.` );
|
|
24993
|
+
|
|
24994
|
+
}
|
|
24995
|
+
|
|
24996
|
+
const layerSize = image.width * image.height * texelSize;
|
|
24997
|
+
|
|
24998
|
+
for ( const layerIndex of texture.layerUpdates ) {
|
|
24999
|
+
|
|
25000
|
+
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 ) ) );
|
|
25001
|
+
|
|
25002
|
+
}
|
|
25003
|
+
|
|
25004
|
+
texture.clearLayerUpdates();
|
|
25005
|
+
|
|
25006
|
+
} else {
|
|
25007
|
+
|
|
25008
|
+
state.texSubImage3D( _gl.TEXTURE_2D_ARRAY, 0, 0, 0, 0, image.width, image.height, image.depth, glFormat, glType, image.data );
|
|
25009
|
+
|
|
25010
|
+
}
|
|
24756
25011
|
|
|
24757
25012
|
}
|
|
24758
25013
|
|
|
@@ -25196,7 +25451,6 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
25196
25451
|
|
|
25197
25452
|
}
|
|
25198
25453
|
|
|
25199
|
-
|
|
25200
25454
|
// Setup storage for internal depth/stencil buffers and bind to correct framebuffer
|
|
25201
25455
|
function setupRenderBufferStorage( renderbuffer, renderTarget, isMultisample ) {
|
|
25202
25456
|
|
|
@@ -25256,66 +25510,30 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
25256
25510
|
|
|
25257
25511
|
} else if ( renderTarget.depthBuffer && ! renderTarget.stencilBuffer ) {
|
|
25258
25512
|
|
|
25259
|
-
|
|
25260
|
-
|
|
25261
|
-
|
|
25262
|
-
|
|
25263
|
-
|
|
25264
|
-
|
|
25265
|
-
if ( depthTexture && depthTexture.isDepthTexture ) {
|
|
25266
|
-
|
|
25267
|
-
if ( depthTexture.type === FloatType ) {
|
|
25268
|
-
|
|
25269
|
-
glInternalFormat = _gl.DEPTH_COMPONENT32F;
|
|
25270
|
-
|
|
25271
|
-
} else if ( depthTexture.type === UnsignedIntType ) {
|
|
25272
|
-
|
|
25273
|
-
glInternalFormat = _gl.DEPTH_COMPONENT24;
|
|
25274
|
-
|
|
25275
|
-
}
|
|
25276
|
-
|
|
25277
|
-
}
|
|
25278
|
-
|
|
25279
|
-
const samples = getRenderTargetSamples( renderTarget );
|
|
25280
|
-
|
|
25281
|
-
if ( useMultisampledRTT( renderTarget ) ) {
|
|
25282
|
-
|
|
25283
|
-
multisampledRTTExt.renderbufferStorageMultisampleEXT( _gl.RENDERBUFFER, samples, glInternalFormat, renderTarget.width, renderTarget.height );
|
|
25284
|
-
|
|
25285
|
-
} else {
|
|
25286
|
-
|
|
25287
|
-
_gl.renderbufferStorageMultisample( _gl.RENDERBUFFER, samples, glInternalFormat, renderTarget.width, renderTarget.height );
|
|
25288
|
-
|
|
25289
|
-
}
|
|
25290
|
-
|
|
25291
|
-
} else {
|
|
25292
|
-
|
|
25293
|
-
_gl.renderbufferStorage( _gl.RENDERBUFFER, glInternalFormat, renderTarget.width, renderTarget.height );
|
|
25294
|
-
|
|
25295
|
-
}
|
|
25296
|
-
|
|
25297
|
-
_gl.framebufferRenderbuffer( _gl.FRAMEBUFFER, _gl.DEPTH_ATTACHMENT, _gl.RENDERBUFFER, renderbuffer );
|
|
25298
|
-
|
|
25299
|
-
} else if ( renderTarget.depthBuffer && renderTarget.stencilBuffer ) {
|
|
25513
|
+
// retrieve the depth attachment types
|
|
25514
|
+
const depthTexture = renderTarget.depthTexture;
|
|
25515
|
+
const depthType = depthTexture && depthTexture.isDepthTexture ? depthTexture.type : null;
|
|
25516
|
+
const glInternalFormat = getInternalDepthFormat( renderTarget.stencilBuffer, depthType );
|
|
25517
|
+
const glAttachmentType = renderTarget.stencilBuffer ? _gl.DEPTH_STENCIL_ATTACHMENT : _gl.DEPTH_ATTACHMENT;
|
|
25300
25518
|
|
|
25519
|
+
// set up the attachment
|
|
25301
25520
|
const samples = getRenderTargetSamples( renderTarget );
|
|
25521
|
+
const isUseMultisampledRTT = useMultisampledRTT( renderTarget );
|
|
25522
|
+
if ( isUseMultisampledRTT ) {
|
|
25302
25523
|
|
|
25303
|
-
|
|
25304
|
-
|
|
25305
|
-
_gl.renderbufferStorageMultisample( _gl.RENDERBUFFER, samples, _gl.DEPTH24_STENCIL8, renderTarget.width, renderTarget.height );
|
|
25524
|
+
multisampledRTTExt.renderbufferStorageMultisampleEXT( _gl.RENDERBUFFER, samples, glInternalFormat, renderTarget.width, renderTarget.height );
|
|
25306
25525
|
|
|
25307
|
-
} else if (
|
|
25526
|
+
} else if ( isMultisample ) {
|
|
25308
25527
|
|
|
25309
|
-
|
|
25528
|
+
_gl.renderbufferStorageMultisample( _gl.RENDERBUFFER, samples, glInternalFormat, renderTarget.width, renderTarget.height );
|
|
25310
25529
|
|
|
25311
25530
|
} else {
|
|
25312
25531
|
|
|
25313
|
-
_gl.renderbufferStorage( _gl.RENDERBUFFER,
|
|
25532
|
+
_gl.renderbufferStorage( _gl.RENDERBUFFER, glInternalFormat, renderTarget.width, renderTarget.height );
|
|
25314
25533
|
|
|
25315
25534
|
}
|
|
25316
25535
|
|
|
25317
|
-
|
|
25318
|
-
_gl.framebufferRenderbuffer( _gl.FRAMEBUFFER, _gl.DEPTH_STENCIL_ATTACHMENT, _gl.RENDERBUFFER, renderbuffer );
|
|
25536
|
+
_gl.framebufferRenderbuffer( _gl.FRAMEBUFFER, glAttachmentType, _gl.RENDERBUFFER, renderbuffer );
|
|
25319
25537
|
|
|
25320
25538
|
} else {
|
|
25321
25539
|
|
|
@@ -25780,112 +25998,120 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
25780
25998
|
|
|
25781
25999
|
}
|
|
25782
26000
|
|
|
26001
|
+
const invalidationArrayRead = [];
|
|
26002
|
+
const invalidationArrayDraw = [];
|
|
26003
|
+
|
|
25783
26004
|
function updateMultisampleRenderTarget( renderTarget ) {
|
|
25784
26005
|
|
|
25785
|
-
if (
|
|
26006
|
+
if ( renderTarget.samples > 0 ) {
|
|
25786
26007
|
|
|
25787
|
-
|
|
25788
|
-
const width = renderTarget.width;
|
|
25789
|
-
const height = renderTarget.height;
|
|
25790
|
-
let mask = _gl.COLOR_BUFFER_BIT;
|
|
25791
|
-
const invalidationArray = [];
|
|
25792
|
-
const depthStyle = renderTarget.stencilBuffer ? _gl.DEPTH_STENCIL_ATTACHMENT : _gl.DEPTH_ATTACHMENT;
|
|
25793
|
-
const renderTargetProperties = properties.get( renderTarget );
|
|
25794
|
-
const isMultipleRenderTargets = ( textures.length > 1 );
|
|
26008
|
+
if ( useMultisampledRTT( renderTarget ) === false ) {
|
|
25795
26009
|
|
|
25796
|
-
|
|
25797
|
-
|
|
26010
|
+
const textures = renderTarget.textures;
|
|
26011
|
+
const width = renderTarget.width;
|
|
26012
|
+
const height = renderTarget.height;
|
|
26013
|
+
let mask = _gl.COLOR_BUFFER_BIT;
|
|
26014
|
+
const depthStyle = renderTarget.stencilBuffer ? _gl.DEPTH_STENCIL_ATTACHMENT : _gl.DEPTH_ATTACHMENT;
|
|
26015
|
+
const renderTargetProperties = properties.get( renderTarget );
|
|
26016
|
+
const isMultipleRenderTargets = ( textures.length > 1 );
|
|
25798
26017
|
|
|
25799
|
-
|
|
26018
|
+
// If MRT we need to remove FBO attachments
|
|
26019
|
+
if ( isMultipleRenderTargets ) {
|
|
26020
|
+
|
|
26021
|
+
for ( let i = 0; i < textures.length; i ++ ) {
|
|
26022
|
+
|
|
26023
|
+
state.bindFramebuffer( _gl.FRAMEBUFFER, renderTargetProperties.__webglMultisampledFramebuffer );
|
|
26024
|
+
_gl.framebufferRenderbuffer( _gl.FRAMEBUFFER, _gl.COLOR_ATTACHMENT0 + i, _gl.RENDERBUFFER, null );
|
|
25800
26025
|
|
|
25801
|
-
|
|
25802
|
-
|
|
26026
|
+
state.bindFramebuffer( _gl.FRAMEBUFFER, renderTargetProperties.__webglFramebuffer );
|
|
26027
|
+
_gl.framebufferTexture2D( _gl.DRAW_FRAMEBUFFER, _gl.COLOR_ATTACHMENT0 + i, _gl.TEXTURE_2D, null, 0 );
|
|
25803
26028
|
|
|
25804
|
-
|
|
25805
|
-
_gl.framebufferTexture2D( _gl.DRAW_FRAMEBUFFER, _gl.COLOR_ATTACHMENT0 + i, _gl.TEXTURE_2D, null, 0 );
|
|
26029
|
+
}
|
|
25806
26030
|
|
|
25807
26031
|
}
|
|
25808
26032
|
|
|
25809
|
-
|
|
26033
|
+
state.bindFramebuffer( _gl.READ_FRAMEBUFFER, renderTargetProperties.__webglMultisampledFramebuffer );
|
|
26034
|
+
state.bindFramebuffer( _gl.DRAW_FRAMEBUFFER, renderTargetProperties.__webglFramebuffer );
|
|
25810
26035
|
|
|
25811
|
-
|
|
25812
|
-
state.bindFramebuffer( _gl.DRAW_FRAMEBUFFER, renderTargetProperties.__webglFramebuffer );
|
|
26036
|
+
for ( let i = 0; i < textures.length; i ++ ) {
|
|
25813
26037
|
|
|
25814
|
-
|
|
26038
|
+
if ( renderTarget.resolveDepthBuffer ) {
|
|
25815
26039
|
|
|
25816
|
-
|
|
26040
|
+
if ( renderTarget.depthBuffer ) mask |= _gl.DEPTH_BUFFER_BIT;
|
|
25817
26041
|
|
|
25818
|
-
|
|
26042
|
+
// resolving stencil is slow with a D3D backend. disable it for all transmission render targets (see #27799)
|
|
25819
26043
|
|
|
25820
|
-
|
|
26044
|
+
if ( renderTarget.stencilBuffer && renderTarget.resolveStencilBuffer ) mask |= _gl.STENCIL_BUFFER_BIT;
|
|
25821
26045
|
|
|
25822
|
-
|
|
26046
|
+
}
|
|
25823
26047
|
|
|
25824
|
-
|
|
26048
|
+
if ( isMultipleRenderTargets ) {
|
|
25825
26049
|
|
|
25826
|
-
|
|
26050
|
+
_gl.framebufferRenderbuffer( _gl.READ_FRAMEBUFFER, _gl.COLOR_ATTACHMENT0, _gl.RENDERBUFFER, renderTargetProperties.__webglColorRenderbuffer[ i ] );
|
|
25827
26051
|
|
|
25828
|
-
|
|
26052
|
+
const webglTexture = properties.get( textures[ i ] ).__webglTexture;
|
|
26053
|
+
_gl.framebufferTexture2D( _gl.DRAW_FRAMEBUFFER, _gl.COLOR_ATTACHMENT0, _gl.TEXTURE_2D, webglTexture, 0 );
|
|
25829
26054
|
|
|
25830
|
-
|
|
26055
|
+
}
|
|
25831
26056
|
|
|
25832
|
-
|
|
26057
|
+
_gl.blitFramebuffer( 0, 0, width, height, 0, 0, width, height, mask, _gl.NEAREST );
|
|
25833
26058
|
|
|
25834
|
-
|
|
26059
|
+
if ( supportsInvalidateFramebuffer === true ) {
|
|
25835
26060
|
|
|
25836
|
-
|
|
26061
|
+
invalidationArrayRead.length = 0;
|
|
26062
|
+
invalidationArrayDraw.length = 0;
|
|
25837
26063
|
|
|
25838
|
-
|
|
26064
|
+
invalidationArrayRead.push( _gl.COLOR_ATTACHMENT0 + i );
|
|
25839
26065
|
|
|
25840
|
-
|
|
26066
|
+
if ( renderTarget.depthBuffer && renderTarget.resolveDepthBuffer === false ) {
|
|
25841
26067
|
|
|
25842
|
-
|
|
26068
|
+
invalidationArrayRead.push( depthStyle );
|
|
26069
|
+
invalidationArrayDraw.push( depthStyle );
|
|
25843
26070
|
|
|
25844
|
-
|
|
25845
|
-
_gl.invalidateFramebuffer( _gl.DRAW_FRAMEBUFFER, [ depthStyle ] );
|
|
26071
|
+
_gl.invalidateFramebuffer( _gl.DRAW_FRAMEBUFFER, invalidationArrayDraw );
|
|
25846
26072
|
|
|
25847
|
-
|
|
26073
|
+
}
|
|
25848
26074
|
|
|
25849
|
-
|
|
26075
|
+
_gl.invalidateFramebuffer( _gl.READ_FRAMEBUFFER, invalidationArrayRead );
|
|
25850
26076
|
|
|
25851
|
-
|
|
25852
|
-
_gl.framebufferTexture2D( _gl.DRAW_FRAMEBUFFER, _gl.COLOR_ATTACHMENT0, _gl.TEXTURE_2D, webglTexture, 0 );
|
|
26077
|
+
}
|
|
25853
26078
|
|
|
25854
26079
|
}
|
|
25855
26080
|
|
|
25856
|
-
|
|
26081
|
+
state.bindFramebuffer( _gl.READ_FRAMEBUFFER, null );
|
|
26082
|
+
state.bindFramebuffer( _gl.DRAW_FRAMEBUFFER, null );
|
|
25857
26083
|
|
|
25858
|
-
|
|
26084
|
+
// If MRT since pre-blit we removed the FBO we need to reconstruct the attachments
|
|
26085
|
+
if ( isMultipleRenderTargets ) {
|
|
25859
26086
|
|
|
25860
|
-
|
|
26087
|
+
for ( let i = 0; i < textures.length; i ++ ) {
|
|
25861
26088
|
|
|
25862
|
-
|
|
26089
|
+
state.bindFramebuffer( _gl.FRAMEBUFFER, renderTargetProperties.__webglMultisampledFramebuffer );
|
|
26090
|
+
_gl.framebufferRenderbuffer( _gl.FRAMEBUFFER, _gl.COLOR_ATTACHMENT0 + i, _gl.RENDERBUFFER, renderTargetProperties.__webglColorRenderbuffer[ i ] );
|
|
25863
26091
|
|
|
26092
|
+
const webglTexture = properties.get( textures[ i ] ).__webglTexture;
|
|
25864
26093
|
|
|
25865
|
-
|
|
26094
|
+
state.bindFramebuffer( _gl.FRAMEBUFFER, renderTargetProperties.__webglFramebuffer );
|
|
26095
|
+
_gl.framebufferTexture2D( _gl.DRAW_FRAMEBUFFER, _gl.COLOR_ATTACHMENT0 + i, _gl.TEXTURE_2D, webglTexture, 0 );
|
|
25866
26096
|
|
|
25867
|
-
|
|
25868
|
-
state.bindFramebuffer( _gl.DRAW_FRAMEBUFFER, null );
|
|
26097
|
+
}
|
|
25869
26098
|
|
|
25870
|
-
|
|
25871
|
-
if ( isMultipleRenderTargets ) {
|
|
26099
|
+
}
|
|
25872
26100
|
|
|
25873
|
-
|
|
26101
|
+
state.bindFramebuffer( _gl.DRAW_FRAMEBUFFER, renderTargetProperties.__webglMultisampledFramebuffer );
|
|
25874
26102
|
|
|
25875
|
-
|
|
25876
|
-
|
|
26103
|
+
} else {
|
|
26104
|
+
|
|
26105
|
+
if ( renderTarget.depthBuffer && renderTarget.resolveDepthBuffer === false && supportsInvalidateFramebuffer ) {
|
|
25877
26106
|
|
|
25878
|
-
const
|
|
26107
|
+
const depthStyle = renderTarget.stencilBuffer ? _gl.DEPTH_STENCIL_ATTACHMENT : _gl.DEPTH_ATTACHMENT;
|
|
25879
26108
|
|
|
25880
|
-
|
|
25881
|
-
_gl.framebufferTexture2D( _gl.DRAW_FRAMEBUFFER, _gl.COLOR_ATTACHMENT0 + i, _gl.TEXTURE_2D, webglTexture, 0 );
|
|
26109
|
+
_gl.invalidateFramebuffer( _gl.DRAW_FRAMEBUFFER, [ depthStyle ] );
|
|
25882
26110
|
|
|
25883
26111
|
}
|
|
25884
26112
|
|
|
25885
26113
|
}
|
|
25886
26114
|
|
|
25887
|
-
state.bindFramebuffer( _gl.DRAW_FRAMEBUFFER, renderTargetProperties.__webglMultisampledFramebuffer );
|
|
25888
|
-
|
|
25889
26115
|
}
|
|
25890
26116
|
|
|
25891
26117
|
}
|
|
@@ -26101,33 +26327,15 @@ function WebGLUtils( gl, extensions ) {
|
|
|
26101
26327
|
|
|
26102
26328
|
}
|
|
26103
26329
|
|
|
26104
|
-
//
|
|
26105
|
-
|
|
26106
|
-
if ( p === RGB_ETC1_Format ) {
|
|
26107
|
-
|
|
26108
|
-
extension = extensions.get( 'WEBGL_compressed_texture_etc1' );
|
|
26109
|
-
|
|
26110
|
-
if ( extension !== null ) {
|
|
26111
|
-
|
|
26112
|
-
return extension.COMPRESSED_RGB_ETC1_WEBGL;
|
|
26113
|
-
|
|
26114
|
-
} else {
|
|
26115
|
-
|
|
26116
|
-
return null;
|
|
26117
|
-
|
|
26118
|
-
}
|
|
26119
|
-
|
|
26120
|
-
}
|
|
26330
|
+
// ETC
|
|
26121
26331
|
|
|
26122
|
-
|
|
26123
|
-
|
|
26124
|
-
if ( p === RGB_ETC2_Format || p === RGBA_ETC2_EAC_Format ) {
|
|
26332
|
+
if ( p === RGB_ETC1_Format || p === RGB_ETC2_Format || p === RGBA_ETC2_EAC_Format ) {
|
|
26125
26333
|
|
|
26126
26334
|
extension = extensions.get( 'WEBGL_compressed_texture_etc' );
|
|
26127
26335
|
|
|
26128
26336
|
if ( extension !== null ) {
|
|
26129
26337
|
|
|
26130
|
-
if ( p === RGB_ETC2_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB8_ETC2 : extension.COMPRESSED_RGB8_ETC2;
|
|
26338
|
+
if ( p === RGB_ETC1_Format || p === RGB_ETC2_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB8_ETC2 : extension.COMPRESSED_RGB8_ETC2;
|
|
26131
26339
|
if ( p === RGBA_ETC2_EAC_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC : extension.COMPRESSED_RGBA8_ETC2_EAC;
|
|
26132
26340
|
|
|
26133
26341
|
} else {
|
|
@@ -27236,7 +27444,7 @@ class WebXRDepthSensing {
|
|
|
27236
27444
|
|
|
27237
27445
|
}
|
|
27238
27446
|
|
|
27239
|
-
|
|
27447
|
+
getMesh( cameraXR ) {
|
|
27240
27448
|
|
|
27241
27449
|
if ( this.texture !== null ) {
|
|
27242
27450
|
|
|
@@ -27257,10 +27465,10 @@ class WebXRDepthSensing {
|
|
|
27257
27465
|
|
|
27258
27466
|
}
|
|
27259
27467
|
|
|
27260
|
-
renderer.render( this.mesh, cameraXR );
|
|
27261
|
-
|
|
27262
27468
|
}
|
|
27263
27469
|
|
|
27470
|
+
return this.mesh;
|
|
27471
|
+
|
|
27264
27472
|
}
|
|
27265
27473
|
|
|
27266
27474
|
reset() {
|
|
@@ -27620,7 +27828,8 @@ class WebXRManager extends EventDispatcher {
|
|
|
27620
27828
|
depthTexture: new DepthTexture( glProjLayer.textureWidth, glProjLayer.textureHeight, depthType, undefined, undefined, undefined, undefined, undefined, undefined, depthFormat ),
|
|
27621
27829
|
stencilBuffer: attributes.stencil,
|
|
27622
27830
|
colorSpace: renderer.outputColorSpace,
|
|
27623
|
-
samples: attributes.antialias ? 4 : 0
|
|
27831
|
+
samples: attributes.antialias ? 4 : 0,
|
|
27832
|
+
resolveDepthBuffer: ( glProjLayer.ignoreDepthValues === false )
|
|
27624
27833
|
};
|
|
27625
27834
|
|
|
27626
27835
|
if ( scope.isMultiview ) {
|
|
@@ -27640,9 +27849,6 @@ class WebXRManager extends EventDispatcher {
|
|
|
27640
27849
|
|
|
27641
27850
|
}
|
|
27642
27851
|
|
|
27643
|
-
const renderTargetProperties = renderer.properties.get( newRenderTarget );
|
|
27644
|
-
renderTargetProperties.__ignoreDepthValues = glProjLayer.ignoreDepthValues;
|
|
27645
|
-
|
|
27646
27852
|
}
|
|
27647
27853
|
|
|
27648
27854
|
newRenderTarget.isXRRenderTarget = true; // TODO Remove this when possible, see #23278
|
|
@@ -27986,6 +28192,12 @@ class WebXRManager extends EventDispatcher {
|
|
|
27986
28192
|
|
|
27987
28193
|
};
|
|
27988
28194
|
|
|
28195
|
+
this.getDepthSensingMesh = function () {
|
|
28196
|
+
|
|
28197
|
+
return depthSensing.getMesh( cameraXR );
|
|
28198
|
+
|
|
28199
|
+
};
|
|
28200
|
+
|
|
27989
28201
|
// Animation Loop
|
|
27990
28202
|
|
|
27991
28203
|
let onAnimationFrameCallback = null;
|
|
@@ -28111,8 +28323,6 @@ class WebXRManager extends EventDispatcher {
|
|
|
28111
28323
|
|
|
28112
28324
|
}
|
|
28113
28325
|
|
|
28114
|
-
depthSensing.render( renderer, cameraXR );
|
|
28115
|
-
|
|
28116
28326
|
if ( onAnimationFrameCallback ) onAnimationFrameCallback( time, frame );
|
|
28117
28327
|
|
|
28118
28328
|
if ( frame.detectedPlanes ) {
|
|
@@ -28387,11 +28597,7 @@ function WebGLMaterials( renderer, properties ) {
|
|
|
28387
28597
|
if ( material.lightMap ) {
|
|
28388
28598
|
|
|
28389
28599
|
uniforms.lightMap.value = material.lightMap;
|
|
28390
|
-
|
|
28391
|
-
// artist-friendly light intensity scaling factor
|
|
28392
|
-
const scaleFactor = ( renderer._useLegacyLights === true ) ? Math.PI : 1;
|
|
28393
|
-
|
|
28394
|
-
uniforms.lightMapIntensity.value = material.lightMapIntensity * scaleFactor;
|
|
28600
|
+
uniforms.lightMapIntensity.value = material.lightMapIntensity;
|
|
28395
28601
|
|
|
28396
28602
|
refreshTransformUniform( material.lightMap, uniforms.lightMapTransform );
|
|
28397
28603
|
|
|
@@ -28608,6 +28814,12 @@ function WebGLMaterials( renderer, properties ) {
|
|
|
28608
28814
|
|
|
28609
28815
|
}
|
|
28610
28816
|
|
|
28817
|
+
if ( material.dispersion > 0 ) {
|
|
28818
|
+
|
|
28819
|
+
uniforms.dispersion.value = material.dispersion;
|
|
28820
|
+
|
|
28821
|
+
}
|
|
28822
|
+
|
|
28611
28823
|
if ( material.iridescence > 0 ) {
|
|
28612
28824
|
|
|
28613
28825
|
uniforms.iridescence.value = material.iridescence;
|
|
@@ -29203,10 +29415,6 @@ class WebGLRenderer {
|
|
|
29203
29415
|
|
|
29204
29416
|
this._outputColorSpace = SRGBColorSpace;
|
|
29205
29417
|
|
|
29206
|
-
// physical lights
|
|
29207
|
-
|
|
29208
|
-
this._useLegacyLights = false;
|
|
29209
|
-
|
|
29210
29418
|
// tone mapping
|
|
29211
29419
|
|
|
29212
29420
|
this.toneMapping = NoToneMapping;
|
|
@@ -29260,11 +29468,12 @@ class WebGLRenderer {
|
|
|
29260
29468
|
|
|
29261
29469
|
const _projScreenMatrix = new Matrix4();
|
|
29262
29470
|
|
|
29263
|
-
const _vector2 = new Vector2();
|
|
29264
29471
|
const _vector3 = new Vector3();
|
|
29265
29472
|
|
|
29266
29473
|
const _emptyScene = { background: null, fog: null, environment: null, overrideMaterial: null, isScene: true };
|
|
29267
29474
|
|
|
29475
|
+
let _renderBackground = false;
|
|
29476
|
+
|
|
29268
29477
|
function getTargetPixelRatio() {
|
|
29269
29478
|
|
|
29270
29479
|
return _currentRenderTarget === null ? _pixelRatio : 1;
|
|
@@ -29277,10 +29486,7 @@ class WebGLRenderer {
|
|
|
29277
29486
|
|
|
29278
29487
|
function getContext( contextName, contextAttributes ) {
|
|
29279
29488
|
|
|
29280
|
-
|
|
29281
|
-
if ( context !== null ) return context;
|
|
29282
|
-
|
|
29283
|
-
return null;
|
|
29489
|
+
return canvas.getContext( contextName, contextAttributes );
|
|
29284
29490
|
|
|
29285
29491
|
}
|
|
29286
29492
|
|
|
@@ -29348,10 +29554,10 @@ class WebGLRenderer {
|
|
|
29348
29554
|
extensions = new WebGLExtensions( _gl );
|
|
29349
29555
|
extensions.init();
|
|
29350
29556
|
|
|
29351
|
-
capabilities = new WebGLCapabilities( _gl, extensions, parameters );
|
|
29352
|
-
|
|
29353
29557
|
utils = new WebGLUtils( _gl, extensions );
|
|
29354
29558
|
|
|
29559
|
+
capabilities = new WebGLCapabilities( _gl, extensions, parameters, utils );
|
|
29560
|
+
|
|
29355
29561
|
state = new WebGLState( _gl );
|
|
29356
29562
|
|
|
29357
29563
|
info = new WebGLInfo( _gl );
|
|
@@ -29917,7 +30123,15 @@ class WebGLRenderer {
|
|
|
29917
30123
|
|
|
29918
30124
|
if ( object.isBatchedMesh ) {
|
|
29919
30125
|
|
|
29920
|
-
|
|
30126
|
+
if ( object._multiDrawInstances !== null ) {
|
|
30127
|
+
|
|
30128
|
+
renderer.renderMultiDrawInstances( object._multiDrawStarts, object._multiDrawCounts, object._multiDrawCount, object._multiDrawInstances );
|
|
30129
|
+
|
|
30130
|
+
} else {
|
|
30131
|
+
|
|
30132
|
+
renderer.renderMultiDraw( object._multiDrawStarts, object._multiDrawCounts, object._multiDrawCount );
|
|
30133
|
+
|
|
30134
|
+
}
|
|
29921
30135
|
|
|
29922
30136
|
} else if ( object.isInstancedMesh ) {
|
|
29923
30137
|
|
|
@@ -29967,7 +30181,7 @@ class WebGLRenderer {
|
|
|
29967
30181
|
if ( targetScene === null ) targetScene = scene;
|
|
29968
30182
|
|
|
29969
30183
|
currentRenderState = renderStates.get( targetScene );
|
|
29970
|
-
currentRenderState.init();
|
|
30184
|
+
currentRenderState.init( camera );
|
|
29971
30185
|
|
|
29972
30186
|
renderStateStack.push( currentRenderState );
|
|
29973
30187
|
|
|
@@ -30009,7 +30223,7 @@ class WebGLRenderer {
|
|
|
30009
30223
|
|
|
30010
30224
|
}
|
|
30011
30225
|
|
|
30012
|
-
currentRenderState.setupLights(
|
|
30226
|
+
currentRenderState.setupLights();
|
|
30013
30227
|
|
|
30014
30228
|
// Only initialize materials in the new scene, not the targetScene.
|
|
30015
30229
|
|
|
@@ -30184,7 +30398,7 @@ class WebGLRenderer {
|
|
|
30184
30398
|
if ( scene.isScene === true ) scene.onBeforeRender( _this, scene, camera, _currentRenderTarget );
|
|
30185
30399
|
|
|
30186
30400
|
currentRenderState = renderStates.get( scene, renderStateStack.length );
|
|
30187
|
-
currentRenderState.init();
|
|
30401
|
+
currentRenderState.init( camera );
|
|
30188
30402
|
|
|
30189
30403
|
renderStateStack.push( currentRenderState );
|
|
30190
30404
|
|
|
@@ -30199,6 +30413,18 @@ class WebGLRenderer {
|
|
|
30199
30413
|
|
|
30200
30414
|
renderListStack.push( currentRenderList );
|
|
30201
30415
|
|
|
30416
|
+
if ( xr.enabled === true && xr.isPresenting === true ) {
|
|
30417
|
+
|
|
30418
|
+
const depthSensingMesh = _this.xr.getDepthSensingMesh();
|
|
30419
|
+
|
|
30420
|
+
if ( depthSensingMesh !== null ) {
|
|
30421
|
+
|
|
30422
|
+
projectObject( depthSensingMesh, camera, - Infinity, _this.sortObjects );
|
|
30423
|
+
|
|
30424
|
+
}
|
|
30425
|
+
|
|
30426
|
+
}
|
|
30427
|
+
|
|
30202
30428
|
projectObject( scene, camera, 0, _this.sortObjects );
|
|
30203
30429
|
|
|
30204
30430
|
currentRenderList.finish();
|
|
@@ -30209,6 +30435,13 @@ class WebGLRenderer {
|
|
|
30209
30435
|
|
|
30210
30436
|
}
|
|
30211
30437
|
|
|
30438
|
+
_renderBackground = xr.enabled === false || xr.isPresenting === false || xr.hasDepthSensing() === false;
|
|
30439
|
+
if ( _renderBackground ) {
|
|
30440
|
+
|
|
30441
|
+
background.addToRenderList( currentRenderList, scene );
|
|
30442
|
+
|
|
30443
|
+
}
|
|
30444
|
+
|
|
30212
30445
|
//
|
|
30213
30446
|
|
|
30214
30447
|
this.info.render.frame ++;
|
|
@@ -30225,20 +30458,30 @@ class WebGLRenderer {
|
|
|
30225
30458
|
|
|
30226
30459
|
if ( this.info.autoReset === true ) this.info.reset();
|
|
30227
30460
|
|
|
30461
|
+
// render scene
|
|
30228
30462
|
|
|
30229
|
-
|
|
30463
|
+
const opaqueObjects = currentRenderList.opaque;
|
|
30464
|
+
const transmissiveObjects = currentRenderList.transmissive;
|
|
30230
30465
|
|
|
30231
|
-
|
|
30466
|
+
currentRenderState.setupLights();
|
|
30232
30467
|
|
|
30233
|
-
|
|
30468
|
+
if ( camera.isArrayCamera ) {
|
|
30234
30469
|
|
|
30235
|
-
|
|
30470
|
+
const cameras = camera.cameras;
|
|
30236
30471
|
|
|
30237
|
-
|
|
30472
|
+
if ( transmissiveObjects.length > 0 ) {
|
|
30238
30473
|
|
|
30239
|
-
|
|
30474
|
+
for ( let i = 0, l = cameras.length; i < l; i ++ ) {
|
|
30240
30475
|
|
|
30241
|
-
|
|
30476
|
+
const camera2 = cameras[ i ];
|
|
30477
|
+
|
|
30478
|
+
renderTransmissionPass( opaqueObjects, transmissiveObjects, scene, camera2 );
|
|
30479
|
+
|
|
30480
|
+
}
|
|
30481
|
+
|
|
30482
|
+
}
|
|
30483
|
+
|
|
30484
|
+
if ( _renderBackground ) background.render( scene );
|
|
30242
30485
|
|
|
30243
30486
|
if ( xr.enabled && xr.isMultiview ) {
|
|
30244
30487
|
|
|
@@ -30248,8 +30491,6 @@ class WebGLRenderer {
|
|
|
30248
30491
|
|
|
30249
30492
|
} else {
|
|
30250
30493
|
|
|
30251
|
-
const cameras = camera.cameras;
|
|
30252
|
-
|
|
30253
30494
|
for ( let i = 0, l = cameras.length; i < l; i ++ ) {
|
|
30254
30495
|
|
|
30255
30496
|
const camera2 = cameras[ i ];
|
|
@@ -30262,6 +30503,10 @@ class WebGLRenderer {
|
|
|
30262
30503
|
|
|
30263
30504
|
} else {
|
|
30264
30505
|
|
|
30506
|
+
if ( transmissiveObjects.length > 0 ) renderTransmissionPass( opaqueObjects, transmissiveObjects, scene, camera );
|
|
30507
|
+
|
|
30508
|
+
if ( _renderBackground ) background.render( scene );
|
|
30509
|
+
|
|
30265
30510
|
renderScene( currentRenderList, scene, camera );
|
|
30266
30511
|
|
|
30267
30512
|
}
|
|
@@ -30303,6 +30548,8 @@ class WebGLRenderer {
|
|
|
30303
30548
|
|
|
30304
30549
|
currentRenderState = renderStateStack[ renderStateStack.length - 1 ];
|
|
30305
30550
|
|
|
30551
|
+
if ( _clippingEnabled === true ) clipping.setGlobalState( _this.clippingPlanes, currentRenderState.state.camera );
|
|
30552
|
+
|
|
30306
30553
|
} else {
|
|
30307
30554
|
|
|
30308
30555
|
currentRenderState = null;
|
|
@@ -30447,8 +30694,6 @@ class WebGLRenderer {
|
|
|
30447
30694
|
|
|
30448
30695
|
if ( _clippingEnabled === true ) clipping.setGlobalState( _this.clippingPlanes, camera );
|
|
30449
30696
|
|
|
30450
|
-
if ( transmissiveObjects.length > 0 ) renderTransmissionPass( opaqueObjects, transmissiveObjects, scene, camera );
|
|
30451
|
-
|
|
30452
30697
|
if ( viewport ) state.viewport( _currentViewport.copy( viewport ) );
|
|
30453
30698
|
|
|
30454
30699
|
if ( opaqueObjects.length > 0 ) renderObjects( opaqueObjects, scene, camera );
|
|
@@ -30475,19 +30720,19 @@ class WebGLRenderer {
|
|
|
30475
30720
|
|
|
30476
30721
|
}
|
|
30477
30722
|
|
|
30478
|
-
if ( currentRenderState.state.transmissionRenderTarget ===
|
|
30723
|
+
if ( currentRenderState.state.transmissionRenderTarget[ camera.id ] === undefined ) {
|
|
30479
30724
|
|
|
30480
|
-
currentRenderState.state.transmissionRenderTarget = new WebGLRenderTarget( 1, 1, {
|
|
30725
|
+
currentRenderState.state.transmissionRenderTarget[ camera.id ] = new WebGLRenderTarget( 1, 1, {
|
|
30481
30726
|
generateMipmaps: true,
|
|
30482
30727
|
type: ( extensions.has( 'EXT_color_buffer_half_float' ) || extensions.has( 'EXT_color_buffer_float' ) ) ? HalfFloatType : UnsignedByteType,
|
|
30483
30728
|
minFilter: LinearMipmapLinearFilter,
|
|
30484
30729
|
samples: 4,
|
|
30485
|
-
stencilBuffer: stencil
|
|
30730
|
+
stencilBuffer: stencil,
|
|
30731
|
+
resolveDepthBuffer: false,
|
|
30732
|
+
resolveStencilBuffer: false,
|
|
30733
|
+
colorSpace: ColorManagement.workingColorSpace,
|
|
30486
30734
|
} );
|
|
30487
30735
|
|
|
30488
|
-
const renderTargetProperties = properties.get( currentRenderState.state.transmissionRenderTarget );
|
|
30489
|
-
renderTargetProperties.__isTransmissionRenderTarget = true;
|
|
30490
|
-
|
|
30491
30736
|
// debug
|
|
30492
30737
|
|
|
30493
30738
|
/*
|
|
@@ -30500,10 +30745,10 @@ class WebGLRenderer {
|
|
|
30500
30745
|
|
|
30501
30746
|
}
|
|
30502
30747
|
|
|
30503
|
-
const transmissionRenderTarget = currentRenderState.state.transmissionRenderTarget;
|
|
30748
|
+
const transmissionRenderTarget = currentRenderState.state.transmissionRenderTarget[ camera.id ];
|
|
30504
30749
|
|
|
30505
|
-
|
|
30506
|
-
transmissionRenderTarget.setSize(
|
|
30750
|
+
const activeViewport = camera.viewport || _currentViewport;
|
|
30751
|
+
transmissionRenderTarget.setSize( activeViewport.z, activeViewport.w );
|
|
30507
30752
|
|
|
30508
30753
|
//
|
|
30509
30754
|
|
|
@@ -30514,51 +30759,72 @@ class WebGLRenderer {
|
|
|
30514
30759
|
_currentClearAlpha = _this.getClearAlpha();
|
|
30515
30760
|
if ( _currentClearAlpha < 1 ) _this.setClearColor( 0xffffff, 0.5 );
|
|
30516
30761
|
|
|
30517
|
-
|
|
30762
|
+
if ( _renderBackground ) {
|
|
30763
|
+
|
|
30764
|
+
background.render( scene );
|
|
30765
|
+
|
|
30766
|
+
} else {
|
|
30767
|
+
|
|
30768
|
+
_this.clear();
|
|
30769
|
+
|
|
30770
|
+
}
|
|
30518
30771
|
|
|
30519
30772
|
// Turn off the features which can affect the frag color for opaque objects pass.
|
|
30520
30773
|
// Otherwise they are applied twice in opaque objects pass and transmission objects pass.
|
|
30521
30774
|
const currentToneMapping = _this.toneMapping;
|
|
30522
30775
|
_this.toneMapping = NoToneMapping;
|
|
30523
30776
|
|
|
30777
|
+
// Remove viewport from camera to avoid nested render calls resetting viewport to it (e.g Reflector).
|
|
30778
|
+
// Transmission render pass requires viewport to match the transmissionRenderTarget.
|
|
30779
|
+
const currentCameraViewport = camera.viewport;
|
|
30780
|
+
if ( camera.viewport !== undefined ) camera.viewport = undefined;
|
|
30781
|
+
|
|
30782
|
+
currentRenderState.setupLightsView( camera );
|
|
30783
|
+
|
|
30784
|
+
if ( _clippingEnabled === true ) clipping.setGlobalState( _this.clippingPlanes, camera );
|
|
30785
|
+
|
|
30524
30786
|
renderObjects( opaqueObjects, scene, camera );
|
|
30525
30787
|
|
|
30526
30788
|
textures.updateMultisampleRenderTarget( transmissionRenderTarget );
|
|
30527
30789
|
textures.updateRenderTargetMipmap( transmissionRenderTarget );
|
|
30528
30790
|
|
|
30529
|
-
|
|
30791
|
+
if ( extensions.has( 'WEBGL_multisampled_render_to_texture' ) === false ) { // see #28131
|
|
30530
30792
|
|
|
30531
|
-
|
|
30793
|
+
let renderTargetNeedsUpdate = false;
|
|
30532
30794
|
|
|
30533
|
-
|
|
30795
|
+
for ( let i = 0, l = transmissiveObjects.length; i < l; i ++ ) {
|
|
30534
30796
|
|
|
30535
|
-
|
|
30536
|
-
const geometry = renderItem.geometry;
|
|
30537
|
-
const material = renderItem.material;
|
|
30538
|
-
const group = renderItem.group;
|
|
30797
|
+
const renderItem = transmissiveObjects[ i ];
|
|
30539
30798
|
|
|
30540
|
-
|
|
30799
|
+
const object = renderItem.object;
|
|
30800
|
+
const geometry = renderItem.geometry;
|
|
30801
|
+
const material = renderItem.material;
|
|
30802
|
+
const group = renderItem.group;
|
|
30541
30803
|
|
|
30542
|
-
|
|
30804
|
+
if ( material.side === DoubleSide && object.layers.test( camera.layers ) ) {
|
|
30543
30805
|
|
|
30544
|
-
|
|
30545
|
-
material.needsUpdate = true;
|
|
30806
|
+
const currentSide = material.side;
|
|
30546
30807
|
|
|
30547
|
-
|
|
30808
|
+
material.side = BackSide;
|
|
30809
|
+
material.needsUpdate = true;
|
|
30548
30810
|
|
|
30549
|
-
|
|
30550
|
-
material.needsUpdate = true;
|
|
30811
|
+
renderObject( object, scene, camera, geometry, material, group );
|
|
30551
30812
|
|
|
30552
|
-
|
|
30813
|
+
material.side = currentSide;
|
|
30814
|
+
material.needsUpdate = true;
|
|
30815
|
+
|
|
30816
|
+
renderTargetNeedsUpdate = true;
|
|
30817
|
+
|
|
30818
|
+
}
|
|
30553
30819
|
|
|
30554
30820
|
}
|
|
30555
30821
|
|
|
30556
|
-
|
|
30822
|
+
if ( renderTargetNeedsUpdate === true ) {
|
|
30557
30823
|
|
|
30558
|
-
|
|
30824
|
+
textures.updateMultisampleRenderTarget( transmissionRenderTarget );
|
|
30825
|
+
textures.updateRenderTargetMipmap( transmissionRenderTarget );
|
|
30559
30826
|
|
|
30560
|
-
|
|
30561
|
-
textures.updateRenderTargetMipmap( transmissionRenderTarget );
|
|
30827
|
+
}
|
|
30562
30828
|
|
|
30563
30829
|
}
|
|
30564
30830
|
|
|
@@ -30566,6 +30832,8 @@ class WebGLRenderer {
|
|
|
30566
30832
|
|
|
30567
30833
|
_this.setClearColor( _currentClearColor, _currentClearAlpha );
|
|
30568
30834
|
|
|
30835
|
+
if ( currentCameraViewport !== undefined ) camera.viewport = currentCameraViewport;
|
|
30836
|
+
|
|
30569
30837
|
_this.toneMapping = currentToneMapping;
|
|
30570
30838
|
|
|
30571
30839
|
}
|
|
@@ -30756,6 +31024,7 @@ class WebGLRenderer {
|
|
|
30756
31024
|
|
|
30757
31025
|
materialProperties.outputColorSpace = parameters.outputColorSpace;
|
|
30758
31026
|
materialProperties.batching = parameters.batching;
|
|
31027
|
+
materialProperties.batchingColor = parameters.batchingColor;
|
|
30759
31028
|
materialProperties.instancing = parameters.instancing;
|
|
30760
31029
|
materialProperties.instancingColor = parameters.instancingColor;
|
|
30761
31030
|
materialProperties.instancingMorph = parameters.instancingMorph;
|
|
@@ -30848,6 +31117,14 @@ class WebGLRenderer {
|
|
|
30848
31117
|
|
|
30849
31118
|
needsProgramChange = true;
|
|
30850
31119
|
|
|
31120
|
+
} else if ( object.isBatchedMesh && materialProperties.batchingColor === true && object.colorTexture === null ) {
|
|
31121
|
+
|
|
31122
|
+
needsProgramChange = true;
|
|
31123
|
+
|
|
31124
|
+
} else if ( object.isBatchedMesh && materialProperties.batchingColor === false && object.colorTexture !== null ) {
|
|
31125
|
+
|
|
31126
|
+
needsProgramChange = true;
|
|
31127
|
+
|
|
30851
31128
|
} else if ( object.isInstancedMesh && materialProperties.instancing === false ) {
|
|
30852
31129
|
|
|
30853
31130
|
needsProgramChange = true;
|
|
@@ -31053,6 +31330,13 @@ class WebGLRenderer {
|
|
|
31053
31330
|
p_uniforms.setOptional( _gl, object, 'batchingTexture' );
|
|
31054
31331
|
p_uniforms.setValue( _gl, 'batchingTexture', object._matricesTexture, textures );
|
|
31055
31332
|
|
|
31333
|
+
p_uniforms.setOptional( _gl, object, 'batchingColorTexture' );
|
|
31334
|
+
if ( object._colorsTexture !== null ) {
|
|
31335
|
+
|
|
31336
|
+
p_uniforms.setValue( _gl, 'batchingColorTexture', object._colorsTexture, textures );
|
|
31337
|
+
|
|
31338
|
+
}
|
|
31339
|
+
|
|
31056
31340
|
}
|
|
31057
31341
|
|
|
31058
31342
|
const morphAttributes = geometry.morphAttributes;
|
|
@@ -31113,7 +31397,7 @@ class WebGLRenderer {
|
|
|
31113
31397
|
|
|
31114
31398
|
}
|
|
31115
31399
|
|
|
31116
|
-
materials.refreshMaterialUniforms( m_uniforms, material, _pixelRatio, _height, currentRenderState.state.transmissionRenderTarget );
|
|
31400
|
+
materials.refreshMaterialUniforms( m_uniforms, material, _pixelRatio, _height, currentRenderState.state.transmissionRenderTarget[ camera.id ] );
|
|
31117
31401
|
|
|
31118
31402
|
WebGLUniforms.upload( _gl, getUniformList( materialProperties ), m_uniforms, textures );
|
|
31119
31403
|
|
|
@@ -31413,17 +31697,14 @@ class WebGLRenderer {
|
|
|
31413
31697
|
const textureFormat = texture.format;
|
|
31414
31698
|
const textureType = texture.type;
|
|
31415
31699
|
|
|
31416
|
-
if (
|
|
31700
|
+
if ( ! capabilities.textureFormatReadable( textureFormat ) ) {
|
|
31417
31701
|
|
|
31418
31702
|
console.error( 'THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.' );
|
|
31419
31703
|
return;
|
|
31420
31704
|
|
|
31421
31705
|
}
|
|
31422
31706
|
|
|
31423
|
-
|
|
31424
|
-
|
|
31425
|
-
if ( textureType !== UnsignedByteType && utils.convert( textureType ) !== _gl.getParameter( _gl.IMPLEMENTATION_COLOR_READ_TYPE ) && // Edge and Chrome Mac < 52 (#9513)
|
|
31426
|
-
textureType !== FloatType && ! halfFloatSupportedByExt ) {
|
|
31707
|
+
if ( ! capabilities.textureTypeReadable( textureType ) ) {
|
|
31427
31708
|
|
|
31428
31709
|
console.error( 'THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.' );
|
|
31429
31710
|
return;
|
|
@@ -31451,24 +31732,159 @@ class WebGLRenderer {
|
|
|
31451
31732
|
|
|
31452
31733
|
};
|
|
31453
31734
|
|
|
31454
|
-
this.
|
|
31735
|
+
this.readRenderTargetPixelsAsync = async function ( renderTarget, x, y, width, height, buffer, activeCubeFaceIndex ) {
|
|
31736
|
+
|
|
31737
|
+
if ( ! ( renderTarget && renderTarget.isWebGLRenderTarget ) ) {
|
|
31738
|
+
|
|
31739
|
+
throw new Error( 'THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.' );
|
|
31740
|
+
|
|
31741
|
+
}
|
|
31742
|
+
|
|
31743
|
+
let framebuffer = properties.get( renderTarget ).__webglFramebuffer;
|
|
31744
|
+
if ( renderTarget.isWebGLCubeRenderTarget && activeCubeFaceIndex !== undefined ) {
|
|
31745
|
+
|
|
31746
|
+
framebuffer = framebuffer[ activeCubeFaceIndex ];
|
|
31747
|
+
|
|
31748
|
+
}
|
|
31749
|
+
|
|
31750
|
+
if ( framebuffer ) {
|
|
31751
|
+
|
|
31752
|
+
state.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );
|
|
31753
|
+
|
|
31754
|
+
try {
|
|
31755
|
+
|
|
31756
|
+
const texture = renderTarget.texture;
|
|
31757
|
+
const textureFormat = texture.format;
|
|
31758
|
+
const textureType = texture.type;
|
|
31759
|
+
|
|
31760
|
+
if ( ! capabilities.textureFormatReadable( textureFormat ) ) {
|
|
31761
|
+
|
|
31762
|
+
throw new Error( 'THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.' );
|
|
31763
|
+
|
|
31764
|
+
}
|
|
31765
|
+
|
|
31766
|
+
if ( ! capabilities.textureTypeReadable( textureType ) ) {
|
|
31767
|
+
|
|
31768
|
+
throw new Error( 'THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.' );
|
|
31769
|
+
|
|
31770
|
+
}
|
|
31771
|
+
|
|
31772
|
+
// the following if statement ensures valid read requests (no out-of-bounds pixels, see #8604)
|
|
31773
|
+
if ( ( x >= 0 && x <= ( renderTarget.width - width ) ) && ( y >= 0 && y <= ( renderTarget.height - height ) ) ) {
|
|
31774
|
+
|
|
31775
|
+
const glBuffer = _gl.createBuffer();
|
|
31776
|
+
_gl.bindBuffer( _gl.PIXEL_PACK_BUFFER, glBuffer );
|
|
31777
|
+
_gl.bufferData( _gl.PIXEL_PACK_BUFFER, buffer.byteLength, _gl.STREAM_READ );
|
|
31778
|
+
_gl.readPixels( x, y, width, height, utils.convert( textureFormat ), utils.convert( textureType ), 0 );
|
|
31779
|
+
_gl.flush();
|
|
31780
|
+
|
|
31781
|
+
// check if the commands have finished every 8 ms
|
|
31782
|
+
const sync = _gl.fenceSync( _gl.SYNC_GPU_COMMANDS_COMPLETE, 0 );
|
|
31783
|
+
await probeAsync( _gl, sync, 4 );
|
|
31784
|
+
|
|
31785
|
+
try {
|
|
31786
|
+
|
|
31787
|
+
_gl.bindBuffer( _gl.PIXEL_PACK_BUFFER, glBuffer );
|
|
31788
|
+
_gl.getBufferSubData( _gl.PIXEL_PACK_BUFFER, 0, buffer );
|
|
31789
|
+
|
|
31790
|
+
} finally {
|
|
31791
|
+
|
|
31792
|
+
_gl.deleteBuffer( glBuffer );
|
|
31793
|
+
_gl.deleteSync( sync );
|
|
31794
|
+
|
|
31795
|
+
}
|
|
31796
|
+
|
|
31797
|
+
return buffer;
|
|
31798
|
+
|
|
31799
|
+
}
|
|
31800
|
+
|
|
31801
|
+
} finally {
|
|
31802
|
+
|
|
31803
|
+
// restore framebuffer of current render target if necessary
|
|
31804
|
+
|
|
31805
|
+
const framebuffer = ( _currentRenderTarget !== null ) ? properties.get( _currentRenderTarget ).__webglFramebuffer : null;
|
|
31806
|
+
state.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );
|
|
31807
|
+
|
|
31808
|
+
}
|
|
31809
|
+
|
|
31810
|
+
}
|
|
31811
|
+
|
|
31812
|
+
};
|
|
31813
|
+
|
|
31814
|
+
this.copyFramebufferToTexture = function ( texture, position = null, level = 0 ) {
|
|
31815
|
+
|
|
31816
|
+
// support previous signature with position first
|
|
31817
|
+
if ( texture.isTexture !== true ) {
|
|
31818
|
+
|
|
31819
|
+
// @deprecated, r165
|
|
31820
|
+
console.warn( 'WebGLRenderer: copyFramebufferToTexture function signature has changed.' );
|
|
31821
|
+
|
|
31822
|
+
position = arguments[ 0 ] || null;
|
|
31823
|
+
texture = arguments[ 1 ];
|
|
31824
|
+
|
|
31825
|
+
}
|
|
31455
31826
|
|
|
31456
31827
|
const levelScale = Math.pow( 2, - level );
|
|
31457
31828
|
const width = Math.floor( texture.image.width * levelScale );
|
|
31458
31829
|
const height = Math.floor( texture.image.height * levelScale );
|
|
31459
31830
|
|
|
31831
|
+
const x = position !== null ? position.x : 0;
|
|
31832
|
+
const y = position !== null ? position.y : 0;
|
|
31833
|
+
|
|
31460
31834
|
textures.setTexture2D( texture, 0 );
|
|
31461
31835
|
|
|
31462
|
-
_gl.copyTexSubImage2D( _gl.TEXTURE_2D, level, 0, 0,
|
|
31836
|
+
_gl.copyTexSubImage2D( _gl.TEXTURE_2D, level, 0, 0, x, y, width, height );
|
|
31463
31837
|
|
|
31464
31838
|
state.unbindTexture();
|
|
31465
31839
|
|
|
31466
31840
|
};
|
|
31467
31841
|
|
|
31468
|
-
this.copyTextureToTexture = function (
|
|
31842
|
+
this.copyTextureToTexture = function ( srcTexture, dstTexture, srcRegion = null, dstPosition = null, level = 0 ) {
|
|
31843
|
+
|
|
31844
|
+
// support previous signature with dstPosition first
|
|
31845
|
+
if ( srcTexture.isTexture !== true ) {
|
|
31846
|
+
|
|
31847
|
+
// @deprecated, r165
|
|
31848
|
+
console.warn( 'WebGLRenderer: copyTextureToTexture function signature has changed.' );
|
|
31849
|
+
|
|
31850
|
+
dstPosition = arguments[ 0 ] || null;
|
|
31851
|
+
srcTexture = arguments[ 1 ];
|
|
31852
|
+
dstTexture = arguments[ 2 ];
|
|
31853
|
+
level = arguments[ 3 ] || 0;
|
|
31854
|
+
srcRegion = null;
|
|
31855
|
+
|
|
31856
|
+
}
|
|
31857
|
+
|
|
31858
|
+
let width, height, minX, minY;
|
|
31859
|
+
let dstX, dstY;
|
|
31860
|
+
if ( srcRegion !== null ) {
|
|
31861
|
+
|
|
31862
|
+
width = srcRegion.max.x - srcRegion.min.x;
|
|
31863
|
+
height = srcRegion.max.y - srcRegion.min.y;
|
|
31864
|
+
minX = srcRegion.min.x;
|
|
31865
|
+
minY = srcRegion.min.y;
|
|
31866
|
+
|
|
31867
|
+
} else {
|
|
31868
|
+
|
|
31869
|
+
width = srcTexture.image.width;
|
|
31870
|
+
height = srcTexture.image.height;
|
|
31871
|
+
minX = 0;
|
|
31872
|
+
minY = 0;
|
|
31873
|
+
|
|
31874
|
+
}
|
|
31875
|
+
|
|
31876
|
+
if ( dstPosition !== null ) {
|
|
31877
|
+
|
|
31878
|
+
dstX = dstPosition.x;
|
|
31879
|
+
dstY = dstPosition.y;
|
|
31880
|
+
|
|
31881
|
+
} else {
|
|
31882
|
+
|
|
31883
|
+
dstX = 0;
|
|
31884
|
+
dstY = 0;
|
|
31885
|
+
|
|
31886
|
+
}
|
|
31469
31887
|
|
|
31470
|
-
const width = srcTexture.image.width;
|
|
31471
|
-
const height = srcTexture.image.height;
|
|
31472
31888
|
const glFormat = utils.convert( dstTexture.format );
|
|
31473
31889
|
const glType = utils.convert( dstTexture.type );
|
|
31474
31890
|
|
|
@@ -31480,24 +31896,43 @@ class WebGLRenderer {
|
|
|
31480
31896
|
_gl.pixelStorei( _gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, dstTexture.premultiplyAlpha );
|
|
31481
31897
|
_gl.pixelStorei( _gl.UNPACK_ALIGNMENT, dstTexture.unpackAlignment );
|
|
31482
31898
|
|
|
31899
|
+
const currentUnpackRowLen = _gl.getParameter( _gl.UNPACK_ROW_LENGTH );
|
|
31900
|
+
const currentUnpackImageHeight = _gl.getParameter( _gl.UNPACK_IMAGE_HEIGHT );
|
|
31901
|
+
const currentUnpackSkipPixels = _gl.getParameter( _gl.UNPACK_SKIP_PIXELS );
|
|
31902
|
+
const currentUnpackSkipRows = _gl.getParameter( _gl.UNPACK_SKIP_ROWS );
|
|
31903
|
+
const currentUnpackSkipImages = _gl.getParameter( _gl.UNPACK_SKIP_IMAGES );
|
|
31904
|
+
|
|
31905
|
+
const image = srcTexture.isCompressedTexture ? srcTexture.mipmaps[ level ] : srcTexture.image;
|
|
31906
|
+
|
|
31907
|
+
_gl.pixelStorei( _gl.UNPACK_ROW_LENGTH, image.width );
|
|
31908
|
+
_gl.pixelStorei( _gl.UNPACK_IMAGE_HEIGHT, image.height );
|
|
31909
|
+
_gl.pixelStorei( _gl.UNPACK_SKIP_PIXELS, minX );
|
|
31910
|
+
_gl.pixelStorei( _gl.UNPACK_SKIP_ROWS, minY );
|
|
31911
|
+
|
|
31483
31912
|
if ( srcTexture.isDataTexture ) {
|
|
31484
31913
|
|
|
31485
|
-
_gl.texSubImage2D( _gl.TEXTURE_2D, level,
|
|
31914
|
+
_gl.texSubImage2D( _gl.TEXTURE_2D, level, dstX, dstY, width, height, glFormat, glType, image.data );
|
|
31486
31915
|
|
|
31487
31916
|
} else {
|
|
31488
31917
|
|
|
31489
31918
|
if ( srcTexture.isCompressedTexture ) {
|
|
31490
31919
|
|
|
31491
|
-
_gl.compressedTexSubImage2D( _gl.TEXTURE_2D, level,
|
|
31920
|
+
_gl.compressedTexSubImage2D( _gl.TEXTURE_2D, level, dstX, dstY, image.width, image.height, glFormat, image.data );
|
|
31492
31921
|
|
|
31493
31922
|
} else {
|
|
31494
31923
|
|
|
31495
|
-
_gl.texSubImage2D( _gl.TEXTURE_2D, level,
|
|
31924
|
+
_gl.texSubImage2D( _gl.TEXTURE_2D, level, dstX, dstY, glFormat, glType, image );
|
|
31496
31925
|
|
|
31497
31926
|
}
|
|
31498
31927
|
|
|
31499
31928
|
}
|
|
31500
31929
|
|
|
31930
|
+
_gl.pixelStorei( _gl.UNPACK_ROW_LENGTH, currentUnpackRowLen );
|
|
31931
|
+
_gl.pixelStorei( _gl.UNPACK_IMAGE_HEIGHT, currentUnpackImageHeight );
|
|
31932
|
+
_gl.pixelStorei( _gl.UNPACK_SKIP_PIXELS, currentUnpackSkipPixels );
|
|
31933
|
+
_gl.pixelStorei( _gl.UNPACK_SKIP_ROWS, currentUnpackSkipRows );
|
|
31934
|
+
_gl.pixelStorei( _gl.UNPACK_SKIP_IMAGES, currentUnpackSkipImages );
|
|
31935
|
+
|
|
31501
31936
|
// Generate mipmaps only when copying level 0
|
|
31502
31937
|
if ( level === 0 && dstTexture.generateMipmaps ) _gl.generateMipmap( _gl.TEXTURE_2D );
|
|
31503
31938
|
|
|
@@ -31505,11 +31940,59 @@ class WebGLRenderer {
|
|
|
31505
31940
|
|
|
31506
31941
|
};
|
|
31507
31942
|
|
|
31508
|
-
this.copyTextureToTexture3D = function (
|
|
31943
|
+
this.copyTextureToTexture3D = function ( srcTexture, dstTexture, srcRegion = null, dstPosition = null, level = 0 ) {
|
|
31944
|
+
|
|
31945
|
+
// support previous signature with source box first
|
|
31946
|
+
if ( srcTexture.isTexture !== true ) {
|
|
31947
|
+
|
|
31948
|
+
// @deprecated, r165
|
|
31949
|
+
console.warn( 'WebGLRenderer: copyTextureToTexture3D function signature has changed.' );
|
|
31950
|
+
|
|
31951
|
+
srcRegion = arguments[ 0 ] || null;
|
|
31952
|
+
dstPosition = arguments[ 1 ] || null;
|
|
31953
|
+
srcTexture = arguments[ 2 ];
|
|
31954
|
+
dstTexture = arguments[ 3 ];
|
|
31955
|
+
level = arguments[ 4 ] || 0;
|
|
31956
|
+
|
|
31957
|
+
}
|
|
31958
|
+
|
|
31959
|
+
let width, height, depth, minX, minY, minZ;
|
|
31960
|
+
let dstX, dstY, dstZ;
|
|
31961
|
+
const image = srcTexture.isCompressedTexture ? srcTexture.mipmaps[ level ] : srcTexture.image;
|
|
31962
|
+
if ( srcRegion !== null ) {
|
|
31963
|
+
|
|
31964
|
+
width = srcRegion.max.x - srcRegion.min.x;
|
|
31965
|
+
height = srcRegion.max.y - srcRegion.min.y;
|
|
31966
|
+
depth = srcRegion.max.z - srcRegion.min.z;
|
|
31967
|
+
minX = srcRegion.min.x;
|
|
31968
|
+
minY = srcRegion.min.y;
|
|
31969
|
+
minZ = srcRegion.min.z;
|
|
31970
|
+
|
|
31971
|
+
} else {
|
|
31972
|
+
|
|
31973
|
+
width = image.width;
|
|
31974
|
+
height = image.height;
|
|
31975
|
+
depth = image.depth;
|
|
31976
|
+
minX = 0;
|
|
31977
|
+
minY = 0;
|
|
31978
|
+
minZ = 0;
|
|
31979
|
+
|
|
31980
|
+
}
|
|
31981
|
+
|
|
31982
|
+
if ( dstPosition !== null ) {
|
|
31983
|
+
|
|
31984
|
+
dstX = dstPosition.x;
|
|
31985
|
+
dstY = dstPosition.y;
|
|
31986
|
+
dstZ = dstPosition.z;
|
|
31987
|
+
|
|
31988
|
+
} else {
|
|
31989
|
+
|
|
31990
|
+
dstX = 0;
|
|
31991
|
+
dstY = 0;
|
|
31992
|
+
dstZ = 0;
|
|
31993
|
+
|
|
31994
|
+
}
|
|
31509
31995
|
|
|
31510
|
-
const width = Math.round( sourceBox.max.x - sourceBox.min.x );
|
|
31511
|
-
const height = Math.round( sourceBox.max.y - sourceBox.min.y );
|
|
31512
|
-
const depth = sourceBox.max.z - sourceBox.min.z + 1;
|
|
31513
31996
|
const glFormat = utils.convert( dstTexture.format );
|
|
31514
31997
|
const glType = utils.convert( dstTexture.type );
|
|
31515
31998
|
let glTarget;
|
|
@@ -31535,43 +32018,41 @@ class WebGLRenderer {
|
|
|
31535
32018
|
_gl.pixelStorei( _gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, dstTexture.premultiplyAlpha );
|
|
31536
32019
|
_gl.pixelStorei( _gl.UNPACK_ALIGNMENT, dstTexture.unpackAlignment );
|
|
31537
32020
|
|
|
31538
|
-
const
|
|
31539
|
-
const
|
|
31540
|
-
const
|
|
31541
|
-
const
|
|
31542
|
-
const
|
|
31543
|
-
|
|
31544
|
-
const image = srcTexture.isCompressedTexture ? srcTexture.mipmaps[ level ] : srcTexture.image;
|
|
32021
|
+
const currentUnpackRowLen = _gl.getParameter( _gl.UNPACK_ROW_LENGTH );
|
|
32022
|
+
const currentUnpackImageHeight = _gl.getParameter( _gl.UNPACK_IMAGE_HEIGHT );
|
|
32023
|
+
const currentUnpackSkipPixels = _gl.getParameter( _gl.UNPACK_SKIP_PIXELS );
|
|
32024
|
+
const currentUnpackSkipRows = _gl.getParameter( _gl.UNPACK_SKIP_ROWS );
|
|
32025
|
+
const currentUnpackSkipImages = _gl.getParameter( _gl.UNPACK_SKIP_IMAGES );
|
|
31545
32026
|
|
|
31546
32027
|
_gl.pixelStorei( _gl.UNPACK_ROW_LENGTH, image.width );
|
|
31547
32028
|
_gl.pixelStorei( _gl.UNPACK_IMAGE_HEIGHT, image.height );
|
|
31548
|
-
_gl.pixelStorei( _gl.UNPACK_SKIP_PIXELS,
|
|
31549
|
-
_gl.pixelStorei( _gl.UNPACK_SKIP_ROWS,
|
|
31550
|
-
_gl.pixelStorei( _gl.UNPACK_SKIP_IMAGES,
|
|
32029
|
+
_gl.pixelStorei( _gl.UNPACK_SKIP_PIXELS, minX );
|
|
32030
|
+
_gl.pixelStorei( _gl.UNPACK_SKIP_ROWS, minY );
|
|
32031
|
+
_gl.pixelStorei( _gl.UNPACK_SKIP_IMAGES, minZ );
|
|
31551
32032
|
|
|
31552
32033
|
if ( srcTexture.isDataTexture || srcTexture.isData3DTexture ) {
|
|
31553
32034
|
|
|
31554
|
-
_gl.texSubImage3D( glTarget, level,
|
|
32035
|
+
_gl.texSubImage3D( glTarget, level, dstX, dstY, dstZ, width, height, depth, glFormat, glType, image.data );
|
|
31555
32036
|
|
|
31556
32037
|
} else {
|
|
31557
32038
|
|
|
31558
32039
|
if ( dstTexture.isCompressedArrayTexture ) {
|
|
31559
32040
|
|
|
31560
|
-
_gl.compressedTexSubImage3D( glTarget, level,
|
|
32041
|
+
_gl.compressedTexSubImage3D( glTarget, level, dstX, dstY, dstZ, width, height, depth, glFormat, image.data );
|
|
31561
32042
|
|
|
31562
32043
|
} else {
|
|
31563
32044
|
|
|
31564
|
-
_gl.texSubImage3D( glTarget, level,
|
|
32045
|
+
_gl.texSubImage3D( glTarget, level, dstX, dstY, dstZ, width, height, depth, glFormat, glType, image );
|
|
31565
32046
|
|
|
31566
32047
|
}
|
|
31567
32048
|
|
|
31568
32049
|
}
|
|
31569
32050
|
|
|
31570
|
-
_gl.pixelStorei( _gl.UNPACK_ROW_LENGTH,
|
|
31571
|
-
_gl.pixelStorei( _gl.UNPACK_IMAGE_HEIGHT,
|
|
31572
|
-
_gl.pixelStorei( _gl.UNPACK_SKIP_PIXELS,
|
|
31573
|
-
_gl.pixelStorei( _gl.UNPACK_SKIP_ROWS,
|
|
31574
|
-
_gl.pixelStorei( _gl.UNPACK_SKIP_IMAGES,
|
|
32051
|
+
_gl.pixelStorei( _gl.UNPACK_ROW_LENGTH, currentUnpackRowLen );
|
|
32052
|
+
_gl.pixelStorei( _gl.UNPACK_IMAGE_HEIGHT, currentUnpackImageHeight );
|
|
32053
|
+
_gl.pixelStorei( _gl.UNPACK_SKIP_PIXELS, currentUnpackSkipPixels );
|
|
32054
|
+
_gl.pixelStorei( _gl.UNPACK_SKIP_ROWS, currentUnpackSkipRows );
|
|
32055
|
+
_gl.pixelStorei( _gl.UNPACK_SKIP_IMAGES, currentUnpackSkipImages );
|
|
31575
32056
|
|
|
31576
32057
|
// Generate mipmaps only when copying level 0
|
|
31577
32058
|
if ( level === 0 && dstTexture.generateMipmaps ) _gl.generateMipmap( glTarget );
|
|
@@ -31580,6 +32061,16 @@ class WebGLRenderer {
|
|
|
31580
32061
|
|
|
31581
32062
|
};
|
|
31582
32063
|
|
|
32064
|
+
this.initRenderTarget = function ( target ) {
|
|
32065
|
+
|
|
32066
|
+
if ( properties.get( target ).__webglFramebuffer === undefined ) {
|
|
32067
|
+
|
|
32068
|
+
textures.setupRenderTarget( target );
|
|
32069
|
+
|
|
32070
|
+
}
|
|
32071
|
+
|
|
32072
|
+
};
|
|
32073
|
+
|
|
31583
32074
|
this.initTexture = function ( texture ) {
|
|
31584
32075
|
|
|
31585
32076
|
if ( texture.isCubeTexture ) {
|
|
@@ -31645,20 +32136,6 @@ class WebGLRenderer {
|
|
|
31645
32136
|
|
|
31646
32137
|
}
|
|
31647
32138
|
|
|
31648
|
-
get useLegacyLights() { // @deprecated, r155
|
|
31649
|
-
|
|
31650
|
-
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.' );
|
|
31651
|
-
return this._useLegacyLights;
|
|
31652
|
-
|
|
31653
|
-
}
|
|
31654
|
-
|
|
31655
|
-
set useLegacyLights( value ) { // @deprecated, r155
|
|
31656
|
-
|
|
31657
|
-
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.' );
|
|
31658
|
-
this._useLegacyLights = value;
|
|
31659
|
-
|
|
31660
|
-
}
|
|
31661
|
-
|
|
31662
32139
|
}
|
|
31663
32140
|
|
|
31664
32141
|
class FogExp2 {
|
|
@@ -33647,11 +34124,14 @@ const ID_ATTR_NAME = 'batchId';
|
|
|
33647
34124
|
const _matrix$1 = /*@__PURE__*/ new Matrix4();
|
|
33648
34125
|
const _invMatrixWorld = /*@__PURE__*/ new Matrix4();
|
|
33649
34126
|
const _identityMatrix = /*@__PURE__*/ new Matrix4();
|
|
34127
|
+
const _whiteColor = /*@__PURE__*/ new Color( 1, 1, 1 );
|
|
33650
34128
|
const _projScreenMatrix$2 = /*@__PURE__*/ new Matrix4();
|
|
33651
34129
|
const _frustum = /*@__PURE__*/ new Frustum();
|
|
33652
34130
|
const _box$1 = /*@__PURE__*/ new Box3();
|
|
33653
34131
|
const _sphere$2 = /*@__PURE__*/ new Sphere();
|
|
33654
34132
|
const _vector$5 = /*@__PURE__*/ new Vector3();
|
|
34133
|
+
const _forward = /*@__PURE__*/ new Vector3();
|
|
34134
|
+
const _temp = /*@__PURE__*/ new Vector3();
|
|
33655
34135
|
const _renderList = /*@__PURE__*/ new MultiDrawRenderList();
|
|
33656
34136
|
const _mesh = /*@__PURE__*/ new Mesh();
|
|
33657
34137
|
const _batchIntersects = [];
|
|
@@ -33728,6 +34208,7 @@ class BatchedMesh extends Mesh {
|
|
|
33728
34208
|
this._multiDrawCounts = new Int32Array( maxGeometryCount );
|
|
33729
34209
|
this._multiDrawStarts = new Int32Array( maxGeometryCount );
|
|
33730
34210
|
this._multiDrawCount = 0;
|
|
34211
|
+
this._multiDrawInstances = null;
|
|
33731
34212
|
this._visibilityChanged = true;
|
|
33732
34213
|
|
|
33733
34214
|
// Local matrix per geometry by using data texture
|
|
@@ -33735,6 +34216,9 @@ class BatchedMesh extends Mesh {
|
|
|
33735
34216
|
|
|
33736
34217
|
this._initMatricesTexture();
|
|
33737
34218
|
|
|
34219
|
+
// Local color per geometry by using data texture
|
|
34220
|
+
this._colorsTexture = null;
|
|
34221
|
+
|
|
33738
34222
|
}
|
|
33739
34223
|
|
|
33740
34224
|
_initMatricesTexture() {
|
|
@@ -33757,6 +34241,20 @@ class BatchedMesh extends Mesh {
|
|
|
33757
34241
|
|
|
33758
34242
|
}
|
|
33759
34243
|
|
|
34244
|
+
_initColorsTexture() {
|
|
34245
|
+
|
|
34246
|
+
let size = Math.sqrt( this._maxGeometryCount );
|
|
34247
|
+
size = Math.ceil( size );
|
|
34248
|
+
|
|
34249
|
+
// 4 floats per RGBA pixel initialized to white
|
|
34250
|
+
const colorsArray = new Float32Array( size * size * 4 ).fill( 1 );
|
|
34251
|
+
const colorsTexture = new DataTexture( colorsArray, size, size, RGBAFormat, FloatType );
|
|
34252
|
+
colorsTexture.colorSpace = ColorManagement.workingColorSpace;
|
|
34253
|
+
|
|
34254
|
+
this._colorsTexture = colorsTexture;
|
|
34255
|
+
|
|
34256
|
+
}
|
|
34257
|
+
|
|
33760
34258
|
_initializeGeometry( reference ) {
|
|
33761
34259
|
|
|
33762
34260
|
const geometry = this.geometry;
|
|
@@ -33990,6 +34488,7 @@ class BatchedMesh extends Mesh {
|
|
|
33990
34488
|
const active = this._active;
|
|
33991
34489
|
const matricesTexture = this._matricesTexture;
|
|
33992
34490
|
const matricesArray = this._matricesTexture.image.data;
|
|
34491
|
+
const colorsTexture = this._colorsTexture;
|
|
33993
34492
|
|
|
33994
34493
|
// push new visibility states
|
|
33995
34494
|
visibility.push( true );
|
|
@@ -34003,6 +34502,14 @@ class BatchedMesh extends Mesh {
|
|
|
34003
34502
|
_identityMatrix.toArray( matricesArray, geometryId * 16 );
|
|
34004
34503
|
matricesTexture.needsUpdate = true;
|
|
34005
34504
|
|
|
34505
|
+
// initialize the color to white
|
|
34506
|
+
if ( colorsTexture !== null ) {
|
|
34507
|
+
|
|
34508
|
+
_whiteColor.toArray( colorsTexture.image.data, geometryId * 4 );
|
|
34509
|
+
colorsTexture.needsUpdate = true;
|
|
34510
|
+
|
|
34511
|
+
}
|
|
34512
|
+
|
|
34006
34513
|
// add the reserved range and draw range objects
|
|
34007
34514
|
reservedRanges.push( reservedRange );
|
|
34008
34515
|
drawRanges.push( {
|
|
@@ -34169,6 +34676,28 @@ class BatchedMesh extends Mesh {
|
|
|
34169
34676
|
|
|
34170
34677
|
}
|
|
34171
34678
|
|
|
34679
|
+
getInstanceCountAt( id ) {
|
|
34680
|
+
|
|
34681
|
+
if ( this._multiDrawInstances === null ) return null;
|
|
34682
|
+
|
|
34683
|
+
return this._multiDrawInstances[ id ];
|
|
34684
|
+
|
|
34685
|
+
}
|
|
34686
|
+
|
|
34687
|
+
setInstanceCountAt( id, instanceCount ) {
|
|
34688
|
+
|
|
34689
|
+
if ( this._multiDrawInstances === null ) {
|
|
34690
|
+
|
|
34691
|
+
this._multiDrawInstances = new Int32Array( this._maxGeometryCount ).fill( 1 );
|
|
34692
|
+
|
|
34693
|
+
}
|
|
34694
|
+
|
|
34695
|
+
this._multiDrawInstances[ id ] = instanceCount;
|
|
34696
|
+
|
|
34697
|
+
return id;
|
|
34698
|
+
|
|
34699
|
+
}
|
|
34700
|
+
|
|
34172
34701
|
// get bounding box and compute it if it doesn't exist
|
|
34173
34702
|
getBoundingBoxAt( id, target ) {
|
|
34174
34703
|
|
|
@@ -34299,6 +34828,49 @@ class BatchedMesh extends Mesh {
|
|
|
34299
34828
|
|
|
34300
34829
|
}
|
|
34301
34830
|
|
|
34831
|
+
setColorAt( geometryId, color ) {
|
|
34832
|
+
|
|
34833
|
+
if ( this._colorsTexture === null ) {
|
|
34834
|
+
|
|
34835
|
+
this._initColorsTexture();
|
|
34836
|
+
|
|
34837
|
+
}
|
|
34838
|
+
|
|
34839
|
+
// @TODO: Map geometryId to index of the arrays because
|
|
34840
|
+
// optimize() can make geometryId mismatch the index
|
|
34841
|
+
|
|
34842
|
+
const active = this._active;
|
|
34843
|
+
const colorsTexture = this._colorsTexture;
|
|
34844
|
+
const colorsArray = this._colorsTexture.image.data;
|
|
34845
|
+
const geometryCount = this._geometryCount;
|
|
34846
|
+
if ( geometryId >= geometryCount || active[ geometryId ] === false ) {
|
|
34847
|
+
|
|
34848
|
+
return this;
|
|
34849
|
+
|
|
34850
|
+
}
|
|
34851
|
+
|
|
34852
|
+
color.toArray( colorsArray, geometryId * 4 );
|
|
34853
|
+
colorsTexture.needsUpdate = true;
|
|
34854
|
+
|
|
34855
|
+
return this;
|
|
34856
|
+
|
|
34857
|
+
}
|
|
34858
|
+
|
|
34859
|
+
getColorAt( geometryId, color ) {
|
|
34860
|
+
|
|
34861
|
+
const active = this._active;
|
|
34862
|
+
const colorsArray = this._colorsTexture.image.data;
|
|
34863
|
+
const geometryCount = this._geometryCount;
|
|
34864
|
+
if ( geometryId >= geometryCount || active[ geometryId ] === false ) {
|
|
34865
|
+
|
|
34866
|
+
return null;
|
|
34867
|
+
|
|
34868
|
+
}
|
|
34869
|
+
|
|
34870
|
+
return color.fromArray( colorsArray, geometryId * 4 );
|
|
34871
|
+
|
|
34872
|
+
}
|
|
34873
|
+
|
|
34302
34874
|
setVisibleAt( geometryId, value ) {
|
|
34303
34875
|
|
|
34304
34876
|
const visibility = this._visibility;
|
|
@@ -34439,6 +35011,13 @@ class BatchedMesh extends Mesh {
|
|
|
34439
35011
|
this._matricesTexture = source._matricesTexture.clone();
|
|
34440
35012
|
this._matricesTexture.image.data = this._matricesTexture.image.slice();
|
|
34441
35013
|
|
|
35014
|
+
if ( this._colorsTexture !== null ) {
|
|
35015
|
+
|
|
35016
|
+
this._colorsTexture = source._colorsTexture.clone();
|
|
35017
|
+
this._colorsTexture.image.data = this._colorsTexture.image.slice();
|
|
35018
|
+
|
|
35019
|
+
}
|
|
35020
|
+
|
|
34442
35021
|
return this;
|
|
34443
35022
|
|
|
34444
35023
|
}
|
|
@@ -34450,6 +35029,14 @@ class BatchedMesh extends Mesh {
|
|
|
34450
35029
|
|
|
34451
35030
|
this._matricesTexture.dispose();
|
|
34452
35031
|
this._matricesTexture = null;
|
|
35032
|
+
|
|
35033
|
+
if ( this._colorsTexture !== null ) {
|
|
35034
|
+
|
|
35035
|
+
this._colorsTexture.dispose();
|
|
35036
|
+
this._colorsTexture = null;
|
|
35037
|
+
|
|
35038
|
+
}
|
|
35039
|
+
|
|
34453
35040
|
return this;
|
|
34454
35041
|
|
|
34455
35042
|
}
|
|
@@ -34495,6 +35082,7 @@ class BatchedMesh extends Mesh {
|
|
|
34495
35082
|
// get the camera position in the local frame
|
|
34496
35083
|
_invMatrixWorld.copy( this.matrixWorld ).invert();
|
|
34497
35084
|
_vector$5.setFromMatrixPosition( camera.matrixWorld ).applyMatrix4( _invMatrixWorld );
|
|
35085
|
+
_forward.set( 0, 0, - 1 ).transformDirection( camera.matrixWorld ).transformDirection( _invMatrixWorld );
|
|
34498
35086
|
|
|
34499
35087
|
for ( let i = 0, l = visibility.length; i < l; i ++ ) {
|
|
34500
35088
|
|
|
@@ -34515,7 +35103,7 @@ class BatchedMesh extends Mesh {
|
|
|
34515
35103
|
if ( ! culled ) {
|
|
34516
35104
|
|
|
34517
35105
|
// get the distance from camera used for sorting
|
|
34518
|
-
const z =
|
|
35106
|
+
const z = _temp.subVectors( _sphere$2.center, _vector$5 ).dot( _forward );
|
|
34519
35107
|
_renderList.push( drawRanges[ i ], z );
|
|
34520
35108
|
|
|
34521
35109
|
}
|
|
@@ -34638,12 +35226,16 @@ class LineBasicMaterial extends Material {
|
|
|
34638
35226
|
|
|
34639
35227
|
}
|
|
34640
35228
|
|
|
34641
|
-
const
|
|
34642
|
-
const
|
|
35229
|
+
const _vStart = /*@__PURE__*/ new Vector3();
|
|
35230
|
+
const _vEnd = /*@__PURE__*/ new Vector3();
|
|
35231
|
+
|
|
34643
35232
|
const _inverseMatrix$1 = /*@__PURE__*/ new Matrix4();
|
|
34644
35233
|
const _ray$1 = /*@__PURE__*/ new Ray();
|
|
34645
35234
|
const _sphere$1 = /*@__PURE__*/ new Sphere();
|
|
34646
35235
|
|
|
35236
|
+
const _intersectPointOnRay = /*@__PURE__*/ new Vector3();
|
|
35237
|
+
const _intersectPointOnSegment = /*@__PURE__*/ new Vector3();
|
|
35238
|
+
|
|
34647
35239
|
class Line extends Object3D {
|
|
34648
35240
|
|
|
34649
35241
|
constructor( geometry = new BufferGeometry(), material = new LineBasicMaterial() ) {
|
|
@@ -34685,11 +35277,11 @@ class Line extends Object3D {
|
|
|
34685
35277
|
|
|
34686
35278
|
for ( let i = 1, l = positionAttribute.count; i < l; i ++ ) {
|
|
34687
35279
|
|
|
34688
|
-
|
|
34689
|
-
|
|
35280
|
+
_vStart.fromBufferAttribute( positionAttribute, i - 1 );
|
|
35281
|
+
_vEnd.fromBufferAttribute( positionAttribute, i );
|
|
34690
35282
|
|
|
34691
35283
|
lineDistances[ i ] = lineDistances[ i - 1 ];
|
|
34692
|
-
lineDistances[ i ] +=
|
|
35284
|
+
lineDistances[ i ] += _vStart.distanceTo( _vEnd );
|
|
34693
35285
|
|
|
34694
35286
|
}
|
|
34695
35287
|
|
|
@@ -34730,10 +35322,6 @@ class Line extends Object3D {
|
|
|
34730
35322
|
const localThreshold = threshold / ( ( this.scale.x + this.scale.y + this.scale.z ) / 3 );
|
|
34731
35323
|
const localThresholdSq = localThreshold * localThreshold;
|
|
34732
35324
|
|
|
34733
|
-
const vStart = new Vector3();
|
|
34734
|
-
const vEnd = new Vector3();
|
|
34735
|
-
const interSegment = new Vector3();
|
|
34736
|
-
const interRay = new Vector3();
|
|
34737
35325
|
const step = this.isLineSegments ? 2 : 1;
|
|
34738
35326
|
|
|
34739
35327
|
const index = geometry.index;
|
|
@@ -34750,31 +35338,28 @@ class Line extends Object3D {
|
|
|
34750
35338
|
const a = index.getX( i );
|
|
34751
35339
|
const b = index.getX( i + 1 );
|
|
34752
35340
|
|
|
34753
|
-
|
|
34754
|
-
|
|
35341
|
+
const intersect = checkIntersection( this, raycaster, _ray$1, localThresholdSq, a, b );
|
|
35342
|
+
|
|
35343
|
+
if ( intersect ) {
|
|
34755
35344
|
|
|
34756
|
-
|
|
35345
|
+
intersects.push( intersect );
|
|
34757
35346
|
|
|
34758
|
-
|
|
35347
|
+
}
|
|
34759
35348
|
|
|
34760
|
-
|
|
35349
|
+
}
|
|
34761
35350
|
|
|
34762
|
-
|
|
35351
|
+
if ( this.isLineLoop ) {
|
|
34763
35352
|
|
|
34764
|
-
|
|
35353
|
+
const a = index.getX( end - 1 );
|
|
35354
|
+
const b = index.getX( start );
|
|
34765
35355
|
|
|
34766
|
-
|
|
35356
|
+
const intersect = checkIntersection( this, raycaster, _ray$1, localThresholdSq, a, b );
|
|
34767
35357
|
|
|
34768
|
-
|
|
34769
|
-
// What do we want? intersection point on the ray or on the segment??
|
|
34770
|
-
// point: raycaster.ray.at( distance ),
|
|
34771
|
-
point: interSegment.clone().applyMatrix4( this.matrixWorld ),
|
|
34772
|
-
index: i,
|
|
34773
|
-
face: null,
|
|
34774
|
-
faceIndex: null,
|
|
34775
|
-
object: this
|
|
35358
|
+
if ( intersect ) {
|
|
34776
35359
|
|
|
34777
|
-
|
|
35360
|
+
intersects.push( intersect );
|
|
35361
|
+
|
|
35362
|
+
}
|
|
34778
35363
|
|
|
34779
35364
|
}
|
|
34780
35365
|
|
|
@@ -34785,31 +35370,25 @@ class Line extends Object3D {
|
|
|
34785
35370
|
|
|
34786
35371
|
for ( let i = start, l = end - 1; i < l; i += step ) {
|
|
34787
35372
|
|
|
34788
|
-
|
|
34789
|
-
vEnd.fromBufferAttribute( positionAttribute, i + 1 );
|
|
35373
|
+
const intersect = checkIntersection( this, raycaster, _ray$1, localThresholdSq, i, i + 1 );
|
|
34790
35374
|
|
|
34791
|
-
|
|
35375
|
+
if ( intersect ) {
|
|
34792
35376
|
|
|
34793
|
-
|
|
35377
|
+
intersects.push( intersect );
|
|
34794
35378
|
|
|
34795
|
-
|
|
35379
|
+
}
|
|
34796
35380
|
|
|
34797
|
-
|
|
35381
|
+
}
|
|
34798
35382
|
|
|
34799
|
-
|
|
35383
|
+
if ( this.isLineLoop ) {
|
|
34800
35384
|
|
|
34801
|
-
|
|
35385
|
+
const intersect = checkIntersection( this, raycaster, _ray$1, localThresholdSq, end - 1, start );
|
|
34802
35386
|
|
|
34803
|
-
|
|
34804
|
-
// What do we want? intersection point on the ray or on the segment??
|
|
34805
|
-
// point: raycaster.ray.at( distance ),
|
|
34806
|
-
point: interSegment.clone().applyMatrix4( this.matrixWorld ),
|
|
34807
|
-
index: i,
|
|
34808
|
-
face: null,
|
|
34809
|
-
faceIndex: null,
|
|
34810
|
-
object: this
|
|
35387
|
+
if ( intersect ) {
|
|
34811
35388
|
|
|
34812
|
-
|
|
35389
|
+
intersects.push( intersect );
|
|
35390
|
+
|
|
35391
|
+
}
|
|
34813
35392
|
|
|
34814
35393
|
}
|
|
34815
35394
|
|
|
@@ -34850,6 +35429,38 @@ class Line extends Object3D {
|
|
|
34850
35429
|
|
|
34851
35430
|
}
|
|
34852
35431
|
|
|
35432
|
+
function checkIntersection( object, raycaster, ray, thresholdSq, a, b ) {
|
|
35433
|
+
|
|
35434
|
+
const positionAttribute = object.geometry.attributes.position;
|
|
35435
|
+
|
|
35436
|
+
_vStart.fromBufferAttribute( positionAttribute, a );
|
|
35437
|
+
_vEnd.fromBufferAttribute( positionAttribute, b );
|
|
35438
|
+
|
|
35439
|
+
const distSq = ray.distanceSqToSegment( _vStart, _vEnd, _intersectPointOnRay, _intersectPointOnSegment );
|
|
35440
|
+
|
|
35441
|
+
if ( distSq > thresholdSq ) return;
|
|
35442
|
+
|
|
35443
|
+
_intersectPointOnRay.applyMatrix4( object.matrixWorld ); // Move back to world space for distance calculation
|
|
35444
|
+
|
|
35445
|
+
const distance = raycaster.ray.origin.distanceTo( _intersectPointOnRay );
|
|
35446
|
+
|
|
35447
|
+
if ( distance < raycaster.near || distance > raycaster.far ) return;
|
|
35448
|
+
|
|
35449
|
+
return {
|
|
35450
|
+
|
|
35451
|
+
distance: distance,
|
|
35452
|
+
// What do we want? intersection point on the ray or on the segment??
|
|
35453
|
+
// point: raycaster.ray.at( distance ),
|
|
35454
|
+
point: _intersectPointOnSegment.clone().applyMatrix4( object.matrixWorld ),
|
|
35455
|
+
index: a,
|
|
35456
|
+
face: null,
|
|
35457
|
+
faceIndex: null,
|
|
35458
|
+
object: object
|
|
35459
|
+
|
|
35460
|
+
};
|
|
35461
|
+
|
|
35462
|
+
}
|
|
35463
|
+
|
|
34853
35464
|
const _start = /*@__PURE__*/ new Vector3();
|
|
34854
35465
|
const _end = /*@__PURE__*/ new Vector3();
|
|
34855
35466
|
|
|
@@ -35222,6 +35833,20 @@ class CompressedArrayTexture extends CompressedTexture {
|
|
|
35222
35833
|
this.image.depth = depth;
|
|
35223
35834
|
this.wrapR = ClampToEdgeWrapping;
|
|
35224
35835
|
|
|
35836
|
+
this.layerUpdates = new Set();
|
|
35837
|
+
|
|
35838
|
+
}
|
|
35839
|
+
|
|
35840
|
+
addLayerUpdates( layerIndex ) {
|
|
35841
|
+
|
|
35842
|
+
this.layerUpdates.add( layerIndex );
|
|
35843
|
+
|
|
35844
|
+
}
|
|
35845
|
+
|
|
35846
|
+
clearLayerUpdates() {
|
|
35847
|
+
|
|
35848
|
+
this.layerUpdates.clear();
|
|
35849
|
+
|
|
35225
35850
|
}
|
|
35226
35851
|
|
|
35227
35852
|
}
|
|
@@ -41487,6 +42112,7 @@ class MeshPhysicalMaterial extends MeshStandardMaterial {
|
|
|
41487
42112
|
|
|
41488
42113
|
this._anisotropy = 0;
|
|
41489
42114
|
this._clearcoat = 0;
|
|
42115
|
+
this._dispersion = 0;
|
|
41490
42116
|
this._iridescence = 0;
|
|
41491
42117
|
this._sheen = 0.0;
|
|
41492
42118
|
this._transmission = 0;
|
|
@@ -41549,6 +42175,24 @@ class MeshPhysicalMaterial extends MeshStandardMaterial {
|
|
|
41549
42175
|
|
|
41550
42176
|
}
|
|
41551
42177
|
|
|
42178
|
+
get dispersion() {
|
|
42179
|
+
|
|
42180
|
+
return this._dispersion;
|
|
42181
|
+
|
|
42182
|
+
}
|
|
42183
|
+
|
|
42184
|
+
set dispersion( value ) {
|
|
42185
|
+
|
|
42186
|
+
if ( this._dispersion > 0 !== value > 0 ) {
|
|
42187
|
+
|
|
42188
|
+
this.version ++;
|
|
42189
|
+
|
|
42190
|
+
}
|
|
42191
|
+
|
|
42192
|
+
this._dispersion = value;
|
|
42193
|
+
|
|
42194
|
+
}
|
|
42195
|
+
|
|
41552
42196
|
get sheen() {
|
|
41553
42197
|
|
|
41554
42198
|
return this._sheen;
|
|
@@ -41607,6 +42251,7 @@ class MeshPhysicalMaterial extends MeshStandardMaterial {
|
|
|
41607
42251
|
this.clearcoatNormalMap = source.clearcoatNormalMap;
|
|
41608
42252
|
this.clearcoatNormalScale.copy( source.clearcoatNormalScale );
|
|
41609
42253
|
|
|
42254
|
+
this.dispersion = source.dispersion;
|
|
41610
42255
|
this.ior = source.ior;
|
|
41611
42256
|
|
|
41612
42257
|
this.iridescence = source.iridescence;
|
|
@@ -43366,7 +44011,16 @@ KeyframeTrack.prototype.DefaultInterpolation = InterpolateLinear;
|
|
|
43366
44011
|
/**
|
|
43367
44012
|
* A Track of Boolean keyframe values.
|
|
43368
44013
|
*/
|
|
43369
|
-
class BooleanKeyframeTrack extends KeyframeTrack {
|
|
44014
|
+
class BooleanKeyframeTrack extends KeyframeTrack {
|
|
44015
|
+
|
|
44016
|
+
// No interpolation parameter because only InterpolateDiscrete is valid.
|
|
44017
|
+
constructor( name, times, values ) {
|
|
44018
|
+
|
|
44019
|
+
super( name, times, values );
|
|
44020
|
+
|
|
44021
|
+
}
|
|
44022
|
+
|
|
44023
|
+
}
|
|
43370
44024
|
|
|
43371
44025
|
BooleanKeyframeTrack.prototype.ValueTypeName = 'bool';
|
|
43372
44026
|
BooleanKeyframeTrack.prototype.ValueBufferType = Array;
|
|
@@ -43437,13 +44091,22 @@ class QuaternionKeyframeTrack extends KeyframeTrack {
|
|
|
43437
44091
|
|
|
43438
44092
|
QuaternionKeyframeTrack.prototype.ValueTypeName = 'quaternion';
|
|
43439
44093
|
// ValueBufferType is inherited
|
|
43440
|
-
|
|
44094
|
+
// DefaultInterpolation is inherited;
|
|
43441
44095
|
QuaternionKeyframeTrack.prototype.InterpolantFactoryMethodSmooth = undefined;
|
|
43442
44096
|
|
|
43443
44097
|
/**
|
|
43444
44098
|
* A Track that interpolates Strings
|
|
43445
44099
|
*/
|
|
43446
|
-
class StringKeyframeTrack extends KeyframeTrack {
|
|
44100
|
+
class StringKeyframeTrack extends KeyframeTrack {
|
|
44101
|
+
|
|
44102
|
+
// No interpolation parameter because only InterpolateDiscrete is valid.
|
|
44103
|
+
constructor( name, times, values ) {
|
|
44104
|
+
|
|
44105
|
+
super( name, times, values );
|
|
44106
|
+
|
|
44107
|
+
}
|
|
44108
|
+
|
|
44109
|
+
}
|
|
43447
44110
|
|
|
43448
44111
|
StringKeyframeTrack.prototype.ValueTypeName = 'string';
|
|
43449
44112
|
StringKeyframeTrack.prototype.ValueBufferType = Array;
|
|
@@ -44280,7 +44943,7 @@ class FileLoader extends Loader {
|
|
|
44280
44943
|
|
|
44281
44944
|
// Nginx needs X-File-Size check
|
|
44282
44945
|
// https://serverfault.com/questions/482875/why-does-nginx-remove-content-length-header-for-chunked-content
|
|
44283
|
-
const contentLength = response.headers.get( '
|
|
44946
|
+
const contentLength = response.headers.get( 'X-File-Size' ) || response.headers.get( 'Content-Length' );
|
|
44284
44947
|
const total = contentLength ? parseInt( contentLength ) : 0;
|
|
44285
44948
|
const lengthComputable = total !== 0;
|
|
44286
44949
|
let loaded = 0;
|
|
@@ -44316,6 +44979,10 @@ class FileLoader extends Loader {
|
|
|
44316
44979
|
|
|
44317
44980
|
}
|
|
44318
44981
|
|
|
44982
|
+
}, ( e ) => {
|
|
44983
|
+
|
|
44984
|
+
controller.error( e );
|
|
44985
|
+
|
|
44319
44986
|
} );
|
|
44320
44987
|
|
|
44321
44988
|
}
|
|
@@ -45881,6 +46548,7 @@ class MaterialLoader extends Loader {
|
|
|
45881
46548
|
if ( json.shininess !== undefined ) material.shininess = json.shininess;
|
|
45882
46549
|
if ( json.clearcoat !== undefined ) material.clearcoat = json.clearcoat;
|
|
45883
46550
|
if ( json.clearcoatRoughness !== undefined ) material.clearcoatRoughness = json.clearcoatRoughness;
|
|
46551
|
+
if ( json.dispersion !== undefined ) material.dispersion = json.dispersion;
|
|
45884
46552
|
if ( json.iridescence !== undefined ) material.iridescence = json.iridescence;
|
|
45885
46553
|
if ( json.iridescenceIOR !== undefined ) material.iridescenceIOR = json.iridescenceIOR;
|
|
45886
46554
|
if ( json.iridescenceThicknessRange !== undefined ) material.iridescenceThicknessRange = json.iridescenceThicknessRange;
|
|
@@ -46150,7 +46818,9 @@ class MaterialLoader extends Loader {
|
|
|
46150
46818
|
|
|
46151
46819
|
class LoaderUtils {
|
|
46152
46820
|
|
|
46153
|
-
static decodeText( array ) {
|
|
46821
|
+
static decodeText( array ) { // @deprecated, r165
|
|
46822
|
+
|
|
46823
|
+
console.warn( 'THREE.LoaderUtils: decodeText() has been deprecated with r165 and will be removed with r175. Use TextDecoder instead.' );
|
|
46154
46824
|
|
|
46155
46825
|
if ( typeof TextDecoder !== 'undefined' ) {
|
|
46156
46826
|
|
|
@@ -47361,6 +48031,7 @@ class ObjectLoader extends Loader {
|
|
|
47361
48031
|
object._geometryCount = data.geometryCount;
|
|
47362
48032
|
|
|
47363
48033
|
object._matricesTexture = getTexture( data.matricesTexture.uuid );
|
|
48034
|
+
if ( data.colorsTexture !== undefined ) object._colorsTexture = getTexture( data.colorsTexture.uuid );
|
|
47364
48035
|
|
|
47365
48036
|
break;
|
|
47366
48037
|
|
|
@@ -51823,13 +52494,17 @@ function ascSort( a, b ) {
|
|
|
51823
52494
|
|
|
51824
52495
|
function intersect( object, raycaster, intersects, recursive ) {
|
|
51825
52496
|
|
|
52497
|
+
let propagate = true;
|
|
52498
|
+
|
|
51826
52499
|
if ( object.layers.test( raycaster.layers ) ) {
|
|
51827
52500
|
|
|
51828
|
-
object.raycast( raycaster, intersects );
|
|
52501
|
+
const result = object.raycast( raycaster, intersects );
|
|
52502
|
+
|
|
52503
|
+
if ( result === false ) propagate = false;
|
|
51829
52504
|
|
|
51830
52505
|
}
|
|
51831
52506
|
|
|
51832
|
-
if ( recursive === true ) {
|
|
52507
|
+
if ( propagate === true && recursive === true ) {
|
|
51833
52508
|
|
|
51834
52509
|
const children = object.children;
|
|
51835
52510
|
|