super-three 0.141.0 → 0.144.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -8
- package/build/three.cjs +1558 -1034
- package/build/three.js +1558 -1034
- package/build/three.min.js +1 -1
- package/build/three.module.js +2012 -1243
- package/examples/js/animation/MMDPhysics.js +1 -16
- package/examples/js/controls/ArcballControls.js +16 -3
- package/examples/js/controls/FirstPersonControls.js +0 -7
- package/examples/js/controls/FlyControls.js +0 -8
- package/examples/js/controls/OrbitControls.js +0 -4
- package/examples/js/controls/PointerLockControls.js +0 -8
- package/examples/js/controls/TrackballControls.js +0 -2
- package/examples/js/controls/TransformControls.js +20 -16
- package/examples/js/effects/AnaglyphEffect.js +2 -2
- package/examples/js/effects/OutlineEffect.js +4 -24
- package/examples/js/effects/ParallaxBarrierEffect.js +2 -2
- package/examples/js/effects/PeppersGhostEffect.js +2 -2
- package/examples/js/effects/StereoEffect.js +2 -2
- package/examples/js/environments/RoomEnvironment.js +22 -0
- package/examples/js/exporters/ColladaExporter.js +4 -13
- package/examples/js/exporters/DRACOExporter.js +0 -12
- package/examples/js/exporters/GLTFExporter.js +28 -29
- package/examples/js/exporters/OBJExporter.js +2 -23
- package/examples/js/exporters/PLYExporter.js +12 -24
- package/examples/js/exporters/STLExporter.js +0 -7
- package/examples/js/exporters/USDZExporter.js +6 -0
- package/examples/js/geometries/ConvexGeometry.js +1 -1
- package/examples/js/geometries/ParametricGeometry.js +1 -8
- package/examples/js/interactive/SelectionHelper.js +2 -0
- package/examples/js/libs/ktx-parse.umd.js +1 -0
- package/examples/js/libs/meshopt_decoder.js +98 -32
- package/examples/js/loaders/ColladaLoader.js +1 -0
- package/examples/js/loaders/DRACOLoader.js +2 -25
- package/examples/js/loaders/EXRLoader.js +2 -13
- package/examples/js/loaders/FBXLoader.js +10 -3
- package/examples/js/loaders/FontLoader.js +3 -16
- package/examples/js/loaders/GLTFLoader.js +52 -36
- package/examples/js/loaders/HDRCubeTextureLoader.js +0 -11
- package/examples/js/loaders/LDrawLoader.js +139 -74
- package/examples/js/loaders/OBJLoader.js +7 -13
- package/examples/js/loaders/PCDLoader.js +59 -14
- package/examples/js/loaders/PLYLoader.js +3 -3
- package/examples/js/loaders/SVGLoader.js +4 -3
- package/examples/js/loaders/TIFFLoader.js +31 -0
- package/examples/js/loaders/VRMLLoader.js +33 -24
- package/examples/js/loaders/VTKLoader.js +1 -1
- package/examples/js/loaders/lwo/LWO2Parser.js +8 -7
- package/examples/js/loaders/lwo/LWO3Parser.js +8 -7
- package/examples/js/materials/MeshGouraudMaterial.js +385 -0
- package/examples/js/math/ColorConverter.js +0 -50
- package/examples/js/misc/GPUComputationRenderer.js +23 -0
- package/examples/js/misc/Volume.js +198 -190
- package/examples/js/misc/VolumeSlice.js +90 -88
- package/examples/js/modifiers/SimplifyModifier.js +1 -1
- package/examples/js/objects/GroundProjectedEnv.js +193 -0
- package/examples/js/objects/Reflector.js +9 -2
- package/examples/js/objects/ReflectorForSSRPass.js +3 -4
- package/examples/js/objects/Refractor.js +10 -4
- package/examples/js/objects/ShadowMesh.js +5 -1
- package/examples/js/postprocessing/OutlinePass.js +5 -3
- package/examples/js/renderers/CSS2DRenderer.js +2 -2
- package/examples/js/renderers/CSS3DRenderer.js +2 -2
- package/examples/js/renderers/Projector.js +2 -23
- package/examples/js/shaders/LuminosityShader.js +1 -1
- package/examples/js/shaders/MMDToonShader.js +6 -2
- package/examples/js/shaders/ToneMapShader.js +1 -1
- package/examples/js/utils/BufferGeometryUtils.js +1 -1
- package/examples/js/utils/GeometryUtils.js +2 -18
- package/examples/js/utils/PackedPhongMaterial.js +1 -1
- package/examples/js/utils/SceneUtils.js +0 -16
- package/examples/jsm/animation/MMDPhysics.js +3 -22
- package/examples/jsm/controls/ArcballControls.js +17 -2
- package/examples/jsm/controls/FirstPersonControls.js +0 -7
- package/examples/jsm/controls/FlyControls.js +0 -7
- package/examples/jsm/controls/OrbitControls.js +0 -5
- package/examples/jsm/controls/PointerLockControls.js +0 -7
- package/examples/jsm/controls/TrackballControls.js +0 -3
- package/examples/jsm/controls/TransformControls.js +18 -16
- package/examples/jsm/effects/AnaglyphEffect.js +2 -2
- package/examples/jsm/effects/OutlineEffect.js +4 -25
- package/examples/jsm/effects/ParallaxBarrierEffect.js +2 -2
- package/examples/jsm/effects/PeppersGhostEffect.js +2 -2
- package/examples/jsm/effects/StereoEffect.js +2 -2
- package/examples/jsm/environments/RoomEnvironment.js +23 -0
- package/examples/jsm/exporters/ColladaExporter.js +4 -13
- package/examples/jsm/exporters/DRACOExporter.js +0 -13
- package/examples/jsm/exporters/GLTFExporter.js +29 -31
- package/examples/jsm/exporters/KTX2Exporter.js +29 -29
- package/examples/jsm/exporters/OBJExporter.js +0 -18
- package/examples/jsm/exporters/PLYExporter.js +14 -22
- package/examples/jsm/exporters/STLExporter.js +1 -9
- package/examples/jsm/exporters/USDZExporter.js +14 -3
- package/examples/jsm/geometries/ConvexGeometry.js +1 -1
- package/examples/jsm/geometries/ParametricGeometry.js +0 -6
- package/examples/jsm/interactive/HTMLMesh.js +9 -9
- package/examples/jsm/interactive/SelectionHelper.js +5 -3
- package/examples/jsm/libs/meshopt_decoder.module.js +97 -32
- package/examples/jsm/libs/utif.module.js +1579 -0
- package/examples/jsm/libs/zstddec.module.js +1 -0
- package/examples/jsm/loaders/ColladaLoader.js +1 -0
- package/examples/jsm/loaders/DRACOLoader.js +2 -28
- package/examples/jsm/loaders/EXRLoader.js +3 -13
- package/examples/jsm/loaders/FBXLoader.js +10 -3
- package/examples/jsm/loaders/FontLoader.js +3 -16
- package/examples/jsm/loaders/GLTFLoader.js +52 -36
- package/examples/jsm/loaders/HDRCubeTextureLoader.js +0 -13
- package/examples/jsm/loaders/KTX2Loader.js +192 -30
- package/examples/jsm/loaders/LDrawLoader.js +135 -74
- package/examples/jsm/loaders/OBJLoader.js +6 -14
- package/examples/jsm/loaders/PCDLoader.js +59 -13
- package/examples/jsm/loaders/PLYLoader.js +3 -3
- package/examples/jsm/loaders/RGBELoader.js +1 -1
- package/examples/jsm/loaders/SVGLoader.js +4 -3
- package/examples/jsm/loaders/TIFFLoader.js +36 -0
- package/examples/jsm/loaders/USDZLoader.js +393 -0
- package/examples/jsm/loaders/VRMLLoader.js +23 -25
- package/examples/jsm/loaders/VTKLoader.js +1 -1
- package/examples/jsm/loaders/lwo/LWO2Parser.js +6 -8
- package/examples/jsm/loaders/lwo/LWO3Parser.js +6 -8
- package/examples/jsm/materials/MeshGouraudMaterial.js +423 -0
- package/examples/jsm/math/ColorConverter.js +1 -49
- package/examples/jsm/misc/GPUComputationRenderer.js +43 -0
- package/examples/jsm/misc/Volume.js +169 -171
- package/examples/jsm/misc/VolumeSlice.js +78 -80
- package/examples/jsm/modifiers/SimplifyModifier.js +1 -1
- package/examples/jsm/node-editor/accessors/MatcapUVEditor.js +1 -1
- package/examples/jsm/node-editor/accessors/NormalEditor.js +1 -1
- package/examples/jsm/node-editor/accessors/PositionEditor.js +1 -1
- package/examples/jsm/node-editor/accessors/UVEditor.js +1 -1
- package/examples/jsm/node-editor/display/BlendEditor.js +1 -1
- package/examples/jsm/node-editor/display/NormalMapEditor.js +1 -1
- package/examples/jsm/node-editor/inputs/ColorEditor.js +1 -1
- package/examples/jsm/node-editor/inputs/FloatEditor.js +1 -1
- package/examples/jsm/node-editor/inputs/SliderEditor.js +1 -1
- package/examples/jsm/node-editor/inputs/TextureEditor.js +1 -1
- package/examples/jsm/node-editor/inputs/Vector2Editor.js +1 -1
- package/examples/jsm/node-editor/inputs/Vector3Editor.js +1 -1
- package/examples/jsm/node-editor/inputs/Vector4Editor.js +1 -1
- package/examples/jsm/node-editor/materials/BasicMaterialEditor.js +1 -1
- package/examples/jsm/node-editor/materials/PointsMaterialEditor.js +1 -1
- package/examples/jsm/node-editor/materials/StandardMaterialEditor.js +1 -1
- package/examples/jsm/node-editor/math/AngleEditor.js +1 -1
- package/examples/jsm/node-editor/math/DotEditor.js +1 -1
- package/examples/jsm/node-editor/math/InvertEditor.js +1 -1
- package/examples/jsm/node-editor/math/LimiterEditor.js +1 -1
- package/examples/jsm/node-editor/math/NormalizeEditor.js +1 -1
- package/examples/jsm/node-editor/math/OperatorEditor.js +1 -1
- package/examples/jsm/node-editor/math/PowerEditor.js +1 -1
- package/examples/jsm/node-editor/math/TrigonometryEditor.js +1 -1
- package/examples/jsm/node-editor/procedural/CheckerEditor.js +1 -1
- package/examples/jsm/node-editor/utils/JoinEditor.js +1 -1
- package/examples/jsm/node-editor/utils/OscillatorEditor.js +1 -1
- package/examples/jsm/node-editor/utils/PreviewEditor.js +3 -3
- package/examples/jsm/node-editor/utils/SplitEditor.js +1 -1
- package/examples/jsm/node-editor/utils/TimerEditor.js +1 -1
- package/examples/jsm/nodes/Nodes.js +43 -13
- package/examples/jsm/nodes/accessors/CubeTextureNode.js +9 -5
- package/examples/jsm/nodes/accessors/NormalNode.js +4 -4
- package/examples/jsm/nodes/accessors/PositionNode.js +5 -5
- package/examples/jsm/nodes/accessors/ReflectVectorNode.js +31 -0
- package/examples/jsm/nodes/core/AttributeNode.js +3 -3
- package/examples/jsm/nodes/core/CodeNode.js +3 -3
- package/examples/jsm/nodes/core/FunctionCallNode.js +20 -5
- package/examples/jsm/nodes/core/FunctionNode.js +2 -2
- package/examples/jsm/nodes/core/Node.js +14 -12
- package/examples/jsm/nodes/core/NodeBuilder.js +12 -12
- package/examples/jsm/nodes/core/NodeUtils.js +23 -1
- package/examples/jsm/nodes/core/{NodeVary.js → NodeVarying.js} +3 -3
- package/examples/jsm/nodes/core/{VaryNode.js → VaryingNode.js} +7 -7
- package/examples/jsm/nodes/display/ColorAdjustmentNode.js +94 -0
- package/examples/jsm/nodes/geometry/RangeNode.js +109 -0
- package/examples/jsm/nodes/gpgpu/ComputeNode.js +2 -0
- package/examples/jsm/nodes/lighting/EnvironmentNode.js +8 -7
- package/examples/jsm/nodes/lighting/LightingContextNode.js +4 -4
- package/examples/jsm/nodes/loaders/NodeLoader.js +2 -2
- package/examples/jsm/nodes/loaders/NodeMaterialLoader.js +31 -0
- package/examples/jsm/nodes/materials/Materials.js +13 -25
- package/examples/jsm/nodes/materials/MeshPhysicalNodeMaterial.js +70 -0
- package/examples/jsm/nodes/materials/MeshStandardNodeMaterial.js +4 -7
- package/examples/jsm/nodes/materials/NodeMaterial.js +2 -2
- package/examples/jsm/nodes/materials/SpriteNodeMaterial.js +28 -17
- package/examples/jsm/nodes/materialx/Disclaimer.md +199 -0
- package/examples/jsm/nodes/materialx/functions/lib/mx_hsv.js +56 -0
- package/examples/jsm/nodes/materialx/functions/lib/mx_noise.js +607 -0
- package/examples/jsm/nodes/math/MathNode.js +2 -12
- package/examples/jsm/nodes/parsers/GLSLNodeFunction.js +21 -6
- package/examples/jsm/nodes/procedural/CheckerNode.js +2 -2
- package/examples/jsm/nodes/shadernode/ShaderNode.js +5 -5
- package/examples/jsm/nodes/shadernode/ShaderNodeBaseElements.js +8 -5
- package/examples/jsm/nodes/shadernode/ShaderNodeElements.js +20 -6
- package/examples/jsm/nodes/utils/ConvertNode.js +8 -3
- package/examples/jsm/nodes/utils/JoinNode.js +7 -7
- package/examples/jsm/nodes/utils/MaxMipLevelNode.js +2 -1
- package/examples/jsm/nodes/utils/RotateUVNode.js +32 -0
- package/examples/jsm/nodes/utils/SplitNode.js +21 -5
- package/examples/jsm/nodes/utils/TimerNode.js +2 -2
- package/examples/jsm/objects/GroundProjectedEnv.js +186 -0
- package/examples/jsm/objects/Reflector.js +12 -5
- package/examples/jsm/objects/ReflectorForSSRPass.js +3 -5
- package/examples/jsm/objects/Refractor.js +12 -6
- package/examples/jsm/objects/ShadowMesh.js +8 -2
- package/examples/jsm/postprocessing/OutlinePass.js +5 -3
- package/examples/jsm/renderers/CSS2DRenderer.js +2 -2
- package/examples/jsm/renderers/CSS3DRenderer.js +2 -2
- package/examples/jsm/renderers/Projector.js +2 -24
- package/examples/jsm/renderers/webgl/nodes/SlotNode.js +9 -5
- package/examples/jsm/renderers/webgl/nodes/WebGLNodeBuilder.js +329 -218
- package/examples/jsm/renderers/webgl/nodes/WebGLNodes.js +7 -3
- package/examples/jsm/renderers/webgpu/WebGPUBackground.js +39 -3
- package/examples/jsm/renderers/webgpu/WebGPUComputePipelines.js +6 -0
- package/examples/jsm/renderers/webgpu/WebGPUGeometries.js +6 -0
- package/examples/jsm/renderers/webgpu/WebGPUObjects.js +1 -1
- package/examples/jsm/renderers/webgpu/WebGPURenderPipeline.js +17 -19
- package/examples/jsm/renderers/webgpu/WebGPURenderPipelines.js +16 -14
- package/examples/jsm/renderers/webgpu/WebGPURenderStates.js +2 -2
- package/examples/jsm/renderers/webgpu/WebGPURenderer.js +66 -81
- package/examples/jsm/renderers/webgpu/WebGPUTextureUtils.js +5 -3
- package/examples/jsm/renderers/webgpu/WebGPUTextures.js +2 -2
- package/examples/jsm/renderers/webgpu/WebGPUUtils.js +81 -0
- package/examples/jsm/renderers/webgpu/nodes/WebGPUNodeBuilder.js +25 -30
- package/examples/jsm/renderers/webgpu/nodes/WebGPUNodes.js +1 -1
- package/examples/jsm/shaders/LuminosityShader.js +1 -1
- package/examples/jsm/shaders/MMDToonShader.js +2 -2
- package/examples/jsm/shaders/ToneMapShader.js +1 -1
- package/examples/jsm/utils/BufferGeometryUtils.js +2 -1
- package/examples/jsm/utils/GeometryUtils.js +17 -25
- package/examples/jsm/utils/PackedPhongMaterial.js +0 -1
- package/examples/jsm/utils/SceneUtils.js +1 -21
- package/examples/jsm/webxr/OculusHandPointerModel.js +6 -1
- package/examples/jsm/webxr/VRButton.js +1 -7
- package/package.json +18 -14
- package/src/Three.Legacy.js +262 -36
- package/src/Three.js +3 -2
- package/src/animation/AnimationAction.js +6 -5
- package/src/animation/AnimationClip.js +1 -1
- package/src/animation/AnimationMixer.js +1 -1
- package/src/animation/AnimationUtils.js +204 -199
- package/src/animation/KeyframeTrack.js +1 -1
- package/src/animation/PropertyBinding.js +24 -5
- package/src/cameras/CubeCamera.js +0 -7
- package/src/constants.js +2 -4
- package/src/core/BufferAttribute.js +81 -111
- package/src/core/BufferGeometry.js +3 -41
- package/src/core/InstancedBufferAttribute.js +0 -10
- package/src/core/InterleavedBuffer.js +1 -1
- package/src/core/InterleavedBufferAttribute.js +56 -7
- package/src/core/Object3D.js +22 -5
- package/src/core/Uniform.js +0 -7
- package/src/core/UniformsGroup.js +92 -0
- package/src/extras/DataUtils.js +104 -88
- package/src/extras/core/Path.js +1 -0
- package/src/extras/core/ShapePath.js +1 -4
- package/src/extras/curves/CatmullRomCurve3.js +4 -2
- package/src/geometries/BoxGeometry.js +1 -1
- package/src/geometries/CapsuleGeometry.js +1 -1
- package/src/geometries/CircleGeometry.js +1 -1
- package/src/geometries/ConeGeometry.js +1 -1
- package/src/geometries/CylinderGeometry.js +2 -1
- package/src/geometries/DodecahedronGeometry.js +1 -1
- package/src/geometries/EdgesGeometry.js +5 -4
- package/src/geometries/ExtrudeGeometry.js +2 -11
- package/src/geometries/IcosahedronGeometry.js +1 -1
- package/src/geometries/LatheGeometry.js +2 -2
- package/src/geometries/OctahedronGeometry.js +1 -1
- package/src/geometries/PlaneGeometry.js +2 -1
- package/src/geometries/PolyhedronGeometry.js +1 -1
- package/src/geometries/RingGeometry.js +1 -1
- package/src/geometries/ShapeGeometry.js +2 -1
- package/src/geometries/SphereGeometry.js +2 -1
- package/src/geometries/TetrahedronGeometry.js +1 -1
- package/src/geometries/TorusGeometry.js +2 -1
- package/src/geometries/TorusKnotGeometry.js +2 -1
- package/src/geometries/TubeGeometry.js +2 -1
- package/src/geometries/WireframeGeometry.js +1 -0
- package/src/helpers/CameraHelper.js +97 -38
- package/src/helpers/DirectionalLightHelper.js +1 -0
- package/src/helpers/HemisphereLightHelper.js +1 -0
- package/src/helpers/PlaneHelper.js +6 -9
- package/src/helpers/PolarGridHelper.js +18 -14
- package/src/helpers/SpotLightHelper.js +1 -0
- package/src/lights/SpotLight.js +2 -0
- package/src/loaders/FileLoader.js +12 -1
- package/src/loaders/LoadingManager.js +1 -1
- package/src/loaders/MaterialLoader.js +49 -7
- package/src/loaders/ObjectLoader.js +4 -41
- package/src/materials/Material.js +1 -33
- package/src/materials/Materials.js +0 -27
- package/src/materials/MeshLambertMaterial.js +28 -1
- package/src/materials/ShaderMaterial.js +3 -7
- package/src/math/Color.js +3 -13
- package/src/math/MathUtils.js +1 -7
- package/src/math/Matrix3.js +1 -7
- package/src/math/Matrix4.js +3 -27
- package/src/math/Quaternion.js +1 -21
- package/src/math/Vector2.js +4 -24
- package/src/math/Vector3.js +7 -46
- package/src/math/Vector4.js +4 -24
- package/src/renderers/WebGLRenderer.js +84 -8
- package/src/renderers/shaders/ShaderChunk/bsdfs.glsl.js +12 -12
- package/src/renderers/shaders/ShaderChunk/bumpmap_pars_fragment.glsl.js +3 -5
- package/src/renderers/shaders/ShaderChunk/common.glsl.js +6 -5
- package/src/renderers/shaders/ShaderChunk/cube_uv_reflection_fragment.glsl.js +24 -24
- package/src/renderers/shaders/ShaderChunk/envmap_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/envmap_pars_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/gradientmap_pars_fragment.glsl.js +2 -1
- package/src/renderers/shaders/ShaderChunk/iridescence_fragment.glsl.js +113 -99
- package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +34 -12
- package/src/renderers/shaders/ShaderChunk/lights_lambert_fragment.glsl.js +5 -0
- package/src/renderers/shaders/ShaderChunk/lights_lambert_pars_fragment.glsl.js +30 -0
- package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +3 -1
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +13 -1
- package/src/renderers/shaders/ShaderChunk/normalmap_pars_fragment.glsl.js +2 -4
- package/src/renderers/shaders/ShaderChunk/output_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +18 -7
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_vertex.glsl.js +8 -3
- package/src/renderers/shaders/ShaderChunk/shadowmap_vertex.glsl.js +9 -6
- package/src/renderers/shaders/ShaderChunk/shadowmask_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/transmission_fragment.glsl.js +14 -10
- package/src/renderers/shaders/ShaderChunk/worldpos_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk.js +4 -2
- package/src/renderers/shaders/ShaderLib/meshbasic.glsl.js +0 -1
- package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +22 -50
- package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +0 -1
- package/src/renderers/shaders/ShaderLib.js +31 -31
- package/src/renderers/shaders/UniformsLib.js +12 -11
- package/src/renderers/shaders/UniformsUtils.js +14 -0
- package/src/renderers/webgl/WebGLBackground.js +2 -2
- package/src/renderers/webgl/WebGLLights.js +37 -13
- package/src/renderers/webgl/WebGLMorphtargets.js +0 -20
- package/src/renderers/webgl/WebGLProgram.js +6 -11
- package/src/renderers/webgl/WebGLPrograms.js +30 -26
- package/src/renderers/webgl/WebGLRenderLists.js +5 -4
- package/src/renderers/webgl/WebGLRenderStates.js +5 -4
- package/src/renderers/webgl/WebGLShaderCache.js +9 -6
- package/src/renderers/webgl/WebGLShadowMap.js +10 -15
- package/src/renderers/webgl/WebGLState.js +47 -0
- package/src/renderers/webgl/WebGLUniforms.js +4 -4
- package/src/renderers/webgl/WebGLUniformsGroups.js +372 -0
- package/src/renderers/webgl/WebGLUtils.js +2 -0
- package/src/renderers/webvr/WebVRManager.js +42 -9
- package/src/renderers/webvr/WebVRUtils.js +1 -1
- package/src/renderers/webxr/WebXRController.js +45 -37
- package/src/renderers/webxr/WebXRManager.js +58 -33
- package/src/scenes/Scene.js +16 -3
- package/src/textures/Source.js +1 -1
- package/src/utils.js +1 -1
- package/examples/js/controls/experimental/CameraControls.js +0 -1048
- package/examples/js/loaders/KTX2Loader.js +0 -558
- package/examples/jsm/controls/experimental/CameraControls.js +0 -1248
- package/examples/jsm/nodes/accessors/ReflectNode.js +0 -70
- package/examples/jsm/package.json +0 -3
- package/examples/jsm/renderers/webgl/nodes/WebGLPhysicalContextNode.js +0 -45
- package/src/renderers/shaders/ShaderChunk/lights_lambert_vertex.glsl.js +0 -122
|
@@ -17,7 +17,7 @@ vec3 pow2( const in vec3 x ) { return x*x; }
|
|
|
17
17
|
float pow3( const in float x ) { return x*x*x; }
|
|
18
18
|
float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
|
|
19
19
|
float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
|
|
20
|
-
float average( const in vec3
|
|
20
|
+
float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
|
|
21
21
|
|
|
22
22
|
// expects values in the range of [0,1]x[0,1], returns values in the [0,1] range.
|
|
23
23
|
// do not collapse into a single function per: http://byteblacksmith.com/improvements-to-the-canonical-one-liner-glsl-rand-for-opengl-es-2-0/
|
|
@@ -88,12 +88,13 @@ mat3 transposeMat3( const in mat3 m ) {
|
|
|
88
88
|
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
|
|
92
|
-
float linearToRelativeLuminance( const in vec3 color ) {
|
|
91
|
+
float luminance( const in vec3 rgb ) {
|
|
93
92
|
|
|
94
|
-
|
|
93
|
+
// assumes rgb is in linear color space with sRGB primaries and D65 white point
|
|
95
94
|
|
|
96
|
-
|
|
95
|
+
const vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );
|
|
96
|
+
|
|
97
|
+
return dot( weights, rgb );
|
|
97
98
|
|
|
98
99
|
}
|
|
99
100
|
|
|
@@ -118,41 +118,41 @@ export default /* glsl */`
|
|
|
118
118
|
|
|
119
119
|
// These defines must match with PMREMGenerator
|
|
120
120
|
|
|
121
|
-
#define
|
|
122
|
-
#define
|
|
123
|
-
#define
|
|
124
|
-
#define
|
|
125
|
-
#define
|
|
126
|
-
#define
|
|
127
|
-
#define
|
|
128
|
-
#define
|
|
129
|
-
#define
|
|
130
|
-
#define
|
|
131
|
-
#define
|
|
132
|
-
#define
|
|
133
|
-
#define
|
|
134
|
-
#define
|
|
135
|
-
#define
|
|
121
|
+
#define cubeUV_r0 1.0
|
|
122
|
+
#define cubeUV_v0 0.339
|
|
123
|
+
#define cubeUV_m0 - 2.0
|
|
124
|
+
#define cubeUV_r1 0.8
|
|
125
|
+
#define cubeUV_v1 0.276
|
|
126
|
+
#define cubeUV_m1 - 1.0
|
|
127
|
+
#define cubeUV_r4 0.4
|
|
128
|
+
#define cubeUV_v4 0.046
|
|
129
|
+
#define cubeUV_m4 2.0
|
|
130
|
+
#define cubeUV_r5 0.305
|
|
131
|
+
#define cubeUV_v5 0.016
|
|
132
|
+
#define cubeUV_m5 3.0
|
|
133
|
+
#define cubeUV_r6 0.21
|
|
134
|
+
#define cubeUV_v6 0.0038
|
|
135
|
+
#define cubeUV_m6 4.0
|
|
136
136
|
|
|
137
137
|
float roughnessToMip( float roughness ) {
|
|
138
138
|
|
|
139
139
|
float mip = 0.0;
|
|
140
140
|
|
|
141
|
-
if ( roughness >=
|
|
141
|
+
if ( roughness >= cubeUV_r1 ) {
|
|
142
142
|
|
|
143
|
-
mip = (
|
|
143
|
+
mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
|
|
144
144
|
|
|
145
|
-
} else if ( roughness >=
|
|
145
|
+
} else if ( roughness >= cubeUV_r4 ) {
|
|
146
146
|
|
|
147
|
-
mip = (
|
|
147
|
+
mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
|
|
148
148
|
|
|
149
|
-
} else if ( roughness >=
|
|
149
|
+
} else if ( roughness >= cubeUV_r5 ) {
|
|
150
150
|
|
|
151
|
-
mip = (
|
|
151
|
+
mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
|
|
152
152
|
|
|
153
|
-
} else if ( roughness >=
|
|
153
|
+
} else if ( roughness >= cubeUV_r6 ) {
|
|
154
154
|
|
|
155
|
-
mip = (
|
|
155
|
+
mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
|
|
156
156
|
|
|
157
157
|
} else {
|
|
158
158
|
|
|
@@ -165,7 +165,7 @@ export default /* glsl */`
|
|
|
165
165
|
|
|
166
166
|
vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
|
|
167
167
|
|
|
168
|
-
float mip = clamp( roughnessToMip( roughness ),
|
|
168
|
+
float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
|
|
169
169
|
|
|
170
170
|
float mipF = fract( mip );
|
|
171
171
|
|
|
@@ -18,7 +18,8 @@ vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
|
|
|
18
18
|
|
|
19
19
|
#else
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
vec2 fw = fwidth( coord ) * 0.5;
|
|
22
|
+
return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
|
|
22
23
|
|
|
23
24
|
#endif
|
|
24
25
|
|
|
@@ -2,105 +2,119 @@ export default /* glsl */`
|
|
|
2
2
|
|
|
3
3
|
#ifdef USE_IRIDESCENCE
|
|
4
4
|
|
|
5
|
-
// XYZ to sRGB color space
|
|
6
|
-
const mat3 XYZ_TO_REC709 = mat3(
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
);
|
|
11
|
-
|
|
12
|
-
// Assume air interface for top
|
|
13
|
-
// Note: We don't handle the case fresnel0 == 1
|
|
14
|
-
vec3 Fresnel0ToIor( vec3 fresnel0 ) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
5
|
+
// XYZ to linear-sRGB color space
|
|
6
|
+
const mat3 XYZ_TO_REC709 = mat3(
|
|
7
|
+
3.2404542, -0.9692660, 0.0556434,
|
|
8
|
+
-1.5371385, 1.8760108, -0.2040259,
|
|
9
|
+
-0.4985314, 0.0415560, 1.0572252
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
// Assume air interface for top
|
|
13
|
+
// Note: We don't handle the case fresnel0 == 1
|
|
14
|
+
vec3 Fresnel0ToIor( vec3 fresnel0 ) {
|
|
15
|
+
|
|
16
|
+
vec3 sqrtF0 = sqrt( fresnel0 );
|
|
17
|
+
return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
|
|
18
|
+
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Conversion FO/IOR
|
|
22
|
+
vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
|
|
23
|
+
|
|
24
|
+
return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
|
|
25
|
+
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// ior is a value between 1.0 and 3.0. 1.0 is air interface
|
|
29
|
+
float IorToFresnel0( float transmittedIor, float incidentIor ) {
|
|
30
|
+
|
|
31
|
+
return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
|
|
32
|
+
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Fresnel equations for dielectric/dielectric interfaces.
|
|
36
|
+
// Ref: https://belcour.github.io/blog/research/2017/05/01/brdf-thin-film.html
|
|
37
|
+
// Evaluation XYZ sensitivity curves in Fourier space
|
|
38
|
+
vec3 evalSensitivity( float OPD, vec3 shift ) {
|
|
39
|
+
|
|
40
|
+
float phase = 2.0 * PI * OPD * 1.0e-9;
|
|
41
|
+
vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
|
|
42
|
+
vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
|
|
43
|
+
vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
|
|
44
|
+
|
|
45
|
+
vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
|
|
46
|
+
xyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );
|
|
47
|
+
xyz /= 1.0685e-7;
|
|
48
|
+
|
|
49
|
+
vec3 rgb = XYZ_TO_REC709 * xyz;
|
|
50
|
+
return rgb;
|
|
51
|
+
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
|
|
55
|
+
|
|
56
|
+
vec3 I;
|
|
57
|
+
|
|
58
|
+
// Force iridescenceIOR -> outsideIOR when thinFilmThickness -> 0.0
|
|
59
|
+
float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
|
|
60
|
+
// Evaluate the cosTheta on the base layer (Snell law)
|
|
61
|
+
float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
|
|
62
|
+
|
|
63
|
+
// Handle TIR:
|
|
64
|
+
float cosTheta2Sq = 1.0 - sinTheta2Sq;
|
|
65
|
+
if ( cosTheta2Sq < 0.0 ) {
|
|
66
|
+
|
|
67
|
+
return vec3( 1.0 );
|
|
68
|
+
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
float cosTheta2 = sqrt( cosTheta2Sq );
|
|
72
|
+
|
|
73
|
+
// First interface
|
|
74
|
+
float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
|
|
75
|
+
float R12 = F_Schlick( R0, 1.0, cosTheta1 );
|
|
76
|
+
float R21 = R12;
|
|
77
|
+
float T121 = 1.0 - R12;
|
|
78
|
+
float phi12 = 0.0;
|
|
79
|
+
if ( iridescenceIOR < outsideIOR ) phi12 = PI;
|
|
80
|
+
float phi21 = PI - phi12;
|
|
81
|
+
|
|
82
|
+
// Second interface
|
|
83
|
+
vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); // guard against 1.0
|
|
84
|
+
vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
|
|
85
|
+
vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
|
|
86
|
+
vec3 phi23 = vec3( 0.0 );
|
|
87
|
+
if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
|
|
88
|
+
if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
|
|
89
|
+
if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
|
|
90
|
+
|
|
91
|
+
// Phase shift
|
|
92
|
+
float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
|
|
93
|
+
vec3 phi = vec3( phi21 ) + phi23;
|
|
94
|
+
|
|
95
|
+
// Compound terms
|
|
96
|
+
vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
|
|
97
|
+
vec3 r123 = sqrt( R123 );
|
|
98
|
+
vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
|
|
99
|
+
|
|
100
|
+
// Reflectance term for m = 0 (DC term amplitude)
|
|
101
|
+
vec3 C0 = R12 + Rs;
|
|
102
|
+
I = C0;
|
|
103
|
+
|
|
104
|
+
// Reflectance term for m > 0 (pairs of diracs)
|
|
105
|
+
vec3 Cm = Rs - T121;
|
|
106
|
+
for ( int m = 1; m <= 2; ++ m ) {
|
|
107
|
+
|
|
108
|
+
Cm *= r123;
|
|
109
|
+
vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
|
|
110
|
+
I += Cm * Sm;
|
|
111
|
+
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// Since out of gamut colors might be produced, negative color values are clamped to 0.
|
|
115
|
+
return max( I, vec3( 0.0 ) );
|
|
116
|
+
|
|
117
|
+
}
|
|
104
118
|
|
|
105
119
|
#endif
|
|
106
120
|
|
|
@@ -28,26 +28,26 @@ geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPositi
|
|
|
28
28
|
|
|
29
29
|
#ifdef USE_IRIDESCENCE
|
|
30
30
|
|
|
31
|
-
float dotNVi = saturate( dot( normal, geometry.viewDir ) );
|
|
31
|
+
float dotNVi = saturate( dot( normal, geometry.viewDir ) );
|
|
32
32
|
|
|
33
|
-
if ( material.iridescenceThickness == 0.0 ) {
|
|
33
|
+
if ( material.iridescenceThickness == 0.0 ) {
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
material.iridescence = 0.0;
|
|
36
36
|
|
|
37
|
-
} else {
|
|
37
|
+
} else {
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
material.iridescence = saturate( material.iridescence );
|
|
40
40
|
|
|
41
|
-
}
|
|
41
|
+
}
|
|
42
42
|
|
|
43
|
-
if ( material.iridescence > 0.0 ) {
|
|
43
|
+
if ( material.iridescence > 0.0 ) {
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
|
|
46
46
|
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
// Iridescence F0 approximation
|
|
48
|
+
material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
|
|
49
49
|
|
|
50
|
-
}
|
|
50
|
+
}
|
|
51
51
|
|
|
52
52
|
#endif
|
|
53
53
|
|
|
@@ -82,6 +82,10 @@ IncidentLight directLight;
|
|
|
82
82
|
#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
|
|
83
83
|
|
|
84
84
|
SpotLight spotLight;
|
|
85
|
+
vec4 spotColor;
|
|
86
|
+
vec3 spotLightCoord;
|
|
87
|
+
bool inSpotLightMap;
|
|
88
|
+
|
|
85
89
|
#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
|
|
86
90
|
SpotLightShadow spotLightShadow;
|
|
87
91
|
#endif
|
|
@@ -93,9 +97,27 @@ IncidentLight directLight;
|
|
|
93
97
|
|
|
94
98
|
getSpotLightInfo( spotLight, geometry, directLight );
|
|
95
99
|
|
|
100
|
+
// spot lights are ordered [shadows with maps, shadows without maps, maps without shadows, none]
|
|
101
|
+
#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
|
|
102
|
+
#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
|
|
103
|
+
#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
|
|
104
|
+
#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
|
|
105
|
+
#else
|
|
106
|
+
#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
|
|
107
|
+
#endif
|
|
108
|
+
|
|
109
|
+
#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
|
|
110
|
+
spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
|
|
111
|
+
inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
|
|
112
|
+
spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
|
|
113
|
+
directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
|
|
114
|
+
#endif
|
|
115
|
+
|
|
116
|
+
#undef SPOT_LIGHT_MAP_INDEX
|
|
117
|
+
|
|
96
118
|
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
|
|
97
119
|
spotLightShadow = spotLightShadows[ i ];
|
|
98
|
-
directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius,
|
|
120
|
+
directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
|
|
99
121
|
#endif
|
|
100
122
|
|
|
101
123
|
RE_Direct( directLight, geometry, material, reflectedLight );
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export default /* glsl */`
|
|
2
|
+
varying vec3 vViewPosition;
|
|
3
|
+
|
|
4
|
+
struct LambertMaterial {
|
|
5
|
+
|
|
6
|
+
vec3 diffuseColor;
|
|
7
|
+
float specularStrength;
|
|
8
|
+
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
void RE_Direct_Lambert( const in IncidentLight directLight, const in GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
|
|
12
|
+
|
|
13
|
+
float dotNL = saturate( dot( geometry.normal, directLight.direction ) );
|
|
14
|
+
vec3 irradiance = dotNL * directLight.color;
|
|
15
|
+
|
|
16
|
+
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
17
|
+
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
|
|
21
|
+
|
|
22
|
+
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
23
|
+
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
#define RE_Direct RE_Direct_Lambert
|
|
27
|
+
#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert
|
|
28
|
+
|
|
29
|
+
#define Material_LightProbeLOD( material ) (0)
|
|
30
|
+
`;
|
|
@@ -11,6 +11,8 @@ material.roughness = min( material.roughness, 1.0 );
|
|
|
11
11
|
|
|
12
12
|
#ifdef IOR
|
|
13
13
|
|
|
14
|
+
material.ior = ior;
|
|
15
|
+
|
|
14
16
|
#ifdef SPECULAR
|
|
15
17
|
|
|
16
18
|
float specularIntensityFactor = specularIntensity;
|
|
@@ -38,7 +40,7 @@ material.roughness = min( material.roughness, 1.0 );
|
|
|
38
40
|
|
|
39
41
|
#endif
|
|
40
42
|
|
|
41
|
-
material.specularColor = mix( min( pow2( ( ior - 1.0 ) / ( ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
|
|
43
|
+
material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
|
|
42
44
|
|
|
43
45
|
#else
|
|
44
46
|
|
|
@@ -26,6 +26,18 @@ struct PhysicalMaterial {
|
|
|
26
26
|
float sheenRoughness;
|
|
27
27
|
#endif
|
|
28
28
|
|
|
29
|
+
#ifdef IOR
|
|
30
|
+
float ior;
|
|
31
|
+
#endif
|
|
32
|
+
|
|
33
|
+
#ifdef USE_TRANSMISSION
|
|
34
|
+
float transmission;
|
|
35
|
+
float transmissionAlpha;
|
|
36
|
+
float thickness;
|
|
37
|
+
float attenuationDistance;
|
|
38
|
+
vec3 attenuationColor;
|
|
39
|
+
#endif
|
|
40
|
+
|
|
29
41
|
};
|
|
30
42
|
|
|
31
43
|
// temporary
|
|
@@ -35,7 +47,7 @@ vec3 sheenSpecular = vec3( 0.0 );
|
|
|
35
47
|
// This is a curve-fit approxmation to the "Charlie sheen" BRDF integrated over the hemisphere from
|
|
36
48
|
// Estevez and Kulla 2017, "Production Friendly Microfacet Sheen BRDF". The analysis can be found
|
|
37
49
|
// in the Sheen section of https://drive.google.com/file/d/1T0D1VSyR4AllqIJTQAraEIzjlb5h4FKH/view?usp=sharing
|
|
38
|
-
float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness) {
|
|
50
|
+
float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
|
|
39
51
|
|
|
40
52
|
float dotNV = saturate( dot( normal, viewDir ) );
|
|
41
53
|
|
|
@@ -19,10 +19,8 @@ export default /* glsl */`
|
|
|
19
19
|
|
|
20
20
|
vec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 mapN, float faceDirection ) {
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
vec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );
|
|
25
|
-
vec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );
|
|
22
|
+
vec3 q0 = dFdx( eye_pos.xyz );
|
|
23
|
+
vec3 q1 = dFdy( eye_pos.xyz );
|
|
26
24
|
vec2 st0 = dFdx( vUv.st );
|
|
27
25
|
vec2 st1 = dFdy( vUv.st );
|
|
28
26
|
|
|
@@ -5,7 +5,7 @@ diffuseColor.a = 1.0;
|
|
|
5
5
|
|
|
6
6
|
// https://github.com/mrdoob/three.js/pull/22425
|
|
7
7
|
#ifdef USE_TRANSMISSION
|
|
8
|
-
diffuseColor.a *= transmissionAlpha + 0.1;
|
|
8
|
+
diffuseColor.a *= material.transmissionAlpha + 0.1;
|
|
9
9
|
#endif
|
|
10
10
|
|
|
11
11
|
gl_FragColor = vec4( outgoingLight, diffuseColor.a );
|
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
export default /* glsl */`
|
|
2
|
+
#if NUM_SPOT_LIGHT_COORDS > 0
|
|
3
|
+
|
|
4
|
+
varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
|
|
5
|
+
|
|
6
|
+
#endif
|
|
7
|
+
|
|
8
|
+
#if NUM_SPOT_LIGHT_MAPS > 0
|
|
9
|
+
|
|
10
|
+
uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
|
|
11
|
+
|
|
12
|
+
#endif
|
|
13
|
+
|
|
2
14
|
#ifdef USE_SHADOWMAP
|
|
3
15
|
|
|
4
16
|
#if NUM_DIR_LIGHT_SHADOWS > 0
|
|
@@ -20,7 +32,6 @@ export default /* glsl */`
|
|
|
20
32
|
#if NUM_SPOT_LIGHT_SHADOWS > 0
|
|
21
33
|
|
|
22
34
|
uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
|
|
23
|
-
varying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];
|
|
24
35
|
|
|
25
36
|
struct SpotLightShadow {
|
|
26
37
|
float shadowBias;
|
|
@@ -159,22 +170,22 @@ export default /* glsl */`
|
|
|
159
170
|
texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
|
|
160
171
|
texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
|
|
161
172
|
texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
|
|
162
|
-
mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
|
|
173
|
+
mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
|
|
163
174
|
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
|
|
164
175
|
f.x ) +
|
|
165
|
-
mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
|
|
176
|
+
mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
|
|
166
177
|
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
|
|
167
178
|
f.x ) +
|
|
168
|
-
mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
|
|
179
|
+
mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
|
|
169
180
|
texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
|
|
170
181
|
f.y ) +
|
|
171
|
-
mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
|
|
182
|
+
mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
|
|
172
183
|
texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
|
|
173
184
|
f.y ) +
|
|
174
|
-
mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
|
|
185
|
+
mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
|
|
175
186
|
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
|
|
176
187
|
f.x ),
|
|
177
|
-
mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
|
|
188
|
+
mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
|
|
178
189
|
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
|
|
179
190
|
f.x ),
|
|
180
191
|
f.y )
|
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
export default /* glsl */`
|
|
2
|
+
|
|
3
|
+
#if NUM_SPOT_LIGHT_COORDS > 0
|
|
4
|
+
|
|
5
|
+
uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
|
|
6
|
+
varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
|
|
7
|
+
|
|
8
|
+
#endif
|
|
9
|
+
|
|
2
10
|
#ifdef USE_SHADOWMAP
|
|
3
11
|
|
|
4
12
|
#if NUM_DIR_LIGHT_SHADOWS > 0
|
|
@@ -19,9 +27,6 @@ export default /* glsl */`
|
|
|
19
27
|
|
|
20
28
|
#if NUM_SPOT_LIGHT_SHADOWS > 0
|
|
21
29
|
|
|
22
|
-
uniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHT_SHADOWS ];
|
|
23
|
-
varying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];
|
|
24
|
-
|
|
25
30
|
struct SpotLightShadow {
|
|
26
31
|
float shadowBias;
|
|
27
32
|
float shadowNormalBias;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export default /* glsl */`
|
|
2
|
-
#
|
|
2
|
+
#if defined( USE_SHADOWMAP ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
|
|
3
3
|
|
|
4
|
-
#if NUM_DIR_LIGHT_SHADOWS > 0 ||
|
|
4
|
+
#if NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SPOT_LIGHT_COORDS > 0 || NUM_POINT_LIGHT_SHADOWS > 0
|
|
5
5
|
|
|
6
6
|
// Offsetting the position used for querying occlusion along the world normal can be used to reduce shadow acne.
|
|
7
7
|
vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
|
|
@@ -22,13 +22,16 @@ export default /* glsl */`
|
|
|
22
22
|
|
|
23
23
|
#endif
|
|
24
24
|
|
|
25
|
-
#if
|
|
25
|
+
#if NUM_SPOT_LIGHT_COORDS > 0
|
|
26
26
|
|
|
27
27
|
#pragma unroll_loop_start
|
|
28
|
-
for ( int i = 0; i <
|
|
28
|
+
for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
|
|
29
29
|
|
|
30
|
-
shadowWorldPosition = worldPosition
|
|
31
|
-
|
|
30
|
+
shadowWorldPosition = worldPosition;
|
|
31
|
+
#if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
|
|
32
|
+
shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
|
|
33
|
+
#endif
|
|
34
|
+
vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
|
|
32
35
|
|
|
33
36
|
}
|
|
34
37
|
#pragma unroll_loop_end
|