super-three 0.163.0 → 0.164.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/three.cjs +473 -245
- package/build/three.module.js +473 -245
- package/build/three.module.min.js +2 -2
- package/examples/jsm/animation/CCDIKSolver.js +4 -2
- package/examples/jsm/exporters/GLTFExporter.js +45 -1
- package/examples/jsm/exporters/USDZExporter.js +7 -1
- package/examples/jsm/libs/draco/README.md +2 -2
- package/examples/jsm/loaders/EXRLoader.js +283 -99
- package/examples/jsm/loaders/GLTFLoader.js +53 -0
- package/examples/jsm/loaders/KTX2Loader.js +3 -6
- 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/nodes/Nodes.js +4 -3
- package/examples/jsm/nodes/accessors/AccessorsUtils.js +16 -1
- package/examples/jsm/nodes/accessors/ClippingNode.js +3 -2
- package/examples/jsm/nodes/accessors/MaterialNode.js +107 -3
- package/examples/jsm/nodes/accessors/StorageBufferNode.js +9 -0
- package/examples/jsm/nodes/accessors/TextureNode.js +21 -3
- package/examples/jsm/nodes/accessors/TextureSizeNode.js +1 -1
- package/examples/jsm/nodes/code/FunctionNode.js +0 -8
- package/examples/jsm/nodes/core/Node.js +8 -0
- package/examples/jsm/nodes/core/NodeBuilder.js +5 -9
- package/examples/jsm/nodes/core/OutputStructNode.js +2 -1
- package/examples/jsm/nodes/core/PropertyNode.js +10 -0
- package/examples/jsm/nodes/display/BumpMapNode.js +7 -26
- package/examples/jsm/nodes/display/FrontFacingNode.js +13 -0
- package/examples/jsm/nodes/display/ViewportDepthNode.js +1 -1
- package/examples/jsm/nodes/display/ViewportNode.js +4 -2
- 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 +164 -10
- package/examples/jsm/nodes/functions/ShadowMaskModel.js +31 -0
- package/examples/jsm/nodes/lighting/AnalyticLightNode.js +18 -4
- 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 +11 -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 +10 -6
- package/examples/jsm/nodes/materials/Materials.js +1 -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 +76 -5
- package/examples/jsm/nodes/materials/MeshStandardNodeMaterial.js +11 -4
- package/examples/jsm/nodes/materials/NodeMaterial.js +31 -41
- package/examples/jsm/nodes/materials/ShadowNodeMaterial.js +34 -0
- package/examples/jsm/nodes/pmrem/PMREMUtils.js +1 -1
- package/examples/jsm/nodes/shadernode/ShaderNode.js +2 -8
- package/examples/jsm/physics/JoltPhysics.js +281 -0
- package/examples/jsm/postprocessing/RenderTransitionPass.js +193 -0
- package/examples/jsm/renderers/common/Background.js +3 -3
- package/examples/jsm/renderers/common/ClippingContext.js +1 -1
- package/examples/jsm/renderers/common/RenderList.js +1 -1
- package/examples/jsm/renderers/common/RenderObject.js +43 -1
- package/examples/jsm/renderers/common/Renderer.js +129 -14
- package/examples/jsm/renderers/common/Textures.js +1 -1
- package/examples/jsm/renderers/common/extras/PMREMGenerator.js +13 -17
- 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 +6 -0
- package/examples/jsm/renderers/webgl/utils/WebGLTextureUtils.js +21 -7
- package/examples/jsm/renderers/webgl/utils/WebGLUtils.js +3 -21
- package/examples/jsm/renderers/webgpu/WebGPUBackend.js +33 -45
- package/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js +16 -1
- package/examples/jsm/renderers/webgpu/utils/WebGPUAttributeUtils.js +4 -1
- package/examples/jsm/transpiler/GLSLDecoder.js +1 -1
- package/examples/jsm/transpiler/ShaderToyDecoder.js +1 -1
- package/examples/jsm/utils/SceneUtils.js +60 -1
- package/examples/jsm/webxr/OculusHandModel.js +3 -2
- package/examples/jsm/webxr/XRHandModelFactory.js +4 -2
- package/package.json +1 -1
- package/src/constants.js +1 -1
- package/src/core/RenderTarget.js +8 -0
- package/src/extras/PMREMGenerator.js +12 -11
- package/src/loaders/FileLoader.js +1 -1
- package/src/loaders/MaterialLoader.js +1 -0
- package/src/materials/Material.js +2 -0
- package/src/materials/MeshPhysicalMaterial.js +20 -0
- package/src/objects/BatchedMesh.js +23 -0
- package/src/objects/Line.js +66 -43
- package/src/renderers/WebGLRenderer.js +92 -61
- 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/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 +18 -3
- package/src/renderers/webgl/WebGLBufferRenderer.js +36 -0
- package/src/renderers/webgl/WebGLCapabilities.js +33 -1
- package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +36 -0
- package/src/renderers/webgl/WebGLMaterials.js +6 -0
- package/src/renderers/webgl/WebGLProgram.js +3 -5
- package/src/renderers/webgl/WebGLPrograms.js +5 -0
- package/src/renderers/webgl/WebGLRenderStates.js +6 -2
- package/src/renderers/webgl/WebGLShadowMap.js +25 -25
- package/src/renderers/webgl/WebGLTextures.js +68 -60
- package/src/renderers/webgl/WebGLUtils.js +3 -21
- package/src/renderers/webxr/WebXRManager.js +2 -4
- 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 = '164';
|
|
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 };
|
|
@@ -2923,6 +2923,8 @@ class RenderTarget extends EventDispatcher {
|
|
|
2923
2923
|
minFilter: LinearFilter,
|
|
2924
2924
|
depthBuffer: true,
|
|
2925
2925
|
stencilBuffer: false,
|
|
2926
|
+
resolveDepthBuffer: true,
|
|
2927
|
+
resolveStencilBuffer: true,
|
|
2926
2928
|
depthTexture: null,
|
|
2927
2929
|
samples: 0,
|
|
2928
2930
|
count: 1
|
|
@@ -2947,6 +2949,9 @@ class RenderTarget extends EventDispatcher {
|
|
|
2947
2949
|
this.depthBuffer = options.depthBuffer;
|
|
2948
2950
|
this.stencilBuffer = options.stencilBuffer;
|
|
2949
2951
|
|
|
2952
|
+
this.resolveDepthBuffer = options.resolveDepthBuffer;
|
|
2953
|
+
this.resolveStencilBuffer = options.resolveStencilBuffer;
|
|
2954
|
+
|
|
2950
2955
|
this.depthTexture = options.depthTexture;
|
|
2951
2956
|
|
|
2952
2957
|
this.samples = options.samples;
|
|
@@ -3024,6 +3029,9 @@ class RenderTarget extends EventDispatcher {
|
|
|
3024
3029
|
this.depthBuffer = source.depthBuffer;
|
|
3025
3030
|
this.stencilBuffer = source.stencilBuffer;
|
|
3026
3031
|
|
|
3032
|
+
this.resolveDepthBuffer = source.resolveDepthBuffer;
|
|
3033
|
+
this.resolveStencilBuffer = source.resolveStencilBuffer;
|
|
3034
|
+
|
|
3027
3035
|
if ( source.depthTexture !== null ) this.depthTexture = source.depthTexture.clone();
|
|
3028
3036
|
|
|
3029
3037
|
this.samples = source.samples;
|
|
@@ -9239,6 +9247,8 @@ class Material extends EventDispatcher {
|
|
|
9239
9247
|
|
|
9240
9248
|
}
|
|
9241
9249
|
|
|
9250
|
+
if ( this.dispersion !== undefined ) data.dispersion = this.dispersion;
|
|
9251
|
+
|
|
9242
9252
|
if ( this.iridescence !== undefined ) data.iridescence = this.iridescence;
|
|
9243
9253
|
if ( this.iridescenceIOR !== undefined ) data.iridescenceIOR = this.iridescenceIOR;
|
|
9244
9254
|
if ( this.iridescenceThicknessRange !== undefined ) data.iridescenceThicknessRange = this.iridescenceThicknessRange;
|
|
@@ -11787,7 +11797,7 @@ class Mesh extends Object3D {
|
|
|
11787
11797
|
|
|
11788
11798
|
}
|
|
11789
11799
|
|
|
11790
|
-
function checkIntersection( object, material, raycaster, ray, pA, pB, pC, point ) {
|
|
11800
|
+
function checkIntersection$1( object, material, raycaster, ray, pA, pB, pC, point ) {
|
|
11791
11801
|
|
|
11792
11802
|
let intersect;
|
|
11793
11803
|
|
|
@@ -11824,7 +11834,7 @@ function checkGeometryIntersection( object, material, raycaster, ray, uv, uv1, n
|
|
|
11824
11834
|
object.getVertexPosition( b, _vB$1 );
|
|
11825
11835
|
object.getVertexPosition( c, _vC$1 );
|
|
11826
11836
|
|
|
11827
|
-
const intersection = checkIntersection( object, material, raycaster, ray, _vA$1, _vB$1, _vC$1, _intersectionPoint );
|
|
11837
|
+
const intersection = checkIntersection$1( object, material, raycaster, ray, _vA$1, _vB$1, _vC$1, _intersectionPoint );
|
|
11828
11838
|
|
|
11829
11839
|
if ( intersection ) {
|
|
11830
11840
|
|
|
@@ -13818,8 +13828,6 @@ var fog_pars_fragment = "#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying flo
|
|
|
13818
13828
|
|
|
13819
13829
|
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
13830
|
|
|
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
13831
|
var lightmap_pars_fragment = "#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif";
|
|
13824
13832
|
|
|
13825
13833
|
var lights_lambert_fragment = "LambertMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularStrength = specularStrength;";
|
|
@@ -13838,9 +13846,9 @@ var lights_phong_fragment = "BlinnPhongMaterial material;\nmaterial.diffuseColor
|
|
|
13838
13846
|
|
|
13839
13847
|
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
13848
|
|
|
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";
|
|
13849
|
+
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
13850
|
|
|
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}";
|
|
13851
|
+
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
13852
|
|
|
13845
13853
|
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
13854
|
|
|
@@ -13936,11 +13944,11 @@ var specularmap_pars_fragment = "#ifdef USE_SPECULARMAP\n\tuniform sampler2D spe
|
|
|
13936
13944
|
|
|
13937
13945
|
var tonemapping_fragment = "#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif";
|
|
13938
13946
|
|
|
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\
|
|
13947
|
+
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
13948
|
|
|
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";
|
|
13949
|
+
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
13950
|
|
|
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,
|
|
13951
|
+
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
13952
|
|
|
13945
13953
|
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
13954
|
|
|
@@ -14000,7 +14008,7 @@ const fragment$6 = "#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;
|
|
|
14000
14008
|
|
|
14001
14009
|
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
14010
|
|
|
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}";
|
|
14011
|
+
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
14012
|
|
|
14005
14013
|
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
14014
|
|
|
@@ -14062,7 +14070,6 @@ const ShaderChunk = {
|
|
|
14062
14070
|
fog_fragment: fog_fragment,
|
|
14063
14071
|
fog_pars_fragment: fog_pars_fragment,
|
|
14064
14072
|
gradientmap_pars_fragment: gradientmap_pars_fragment,
|
|
14065
|
-
lightmap_fragment: lightmap_fragment,
|
|
14066
14073
|
lightmap_pars_fragment: lightmap_pars_fragment,
|
|
14067
14074
|
lights_lambert_fragment: lights_lambert_fragment,
|
|
14068
14075
|
lights_lambert_pars_fragment: lights_lambert_pars_fragment,
|
|
@@ -14698,6 +14705,7 @@ ShaderLib.physical = {
|
|
|
14698
14705
|
clearcoatRoughness: { value: 0 },
|
|
14699
14706
|
clearcoatRoughnessMap: { value: null },
|
|
14700
14707
|
clearcoatRoughnessMapTransform: { value: /*@__PURE__*/ new Matrix3() },
|
|
14708
|
+
dispersion: { value: 0 },
|
|
14701
14709
|
iridescence: { value: 0 },
|
|
14702
14710
|
iridescenceMap: { value: null },
|
|
14703
14711
|
iridescenceMapTransform: { value: /*@__PURE__*/ new Matrix3() },
|
|
@@ -14756,9 +14764,8 @@ function WebGLBackground( renderer, cubemaps, cubeuvmaps, state, objects, alpha,
|
|
|
14756
14764
|
let currentBackgroundVersion = 0;
|
|
14757
14765
|
let currentTonemapping = null;
|
|
14758
14766
|
|
|
14759
|
-
function
|
|
14767
|
+
function getBackground( scene ) {
|
|
14760
14768
|
|
|
14761
|
-
let forceClear = false;
|
|
14762
14769
|
let background = scene.isScene === true ? scene.background : null;
|
|
14763
14770
|
|
|
14764
14771
|
if ( background && background.isTexture ) {
|
|
@@ -14768,6 +14775,15 @@ function WebGLBackground( renderer, cubemaps, cubeuvmaps, state, objects, alpha,
|
|
|
14768
14775
|
|
|
14769
14776
|
}
|
|
14770
14777
|
|
|
14778
|
+
return background;
|
|
14779
|
+
|
|
14780
|
+
}
|
|
14781
|
+
|
|
14782
|
+
function render( scene ) {
|
|
14783
|
+
|
|
14784
|
+
let forceClear = false;
|
|
14785
|
+
const background = getBackground( scene );
|
|
14786
|
+
|
|
14771
14787
|
if ( background === null ) {
|
|
14772
14788
|
|
|
14773
14789
|
setClear( clearColor, clearAlpha );
|
|
@@ -14797,6 +14813,12 @@ function WebGLBackground( renderer, cubemaps, cubeuvmaps, state, objects, alpha,
|
|
|
14797
14813
|
|
|
14798
14814
|
}
|
|
14799
14815
|
|
|
14816
|
+
}
|
|
14817
|
+
|
|
14818
|
+
function addToRenderList( renderList, scene ) {
|
|
14819
|
+
|
|
14820
|
+
const background = getBackground( scene );
|
|
14821
|
+
|
|
14800
14822
|
if ( background && ( background.isCubeTexture || background.mapping === CubeUVReflectionMapping ) ) {
|
|
14801
14823
|
|
|
14802
14824
|
if ( boxMesh === undefined ) {
|
|
@@ -14977,7 +14999,8 @@ function WebGLBackground( renderer, cubemaps, cubeuvmaps, state, objects, alpha,
|
|
|
14977
14999
|
setClear( clearColor, clearAlpha );
|
|
14978
15000
|
|
|
14979
15001
|
},
|
|
14980
|
-
render: render
|
|
15002
|
+
render: render,
|
|
15003
|
+
addToRenderList: addToRenderList
|
|
14981
15004
|
|
|
14982
15005
|
};
|
|
14983
15006
|
|
|
@@ -15632,16 +15655,52 @@ function WebGLBufferRenderer( gl, extensions, info ) {
|
|
|
15632
15655
|
|
|
15633
15656
|
}
|
|
15634
15657
|
|
|
15658
|
+
function renderMultiDrawInstances( starts, counts, drawCount, primcount ) {
|
|
15659
|
+
|
|
15660
|
+
if ( drawCount === 0 ) return;
|
|
15661
|
+
|
|
15662
|
+
const extension = extensions.get( 'WEBGL_multi_draw' );
|
|
15663
|
+
|
|
15664
|
+
if ( extension === null ) {
|
|
15665
|
+
|
|
15666
|
+
for ( let i = 0; i < starts.length; i ++ ) {
|
|
15667
|
+
|
|
15668
|
+
renderInstances( starts[ i ], counts[ i ], primcount[ i ] );
|
|
15669
|
+
|
|
15670
|
+
}
|
|
15671
|
+
|
|
15672
|
+
} else {
|
|
15673
|
+
|
|
15674
|
+
extension.multiDrawArraysInstancedWEBGL( mode, starts, 0, counts, 0, primcount, 0, drawCount );
|
|
15675
|
+
|
|
15676
|
+
let elementCount = 0;
|
|
15677
|
+
for ( let i = 0; i < drawCount; i ++ ) {
|
|
15678
|
+
|
|
15679
|
+
elementCount += counts[ i ];
|
|
15680
|
+
|
|
15681
|
+
}
|
|
15682
|
+
|
|
15683
|
+
for ( let i = 0; i < primcount.length; i ++ ) {
|
|
15684
|
+
|
|
15685
|
+
info.update( elementCount, mode, primcount[ i ] );
|
|
15686
|
+
|
|
15687
|
+
}
|
|
15688
|
+
|
|
15689
|
+
}
|
|
15690
|
+
|
|
15691
|
+
}
|
|
15692
|
+
|
|
15635
15693
|
//
|
|
15636
15694
|
|
|
15637
15695
|
this.setMode = setMode;
|
|
15638
15696
|
this.render = render;
|
|
15639
15697
|
this.renderInstances = renderInstances;
|
|
15640
15698
|
this.renderMultiDraw = renderMultiDraw;
|
|
15699
|
+
this.renderMultiDrawInstances = renderMultiDrawInstances;
|
|
15641
15700
|
|
|
15642
15701
|
}
|
|
15643
15702
|
|
|
15644
|
-
function WebGLCapabilities( gl, extensions, parameters ) {
|
|
15703
|
+
function WebGLCapabilities( gl, extensions, parameters, utils ) {
|
|
15645
15704
|
|
|
15646
15705
|
let maxAnisotropy;
|
|
15647
15706
|
|
|
@@ -15665,6 +15724,33 @@ function WebGLCapabilities( gl, extensions, parameters ) {
|
|
|
15665
15724
|
|
|
15666
15725
|
}
|
|
15667
15726
|
|
|
15727
|
+
function textureFormatReadable( textureFormat ) {
|
|
15728
|
+
|
|
15729
|
+
if ( textureFormat !== RGBAFormat && utils.convert( textureFormat ) !== gl.getParameter( gl.IMPLEMENTATION_COLOR_READ_FORMAT ) ) {
|
|
15730
|
+
|
|
15731
|
+
return false;
|
|
15732
|
+
|
|
15733
|
+
}
|
|
15734
|
+
|
|
15735
|
+
return true;
|
|
15736
|
+
|
|
15737
|
+
}
|
|
15738
|
+
|
|
15739
|
+
function textureTypeReadable( textureType ) {
|
|
15740
|
+
|
|
15741
|
+
const halfFloatSupportedByExt = ( textureType === HalfFloatType ) && ( extensions.has( 'EXT_color_buffer_half_float' ) || extensions.has( 'EXT_color_buffer_float' ) );
|
|
15742
|
+
|
|
15743
|
+
if ( textureType !== UnsignedByteType && utils.convert( textureType ) !== gl.getParameter( gl.IMPLEMENTATION_COLOR_READ_TYPE ) && // Edge and Chrome Mac < 52 (#9513)
|
|
15744
|
+
textureType !== FloatType && ! halfFloatSupportedByExt ) {
|
|
15745
|
+
|
|
15746
|
+
return false;
|
|
15747
|
+
|
|
15748
|
+
}
|
|
15749
|
+
|
|
15750
|
+
return true;
|
|
15751
|
+
|
|
15752
|
+
}
|
|
15753
|
+
|
|
15668
15754
|
function getMaxPrecision( precision ) {
|
|
15669
15755
|
|
|
15670
15756
|
if ( precision === 'highp' ) {
|
|
@@ -15728,6 +15814,9 @@ function WebGLCapabilities( gl, extensions, parameters ) {
|
|
|
15728
15814
|
getMaxAnisotropy: getMaxAnisotropy,
|
|
15729
15815
|
getMaxPrecision: getMaxPrecision,
|
|
15730
15816
|
|
|
15817
|
+
textureFormatReadable: textureFormatReadable,
|
|
15818
|
+
textureTypeReadable: textureTypeReadable,
|
|
15819
|
+
|
|
15731
15820
|
precision: precision,
|
|
15732
15821
|
logarithmicDepthBuffer: logarithmicDepthBuffer,
|
|
15733
15822
|
|
|
@@ -16169,16 +16258,16 @@ const INV_PHI = 1 / PHI;
|
|
|
16169
16258
|
// Vertices of a dodecahedron (except the opposites, which represent the
|
|
16170
16259
|
// same axis), used as axis directions evenly spread on a sphere.
|
|
16171
16260
|
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 ),
|
|
16261
|
+
/*@__PURE__*/ new Vector3( - PHI, INV_PHI, 0 ),
|
|
16180
16262
|
/*@__PURE__*/ new Vector3( PHI, INV_PHI, 0 ),
|
|
16181
|
-
/*@__PURE__*/ new Vector3( -
|
|
16263
|
+
/*@__PURE__*/ new Vector3( - INV_PHI, 0, PHI ),
|
|
16264
|
+
/*@__PURE__*/ new Vector3( INV_PHI, 0, PHI ),
|
|
16265
|
+
/*@__PURE__*/ new Vector3( 0, PHI, - INV_PHI ),
|
|
16266
|
+
/*@__PURE__*/ new Vector3( 0, PHI, INV_PHI ),
|
|
16267
|
+
/*@__PURE__*/ new Vector3( - 1, 1, - 1 ),
|
|
16268
|
+
/*@__PURE__*/ new Vector3( 1, 1, - 1 ),
|
|
16269
|
+
/*@__PURE__*/ new Vector3( - 1, 1, 1 ),
|
|
16270
|
+
/*@__PURE__*/ new Vector3( 1, 1, 1 ) ];
|
|
16182
16271
|
|
|
16183
16272
|
/**
|
|
16184
16273
|
* This class generates a Prefiltered, Mipmapped Radiance Environment Map
|
|
@@ -16564,12 +16653,13 @@ class PMREMGenerator {
|
|
|
16564
16653
|
const renderer = this._renderer;
|
|
16565
16654
|
const autoClear = renderer.autoClear;
|
|
16566
16655
|
renderer.autoClear = false;
|
|
16656
|
+
const n = this._lodPlanes.length;
|
|
16567
16657
|
|
|
16568
|
-
for ( let i = 1; i <
|
|
16658
|
+
for ( let i = 1; i < n; i ++ ) {
|
|
16569
16659
|
|
|
16570
16660
|
const sigma = Math.sqrt( this._sigmas[ i ] * this._sigmas[ i ] - this._sigmas[ i - 1 ] * this._sigmas[ i - 1 ] );
|
|
16571
16661
|
|
|
16572
|
-
const poleAxis = _axisDirections[ ( i - 1 ) % _axisDirections.length ];
|
|
16662
|
+
const poleAxis = _axisDirections[ ( n - i - 1 ) % _axisDirections.length ];
|
|
16573
16663
|
|
|
16574
16664
|
this._blur( cubeUVRenderTarget, i - 1, i, sigma, poleAxis );
|
|
16575
16665
|
|
|
@@ -17518,6 +17608,41 @@ function WebGLIndexedBufferRenderer( gl, extensions, info ) {
|
|
|
17518
17608
|
|
|
17519
17609
|
}
|
|
17520
17610
|
|
|
17611
|
+
function renderMultiDrawInstances( starts, counts, drawCount, primcount ) {
|
|
17612
|
+
|
|
17613
|
+
if ( drawCount === 0 ) return;
|
|
17614
|
+
|
|
17615
|
+
const extension = extensions.get( 'WEBGL_multi_draw' );
|
|
17616
|
+
|
|
17617
|
+
if ( extension === null ) {
|
|
17618
|
+
|
|
17619
|
+
for ( let i = 0; i < starts.length; i ++ ) {
|
|
17620
|
+
|
|
17621
|
+
renderInstances( starts[ i ] / bytesPerElement, counts[ i ], primcount[ i ] );
|
|
17622
|
+
|
|
17623
|
+
}
|
|
17624
|
+
|
|
17625
|
+
} else {
|
|
17626
|
+
|
|
17627
|
+
extension.multiDrawElementsInstancedWEBGL( mode, counts, 0, type, starts, 0, primcount, 0, drawCount );
|
|
17628
|
+
|
|
17629
|
+
let elementCount = 0;
|
|
17630
|
+
for ( let i = 0; i < drawCount; i ++ ) {
|
|
17631
|
+
|
|
17632
|
+
elementCount += counts[ i ];
|
|
17633
|
+
|
|
17634
|
+
}
|
|
17635
|
+
|
|
17636
|
+
for ( let i = 0; i < primcount.length; i ++ ) {
|
|
17637
|
+
|
|
17638
|
+
info.update( elementCount, mode, primcount[ i ] );
|
|
17639
|
+
|
|
17640
|
+
}
|
|
17641
|
+
|
|
17642
|
+
}
|
|
17643
|
+
|
|
17644
|
+
}
|
|
17645
|
+
|
|
17521
17646
|
//
|
|
17522
17647
|
|
|
17523
17648
|
this.setMode = setMode;
|
|
@@ -17525,6 +17650,7 @@ function WebGLIndexedBufferRenderer( gl, extensions, info ) {
|
|
|
17525
17650
|
this.render = render;
|
|
17526
17651
|
this.renderInstances = renderInstances;
|
|
17527
17652
|
this.renderMultiDraw = renderMultiDraw;
|
|
17653
|
+
this.renderMultiDrawInstances = renderMultiDrawInstances;
|
|
17528
17654
|
|
|
17529
17655
|
}
|
|
17530
17656
|
|
|
@@ -19400,11 +19526,7 @@ function resolveIncludes( string ) {
|
|
|
19400
19526
|
|
|
19401
19527
|
}
|
|
19402
19528
|
|
|
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
|
-
] );
|
|
19529
|
+
const shaderChunkMap = new Map();
|
|
19408
19530
|
|
|
19409
19531
|
function includeReplacer( match, include ) {
|
|
19410
19532
|
|
|
@@ -19935,6 +20057,8 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
|
|
|
19935
20057
|
parameters.clearcoatRoughnessMap ? '#define USE_CLEARCOAT_ROUGHNESSMAP' : '',
|
|
19936
20058
|
parameters.clearcoatNormalMap ? '#define USE_CLEARCOAT_NORMALMAP' : '',
|
|
19937
20059
|
|
|
20060
|
+
parameters.dispersion ? '#define USE_DISPERSION' : '',
|
|
20061
|
+
|
|
19938
20062
|
parameters.iridescence ? '#define USE_IRIDESCENCE' : '',
|
|
19939
20063
|
parameters.iridescenceMap ? '#define USE_IRIDESCENCEMAP' : '',
|
|
19940
20064
|
parameters.iridescenceThicknessMap ? '#define USE_IRIDESCENCE_THICKNESSMAP' : '',
|
|
@@ -20540,6 +20664,7 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
|
|
|
20540
20664
|
|
|
20541
20665
|
const HAS_ANISOTROPY = material.anisotropy > 0;
|
|
20542
20666
|
const HAS_CLEARCOAT = material.clearcoat > 0;
|
|
20667
|
+
const HAS_DISPERSION = material.dispersion > 0;
|
|
20543
20668
|
const HAS_IRIDESCENCE = material.iridescence > 0;
|
|
20544
20669
|
const HAS_SHEEN = material.sheen > 0;
|
|
20545
20670
|
const HAS_TRANSMISSION = material.transmission > 0;
|
|
@@ -20639,6 +20764,8 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
|
|
|
20639
20764
|
clearcoatNormalMap: HAS_CLEARCOAT_NORMALMAP,
|
|
20640
20765
|
clearcoatRoughnessMap: HAS_CLEARCOAT_ROUGHNESSMAP,
|
|
20641
20766
|
|
|
20767
|
+
dispersion: HAS_DISPERSION,
|
|
20768
|
+
|
|
20642
20769
|
iridescence: HAS_IRIDESCENCE,
|
|
20643
20770
|
iridescenceMap: HAS_IRIDESCENCEMAP,
|
|
20644
20771
|
iridescenceThicknessMap: HAS_IRIDESCENCE_THICKNESSMAP,
|
|
@@ -20919,6 +21046,8 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
|
|
|
20919
21046
|
_programLayers.enable( 18 );
|
|
20920
21047
|
if ( parameters.batching )
|
|
20921
21048
|
_programLayers.enable( 19 );
|
|
21049
|
+
if ( parameters.dispersion )
|
|
21050
|
+
_programLayers.enable( 20 );
|
|
20922
21051
|
|
|
20923
21052
|
array.push( _programLayers.mask );
|
|
20924
21053
|
_programLayers.disableAll();
|
|
@@ -21910,7 +22039,9 @@ function WebGLRenderState( extensions ) {
|
|
|
21910
22039
|
const lightsArray = [];
|
|
21911
22040
|
const shadowsArray = [];
|
|
21912
22041
|
|
|
21913
|
-
function init() {
|
|
22042
|
+
function init( camera ) {
|
|
22043
|
+
|
|
22044
|
+
state.camera = camera;
|
|
21914
22045
|
|
|
21915
22046
|
lightsArray.length = 0;
|
|
21916
22047
|
shadowsArray.length = 0;
|
|
@@ -21945,9 +22076,11 @@ function WebGLRenderState( extensions ) {
|
|
|
21945
22076
|
lightsArray: lightsArray,
|
|
21946
22077
|
shadowsArray: shadowsArray,
|
|
21947
22078
|
|
|
22079
|
+
camera: null,
|
|
22080
|
+
|
|
21948
22081
|
lights: lights,
|
|
21949
22082
|
|
|
21950
|
-
transmissionRenderTarget:
|
|
22083
|
+
transmissionRenderTarget: {}
|
|
21951
22084
|
};
|
|
21952
22085
|
|
|
21953
22086
|
return {
|
|
@@ -22102,7 +22235,7 @@ const vertex = "void main() {\n\tgl_Position = vec4( position, 1.0 );\n}";
|
|
|
22102
22235
|
|
|
22103
22236
|
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
22237
|
|
|
22105
|
-
function WebGLShadowMap(
|
|
22238
|
+
function WebGLShadowMap( renderer, objects, capabilities ) {
|
|
22106
22239
|
|
|
22107
22240
|
let _frustum = new Frustum();
|
|
22108
22241
|
|
|
@@ -22116,7 +22249,7 @@ function WebGLShadowMap( _renderer, _objects, _capabilities ) {
|
|
|
22116
22249
|
|
|
22117
22250
|
_materialCache = {},
|
|
22118
22251
|
|
|
22119
|
-
_maxTextureSize =
|
|
22252
|
+
_maxTextureSize = capabilities.maxTextureSize;
|
|
22120
22253
|
|
|
22121
22254
|
const shadowSide = { [ FrontSide ]: BackSide, [ BackSide ]: FrontSide, [ DoubleSide ]: DoubleSide };
|
|
22122
22255
|
|
|
@@ -22166,11 +22299,11 @@ function WebGLShadowMap( _renderer, _objects, _capabilities ) {
|
|
|
22166
22299
|
|
|
22167
22300
|
if ( lights.length === 0 ) return;
|
|
22168
22301
|
|
|
22169
|
-
const currentRenderTarget =
|
|
22170
|
-
const activeCubeFace =
|
|
22171
|
-
const activeMipmapLevel =
|
|
22302
|
+
const currentRenderTarget = renderer.getRenderTarget();
|
|
22303
|
+
const activeCubeFace = renderer.getActiveCubeFace();
|
|
22304
|
+
const activeMipmapLevel = renderer.getActiveMipmapLevel();
|
|
22172
22305
|
|
|
22173
|
-
const _state =
|
|
22306
|
+
const _state = renderer.state;
|
|
22174
22307
|
|
|
22175
22308
|
// Set GL state for depth map.
|
|
22176
22309
|
_state.setBlending( NoBlending );
|
|
@@ -22244,8 +22377,8 @@ function WebGLShadowMap( _renderer, _objects, _capabilities ) {
|
|
|
22244
22377
|
|
|
22245
22378
|
}
|
|
22246
22379
|
|
|
22247
|
-
|
|
22248
|
-
|
|
22380
|
+
renderer.setRenderTarget( shadow.map );
|
|
22381
|
+
renderer.clear();
|
|
22249
22382
|
|
|
22250
22383
|
const viewportCount = shadow.getViewportCount();
|
|
22251
22384
|
|
|
@@ -22286,13 +22419,13 @@ function WebGLShadowMap( _renderer, _objects, _capabilities ) {
|
|
|
22286
22419
|
|
|
22287
22420
|
scope.needsUpdate = false;
|
|
22288
22421
|
|
|
22289
|
-
|
|
22422
|
+
renderer.setRenderTarget( currentRenderTarget, activeCubeFace, activeMipmapLevel );
|
|
22290
22423
|
|
|
22291
22424
|
};
|
|
22292
22425
|
|
|
22293
22426
|
function VSMPass( shadow, camera ) {
|
|
22294
22427
|
|
|
22295
|
-
const geometry =
|
|
22428
|
+
const geometry = objects.update( fullScreenMesh );
|
|
22296
22429
|
|
|
22297
22430
|
if ( shadowMaterialVertical.defines.VSM_SAMPLES !== shadow.blurSamples ) {
|
|
22298
22431
|
|
|
@@ -22315,18 +22448,18 @@ function WebGLShadowMap( _renderer, _objects, _capabilities ) {
|
|
|
22315
22448
|
shadowMaterialVertical.uniforms.shadow_pass.value = shadow.map.texture;
|
|
22316
22449
|
shadowMaterialVertical.uniforms.resolution.value = shadow.mapSize;
|
|
22317
22450
|
shadowMaterialVertical.uniforms.radius.value = shadow.radius;
|
|
22318
|
-
|
|
22319
|
-
|
|
22320
|
-
|
|
22451
|
+
renderer.setRenderTarget( shadow.mapPass );
|
|
22452
|
+
renderer.clear();
|
|
22453
|
+
renderer.renderBufferDirect( camera, null, geometry, shadowMaterialVertical, fullScreenMesh, null );
|
|
22321
22454
|
|
|
22322
22455
|
// horizontal pass
|
|
22323
22456
|
|
|
22324
22457
|
shadowMaterialHorizontal.uniforms.shadow_pass.value = shadow.mapPass.texture;
|
|
22325
22458
|
shadowMaterialHorizontal.uniforms.resolution.value = shadow.mapSize;
|
|
22326
22459
|
shadowMaterialHorizontal.uniforms.radius.value = shadow.radius;
|
|
22327
|
-
|
|
22328
|
-
|
|
22329
|
-
|
|
22460
|
+
renderer.setRenderTarget( shadow.map );
|
|
22461
|
+
renderer.clear();
|
|
22462
|
+
renderer.renderBufferDirect( camera, null, geometry, shadowMaterialHorizontal, fullScreenMesh, null );
|
|
22330
22463
|
|
|
22331
22464
|
}
|
|
22332
22465
|
|
|
@@ -22344,7 +22477,7 @@ function WebGLShadowMap( _renderer, _objects, _capabilities ) {
|
|
|
22344
22477
|
|
|
22345
22478
|
result = ( light.isPointLight === true ) ? _distanceMaterial : _depthMaterial;
|
|
22346
22479
|
|
|
22347
|
-
if ( (
|
|
22480
|
+
if ( ( renderer.localClippingEnabled && material.clipShadows === true && Array.isArray( material.clippingPlanes ) && material.clippingPlanes.length !== 0 ) ||
|
|
22348
22481
|
( material.displacementMap && material.displacementScale !== 0 ) ||
|
|
22349
22482
|
( material.alphaMap && material.alphaTest > 0 ) ||
|
|
22350
22483
|
( material.map && material.alphaTest > 0 ) ) {
|
|
@@ -22409,7 +22542,7 @@ function WebGLShadowMap( _renderer, _objects, _capabilities ) {
|
|
|
22409
22542
|
|
|
22410
22543
|
if ( light.isPointLight === true && result.isMeshDistanceMaterial === true ) {
|
|
22411
22544
|
|
|
22412
|
-
const materialProperties =
|
|
22545
|
+
const materialProperties = renderer.properties.get( result );
|
|
22413
22546
|
materialProperties.light = light;
|
|
22414
22547
|
|
|
22415
22548
|
}
|
|
@@ -22430,7 +22563,7 @@ function WebGLShadowMap( _renderer, _objects, _capabilities ) {
|
|
|
22430
22563
|
|
|
22431
22564
|
object.modelViewMatrix.multiplyMatrices( shadowCamera.matrixWorldInverse, object.matrixWorld );
|
|
22432
22565
|
|
|
22433
|
-
const geometry =
|
|
22566
|
+
const geometry = objects.update( object );
|
|
22434
22567
|
const material = object.material;
|
|
22435
22568
|
|
|
22436
22569
|
if ( Array.isArray( material ) ) {
|
|
@@ -22446,11 +22579,11 @@ function WebGLShadowMap( _renderer, _objects, _capabilities ) {
|
|
|
22446
22579
|
|
|
22447
22580
|
const depthMaterial = getDepthMaterial( object, groupMaterial, light, type );
|
|
22448
22581
|
|
|
22449
|
-
object.onBeforeShadow(
|
|
22582
|
+
object.onBeforeShadow( renderer, object, camera, shadowCamera, geometry, depthMaterial, group );
|
|
22450
22583
|
|
|
22451
|
-
|
|
22584
|
+
renderer.renderBufferDirect( shadowCamera, null, geometry, depthMaterial, object, group );
|
|
22452
22585
|
|
|
22453
|
-
object.onAfterShadow(
|
|
22586
|
+
object.onAfterShadow( renderer, object, camera, shadowCamera, geometry, depthMaterial, group );
|
|
22454
22587
|
|
|
22455
22588
|
}
|
|
22456
22589
|
|
|
@@ -22460,11 +22593,11 @@ function WebGLShadowMap( _renderer, _objects, _capabilities ) {
|
|
|
22460
22593
|
|
|
22461
22594
|
const depthMaterial = getDepthMaterial( object, material, light, type );
|
|
22462
22595
|
|
|
22463
|
-
object.onBeforeShadow(
|
|
22596
|
+
object.onBeforeShadow( renderer, object, camera, shadowCamera, geometry, depthMaterial, null );
|
|
22464
22597
|
|
|
22465
|
-
|
|
22598
|
+
renderer.renderBufferDirect( shadowCamera, null, geometry, depthMaterial, object, null );
|
|
22466
22599
|
|
|
22467
|
-
object.onAfterShadow(
|
|
22600
|
+
object.onAfterShadow( renderer, object, camera, shadowCamera, geometry, depthMaterial, null );
|
|
22468
22601
|
|
|
22469
22602
|
}
|
|
22470
22603
|
|
|
@@ -24523,7 +24656,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
24523
24656
|
let mipmap;
|
|
24524
24657
|
const mipmaps = texture.mipmaps;
|
|
24525
24658
|
|
|
24526
|
-
const useTexStorage = ( texture.isVideoTexture !== true
|
|
24659
|
+
const useTexStorage = ( texture.isVideoTexture !== true );
|
|
24527
24660
|
const allocateMemory = ( sourceProperties.__version === undefined ) || ( forceUpload === true );
|
|
24528
24661
|
const dataReady = source.dataReady;
|
|
24529
24662
|
const levels = getMipLevels( texture, image );
|
|
@@ -25780,112 +25913,120 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
25780
25913
|
|
|
25781
25914
|
}
|
|
25782
25915
|
|
|
25916
|
+
const invalidationArrayRead = [];
|
|
25917
|
+
const invalidationArrayDraw = [];
|
|
25918
|
+
|
|
25783
25919
|
function updateMultisampleRenderTarget( renderTarget ) {
|
|
25784
25920
|
|
|
25785
|
-
if (
|
|
25921
|
+
if ( renderTarget.samples > 0 ) {
|
|
25786
25922
|
|
|
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 );
|
|
25923
|
+
if ( useMultisampledRTT( renderTarget ) === false ) {
|
|
25795
25924
|
|
|
25796
|
-
|
|
25797
|
-
|
|
25925
|
+
const textures = renderTarget.textures;
|
|
25926
|
+
const width = renderTarget.width;
|
|
25927
|
+
const height = renderTarget.height;
|
|
25928
|
+
let mask = _gl.COLOR_BUFFER_BIT;
|
|
25929
|
+
const depthStyle = renderTarget.stencilBuffer ? _gl.DEPTH_STENCIL_ATTACHMENT : _gl.DEPTH_ATTACHMENT;
|
|
25930
|
+
const renderTargetProperties = properties.get( renderTarget );
|
|
25931
|
+
const isMultipleRenderTargets = ( textures.length > 1 );
|
|
25798
25932
|
|
|
25799
|
-
|
|
25933
|
+
// If MRT we need to remove FBO attachments
|
|
25934
|
+
if ( isMultipleRenderTargets ) {
|
|
25935
|
+
|
|
25936
|
+
for ( let i = 0; i < textures.length; i ++ ) {
|
|
25800
25937
|
|
|
25801
|
-
|
|
25802
|
-
|
|
25938
|
+
state.bindFramebuffer( _gl.FRAMEBUFFER, renderTargetProperties.__webglMultisampledFramebuffer );
|
|
25939
|
+
_gl.framebufferRenderbuffer( _gl.FRAMEBUFFER, _gl.COLOR_ATTACHMENT0 + i, _gl.RENDERBUFFER, null );
|
|
25803
25940
|
|
|
25804
|
-
|
|
25805
|
-
|
|
25941
|
+
state.bindFramebuffer( _gl.FRAMEBUFFER, renderTargetProperties.__webglFramebuffer );
|
|
25942
|
+
_gl.framebufferTexture2D( _gl.DRAW_FRAMEBUFFER, _gl.COLOR_ATTACHMENT0 + i, _gl.TEXTURE_2D, null, 0 );
|
|
25943
|
+
|
|
25944
|
+
}
|
|
25806
25945
|
|
|
25807
25946
|
}
|
|
25808
25947
|
|
|
25809
|
-
|
|
25948
|
+
state.bindFramebuffer( _gl.READ_FRAMEBUFFER, renderTargetProperties.__webglMultisampledFramebuffer );
|
|
25949
|
+
state.bindFramebuffer( _gl.DRAW_FRAMEBUFFER, renderTargetProperties.__webglFramebuffer );
|
|
25810
25950
|
|
|
25811
|
-
|
|
25812
|
-
state.bindFramebuffer( _gl.DRAW_FRAMEBUFFER, renderTargetProperties.__webglFramebuffer );
|
|
25951
|
+
for ( let i = 0; i < textures.length; i ++ ) {
|
|
25813
25952
|
|
|
25814
|
-
|
|
25953
|
+
if ( renderTarget.resolveDepthBuffer ) {
|
|
25815
25954
|
|
|
25816
|
-
|
|
25955
|
+
if ( renderTarget.depthBuffer ) mask |= _gl.DEPTH_BUFFER_BIT;
|
|
25817
25956
|
|
|
25818
|
-
|
|
25957
|
+
// resolving stencil is slow with a D3D backend. disable it for all transmission render targets (see #27799)
|
|
25819
25958
|
|
|
25820
|
-
|
|
25959
|
+
if ( renderTarget.stencilBuffer && renderTarget.resolveStencilBuffer ) mask |= _gl.STENCIL_BUFFER_BIT;
|
|
25821
25960
|
|
|
25822
|
-
|
|
25961
|
+
}
|
|
25823
25962
|
|
|
25824
|
-
|
|
25963
|
+
if ( isMultipleRenderTargets ) {
|
|
25825
25964
|
|
|
25826
|
-
|
|
25965
|
+
_gl.framebufferRenderbuffer( _gl.READ_FRAMEBUFFER, _gl.COLOR_ATTACHMENT0, _gl.RENDERBUFFER, renderTargetProperties.__webglColorRenderbuffer[ i ] );
|
|
25827
25966
|
|
|
25828
|
-
|
|
25967
|
+
const webglTexture = properties.get( textures[ i ] ).__webglTexture;
|
|
25968
|
+
_gl.framebufferTexture2D( _gl.DRAW_FRAMEBUFFER, _gl.COLOR_ATTACHMENT0, _gl.TEXTURE_2D, webglTexture, 0 );
|
|
25829
25969
|
|
|
25830
|
-
|
|
25970
|
+
}
|
|
25831
25971
|
|
|
25832
|
-
|
|
25972
|
+
_gl.blitFramebuffer( 0, 0, width, height, 0, 0, width, height, mask, _gl.NEAREST );
|
|
25833
25973
|
|
|
25834
|
-
|
|
25974
|
+
if ( supportsInvalidateFramebuffer === true ) {
|
|
25835
25975
|
|
|
25836
|
-
|
|
25976
|
+
invalidationArrayRead.length = 0;
|
|
25977
|
+
invalidationArrayDraw.length = 0;
|
|
25837
25978
|
|
|
25838
|
-
|
|
25979
|
+
invalidationArrayRead.push( _gl.COLOR_ATTACHMENT0 + i );
|
|
25839
25980
|
|
|
25840
|
-
|
|
25981
|
+
if ( renderTarget.depthBuffer && renderTarget.resolveDepthBuffer === false ) {
|
|
25841
25982
|
|
|
25842
|
-
|
|
25983
|
+
invalidationArrayRead.push( depthStyle );
|
|
25984
|
+
invalidationArrayDraw.push( depthStyle );
|
|
25843
25985
|
|
|
25844
|
-
|
|
25845
|
-
_gl.invalidateFramebuffer( _gl.DRAW_FRAMEBUFFER, [ depthStyle ] );
|
|
25986
|
+
_gl.invalidateFramebuffer( _gl.DRAW_FRAMEBUFFER, invalidationArrayDraw );
|
|
25846
25987
|
|
|
25847
|
-
|
|
25988
|
+
}
|
|
25848
25989
|
|
|
25849
|
-
|
|
25990
|
+
_gl.invalidateFramebuffer( _gl.READ_FRAMEBUFFER, invalidationArrayRead );
|
|
25850
25991
|
|
|
25851
|
-
|
|
25852
|
-
_gl.framebufferTexture2D( _gl.DRAW_FRAMEBUFFER, _gl.COLOR_ATTACHMENT0, _gl.TEXTURE_2D, webglTexture, 0 );
|
|
25992
|
+
}
|
|
25853
25993
|
|
|
25854
25994
|
}
|
|
25855
25995
|
|
|
25856
|
-
|
|
25996
|
+
state.bindFramebuffer( _gl.READ_FRAMEBUFFER, null );
|
|
25997
|
+
state.bindFramebuffer( _gl.DRAW_FRAMEBUFFER, null );
|
|
25857
25998
|
|
|
25858
|
-
|
|
25999
|
+
// If MRT since pre-blit we removed the FBO we need to reconstruct the attachments
|
|
26000
|
+
if ( isMultipleRenderTargets ) {
|
|
25859
26001
|
|
|
25860
|
-
|
|
26002
|
+
for ( let i = 0; i < textures.length; i ++ ) {
|
|
25861
26003
|
|
|
25862
|
-
|
|
26004
|
+
state.bindFramebuffer( _gl.FRAMEBUFFER, renderTargetProperties.__webglMultisampledFramebuffer );
|
|
26005
|
+
_gl.framebufferRenderbuffer( _gl.FRAMEBUFFER, _gl.COLOR_ATTACHMENT0 + i, _gl.RENDERBUFFER, renderTargetProperties.__webglColorRenderbuffer[ i ] );
|
|
25863
26006
|
|
|
26007
|
+
const webglTexture = properties.get( textures[ i ] ).__webglTexture;
|
|
25864
26008
|
|
|
25865
|
-
|
|
26009
|
+
state.bindFramebuffer( _gl.FRAMEBUFFER, renderTargetProperties.__webglFramebuffer );
|
|
26010
|
+
_gl.framebufferTexture2D( _gl.DRAW_FRAMEBUFFER, _gl.COLOR_ATTACHMENT0 + i, _gl.TEXTURE_2D, webglTexture, 0 );
|
|
25866
26011
|
|
|
25867
|
-
|
|
25868
|
-
state.bindFramebuffer( _gl.DRAW_FRAMEBUFFER, null );
|
|
26012
|
+
}
|
|
25869
26013
|
|
|
25870
|
-
|
|
25871
|
-
if ( isMultipleRenderTargets ) {
|
|
26014
|
+
}
|
|
25872
26015
|
|
|
25873
|
-
|
|
26016
|
+
state.bindFramebuffer( _gl.DRAW_FRAMEBUFFER, renderTargetProperties.__webglMultisampledFramebuffer );
|
|
25874
26017
|
|
|
25875
|
-
|
|
25876
|
-
_gl.framebufferRenderbuffer( _gl.FRAMEBUFFER, _gl.COLOR_ATTACHMENT0 + i, _gl.RENDERBUFFER, renderTargetProperties.__webglColorRenderbuffer[ i ] );
|
|
26018
|
+
} else {
|
|
25877
26019
|
|
|
25878
|
-
|
|
26020
|
+
if ( renderTarget.depthBuffer && renderTarget.resolveDepthBuffer === false && supportsInvalidateFramebuffer ) {
|
|
25879
26021
|
|
|
25880
|
-
|
|
25881
|
-
|
|
26022
|
+
const depthStyle = renderTarget.stencilBuffer ? _gl.DEPTH_STENCIL_ATTACHMENT : _gl.DEPTH_ATTACHMENT;
|
|
26023
|
+
|
|
26024
|
+
_gl.invalidateFramebuffer( _gl.DRAW_FRAMEBUFFER, [ depthStyle ] );
|
|
25882
26025
|
|
|
25883
26026
|
}
|
|
25884
26027
|
|
|
25885
26028
|
}
|
|
25886
26029
|
|
|
25887
|
-
state.bindFramebuffer( _gl.DRAW_FRAMEBUFFER, renderTargetProperties.__webglMultisampledFramebuffer );
|
|
25888
|
-
|
|
25889
26030
|
}
|
|
25890
26031
|
|
|
25891
26032
|
}
|
|
@@ -26101,33 +26242,15 @@ function WebGLUtils( gl, extensions ) {
|
|
|
26101
26242
|
|
|
26102
26243
|
}
|
|
26103
26244
|
|
|
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
|
-
}
|
|
26121
|
-
|
|
26122
|
-
// ETC2
|
|
26245
|
+
// ETC
|
|
26123
26246
|
|
|
26124
|
-
if ( p === RGB_ETC2_Format || p === RGBA_ETC2_EAC_Format ) {
|
|
26247
|
+
if ( p === RGB_ETC1_Format || p === RGB_ETC2_Format || p === RGBA_ETC2_EAC_Format ) {
|
|
26125
26248
|
|
|
26126
26249
|
extension = extensions.get( 'WEBGL_compressed_texture_etc' );
|
|
26127
26250
|
|
|
26128
26251
|
if ( extension !== null ) {
|
|
26129
26252
|
|
|
26130
|
-
if ( p === RGB_ETC2_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB8_ETC2 : extension.COMPRESSED_RGB8_ETC2;
|
|
26253
|
+
if ( p === RGB_ETC1_Format || p === RGB_ETC2_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB8_ETC2 : extension.COMPRESSED_RGB8_ETC2;
|
|
26131
26254
|
if ( p === RGBA_ETC2_EAC_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC : extension.COMPRESSED_RGBA8_ETC2_EAC;
|
|
26132
26255
|
|
|
26133
26256
|
} else {
|
|
@@ -27620,7 +27743,8 @@ class WebXRManager extends EventDispatcher {
|
|
|
27620
27743
|
depthTexture: new DepthTexture( glProjLayer.textureWidth, glProjLayer.textureHeight, depthType, undefined, undefined, undefined, undefined, undefined, undefined, depthFormat ),
|
|
27621
27744
|
stencilBuffer: attributes.stencil,
|
|
27622
27745
|
colorSpace: renderer.outputColorSpace,
|
|
27623
|
-
samples: attributes.antialias ? 4 : 0
|
|
27746
|
+
samples: attributes.antialias ? 4 : 0,
|
|
27747
|
+
resolveDepthBuffer: ( glProjLayer.ignoreDepthValues === false )
|
|
27624
27748
|
};
|
|
27625
27749
|
|
|
27626
27750
|
if ( scope.isMultiview ) {
|
|
@@ -27640,9 +27764,6 @@ class WebXRManager extends EventDispatcher {
|
|
|
27640
27764
|
|
|
27641
27765
|
}
|
|
27642
27766
|
|
|
27643
|
-
const renderTargetProperties = renderer.properties.get( newRenderTarget );
|
|
27644
|
-
renderTargetProperties.__ignoreDepthValues = glProjLayer.ignoreDepthValues;
|
|
27645
|
-
|
|
27646
27767
|
}
|
|
27647
27768
|
|
|
27648
27769
|
newRenderTarget.isXRRenderTarget = true; // TODO Remove this when possible, see #23278
|
|
@@ -28608,6 +28729,12 @@ function WebGLMaterials( renderer, properties ) {
|
|
|
28608
28729
|
|
|
28609
28730
|
}
|
|
28610
28731
|
|
|
28732
|
+
if ( material.dispersion > 0 ) {
|
|
28733
|
+
|
|
28734
|
+
uniforms.dispersion.value = material.dispersion;
|
|
28735
|
+
|
|
28736
|
+
}
|
|
28737
|
+
|
|
28611
28738
|
if ( material.iridescence > 0 ) {
|
|
28612
28739
|
|
|
28613
28740
|
uniforms.iridescence.value = material.iridescence;
|
|
@@ -29260,7 +29387,6 @@ class WebGLRenderer {
|
|
|
29260
29387
|
|
|
29261
29388
|
const _projScreenMatrix = new Matrix4();
|
|
29262
29389
|
|
|
29263
|
-
const _vector2 = new Vector2();
|
|
29264
29390
|
const _vector3 = new Vector3();
|
|
29265
29391
|
|
|
29266
29392
|
const _emptyScene = { background: null, fog: null, environment: null, overrideMaterial: null, isScene: true };
|
|
@@ -29277,10 +29403,7 @@ class WebGLRenderer {
|
|
|
29277
29403
|
|
|
29278
29404
|
function getContext( contextName, contextAttributes ) {
|
|
29279
29405
|
|
|
29280
|
-
|
|
29281
|
-
if ( context !== null ) return context;
|
|
29282
|
-
|
|
29283
|
-
return null;
|
|
29406
|
+
return canvas.getContext( contextName, contextAttributes );
|
|
29284
29407
|
|
|
29285
29408
|
}
|
|
29286
29409
|
|
|
@@ -29348,10 +29471,10 @@ class WebGLRenderer {
|
|
|
29348
29471
|
extensions = new WebGLExtensions( _gl );
|
|
29349
29472
|
extensions.init();
|
|
29350
29473
|
|
|
29351
|
-
capabilities = new WebGLCapabilities( _gl, extensions, parameters );
|
|
29352
|
-
|
|
29353
29474
|
utils = new WebGLUtils( _gl, extensions );
|
|
29354
29475
|
|
|
29476
|
+
capabilities = new WebGLCapabilities( _gl, extensions, parameters, utils );
|
|
29477
|
+
|
|
29355
29478
|
state = new WebGLState( _gl );
|
|
29356
29479
|
|
|
29357
29480
|
info = new WebGLInfo( _gl );
|
|
@@ -29917,7 +30040,15 @@ class WebGLRenderer {
|
|
|
29917
30040
|
|
|
29918
30041
|
if ( object.isBatchedMesh ) {
|
|
29919
30042
|
|
|
29920
|
-
|
|
30043
|
+
if ( object._multiDrawInstances !== null ) {
|
|
30044
|
+
|
|
30045
|
+
renderer.renderMultiDrawInstances( object._multiDrawStarts, object._multiDrawCounts, object._multiDrawCount, object._multiDrawInstances );
|
|
30046
|
+
|
|
30047
|
+
} else {
|
|
30048
|
+
|
|
30049
|
+
renderer.renderMultiDraw( object._multiDrawStarts, object._multiDrawCounts, object._multiDrawCount );
|
|
30050
|
+
|
|
30051
|
+
}
|
|
29921
30052
|
|
|
29922
30053
|
} else if ( object.isInstancedMesh ) {
|
|
29923
30054
|
|
|
@@ -29967,7 +30098,7 @@ class WebGLRenderer {
|
|
|
29967
30098
|
if ( targetScene === null ) targetScene = scene;
|
|
29968
30099
|
|
|
29969
30100
|
currentRenderState = renderStates.get( targetScene );
|
|
29970
|
-
currentRenderState.init();
|
|
30101
|
+
currentRenderState.init( camera );
|
|
29971
30102
|
|
|
29972
30103
|
renderStateStack.push( currentRenderState );
|
|
29973
30104
|
|
|
@@ -30184,7 +30315,7 @@ class WebGLRenderer {
|
|
|
30184
30315
|
if ( scene.isScene === true ) scene.onBeforeRender( _this, scene, camera, _currentRenderTarget );
|
|
30185
30316
|
|
|
30186
30317
|
currentRenderState = renderStates.get( scene, renderStateStack.length );
|
|
30187
|
-
currentRenderState.init();
|
|
30318
|
+
currentRenderState.init( camera );
|
|
30188
30319
|
|
|
30189
30320
|
renderStateStack.push( currentRenderState );
|
|
30190
30321
|
|
|
@@ -30209,6 +30340,13 @@ class WebGLRenderer {
|
|
|
30209
30340
|
|
|
30210
30341
|
}
|
|
30211
30342
|
|
|
30343
|
+
const renderBackground = xr.enabled === false || xr.isPresenting === false || xr.hasDepthSensing() === false;
|
|
30344
|
+
if ( renderBackground ) {
|
|
30345
|
+
|
|
30346
|
+
background.addToRenderList( currentRenderList, scene );
|
|
30347
|
+
|
|
30348
|
+
}
|
|
30349
|
+
|
|
30212
30350
|
//
|
|
30213
30351
|
|
|
30214
30352
|
this.info.render.frame ++;
|
|
@@ -30225,20 +30363,30 @@ class WebGLRenderer {
|
|
|
30225
30363
|
|
|
30226
30364
|
if ( this.info.autoReset === true ) this.info.reset();
|
|
30227
30365
|
|
|
30366
|
+
// render scene
|
|
30228
30367
|
|
|
30229
|
-
|
|
30368
|
+
const opaqueObjects = currentRenderList.opaque;
|
|
30369
|
+
const transmissiveObjects = currentRenderList.transmissive;
|
|
30230
30370
|
|
|
30231
|
-
|
|
30371
|
+
currentRenderState.setupLights( _this._useLegacyLights );
|
|
30232
30372
|
|
|
30233
|
-
|
|
30373
|
+
if ( camera.isArrayCamera ) {
|
|
30234
30374
|
|
|
30235
|
-
|
|
30375
|
+
const cameras = camera.cameras;
|
|
30236
30376
|
|
|
30237
|
-
|
|
30377
|
+
if ( transmissiveObjects.length > 0 ) {
|
|
30238
30378
|
|
|
30239
|
-
|
|
30379
|
+
for ( let i = 0, l = cameras.length; i < l; i ++ ) {
|
|
30240
30380
|
|
|
30241
|
-
|
|
30381
|
+
const camera2 = cameras[ i ];
|
|
30382
|
+
|
|
30383
|
+
renderTransmissionPass( opaqueObjects, transmissiveObjects, scene, camera2 );
|
|
30384
|
+
|
|
30385
|
+
}
|
|
30386
|
+
|
|
30387
|
+
}
|
|
30388
|
+
|
|
30389
|
+
if ( renderBackground ) background.render( scene );
|
|
30242
30390
|
|
|
30243
30391
|
if ( xr.enabled && xr.isMultiview ) {
|
|
30244
30392
|
|
|
@@ -30248,8 +30396,6 @@ class WebGLRenderer {
|
|
|
30248
30396
|
|
|
30249
30397
|
} else {
|
|
30250
30398
|
|
|
30251
|
-
const cameras = camera.cameras;
|
|
30252
|
-
|
|
30253
30399
|
for ( let i = 0, l = cameras.length; i < l; i ++ ) {
|
|
30254
30400
|
|
|
30255
30401
|
const camera2 = cameras[ i ];
|
|
@@ -30262,6 +30408,10 @@ class WebGLRenderer {
|
|
|
30262
30408
|
|
|
30263
30409
|
} else {
|
|
30264
30410
|
|
|
30411
|
+
if ( transmissiveObjects.length > 0 ) renderTransmissionPass( opaqueObjects, transmissiveObjects, scene, camera );
|
|
30412
|
+
|
|
30413
|
+
if ( renderBackground ) background.render( scene );
|
|
30414
|
+
|
|
30265
30415
|
renderScene( currentRenderList, scene, camera );
|
|
30266
30416
|
|
|
30267
30417
|
}
|
|
@@ -30303,6 +30453,8 @@ class WebGLRenderer {
|
|
|
30303
30453
|
|
|
30304
30454
|
currentRenderState = renderStateStack[ renderStateStack.length - 1 ];
|
|
30305
30455
|
|
|
30456
|
+
if ( _clippingEnabled === true ) clipping.setGlobalState( _this.clippingPlanes, currentRenderState.state.camera );
|
|
30457
|
+
|
|
30306
30458
|
} else {
|
|
30307
30459
|
|
|
30308
30460
|
currentRenderState = null;
|
|
@@ -30447,8 +30599,6 @@ class WebGLRenderer {
|
|
|
30447
30599
|
|
|
30448
30600
|
if ( _clippingEnabled === true ) clipping.setGlobalState( _this.clippingPlanes, camera );
|
|
30449
30601
|
|
|
30450
|
-
if ( transmissiveObjects.length > 0 ) renderTransmissionPass( opaqueObjects, transmissiveObjects, scene, camera );
|
|
30451
|
-
|
|
30452
30602
|
if ( viewport ) state.viewport( _currentViewport.copy( viewport ) );
|
|
30453
30603
|
|
|
30454
30604
|
if ( opaqueObjects.length > 0 ) renderObjects( opaqueObjects, scene, camera );
|
|
@@ -30475,19 +30625,18 @@ class WebGLRenderer {
|
|
|
30475
30625
|
|
|
30476
30626
|
}
|
|
30477
30627
|
|
|
30478
|
-
if ( currentRenderState.state.transmissionRenderTarget ===
|
|
30628
|
+
if ( currentRenderState.state.transmissionRenderTarget[ camera.id ] === undefined ) {
|
|
30479
30629
|
|
|
30480
|
-
currentRenderState.state.transmissionRenderTarget = new WebGLRenderTarget( 1, 1, {
|
|
30630
|
+
currentRenderState.state.transmissionRenderTarget[ camera.id ] = new WebGLRenderTarget( 1, 1, {
|
|
30481
30631
|
generateMipmaps: true,
|
|
30482
30632
|
type: ( extensions.has( 'EXT_color_buffer_half_float' ) || extensions.has( 'EXT_color_buffer_float' ) ) ? HalfFloatType : UnsignedByteType,
|
|
30483
30633
|
minFilter: LinearMipmapLinearFilter,
|
|
30484
30634
|
samples: 4,
|
|
30485
|
-
stencilBuffer: stencil
|
|
30635
|
+
stencilBuffer: stencil,
|
|
30636
|
+
resolveDepthBuffer: false,
|
|
30637
|
+
resolveStencilBuffer: false
|
|
30486
30638
|
} );
|
|
30487
30639
|
|
|
30488
|
-
const renderTargetProperties = properties.get( currentRenderState.state.transmissionRenderTarget );
|
|
30489
|
-
renderTargetProperties.__isTransmissionRenderTarget = true;
|
|
30490
|
-
|
|
30491
30640
|
// debug
|
|
30492
30641
|
|
|
30493
30642
|
/*
|
|
@@ -30500,10 +30649,10 @@ class WebGLRenderer {
|
|
|
30500
30649
|
|
|
30501
30650
|
}
|
|
30502
30651
|
|
|
30503
|
-
const transmissionRenderTarget = currentRenderState.state.transmissionRenderTarget;
|
|
30652
|
+
const transmissionRenderTarget = currentRenderState.state.transmissionRenderTarget[ camera.id ];
|
|
30504
30653
|
|
|
30505
|
-
|
|
30506
|
-
transmissionRenderTarget.setSize(
|
|
30654
|
+
const activeViewport = camera.viewport || _currentViewport;
|
|
30655
|
+
transmissionRenderTarget.setSize( activeViewport.z, activeViewport.w );
|
|
30507
30656
|
|
|
30508
30657
|
//
|
|
30509
30658
|
|
|
@@ -30521,44 +30670,57 @@ class WebGLRenderer {
|
|
|
30521
30670
|
const currentToneMapping = _this.toneMapping;
|
|
30522
30671
|
_this.toneMapping = NoToneMapping;
|
|
30523
30672
|
|
|
30673
|
+
// Remove viewport from camera to avoid nested render calls resetting viewport to it (e.g Reflector).
|
|
30674
|
+
// Transmission render pass requires viewport to match the transmissionRenderTarget.
|
|
30675
|
+
const currentCameraViewport = camera.viewport;
|
|
30676
|
+
if ( camera.viewport !== undefined ) camera.viewport = undefined;
|
|
30677
|
+
|
|
30678
|
+
currentRenderState.setupLightsView( camera );
|
|
30679
|
+
|
|
30680
|
+
if ( _clippingEnabled === true ) clipping.setGlobalState( _this.clippingPlanes, camera );
|
|
30681
|
+
|
|
30524
30682
|
renderObjects( opaqueObjects, scene, camera );
|
|
30525
30683
|
|
|
30526
30684
|
textures.updateMultisampleRenderTarget( transmissionRenderTarget );
|
|
30527
30685
|
textures.updateRenderTargetMipmap( transmissionRenderTarget );
|
|
30528
30686
|
|
|
30529
|
-
|
|
30687
|
+
if ( extensions.has( 'WEBGL_multisampled_render_to_texture' ) === false ) { // see #28131
|
|
30530
30688
|
|
|
30531
|
-
|
|
30689
|
+
let renderTargetNeedsUpdate = false;
|
|
30532
30690
|
|
|
30533
|
-
|
|
30691
|
+
for ( let i = 0, l = transmissiveObjects.length; i < l; i ++ ) {
|
|
30534
30692
|
|
|
30535
|
-
|
|
30536
|
-
const geometry = renderItem.geometry;
|
|
30537
|
-
const material = renderItem.material;
|
|
30538
|
-
const group = renderItem.group;
|
|
30693
|
+
const renderItem = transmissiveObjects[ i ];
|
|
30539
30694
|
|
|
30540
|
-
|
|
30695
|
+
const object = renderItem.object;
|
|
30696
|
+
const geometry = renderItem.geometry;
|
|
30697
|
+
const material = renderItem.material;
|
|
30698
|
+
const group = renderItem.group;
|
|
30541
30699
|
|
|
30542
|
-
|
|
30700
|
+
if ( material.side === DoubleSide && object.layers.test( camera.layers ) ) {
|
|
30543
30701
|
|
|
30544
|
-
|
|
30545
|
-
material.needsUpdate = true;
|
|
30702
|
+
const currentSide = material.side;
|
|
30546
30703
|
|
|
30547
|
-
|
|
30704
|
+
material.side = BackSide;
|
|
30705
|
+
material.needsUpdate = true;
|
|
30706
|
+
|
|
30707
|
+
renderObject( object, scene, camera, geometry, material, group );
|
|
30548
30708
|
|
|
30549
|
-
|
|
30550
|
-
|
|
30709
|
+
material.side = currentSide;
|
|
30710
|
+
material.needsUpdate = true;
|
|
30551
30711
|
|
|
30552
|
-
|
|
30712
|
+
renderTargetNeedsUpdate = true;
|
|
30713
|
+
|
|
30714
|
+
}
|
|
30553
30715
|
|
|
30554
30716
|
}
|
|
30555
30717
|
|
|
30556
|
-
|
|
30718
|
+
if ( renderTargetNeedsUpdate === true ) {
|
|
30557
30719
|
|
|
30558
|
-
|
|
30720
|
+
textures.updateMultisampleRenderTarget( transmissionRenderTarget );
|
|
30721
|
+
textures.updateRenderTargetMipmap( transmissionRenderTarget );
|
|
30559
30722
|
|
|
30560
|
-
|
|
30561
|
-
textures.updateRenderTargetMipmap( transmissionRenderTarget );
|
|
30723
|
+
}
|
|
30562
30724
|
|
|
30563
30725
|
}
|
|
30564
30726
|
|
|
@@ -30566,6 +30728,8 @@ class WebGLRenderer {
|
|
|
30566
30728
|
|
|
30567
30729
|
_this.setClearColor( _currentClearColor, _currentClearAlpha );
|
|
30568
30730
|
|
|
30731
|
+
if ( currentCameraViewport !== undefined ) camera.viewport = currentCameraViewport;
|
|
30732
|
+
|
|
30569
30733
|
_this.toneMapping = currentToneMapping;
|
|
30570
30734
|
|
|
30571
30735
|
}
|
|
@@ -31113,7 +31277,7 @@ class WebGLRenderer {
|
|
|
31113
31277
|
|
|
31114
31278
|
}
|
|
31115
31279
|
|
|
31116
|
-
materials.refreshMaterialUniforms( m_uniforms, material, _pixelRatio, _height, currentRenderState.state.transmissionRenderTarget );
|
|
31280
|
+
materials.refreshMaterialUniforms( m_uniforms, material, _pixelRatio, _height, currentRenderState.state.transmissionRenderTarget[ camera.id ] );
|
|
31117
31281
|
|
|
31118
31282
|
WebGLUniforms.upload( _gl, getUniformList( materialProperties ), m_uniforms, textures );
|
|
31119
31283
|
|
|
@@ -31413,17 +31577,14 @@ class WebGLRenderer {
|
|
|
31413
31577
|
const textureFormat = texture.format;
|
|
31414
31578
|
const textureType = texture.type;
|
|
31415
31579
|
|
|
31416
|
-
if (
|
|
31580
|
+
if ( ! capabilities.textureFormatReadable( textureFormat ) ) {
|
|
31417
31581
|
|
|
31418
31582
|
console.error( 'THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.' );
|
|
31419
31583
|
return;
|
|
31420
31584
|
|
|
31421
31585
|
}
|
|
31422
31586
|
|
|
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 ) {
|
|
31587
|
+
if ( ! capabilities.textureTypeReadable( textureType ) ) {
|
|
31427
31588
|
|
|
31428
31589
|
console.error( 'THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.' );
|
|
31429
31590
|
return;
|
|
@@ -31507,9 +31668,9 @@ class WebGLRenderer {
|
|
|
31507
31668
|
|
|
31508
31669
|
this.copyTextureToTexture3D = function ( sourceBox, position, srcTexture, dstTexture, level = 0 ) {
|
|
31509
31670
|
|
|
31510
|
-
const width =
|
|
31511
|
-
const height =
|
|
31512
|
-
const depth = sourceBox.max.z - sourceBox.min.z
|
|
31671
|
+
const width = sourceBox.max.x - sourceBox.min.x;
|
|
31672
|
+
const height = sourceBox.max.y - sourceBox.min.y;
|
|
31673
|
+
const depth = sourceBox.max.z - sourceBox.min.z;
|
|
31513
31674
|
const glFormat = utils.convert( dstTexture.format );
|
|
31514
31675
|
const glType = utils.convert( dstTexture.type );
|
|
31515
31676
|
let glTarget;
|
|
@@ -33728,6 +33889,7 @@ class BatchedMesh extends Mesh {
|
|
|
33728
33889
|
this._multiDrawCounts = new Int32Array( maxGeometryCount );
|
|
33729
33890
|
this._multiDrawStarts = new Int32Array( maxGeometryCount );
|
|
33730
33891
|
this._multiDrawCount = 0;
|
|
33892
|
+
this._multiDrawInstances = null;
|
|
33731
33893
|
this._visibilityChanged = true;
|
|
33732
33894
|
|
|
33733
33895
|
// Local matrix per geometry by using data texture
|
|
@@ -34169,6 +34331,28 @@ class BatchedMesh extends Mesh {
|
|
|
34169
34331
|
|
|
34170
34332
|
}
|
|
34171
34333
|
|
|
34334
|
+
getInstanceCountAt( id ) {
|
|
34335
|
+
|
|
34336
|
+
if ( this._multiDrawInstances === null ) return null;
|
|
34337
|
+
|
|
34338
|
+
return this._multiDrawInstances[ id ];
|
|
34339
|
+
|
|
34340
|
+
}
|
|
34341
|
+
|
|
34342
|
+
setInstanceCountAt( id, instanceCount ) {
|
|
34343
|
+
|
|
34344
|
+
if ( this._multiDrawInstances === null ) {
|
|
34345
|
+
|
|
34346
|
+
this._multiDrawInstances = new Int32Array( this._maxGeometryCount ).fill( 1 );
|
|
34347
|
+
|
|
34348
|
+
}
|
|
34349
|
+
|
|
34350
|
+
this._multiDrawInstances[ id ] = instanceCount;
|
|
34351
|
+
|
|
34352
|
+
return id;
|
|
34353
|
+
|
|
34354
|
+
}
|
|
34355
|
+
|
|
34172
34356
|
// get bounding box and compute it if it doesn't exist
|
|
34173
34357
|
getBoundingBoxAt( id, target ) {
|
|
34174
34358
|
|
|
@@ -34638,12 +34822,16 @@ class LineBasicMaterial extends Material {
|
|
|
34638
34822
|
|
|
34639
34823
|
}
|
|
34640
34824
|
|
|
34641
|
-
const
|
|
34642
|
-
const
|
|
34825
|
+
const _vStart = /*@__PURE__*/ new Vector3();
|
|
34826
|
+
const _vEnd = /*@__PURE__*/ new Vector3();
|
|
34827
|
+
|
|
34643
34828
|
const _inverseMatrix$1 = /*@__PURE__*/ new Matrix4();
|
|
34644
34829
|
const _ray$1 = /*@__PURE__*/ new Ray();
|
|
34645
34830
|
const _sphere$1 = /*@__PURE__*/ new Sphere();
|
|
34646
34831
|
|
|
34832
|
+
const _intersectPointOnRay = /*@__PURE__*/ new Vector3();
|
|
34833
|
+
const _intersectPointOnSegment = /*@__PURE__*/ new Vector3();
|
|
34834
|
+
|
|
34647
34835
|
class Line extends Object3D {
|
|
34648
34836
|
|
|
34649
34837
|
constructor( geometry = new BufferGeometry(), material = new LineBasicMaterial() ) {
|
|
@@ -34685,11 +34873,11 @@ class Line extends Object3D {
|
|
|
34685
34873
|
|
|
34686
34874
|
for ( let i = 1, l = positionAttribute.count; i < l; i ++ ) {
|
|
34687
34875
|
|
|
34688
|
-
|
|
34689
|
-
|
|
34876
|
+
_vStart.fromBufferAttribute( positionAttribute, i - 1 );
|
|
34877
|
+
_vEnd.fromBufferAttribute( positionAttribute, i );
|
|
34690
34878
|
|
|
34691
34879
|
lineDistances[ i ] = lineDistances[ i - 1 ];
|
|
34692
|
-
lineDistances[ i ] +=
|
|
34880
|
+
lineDistances[ i ] += _vStart.distanceTo( _vEnd );
|
|
34693
34881
|
|
|
34694
34882
|
}
|
|
34695
34883
|
|
|
@@ -34730,10 +34918,6 @@ class Line extends Object3D {
|
|
|
34730
34918
|
const localThreshold = threshold / ( ( this.scale.x + this.scale.y + this.scale.z ) / 3 );
|
|
34731
34919
|
const localThresholdSq = localThreshold * localThreshold;
|
|
34732
34920
|
|
|
34733
|
-
const vStart = new Vector3();
|
|
34734
|
-
const vEnd = new Vector3();
|
|
34735
|
-
const interSegment = new Vector3();
|
|
34736
|
-
const interRay = new Vector3();
|
|
34737
34921
|
const step = this.isLineSegments ? 2 : 1;
|
|
34738
34922
|
|
|
34739
34923
|
const index = geometry.index;
|
|
@@ -34750,31 +34934,28 @@ class Line extends Object3D {
|
|
|
34750
34934
|
const a = index.getX( i );
|
|
34751
34935
|
const b = index.getX( i + 1 );
|
|
34752
34936
|
|
|
34753
|
-
|
|
34754
|
-
vEnd.fromBufferAttribute( positionAttribute, b );
|
|
34937
|
+
const intersect = checkIntersection( this, raycaster, _ray$1, localThresholdSq, a, b );
|
|
34755
34938
|
|
|
34756
|
-
|
|
34939
|
+
if ( intersect ) {
|
|
34757
34940
|
|
|
34758
|
-
|
|
34941
|
+
intersects.push( intersect );
|
|
34759
34942
|
|
|
34760
|
-
|
|
34943
|
+
}
|
|
34761
34944
|
|
|
34762
|
-
|
|
34945
|
+
}
|
|
34763
34946
|
|
|
34764
|
-
|
|
34947
|
+
if ( this.isLineLoop ) {
|
|
34765
34948
|
|
|
34766
|
-
|
|
34949
|
+
const a = index.getX( end - 1 );
|
|
34950
|
+
const b = index.getX( start );
|
|
34767
34951
|
|
|
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
|
|
34952
|
+
const intersect = checkIntersection( this, raycaster, _ray$1, localThresholdSq, a, b );
|
|
34776
34953
|
|
|
34777
|
-
|
|
34954
|
+
if ( intersect ) {
|
|
34955
|
+
|
|
34956
|
+
intersects.push( intersect );
|
|
34957
|
+
|
|
34958
|
+
}
|
|
34778
34959
|
|
|
34779
34960
|
}
|
|
34780
34961
|
|
|
@@ -34785,31 +34966,25 @@ class Line extends Object3D {
|
|
|
34785
34966
|
|
|
34786
34967
|
for ( let i = start, l = end - 1; i < l; i += step ) {
|
|
34787
34968
|
|
|
34788
|
-
|
|
34789
|
-
vEnd.fromBufferAttribute( positionAttribute, i + 1 );
|
|
34969
|
+
const intersect = checkIntersection( this, raycaster, _ray$1, localThresholdSq, i, i + 1 );
|
|
34790
34970
|
|
|
34791
|
-
|
|
34971
|
+
if ( intersect ) {
|
|
34792
34972
|
|
|
34793
|
-
|
|
34973
|
+
intersects.push( intersect );
|
|
34794
34974
|
|
|
34795
|
-
|
|
34975
|
+
}
|
|
34796
34976
|
|
|
34797
|
-
|
|
34977
|
+
}
|
|
34798
34978
|
|
|
34799
|
-
|
|
34979
|
+
if ( this.isLineLoop ) {
|
|
34800
34980
|
|
|
34801
|
-
|
|
34981
|
+
const intersect = checkIntersection( this, raycaster, _ray$1, localThresholdSq, end - 1, start );
|
|
34802
34982
|
|
|
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
|
|
34983
|
+
if ( intersect ) {
|
|
34811
34984
|
|
|
34812
|
-
|
|
34985
|
+
intersects.push( intersect );
|
|
34986
|
+
|
|
34987
|
+
}
|
|
34813
34988
|
|
|
34814
34989
|
}
|
|
34815
34990
|
|
|
@@ -34850,6 +35025,38 @@ class Line extends Object3D {
|
|
|
34850
35025
|
|
|
34851
35026
|
}
|
|
34852
35027
|
|
|
35028
|
+
function checkIntersection( object, raycaster, ray, thresholdSq, a, b ) {
|
|
35029
|
+
|
|
35030
|
+
const positionAttribute = object.geometry.attributes.position;
|
|
35031
|
+
|
|
35032
|
+
_vStart.fromBufferAttribute( positionAttribute, a );
|
|
35033
|
+
_vEnd.fromBufferAttribute( positionAttribute, b );
|
|
35034
|
+
|
|
35035
|
+
const distSq = ray.distanceSqToSegment( _vStart, _vEnd, _intersectPointOnRay, _intersectPointOnSegment );
|
|
35036
|
+
|
|
35037
|
+
if ( distSq > thresholdSq ) return;
|
|
35038
|
+
|
|
35039
|
+
_intersectPointOnRay.applyMatrix4( object.matrixWorld ); // Move back to world space for distance calculation
|
|
35040
|
+
|
|
35041
|
+
const distance = raycaster.ray.origin.distanceTo( _intersectPointOnRay );
|
|
35042
|
+
|
|
35043
|
+
if ( distance < raycaster.near || distance > raycaster.far ) return;
|
|
35044
|
+
|
|
35045
|
+
return {
|
|
35046
|
+
|
|
35047
|
+
distance: distance,
|
|
35048
|
+
// What do we want? intersection point on the ray or on the segment??
|
|
35049
|
+
// point: raycaster.ray.at( distance ),
|
|
35050
|
+
point: _intersectPointOnSegment.clone().applyMatrix4( object.matrixWorld ),
|
|
35051
|
+
index: a,
|
|
35052
|
+
face: null,
|
|
35053
|
+
faceIndex: null,
|
|
35054
|
+
object: object
|
|
35055
|
+
|
|
35056
|
+
};
|
|
35057
|
+
|
|
35058
|
+
}
|
|
35059
|
+
|
|
34853
35060
|
const _start = /*@__PURE__*/ new Vector3();
|
|
34854
35061
|
const _end = /*@__PURE__*/ new Vector3();
|
|
34855
35062
|
|
|
@@ -41487,6 +41694,7 @@ class MeshPhysicalMaterial extends MeshStandardMaterial {
|
|
|
41487
41694
|
|
|
41488
41695
|
this._anisotropy = 0;
|
|
41489
41696
|
this._clearcoat = 0;
|
|
41697
|
+
this._dispersion = 0;
|
|
41490
41698
|
this._iridescence = 0;
|
|
41491
41699
|
this._sheen = 0.0;
|
|
41492
41700
|
this._transmission = 0;
|
|
@@ -41549,6 +41757,24 @@ class MeshPhysicalMaterial extends MeshStandardMaterial {
|
|
|
41549
41757
|
|
|
41550
41758
|
}
|
|
41551
41759
|
|
|
41760
|
+
get dispersion() {
|
|
41761
|
+
|
|
41762
|
+
return this._dispersion;
|
|
41763
|
+
|
|
41764
|
+
}
|
|
41765
|
+
|
|
41766
|
+
set dispersion( value ) {
|
|
41767
|
+
|
|
41768
|
+
if ( this._dispersion > 0 !== value > 0 ) {
|
|
41769
|
+
|
|
41770
|
+
this.version ++;
|
|
41771
|
+
|
|
41772
|
+
}
|
|
41773
|
+
|
|
41774
|
+
this._dispersion = value;
|
|
41775
|
+
|
|
41776
|
+
}
|
|
41777
|
+
|
|
41552
41778
|
get sheen() {
|
|
41553
41779
|
|
|
41554
41780
|
return this._sheen;
|
|
@@ -41607,6 +41833,7 @@ class MeshPhysicalMaterial extends MeshStandardMaterial {
|
|
|
41607
41833
|
this.clearcoatNormalMap = source.clearcoatNormalMap;
|
|
41608
41834
|
this.clearcoatNormalScale.copy( source.clearcoatNormalScale );
|
|
41609
41835
|
|
|
41836
|
+
this.dispersion = source.dispersion;
|
|
41610
41837
|
this.ior = source.ior;
|
|
41611
41838
|
|
|
41612
41839
|
this.iridescence = source.iridescence;
|
|
@@ -44280,7 +44507,7 @@ class FileLoader extends Loader {
|
|
|
44280
44507
|
|
|
44281
44508
|
// Nginx needs X-File-Size check
|
|
44282
44509
|
// https://serverfault.com/questions/482875/why-does-nginx-remove-content-length-header-for-chunked-content
|
|
44283
|
-
const contentLength = response.headers.get( '
|
|
44510
|
+
const contentLength = response.headers.get( 'X-File-Size' ) || response.headers.get( 'Content-Length' );
|
|
44284
44511
|
const total = contentLength ? parseInt( contentLength ) : 0;
|
|
44285
44512
|
const lengthComputable = total !== 0;
|
|
44286
44513
|
let loaded = 0;
|
|
@@ -45881,6 +46108,7 @@ class MaterialLoader extends Loader {
|
|
|
45881
46108
|
if ( json.shininess !== undefined ) material.shininess = json.shininess;
|
|
45882
46109
|
if ( json.clearcoat !== undefined ) material.clearcoat = json.clearcoat;
|
|
45883
46110
|
if ( json.clearcoatRoughness !== undefined ) material.clearcoatRoughness = json.clearcoatRoughness;
|
|
46111
|
+
if ( json.dispersion !== undefined ) material.dispersion = json.dispersion;
|
|
45884
46112
|
if ( json.iridescence !== undefined ) material.iridescence = json.iridescence;
|
|
45885
46113
|
if ( json.iridescenceIOR !== undefined ) material.iridescenceIOR = json.iridescenceIOR;
|
|
45886
46114
|
if ( json.iridescenceThicknessRange !== undefined ) material.iridescenceThicknessRange = json.iridescenceThicknessRange;
|