@plastic-software/three 0.183.4 → 0.184.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 +775 -287
- package/build/three.core.js +372 -110
- package/build/three.core.min.js +1 -1
- package/build/three.module.js +428 -181
- package/build/three.module.min.js +1 -1
- package/build/three.tsl.js +7 -1
- package/build/three.tsl.min.js +1 -1
- package/build/three.webgpu.js +2979 -1281
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +2942 -1281
- package/build/three.webgpu.nodes.min.js +1 -1
- package/examples/jsm/Addons.js +11 -0
- package/examples/jsm/animation/CCDIKSolver.js +5 -1
- package/examples/jsm/controls/ArcballControls.js +4 -1
- package/examples/jsm/controls/DragControls.js +2 -2
- package/examples/jsm/controls/FirstPersonControls.js +58 -54
- package/examples/jsm/controls/FlyControls.js +4 -0
- package/examples/jsm/controls/OrbitControls.js +2 -2
- package/examples/jsm/controls/TrackballControls.js +2 -2
- package/examples/jsm/controls/TransformControls.js +34 -2
- package/examples/jsm/csm/CSMShadowNode.js +6 -2
- package/examples/jsm/exporters/GLTFExporter.js +21 -5
- package/examples/jsm/geometries/TextGeometry.js +18 -0
- package/examples/jsm/helpers/LightProbeGridHelper.js +221 -0
- package/examples/jsm/inspector/Extension.js +13 -0
- package/examples/jsm/inspector/Inspector.js +169 -114
- package/examples/jsm/inspector/RendererInspector.js +2 -2
- package/examples/jsm/inspector/extensions/extensions.json +6 -0
- package/examples/jsm/inspector/extensions/tsl-graph/TSLGraphEditor.js +916 -0
- package/examples/jsm/inspector/extensions/tsl-graph/TSLGraphLoader.js +281 -0
- package/examples/jsm/inspector/tabs/Memory.js +128 -0
- package/examples/jsm/inspector/tabs/Parameters.js +34 -2
- package/examples/jsm/inspector/tabs/Performance.js +2 -2
- package/examples/jsm/inspector/tabs/Settings.js +264 -0
- package/examples/jsm/inspector/tabs/Timeline.js +1611 -0
- package/examples/jsm/inspector/tabs/Viewer.js +105 -3
- package/examples/jsm/inspector/ui/Graph.js +2 -2
- package/examples/jsm/inspector/ui/List.js +1 -1
- package/examples/jsm/inspector/ui/Profiler.js +273 -176
- package/examples/jsm/inspector/ui/Style.js +64 -10
- package/examples/jsm/inspector/ui/Tab.js +39 -7
- package/examples/jsm/inspector/ui/Values.js +39 -2
- package/examples/jsm/inspector/ui/utils.js +13 -0
- package/examples/jsm/interaction/InteractionManager.js +226 -0
- package/examples/jsm/libs/meshopt_decoder.module.js +8 -8
- package/examples/jsm/lighting/DynamicLighting.js +82 -0
- package/examples/jsm/lighting/LightProbeGrid.js +651 -0
- package/examples/jsm/lines/LineMaterial.js +1 -1
- package/examples/jsm/loaders/EXRLoader.js +682 -43
- package/examples/jsm/loaders/FBXLoader.js +233 -33
- package/examples/jsm/loaders/GLTFLoader.js +24 -7
- package/examples/jsm/loaders/HDRLoader.js +1 -1
- package/examples/jsm/loaders/KTX2Loader.js +8 -2
- package/examples/jsm/loaders/LDrawLoader.js +39 -47
- package/examples/jsm/loaders/SVGLoader.js +1 -1
- package/examples/jsm/loaders/VTKLoader.js +5 -1
- package/examples/jsm/loaders/collada/ColladaComposer.js +101 -7
- package/examples/jsm/loaders/collada/ColladaParser.js +19 -4
- package/examples/jsm/loaders/usd/USDAParser.js +6 -0
- package/examples/jsm/loaders/usd/USDCParser.js +26 -0
- package/examples/jsm/loaders/usd/USDComposer.js +656 -103
- package/examples/jsm/misc/GPUComputationRenderer.js +2 -0
- package/examples/jsm/misc/RollerCoaster.js +42 -4
- package/examples/jsm/modifiers/TessellateModifier.js +1 -1
- package/examples/jsm/objects/Reflector.js +73 -25
- package/examples/jsm/objects/Sky.js +14 -2
- package/examples/jsm/objects/SkyMesh.js +23 -6
- package/examples/jsm/renderers/Projector.js +18 -38
- package/examples/jsm/renderers/SVGRenderer.js +6 -25
- package/examples/jsm/transpiler/GLSLDecoder.js +2 -2
- package/examples/jsm/tsl/WebGLNodesHandler.js +605 -0
- package/examples/jsm/tsl/display/AfterImageNode.js +10 -0
- package/examples/jsm/tsl/display/AnamorphicNode.js +11 -0
- package/examples/jsm/tsl/display/BilateralBlurNode.js +10 -0
- package/examples/jsm/tsl/display/ChromaticAberrationNode.js +3 -36
- package/examples/jsm/tsl/display/FSR1Node.js +477 -0
- package/examples/jsm/tsl/display/GTAONode.js +2 -1
- package/examples/jsm/tsl/display/GaussianBlurNode.js +10 -0
- package/examples/jsm/tsl/display/GodraysNode.js +2 -11
- package/examples/jsm/tsl/display/OutlineNode.js +66 -16
- package/examples/jsm/tsl/display/SSGINode.js +0 -4
- package/examples/jsm/tsl/display/SharpenNode.js +283 -0
- package/examples/jsm/tsl/display/TAAUNode.js +835 -0
- package/examples/jsm/tsl/display/TRAANode.js +48 -7
- package/examples/jsm/tsl/lighting/DynamicLightsNode.js +300 -0
- package/examples/jsm/tsl/lighting/data/AmbientLightDataNode.js +61 -0
- package/examples/jsm/tsl/lighting/data/DirectionalLightDataNode.js +111 -0
- package/examples/jsm/tsl/lighting/data/HemisphereLightDataNode.js +99 -0
- package/examples/jsm/tsl/lighting/data/PointLightDataNode.js +134 -0
- package/examples/jsm/tsl/lighting/data/SpotLightDataNode.js +161 -0
- package/examples/jsm/tsl/math/Bayer.js +13 -2
- package/examples/jsm/utils/BufferGeometryUtils.js +2 -3
- package/examples/jsm/utils/ColorUtils.js +76 -0
- package/examples/jsm/utils/SkeletonUtils.js +14 -8
- package/examples/jsm/webxr/XRHandMeshModel.js +36 -10
- package/examples/jsm/webxr/XRHandModelFactory.js +2 -1
- package/package.json +4 -4
- package/src/Three.Core.js +1 -0
- package/src/Three.TSL.js +6 -0
- package/src/Three.WebGPU.Nodes.js +3 -0
- package/src/Three.WebGPU.js +6 -0
- package/src/animation/AnimationAction.js +11 -1
- package/src/audio/AudioContext.js +2 -2
- package/src/constants.js +1 -1
- package/src/core/BufferAttribute.js +13 -1
- package/src/core/Clock.js +1 -1
- package/src/core/Object3D.js +1 -5
- package/src/core/RenderTarget.js +1 -0
- package/src/extras/curves/CatmullRomCurve3.js +3 -2
- package/src/loaders/AudioLoader.js +11 -1
- package/src/loaders/DataTextureLoader.js +6 -4
- package/src/loaders/FileLoader.js +1 -2
- package/src/loaders/ImageBitmapLoader.js +4 -6
- package/src/loaders/MaterialLoader.js +1 -1
- package/src/loaders/ObjectLoader.js +25 -4
- package/src/loaders/nodes/NodeObjectLoader.js +18 -0
- package/src/materials/MeshToonMaterial.js +1 -1
- package/src/materials/nodes/Line2NodeMaterial.js +27 -0
- package/src/materials/nodes/NodeMaterial.js +0 -27
- package/src/materials/nodes/manager/NodeMaterialObserver.js +188 -89
- package/src/math/Line3.js +3 -0
- package/src/math/Matrix2.js +13 -9
- package/src/math/Matrix3.js +13 -9
- package/src/math/Matrix4.js +13 -9
- package/src/math/Plane.js +4 -3
- package/src/math/Triangle.js +1 -1
- package/src/math/Vector2.js +11 -7
- package/src/math/Vector3.js +12 -8
- package/src/math/Vector4.js +13 -9
- package/src/nodes/Nodes.js +0 -1
- package/src/nodes/TSL.js +1 -1
- package/src/nodes/accessors/BufferAttributeNode.js +9 -3
- package/src/nodes/accessors/CubeTextureNode.js +7 -1
- package/src/nodes/accessors/MaterialProperties.js +2 -5
- package/src/nodes/accessors/Object3DNode.js +1 -1
- package/src/nodes/accessors/ReferenceBaseNode.js +2 -2
- package/src/nodes/accessors/ReferenceNode.js +4 -4
- package/src/nodes/accessors/SceneProperties.js +2 -8
- package/src/nodes/accessors/StorageBufferNode.js +10 -4
- package/src/nodes/accessors/StorageTextureNode.js +4 -9
- package/src/nodes/accessors/TextureNode.js +10 -2
- package/src/nodes/accessors/UniformArrayNode.js +2 -2
- package/src/nodes/code/FunctionCallNode.js +1 -1
- package/src/nodes/code/FunctionNode.js +1 -1
- package/src/nodes/core/ArrayNode.js +1 -1
- package/src/nodes/core/AssignNode.js +1 -1
- package/src/nodes/core/AttributeNode.js +1 -1
- package/src/nodes/core/BypassNode.js +1 -1
- package/src/nodes/core/ContextNode.js +1 -1
- package/src/nodes/core/IndexNode.js +2 -1
- package/src/nodes/core/InputNode.js +1 -1
- package/src/nodes/core/InspectorNode.js +1 -1
- package/src/nodes/core/IsolateNode.js +1 -1
- package/src/nodes/core/Node.js +83 -12
- package/src/nodes/core/NodeBuilder.js +117 -16
- package/src/nodes/core/NodeUtils.js +1 -1
- package/src/nodes/core/OutputStructNode.js +1 -1
- package/src/nodes/core/ParameterNode.js +1 -1
- package/src/nodes/core/StackNode.js +1 -1
- package/src/nodes/core/StructNode.js +1 -1
- package/src/nodes/core/StructTypeNode.js +1 -1
- package/src/nodes/core/SubBuildNode.js +1 -1
- package/src/nodes/core/UniformGroupNode.js +36 -6
- package/src/nodes/core/VarNode.js +1 -1
- package/src/nodes/core/VaryingNode.js +1 -1
- package/src/nodes/display/NormalMapNode.js +2 -2
- package/src/nodes/display/PassNode.js +27 -7
- package/src/nodes/display/RenderOutputNode.js +4 -4
- package/src/nodes/display/ScreenNode.js +1 -1
- package/src/nodes/display/ViewportDepthTextureNode.js +11 -15
- package/src/nodes/display/ViewportTextureNode.js +18 -7
- package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +2 -2
- package/src/nodes/geometry/RangeNode.js +1 -1
- package/src/nodes/gpgpu/AtomicFunctionNode.js +1 -1
- package/src/nodes/gpgpu/BarrierNode.js +9 -0
- package/src/nodes/gpgpu/ComputeBuiltinNode.js +1 -1
- package/src/nodes/gpgpu/ComputeNode.js +69 -44
- package/src/nodes/gpgpu/SubgroupFunctionNode.js +1 -1
- package/src/nodes/lighting/LightsNode.js +6 -27
- package/src/nodes/lighting/ShadowNode.js +24 -2
- package/src/nodes/math/BitcastNode.js +1 -1
- package/src/nodes/math/ConditionalNode.js +1 -1
- package/src/nodes/math/MathNode.js +73 -1
- package/src/nodes/math/OperatorNode.js +1 -1
- package/src/nodes/math/PackFloatNode.js +1 -1
- package/src/nodes/math/UnpackFloatNode.js +1 -1
- package/src/nodes/tsl/TSLBase.js +1 -1
- package/src/nodes/tsl/TSLCore.js +21 -3
- package/src/nodes/utils/ArrayElementNode.js +1 -1
- package/src/nodes/utils/ConvertNode.js +1 -1
- package/src/nodes/utils/DebugNode.js +1 -1
- package/src/nodes/utils/EventNode.js +30 -0
- package/src/nodes/utils/FlipNode.js +1 -1
- package/src/nodes/utils/FunctionOverloadingNode.js +1 -1
- package/src/nodes/utils/JoinNode.js +1 -1
- package/src/nodes/utils/MemberNode.js +1 -1
- package/src/nodes/utils/Remap.js +48 -0
- package/src/nodes/utils/RotateNode.js +1 -1
- package/src/nodes/utils/SetNode.js +1 -1
- package/src/nodes/utils/SplitNode.js +1 -1
- package/src/objects/BatchedMesh.js +17 -2
- package/src/objects/InstancedMesh.js +19 -3
- package/src/objects/SkinnedMesh.js +26 -9
- package/src/renderers/WebGLRenderer.js +147 -48
- package/src/renderers/common/Animation.js +3 -3
- package/src/renderers/common/Attributes.js +15 -1
- package/src/renderers/common/Backend.js +0 -8
- package/src/renderers/common/Background.js +2 -2
- package/src/renderers/common/BindGroup.js +1 -8
- package/src/renderers/common/Bindings.js +2 -2
- package/src/renderers/common/ComputePipeline.js +1 -1
- package/src/renderers/common/CubeRenderTarget.js +1 -1
- package/src/renderers/common/Info.js +333 -4
- package/src/renderers/common/InspectorBase.js +6 -1
- package/src/renderers/common/Pipelines.js +36 -3
- package/src/renderers/common/ReadbackBuffer.js +78 -0
- package/src/renderers/common/RenderBundle.js +3 -1
- package/src/renderers/common/RenderBundles.js +5 -2
- package/src/renderers/common/RenderObject.js +2 -2
- package/src/renderers/common/RenderObjects.js +3 -3
- package/src/renderers/common/RenderPipeline.js +35 -6
- package/src/renderers/common/Renderer.js +232 -53
- package/src/renderers/common/Textures.js +72 -3
- package/src/renderers/common/UniformsGroup.js +1 -1
- package/src/renderers/common/XRManager.js +34 -27
- package/src/renderers/common/extras/PMREMGenerator.js +23 -15
- package/src/renderers/common/nodes/NodeBuilderState.js +1 -1
- package/src/renderers/common/nodes/NodeManager.js +230 -99
- package/src/renderers/shaders/ShaderChunk/envmap_common_pars_fragment.glsl.js +0 -1
- package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/lightprobes_pars_fragment.glsl.js +80 -0
- package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +8 -0
- package/src/renderers/shaders/ShaderChunk/lights_pars_begin.glsl.js +2 -0
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +1 -3
- package/src/renderers/shaders/ShaderChunk/normal_fragment_maps.glsl.js +7 -0
- package/src/renderers/shaders/ShaderChunk/premultiplied_alpha_fragment.glsl.js +0 -1
- package/src/renderers/shaders/ShaderChunk/shadowmap_vertex.glsl.js +12 -2
- package/src/renderers/shaders/ShaderChunk.js +2 -0
- package/src/renderers/shaders/ShaderLib/backgroundCube.glsl.js +1 -2
- package/src/renderers/shaders/ShaderLib.js +0 -1
- package/src/renderers/shaders/UniformsLib.js +7 -2
- package/src/renderers/shaders/UniformsUtils.js +27 -5
- package/src/renderers/webgl/WebGLAnimation.js +2 -1
- package/src/renderers/webgl/WebGLBackground.js +13 -13
- package/src/renderers/webgl/WebGLBufferRenderer.js +0 -32
- package/src/renderers/webgl/WebGLCapabilities.js +6 -0
- package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +0 -32
- package/src/renderers/webgl/WebGLMaterials.js +12 -13
- package/src/renderers/webgl/WebGLOutput.js +4 -1
- package/src/renderers/webgl/WebGLProgram.js +4 -0
- package/src/renderers/webgl/WebGLPrograms.js +21 -4
- package/src/renderers/webgl/WebGLRenderStates.js +13 -2
- package/src/renderers/webgl/WebGLState.js +43 -0
- package/src/renderers/webgl/WebGLTextures.js +129 -26
- package/src/renderers/webgl/WebGLUniformsGroups.js +19 -0
- package/src/renderers/webgl-fallback/WebGLBackend.js +106 -65
- package/src/renderers/webgl-fallback/WebGLBufferRenderer.js +0 -41
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +29 -51
- package/src/renderers/webgl-fallback/utils/WebGLAttributeUtils.js +53 -19
- package/src/renderers/webgl-fallback/utils/WebGLCapabilities.js +25 -0
- package/src/renderers/webgl-fallback/utils/WebGLState.js +42 -1
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +63 -50
- package/src/renderers/webgl-fallback/utils/WebGLTimestampQueryPool.js +1 -1
- package/src/renderers/webgpu/WebGPUBackend.js +160 -146
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +55 -33
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +103 -17
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +1 -1
- package/src/renderers/webgpu/utils/WebGPUCapabilities.js +48 -0
- package/src/renderers/webgpu/utils/WebGPUConstants.js +8 -0
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +91 -17
- package/src/renderers/webgpu/utils/WebGPUUtils.js +18 -2
- package/src/renderers/webxr/WebXRController.js +12 -0
- package/src/textures/HTMLTexture.js +74 -0
- package/src/textures/Source.js +1 -1
- package/src/textures/Texture.js +13 -2
- package/src/utils.js +23 -1
- package/src/nodes/utils/RemapNode.js +0 -125
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
export default /* glsl */`
|
|
2
|
+
#ifdef USE_LIGHT_PROBES_GRID
|
|
3
|
+
|
|
4
|
+
// Single atlas 3D texture that stores all 7 SH sub-volumes stacked along Z.
|
|
5
|
+
// Atlas depth = 7 * ( nz + 2 ) where nz = probesResolution.z.
|
|
6
|
+
// Each sub-volume occupies ( nz + 2 ) slices: 1 padding + nz data + 1 padding.
|
|
7
|
+
// Padding is a copy of the first / last data slice and prevents color bleeding
|
|
8
|
+
// when the hardware linear filter reads across a sub-volume boundary.
|
|
9
|
+
uniform highp sampler3D probesSH;
|
|
10
|
+
|
|
11
|
+
uniform vec3 probesMin;
|
|
12
|
+
uniform vec3 probesMax;
|
|
13
|
+
uniform vec3 probesResolution;
|
|
14
|
+
|
|
15
|
+
vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
|
|
16
|
+
|
|
17
|
+
vec3 res = probesResolution;
|
|
18
|
+
vec3 gridRange = probesMax - probesMin;
|
|
19
|
+
vec3 resMinusOne = res - 1.0;
|
|
20
|
+
vec3 probeSpacing = gridRange / resMinusOne;
|
|
21
|
+
|
|
22
|
+
// Offset sample position along normal by half a probe spacing
|
|
23
|
+
vec3 samplePos = worldPos + worldNormal * probeSpacing * 0.5;
|
|
24
|
+
vec3 uvw = clamp( ( samplePos - probesMin ) / gridRange, 0.0, 1.0 );
|
|
25
|
+
|
|
26
|
+
// Remap to texel centers of the probe grid (XY and Z)
|
|
27
|
+
uvw = uvw * resMinusOne / res + 0.5 / res;
|
|
28
|
+
|
|
29
|
+
// Atlas UV mapping along Z:
|
|
30
|
+
// paddedSlices = nz + 2 (1 padding texel at each end of every sub-volume)
|
|
31
|
+
// atlasDepth = 7 * paddedSlices
|
|
32
|
+
// For sub-volume t the first DATA texel sits at atlas slice t*paddedSlices + 1.
|
|
33
|
+
// Given probe-grid texel-centre UVZ = ( iz + 0.5 ) / nz the atlas UV is:
|
|
34
|
+
// atlasUvZ = ( uvw.z * nz + t * paddedSlices + 1 ) / atlasDepth
|
|
35
|
+
//
|
|
36
|
+
// uvZBase encodes the nz-scaled Z plus the intra-volume offset (+ 1 for padding),
|
|
37
|
+
// so adding t*paddedSlices steps to each successive sub-volume.
|
|
38
|
+
float nz = res.z;
|
|
39
|
+
float paddedSlices = nz + 2.0;
|
|
40
|
+
float atlasDepth = 7.0 * paddedSlices;
|
|
41
|
+
float uvZBase = uvw.z * nz + 1.0;
|
|
42
|
+
|
|
43
|
+
vec4 s0 = texture( probesSH, vec3( uvw.xy, ( uvZBase ) / atlasDepth ) );
|
|
44
|
+
vec4 s1 = texture( probesSH, vec3( uvw.xy, ( uvZBase + paddedSlices ) / atlasDepth ) );
|
|
45
|
+
vec4 s2 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 2.0 * paddedSlices ) / atlasDepth ) );
|
|
46
|
+
vec4 s3 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 3.0 * paddedSlices ) / atlasDepth ) );
|
|
47
|
+
vec4 s4 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 4.0 * paddedSlices ) / atlasDepth ) );
|
|
48
|
+
vec4 s5 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 5.0 * paddedSlices ) / atlasDepth ) );
|
|
49
|
+
vec4 s6 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 6.0 * paddedSlices ) / atlasDepth ) );
|
|
50
|
+
|
|
51
|
+
// Unpack 9 vec3 SH L2 coefficients
|
|
52
|
+
vec3 c0 = s0.xyz;
|
|
53
|
+
vec3 c1 = vec3( s0.w, s1.xy );
|
|
54
|
+
vec3 c2 = vec3( s1.zw, s2.x );
|
|
55
|
+
vec3 c3 = s2.yzw;
|
|
56
|
+
vec3 c4 = s3.xyz;
|
|
57
|
+
vec3 c5 = vec3( s3.w, s4.xy );
|
|
58
|
+
vec3 c6 = vec3( s4.zw, s5.x );
|
|
59
|
+
vec3 c7 = s5.yzw;
|
|
60
|
+
vec3 c8 = s6.xyz;
|
|
61
|
+
|
|
62
|
+
// Evaluate L2 irradiance
|
|
63
|
+
float x = worldNormal.x, y = worldNormal.y, z = worldNormal.z;
|
|
64
|
+
|
|
65
|
+
vec3 result = c0 * 0.886227;
|
|
66
|
+
result += c1 * 2.0 * 0.511664 * y;
|
|
67
|
+
result += c2 * 2.0 * 0.511664 * z;
|
|
68
|
+
result += c3 * 2.0 * 0.511664 * x;
|
|
69
|
+
result += c4 * 2.0 * 0.429043 * x * y;
|
|
70
|
+
result += c5 * 2.0 * 0.429043 * y * z;
|
|
71
|
+
result += c6 * ( 0.743125 * z * z - 0.247708 );
|
|
72
|
+
result += c7 * 2.0 * 0.429043 * x * z;
|
|
73
|
+
result += c8 * 0.429043 * ( x * x - y * y );
|
|
74
|
+
|
|
75
|
+
return max( result, vec3( 0.0 ) );
|
|
76
|
+
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
#endif
|
|
80
|
+
`;
|
|
@@ -194,6 +194,14 @@ IncidentLight directLight;
|
|
|
194
194
|
|
|
195
195
|
#endif
|
|
196
196
|
|
|
197
|
+
#ifdef USE_LIGHT_PROBES_GRID
|
|
198
|
+
|
|
199
|
+
vec3 probeWorldPos = ( ( vec4( geometryPosition, 1.0 ) - viewMatrix[ 3 ] ) * viewMatrix ).xyz;
|
|
200
|
+
vec3 probeWorldNormal = inverseTransformDirection( geometryNormal, viewMatrix );
|
|
201
|
+
irradiance += getLightProbeGridIrradiance( probeWorldPos, probeWorldNormal );
|
|
202
|
+
|
|
203
|
+
#endif
|
|
204
|
+
|
|
197
205
|
#endif
|
|
198
206
|
|
|
199
207
|
#if defined( RE_IndirectSpecular )
|
|
@@ -103,9 +103,7 @@ float D_GGX( const in float alpha, const in float dotNH ) {
|
|
|
103
103
|
|
|
104
104
|
float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
|
|
105
105
|
float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
return v;
|
|
106
|
+
return 0.5 / max( gv + gl, EPSILON );
|
|
109
107
|
|
|
110
108
|
}
|
|
111
109
|
|
|
@@ -37,6 +37,13 @@ export default /* glsl */`
|
|
|
37
37
|
#elif defined( USE_NORMALMAP_TANGENTSPACE )
|
|
38
38
|
|
|
39
39
|
vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
|
|
40
|
+
|
|
41
|
+
#if defined( USE_PACKED_NORMALMAP )
|
|
42
|
+
|
|
43
|
+
mapN = vec3( mapN.xy, sqrt( saturate( 1.0 - dot( mapN.xy, mapN.xy ) ) ) );
|
|
44
|
+
|
|
45
|
+
#endif
|
|
46
|
+
|
|
40
47
|
mapN.xy *= normalScale;
|
|
41
48
|
|
|
42
49
|
normal = normalize( tbn * mapN );
|
|
@@ -2,8 +2,18 @@ export default /* glsl */`
|
|
|
2
2
|
|
|
3
3
|
#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
#ifdef HAS_NORMAL
|
|
6
|
+
|
|
7
|
+
// Offsetting the position used for querying occlusion along the world normal can be used to reduce shadow acne.
|
|
8
|
+
|
|
9
|
+
vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
|
|
10
|
+
|
|
11
|
+
#else
|
|
12
|
+
|
|
13
|
+
vec3 shadowWorldNormal = vec3( 0.0 ); // fallback, see #21483
|
|
14
|
+
|
|
15
|
+
#endif
|
|
16
|
+
|
|
7
17
|
vec4 shadowWorldPosition;
|
|
8
18
|
|
|
9
19
|
#endif
|
|
@@ -54,6 +54,7 @@ import lights_physical_pars_fragment from './ShaderChunk/lights_physical_pars_fr
|
|
|
54
54
|
import lights_fragment_begin from './ShaderChunk/lights_fragment_begin.glsl.js';
|
|
55
55
|
import lights_fragment_maps from './ShaderChunk/lights_fragment_maps.glsl.js';
|
|
56
56
|
import lights_fragment_end from './ShaderChunk/lights_fragment_end.glsl.js';
|
|
57
|
+
import lightprobes_pars_fragment from './ShaderChunk/lightprobes_pars_fragment.glsl.js';
|
|
57
58
|
import logdepthbuf_fragment from './ShaderChunk/logdepthbuf_fragment.glsl.js';
|
|
58
59
|
import logdepthbuf_pars_fragment from './ShaderChunk/logdepthbuf_pars_fragment.glsl.js';
|
|
59
60
|
import logdepthbuf_pars_vertex from './ShaderChunk/logdepthbuf_pars_vertex.glsl.js';
|
|
@@ -182,6 +183,7 @@ export const ShaderChunk = {
|
|
|
182
183
|
lights_fragment_begin: lights_fragment_begin,
|
|
183
184
|
lights_fragment_maps: lights_fragment_maps,
|
|
184
185
|
lights_fragment_end: lights_fragment_end,
|
|
186
|
+
lightprobes_pars_fragment: lightprobes_pars_fragment,
|
|
185
187
|
logdepthbuf_fragment: logdepthbuf_fragment,
|
|
186
188
|
logdepthbuf_pars_fragment: logdepthbuf_pars_fragment,
|
|
187
189
|
logdepthbuf_pars_vertex: logdepthbuf_pars_vertex,
|
|
@@ -27,7 +27,6 @@ export const fragment = /* glsl */`
|
|
|
27
27
|
|
|
28
28
|
#endif
|
|
29
29
|
|
|
30
|
-
uniform float flipEnvMap;
|
|
31
30
|
uniform float backgroundBlurriness;
|
|
32
31
|
uniform float backgroundIntensity;
|
|
33
32
|
uniform mat3 backgroundRotation;
|
|
@@ -40,7 +39,7 @@ void main() {
|
|
|
40
39
|
|
|
41
40
|
#ifdef ENVMAP_TYPE_CUBE
|
|
42
41
|
|
|
43
|
-
vec4 texColor = textureCube( envMap, backgroundRotation *
|
|
42
|
+
vec4 texColor = textureCube( envMap, backgroundRotation * vWorldDirection );
|
|
44
43
|
|
|
45
44
|
#elif defined( ENVMAP_TYPE_CUBE_UV )
|
|
46
45
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Color } from '../../math/Color.js';
|
|
2
2
|
import { Vector2 } from '../../math/Vector2.js';
|
|
3
|
+
import { Vector3 } from '../../math/Vector3.js';
|
|
3
4
|
import { Matrix3 } from '../../math/Matrix3.js';
|
|
4
5
|
import { Matrix4 } from '../../math/Matrix4.js';
|
|
5
6
|
|
|
@@ -35,7 +36,6 @@ const UniformsLib = {
|
|
|
35
36
|
|
|
36
37
|
envMap: { value: null },
|
|
37
38
|
envMapRotation: { value: /*@__PURE__*/ new Matrix3() },
|
|
38
|
-
flipEnvMap: { value: - 1 },
|
|
39
39
|
reflectivity: { value: 1.0 }, // basic, lambert, phong
|
|
40
40
|
ior: { value: 1.5 }, // physical
|
|
41
41
|
refractionRatio: { value: 0.98 }, // basic, lambert, phong
|
|
@@ -196,7 +196,12 @@ const UniformsLib = {
|
|
|
196
196
|
} },
|
|
197
197
|
|
|
198
198
|
ltc_1: { value: null },
|
|
199
|
-
ltc_2: { value: null }
|
|
199
|
+
ltc_2: { value: null },
|
|
200
|
+
|
|
201
|
+
probesSH: { value: null },
|
|
202
|
+
probesMin: { value: /*@__PURE__*/ new Vector3() },
|
|
203
|
+
probesMax: { value: /*@__PURE__*/ new Vector3() },
|
|
204
|
+
probesResolution: { value: /*@__PURE__*/ new Vector3() }
|
|
200
205
|
|
|
201
206
|
},
|
|
202
207
|
|
|
@@ -27,10 +27,7 @@ export function cloneUniforms( src ) {
|
|
|
27
27
|
|
|
28
28
|
const property = src[ u ][ p ];
|
|
29
29
|
|
|
30
|
-
if ( property
|
|
31
|
-
property.isMatrix3 || property.isMatrix4 ||
|
|
32
|
-
property.isVector2 || property.isVector3 || property.isVector4 ||
|
|
33
|
-
property.isTexture || property.isQuaternion ) ) {
|
|
30
|
+
if ( isThreeObject( property ) ) {
|
|
34
31
|
|
|
35
32
|
if ( property.isRenderTargetTexture ) {
|
|
36
33
|
|
|
@@ -45,7 +42,23 @@ export function cloneUniforms( src ) {
|
|
|
45
42
|
|
|
46
43
|
} else if ( Array.isArray( property ) ) {
|
|
47
44
|
|
|
48
|
-
|
|
45
|
+
if ( isThreeObject( property[ 0 ] ) ) {
|
|
46
|
+
|
|
47
|
+
const clonedProperty = [];
|
|
48
|
+
|
|
49
|
+
for ( let i = 0, l = property.length; i < l; i ++ ) {
|
|
50
|
+
|
|
51
|
+
clonedProperty[ i ] = property[ i ].clone();
|
|
52
|
+
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
dst[ u ][ p ] = clonedProperty;
|
|
56
|
+
|
|
57
|
+
} else {
|
|
58
|
+
|
|
59
|
+
dst[ u ][ p ] = property.slice();
|
|
60
|
+
|
|
61
|
+
}
|
|
49
62
|
|
|
50
63
|
} else {
|
|
51
64
|
|
|
@@ -89,6 +102,15 @@ export function mergeUniforms( uniforms ) {
|
|
|
89
102
|
|
|
90
103
|
}
|
|
91
104
|
|
|
105
|
+
function isThreeObject( property ) {
|
|
106
|
+
|
|
107
|
+
return ( property && ( property.isColor ||
|
|
108
|
+
property.isMatrix3 || property.isMatrix4 ||
|
|
109
|
+
property.isVector2 || property.isVector3 || property.isVector4 ||
|
|
110
|
+
property.isTexture || property.isQuaternion ) );
|
|
111
|
+
|
|
112
|
+
}
|
|
113
|
+
|
|
92
114
|
export function cloneUniformsGroups( src ) {
|
|
93
115
|
|
|
94
116
|
const dst = [];
|
|
@@ -19,6 +19,7 @@ function WebGLAnimation() {
|
|
|
19
19
|
|
|
20
20
|
if ( isAnimating === true ) return;
|
|
21
21
|
if ( animationLoop === null ) return;
|
|
22
|
+
if ( context === null ) return;
|
|
22
23
|
|
|
23
24
|
requestId = context.requestAnimationFrame( onAnimationFrame );
|
|
24
25
|
|
|
@@ -28,7 +29,7 @@ function WebGLAnimation() {
|
|
|
28
29
|
|
|
29
30
|
stop: function () {
|
|
30
31
|
|
|
31
|
-
context.cancelAnimationFrame( requestId );
|
|
32
|
+
if ( context !== null ) context.cancelAnimationFrame( requestId );
|
|
32
33
|
|
|
33
34
|
isAnimating = false;
|
|
34
35
|
|
|
@@ -4,15 +4,17 @@ import { PlaneGeometry } from '../../geometries/PlaneGeometry.js';
|
|
|
4
4
|
import { ShaderMaterial } from '../../materials/ShaderMaterial.js';
|
|
5
5
|
import { Color } from '../../math/Color.js';
|
|
6
6
|
import { ColorManagement } from '../../math/ColorManagement.js';
|
|
7
|
-
import {
|
|
7
|
+
import { Matrix3 } from '../../math/Matrix3.js';
|
|
8
8
|
import { Matrix4 } from '../../math/Matrix4.js';
|
|
9
9
|
import { Mesh } from '../../objects/Mesh.js';
|
|
10
10
|
import { ShaderLib } from '../shaders/ShaderLib.js';
|
|
11
11
|
import { cloneUniforms, getUnlitUniformColorSpace } from '../shaders/UniformsUtils.js';
|
|
12
12
|
|
|
13
13
|
const _rgb = { r: 0, b: 0, g: 0 };
|
|
14
|
-
const _e1 = /*@__PURE__*/ new Euler();
|
|
15
14
|
const _m1 = /*@__PURE__*/ new Matrix4();
|
|
15
|
+
const _m = /*@__PURE__*/ new Matrix3();
|
|
16
|
+
|
|
17
|
+
_m.set( - 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0 );
|
|
16
18
|
|
|
17
19
|
function WebGLBackground( renderer, environments, state, objects, alpha, premultipliedAlpha ) {
|
|
18
20
|
|
|
@@ -130,24 +132,22 @@ function WebGLBackground( renderer, environments, state, objects, alpha, premult
|
|
|
130
132
|
|
|
131
133
|
}
|
|
132
134
|
|
|
133
|
-
_e1.copy( scene.backgroundRotation );
|
|
134
135
|
|
|
135
|
-
|
|
136
|
-
|
|
136
|
+
boxMesh.material.uniforms.envMap.value = background;
|
|
137
|
+
boxMesh.material.uniforms.backgroundBlurriness.value = scene.backgroundBlurriness;
|
|
138
|
+
boxMesh.material.uniforms.backgroundIntensity.value = scene.backgroundIntensity;
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
// note: since the matrix is orthonormal, we can use the more-efficient transpose() in lieu of invert()
|
|
142
|
+
boxMesh.material.uniforms.backgroundRotation.value.setFromMatrix4( _m1.makeRotationFromEuler( scene.backgroundRotation ) ).transpose();
|
|
137
143
|
|
|
138
144
|
if ( background.isCubeTexture && background.isRenderTargetTexture === false ) {
|
|
139
145
|
|
|
140
|
-
|
|
141
|
-
_e1.y *= - 1;
|
|
142
|
-
_e1.z *= - 1;
|
|
146
|
+
boxMesh.material.uniforms.backgroundRotation.value.premultiply( _m );
|
|
143
147
|
|
|
144
148
|
}
|
|
145
149
|
|
|
146
|
-
|
|
147
|
-
boxMesh.material.uniforms.flipEnvMap.value = ( background.isCubeTexture && background.isRenderTargetTexture === false ) ? - 1 : 1;
|
|
148
|
-
boxMesh.material.uniforms.backgroundBlurriness.value = scene.backgroundBlurriness;
|
|
149
|
-
boxMesh.material.uniforms.backgroundIntensity.value = scene.backgroundIntensity;
|
|
150
|
-
boxMesh.material.uniforms.backgroundRotation.value.setFromMatrix4( _m1.makeRotationFromEuler( _e1 ) );
|
|
150
|
+
|
|
151
151
|
boxMesh.material.toneMapped = ColorManagement.getTransfer( background.colorSpace ) !== SRGBTransfer;
|
|
152
152
|
|
|
153
153
|
if ( currentBackground !== background ||
|
|
@@ -44,44 +44,12 @@ function WebGLBufferRenderer( gl, extensions, info ) {
|
|
|
44
44
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
function renderMultiDrawInstances( starts, counts, drawCount, primcount ) {
|
|
48
|
-
|
|
49
|
-
if ( drawCount === 0 ) return;
|
|
50
|
-
|
|
51
|
-
const extension = extensions.get( 'WEBGL_multi_draw' );
|
|
52
|
-
|
|
53
|
-
if ( extension === null ) {
|
|
54
|
-
|
|
55
|
-
for ( let i = 0; i < starts.length; i ++ ) {
|
|
56
|
-
|
|
57
|
-
renderInstances( starts[ i ], counts[ i ], primcount[ i ] );
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
} else {
|
|
62
|
-
|
|
63
|
-
extension.multiDrawArraysInstancedWEBGL( mode, starts, 0, counts, 0, primcount, 0, drawCount );
|
|
64
|
-
|
|
65
|
-
let elementCount = 0;
|
|
66
|
-
for ( let i = 0; i < drawCount; i ++ ) {
|
|
67
|
-
|
|
68
|
-
elementCount += counts[ i ] * primcount[ i ];
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
info.update( elementCount, mode, 1 );
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
}
|
|
77
|
-
|
|
78
47
|
//
|
|
79
48
|
|
|
80
49
|
this.setMode = setMode;
|
|
81
50
|
this.render = render;
|
|
82
51
|
this.renderInstances = renderInstances;
|
|
83
52
|
this.renderMultiDraw = renderMultiDraw;
|
|
84
|
-
this.renderMultiDrawInstances = renderMultiDrawInstances;
|
|
85
53
|
|
|
86
54
|
}
|
|
87
55
|
|
|
@@ -95,6 +95,12 @@ function WebGLCapabilities( gl, extensions, parameters, utils ) {
|
|
|
95
95
|
const logarithmicDepthBuffer = parameters.logarithmicDepthBuffer === true;
|
|
96
96
|
const reversedDepthBuffer = parameters.reversedDepthBuffer === true && extensions.has( 'EXT_clip_control' );
|
|
97
97
|
|
|
98
|
+
if ( parameters.reversedDepthBuffer === true && reversedDepthBuffer === false ) {
|
|
99
|
+
|
|
100
|
+
warn( 'WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.' );
|
|
101
|
+
|
|
102
|
+
}
|
|
103
|
+
|
|
98
104
|
const maxTextures = gl.getParameter( gl.MAX_TEXTURE_IMAGE_UNITS );
|
|
99
105
|
const maxVertexTextures = gl.getParameter( gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS );
|
|
100
106
|
const maxTextureSize = gl.getParameter( gl.MAX_TEXTURE_SIZE );
|
|
@@ -54,37 +54,6 @@ function WebGLIndexedBufferRenderer( gl, extensions, info ) {
|
|
|
54
54
|
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
function renderMultiDrawInstances( starts, counts, drawCount, primcount ) {
|
|
58
|
-
|
|
59
|
-
if ( drawCount === 0 ) return;
|
|
60
|
-
|
|
61
|
-
const extension = extensions.get( 'WEBGL_multi_draw' );
|
|
62
|
-
|
|
63
|
-
if ( extension === null ) {
|
|
64
|
-
|
|
65
|
-
for ( let i = 0; i < starts.length; i ++ ) {
|
|
66
|
-
|
|
67
|
-
renderInstances( starts[ i ] / bytesPerElement, counts[ i ], primcount[ i ] );
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
} else {
|
|
72
|
-
|
|
73
|
-
extension.multiDrawElementsInstancedWEBGL( mode, counts, 0, type, starts, 0, primcount, 0, drawCount );
|
|
74
|
-
|
|
75
|
-
let elementCount = 0;
|
|
76
|
-
for ( let i = 0; i < drawCount; i ++ ) {
|
|
77
|
-
|
|
78
|
-
elementCount += counts[ i ] * primcount[ i ];
|
|
79
|
-
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
info.update( elementCount, mode, 1 );
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
}
|
|
87
|
-
|
|
88
57
|
//
|
|
89
58
|
|
|
90
59
|
this.setMode = setMode;
|
|
@@ -92,7 +61,6 @@ function WebGLIndexedBufferRenderer( gl, extensions, info ) {
|
|
|
92
61
|
this.render = render;
|
|
93
62
|
this.renderInstances = renderInstances;
|
|
94
63
|
this.renderMultiDraw = renderMultiDraw;
|
|
95
|
-
this.renderMultiDrawInstances = renderMultiDrawInstances;
|
|
96
64
|
|
|
97
65
|
}
|
|
98
66
|
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { BackSide } from '../../constants.js';
|
|
2
2
|
import { getUnlitUniformColorSpace } from '../shaders/UniformsUtils.js';
|
|
3
|
-
import {
|
|
3
|
+
import { Matrix3 } from '../../math/Matrix3.js';
|
|
4
4
|
import { Matrix4 } from '../../math/Matrix4.js';
|
|
5
5
|
|
|
6
|
-
const _e1 = /*@__PURE__*/ new Euler();
|
|
7
6
|
const _m1 = /*@__PURE__*/ new Matrix4();
|
|
7
|
+
const _m = /*@__PURE__*/ new Matrix3();
|
|
8
|
+
|
|
9
|
+
_m.set( - 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0 );
|
|
8
10
|
|
|
9
11
|
function WebGLMaterials( renderer, properties ) {
|
|
10
12
|
|
|
@@ -39,7 +41,11 @@ function WebGLMaterials( renderer, properties ) {
|
|
|
39
41
|
|
|
40
42
|
function refreshMaterialUniforms( uniforms, material, pixelRatio, height, transmissionRenderTarget ) {
|
|
41
43
|
|
|
42
|
-
if ( material.
|
|
44
|
+
if ( material.isNodeMaterial ) {
|
|
45
|
+
|
|
46
|
+
material.uniformsNeedUpdate = false;
|
|
47
|
+
|
|
48
|
+
} else if ( material.isMeshBasicMaterial ) {
|
|
43
49
|
|
|
44
50
|
refreshUniformsCommon( uniforms, material );
|
|
45
51
|
|
|
@@ -247,23 +253,16 @@ function WebGLMaterials( renderer, properties ) {
|
|
|
247
253
|
|
|
248
254
|
uniforms.envMap.value = envMap;
|
|
249
255
|
|
|
250
|
-
|
|
256
|
+
// note: since the matrix is orthonormal, we can use the more-efficient transpose() in lieu of invert()
|
|
257
|
+
uniforms.envMapRotation.value.setFromMatrix4( _m1.makeRotationFromEuler( envMapRotation ) ).transpose();
|
|
251
258
|
|
|
252
|
-
// accommodate left-handed frame
|
|
253
|
-
_e1.x *= - 1; _e1.y *= - 1; _e1.z *= - 1;
|
|
254
259
|
|
|
255
260
|
if ( envMap.isCubeTexture && envMap.isRenderTargetTexture === false ) {
|
|
256
261
|
|
|
257
|
-
|
|
258
|
-
_e1.y *= - 1;
|
|
259
|
-
_e1.z *= - 1;
|
|
262
|
+
uniforms.envMapRotation.value.premultiply( _m );
|
|
260
263
|
|
|
261
264
|
}
|
|
262
265
|
|
|
263
|
-
uniforms.envMapRotation.value.setFromMatrix4( _m1.makeRotationFromEuler( _e1 ) );
|
|
264
|
-
|
|
265
|
-
uniforms.flipEnvMap.value = ( envMap.isCubeTexture && envMap.isRenderTargetTexture === false ) ? - 1 : 1;
|
|
266
|
-
|
|
267
266
|
uniforms.reflectivity.value = material.reflectivity;
|
|
268
267
|
uniforms.ior.value = material.ior;
|
|
269
268
|
uniforms.refractionRatio.value = material.refractionRatio;
|
|
@@ -15,6 +15,7 @@ import { Float32BufferAttribute } from '../../core/BufferAttribute.js';
|
|
|
15
15
|
import { RawShaderMaterial } from '../../materials/RawShaderMaterial.js';
|
|
16
16
|
import { Mesh } from '../../objects/Mesh.js';
|
|
17
17
|
import { OrthographicCamera } from '../../cameras/OrthographicCamera.js';
|
|
18
|
+
import { DepthTexture } from '../../textures/DepthTexture.js';
|
|
18
19
|
import { WebGLRenderTarget } from '../WebGLRenderTarget.js';
|
|
19
20
|
import { ColorManagement } from '../../math/ColorManagement.js';
|
|
20
21
|
|
|
@@ -34,7 +35,8 @@ function WebGLOutput( type, width, height, depth, stencil ) {
|
|
|
34
35
|
const targetA = new WebGLRenderTarget( width, height, {
|
|
35
36
|
type: type,
|
|
36
37
|
depthBuffer: depth,
|
|
37
|
-
stencilBuffer: stencil
|
|
38
|
+
stencilBuffer: stencil,
|
|
39
|
+
depthTexture: depth ? new DepthTexture( width, height ) : undefined
|
|
38
40
|
} );
|
|
39
41
|
|
|
40
42
|
const targetB = new WebGLRenderTarget( width, height, {
|
|
@@ -255,6 +257,7 @@ function WebGLOutput( type, width, height, depth, stencil ) {
|
|
|
255
257
|
|
|
256
258
|
this.dispose = function () {
|
|
257
259
|
|
|
260
|
+
if ( targetA.depthTexture ) targetA.depthTexture.dispose();
|
|
258
261
|
targetA.dispose();
|
|
259
262
|
targetB.dispose();
|
|
260
263
|
geometry.dispose();
|
|
@@ -574,6 +574,7 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
|
|
|
574
574
|
//
|
|
575
575
|
|
|
576
576
|
parameters.vertexTangents && parameters.flatShading === false ? '#define USE_TANGENT' : '',
|
|
577
|
+
parameters.vertexNormals ? '#define HAS_NORMAL' : '',
|
|
577
578
|
parameters.vertexColors ? '#define USE_COLOR' : '',
|
|
578
579
|
parameters.vertexAlphas ? '#define USE_COLOR_ALPHA' : '',
|
|
579
580
|
parameters.vertexUv1s ? '#define USE_UV1' : '',
|
|
@@ -710,6 +711,7 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
|
|
|
710
711
|
parameters.normalMapMode === TriPlanarMapping ? '#define USE_NORMALMAP_TRIPLANAR' : parameters.normalMapMode === CylindricalMapping ? '#define USE_NORMALMAP_CYLINDRICAL' : parameters.normalMapMode === UVMapping ? '#define USE_NORMALMAP_UV' : '',
|
|
711
712
|
parameters.normalMapObjectSpace && [ UVMapping, CylindricalMapping ].includes( parameters.normalMapMode ) ? '#define USE_NORMALMAP_OBJECTSPACE' : '',
|
|
712
713
|
parameters.normalMapTangentSpace && [ UVMapping, CylindricalMapping ].includes( parameters.normalMapMode ) ? '#define USE_NORMALMAP_TANGENTSPACE' : '',
|
|
714
|
+
parameters.packedNormalMap ? '#define USE_PACKED_NORMALMAP' : '',
|
|
713
715
|
parameters.emissiveMap ? '#define USE_EMISSIVEMAP' : '',
|
|
714
716
|
|
|
715
717
|
parameters.anisotropy ? '#define USE_ANISOTROPY' : '',
|
|
@@ -774,6 +776,8 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
|
|
|
774
776
|
|
|
775
777
|
parameters.numLightProbes > 0 ? '#define USE_LIGHT_PROBES' : '',
|
|
776
778
|
|
|
779
|
+
parameters.numLightProbeGrids > 0 ? '#define USE_LIGHT_PROBES_GRID' : '',
|
|
780
|
+
|
|
777
781
|
parameters.decodeVideoTexture ? '#define DECODE_VIDEO_TEXTURE' : '',
|
|
778
782
|
parameters.decodeVideoTextureEmissive ? '#define DECODE_VIDEO_TEXTURE_EMISSIVE' : '',
|
|
779
783
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BackSide, DoubleSide, CubeUVReflectionMapping, ObjectSpaceNormalMap, TangentSpaceNormalMap, NoToneMapping, NormalBlending,
|
|
1
|
+
import { BackSide, DoubleSide, CubeUVReflectionMapping, ObjectSpaceNormalMap, TangentSpaceNormalMap, NoToneMapping, NormalBlending, SRGBTransfer, UVMapping, RGFormat, RG11_EAC_Format, RED_GREEN_RGTC2_Format } from '../../constants.js';
|
|
2
2
|
import { Layers } from '../../core/Layers.js';
|
|
3
3
|
import { WebGLProgram } from './WebGLProgram.js';
|
|
4
4
|
import { WebGLShaderCache } from './WebGLShaderCache.js';
|
|
@@ -7,6 +7,12 @@ import { UniformsUtils } from '../shaders/UniformsUtils.js';
|
|
|
7
7
|
import { ColorManagement } from '../../math/ColorManagement.js';
|
|
8
8
|
import { warn } from '../../utils.js';
|
|
9
9
|
|
|
10
|
+
function isPackedRGFormat( format ) {
|
|
11
|
+
|
|
12
|
+
return format === RGFormat || format === RG11_EAC_Format || format === RED_GREEN_RGTC2_Format;
|
|
13
|
+
|
|
14
|
+
}
|
|
15
|
+
|
|
10
16
|
function WebGLPrograms( renderer, environments, extensions, capabilities, bindingStates, clipping ) {
|
|
11
17
|
|
|
12
18
|
const _programLayers = new Layers();
|
|
@@ -47,7 +53,7 @@ function WebGLPrograms( renderer, environments, extensions, capabilities, bindin
|
|
|
47
53
|
|
|
48
54
|
}
|
|
49
55
|
|
|
50
|
-
function getParameters( material, lights, shadows, scene, object ) {
|
|
56
|
+
function getParameters( material, lights, shadows, scene, object, lightProbeGrids ) {
|
|
51
57
|
|
|
52
58
|
const fog = scene.fog;
|
|
53
59
|
const geometry = object.geometry;
|
|
@@ -163,6 +169,7 @@ function WebGLPrograms( renderer, environments, extensions, capabilities, bindin
|
|
|
163
169
|
const HAS_ALPHAHASH = !! material.alphaHash;
|
|
164
170
|
|
|
165
171
|
const HAS_OCTAHEDRAL_NORMALS = object.geometry.attributes.normalOctahedral !== undefined;
|
|
172
|
+
const HAS_VERTEX_NORMALS = geometry.attributes.normal !== undefined || HAS_OCTAHEDRAL_NORMALS;
|
|
166
173
|
|
|
167
174
|
const HAS_EXTENSIONS = !! material.extensions;
|
|
168
175
|
|
|
@@ -204,7 +211,7 @@ function WebGLPrograms( renderer, environments, extensions, capabilities, bindin
|
|
|
204
211
|
instancingColor: IS_INSTANCEDMESH && object.instanceColor !== null,
|
|
205
212
|
instancingMorph: IS_INSTANCEDMESH && object.morphTexture !== null,
|
|
206
213
|
|
|
207
|
-
outputColorSpace: ( currentRenderTarget === null ) ? renderer.outputColorSpace : ( currentRenderTarget.isXRRenderTarget === true ? currentRenderTarget.texture.colorSpace :
|
|
214
|
+
outputColorSpace: ( currentRenderTarget === null ) ? renderer.outputColorSpace : ( currentRenderTarget.isXRRenderTarget === true ? currentRenderTarget.texture.colorSpace : ColorManagement.workingColorSpace ),
|
|
208
215
|
alphaToCoverage: !! material.alphaToCoverage,
|
|
209
216
|
|
|
210
217
|
map: HAS_MAP,
|
|
@@ -221,6 +228,7 @@ function WebGLPrograms( renderer, environments, extensions, capabilities, bindin
|
|
|
221
228
|
|
|
222
229
|
normalMapObjectSpace: HAS_NORMALMAP && material.normalMapType === ObjectSpaceNormalMap,
|
|
223
230
|
normalMapTangentSpace: HAS_NORMALMAP && material.normalMapType === TangentSpaceNormalMap,
|
|
231
|
+
packedNormalMap: HAS_NORMALMAP && material.normalMapType === TangentSpaceNormalMap && isPackedRGFormat( material.normalMap.format ),
|
|
224
232
|
|
|
225
233
|
metalnessMap: HAS_METALNESSMAP,
|
|
226
234
|
roughnessMap: HAS_ROUGHNESSMAP,
|
|
@@ -305,6 +313,7 @@ function WebGLPrograms( renderer, environments, extensions, capabilities, bindin
|
|
|
305
313
|
//
|
|
306
314
|
|
|
307
315
|
vertexTangents: !! geometry.attributes.tangent && ( HAS_NORMALMAP || HAS_ANISOTROPY ),
|
|
316
|
+
vertexNormals: HAS_VERTEX_NORMALS,
|
|
308
317
|
vertexColors: material.vertexColors,
|
|
309
318
|
vertexAlphas: material.vertexColors === true && !! geometry.attributes.color && geometry.attributes.color.itemSize === 4,
|
|
310
319
|
|
|
@@ -316,7 +325,7 @@ function WebGLPrograms( renderer, environments, extensions, capabilities, bindin
|
|
|
316
325
|
|
|
317
326
|
flatShading: material.wireframe === false && (
|
|
318
327
|
material.flatShading === true ||
|
|
319
|
-
(
|
|
328
|
+
( HAS_VERTEX_NORMALS === false && HAS_NORMALMAP === false &&
|
|
320
329
|
( material.isMeshLambertMaterial || material.isMeshPhongMaterial || material.isMeshStandardMaterial || material.isMeshPhysicalMaterial )
|
|
321
330
|
)
|
|
322
331
|
),
|
|
@@ -347,6 +356,8 @@ function WebGLPrograms( renderer, environments, extensions, capabilities, bindin
|
|
|
347
356
|
|
|
348
357
|
numLightProbes: lights.numLightProbes,
|
|
349
358
|
|
|
359
|
+
numLightProbeGrids: lightProbeGrids.length,
|
|
360
|
+
|
|
350
361
|
numClippingPlanes: clipping.numPlanes,
|
|
351
362
|
numClipIntersection: clipping.numIntersection,
|
|
352
363
|
|
|
@@ -543,6 +554,10 @@ function WebGLPrograms( renderer, environments, extensions, capabilities, bindin
|
|
|
543
554
|
_programLayers.enable( 22 );
|
|
544
555
|
if ( parameters.normalOctahedral )
|
|
545
556
|
_programLayers.enable( 23 );
|
|
557
|
+
if ( parameters.packedNormalMap )
|
|
558
|
+
_programLayers.enable( 24 );
|
|
559
|
+
if ( parameters.vertexNormals )
|
|
560
|
+
_programLayers.enable( 25 );
|
|
546
561
|
|
|
547
562
|
array.push( _programLayers.mask );
|
|
548
563
|
_programLayers.disableAll();
|
|
@@ -591,6 +606,8 @@ function WebGLPrograms( renderer, environments, extensions, capabilities, bindin
|
|
|
591
606
|
_programLayers.enable( 20 );
|
|
592
607
|
if ( parameters.alphaToCoverage )
|
|
593
608
|
_programLayers.enable( 21 );
|
|
609
|
+
if ( parameters.numLightProbeGrids > 0 )
|
|
610
|
+
_programLayers.enable( 22 );
|
|
594
611
|
|
|
595
612
|
array.push( _programLayers.mask );
|
|
596
613
|
|