super-three 0.152.0 → 0.154.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 +779 -557
- package/build/three.js +779 -557
- package/build/three.min.js +2 -1
- package/build/three.module.js +770 -539
- package/build/three.module.min.js +2 -1
- package/examples/jsm/cameras/CinematicCamera.js +1 -2
- package/examples/jsm/capabilities/WebGPU.js +15 -1
- package/examples/jsm/controls/ArcballControls.js +2 -1
- package/examples/jsm/controls/FlyControls.js +25 -9
- package/examples/jsm/controls/OrbitControls.js +5 -1
- package/examples/jsm/csm/CSM.js +1 -3
- package/examples/jsm/effects/AnaglyphEffect.js +6 -20
- package/examples/jsm/effects/OutlineEffect.js +1 -1
- package/examples/jsm/effects/ParallaxBarrierEffect.js +3 -0
- package/examples/jsm/environments/RoomEnvironment.js +6 -2
- package/examples/jsm/exporters/GLTFExporter.js +74 -2
- package/examples/jsm/exporters/USDZExporter.js +170 -129
- package/examples/jsm/helpers/ViewHelper.js +1 -1
- package/examples/jsm/lines/LineMaterial.js +1 -1
- package/examples/jsm/loaders/3DMLoader.js +1 -1
- package/examples/jsm/loaders/3MFLoader.js +5 -1
- package/examples/jsm/loaders/AMFLoader.js +5 -1
- package/examples/jsm/loaders/ColladaLoader.js +4 -1
- package/examples/jsm/loaders/DRACOLoader.js +2 -0
- package/examples/jsm/loaders/FBXLoader.js +9 -2
- package/examples/jsm/loaders/GLTFLoader.js +230 -94
- package/examples/jsm/loaders/KTX2Loader.js +106 -47
- package/examples/jsm/loaders/LDrawLoader.js +4 -7
- package/examples/jsm/loaders/MMDLoader.js +40 -13
- package/examples/jsm/loaders/PCDLoader.js +25 -10
- package/examples/jsm/loaders/PDBLoader.js +7 -2
- package/examples/jsm/loaders/PLYLoader.js +30 -8
- package/examples/jsm/loaders/STLLoader.js +8 -3
- package/examples/jsm/loaders/VRMLLoader.js +55 -7
- package/examples/jsm/loaders/VTKLoader.js +12 -4
- package/examples/jsm/loaders/XYZLoader.js +9 -3
- package/examples/jsm/materials/MeshGouraudMaterial.js +2 -2
- package/examples/jsm/math/Lut.js +5 -4
- package/examples/jsm/math/MeshSurfaceSampler.js +82 -37
- package/examples/jsm/misc/GPUComputationRenderer.js +1 -0
- package/examples/jsm/misc/VolumeSlice.js +3 -1
- package/examples/jsm/nodes/Nodes.js +22 -16
- package/examples/jsm/nodes/accessors/BufferAttributeNode.js +99 -0
- package/examples/jsm/nodes/accessors/BufferNode.js +2 -2
- package/examples/jsm/nodes/accessors/CameraNode.js +25 -4
- package/examples/jsm/nodes/accessors/ExtendedMaterialNode.js +7 -1
- package/examples/jsm/nodes/accessors/InstanceNode.js +29 -12
- package/examples/jsm/nodes/accessors/MaterialNode.js +55 -47
- package/examples/jsm/nodes/accessors/MaterialReferenceNode.js +2 -2
- package/examples/jsm/nodes/accessors/ModelNode.js +3 -1
- package/examples/jsm/nodes/accessors/ModelViewProjectionNode.js +4 -9
- package/examples/jsm/nodes/accessors/MorphNode.js +70 -0
- package/examples/jsm/nodes/accessors/NormalNode.js +3 -2
- package/examples/jsm/nodes/accessors/Object3DNode.js +10 -2
- package/examples/jsm/nodes/accessors/ReferenceNode.js +2 -2
- package/examples/jsm/nodes/accessors/SceneNode.js +46 -0
- package/examples/jsm/nodes/accessors/SkinningNode.js +43 -62
- package/examples/jsm/nodes/accessors/StorageBufferNode.js +2 -2
- package/examples/jsm/nodes/accessors/TangentNode.js +2 -2
- package/examples/jsm/nodes/accessors/TextureBicubicNode.js +94 -0
- package/examples/jsm/nodes/accessors/TextureNode.js +68 -6
- package/examples/jsm/nodes/accessors/TextureSizeNode.js +35 -0
- package/examples/jsm/nodes/accessors/UVNode.js +1 -1
- package/examples/jsm/nodes/code/CodeNode.js +3 -0
- package/examples/jsm/nodes/code/FunctionNode.js +25 -4
- package/examples/jsm/nodes/core/AttributeNode.js +1 -1
- package/examples/jsm/nodes/core/BypassNode.js +2 -2
- package/examples/jsm/nodes/core/ContextNode.js +2 -0
- package/examples/jsm/nodes/core/IndexNode.js +66 -0
- package/examples/jsm/nodes/core/LightingModel.js +2 -1
- package/examples/jsm/nodes/core/Node.js +13 -16
- package/examples/jsm/nodes/core/NodeAttribute.js +2 -1
- package/examples/jsm/nodes/core/NodeBuilder.js +86 -8
- package/examples/jsm/nodes/core/NodeUtils.js +10 -0
- package/examples/jsm/nodes/core/PropertyNode.js +6 -2
- package/examples/jsm/nodes/core/StackNode.js +8 -1
- package/examples/jsm/nodes/core/UniformNode.js +1 -1
- package/examples/jsm/nodes/core/VarNode.js +1 -3
- package/examples/jsm/nodes/display/BlendModeNode.js +9 -9
- package/examples/jsm/nodes/display/ColorAdjustmentNode.js +7 -7
- package/examples/jsm/nodes/display/ColorSpaceNode.js +50 -49
- package/examples/jsm/nodes/display/NormalMapNode.js +3 -3
- package/examples/jsm/nodes/display/ToneMappingNode.js +24 -15
- package/examples/jsm/nodes/display/ViewportDepthNode.js +69 -0
- package/examples/jsm/nodes/display/ViewportDepthTextureNode.js +34 -0
- package/examples/jsm/nodes/display/ViewportSharedTextureNode.js +7 -6
- package/examples/jsm/nodes/display/ViewportTextureNode.js +33 -19
- package/examples/jsm/nodes/functions/BSDF/BRDF_BlinnPhong.js +5 -5
- package/examples/jsm/nodes/functions/BSDF/BRDF_GGX.js +10 -8
- package/examples/jsm/nodes/functions/BSDF/BRDF_Lambert.js +2 -2
- package/examples/jsm/nodes/functions/BSDF/BRDF_Sheen.js +43 -0
- package/examples/jsm/nodes/functions/BSDF/DFGApprox.js +4 -4
- package/examples/jsm/nodes/functions/BSDF/D_GGX.js +2 -2
- package/examples/jsm/nodes/functions/BSDF/EnvironmentBRDF.js +13 -0
- package/examples/jsm/nodes/functions/BSDF/F_Schlick.js +2 -4
- package/examples/jsm/nodes/functions/BSDF/V_GGX_SmithCorrelated.js +2 -2
- package/examples/jsm/nodes/functions/PhongLightingModel.js +7 -7
- package/examples/jsm/nodes/functions/PhysicalLightingModel.js +132 -19
- package/examples/jsm/nodes/functions/material/getGeometryRoughness.js +2 -2
- package/examples/jsm/nodes/functions/material/getRoughness.js +3 -3
- package/examples/jsm/nodes/geometry/RangeNode.js +33 -51
- package/examples/jsm/nodes/lighting/AnalyticLightNode.js +6 -3
- package/examples/jsm/nodes/lighting/DirectionalLightNode.js +2 -2
- package/examples/jsm/nodes/lighting/EnvironmentNode.js +107 -62
- package/examples/jsm/nodes/lighting/HemisphereLightNode.js +2 -2
- package/examples/jsm/nodes/lighting/LightUtils.js +2 -2
- package/examples/jsm/nodes/lighting/LightingContextNode.js +17 -15
- package/examples/jsm/nodes/lighting/PointLightNode.js +3 -3
- package/examples/jsm/nodes/lighting/SpotLightNode.js +3 -3
- package/examples/jsm/nodes/materials/LineBasicNodeMaterial.js +0 -15
- package/examples/jsm/nodes/materials/MeshBasicNodeMaterial.js +0 -15
- package/examples/jsm/nodes/materials/MeshNormalNodeMaterial.js +0 -10
- package/examples/jsm/nodes/materials/MeshPhongNodeMaterial.js +0 -9
- package/examples/jsm/nodes/materials/MeshPhysicalNodeMaterial.js +41 -0
- package/examples/jsm/nodes/materials/MeshStandardNodeMaterial.js +1 -14
- package/examples/jsm/nodes/materials/NodeMaterial.js +119 -29
- package/examples/jsm/nodes/materials/PointsNodeMaterial.js +0 -9
- package/examples/jsm/nodes/materials/SpriteNodeMaterial.js +0 -7
- package/examples/jsm/nodes/materialx/lib/mx_hsv.js +3 -3
- package/examples/jsm/nodes/materialx/lib/mx_noise.js +14 -14
- package/examples/jsm/nodes/materialx/lib/mx_transform_color.js +4 -4
- package/examples/jsm/nodes/math/MathNode.js +6 -0
- package/examples/jsm/nodes/math/OperatorNode.js +1 -1
- package/examples/jsm/nodes/procedural/CheckerNode.js +3 -3
- package/examples/jsm/nodes/shadernode/ShaderNode.js +60 -33
- package/examples/jsm/nodes/utils/EquirectUVNode.js +2 -3
- package/examples/jsm/nodes/utils/LoopNode.js +186 -0
- package/examples/jsm/nodes/utils/TriplanarTexturesNode.js +1 -1
- package/examples/jsm/objects/GroundProjectedSkybox.js +1 -1
- package/examples/jsm/objects/Lensflare.js +3 -4
- package/examples/jsm/objects/MarchingCubes.js +5 -1
- package/examples/jsm/objects/Reflector.js +4 -1
- package/examples/jsm/objects/Refractor.js +1 -1
- package/examples/jsm/objects/Sky.js +1 -1
- package/examples/jsm/objects/Water.js +2 -1
- package/examples/jsm/objects/Water2.js +1 -1
- package/examples/jsm/offscreen/scene.js +1 -0
- package/examples/jsm/physics/RapierPhysics.js +93 -133
- package/examples/jsm/postprocessing/AfterimagePass.js +3 -0
- package/examples/jsm/postprocessing/BloomPass.js +7 -2
- package/examples/jsm/postprocessing/BokehPass.js +3 -2
- package/examples/jsm/postprocessing/DotScreenPass.js +1 -0
- package/examples/jsm/postprocessing/EffectComposer.js +4 -1
- package/examples/jsm/postprocessing/FilmPass.js +1 -0
- package/examples/jsm/postprocessing/OutlinePass.js +8 -9
- package/examples/jsm/postprocessing/OutputPass.js +72 -0
- package/examples/jsm/postprocessing/RenderPixelatedPass.js +4 -3
- package/examples/jsm/postprocessing/SAOPass.js +4 -2
- package/examples/jsm/postprocessing/SMAAPass.js +5 -2
- package/examples/jsm/postprocessing/SSAARenderPass.js +5 -13
- package/examples/jsm/postprocessing/SSAOPass.js +4 -2
- package/examples/jsm/postprocessing/SSRPass.js +3 -1
- package/examples/jsm/postprocessing/SavePass.js +5 -2
- package/examples/jsm/postprocessing/ShaderPass.js +1 -0
- package/examples/jsm/postprocessing/TAARenderPass.js +17 -4
- package/examples/jsm/postprocessing/TexturePass.js +2 -1
- package/examples/jsm/postprocessing/UnrealBloomPass.js +13 -13
- package/examples/jsm/renderers/{webgpu/WebGPUAnimation.js → common/Animation.js} +2 -2
- package/examples/jsm/renderers/common/Attributes.js +75 -0
- package/examples/jsm/renderers/common/Backend.js +162 -0
- package/examples/jsm/renderers/common/Background.js +134 -0
- package/examples/jsm/renderers/common/Binding.js +11 -0
- package/examples/jsm/renderers/common/Bindings.js +169 -0
- package/examples/jsm/renderers/common/Buffer.js +38 -0
- package/examples/jsm/renderers/{webgpu/WebGPUBufferUtils.js → common/BufferUtils.js} +2 -2
- package/examples/jsm/renderers/{webgpu/WebGPUWeakMap.js → common/ChainMap.js} +11 -5
- package/examples/jsm/renderers/common/ComputePipeline.js +17 -0
- package/examples/jsm/renderers/common/Constants.js +14 -0
- package/examples/jsm/renderers/common/CubeRenderTarget.js +65 -0
- package/examples/jsm/renderers/common/DataMap.js +54 -0
- package/examples/jsm/renderers/{webgpu/WebGPUGeometries.js → common/Geometries.js} +38 -37
- package/examples/jsm/renderers/{webgpu/WebGPUInfo.js → common/Info.js} +2 -3
- package/examples/jsm/renderers/common/Pipeline.js +13 -0
- package/examples/jsm/renderers/common/Pipelines.js +321 -0
- package/examples/jsm/renderers/common/ProgrammableStage.js +18 -0
- package/examples/jsm/renderers/common/RenderContext.js +37 -0
- package/examples/jsm/renderers/common/RenderContexts.js +38 -0
- package/examples/jsm/renderers/{webgpu/WebGPURenderLists.js → common/RenderList.js} +2 -39
- package/examples/jsm/renderers/common/RenderLists.js +38 -0
- package/examples/jsm/renderers/common/RenderObject.js +113 -0
- package/examples/jsm/renderers/common/RenderObjects.js +92 -0
- package/examples/jsm/renderers/common/RenderPipeline.js +16 -0
- package/examples/jsm/renderers/{webgpu/WebGPURenderTarget.js → common/RenderTarget.js} +2 -2
- package/examples/jsm/renderers/common/Renderer.js +864 -0
- package/examples/jsm/renderers/common/SampledTexture.js +80 -0
- package/examples/jsm/renderers/common/Sampler.js +18 -0
- package/examples/jsm/renderers/common/StorageBuffer.js +17 -0
- package/examples/jsm/renderers/common/Textures.js +206 -0
- package/examples/jsm/renderers/{webgpu/WebGPUUniform.js → common/Uniform.js} +13 -9
- package/examples/jsm/renderers/common/UniformBuffer.js +15 -0
- package/examples/jsm/renderers/{webgpu/WebGPUUniformsGroup.js → common/UniformsGroup.js} +13 -13
- package/examples/jsm/renderers/{webgpu/nodes/WebGPUNodes.js → common/nodes/NodeRender.js} +3 -3
- package/examples/jsm/renderers/{webgpu/nodes/WebGPUNodeSampledTexture.js → common/nodes/NodeSampledTexture.js} +4 -4
- package/examples/jsm/renderers/{webgpu/nodes/WebGPUNodeSampler.js → common/nodes/NodeSampler.js} +3 -3
- package/examples/jsm/renderers/{webgpu/nodes/WebGPUNodeUniform.js → common/nodes/NodeUniform.js} +1 -1
- package/examples/jsm/renderers/common/nodes/Nodes.js +319 -0
- package/examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js +340 -0
- package/examples/jsm/renderers/webgl/nodes/WebGLNodeBuilder.js +23 -19
- package/examples/jsm/renderers/webgpu/WebGPUBackend.js +847 -0
- package/examples/jsm/renderers/webgpu/WebGPURenderer.js +15 -1131
- package/examples/jsm/renderers/webgpu/nodes/{WebGPUNodeBuilder.js → WGSLNodeBuilder.js} +75 -45
- package/examples/jsm/{nodes/parsers → renderers/webgpu/nodes}/WGSLNodeFunction.js +2 -2
- package/examples/jsm/{nodes/parsers → renderers/webgpu/nodes}/WGSLNodeParser.js +1 -1
- package/examples/jsm/renderers/webgpu/utils/WebGPUAttributeUtils.js +255 -0
- package/examples/jsm/renderers/webgpu/utils/WebGPUBindingUtils.js +145 -0
- package/examples/jsm/renderers/webgpu/{constants.js → utils/WebGPUConstants.js} +6 -7
- package/examples/jsm/renderers/webgpu/{WebGPURenderPipeline.js → utils/WebGPUPipelineUtils.js} +154 -247
- package/examples/jsm/renderers/webgpu/{WebGPUTextureUtils.js → utils/WebGPUTextureMipmapUtils.js} +3 -25
- package/examples/jsm/renderers/webgpu/{WebGPUTextures.js → utils/WebGPUTextureUtils.js} +392 -505
- package/examples/jsm/renderers/webgpu/utils/WebGPUUtils.js +92 -0
- package/examples/jsm/shaders/BleachBypassShader.js +2 -0
- package/examples/jsm/shaders/BlendShader.js +1 -2
- package/examples/jsm/shaders/BokehShader2.js +3 -0
- package/examples/jsm/shaders/ColorifyShader.js +2 -0
- package/examples/jsm/shaders/ConvolutionShader.js +2 -0
- package/examples/jsm/shaders/CopyShader.js +4 -2
- package/examples/jsm/shaders/DotScreenShader.js +2 -0
- package/examples/jsm/shaders/ExposureShader.js +44 -0
- package/examples/jsm/shaders/FilmShader.js +2 -0
- package/examples/jsm/shaders/GammaCorrectionShader.js +2 -0
- package/examples/jsm/shaders/HorizontalBlurShader.js +2 -0
- package/examples/jsm/shaders/OutputShader.js +61 -0
- package/examples/jsm/shaders/RGBShiftShader.js +2 -0
- package/examples/jsm/shaders/SepiaShader.js +2 -0
- package/examples/jsm/shaders/ToonShader.js +13 -5
- package/examples/jsm/shaders/VerticalBlurShader.js +2 -0
- package/examples/jsm/shaders/VignetteShader.js +2 -0
- package/examples/jsm/shaders/WaterRefractionShader.js +5 -2
- package/examples/jsm/utils/BufferGeometryUtils.js +17 -1
- package/examples/jsm/utils/TextureUtils.js +86 -0
- package/examples/jsm/webxr/OculusHandPointerModel.js +34 -13
- package/examples/jsm/webxr/XRHandPrimitiveModel.js +1 -0
- package/examples/jsm/webxr/XRPlanes.js +100 -0
- package/package.json +3 -1
- package/src/Three.Legacy.js +0 -228
- package/src/audio/PositionalAudio.js +8 -0
- package/src/cameras/Camera.js +5 -0
- package/src/cameras/CubeCamera.js +76 -13
- package/src/cameras/OrthographicCamera.js +1 -1
- package/src/cameras/PerspectiveCamera.js +1 -1
- package/src/constants.js +13 -1
- package/src/core/BufferAttribute.js +3 -25
- package/src/core/BufferGeometry.js +1 -8
- package/src/core/Object3D.js +1 -1
- package/src/extras/core/Curve.js +1 -1
- package/src/loaders/CubeTextureLoader.js +2 -0
- package/src/loaders/Loader.js +2 -0
- package/src/loaders/MaterialLoader.js +5 -0
- package/src/loaders/ObjectLoader.js +1 -0
- package/src/materials/Material.js +13 -1
- package/src/materials/MeshPhysicalMaterial.js +32 -6
- package/src/math/Color.js +16 -11
- package/src/math/Frustum.js +16 -2
- package/src/math/MathUtils.js +16 -0
- package/src/math/Matrix3.js +26 -6
- package/src/math/Matrix4.js +74 -19
- package/src/objects/InstancedMesh.js +3 -0
- package/src/objects/Mesh.js +14 -10
- package/src/objects/Skeleton.js +1 -3
- package/src/objects/SkinnedMesh.js +36 -8
- package/src/renderers/WebGLRenderer.js +126 -21
- package/src/renderers/shaders/ShaderChunk/alphahash_fragment.glsl.js +7 -0
- package/src/renderers/shaders/ShaderChunk/alphahash_pars_fragment.glsl.js +68 -0
- package/src/renderers/shaders/ShaderChunk/begin_vertex.glsl.js +6 -0
- package/src/renderers/shaders/ShaderChunk/common.glsl.js +6 -0
- package/src/renderers/shaders/ShaderChunk/envmap_physical_pars_fragment.glsl.js +26 -3
- package/src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js +9 -1
- package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +26 -0
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +52 -2
- package/src/renderers/shaders/ShaderChunk/normal_fragment_begin.glsl.js +10 -2
- package/src/renderers/shaders/ShaderChunk/normalmap_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/{output_fragment.glsl.js → opaque_fragment.glsl.js} +1 -2
- package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/transmission_fragment.glsl.js +3 -3
- package/src/renderers/shaders/ShaderChunk/transmission_pars_fragment.glsl.js +10 -5
- package/src/renderers/shaders/ShaderChunk/uv_pars_fragment.glsl.js +6 -1
- package/src/renderers/shaders/ShaderChunk/uv_pars_vertex.glsl.js +7 -1
- package/src/renderers/shaders/ShaderChunk/uv_vertex.glsl.js +6 -1
- package/src/renderers/shaders/ShaderChunk.js +10 -6
- package/src/renderers/shaders/ShaderLib/background.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/backgroundCube.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/cube.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/depth.glsl.js +2 -0
- package/src/renderers/shaders/ShaderLib/distanceRGBA.glsl.js +2 -0
- package/src/renderers/shaders/ShaderLib/equirect.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/linedashed.glsl.js +2 -2
- package/src/renderers/shaders/ShaderLib/meshbasic.glsl.js +4 -2
- package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +4 -2
- package/src/renderers/shaders/ShaderLib/meshmatcap.glsl.js +4 -2
- package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +4 -2
- package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +12 -2
- package/src/renderers/shaders/ShaderLib/meshtoon.glsl.js +4 -2
- package/src/renderers/shaders/ShaderLib/points.glsl.js +4 -2
- package/src/renderers/shaders/ShaderLib/shadow.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/sprite.glsl.js +4 -2
- package/src/renderers/shaders/ShaderLib.js +4 -1
- package/src/renderers/shaders/UniformsLib.js +2 -0
- package/src/renderers/webgl/WebGLBindingStates.js +13 -5
- package/src/renderers/webgl/WebGLGeometries.js +12 -0
- package/src/renderers/webgl/WebGLInfo.js +0 -1
- package/src/renderers/webgl/WebGLMaterials.js +18 -0
- package/src/renderers/webgl/WebGLObjects.js +23 -3
- package/src/renderers/webgl/WebGLProgram.js +43 -5
- package/src/renderers/webgl/WebGLPrograms.js +19 -7
- package/src/renderers/webgl/WebGLTextures.js +19 -1
- package/src/renderers/webvr/WebVRManager.js +12 -0
- package/src/renderers/webxr/WebXRManager.js +39 -99
- package/src/scenes/Scene.js +0 -14
- package/src/textures/DepthTexture.js +22 -0
- package/src/textures/FramebufferTexture.js +1 -3
- package/src/textures/Source.js +4 -0
- package/src/textures/Texture.js +1 -1
- package/examples/jsm/exporters/ColladaExporter.js +0 -725
- package/examples/jsm/geometries/LightningStrike.js +0 -1017
- package/examples/jsm/loaders/PRWMLoader.js +0 -299
- package/examples/jsm/nodes/core/InstanceIndexNode.js +0 -26
- package/examples/jsm/objects/LightningStorm.js +0 -245
- package/examples/jsm/postprocessing/AdaptiveToneMappingPass.js +0 -361
- package/examples/jsm/renderers/webgpu/WebGPUAttributes.js +0 -197
- package/examples/jsm/renderers/webgpu/WebGPUBackground.js +0 -190
- package/examples/jsm/renderers/webgpu/WebGPUBinding.js +0 -22
- package/examples/jsm/renderers/webgpu/WebGPUBindings.js +0 -270
- package/examples/jsm/renderers/webgpu/WebGPUBuffer.js +0 -43
- package/examples/jsm/renderers/webgpu/WebGPUComputePipelines.js +0 -78
- package/examples/jsm/renderers/webgpu/WebGPUProgrammableStage.js +0 -22
- package/examples/jsm/renderers/webgpu/WebGPUProperties.js +0 -44
- package/examples/jsm/renderers/webgpu/WebGPURenderObject.js +0 -40
- package/examples/jsm/renderers/webgpu/WebGPURenderObjects.js +0 -50
- package/examples/jsm/renderers/webgpu/WebGPURenderPipelines.js +0 -274
- package/examples/jsm/renderers/webgpu/WebGPURenderStates.js +0 -54
- package/examples/jsm/renderers/webgpu/WebGPUSampledTexture.js +0 -75
- package/examples/jsm/renderers/webgpu/WebGPUSampler.js +0 -29
- package/examples/jsm/renderers/webgpu/WebGPUStorageBuffer.js +0 -20
- package/examples/jsm/renderers/webgpu/WebGPUTextureRenderer.js +0 -38
- package/examples/jsm/renderers/webgpu/WebGPUUniformBuffer.js +0 -18
- package/examples/jsm/renderers/webgpu/WebGPUUtils.js +0 -88
- package/examples/jsm/shaders/ToneMapShader.js +0 -73
- /package/src/renderers/shaders/ShaderChunk/{encodings_fragment.glsl.js → colorspace_fragment.glsl.js} +0 -0
- /package/src/renderers/shaders/ShaderChunk/{encodings_pars_fragment.glsl.js → colorspace_pars_fragment.glsl.js} +0 -0
|
@@ -12,12 +12,24 @@ import {
|
|
|
12
12
|
SRGBColorSpace,
|
|
13
13
|
LinearSRGBColorSpace,
|
|
14
14
|
sRGBEncoding,
|
|
15
|
-
LinearEncoding
|
|
15
|
+
LinearEncoding,
|
|
16
|
+
RGBAIntegerFormat,
|
|
17
|
+
RGIntegerFormat,
|
|
18
|
+
RedIntegerFormat,
|
|
19
|
+
UnsignedIntType,
|
|
20
|
+
UnsignedShortType,
|
|
21
|
+
UnsignedInt248Type,
|
|
22
|
+
UnsignedShort4444Type,
|
|
23
|
+
UnsignedShort5551Type,
|
|
24
|
+
WebGLCoordinateSystem
|
|
16
25
|
} from '../constants.js';
|
|
26
|
+
import { Color } from '../math/Color.js';
|
|
17
27
|
import { Frustum } from '../math/Frustum.js';
|
|
18
28
|
import { Matrix4 } from '../math/Matrix4.js';
|
|
29
|
+
import { Vector2 } from '../math/Vector2.js';
|
|
19
30
|
import { Vector3 } from '../math/Vector3.js';
|
|
20
31
|
import { Vector4 } from '../math/Vector4.js';
|
|
32
|
+
import { floorPowerOfTwo } from '../math/MathUtils.js';
|
|
21
33
|
import { WebGLAnimation } from './webgl/WebGLAnimation.js';
|
|
22
34
|
import { WebGLAttributes } from './webgl/WebGLAttributes.js';
|
|
23
35
|
import { WebGLBackground } from './webgl/WebGLBackground.js';
|
|
@@ -88,6 +100,9 @@ class WebGLRenderer {
|
|
|
88
100
|
|
|
89
101
|
}
|
|
90
102
|
|
|
103
|
+
const uintClearColor = new Uint32Array( 4 );
|
|
104
|
+
const intClearColor = new Int32Array( 4 );
|
|
105
|
+
|
|
91
106
|
let currentRenderList = null;
|
|
92
107
|
let currentRenderState = null;
|
|
93
108
|
|
|
@@ -164,6 +179,9 @@ class WebGLRenderer {
|
|
|
164
179
|
const _currentScissor = new Vector4();
|
|
165
180
|
let _currentScissorTest = null;
|
|
166
181
|
|
|
182
|
+
const _currentClearColor = new Color( 0x000000 );
|
|
183
|
+
let _currentClearAlpha = 0;
|
|
184
|
+
|
|
167
185
|
//
|
|
168
186
|
|
|
169
187
|
let _width = canvas.width;
|
|
@@ -194,6 +212,7 @@ class WebGLRenderer {
|
|
|
194
212
|
|
|
195
213
|
const _projScreenMatrix = new Matrix4();
|
|
196
214
|
|
|
215
|
+
const _vector2 = new Vector2();
|
|
197
216
|
const _vector3 = new Vector3();
|
|
198
217
|
|
|
199
218
|
const _emptyScene = { background: null, fog: null, environment: null, overrideMaterial: null, isScene: true };
|
|
@@ -271,6 +290,12 @@ class WebGLRenderer {
|
|
|
271
290
|
|
|
272
291
|
}
|
|
273
292
|
|
|
293
|
+
if ( typeof WebGLRenderingContext !== 'undefined' && _gl instanceof WebGLRenderingContext ) { // @deprecated, r153
|
|
294
|
+
|
|
295
|
+
console.warn( 'THREE.WebGLRenderer: WebGL 1 support was deprecated in r153 and will be removed in r163.' );
|
|
296
|
+
|
|
297
|
+
}
|
|
298
|
+
|
|
274
299
|
// Some experimental-webgl implementations do not have getShaderPrecisionFormat
|
|
275
300
|
|
|
276
301
|
if ( _gl.getShaderPrecisionFormat === undefined ) {
|
|
@@ -552,7 +577,63 @@ class WebGLRenderer {
|
|
|
552
577
|
|
|
553
578
|
let bits = 0;
|
|
554
579
|
|
|
555
|
-
if ( color )
|
|
580
|
+
if ( color ) {
|
|
581
|
+
|
|
582
|
+
// check if we're trying to clear an integer target
|
|
583
|
+
let isIntegerFormat = false;
|
|
584
|
+
if ( _currentRenderTarget !== null ) {
|
|
585
|
+
|
|
586
|
+
const targetFormat = _currentRenderTarget.texture.format;
|
|
587
|
+
isIntegerFormat = targetFormat === RGBAIntegerFormat ||
|
|
588
|
+
targetFormat === RGIntegerFormat ||
|
|
589
|
+
targetFormat === RedIntegerFormat;
|
|
590
|
+
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
// use the appropriate clear functions to clear the target if it's a signed
|
|
594
|
+
// or unsigned integer target
|
|
595
|
+
if ( isIntegerFormat ) {
|
|
596
|
+
|
|
597
|
+
const targetType = _currentRenderTarget.texture.type;
|
|
598
|
+
const isUnsignedType = targetType === UnsignedByteType ||
|
|
599
|
+
targetType === UnsignedIntType ||
|
|
600
|
+
targetType === UnsignedShortType ||
|
|
601
|
+
targetType === UnsignedInt248Type ||
|
|
602
|
+
targetType === UnsignedShort4444Type ||
|
|
603
|
+
targetType === UnsignedShort5551Type;
|
|
604
|
+
|
|
605
|
+
const clearColor = background.getClearColor();
|
|
606
|
+
const a = background.getClearAlpha();
|
|
607
|
+
const r = clearColor.r;
|
|
608
|
+
const g = clearColor.g;
|
|
609
|
+
const b = clearColor.b;
|
|
610
|
+
|
|
611
|
+
if ( isUnsignedType ) {
|
|
612
|
+
|
|
613
|
+
uintClearColor[ 0 ] = r;
|
|
614
|
+
uintClearColor[ 1 ] = g;
|
|
615
|
+
uintClearColor[ 2 ] = b;
|
|
616
|
+
uintClearColor[ 3 ] = a;
|
|
617
|
+
_gl.clearBufferuiv( _gl.COLOR, 0, uintClearColor );
|
|
618
|
+
|
|
619
|
+
} else {
|
|
620
|
+
|
|
621
|
+
intClearColor[ 0 ] = r;
|
|
622
|
+
intClearColor[ 1 ] = g;
|
|
623
|
+
intClearColor[ 2 ] = b;
|
|
624
|
+
intClearColor[ 3 ] = a;
|
|
625
|
+
_gl.clearBufferiv( _gl.COLOR, 0, intClearColor );
|
|
626
|
+
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
} else {
|
|
630
|
+
|
|
631
|
+
bits |= _gl.COLOR_BUFFER_BIT;
|
|
632
|
+
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
}
|
|
636
|
+
|
|
556
637
|
if ( depth ) bits |= _gl.DEPTH_BUFFER_BIT;
|
|
557
638
|
if ( stencil ) bits |= _gl.STENCIL_BUFFER_BIT;
|
|
558
639
|
|
|
@@ -1011,6 +1092,8 @@ class WebGLRenderer {
|
|
|
1011
1092
|
|
|
1012
1093
|
//
|
|
1013
1094
|
|
|
1095
|
+
this.info.render.frame ++;
|
|
1096
|
+
|
|
1014
1097
|
if ( _clippingEnabled === true ) clipping.beginShadows();
|
|
1015
1098
|
|
|
1016
1099
|
const shadowsArray = currentRenderState.state.shadowsArray;
|
|
@@ -1023,6 +1106,7 @@ class WebGLRenderer {
|
|
|
1023
1106
|
|
|
1024
1107
|
if ( this.info.autoReset === true ) this.info.reset();
|
|
1025
1108
|
|
|
1109
|
+
|
|
1026
1110
|
//
|
|
1027
1111
|
|
|
1028
1112
|
background.render( currentRenderList, scene );
|
|
@@ -1156,28 +1240,24 @@ class WebGLRenderer {
|
|
|
1156
1240
|
|
|
1157
1241
|
if ( ! object.frustumCulled || _frustum.intersectsObject( object ) ) {
|
|
1158
1242
|
|
|
1159
|
-
|
|
1243
|
+
const geometry = objects.update( object );
|
|
1244
|
+
const material = object.material;
|
|
1160
1245
|
|
|
1161
|
-
|
|
1246
|
+
if ( sortObjects ) {
|
|
1162
1247
|
|
|
1163
|
-
if ( object.
|
|
1248
|
+
if ( object.boundingSphere !== undefined ) {
|
|
1164
1249
|
|
|
1165
|
-
object.
|
|
1166
|
-
object.
|
|
1250
|
+
if ( object.boundingSphere === null ) object.computeBoundingSphere();
|
|
1251
|
+
_vector3.copy( object.boundingSphere.center );
|
|
1167
1252
|
|
|
1168
|
-
}
|
|
1253
|
+
} else {
|
|
1169
1254
|
|
|
1170
|
-
|
|
1255
|
+
if ( geometry.boundingSphere === null ) geometry.computeBoundingSphere();
|
|
1256
|
+
_vector3.copy( geometry.boundingSphere.center );
|
|
1171
1257
|
|
|
1172
|
-
|
|
1173
|
-
const material = object.material;
|
|
1174
|
-
|
|
1175
|
-
if ( sortObjects ) {
|
|
1176
|
-
|
|
1177
|
-
if ( geometry.boundingSphere === null ) geometry.computeBoundingSphere();
|
|
1258
|
+
}
|
|
1178
1259
|
|
|
1179
1260
|
_vector3
|
|
1180
|
-
.copy( geometry.boundingSphere.center )
|
|
1181
1261
|
.applyMatrix4( object.matrixWorld )
|
|
1182
1262
|
.applyMatrix4( _projScreenMatrix );
|
|
1183
1263
|
|
|
@@ -1252,15 +1332,15 @@ class WebGLRenderer {
|
|
|
1252
1332
|
|
|
1253
1333
|
function renderTransmissionPass( opaqueObjects, transmissiveObjects, scene, camera ) {
|
|
1254
1334
|
|
|
1255
|
-
|
|
1335
|
+
const isWebGL2 = capabilities.isWebGL2;
|
|
1256
1336
|
|
|
1257
|
-
|
|
1337
|
+
if ( _transmissionRenderTarget === null ) {
|
|
1258
1338
|
|
|
1259
|
-
_transmissionRenderTarget = new WebGLRenderTarget(
|
|
1339
|
+
_transmissionRenderTarget = new WebGLRenderTarget( 1, 1, {
|
|
1260
1340
|
generateMipmaps: true,
|
|
1261
1341
|
type: extensions.has( 'EXT_color_buffer_half_float' ) ? HalfFloatType : UnsignedByteType,
|
|
1262
1342
|
minFilter: LinearMipmapLinearFilter,
|
|
1263
|
-
samples: ( isWebGL2
|
|
1343
|
+
samples: ( isWebGL2 ) ? 4 : 0
|
|
1264
1344
|
} );
|
|
1265
1345
|
|
|
1266
1346
|
// debug
|
|
@@ -1275,10 +1355,27 @@ class WebGLRenderer {
|
|
|
1275
1355
|
|
|
1276
1356
|
}
|
|
1277
1357
|
|
|
1358
|
+
_this.getDrawingBufferSize( _vector2 );
|
|
1359
|
+
|
|
1360
|
+
if ( isWebGL2 ) {
|
|
1361
|
+
|
|
1362
|
+
_transmissionRenderTarget.setSize( _vector2.x, _vector2.y );
|
|
1363
|
+
|
|
1364
|
+
} else {
|
|
1365
|
+
|
|
1366
|
+
_transmissionRenderTarget.setSize( floorPowerOfTwo( _vector2.x ), floorPowerOfTwo( _vector2.y ) );
|
|
1367
|
+
|
|
1368
|
+
}
|
|
1369
|
+
|
|
1278
1370
|
//
|
|
1279
1371
|
|
|
1280
1372
|
const currentRenderTarget = _this.getRenderTarget();
|
|
1281
1373
|
_this.setRenderTarget( _transmissionRenderTarget );
|
|
1374
|
+
|
|
1375
|
+
_this.getClearColor( _currentClearColor );
|
|
1376
|
+
_currentClearAlpha = _this.getClearAlpha();
|
|
1377
|
+
if ( _currentClearAlpha < 1 ) _this.setClearColor( 0xffffff, 0.5 );
|
|
1378
|
+
|
|
1282
1379
|
_this.clear();
|
|
1283
1380
|
|
|
1284
1381
|
// Turn off the features which can affect the frag color for opaque objects pass.
|
|
@@ -1329,6 +1426,8 @@ class WebGLRenderer {
|
|
|
1329
1426
|
|
|
1330
1427
|
_this.setRenderTarget( currentRenderTarget );
|
|
1331
1428
|
|
|
1429
|
+
_this.setClearColor( _currentClearColor, _currentClearAlpha );
|
|
1430
|
+
|
|
1332
1431
|
_this.toneMapping = currentToneMapping;
|
|
1333
1432
|
|
|
1334
1433
|
}
|
|
@@ -1532,7 +1631,7 @@ class WebGLRenderer {
|
|
|
1532
1631
|
const colorSpace = ( _currentRenderTarget === null ) ? _this.outputColorSpace : ( _currentRenderTarget.isXRRenderTarget === true ? _currentRenderTarget.texture.colorSpace : LinearSRGBColorSpace );
|
|
1533
1632
|
const envMap = ( material.isMeshStandardMaterial ? cubeuvmaps : cubemaps ).get( material.envMap || environment );
|
|
1534
1633
|
const vertexAlphas = material.vertexColors === true && !! geometry.attributes.color && geometry.attributes.color.itemSize === 4;
|
|
1535
|
-
const vertexTangents = !!
|
|
1634
|
+
const vertexTangents = !! geometry.attributes.tangent && ( !! material.normalMap || material.anisotropy > 0 );
|
|
1536
1635
|
const morphTargets = !! geometry.morphAttributes.position;
|
|
1537
1636
|
const morphNormals = !! geometry.morphAttributes.normal;
|
|
1538
1637
|
const morphColors = !! geometry.morphAttributes.color;
|
|
@@ -2332,6 +2431,12 @@ class WebGLRenderer {
|
|
|
2332
2431
|
|
|
2333
2432
|
}
|
|
2334
2433
|
|
|
2434
|
+
get coordinateSystem() {
|
|
2435
|
+
|
|
2436
|
+
return WebGLCoordinateSystem;
|
|
2437
|
+
|
|
2438
|
+
}
|
|
2439
|
+
|
|
2335
2440
|
get physicallyCorrectLights() { // @deprecated, r150
|
|
2336
2441
|
|
|
2337
2442
|
console.warn( 'THREE.WebGLRenderer: the property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead.' );
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
export default /* glsl */`
|
|
2
|
+
#ifdef USE_ALPHAHASH
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* See: https://casual-effects.com/research/Wyman2017Hashed/index.html
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const float ALPHA_HASH_SCALE = 0.05; // Derived from trials only, and may be changed.
|
|
9
|
+
|
|
10
|
+
float hash2D( vec2 value ) {
|
|
11
|
+
|
|
12
|
+
return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
|
|
13
|
+
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
float hash3D( vec3 value ) {
|
|
17
|
+
|
|
18
|
+
return hash2D( vec2( hash2D( value.xy ), value.z ) );
|
|
19
|
+
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
float getAlphaHashThreshold( vec3 position ) {
|
|
23
|
+
|
|
24
|
+
// Find the discretized derivatives of our coordinates
|
|
25
|
+
float maxDeriv = max(
|
|
26
|
+
length( dFdx( position.xyz ) ),
|
|
27
|
+
length( dFdy( position.xyz ) )
|
|
28
|
+
);
|
|
29
|
+
float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );
|
|
30
|
+
|
|
31
|
+
// Find two nearest log-discretized noise scales
|
|
32
|
+
vec2 pixScales = vec2(
|
|
33
|
+
exp2( floor( log2( pixScale ) ) ),
|
|
34
|
+
exp2( ceil( log2( pixScale ) ) )
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
// Compute alpha thresholds at our two noise scales
|
|
38
|
+
vec2 alpha = vec2(
|
|
39
|
+
hash3D( floor( pixScales.x * position.xyz ) ),
|
|
40
|
+
hash3D( floor( pixScales.y * position.xyz ) )
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
// Factor to interpolate lerp with
|
|
44
|
+
float lerpFactor = fract( log2( pixScale ) );
|
|
45
|
+
|
|
46
|
+
// Interpolate alpha threshold from noise at two scales
|
|
47
|
+
float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;
|
|
48
|
+
|
|
49
|
+
// Pass into CDF to compute uniformly distrib threshold
|
|
50
|
+
float a = min( lerpFactor, 1.0 - lerpFactor );
|
|
51
|
+
vec3 cases = vec3(
|
|
52
|
+
x * x / ( 2.0 * a * ( 1.0 - a ) ),
|
|
53
|
+
( x - 0.5 * a ) / ( 1.0 - a ),
|
|
54
|
+
1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
// Find our final, uniformly distributed alpha threshold (ατ)
|
|
58
|
+
float threshold = ( x < ( 1.0 - a ) )
|
|
59
|
+
? ( ( x < a ) ? cases.x : cases.y )
|
|
60
|
+
: cases.z;
|
|
61
|
+
|
|
62
|
+
// Avoids ατ == 0. Could also do ατ =1-ατ
|
|
63
|
+
return clamp( threshold , 1.0e-6, 1.0 );
|
|
64
|
+
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
#endif
|
|
68
|
+
`;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export default /* glsl */`
|
|
2
|
-
#
|
|
2
|
+
#ifdef USE_ENVMAP
|
|
3
3
|
|
|
4
4
|
vec3 getIBLIrradiance( const in vec3 normal ) {
|
|
5
5
|
|
|
6
|
-
#
|
|
6
|
+
#ifdef ENVMAP_TYPE_CUBE_UV
|
|
7
7
|
|
|
8
8
|
vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
|
|
9
9
|
|
|
@@ -21,7 +21,7 @@ export default /* glsl */`
|
|
|
21
21
|
|
|
22
22
|
vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
|
|
23
23
|
|
|
24
|
-
#
|
|
24
|
+
#ifdef ENVMAP_TYPE_CUBE_UV
|
|
25
25
|
|
|
26
26
|
vec3 reflectVec = reflect( - viewDir, normal );
|
|
27
27
|
|
|
@@ -42,5 +42,28 @@ export default /* glsl */`
|
|
|
42
42
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
+
#ifdef USE_ANISOTROPY
|
|
46
|
+
|
|
47
|
+
vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
|
|
48
|
+
|
|
49
|
+
#ifdef ENVMAP_TYPE_CUBE_UV
|
|
50
|
+
|
|
51
|
+
// https://google.github.io/filament/Filament.md.html#lighting/imagebasedlights/anisotropy
|
|
52
|
+
vec3 bentNormal = cross( bitangent, viewDir );
|
|
53
|
+
bentNormal = normalize( cross( bentNormal, bitangent ) );
|
|
54
|
+
bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
|
|
55
|
+
|
|
56
|
+
return getIBLRadiance( viewDir, bentNormal, roughness );
|
|
57
|
+
|
|
58
|
+
#else
|
|
59
|
+
|
|
60
|
+
return vec3( 0.0 );
|
|
61
|
+
|
|
62
|
+
#endif
|
|
63
|
+
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
#endif
|
|
67
|
+
|
|
45
68
|
#endif
|
|
46
69
|
`;
|
|
@@ -20,7 +20,15 @@ export default /* glsl */`
|
|
|
20
20
|
|
|
21
21
|
#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
#ifdef USE_ANISOTROPY
|
|
24
|
+
|
|
25
|
+
radiance += getIBLAnisotropyRadiance( geometry.viewDir, geometry.normal, material.roughness, material.anisotropyB, material.anisotropy );
|
|
26
|
+
|
|
27
|
+
#else
|
|
28
|
+
|
|
29
|
+
radiance += getIBLRadiance( geometry.viewDir, geometry.normal, material.roughness );
|
|
30
|
+
|
|
31
|
+
#endif
|
|
24
32
|
|
|
25
33
|
#ifdef USE_CLEARCOAT
|
|
26
34
|
|
|
@@ -116,5 +116,31 @@ material.roughness = min( material.roughness, 1.0 );
|
|
|
116
116
|
|
|
117
117
|
#endif
|
|
118
118
|
|
|
119
|
+
#endif
|
|
120
|
+
|
|
121
|
+
#ifdef USE_ANISOTROPY
|
|
122
|
+
|
|
123
|
+
#ifdef USE_ANISOTROPYMAP
|
|
124
|
+
|
|
125
|
+
mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
|
|
126
|
+
vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
|
|
127
|
+
vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
|
|
128
|
+
|
|
129
|
+
#else
|
|
130
|
+
|
|
131
|
+
vec2 anisotropyV = anisotropyVector;
|
|
132
|
+
|
|
133
|
+
#endif
|
|
134
|
+
|
|
135
|
+
material.anisotropy = length( anisotropyV );
|
|
136
|
+
anisotropyV /= material.anisotropy;
|
|
137
|
+
material.anisotropy = saturate( material.anisotropy );
|
|
138
|
+
|
|
139
|
+
// Roughness along the anisotropy bitangent is the material roughness, while the tangent roughness increases with anisotropy.
|
|
140
|
+
material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
|
|
141
|
+
|
|
142
|
+
material.anisotropyT = tbn[ 0 ] * anisotropyV.x - tbn[ 1 ] * anisotropyV.y;
|
|
143
|
+
material.anisotropyB = tbn[ 1 ] * anisotropyV.x + tbn[ 0 ] * anisotropyV.y;
|
|
144
|
+
|
|
119
145
|
#endif
|
|
120
146
|
`;
|
|
@@ -39,6 +39,13 @@ struct PhysicalMaterial {
|
|
|
39
39
|
vec3 attenuationColor;
|
|
40
40
|
#endif
|
|
41
41
|
|
|
42
|
+
#ifdef USE_ANISOTROPY
|
|
43
|
+
float anisotropy;
|
|
44
|
+
float alphaT;
|
|
45
|
+
vec3 anisotropyT;
|
|
46
|
+
vec3 anisotropyB;
|
|
47
|
+
#endif
|
|
48
|
+
|
|
42
49
|
};
|
|
43
50
|
|
|
44
51
|
// temporary
|
|
@@ -79,6 +86,32 @@ float D_GGX( const in float alpha, const in float dotNH ) {
|
|
|
79
86
|
|
|
80
87
|
}
|
|
81
88
|
|
|
89
|
+
// https://google.github.io/filament/Filament.md.html#materialsystem/anisotropicmodel/anisotropicspecularbrdf
|
|
90
|
+
#ifdef USE_ANISOTROPY
|
|
91
|
+
|
|
92
|
+
float 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 ) {
|
|
93
|
+
|
|
94
|
+
float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
|
|
95
|
+
float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
|
|
96
|
+
float v = 0.5 / ( gv + gl );
|
|
97
|
+
|
|
98
|
+
return saturate(v);
|
|
99
|
+
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
|
|
103
|
+
|
|
104
|
+
float a2 = alphaT * alphaB;
|
|
105
|
+
highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
|
|
106
|
+
highp float v2 = dot( v, v );
|
|
107
|
+
float w2 = a2 / v2;
|
|
108
|
+
|
|
109
|
+
return RECIPROCAL_PI * a2 * pow2 ( w2 );
|
|
110
|
+
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
#endif
|
|
114
|
+
|
|
82
115
|
#ifdef USE_CLEARCOAT
|
|
83
116
|
|
|
84
117
|
// GGX Distribution, Schlick Fresnel, GGX_SmithCorrelated Visibility
|
|
@@ -132,9 +165,26 @@ vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 norm
|
|
|
132
165
|
|
|
133
166
|
#endif
|
|
134
167
|
|
|
135
|
-
|
|
168
|
+
#ifdef USE_ANISOTROPY
|
|
169
|
+
|
|
170
|
+
float dotTL = dot( material.anisotropyT, lightDir );
|
|
171
|
+
float dotTV = dot( material.anisotropyT, viewDir );
|
|
172
|
+
float dotTH = dot( material.anisotropyT, halfDir );
|
|
173
|
+
float dotBL = dot( material.anisotropyB, lightDir );
|
|
174
|
+
float dotBV = dot( material.anisotropyB, viewDir );
|
|
175
|
+
float dotBH = dot( material.anisotropyB, halfDir );
|
|
176
|
+
|
|
177
|
+
float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
|
|
178
|
+
|
|
179
|
+
float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
|
|
180
|
+
|
|
181
|
+
#else
|
|
182
|
+
|
|
183
|
+
float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
|
|
136
184
|
|
|
137
|
-
|
|
185
|
+
float D = D_GGX( alpha, dotNH );
|
|
186
|
+
|
|
187
|
+
#endif
|
|
138
188
|
|
|
139
189
|
return F * ( V * D );
|
|
140
190
|
|
|
@@ -19,7 +19,7 @@ float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
|
|
|
19
19
|
|
|
20
20
|
#endif
|
|
21
21
|
|
|
22
|
-
#
|
|
22
|
+
#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
|
|
23
23
|
|
|
24
24
|
#ifdef USE_TANGENT
|
|
25
25
|
|
|
@@ -27,7 +27,15 @@ float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
|
|
|
27
27
|
|
|
28
28
|
#else
|
|
29
29
|
|
|
30
|
-
mat3 tbn = getTangentFrame( - vViewPosition, normal,
|
|
30
|
+
mat3 tbn = getTangentFrame( - vViewPosition, normal,
|
|
31
|
+
#if defined( USE_NORMALMAP )
|
|
32
|
+
vNormalMapUv
|
|
33
|
+
#elif defined( USE_CLEARCOAT_NORMALMAP )
|
|
34
|
+
vClearcoatNormalMapUv
|
|
35
|
+
#else
|
|
36
|
+
vUv
|
|
37
|
+
#endif
|
|
38
|
+
);
|
|
31
39
|
|
|
32
40
|
#endif
|
|
33
41
|
|
|
@@ -12,7 +12,7 @@ export default /* glsl */`
|
|
|
12
12
|
|
|
13
13
|
#endif
|
|
14
14
|
|
|
15
|
-
#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) )
|
|
15
|
+
#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
|
|
16
16
|
|
|
17
17
|
// Normal Mapping Without Precomputed Tangents
|
|
18
18
|
// http://www.thetenthplanet.de/archives/1180
|
package/src/renderers/shaders/ShaderChunk/{output_fragment.glsl.js → opaque_fragment.glsl.js}
RENAMED
|
@@ -3,9 +3,8 @@ export default /* glsl */`
|
|
|
3
3
|
diffuseColor.a = 1.0;
|
|
4
4
|
#endif
|
|
5
5
|
|
|
6
|
-
// https://github.com/mrdoob/three.js/pull/22425
|
|
7
6
|
#ifdef USE_TRANSMISSION
|
|
8
|
-
diffuseColor.a *= material.transmissionAlpha
|
|
7
|
+
diffuseColor.a *= material.transmissionAlpha;
|
|
9
8
|
#endif
|
|
10
9
|
|
|
11
10
|
gl_FragColor = vec4( outgoingLight, diffuseColor.a );
|
|
@@ -23,14 +23,14 @@ export default /* glsl */`
|
|
|
23
23
|
vec3 v = normalize( cameraPosition - pos );
|
|
24
24
|
vec3 n = inverseTransformDirection( normal, viewMatrix );
|
|
25
25
|
|
|
26
|
-
vec4
|
|
26
|
+
vec4 transmitted = getIBLVolumeRefraction(
|
|
27
27
|
n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
|
|
28
28
|
pos, modelMatrix, viewMatrix, projectionMatrix, material.ior, material.thickness,
|
|
29
29
|
material.attenuationColor, material.attenuationDistance );
|
|
30
30
|
|
|
31
|
-
material.transmissionAlpha = mix( material.transmissionAlpha,
|
|
31
|
+
material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
|
|
32
32
|
|
|
33
|
-
totalDiffuse = mix( totalDiffuse,
|
|
33
|
+
totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
|
|
34
34
|
|
|
35
35
|
#endif
|
|
36
36
|
`;
|
|
@@ -149,19 +149,19 @@ export default /* glsl */`
|
|
|
149
149
|
|
|
150
150
|
}
|
|
151
151
|
|
|
152
|
-
vec3
|
|
152
|
+
vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
|
|
153
153
|
|
|
154
154
|
if ( isinf( attenuationDistance ) ) {
|
|
155
155
|
|
|
156
156
|
// Attenuation distance is +∞, i.e. the transmitted color is not attenuated at all.
|
|
157
|
-
return
|
|
157
|
+
return vec3( 1.0 );
|
|
158
158
|
|
|
159
159
|
} else {
|
|
160
160
|
|
|
161
161
|
// Compute light attenuation using Beer's law.
|
|
162
162
|
vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
|
|
163
163
|
vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); // Beer's law
|
|
164
|
-
return transmittance
|
|
164
|
+
return transmittance;
|
|
165
165
|
|
|
166
166
|
}
|
|
167
167
|
|
|
@@ -184,12 +184,17 @@ export default /* glsl */`
|
|
|
184
184
|
// Sample framebuffer to get pixel the refracted ray hits.
|
|
185
185
|
vec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
|
|
186
186
|
|
|
187
|
-
vec3
|
|
187
|
+
vec3 transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
|
|
188
|
+
vec3 attenuatedColor = transmittance * transmittedLight.rgb;
|
|
188
189
|
|
|
189
190
|
// Get the specular component.
|
|
190
191
|
vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
|
|
191
192
|
|
|
192
|
-
|
|
193
|
+
// As less light is transmitted, the opacity should be increased. This simple approximation does a decent job
|
|
194
|
+
// of modulating a CSS background, and has no effect when the buffer is opaque, due to a solid object or clear color.
|
|
195
|
+
float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
|
|
196
|
+
|
|
197
|
+
return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
|
|
193
198
|
|
|
194
199
|
}
|
|
195
200
|
#endif
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export default /* glsl */`
|
|
2
|
-
#
|
|
2
|
+
#if defined( USE_UV ) || defined( USE_ANISOTROPY )
|
|
3
3
|
|
|
4
4
|
varying vec2 vUv;
|
|
5
5
|
|
|
@@ -48,6 +48,11 @@ export default /* glsl */`
|
|
|
48
48
|
|
|
49
49
|
varying vec2 vRoughnessMapUv;
|
|
50
50
|
|
|
51
|
+
#endif
|
|
52
|
+
#ifdef USE_ANISOTROPYMAP
|
|
53
|
+
|
|
54
|
+
varying vec2 vAnisotropyMapUv;
|
|
55
|
+
|
|
51
56
|
#endif
|
|
52
57
|
#ifdef USE_CLEARCOATMAP
|
|
53
58
|
|