super-three 0.152.0 → 0.154.1
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 +778 -557
- package/build/three.js +778 -557
- package/build/three.min.js +1 -1
- package/build/three.module.js +769 -539
- package/build/three.module.min.js +1 -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
|
@@ -3,17 +3,24 @@ import { NodeUpdateType } from '../core/constants.js';
|
|
|
3
3
|
import { addNodeClass } from '../core/Node.js';
|
|
4
4
|
import { addNodeElement, nodeProxy } from '../shadernode/ShaderNode.js';
|
|
5
5
|
import { viewportTopLeft } from './ViewportNode.js';
|
|
6
|
-
import { Vector2 } from 'three';
|
|
6
|
+
import { Vector2, FramebufferTexture, LinearMipmapLinearFilter } from 'three';
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
const _size = new Vector2();
|
|
9
9
|
|
|
10
10
|
class ViewportTextureNode extends TextureNode {
|
|
11
11
|
|
|
12
|
-
constructor(
|
|
12
|
+
constructor( uvNode = viewportTopLeft, levelNode = null, framebufferTexture = null ) {
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
if ( framebufferTexture === null ) {
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
framebufferTexture = new FramebufferTexture();
|
|
17
|
+
framebufferTexture.minFilter = LinearMipmapLinearFilter;
|
|
18
|
+
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
super( framebufferTexture, uvNode, levelNode );
|
|
22
|
+
|
|
23
|
+
this.generateMipmaps = false;
|
|
17
24
|
|
|
18
25
|
this.isOutputTextureNode = true;
|
|
19
26
|
|
|
@@ -21,32 +28,37 @@ class ViewportTextureNode extends TextureNode {
|
|
|
21
28
|
|
|
22
29
|
}
|
|
23
30
|
|
|
24
|
-
|
|
31
|
+
updateBefore( frame ) {
|
|
25
32
|
|
|
26
|
-
|
|
33
|
+
const renderer = frame.renderer;
|
|
34
|
+
renderer.getDrawingBufferSize( _size );
|
|
27
35
|
|
|
28
|
-
|
|
36
|
+
//
|
|
29
37
|
|
|
30
|
-
|
|
38
|
+
const framebufferTexture = this.value;
|
|
31
39
|
|
|
32
|
-
if (
|
|
40
|
+
if ( framebufferTexture.image.width !== _size.width || framebufferTexture.image.height !== _size.height ) {
|
|
33
41
|
|
|
34
|
-
|
|
42
|
+
framebufferTexture.image.width = _size.width;
|
|
43
|
+
framebufferTexture.image.height = _size.height;
|
|
44
|
+
framebufferTexture.needsUpdate = true;
|
|
35
45
|
|
|
36
|
-
|
|
46
|
+
}
|
|
37
47
|
|
|
38
|
-
|
|
48
|
+
//
|
|
39
49
|
|
|
40
|
-
|
|
50
|
+
const currentGenerateMipmaps = framebufferTexture.generateMipmaps;
|
|
51
|
+
framebufferTexture.generateMipmaps = this.generateMipmaps;
|
|
41
52
|
|
|
42
|
-
|
|
53
|
+
renderer.copyFramebufferToTexture( framebufferTexture );
|
|
43
54
|
|
|
44
|
-
|
|
45
|
-
|
|
55
|
+
framebufferTexture.generateMipmaps = currentGenerateMipmaps;
|
|
56
|
+
|
|
57
|
+
}
|
|
46
58
|
|
|
47
|
-
|
|
59
|
+
clone() {
|
|
48
60
|
|
|
49
|
-
|
|
61
|
+
return new this.constructor( this.uvNode, this.levelNode, this.value );
|
|
50
62
|
|
|
51
63
|
}
|
|
52
64
|
|
|
@@ -55,7 +67,9 @@ class ViewportTextureNode extends TextureNode {
|
|
|
55
67
|
export default ViewportTextureNode;
|
|
56
68
|
|
|
57
69
|
export const viewportTexture = nodeProxy( ViewportTextureNode );
|
|
70
|
+
export const viewportMipTexture = nodeProxy( ViewportTextureNode, null, null, { generateMipmaps: true } );
|
|
58
71
|
|
|
59
72
|
addNodeElement( 'viewportTexture', viewportTexture );
|
|
73
|
+
addNodeElement( 'viewportMipTexture', viewportMipTexture );
|
|
60
74
|
|
|
61
75
|
addNodeClass( ViewportTextureNode );
|
|
@@ -2,26 +2,26 @@ import F_Schlick from './F_Schlick.js';
|
|
|
2
2
|
import { shininess, specularColor } from '../../core/PropertyNode.js';
|
|
3
3
|
import { transformedNormalView } from '../../accessors/NormalNode.js';
|
|
4
4
|
import { positionViewDirection } from '../../accessors/PositionNode.js';
|
|
5
|
-
import {
|
|
5
|
+
import { tslFn, float } from '../../shadernode/ShaderNode.js';
|
|
6
6
|
|
|
7
7
|
const G_BlinnPhong_Implicit = () => float( 0.25 );
|
|
8
8
|
|
|
9
|
-
const D_BlinnPhong =
|
|
9
|
+
const D_BlinnPhong = tslFn( ( { dotNH } ) => {
|
|
10
10
|
|
|
11
11
|
return shininess.mul( 0.5 / Math.PI ).add( 1.0 ).mul( dotNH.pow( shininess ) );
|
|
12
12
|
|
|
13
13
|
} );
|
|
14
14
|
|
|
15
|
-
const BRDF_BlinnPhong =
|
|
15
|
+
const BRDF_BlinnPhong = tslFn( ( { lightDirection } ) => {
|
|
16
16
|
|
|
17
17
|
const halfDir = lightDirection.add( positionViewDirection ).normalize();
|
|
18
18
|
|
|
19
19
|
const dotNH = transformedNormalView.dot( halfDir ).clamp();
|
|
20
20
|
const dotVH = positionViewDirection.dot( halfDir ).clamp();
|
|
21
21
|
|
|
22
|
-
const F = F_Schlick
|
|
22
|
+
const F = F_Schlick( { f0: specularColor, f90: 1.0, dotVH } );
|
|
23
23
|
const G = G_BlinnPhong_Implicit();
|
|
24
|
-
const D = D_BlinnPhong
|
|
24
|
+
const D = D_BlinnPhong( { dotNH } );
|
|
25
25
|
|
|
26
26
|
return F.mul( G ).mul( D );
|
|
27
27
|
|
|
@@ -3,25 +3,27 @@ import V_GGX_SmithCorrelated from './V_GGX_SmithCorrelated.js';
|
|
|
3
3
|
import D_GGX from './D_GGX.js';
|
|
4
4
|
import { transformedNormalView } from '../../accessors/NormalNode.js';
|
|
5
5
|
import { positionViewDirection } from '../../accessors/PositionNode.js';
|
|
6
|
-
import {
|
|
6
|
+
import { tslFn } from '../../shadernode/ShaderNode.js';
|
|
7
7
|
|
|
8
8
|
// GGX Distribution, Schlick Fresnel, GGX_SmithCorrelated Visibility
|
|
9
|
-
const BRDF_GGX =
|
|
9
|
+
const BRDF_GGX = tslFn( ( inputs ) => {
|
|
10
10
|
|
|
11
11
|
const { lightDirection, f0, f90, roughness } = inputs;
|
|
12
12
|
|
|
13
|
+
const normalView = inputs.normalView || transformedNormalView;
|
|
14
|
+
|
|
13
15
|
const alpha = roughness.pow2(); // UE4's roughness
|
|
14
16
|
|
|
15
17
|
const halfDir = lightDirection.add( positionViewDirection ).normalize();
|
|
16
18
|
|
|
17
|
-
const dotNL =
|
|
18
|
-
const dotNV =
|
|
19
|
-
const dotNH =
|
|
19
|
+
const dotNL = normalView.dot( lightDirection ).clamp();
|
|
20
|
+
const dotNV = normalView.dot( positionViewDirection ).clamp(); // @ TODO: Move to core dotNV
|
|
21
|
+
const dotNH = normalView.dot( halfDir ).clamp();
|
|
20
22
|
const dotVH = positionViewDirection.dot( halfDir ).clamp();
|
|
21
23
|
|
|
22
|
-
const F = F_Schlick
|
|
23
|
-
const V = V_GGX_SmithCorrelated
|
|
24
|
-
const D = D_GGX
|
|
24
|
+
const F = F_Schlick( { f0, f90, dotVH } );
|
|
25
|
+
const V = V_GGX_SmithCorrelated( { alpha, dotNL, dotNV } );
|
|
26
|
+
const D = D_GGX( { alpha, dotNH } );
|
|
25
27
|
|
|
26
28
|
return F.mul( V ).mul( D );
|
|
27
29
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { tslFn } from '../../shadernode/ShaderNode.js';
|
|
2
2
|
|
|
3
|
-
const BRDF_Lambert =
|
|
3
|
+
const BRDF_Lambert = tslFn( ( inputs ) => {
|
|
4
4
|
|
|
5
5
|
return inputs.diffuseColor.mul( 1 / Math.PI ); // punctual light
|
|
6
6
|
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { transformedNormalView } from '../../accessors/NormalNode.js';
|
|
2
|
+
import { positionViewDirection } from '../../accessors/PositionNode.js';
|
|
3
|
+
import { sheen, sheenRoughness } from '../../core/PropertyNode.js';
|
|
4
|
+
import { tslFn, float } from '../../shadernode/ShaderNode.js';
|
|
5
|
+
|
|
6
|
+
// https://github.com/google/filament/blob/master/shaders/src/brdf.fs
|
|
7
|
+
const D_Charlie = ( roughness, dotNH ) => {
|
|
8
|
+
|
|
9
|
+
const alpha = roughness.pow2();
|
|
10
|
+
|
|
11
|
+
// Estevez and Kulla 2017, "Production Friendly Microfacet Sheen BRDF"
|
|
12
|
+
const invAlpha = float( 1.0 ).div( alpha );
|
|
13
|
+
const cos2h = dotNH.pow2();
|
|
14
|
+
const sin2h = cos2h.oneMinus().max( 0.0078125 ); // 2^(-14/2), so sin2h^2 > 0 in fp16
|
|
15
|
+
|
|
16
|
+
return float( 2.0 ).add( invAlpha ).mul( sin2h.pow( invAlpha.mul( 0.5 ) ) ).div( 2.0 * Math.PI );
|
|
17
|
+
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
// https://github.com/google/filament/blob/master/shaders/src/brdf.fs
|
|
21
|
+
const V_Neubelt = ( dotNV, dotNL ) => {
|
|
22
|
+
|
|
23
|
+
// Neubelt and Pettineo 2013, "Crafting a Next-gen Material Pipeline for The Order: 1886"
|
|
24
|
+
return float( 1.0 ).div( float( 4.0 ).mul( dotNL.add( dotNV ).sub( dotNL.mul( dotNV ) ) ) );
|
|
25
|
+
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const BRDF_Sheen = tslFn( ( { lightDirection } ) => {
|
|
29
|
+
|
|
30
|
+
const halfDir = lightDirection.add( positionViewDirection ).normalize();
|
|
31
|
+
|
|
32
|
+
const dotNL = transformedNormalView.dot( lightDirection ).clamp();
|
|
33
|
+
const dotNV = transformedNormalView.dot( positionViewDirection ).clamp();
|
|
34
|
+
const dotNH = transformedNormalView.dot( halfDir ).clamp();
|
|
35
|
+
|
|
36
|
+
const D = D_Charlie( sheenRoughness, dotNH );
|
|
37
|
+
const V = V_Neubelt( dotNV, dotNL );
|
|
38
|
+
|
|
39
|
+
return sheen.mul( D ).mul( V );
|
|
40
|
+
|
|
41
|
+
} );
|
|
42
|
+
|
|
43
|
+
export default BRDF_Sheen;
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import { transformedNormalView } from '../../accessors/NormalNode.js';
|
|
2
2
|
import { positionViewDirection } from '../../accessors/PositionNode.js';
|
|
3
|
-
import {
|
|
3
|
+
import { tslFn, vec2, vec4 } from '../../shadernode/ShaderNode.js';
|
|
4
4
|
|
|
5
5
|
// Analytical approximation of the DFG LUT, one half of the
|
|
6
6
|
// split-sum approximation used in indirect specular lighting.
|
|
7
7
|
// via 'environmentBRDF' from "Physically Based Shading on Mobile"
|
|
8
8
|
// https://www.unrealengine.com/blog/physically-based-shading-on-mobile
|
|
9
|
-
const DFGApprox =
|
|
9
|
+
const DFGApprox = tslFn( ( inputs ) => {
|
|
10
10
|
|
|
11
11
|
const { roughness } = inputs;
|
|
12
12
|
|
|
13
|
+
const dotNV = inputs.dotNV || transformedNormalView.dot( positionViewDirection ).clamp(); // @ TODO: Move to core dotNV
|
|
14
|
+
|
|
13
15
|
const c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );
|
|
14
16
|
|
|
15
17
|
const c1 = vec4( 1, 0.0425, 1.04, - 0.04 );
|
|
16
18
|
|
|
17
19
|
const r = roughness.mul( c0 ).add( c1 );
|
|
18
20
|
|
|
19
|
-
const dotNV = transformedNormalView.dot( positionViewDirection ).clamp();
|
|
20
|
-
|
|
21
21
|
const a004 = r.x.mul( r.x ).min( dotNV.mul( - 9.28 ).exp2() ).mul( r.x ).add( r.y );
|
|
22
22
|
|
|
23
23
|
const fab = vec2( - 1.04, 1.04 ).mul( a004 ).add( r.zw );
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { tslFn } from '../../shadernode/ShaderNode.js';
|
|
2
2
|
|
|
3
3
|
// Microfacet Models for Refraction through Rough Surfaces - equation (33)
|
|
4
4
|
// http://graphicrants.blogspot.com/2013/08/specular-brdf-reference.html
|
|
5
5
|
// alpha is "roughness squared" in Disney’s reparameterization
|
|
6
|
-
const D_GGX =
|
|
6
|
+
const D_GGX = tslFn( ( inputs ) => {
|
|
7
7
|
|
|
8
8
|
const { alpha, dotNH } = inputs;
|
|
9
9
|
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import DFGApprox from './DFGApprox.js';
|
|
2
|
+
import { tslFn } from '../../shadernode/ShaderNode.js';
|
|
3
|
+
|
|
4
|
+
const EnvironmentBRDF = tslFn( ( inputs ) => {
|
|
5
|
+
|
|
6
|
+
const { dotNV, specularColor, specularF90, roughness } = inputs;
|
|
7
|
+
|
|
8
|
+
const fab = DFGApprox( { dotNV, roughness } );
|
|
9
|
+
return specularColor.mul( fab.x ).add( specularF90.mul( fab.y ) );
|
|
10
|
+
|
|
11
|
+
} );
|
|
12
|
+
|
|
13
|
+
export default EnvironmentBRDF;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { tslFn } from '../../shadernode/ShaderNode.js';
|
|
2
2
|
|
|
3
|
-
const F_Schlick =
|
|
4
|
-
|
|
5
|
-
const { f0, f90, dotVH } = inputs;
|
|
3
|
+
const F_Schlick = tslFn( ( { f0, f90, dotVH } ) => {
|
|
6
4
|
|
|
7
5
|
// Original approximation by Christophe Schlick '94
|
|
8
6
|
// float fresnel = pow( 1.0 - dotVH, 5.0 );
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { div } from '../../math/OperatorNode.js';
|
|
2
2
|
import { EPSILON } from '../../math/MathNode.js';
|
|
3
|
-
import {
|
|
3
|
+
import { tslFn } from '../../shadernode/ShaderNode.js';
|
|
4
4
|
|
|
5
5
|
// Moving Frostbite to Physically Based Rendering 3.0 - page 12, listing 2
|
|
6
6
|
// https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf
|
|
7
|
-
const V_GGX_SmithCorrelated =
|
|
7
|
+
const V_GGX_SmithCorrelated = tslFn( ( inputs ) => {
|
|
8
8
|
|
|
9
9
|
const { alpha, dotNL, dotNV } = inputs;
|
|
10
10
|
|
|
@@ -4,25 +4,25 @@ import { lightingModel } from '../core/LightingModel.js';
|
|
|
4
4
|
import { diffuseColor } from '../core/PropertyNode.js';
|
|
5
5
|
import { materialReflectivity } from '../accessors/MaterialNode.js';
|
|
6
6
|
import { transformedNormalView } from '../accessors/NormalNode.js';
|
|
7
|
-
import {
|
|
7
|
+
import { tslFn } from '../shadernode/ShaderNode.js';
|
|
8
8
|
|
|
9
|
-
const RE_Direct_BlinnPhong =
|
|
9
|
+
const RE_Direct_BlinnPhong = tslFn( ( { lightDirection, lightColor, reflectedLight } ) => {
|
|
10
10
|
|
|
11
11
|
const dotNL = transformedNormalView.dot( lightDirection ).clamp();
|
|
12
12
|
const irradiance = dotNL.mul( lightColor );
|
|
13
13
|
|
|
14
|
-
reflectedLight.directDiffuse.addAssign( irradiance.mul( BRDF_Lambert
|
|
14
|
+
reflectedLight.directDiffuse.addAssign( irradiance.mul( BRDF_Lambert( { diffuseColor: diffuseColor.rgb } ) ) );
|
|
15
15
|
|
|
16
|
-
reflectedLight.directSpecular.addAssign( irradiance.mul( BRDF_BlinnPhong
|
|
16
|
+
reflectedLight.directSpecular.addAssign( irradiance.mul( BRDF_BlinnPhong( { lightDirection } ) ).mul( materialReflectivity ) );
|
|
17
17
|
|
|
18
18
|
} );
|
|
19
19
|
|
|
20
|
-
const RE_IndirectDiffuse_BlinnPhong =
|
|
20
|
+
const RE_IndirectDiffuse_BlinnPhong = tslFn( ( { irradiance, reflectedLight } ) => {
|
|
21
21
|
|
|
22
|
-
reflectedLight.indirectDiffuse.addAssign( irradiance.mul( BRDF_Lambert
|
|
22
|
+
reflectedLight.indirectDiffuse.addAssign( irradiance.mul( BRDF_Lambert( { diffuseColor } ) ) );
|
|
23
23
|
|
|
24
24
|
} );
|
|
25
25
|
|
|
26
|
-
const phongLightingModel = lightingModel( RE_Direct_BlinnPhong, RE_IndirectDiffuse_BlinnPhong );
|
|
26
|
+
const phongLightingModel = lightingModel( null, RE_Direct_BlinnPhong, RE_IndirectDiffuse_BlinnPhong );
|
|
27
27
|
|
|
28
28
|
export default phongLightingModel;
|
|
@@ -1,19 +1,52 @@
|
|
|
1
1
|
import BRDF_Lambert from './BSDF/BRDF_Lambert.js';
|
|
2
2
|
import BRDF_GGX from './BSDF/BRDF_GGX.js';
|
|
3
3
|
import DFGApprox from './BSDF/DFGApprox.js';
|
|
4
|
+
import EnvironmentBRDF from './BSDF/EnvironmentBRDF.js';
|
|
5
|
+
import F_Schlick from './BSDF/F_Schlick.js';
|
|
6
|
+
import BRDF_Sheen from './BSDF/BRDF_Sheen.js';
|
|
4
7
|
import { lightingModel } from '../core/LightingModel.js';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { transformedNormalView } from '../accessors/NormalNode.js';
|
|
8
|
+
import { diffuseColor, specularColor, roughness, clearcoat, clearcoatRoughness, sheen, sheenRoughness } from '../core/PropertyNode.js';
|
|
9
|
+
import { transformedNormalView, transformedClearcoatNormalView } from '../accessors/NormalNode.js';
|
|
8
10
|
import { positionViewDirection } from '../accessors/PositionNode.js';
|
|
9
|
-
import {
|
|
11
|
+
import { tslFn, float, vec3 } from '../shadernode/ShaderNode.js';
|
|
12
|
+
import { cond } from '../math/CondNode.js';
|
|
13
|
+
|
|
14
|
+
const clearcoatF0 = vec3( 0.04 );
|
|
15
|
+
const clearcoatF90 = vec3( 1 );
|
|
16
|
+
|
|
17
|
+
// This is a curve-fit approxmation to the "Charlie sheen" BRDF integrated over the hemisphere from
|
|
18
|
+
// Estevez and Kulla 2017, "Production Friendly Microfacet Sheen BRDF". The analysis can be found
|
|
19
|
+
// in the Sheen section of https://drive.google.com/file/d/1T0D1VSyR4AllqIJTQAraEIzjlb5h4FKH/view?usp=sharing
|
|
20
|
+
const IBLSheenBRDF = ( normal, viewDir, roughness ) => {
|
|
21
|
+
|
|
22
|
+
const dotNV = normal.dot( viewDir ).saturate();
|
|
23
|
+
|
|
24
|
+
const r2 = roughness.pow2();
|
|
25
|
+
|
|
26
|
+
const a = cond(
|
|
27
|
+
roughness.lessThan( 0.25 ),
|
|
28
|
+
float( - 339.2 ).mul( r2 ).add( float( 161.4 ).mul( roughness ) ).sub( 25.9 ),
|
|
29
|
+
float( - 8.48 ).mul( r2 ).add( float( 14.3 ).mul( roughness ) ).sub( 9.95 )
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
const b = cond(
|
|
33
|
+
roughness.lessThan( 0.25 ),
|
|
34
|
+
float( 44.0 ).mul( r2 ).sub( float( 23.7 ).mul( roughness ) ).add( 3.26 ),
|
|
35
|
+
float( 1.97 ).mul( r2 ).sub( float( 3.27 ).mul( roughness ) ).add( 0.72 )
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
const DG = cond( roughness.lessThan( 0.25 ), 0.0, float( 0.1 ).mul( roughness ).sub( 0.025 ) ).add( a.mul( dotNV ).add( b ).exp() );
|
|
39
|
+
|
|
40
|
+
return DG.mul( 1.0 / Math.PI ).saturate();
|
|
41
|
+
|
|
42
|
+
};
|
|
10
43
|
|
|
11
44
|
// Fdez-Agüera's "Multiple-Scattering Microfacet Model for Real-Time Image Based Lighting"
|
|
12
45
|
// Approximates multiscattering in order to preserve energy.
|
|
13
46
|
// http://www.jcgt.org/published/0008/01/03/
|
|
14
47
|
const computeMultiscattering = ( singleScatter, multiScatter, specularF90 = float( 1 ) ) => {
|
|
15
48
|
|
|
16
|
-
const fab = DFGApprox
|
|
49
|
+
const fab = DFGApprox( { roughness } );
|
|
17
50
|
|
|
18
51
|
const FssEss = specularColor.mul( fab.x ).add( specularF90.mul( fab.y ) );
|
|
19
52
|
|
|
@@ -28,19 +61,82 @@ const computeMultiscattering = ( singleScatter, multiScatter, specularF90 = floa
|
|
|
28
61
|
|
|
29
62
|
};
|
|
30
63
|
|
|
31
|
-
const
|
|
64
|
+
const LM_Init = tslFn( ( context, stack, builder ) => {
|
|
65
|
+
|
|
66
|
+
if ( builder.includes( clearcoat ) ) {
|
|
67
|
+
|
|
68
|
+
context.clearcoatRadiance = vec3().temp();
|
|
69
|
+
context.reflectedLight.clearcoatSpecular = vec3().temp();
|
|
70
|
+
|
|
71
|
+
const dotNVcc = transformedClearcoatNormalView.dot( positionViewDirection ).clamp();
|
|
72
|
+
|
|
73
|
+
const Fcc = F_Schlick( {
|
|
74
|
+
dotVH: dotNVcc,
|
|
75
|
+
f0: clearcoatF0,
|
|
76
|
+
f90: clearcoatF90
|
|
77
|
+
} );
|
|
78
|
+
|
|
79
|
+
const outgoingLight = context.reflectedLight.total;
|
|
80
|
+
const clearcoatLight = outgoingLight.mul( clearcoat.mul( Fcc ).oneMinus() ).add( context.reflectedLight.clearcoatSpecular.mul( clearcoat ) );
|
|
81
|
+
|
|
82
|
+
outgoingLight.assign( clearcoatLight );
|
|
83
|
+
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if ( builder.includes( sheen ) ) {
|
|
87
|
+
|
|
88
|
+
context.reflectedLight.sheenSpecular = vec3().temp();
|
|
89
|
+
|
|
90
|
+
const outgoingLight = context.reflectedLight.total;
|
|
91
|
+
|
|
92
|
+
const sheenEnergyComp = sheen.r.max( sheen.g ).max( sheen.b ).mul( 0.157 ).oneMinus();
|
|
93
|
+
const sheenLight = outgoingLight.mul( sheenEnergyComp ).add( context.reflectedLight.sheenSpecular );
|
|
94
|
+
|
|
95
|
+
outgoingLight.assign( sheenLight );
|
|
32
96
|
|
|
33
|
-
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
} );
|
|
100
|
+
|
|
101
|
+
const RE_IndirectSpecular_Physical = tslFn( ( context ) => {
|
|
102
|
+
|
|
103
|
+
const { radiance, iblIrradiance, reflectedLight } = context;
|
|
104
|
+
|
|
105
|
+
if ( reflectedLight.sheenSpecular ) {
|
|
106
|
+
|
|
107
|
+
reflectedLight.sheenSpecular.addAssign( iblIrradiance.mul(
|
|
108
|
+
sheen,
|
|
109
|
+
IBLSheenBRDF( transformedNormalView, positionViewDirection, sheenRoughness )
|
|
110
|
+
) );
|
|
111
|
+
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if ( reflectedLight.clearcoatSpecular ) {
|
|
115
|
+
|
|
116
|
+
const dotNVcc = transformedClearcoatNormalView.dot( positionViewDirection ).clamp();
|
|
117
|
+
|
|
118
|
+
const clearcoatEnv = EnvironmentBRDF( {
|
|
119
|
+
dotNV: dotNVcc,
|
|
120
|
+
specularColor: clearcoatF0,
|
|
121
|
+
specularF90: clearcoatF90,
|
|
122
|
+
roughness: clearcoatRoughness
|
|
123
|
+
} );
|
|
124
|
+
|
|
125
|
+
reflectedLight.clearcoatSpecular.addAssign( context.clearcoatRadiance.mul( clearcoatEnv ) );
|
|
126
|
+
|
|
127
|
+
}
|
|
34
128
|
|
|
35
129
|
// Both indirect specular and indirect diffuse light accumulate here
|
|
36
130
|
|
|
37
|
-
const singleScattering =
|
|
38
|
-
const multiScattering =
|
|
131
|
+
const singleScattering = vec3().temp();
|
|
132
|
+
const multiScattering = vec3().temp();
|
|
39
133
|
const cosineWeightedIrradiance = iblIrradiance.mul( 1 / Math.PI );
|
|
40
134
|
|
|
41
135
|
computeMultiscattering( singleScattering, multiScattering );
|
|
42
136
|
|
|
43
|
-
const
|
|
137
|
+
const totalScattering = singleScattering.add( multiScattering );
|
|
138
|
+
|
|
139
|
+
const diffuse = diffuseColor.mul( totalScattering.r.max( totalScattering.g ).max( totalScattering.b ).oneMinus() );
|
|
44
140
|
|
|
45
141
|
reflectedLight.indirectSpecular.addAssign( radiance.mul( singleScattering ) );
|
|
46
142
|
reflectedLight.indirectSpecular.addAssign( multiScattering.mul( cosineWeightedIrradiance ) );
|
|
@@ -49,30 +145,47 @@ const RE_IndirectSpecular_Physical = new ShaderNode( ( inputs ) => {
|
|
|
49
145
|
|
|
50
146
|
} );
|
|
51
147
|
|
|
52
|
-
const RE_IndirectDiffuse_Physical =
|
|
148
|
+
const RE_IndirectDiffuse_Physical = tslFn( ( context ) => {
|
|
53
149
|
|
|
54
|
-
const { irradiance, reflectedLight } =
|
|
150
|
+
const { irradiance, reflectedLight } = context;
|
|
55
151
|
|
|
56
|
-
reflectedLight.indirectDiffuse.addAssign( irradiance.mul( BRDF_Lambert
|
|
152
|
+
reflectedLight.indirectDiffuse.addAssign( irradiance.mul( BRDF_Lambert( { diffuseColor } ) ) );
|
|
57
153
|
|
|
58
154
|
} );
|
|
59
155
|
|
|
60
|
-
const RE_Direct_Physical =
|
|
156
|
+
const RE_Direct_Physical = tslFn( ( inputs ) => {
|
|
61
157
|
|
|
62
158
|
const { lightDirection, lightColor, reflectedLight } = inputs;
|
|
63
159
|
|
|
64
160
|
const dotNL = transformedNormalView.dot( lightDirection ).clamp();
|
|
65
161
|
const irradiance = dotNL.mul( lightColor );
|
|
66
162
|
|
|
67
|
-
|
|
163
|
+
if ( reflectedLight.sheenSpecular ) {
|
|
164
|
+
|
|
165
|
+
reflectedLight.sheenSpecular.addAssign( irradiance.mul( BRDF_Sheen( { lightDirection } ) ) );
|
|
166
|
+
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
if ( reflectedLight.clearcoatSpecular ) {
|
|
68
170
|
|
|
69
|
-
|
|
171
|
+
const dotNLcc = transformedClearcoatNormalView.dot( lightDirection ).clamp();
|
|
172
|
+
const ccIrradiance = dotNLcc.mul( lightColor );
|
|
173
|
+
|
|
174
|
+
reflectedLight.clearcoatSpecular.addAssign( ccIrradiance.mul( BRDF_GGX( { lightDirection, f0: clearcoatF0, f90: clearcoatF90, roughness: clearcoatRoughness, normalView: transformedClearcoatNormalView } ) ) );
|
|
175
|
+
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
reflectedLight.directDiffuse.addAssign( irradiance.mul( BRDF_Lambert( { diffuseColor: diffuseColor.rgb } ) ) );
|
|
179
|
+
|
|
180
|
+
reflectedLight.directSpecular.addAssign( irradiance.mul( BRDF_GGX( { lightDirection, f0: specularColor, f90: 1, roughness } ) ) );
|
|
70
181
|
|
|
71
182
|
} );
|
|
72
183
|
|
|
73
|
-
const RE_AmbientOcclusion_Physical =
|
|
184
|
+
const RE_AmbientOcclusion_Physical = tslFn( ( context ) => {
|
|
185
|
+
|
|
186
|
+
const { ambientOcclusion, reflectedLight } = context;
|
|
74
187
|
|
|
75
|
-
const dotNV = transformedNormalView.dot( positionViewDirection ).clamp();
|
|
188
|
+
const dotNV = transformedNormalView.dot( positionViewDirection ).clamp(); // @ TODO: Move to core dotNV
|
|
76
189
|
|
|
77
190
|
const aoNV = dotNV.add( ambientOcclusion );
|
|
78
191
|
const aoExp = roughness.mul( - 16.0 ).oneMinus().negate().exp2();
|
|
@@ -86,6 +199,6 @@ const RE_AmbientOcclusion_Physical = new ShaderNode( ( { ambientOcclusion, refle
|
|
|
86
199
|
|
|
87
200
|
} );
|
|
88
201
|
|
|
89
|
-
const physicalLightingModel = lightingModel( RE_Direct_Physical, RE_IndirectDiffuse_Physical, RE_IndirectSpecular_Physical, RE_AmbientOcclusion_Physical );
|
|
202
|
+
const physicalLightingModel = lightingModel( LM_Init, RE_Direct_Physical, RE_IndirectDiffuse_Physical, RE_IndirectSpecular_Physical, RE_AmbientOcclusion_Physical );
|
|
90
203
|
|
|
91
204
|
export default physicalLightingModel;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { normalGeometry } from '../../accessors/NormalNode.js';
|
|
2
|
-
import {
|
|
2
|
+
import { tslFn } from '../../shadernode/ShaderNode.js';
|
|
3
3
|
|
|
4
|
-
const getGeometryRoughness =
|
|
4
|
+
const getGeometryRoughness = tslFn( () => {
|
|
5
5
|
|
|
6
6
|
const dxy = normalGeometry.dFdx().abs().max( normalGeometry.dFdy().abs() );
|
|
7
7
|
const geometryRoughness = dxy.x.max( dxy.y ).max( dxy.z );
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import getGeometryRoughness from './getGeometryRoughness.js';
|
|
2
|
-
import {
|
|
2
|
+
import { tslFn } from '../../shadernode/ShaderNode.js';
|
|
3
3
|
|
|
4
|
-
const getRoughness =
|
|
4
|
+
const getRoughness = tslFn( ( inputs ) => {
|
|
5
5
|
|
|
6
6
|
const { roughness } = inputs;
|
|
7
7
|
|
|
8
|
-
const geometryRoughness = getGeometryRoughness
|
|
8
|
+
const geometryRoughness = getGeometryRoughness();
|
|
9
9
|
|
|
10
10
|
let roughnessFactor = roughness.max( 0.0525 ); // 0.0525 corresponds to the base mip of a 256 cubemap.
|
|
11
11
|
roughnessFactor = roughnessFactor.add( geometryRoughness );
|