super-three 0.157.1 → 0.160.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 +6 -4
- package/build/three.cjs +3100 -1537
- package/build/three.js +3100 -1537
- package/build/three.min.js +1 -1
- package/build/three.module.js +3093 -1538
- package/build/three.module.min.js +1 -1
- package/examples/jsm/Addons.js +291 -0
- package/examples/jsm/controls/FlyControls.js +26 -0
- package/examples/jsm/controls/OrbitControls.js +62 -41
- package/examples/jsm/controls/TransformControls.js +27 -11
- package/examples/jsm/csm/CSMShader.js +53 -48
- package/examples/jsm/exporters/GLTFExporter.js +151 -3
- package/examples/jsm/exporters/USDZExporter.js +27 -19
- package/examples/jsm/geometries/InstancedPointsGeometry.js +174 -0
- package/examples/jsm/geometries/SDFGeometryGenerator.js +144 -0
- package/examples/jsm/helpers/TextureHelper.js +237 -0
- package/examples/jsm/interactive/HTMLMesh.js +9 -2
- package/examples/jsm/libs/lottie_canvas.module.js +6 -1
- package/examples/jsm/libs/opentype.module.js +13 -75
- package/examples/jsm/libs/surfaceNet.js +201 -0
- package/examples/jsm/lines/LineMaterial.js +16 -33
- package/examples/jsm/loaders/ColladaLoader.js +0 -6
- package/examples/jsm/loaders/DRACOLoader.js +4 -3
- package/examples/jsm/loaders/FBXLoader.js +294 -124
- package/examples/jsm/loaders/GLTFLoader.js +83 -6
- package/examples/jsm/loaders/LUTImageLoader.js +162 -0
- package/examples/jsm/loaders/MaterialXLoader.js +73 -54
- package/examples/jsm/loaders/NRRDLoader.js +0 -13
- package/examples/jsm/loaders/SVGLoader.js +4 -4
- package/examples/jsm/loaders/USDZLoader.js +3 -17
- package/examples/jsm/loaders/lwo/IFFParser.js +89 -93
- package/examples/jsm/materials/MeshGouraudMaterial.js +2 -0
- package/examples/jsm/math/Capsule.js +0 -55
- package/examples/jsm/math/Octree.js +85 -7
- package/examples/jsm/misc/Timer.js +119 -0
- package/examples/jsm/misc/TubePainter.js +3 -6
- package/examples/jsm/modifiers/CurveModifier.js +20 -2
- package/examples/jsm/modifiers/SimplifyModifier.js +103 -11
- package/examples/jsm/modifiers/TessellateModifier.js +3 -3
- package/examples/jsm/nodes/Nodes.js +16 -12
- package/examples/jsm/nodes/accessors/CameraNode.js +18 -2
- package/examples/jsm/nodes/accessors/CubeTextureNode.js +5 -73
- package/examples/jsm/nodes/accessors/InstanceNode.js +3 -3
- package/examples/jsm/nodes/accessors/InstancedPointsMaterialNode.js +21 -0
- package/examples/jsm/nodes/accessors/MaterialNode.js +68 -31
- package/examples/jsm/nodes/accessors/MaterialReferenceNode.js +11 -2
- package/examples/jsm/nodes/accessors/ModelNode.js +1 -2
- package/examples/jsm/nodes/accessors/ModelViewProjectionNode.js +12 -3
- package/examples/jsm/nodes/accessors/MorphNode.js +191 -16
- package/examples/jsm/nodes/accessors/NormalNode.js +1 -1
- package/examples/jsm/nodes/accessors/PositionNode.js +1 -1
- package/examples/jsm/nodes/accessors/ReferenceNode.js +25 -1
- package/examples/jsm/nodes/accessors/SkinningNode.js +13 -3
- package/examples/jsm/nodes/accessors/TextureNode.js +123 -37
- package/examples/jsm/nodes/code/CodeNode.js +3 -3
- package/examples/jsm/nodes/code/FunctionNode.js +1 -1
- package/examples/jsm/nodes/core/AssignNode.js +72 -0
- package/examples/jsm/nodes/core/AttributeNode.js +7 -1
- package/examples/jsm/nodes/core/CacheNode.js +4 -1
- package/examples/jsm/nodes/core/ConstNode.js +1 -1
- package/examples/jsm/nodes/core/LightingModel.js +3 -1
- package/examples/jsm/nodes/core/Node.js +13 -15
- package/examples/jsm/nodes/core/NodeBuilder.js +209 -42
- package/examples/jsm/nodes/core/NodeFrame.js +10 -8
- package/examples/jsm/nodes/core/NodeUniform.js +12 -0
- package/examples/jsm/nodes/core/NodeUtils.js +7 -9
- package/examples/jsm/nodes/core/OutputStructNode.js +4 -4
- package/examples/jsm/nodes/core/ParameterNode.js +33 -0
- package/examples/jsm/nodes/core/PropertyNode.js +15 -6
- package/examples/jsm/nodes/core/StackNode.js +7 -17
- package/examples/jsm/nodes/core/StructTypeNode.js +4 -4
- package/examples/jsm/nodes/core/TempNode.js +1 -1
- package/examples/jsm/nodes/core/UniformGroup.js +13 -0
- package/examples/jsm/nodes/core/UniformGroupNode.js +36 -0
- package/examples/jsm/nodes/core/UniformNode.js +17 -0
- package/examples/jsm/nodes/core/VarNode.js +7 -34
- package/examples/jsm/nodes/core/VaryingNode.js +3 -7
- package/examples/jsm/nodes/display/BumpMapNode.js +35 -13
- package/examples/jsm/nodes/display/ColorAdjustmentNode.js +6 -10
- package/examples/jsm/nodes/display/GaussianBlurNode.js +170 -0
- package/examples/jsm/nodes/display/NormalMapNode.js +3 -1
- package/examples/jsm/nodes/display/PassNode.js +182 -0
- package/examples/jsm/nodes/display/ViewportDepthNode.js +31 -3
- package/examples/jsm/nodes/display/ViewportDepthTextureNode.js +2 -2
- package/examples/jsm/nodes/display/ViewportNode.js +17 -10
- package/examples/jsm/nodes/functions/BSDF/BRDF_Sheen.js +20 -6
- package/examples/jsm/nodes/functions/BSDF/DFGApprox.js +8 -7
- package/examples/jsm/nodes/functions/BSDF/D_GGX.js +8 -3
- package/examples/jsm/nodes/functions/BSDF/Schlick_to_F0.js +8 -0
- package/examples/jsm/nodes/functions/BSDF/V_GGX_SmithCorrelated.js +8 -0
- package/examples/jsm/nodes/functions/PhysicalLightingModel.js +93 -43
- package/examples/jsm/nodes/gpgpu/ComputeNode.js +2 -2
- package/examples/jsm/nodes/lighting/AmbientLightNode.js +1 -1
- package/examples/jsm/nodes/lighting/AnalyticLightNode.js +55 -6
- package/examples/jsm/nodes/lighting/DirectionalLightNode.js +1 -1
- package/examples/jsm/nodes/lighting/EnvironmentNode.js +8 -18
- package/examples/jsm/nodes/lighting/LightingContextNode.js +21 -57
- package/examples/jsm/nodes/lighting/LightsNode.js +80 -20
- package/examples/jsm/nodes/lighting/PointLightNode.js +1 -1
- package/examples/jsm/nodes/lighting/SpotLightNode.js +1 -1
- package/examples/jsm/nodes/materials/InstancedPointsNodeMaterial.js +162 -0
- package/examples/jsm/nodes/materials/Line2NodeMaterial.js +76 -77
- package/examples/jsm/nodes/materials/LineDashedNodeMaterial.js +5 -5
- package/examples/jsm/nodes/materials/Materials.js +1 -0
- package/examples/jsm/nodes/materials/MeshBasicNodeMaterial.js +1 -0
- package/examples/jsm/nodes/materials/MeshNormalNodeMaterial.js +3 -3
- package/examples/jsm/nodes/materials/MeshPhongNodeMaterial.js +3 -3
- package/examples/jsm/nodes/materials/MeshPhysicalNodeMaterial.js +47 -20
- package/examples/jsm/nodes/materials/MeshStandardNodeMaterial.js +6 -6
- package/examples/jsm/nodes/materials/NodeMaterial.js +82 -60
- package/examples/jsm/nodes/materials/PointsNodeMaterial.js +0 -10
- package/examples/jsm/nodes/materials/SpriteNodeMaterial.js +0 -7
- package/examples/jsm/nodes/materialx/MaterialXNodes.js +10 -10
- package/examples/jsm/nodes/materialx/lib/mx_hsv.js +128 -54
- package/examples/jsm/nodes/materialx/lib/mx_noise.js +1430 -618
- package/examples/jsm/nodes/materialx/lib/mx_transform_color.js +24 -14
- package/examples/jsm/nodes/math/MathNode.js +2 -0
- package/examples/jsm/nodes/math/OperatorNode.js +24 -27
- package/examples/jsm/nodes/shadernode/ShaderNode.js +158 -10
- package/examples/jsm/nodes/utils/ArrayElementNode.js +2 -0
- package/examples/jsm/nodes/utils/DiscardNode.js +3 -2
- package/examples/jsm/nodes/utils/FunctionOverloadingNode.js +95 -0
- package/examples/jsm/nodes/utils/JoinNode.js +11 -1
- package/examples/jsm/nodes/utils/LoopNode.js +36 -24
- package/examples/jsm/nodes/utils/RemapNode.js +2 -2
- package/examples/jsm/nodes/utils/SplitNode.js +10 -2
- package/examples/jsm/nodes/utils/TriplanarTexturesNode.js +3 -3
- package/examples/jsm/objects/InstancedPoints.js +21 -0
- package/examples/jsm/objects/Lensflare.js +20 -0
- package/examples/jsm/objects/QuadMesh.js +60 -0
- package/examples/jsm/objects/ReflectorForSSRPass.js +3 -0
- package/examples/jsm/objects/Refractor.js +3 -0
- package/examples/jsm/objects/Sky.js +5 -3
- package/examples/jsm/objects/Water.js +5 -2
- package/examples/jsm/objects/Water2.js +3 -0
- package/examples/jsm/physics/AmmoPhysics.js +21 -0
- package/examples/jsm/physics/RapierPhysics.js +21 -0
- package/examples/jsm/postprocessing/BokehPass.js +3 -2
- package/examples/jsm/postprocessing/GTAOPass.js +572 -0
- package/examples/jsm/postprocessing/LUTPass.js +2 -1
- package/examples/jsm/postprocessing/OutputPass.js +3 -0
- package/examples/jsm/postprocessing/Pass.js +14 -3
- package/examples/jsm/postprocessing/SAOPass.js +0 -1
- package/examples/jsm/postprocessing/SMAAPass.js +0 -2
- package/examples/jsm/postprocessing/TAARenderPass.js +1 -2
- package/examples/jsm/renderers/CSS3DRenderer.js +3 -9
- package/examples/jsm/renderers/SVGRenderer.js +9 -6
- package/examples/jsm/renderers/common/Animation.js +10 -21
- package/examples/jsm/renderers/common/Backend.js +19 -3
- package/examples/jsm/renderers/common/Background.js +20 -22
- package/examples/jsm/renderers/common/Bindings.js +31 -22
- package/examples/jsm/renderers/common/ChainMap.js +3 -3
- package/examples/jsm/renderers/common/Color4.js +37 -0
- package/examples/jsm/renderers/common/Geometries.js +4 -4
- package/examples/jsm/renderers/common/Info.js +12 -2
- package/examples/jsm/renderers/common/Pipelines.js +3 -51
- package/examples/jsm/renderers/common/PostProcessing.js +25 -0
- package/examples/jsm/renderers/common/RenderContext.js +1 -1
- package/examples/jsm/renderers/common/RenderContexts.js +1 -1
- package/examples/jsm/renderers/common/RenderObject.js +21 -2
- package/examples/jsm/renderers/common/RenderObjects.js +5 -3
- package/examples/jsm/renderers/common/Renderer.js +137 -37
- package/examples/jsm/renderers/common/StorageTexture.js +1 -0
- package/examples/jsm/renderers/common/Textures.js +8 -37
- package/examples/jsm/renderers/common/nodes/NodeBuilderState.js +10 -2
- package/examples/jsm/renderers/common/nodes/NodeUniformsGroup.js +44 -0
- package/examples/jsm/renderers/common/nodes/Nodes.js +121 -19
- package/examples/jsm/renderers/webgl/WebGLBackend.js +366 -67
- package/examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js +183 -38
- package/examples/jsm/renderers/webgl/utils/WebGLAttributeUtils.js +92 -5
- package/examples/jsm/renderers/webgl/utils/WebGLCapabilities.js +36 -0
- package/examples/jsm/renderers/webgl/utils/WebGLExtensions.js +11 -1
- package/examples/jsm/renderers/webgl/utils/WebGLState.js +14 -2
- package/examples/jsm/renderers/webgl/utils/WebGLTextureUtils.js +71 -2
- package/examples/jsm/renderers/webgl/utils/WebGLUtils.js +42 -0
- package/examples/jsm/renderers/webgl-legacy/nodes/SlotNode.js +1 -1
- package/examples/jsm/renderers/webgl-legacy/nodes/WebGLNodeBuilder.js +33 -3
- package/examples/jsm/renderers/webgl-legacy/nodes/WebGLNodes.js +4 -14
- package/examples/jsm/renderers/webgpu/WebGPUBackend.js +188 -137
- package/examples/jsm/renderers/webgpu/WebGPURenderer.js +1 -1
- package/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js +241 -90
- package/examples/jsm/renderers/webgpu/utils/WebGPUAttributeUtils.js +15 -10
- package/examples/jsm/renderers/webgpu/utils/WebGPUBindingUtils.js +11 -3
- package/examples/jsm/renderers/webgpu/utils/WebGPUPipelineUtils.js +2 -3
- package/examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js +88 -6
- package/examples/jsm/shaders/ACESFilmicToneMappingShader.js +2 -0
- package/examples/jsm/shaders/AfterimageShader.js +2 -0
- package/examples/jsm/shaders/BasicShader.js +2 -0
- package/examples/jsm/shaders/BlendShader.js +2 -0
- package/examples/jsm/shaders/BokehShader.js +2 -0
- package/examples/jsm/shaders/BokehShader2.js +4 -0
- package/examples/jsm/shaders/BrightnessContrastShader.js +2 -0
- package/examples/jsm/shaders/ColorCorrectionShader.js +2 -0
- package/examples/jsm/shaders/DOFMipMapShader.js +2 -0
- package/examples/jsm/shaders/DepthLimitedBlurShader.js +5 -0
- package/examples/jsm/shaders/FXAAShader.js +135 -133
- package/examples/jsm/shaders/FilmShader.js +1 -1
- package/examples/jsm/shaders/FocusShader.js +2 -0
- package/examples/jsm/shaders/FreiChenShader.js +2 -0
- package/examples/jsm/shaders/GTAOShader.js +424 -0
- package/examples/jsm/shaders/GodRaysShader.js +8 -0
- package/examples/jsm/shaders/HalftoneShader.js +2 -0
- package/examples/jsm/shaders/HorizontalTiltShiftShader.js +2 -0
- package/examples/jsm/shaders/HueSaturationShader.js +2 -0
- package/examples/jsm/shaders/KaleidoShader.js +2 -0
- package/examples/jsm/shaders/LuminosityHighPassShader.js +2 -0
- package/examples/jsm/shaders/LuminosityShader.js +2 -0
- package/examples/jsm/shaders/MMDToonShader.js +2 -0
- package/examples/jsm/shaders/MirrorShader.js +2 -0
- package/examples/jsm/shaders/NormalMapShader.js +2 -0
- package/examples/jsm/shaders/OutputShader.js +8 -5
- package/examples/jsm/shaders/PoissonDenoiseShader.js +226 -0
- package/examples/jsm/shaders/SAOShader.js +7 -3
- package/examples/jsm/shaders/SMAAShader.js +6 -0
- package/examples/jsm/shaders/SSAOShader.js +8 -3
- package/examples/jsm/shaders/SSRShader.js +6 -0
- package/examples/jsm/shaders/SobelOperatorShader.js +2 -0
- package/examples/jsm/shaders/SubsurfaceScatteringShader.js +2 -0
- package/examples/jsm/shaders/TechnicolorShader.js +2 -0
- package/examples/jsm/shaders/TriangleBlurShader.js +2 -0
- package/examples/jsm/shaders/UnpackDepthRGBAShader.js +2 -0
- package/examples/jsm/shaders/VelocityShader.js +2 -0
- package/examples/jsm/shaders/VerticalTiltShiftShader.js +2 -0
- package/examples/jsm/shaders/WaterRefractionShader.js +2 -0
- package/examples/jsm/transpiler/AST.js +270 -0
- package/examples/jsm/transpiler/GLSLDecoder.js +941 -0
- package/examples/jsm/transpiler/ShaderToyDecoder.js +49 -0
- package/examples/jsm/transpiler/TSLEncoder.js +715 -0
- package/examples/jsm/transpiler/Transpiler.js +18 -0
- package/examples/jsm/utils/SortUtils.js +158 -0
- package/examples/jsm/utils/TextureUtils.js +33 -21
- package/examples/jsm/webxr/ARButton.js +14 -0
- package/examples/jsm/webxr/VRButton.js +24 -9
- package/examples/jsm/webxr/XRButton.js +27 -11
- package/examples/jsm/webxr/XREstimatedLight.js +1 -1
- package/package.json +8 -6
- package/src/Three.js +1 -0
- package/src/constants.js +8 -1
- package/src/core/BufferAttribute.js +21 -2
- package/src/core/InterleavedBuffer.js +21 -1
- package/src/core/Object3D.js +60 -12
- package/src/core/UniformsGroup.js +7 -1
- package/src/extras/PMREMGenerator.js +7 -1
- package/src/extras/curves/LineCurve3.js +4 -0
- package/src/loaders/AudioLoader.js +1 -1
- package/src/loaders/BufferGeometryLoader.js +0 -7
- package/src/loaders/ImageBitmapLoader.js +25 -1
- package/src/loaders/MaterialLoader.js +10 -2
- package/src/loaders/ObjectLoader.js +49 -0
- package/src/materials/Material.js +27 -13
- package/src/materials/ShaderMaterial.js +2 -1
- package/src/math/Box3.js +35 -18
- package/src/math/ColorManagement.js +0 -16
- package/src/math/Quaternion.js +5 -4
- package/src/math/Sphere.js +2 -0
- package/src/math/Triangle.js +17 -5
- package/src/math/Vector3.js +11 -12
- package/src/objects/BatchedMesh.js +1020 -0
- package/src/objects/Skeleton.js +1 -3
- package/src/objects/SkinnedMesh.js +6 -7
- package/src/renderers/WebGL3DRenderTarget.js +2 -2
- package/src/renderers/WebGLArrayRenderTarget.js +2 -2
- package/src/renderers/WebGLRenderer.js +165 -43
- package/src/renderers/shaders/ShaderChunk/aomap_fragment.glsl.js +8 -0
- package/src/renderers/shaders/ShaderChunk/batching_pars_vertex.glsl.js +19 -0
- package/src/renderers/shaders/ShaderChunk/batching_vertex.glsl.js +5 -0
- package/src/renderers/shaders/ShaderChunk/bumpmap_pars_fragment.glsl.js +3 -2
- package/src/renderers/shaders/ShaderChunk/cube_uv_reflection_fragment.glsl.js +0 -5
- package/src/renderers/shaders/ShaderChunk/defaultnormal_vertex.glsl.js +31 -4
- package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +9 -4
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +8 -6
- package/src/renderers/shaders/ShaderChunk/project_vertex.glsl.js +6 -0
- package/src/renderers/shaders/ShaderChunk/skinning_pars_vertex.glsl.js +9 -17
- package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +84 -0
- package/src/renderers/shaders/ShaderChunk/worldpos_vertex.glsl.js +6 -0
- package/src/renderers/shaders/ShaderChunk.js +4 -0
- 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/meshbasic.glsl.js +2 -0
- package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +2 -0
- package/src/renderers/shaders/ShaderLib/meshmatcap.glsl.js +3 -0
- package/src/renderers/shaders/ShaderLib/meshnormal.glsl.js +2 -0
- package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +2 -0
- package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +4 -2
- package/src/renderers/shaders/ShaderLib/meshtoon.glsl.js +2 -0
- package/src/renderers/shaders/ShaderLib/shadow.glsl.js +3 -0
- package/src/renderers/webgl/WebGLAttributes.js +39 -5
- package/src/renderers/webgl/WebGLBufferRenderer.js +31 -0
- package/src/renderers/webgl/WebGLCubeMaps.js +1 -1
- package/src/renderers/webgl/WebGLExtensions.js +1 -0
- package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +31 -0
- package/src/renderers/webgl/WebGLLights.js +11 -2
- package/src/renderers/webgl/WebGLProgram.js +100 -51
- package/src/renderers/webgl/WebGLPrograms.js +8 -0
- package/src/renderers/webgl/WebGLShadowMap.js +35 -0
- package/src/renderers/webgl/WebGLState.js +25 -4
- package/src/renderers/webgl/WebGLTextures.js +7 -11
- package/src/renderers/webgl/WebGLUniforms.js +11 -1
- package/src/renderers/webgl/WebGLUniformsGroups.js +72 -93
- package/src/renderers/webxr/WebXRManager.js +16 -0
- package/examples/jsm/nodes/accessors/ExtendedMaterialNode.js +0 -76
- package/examples/jsm/nodes/accessors/LineMaterialNode.js +0 -29
package/src/objects/Skeleton.js
CHANGED
|
@@ -21,7 +21,6 @@ class Skeleton {
|
|
|
21
21
|
this.boneMatrices = null;
|
|
22
22
|
|
|
23
23
|
this.boneTexture = null;
|
|
24
|
-
this.boneTextureSize = 0;
|
|
25
24
|
|
|
26
25
|
this.init();
|
|
27
26
|
|
|
@@ -169,7 +168,7 @@ class Skeleton {
|
|
|
169
168
|
// 64x64 pixel texture max 1024 bones * 4 pixels = (64 * 64)
|
|
170
169
|
|
|
171
170
|
let size = Math.sqrt( this.bones.length * 4 ); // 4 pixels needed for 1 matrix
|
|
172
|
-
size =
|
|
171
|
+
size = Math.ceil( size / 4 ) * 4;
|
|
173
172
|
size = Math.max( size, 4 );
|
|
174
173
|
|
|
175
174
|
const boneMatrices = new Float32Array( size * size * 4 ); // 4 floats per RGBA pixel
|
|
@@ -180,7 +179,6 @@ class Skeleton {
|
|
|
180
179
|
|
|
181
180
|
this.boneMatrices = boneMatrices;
|
|
182
181
|
this.boneTexture = boneTexture;
|
|
183
|
-
this.boneTextureSize = size;
|
|
184
182
|
|
|
185
183
|
return this;
|
|
186
184
|
|
|
@@ -5,6 +5,7 @@ import { Sphere } from '../math/Sphere.js';
|
|
|
5
5
|
import { Vector3 } from '../math/Vector3.js';
|
|
6
6
|
import { Vector4 } from '../math/Vector4.js';
|
|
7
7
|
import { Ray } from '../math/Ray.js';
|
|
8
|
+
import { AttachedBindMode, DetachedBindMode } from '../constants.js';
|
|
8
9
|
|
|
9
10
|
const _basePosition = /*@__PURE__*/ new Vector3();
|
|
10
11
|
|
|
@@ -29,7 +30,7 @@ class SkinnedMesh extends Mesh {
|
|
|
29
30
|
|
|
30
31
|
this.type = 'SkinnedMesh';
|
|
31
32
|
|
|
32
|
-
this.bindMode =
|
|
33
|
+
this.bindMode = AttachedBindMode;
|
|
33
34
|
this.bindMatrix = new Matrix4();
|
|
34
35
|
this.bindMatrixInverse = new Matrix4();
|
|
35
36
|
|
|
@@ -54,8 +55,7 @@ class SkinnedMesh extends Mesh {
|
|
|
54
55
|
|
|
55
56
|
for ( let i = 0; i < positionAttribute.count; i ++ ) {
|
|
56
57
|
|
|
57
|
-
|
|
58
|
-
this.applyBoneTransform( i, _vertex );
|
|
58
|
+
this.getVertexPosition( i, _vertex );
|
|
59
59
|
this.boundingBox.expandByPoint( _vertex );
|
|
60
60
|
|
|
61
61
|
}
|
|
@@ -78,8 +78,7 @@ class SkinnedMesh extends Mesh {
|
|
|
78
78
|
|
|
79
79
|
for ( let i = 0; i < positionAttribute.count; i ++ ) {
|
|
80
80
|
|
|
81
|
-
|
|
82
|
-
this.applyBoneTransform( i, _vertex );
|
|
81
|
+
this.getVertexPosition( i, _vertex );
|
|
83
82
|
this.boundingSphere.expandByPoint( _vertex );
|
|
84
83
|
|
|
85
84
|
}
|
|
@@ -205,11 +204,11 @@ class SkinnedMesh extends Mesh {
|
|
|
205
204
|
|
|
206
205
|
super.updateMatrixWorld( force );
|
|
207
206
|
|
|
208
|
-
if ( this.bindMode ===
|
|
207
|
+
if ( this.bindMode === AttachedBindMode ) {
|
|
209
208
|
|
|
210
209
|
this.bindMatrixInverse.copy( this.matrixWorld ).invert();
|
|
211
210
|
|
|
212
|
-
} else if ( this.bindMode ===
|
|
211
|
+
} else if ( this.bindMode === DetachedBindMode ) {
|
|
213
212
|
|
|
214
213
|
this.bindMatrixInverse.copy( this.bindMatrix ).invert();
|
|
215
214
|
|
|
@@ -3,9 +3,9 @@ import { Data3DTexture } from '../textures/Data3DTexture.js';
|
|
|
3
3
|
|
|
4
4
|
class WebGL3DRenderTarget extends WebGLRenderTarget {
|
|
5
5
|
|
|
6
|
-
constructor( width = 1, height = 1, depth = 1 ) {
|
|
6
|
+
constructor( width = 1, height = 1, depth = 1, options = {} ) {
|
|
7
7
|
|
|
8
|
-
super( width, height );
|
|
8
|
+
super( width, height, options );
|
|
9
9
|
|
|
10
10
|
this.isWebGL3DRenderTarget = true;
|
|
11
11
|
|
|
@@ -3,9 +3,9 @@ import { DataArrayTexture } from '../textures/DataArrayTexture.js';
|
|
|
3
3
|
|
|
4
4
|
class WebGLArrayRenderTarget extends WebGLRenderTarget {
|
|
5
5
|
|
|
6
|
-
constructor( width = 1, height = 1, depth = 1 ) {
|
|
6
|
+
constructor( width = 1, height = 1, depth = 1, options = {} ) {
|
|
7
7
|
|
|
8
|
-
super( width, height );
|
|
8
|
+
super( width, height, options );
|
|
9
9
|
|
|
10
10
|
this.isWebGLArrayRenderTarget = true;
|
|
11
11
|
|
|
@@ -634,7 +634,12 @@ class WebGLRenderer {
|
|
|
634
634
|
}
|
|
635
635
|
|
|
636
636
|
if ( depth ) bits |= _gl.DEPTH_BUFFER_BIT;
|
|
637
|
-
if ( stencil )
|
|
637
|
+
if ( stencil ) {
|
|
638
|
+
|
|
639
|
+
bits |= _gl.STENCIL_BUFFER_BIT;
|
|
640
|
+
this.state.buffers.stencil.setMask( 0xffffffff );
|
|
641
|
+
|
|
642
|
+
}
|
|
638
643
|
|
|
639
644
|
_gl.clear( bits );
|
|
640
645
|
|
|
@@ -896,7 +901,11 @@ class WebGLRenderer {
|
|
|
896
901
|
|
|
897
902
|
}
|
|
898
903
|
|
|
899
|
-
if ( object.
|
|
904
|
+
if ( object.isBatchedMesh ) {
|
|
905
|
+
|
|
906
|
+
renderer.renderMultiDraw( object._multiDrawStarts, object._multiDrawCounts, object._multiDrawCount );
|
|
907
|
+
|
|
908
|
+
} else if ( object.isInstancedMesh ) {
|
|
900
909
|
|
|
901
910
|
renderer.renderInstances( drawStart, drawCount, object.count );
|
|
902
911
|
|
|
@@ -917,36 +926,40 @@ class WebGLRenderer {
|
|
|
917
926
|
|
|
918
927
|
// Compile
|
|
919
928
|
|
|
920
|
-
|
|
929
|
+
function prepareMaterial( material, scene, object ) {
|
|
921
930
|
|
|
922
|
-
|
|
931
|
+
if ( material.transparent === true && material.side === DoubleSide && material.forceSinglePass === false ) {
|
|
923
932
|
|
|
924
|
-
|
|
933
|
+
material.side = BackSide;
|
|
934
|
+
material.needsUpdate = true;
|
|
935
|
+
getProgram( material, scene, object );
|
|
925
936
|
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
937
|
+
material.side = FrontSide;
|
|
938
|
+
material.needsUpdate = true;
|
|
939
|
+
getProgram( material, scene, object );
|
|
929
940
|
|
|
930
|
-
|
|
931
|
-
material.needsUpdate = true;
|
|
932
|
-
getProgram( material, scene, object );
|
|
941
|
+
material.side = DoubleSide;
|
|
933
942
|
|
|
934
|
-
|
|
943
|
+
} else {
|
|
935
944
|
|
|
936
|
-
|
|
945
|
+
getProgram( material, scene, object );
|
|
937
946
|
|
|
938
|
-
|
|
947
|
+
}
|
|
939
948
|
|
|
940
|
-
|
|
949
|
+
}
|
|
941
950
|
|
|
942
|
-
|
|
951
|
+
this.compile = function ( scene, camera, targetScene = null ) {
|
|
952
|
+
|
|
953
|
+
if ( targetScene === null ) targetScene = scene;
|
|
943
954
|
|
|
944
|
-
currentRenderState = renderStates.get(
|
|
955
|
+
currentRenderState = renderStates.get( targetScene );
|
|
945
956
|
currentRenderState.init();
|
|
946
957
|
|
|
947
958
|
renderStateStack.push( currentRenderState );
|
|
948
959
|
|
|
949
|
-
scene
|
|
960
|
+
// gather lights from both the target scene and the new object that will be added to the scene.
|
|
961
|
+
|
|
962
|
+
targetScene.traverseVisible( function ( object ) {
|
|
950
963
|
|
|
951
964
|
if ( object.isLight && object.layers.test( camera.layers ) ) {
|
|
952
965
|
|
|
@@ -962,8 +975,32 @@ class WebGLRenderer {
|
|
|
962
975
|
|
|
963
976
|
} );
|
|
964
977
|
|
|
978
|
+
if ( scene !== targetScene ) {
|
|
979
|
+
|
|
980
|
+
scene.traverseVisible( function ( object ) {
|
|
981
|
+
|
|
982
|
+
if ( object.isLight && object.layers.test( camera.layers ) ) {
|
|
983
|
+
|
|
984
|
+
currentRenderState.pushLight( object );
|
|
985
|
+
|
|
986
|
+
if ( object.castShadow ) {
|
|
987
|
+
|
|
988
|
+
currentRenderState.pushShadow( object );
|
|
989
|
+
|
|
990
|
+
}
|
|
991
|
+
|
|
992
|
+
}
|
|
993
|
+
|
|
994
|
+
} );
|
|
995
|
+
|
|
996
|
+
}
|
|
997
|
+
|
|
965
998
|
currentRenderState.setupLights( _this._useLegacyLights );
|
|
966
999
|
|
|
1000
|
+
// Only initialize materials in the new scene, not the targetScene.
|
|
1001
|
+
|
|
1002
|
+
const materials = new Set();
|
|
1003
|
+
|
|
967
1004
|
scene.traverse( function ( object ) {
|
|
968
1005
|
|
|
969
1006
|
const material = object.material;
|
|
@@ -976,13 +1013,15 @@ class WebGLRenderer {
|
|
|
976
1013
|
|
|
977
1014
|
const material2 = material[ i ];
|
|
978
1015
|
|
|
979
|
-
|
|
1016
|
+
prepareMaterial( material2, targetScene, object );
|
|
1017
|
+
materials.add( material2 );
|
|
980
1018
|
|
|
981
1019
|
}
|
|
982
1020
|
|
|
983
1021
|
} else {
|
|
984
1022
|
|
|
985
|
-
|
|
1023
|
+
prepareMaterial( material, targetScene, object );
|
|
1024
|
+
materials.add( material );
|
|
986
1025
|
|
|
987
1026
|
}
|
|
988
1027
|
|
|
@@ -993,6 +1032,70 @@ class WebGLRenderer {
|
|
|
993
1032
|
renderStateStack.pop();
|
|
994
1033
|
currentRenderState = null;
|
|
995
1034
|
|
|
1035
|
+
return materials;
|
|
1036
|
+
|
|
1037
|
+
};
|
|
1038
|
+
|
|
1039
|
+
// compileAsync
|
|
1040
|
+
|
|
1041
|
+
this.compileAsync = function ( scene, camera, targetScene = null ) {
|
|
1042
|
+
|
|
1043
|
+
const materials = this.compile( scene, camera, targetScene );
|
|
1044
|
+
|
|
1045
|
+
// Wait for all the materials in the new object to indicate that they're
|
|
1046
|
+
// ready to be used before resolving the promise.
|
|
1047
|
+
|
|
1048
|
+
return new Promise( ( resolve ) => {
|
|
1049
|
+
|
|
1050
|
+
function checkMaterialsReady() {
|
|
1051
|
+
|
|
1052
|
+
materials.forEach( function ( material ) {
|
|
1053
|
+
|
|
1054
|
+
const materialProperties = properties.get( material );
|
|
1055
|
+
const program = materialProperties.currentProgram;
|
|
1056
|
+
|
|
1057
|
+
if ( program.isReady() ) {
|
|
1058
|
+
|
|
1059
|
+
// remove any programs that report they're ready to use from the list
|
|
1060
|
+
materials.delete( material );
|
|
1061
|
+
|
|
1062
|
+
}
|
|
1063
|
+
|
|
1064
|
+
} );
|
|
1065
|
+
|
|
1066
|
+
// once the list of compiling materials is empty, call the callback
|
|
1067
|
+
|
|
1068
|
+
if ( materials.size === 0 ) {
|
|
1069
|
+
|
|
1070
|
+
resolve( scene );
|
|
1071
|
+
return;
|
|
1072
|
+
|
|
1073
|
+
}
|
|
1074
|
+
|
|
1075
|
+
// if some materials are still not ready, wait a bit and check again
|
|
1076
|
+
|
|
1077
|
+
setTimeout( checkMaterialsReady, 10 );
|
|
1078
|
+
|
|
1079
|
+
}
|
|
1080
|
+
|
|
1081
|
+
if ( extensions.get( 'KHR_parallel_shader_compile' ) !== null ) {
|
|
1082
|
+
|
|
1083
|
+
// If we can check the compilation status of the materials without
|
|
1084
|
+
// blocking then do so right away.
|
|
1085
|
+
|
|
1086
|
+
checkMaterialsReady();
|
|
1087
|
+
|
|
1088
|
+
} else {
|
|
1089
|
+
|
|
1090
|
+
// Otherwise start by waiting a bit to give the materials we just
|
|
1091
|
+
// initialized a chance to finish.
|
|
1092
|
+
|
|
1093
|
+
setTimeout( checkMaterialsReady, 10 );
|
|
1094
|
+
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1097
|
+
} );
|
|
1098
|
+
|
|
996
1099
|
};
|
|
997
1100
|
|
|
998
1101
|
// Animation Loop
|
|
@@ -1346,6 +1449,14 @@ class WebGLRenderer {
|
|
|
1346
1449
|
|
|
1347
1450
|
function renderTransmissionPass( opaqueObjects, transmissiveObjects, scene, camera ) {
|
|
1348
1451
|
|
|
1452
|
+
const overrideMaterial = scene.isScene === true ? scene.overrideMaterial : null;
|
|
1453
|
+
|
|
1454
|
+
if ( overrideMaterial !== null ) {
|
|
1455
|
+
|
|
1456
|
+
return;
|
|
1457
|
+
|
|
1458
|
+
}
|
|
1459
|
+
|
|
1349
1460
|
const isWebGL2 = capabilities.isWebGL2;
|
|
1350
1461
|
|
|
1351
1462
|
if ( _transmissionRenderTarget === null ) {
|
|
@@ -1605,21 +1716,32 @@ class WebGLRenderer {
|
|
|
1605
1716
|
|
|
1606
1717
|
}
|
|
1607
1718
|
|
|
1608
|
-
const progUniforms = program.getUniforms();
|
|
1609
|
-
const uniformsList = WebGLUniforms.seqWithValue( progUniforms.seq, uniforms );
|
|
1610
|
-
|
|
1611
1719
|
materialProperties.currentProgram = program;
|
|
1612
|
-
materialProperties.uniformsList =
|
|
1720
|
+
materialProperties.uniformsList = null;
|
|
1613
1721
|
|
|
1614
1722
|
return program;
|
|
1615
1723
|
|
|
1616
1724
|
}
|
|
1617
1725
|
|
|
1726
|
+
function getUniformList( materialProperties ) {
|
|
1727
|
+
|
|
1728
|
+
if ( materialProperties.uniformsList === null ) {
|
|
1729
|
+
|
|
1730
|
+
const progUniforms = materialProperties.currentProgram.getUniforms();
|
|
1731
|
+
materialProperties.uniformsList = WebGLUniforms.seqWithValue( progUniforms.seq, materialProperties.uniforms );
|
|
1732
|
+
|
|
1733
|
+
}
|
|
1734
|
+
|
|
1735
|
+
return materialProperties.uniformsList;
|
|
1736
|
+
|
|
1737
|
+
}
|
|
1738
|
+
|
|
1618
1739
|
function updateCommonMaterialProperties( material, parameters ) {
|
|
1619
1740
|
|
|
1620
1741
|
const materialProperties = properties.get( material );
|
|
1621
1742
|
|
|
1622
1743
|
materialProperties.outputColorSpace = parameters.outputColorSpace;
|
|
1744
|
+
materialProperties.batching = parameters.batching;
|
|
1623
1745
|
materialProperties.instancing = parameters.instancing;
|
|
1624
1746
|
materialProperties.instancingColor = parameters.instancingColor;
|
|
1625
1747
|
materialProperties.skinning = parameters.skinning;
|
|
@@ -1703,6 +1825,14 @@ class WebGLRenderer {
|
|
|
1703
1825
|
|
|
1704
1826
|
needsProgramChange = true;
|
|
1705
1827
|
|
|
1828
|
+
} else if ( object.isBatchedMesh && materialProperties.batching === false ) {
|
|
1829
|
+
|
|
1830
|
+
needsProgramChange = true;
|
|
1831
|
+
|
|
1832
|
+
} else if ( ! object.isBatchedMesh && materialProperties.batching === true ) {
|
|
1833
|
+
|
|
1834
|
+
needsProgramChange = true;
|
|
1835
|
+
|
|
1706
1836
|
} else if ( object.isInstancedMesh && materialProperties.instancing === false ) {
|
|
1707
1837
|
|
|
1708
1838
|
needsProgramChange = true;
|
|
@@ -1892,7 +2022,6 @@ class WebGLRenderer {
|
|
|
1892
2022
|
if ( skeleton.boneTexture === null ) skeleton.computeBoneTexture();
|
|
1893
2023
|
|
|
1894
2024
|
p_uniforms.setValue( _gl, 'boneTexture', skeleton.boneTexture, textures );
|
|
1895
|
-
p_uniforms.setValue( _gl, 'boneTextureSize', skeleton.boneTextureSize );
|
|
1896
2025
|
|
|
1897
2026
|
} else {
|
|
1898
2027
|
|
|
@@ -1904,6 +2033,13 @@ class WebGLRenderer {
|
|
|
1904
2033
|
|
|
1905
2034
|
}
|
|
1906
2035
|
|
|
2036
|
+
if ( object.isBatchedMesh ) {
|
|
2037
|
+
|
|
2038
|
+
p_uniforms.setOptional( _gl, object, 'batchingTexture' );
|
|
2039
|
+
p_uniforms.setValue( _gl, 'batchingTexture', object._matricesTexture, textures );
|
|
2040
|
+
|
|
2041
|
+
}
|
|
2042
|
+
|
|
1907
2043
|
const morphAttributes = geometry.morphAttributes;
|
|
1908
2044
|
|
|
1909
2045
|
if ( morphAttributes.position !== undefined || morphAttributes.normal !== undefined || ( morphAttributes.color !== undefined && capabilities.isWebGL2 === true ) ) {
|
|
@@ -1958,13 +2094,13 @@ class WebGLRenderer {
|
|
|
1958
2094
|
|
|
1959
2095
|
materials.refreshMaterialUniforms( m_uniforms, material, _pixelRatio, _height, _transmissionRenderTarget );
|
|
1960
2096
|
|
|
1961
|
-
WebGLUniforms.upload( _gl, materialProperties
|
|
2097
|
+
WebGLUniforms.upload( _gl, getUniformList( materialProperties ), m_uniforms, textures );
|
|
1962
2098
|
|
|
1963
2099
|
}
|
|
1964
2100
|
|
|
1965
2101
|
if ( material.isShaderMaterial && material.uniformsNeedUpdate === true ) {
|
|
1966
2102
|
|
|
1967
|
-
WebGLUniforms.upload( _gl, materialProperties
|
|
2103
|
+
WebGLUniforms.upload( _gl, getUniformList( materialProperties ), m_uniforms, textures );
|
|
1968
2104
|
material.uniformsNeedUpdate = false;
|
|
1969
2105
|
|
|
1970
2106
|
}
|
|
@@ -2378,7 +2514,7 @@ class WebGLRenderer {
|
|
|
2378
2514
|
textures.setTexture3D( dstTexture, 0 );
|
|
2379
2515
|
glTarget = _gl.TEXTURE_3D;
|
|
2380
2516
|
|
|
2381
|
-
} else if ( dstTexture.isDataArrayTexture ) {
|
|
2517
|
+
} else if ( dstTexture.isDataArrayTexture || dstTexture.isCompressedArrayTexture ) {
|
|
2382
2518
|
|
|
2383
2519
|
textures.setTexture2DArray( dstTexture, 0 );
|
|
2384
2520
|
glTarget = _gl.TEXTURE_2D_ARRAY;
|
|
@@ -2400,7 +2536,7 @@ class WebGLRenderer {
|
|
|
2400
2536
|
const unpackSkipRows = _gl.getParameter( _gl.UNPACK_SKIP_ROWS );
|
|
2401
2537
|
const unpackSkipImages = _gl.getParameter( _gl.UNPACK_SKIP_IMAGES );
|
|
2402
2538
|
|
|
2403
|
-
const image = srcTexture.isCompressedTexture ? srcTexture.mipmaps[
|
|
2539
|
+
const image = srcTexture.isCompressedTexture ? srcTexture.mipmaps[ level ] : srcTexture.image;
|
|
2404
2540
|
|
|
2405
2541
|
_gl.pixelStorei( _gl.UNPACK_ROW_LENGTH, image.width );
|
|
2406
2542
|
_gl.pixelStorei( _gl.UNPACK_IMAGE_HEIGHT, image.height );
|
|
@@ -2505,20 +2641,6 @@ class WebGLRenderer {
|
|
|
2505
2641
|
|
|
2506
2642
|
}
|
|
2507
2643
|
|
|
2508
|
-
get physicallyCorrectLights() { // @deprecated, r150
|
|
2509
|
-
|
|
2510
|
-
console.warn( 'THREE.WebGLRenderer: The property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead.' );
|
|
2511
|
-
return ! this.useLegacyLights;
|
|
2512
|
-
|
|
2513
|
-
}
|
|
2514
|
-
|
|
2515
|
-
set physicallyCorrectLights( value ) { // @deprecated, r150
|
|
2516
|
-
|
|
2517
|
-
console.warn( 'THREE.WebGLRenderer: The property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead.' );
|
|
2518
|
-
this.useLegacyLights = ! value;
|
|
2519
|
-
|
|
2520
|
-
}
|
|
2521
|
-
|
|
2522
2644
|
get outputEncoding() { // @deprecated, r152
|
|
2523
2645
|
|
|
2524
2646
|
console.warn( 'THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead.' );
|
|
@@ -6,6 +6,14 @@ export default /* glsl */`
|
|
|
6
6
|
|
|
7
7
|
reflectedLight.indirectDiffuse *= ambientOcclusion;
|
|
8
8
|
|
|
9
|
+
#if defined( USE_CLEARCOAT )
|
|
10
|
+
clearcoatSpecularIndirect *= ambientOcclusion;
|
|
11
|
+
#endif
|
|
12
|
+
|
|
13
|
+
#if defined( USE_SHEEN )
|
|
14
|
+
sheenSpecularIndirect *= ambientOcclusion;
|
|
15
|
+
#endif
|
|
16
|
+
|
|
9
17
|
#if defined( USE_ENVMAP ) && defined( STANDARD )
|
|
10
18
|
|
|
11
19
|
float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export default /* glsl */`
|
|
2
|
+
#ifdef USE_BATCHING
|
|
3
|
+
attribute float batchId;
|
|
4
|
+
uniform highp sampler2D batchingTexture;
|
|
5
|
+
mat4 getBatchingMatrix( const in float i ) {
|
|
6
|
+
|
|
7
|
+
int size = textureSize( batchingTexture, 0 ).x;
|
|
8
|
+
int j = int( i ) * 4;
|
|
9
|
+
int x = j % size;
|
|
10
|
+
int y = j / size;
|
|
11
|
+
vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );
|
|
12
|
+
vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );
|
|
13
|
+
vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );
|
|
14
|
+
vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
|
|
15
|
+
return mat4( v1, v2, v3, v4 );
|
|
16
|
+
|
|
17
|
+
}
|
|
18
|
+
#endif
|
|
19
|
+
`;
|
|
@@ -24,8 +24,9 @@ export default /* glsl */`
|
|
|
24
24
|
|
|
25
25
|
vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
vec3
|
|
27
|
+
// normalize is done to ensure that the bump map looks the same regardless of the texture's scale
|
|
28
|
+
vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
|
|
29
|
+
vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
|
|
29
30
|
vec3 vN = surf_norm; // normalized
|
|
30
31
|
|
|
31
32
|
vec3 R1 = cross( vSigmaY, vN );
|
|
@@ -119,19 +119,14 @@ export default /* glsl */`
|
|
|
119
119
|
// These defines must match with PMREMGenerator
|
|
120
120
|
|
|
121
121
|
#define cubeUV_r0 1.0
|
|
122
|
-
#define cubeUV_v0 0.339
|
|
123
122
|
#define cubeUV_m0 - 2.0
|
|
124
123
|
#define cubeUV_r1 0.8
|
|
125
|
-
#define cubeUV_v1 0.276
|
|
126
124
|
#define cubeUV_m1 - 1.0
|
|
127
125
|
#define cubeUV_r4 0.4
|
|
128
|
-
#define cubeUV_v4 0.046
|
|
129
126
|
#define cubeUV_m4 2.0
|
|
130
127
|
#define cubeUV_r5 0.305
|
|
131
|
-
#define cubeUV_v5 0.016
|
|
132
128
|
#define cubeUV_m5 3.0
|
|
133
129
|
#define cubeUV_r6 0.21
|
|
134
|
-
#define cubeUV_v6 0.0038
|
|
135
130
|
#define cubeUV_m6 4.0
|
|
136
131
|
|
|
137
132
|
float roughnessToMip( float roughness ) {
|
|
@@ -1,16 +1,43 @@
|
|
|
1
1
|
export default /* glsl */`
|
|
2
|
+
|
|
2
3
|
vec3 transformedNormal = objectNormal;
|
|
4
|
+
#ifdef USE_TANGENT
|
|
5
|
+
|
|
6
|
+
vec3 transformedTangent = objectTangent;
|
|
7
|
+
|
|
8
|
+
#endif
|
|
9
|
+
|
|
10
|
+
#ifdef USE_BATCHING
|
|
11
|
+
|
|
12
|
+
// this is in lieu of a per-instance normal-matrix
|
|
13
|
+
// shear transforms in the instance matrix are not supported
|
|
14
|
+
|
|
15
|
+
mat3 bm = mat3( batchingMatrix );
|
|
16
|
+
transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
|
|
17
|
+
transformedNormal = bm * transformedNormal;
|
|
18
|
+
|
|
19
|
+
#ifdef USE_TANGENT
|
|
20
|
+
|
|
21
|
+
transformedTangent = bm * transformedTangent;
|
|
22
|
+
|
|
23
|
+
#endif
|
|
24
|
+
|
|
25
|
+
#endif
|
|
3
26
|
|
|
4
27
|
#ifdef USE_INSTANCING
|
|
5
28
|
|
|
6
29
|
// this is in lieu of a per-instance normal-matrix
|
|
7
30
|
// shear transforms in the instance matrix are not supported
|
|
8
31
|
|
|
9
|
-
mat3
|
|
32
|
+
mat3 im = mat3( instanceMatrix );
|
|
33
|
+
transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
|
|
34
|
+
transformedNormal = im * transformedNormal;
|
|
10
35
|
|
|
11
|
-
|
|
36
|
+
#ifdef USE_TANGENT
|
|
12
37
|
|
|
13
|
-
|
|
38
|
+
transformedTangent = im * transformedTangent;
|
|
39
|
+
|
|
40
|
+
#endif
|
|
14
41
|
|
|
15
42
|
#endif
|
|
16
43
|
|
|
@@ -24,7 +51,7 @@ transformedNormal = normalMatrix * transformedNormal;
|
|
|
24
51
|
|
|
25
52
|
#ifdef USE_TANGENT
|
|
26
53
|
|
|
27
|
-
|
|
54
|
+
transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
|
|
28
55
|
|
|
29
56
|
#ifdef FLIP_SIDED
|
|
30
57
|
|
|
@@ -17,7 +17,7 @@ vec3 geometryPosition = - vViewPosition;
|
|
|
17
17
|
vec3 geometryNormal = normal;
|
|
18
18
|
vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
|
|
19
19
|
|
|
20
|
-
vec3 geometryClearcoatNormal;
|
|
20
|
+
vec3 geometryClearcoatNormal = vec3( 0.0 );
|
|
21
21
|
|
|
22
22
|
#ifdef USE_CLEARCOAT
|
|
23
23
|
|
|
@@ -133,14 +133,19 @@ material.roughness = min( material.roughness, 1.0 );
|
|
|
133
133
|
#endif
|
|
134
134
|
|
|
135
135
|
material.anisotropy = length( anisotropyV );
|
|
136
|
-
|
|
137
|
-
material.anisotropy
|
|
136
|
+
|
|
137
|
+
if( material.anisotropy == 0.0 ) {
|
|
138
|
+
anisotropyV = vec2( 1.0, 0.0 );
|
|
139
|
+
} else {
|
|
140
|
+
anisotropyV /= material.anisotropy;
|
|
141
|
+
material.anisotropy = saturate( material.anisotropy );
|
|
142
|
+
}
|
|
138
143
|
|
|
139
144
|
// Roughness along the anisotropy bitangent is the material roughness, while the tangent roughness increases with anisotropy.
|
|
140
145
|
material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
|
|
141
146
|
|
|
142
|
-
material.anisotropyT = tbn[ 0 ] * anisotropyV.x
|
|
143
|
-
material.anisotropyB = tbn[ 1 ] * anisotropyV.x
|
|
147
|
+
material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
|
|
148
|
+
material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
|
|
144
149
|
|
|
145
150
|
#endif
|
|
146
151
|
`;
|
|
@@ -49,8 +49,10 @@ struct PhysicalMaterial {
|
|
|
49
49
|
};
|
|
50
50
|
|
|
51
51
|
// temporary
|
|
52
|
-
vec3
|
|
53
|
-
vec3
|
|
52
|
+
vec3 clearcoatSpecularDirect = vec3( 0.0 );
|
|
53
|
+
vec3 clearcoatSpecularIndirect = vec3( 0.0 );
|
|
54
|
+
vec3 sheenSpecularDirect = vec3( 0.0 );
|
|
55
|
+
vec3 sheenSpecularIndirect = vec3(0.0 );
|
|
54
56
|
|
|
55
57
|
vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
|
|
56
58
|
float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
|
|
@@ -485,13 +487,13 @@ void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geome
|
|
|
485
487
|
|
|
486
488
|
vec3 ccIrradiance = dotNLcc * directLight.color;
|
|
487
489
|
|
|
488
|
-
|
|
490
|
+
clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
|
|
489
491
|
|
|
490
492
|
#endif
|
|
491
493
|
|
|
492
494
|
#ifdef USE_SHEEN
|
|
493
495
|
|
|
494
|
-
|
|
496
|
+
sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
|
|
495
497
|
|
|
496
498
|
#endif
|
|
497
499
|
|
|
@@ -510,13 +512,13 @@ void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradia
|
|
|
510
512
|
|
|
511
513
|
#ifdef USE_CLEARCOAT
|
|
512
514
|
|
|
513
|
-
|
|
515
|
+
clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
|
|
514
516
|
|
|
515
517
|
#endif
|
|
516
518
|
|
|
517
519
|
#ifdef USE_SHEEN
|
|
518
520
|
|
|
519
|
-
|
|
521
|
+
sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
|
|
520
522
|
|
|
521
523
|
#endif
|
|
522
524
|
|