@plastic-software/three 0.183.4 → 0.184.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.
Files changed (277) hide show
  1. package/build/three.cjs +773 -286
  2. package/build/three.core.js +372 -110
  3. package/build/three.core.min.js +1 -1
  4. package/build/three.module.js +426 -180
  5. package/build/three.module.min.js +1 -1
  6. package/build/three.tsl.js +7 -1
  7. package/build/three.tsl.min.js +1 -1
  8. package/build/three.webgpu.js +2979 -1281
  9. package/build/three.webgpu.min.js +1 -1
  10. package/build/three.webgpu.nodes.js +2942 -1281
  11. package/build/three.webgpu.nodes.min.js +1 -1
  12. package/examples/jsm/Addons.js +11 -0
  13. package/examples/jsm/animation/CCDIKSolver.js +5 -1
  14. package/examples/jsm/controls/ArcballControls.js +4 -1
  15. package/examples/jsm/controls/DragControls.js +2 -2
  16. package/examples/jsm/controls/FirstPersonControls.js +58 -54
  17. package/examples/jsm/controls/FlyControls.js +4 -0
  18. package/examples/jsm/controls/OrbitControls.js +2 -2
  19. package/examples/jsm/controls/TrackballControls.js +2 -2
  20. package/examples/jsm/controls/TransformControls.js +34 -2
  21. package/examples/jsm/csm/CSMShadowNode.js +6 -2
  22. package/examples/jsm/exporters/GLTFExporter.js +21 -5
  23. package/examples/jsm/geometries/TextGeometry.js +18 -0
  24. package/examples/jsm/helpers/LightProbeGridHelper.js +221 -0
  25. package/examples/jsm/inspector/Extension.js +13 -0
  26. package/examples/jsm/inspector/Inspector.js +169 -114
  27. package/examples/jsm/inspector/RendererInspector.js +2 -2
  28. package/examples/jsm/inspector/extensions/extensions.json +6 -0
  29. package/examples/jsm/inspector/extensions/tsl-graph/TSLGraphEditor.js +916 -0
  30. package/examples/jsm/inspector/extensions/tsl-graph/TSLGraphLoader.js +281 -0
  31. package/examples/jsm/inspector/tabs/Memory.js +128 -0
  32. package/examples/jsm/inspector/tabs/Parameters.js +34 -2
  33. package/examples/jsm/inspector/tabs/Performance.js +2 -2
  34. package/examples/jsm/inspector/tabs/Settings.js +264 -0
  35. package/examples/jsm/inspector/tabs/Timeline.js +1611 -0
  36. package/examples/jsm/inspector/tabs/Viewer.js +105 -3
  37. package/examples/jsm/inspector/ui/Graph.js +2 -2
  38. package/examples/jsm/inspector/ui/List.js +1 -1
  39. package/examples/jsm/inspector/ui/Profiler.js +273 -176
  40. package/examples/jsm/inspector/ui/Style.js +64 -10
  41. package/examples/jsm/inspector/ui/Tab.js +39 -7
  42. package/examples/jsm/inspector/ui/Values.js +39 -2
  43. package/examples/jsm/inspector/ui/utils.js +13 -0
  44. package/examples/jsm/interaction/InteractionManager.js +226 -0
  45. package/examples/jsm/libs/meshopt_decoder.module.js +8 -8
  46. package/examples/jsm/lighting/DynamicLighting.js +82 -0
  47. package/examples/jsm/lighting/LightProbeGrid.js +651 -0
  48. package/examples/jsm/lines/LineMaterial.js +1 -1
  49. package/examples/jsm/loaders/EXRLoader.js +682 -43
  50. package/examples/jsm/loaders/FBXLoader.js +233 -33
  51. package/examples/jsm/loaders/GLTFLoader.js +24 -7
  52. package/examples/jsm/loaders/HDRLoader.js +1 -1
  53. package/examples/jsm/loaders/KTX2Loader.js +8 -2
  54. package/examples/jsm/loaders/LDrawLoader.js +39 -47
  55. package/examples/jsm/loaders/SVGLoader.js +1 -1
  56. package/examples/jsm/loaders/VTKLoader.js +5 -1
  57. package/examples/jsm/loaders/collada/ColladaComposer.js +101 -7
  58. package/examples/jsm/loaders/collada/ColladaParser.js +19 -4
  59. package/examples/jsm/loaders/usd/USDAParser.js +6 -0
  60. package/examples/jsm/loaders/usd/USDCParser.js +26 -0
  61. package/examples/jsm/loaders/usd/USDComposer.js +656 -103
  62. package/examples/jsm/misc/GPUComputationRenderer.js +2 -0
  63. package/examples/jsm/misc/RollerCoaster.js +42 -4
  64. package/examples/jsm/modifiers/TessellateModifier.js +1 -1
  65. package/examples/jsm/objects/Reflector.js +73 -25
  66. package/examples/jsm/objects/Sky.js +14 -2
  67. package/examples/jsm/objects/SkyMesh.js +23 -6
  68. package/examples/jsm/renderers/Projector.js +18 -38
  69. package/examples/jsm/renderers/SVGRenderer.js +6 -25
  70. package/examples/jsm/transpiler/GLSLDecoder.js +2 -2
  71. package/examples/jsm/tsl/WebGLNodesHandler.js +605 -0
  72. package/examples/jsm/tsl/display/AfterImageNode.js +10 -0
  73. package/examples/jsm/tsl/display/AnamorphicNode.js +11 -0
  74. package/examples/jsm/tsl/display/BilateralBlurNode.js +10 -0
  75. package/examples/jsm/tsl/display/ChromaticAberrationNode.js +3 -36
  76. package/examples/jsm/tsl/display/FSR1Node.js +477 -0
  77. package/examples/jsm/tsl/display/GTAONode.js +2 -1
  78. package/examples/jsm/tsl/display/GaussianBlurNode.js +10 -0
  79. package/examples/jsm/tsl/display/GodraysNode.js +2 -11
  80. package/examples/jsm/tsl/display/OutlineNode.js +66 -16
  81. package/examples/jsm/tsl/display/SSGINode.js +0 -4
  82. package/examples/jsm/tsl/display/SharpenNode.js +283 -0
  83. package/examples/jsm/tsl/display/TAAUNode.js +835 -0
  84. package/examples/jsm/tsl/display/TRAANode.js +48 -7
  85. package/examples/jsm/tsl/lighting/DynamicLightsNode.js +300 -0
  86. package/examples/jsm/tsl/lighting/data/AmbientLightDataNode.js +61 -0
  87. package/examples/jsm/tsl/lighting/data/DirectionalLightDataNode.js +111 -0
  88. package/examples/jsm/tsl/lighting/data/HemisphereLightDataNode.js +99 -0
  89. package/examples/jsm/tsl/lighting/data/PointLightDataNode.js +134 -0
  90. package/examples/jsm/tsl/lighting/data/SpotLightDataNode.js +161 -0
  91. package/examples/jsm/tsl/math/Bayer.js +13 -2
  92. package/examples/jsm/utils/BufferGeometryUtils.js +2 -3
  93. package/examples/jsm/utils/ColorUtils.js +76 -0
  94. package/examples/jsm/utils/SkeletonUtils.js +14 -8
  95. package/examples/jsm/webxr/XRHandMeshModel.js +36 -10
  96. package/examples/jsm/webxr/XRHandModelFactory.js +2 -1
  97. package/package.json +4 -4
  98. package/src/Three.Core.js +1 -0
  99. package/src/Three.TSL.js +6 -0
  100. package/src/Three.WebGPU.Nodes.js +3 -0
  101. package/src/Three.WebGPU.js +6 -0
  102. package/src/animation/AnimationAction.js +11 -1
  103. package/src/audio/AudioContext.js +2 -2
  104. package/src/constants.js +1 -1
  105. package/src/core/BufferAttribute.js +13 -1
  106. package/src/core/Clock.js +1 -1
  107. package/src/core/Object3D.js +1 -5
  108. package/src/core/RenderTarget.js +1 -0
  109. package/src/extras/curves/CatmullRomCurve3.js +3 -2
  110. package/src/loaders/AudioLoader.js +11 -1
  111. package/src/loaders/DataTextureLoader.js +6 -4
  112. package/src/loaders/FileLoader.js +1 -2
  113. package/src/loaders/ImageBitmapLoader.js +4 -6
  114. package/src/loaders/MaterialLoader.js +1 -1
  115. package/src/loaders/ObjectLoader.js +25 -4
  116. package/src/loaders/nodes/NodeObjectLoader.js +18 -0
  117. package/src/materials/MeshToonMaterial.js +1 -1
  118. package/src/materials/nodes/Line2NodeMaterial.js +27 -0
  119. package/src/materials/nodes/NodeMaterial.js +0 -27
  120. package/src/materials/nodes/manager/NodeMaterialObserver.js +188 -89
  121. package/src/math/Line3.js +3 -0
  122. package/src/math/Matrix2.js +13 -9
  123. package/src/math/Matrix3.js +13 -9
  124. package/src/math/Matrix4.js +13 -9
  125. package/src/math/Plane.js +4 -3
  126. package/src/math/Triangle.js +1 -1
  127. package/src/math/Vector2.js +11 -7
  128. package/src/math/Vector3.js +12 -8
  129. package/src/math/Vector4.js +13 -9
  130. package/src/nodes/Nodes.js +0 -1
  131. package/src/nodes/TSL.js +1 -1
  132. package/src/nodes/accessors/BufferAttributeNode.js +9 -3
  133. package/src/nodes/accessors/CubeTextureNode.js +7 -1
  134. package/src/nodes/accessors/MaterialProperties.js +2 -5
  135. package/src/nodes/accessors/Object3DNode.js +1 -1
  136. package/src/nodes/accessors/ReferenceBaseNode.js +2 -2
  137. package/src/nodes/accessors/ReferenceNode.js +4 -4
  138. package/src/nodes/accessors/SceneProperties.js +2 -8
  139. package/src/nodes/accessors/StorageBufferNode.js +10 -4
  140. package/src/nodes/accessors/StorageTextureNode.js +4 -9
  141. package/src/nodes/accessors/TextureNode.js +10 -2
  142. package/src/nodes/accessors/UniformArrayNode.js +2 -2
  143. package/src/nodes/code/FunctionCallNode.js +1 -1
  144. package/src/nodes/code/FunctionNode.js +1 -1
  145. package/src/nodes/core/ArrayNode.js +1 -1
  146. package/src/nodes/core/AssignNode.js +1 -1
  147. package/src/nodes/core/AttributeNode.js +1 -1
  148. package/src/nodes/core/BypassNode.js +1 -1
  149. package/src/nodes/core/ContextNode.js +1 -1
  150. package/src/nodes/core/IndexNode.js +2 -1
  151. package/src/nodes/core/InputNode.js +1 -1
  152. package/src/nodes/core/InspectorNode.js +1 -1
  153. package/src/nodes/core/IsolateNode.js +1 -1
  154. package/src/nodes/core/Node.js +83 -12
  155. package/src/nodes/core/NodeBuilder.js +117 -16
  156. package/src/nodes/core/NodeUtils.js +1 -1
  157. package/src/nodes/core/OutputStructNode.js +1 -1
  158. package/src/nodes/core/ParameterNode.js +1 -1
  159. package/src/nodes/core/StackNode.js +1 -1
  160. package/src/nodes/core/StructNode.js +1 -1
  161. package/src/nodes/core/StructTypeNode.js +1 -1
  162. package/src/nodes/core/SubBuildNode.js +1 -1
  163. package/src/nodes/core/UniformGroupNode.js +36 -6
  164. package/src/nodes/core/VarNode.js +1 -1
  165. package/src/nodes/core/VaryingNode.js +1 -1
  166. package/src/nodes/display/NormalMapNode.js +2 -2
  167. package/src/nodes/display/PassNode.js +27 -7
  168. package/src/nodes/display/RenderOutputNode.js +4 -4
  169. package/src/nodes/display/ScreenNode.js +1 -1
  170. package/src/nodes/display/ViewportDepthTextureNode.js +11 -15
  171. package/src/nodes/display/ViewportTextureNode.js +18 -7
  172. package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +2 -2
  173. package/src/nodes/geometry/RangeNode.js +1 -1
  174. package/src/nodes/gpgpu/AtomicFunctionNode.js +1 -1
  175. package/src/nodes/gpgpu/BarrierNode.js +9 -0
  176. package/src/nodes/gpgpu/ComputeBuiltinNode.js +1 -1
  177. package/src/nodes/gpgpu/ComputeNode.js +69 -44
  178. package/src/nodes/gpgpu/SubgroupFunctionNode.js +1 -1
  179. package/src/nodes/lighting/LightsNode.js +6 -27
  180. package/src/nodes/lighting/ShadowNode.js +24 -2
  181. package/src/nodes/math/BitcastNode.js +1 -1
  182. package/src/nodes/math/ConditionalNode.js +1 -1
  183. package/src/nodes/math/MathNode.js +73 -1
  184. package/src/nodes/math/OperatorNode.js +1 -1
  185. package/src/nodes/math/PackFloatNode.js +1 -1
  186. package/src/nodes/math/UnpackFloatNode.js +1 -1
  187. package/src/nodes/tsl/TSLBase.js +1 -1
  188. package/src/nodes/tsl/TSLCore.js +21 -3
  189. package/src/nodes/utils/ArrayElementNode.js +1 -1
  190. package/src/nodes/utils/ConvertNode.js +1 -1
  191. package/src/nodes/utils/DebugNode.js +1 -1
  192. package/src/nodes/utils/EventNode.js +30 -0
  193. package/src/nodes/utils/FlipNode.js +1 -1
  194. package/src/nodes/utils/FunctionOverloadingNode.js +1 -1
  195. package/src/nodes/utils/JoinNode.js +1 -1
  196. package/src/nodes/utils/MemberNode.js +1 -1
  197. package/src/nodes/utils/Remap.js +48 -0
  198. package/src/nodes/utils/RotateNode.js +1 -1
  199. package/src/nodes/utils/SetNode.js +1 -1
  200. package/src/nodes/utils/SplitNode.js +1 -1
  201. package/src/objects/BatchedMesh.js +17 -2
  202. package/src/objects/InstancedMesh.js +19 -3
  203. package/src/objects/SkinnedMesh.js +26 -9
  204. package/src/renderers/WebGLRenderer.js +147 -48
  205. package/src/renderers/common/Animation.js +3 -3
  206. package/src/renderers/common/Attributes.js +15 -1
  207. package/src/renderers/common/Backend.js +0 -8
  208. package/src/renderers/common/Background.js +2 -2
  209. package/src/renderers/common/BindGroup.js +1 -8
  210. package/src/renderers/common/Bindings.js +2 -2
  211. package/src/renderers/common/ComputePipeline.js +1 -1
  212. package/src/renderers/common/CubeRenderTarget.js +1 -1
  213. package/src/renderers/common/Info.js +333 -4
  214. package/src/renderers/common/InspectorBase.js +6 -1
  215. package/src/renderers/common/Pipelines.js +36 -3
  216. package/src/renderers/common/ReadbackBuffer.js +78 -0
  217. package/src/renderers/common/RenderBundle.js +3 -1
  218. package/src/renderers/common/RenderBundles.js +5 -2
  219. package/src/renderers/common/RenderObject.js +2 -2
  220. package/src/renderers/common/RenderObjects.js +3 -3
  221. package/src/renderers/common/RenderPipeline.js +35 -6
  222. package/src/renderers/common/Renderer.js +232 -53
  223. package/src/renderers/common/Textures.js +72 -3
  224. package/src/renderers/common/UniformsGroup.js +1 -1
  225. package/src/renderers/common/XRManager.js +34 -27
  226. package/src/renderers/common/extras/PMREMGenerator.js +23 -15
  227. package/src/renderers/common/nodes/NodeBuilderState.js +1 -1
  228. package/src/renderers/common/nodes/NodeManager.js +230 -99
  229. package/src/renderers/shaders/ShaderChunk/envmap_common_pars_fragment.glsl.js +0 -1
  230. package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +1 -1
  231. package/src/renderers/shaders/ShaderChunk/lightprobes_pars_fragment.glsl.js +80 -0
  232. package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +8 -0
  233. package/src/renderers/shaders/ShaderChunk/lights_pars_begin.glsl.js +2 -0
  234. package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +1 -3
  235. package/src/renderers/shaders/ShaderChunk/normal_fragment_maps.glsl.js +7 -0
  236. package/src/renderers/shaders/ShaderChunk/premultiplied_alpha_fragment.glsl.js +0 -1
  237. package/src/renderers/shaders/ShaderChunk/shadowmap_vertex.glsl.js +12 -2
  238. package/src/renderers/shaders/ShaderChunk.js +2 -0
  239. package/src/renderers/shaders/ShaderLib/backgroundCube.glsl.js +1 -2
  240. package/src/renderers/shaders/ShaderLib.js +0 -1
  241. package/src/renderers/shaders/UniformsLib.js +7 -2
  242. package/src/renderers/shaders/UniformsUtils.js +27 -5
  243. package/src/renderers/webgl/WebGLAnimation.js +2 -1
  244. package/src/renderers/webgl/WebGLBackground.js +13 -13
  245. package/src/renderers/webgl/WebGLBufferRenderer.js +0 -32
  246. package/src/renderers/webgl/WebGLCapabilities.js +6 -0
  247. package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +0 -32
  248. package/src/renderers/webgl/WebGLMaterials.js +12 -13
  249. package/src/renderers/webgl/WebGLOutput.js +4 -1
  250. package/src/renderers/webgl/WebGLProgram.js +4 -0
  251. package/src/renderers/webgl/WebGLPrograms.js +19 -3
  252. package/src/renderers/webgl/WebGLRenderStates.js +13 -2
  253. package/src/renderers/webgl/WebGLState.js +43 -0
  254. package/src/renderers/webgl/WebGLTextures.js +129 -26
  255. package/src/renderers/webgl/WebGLUniformsGroups.js +19 -0
  256. package/src/renderers/webgl-fallback/WebGLBackend.js +106 -65
  257. package/src/renderers/webgl-fallback/WebGLBufferRenderer.js +0 -41
  258. package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +29 -51
  259. package/src/renderers/webgl-fallback/utils/WebGLAttributeUtils.js +53 -19
  260. package/src/renderers/webgl-fallback/utils/WebGLCapabilities.js +25 -0
  261. package/src/renderers/webgl-fallback/utils/WebGLState.js +42 -1
  262. package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +63 -50
  263. package/src/renderers/webgl-fallback/utils/WebGLTimestampQueryPool.js +1 -1
  264. package/src/renderers/webgpu/WebGPUBackend.js +160 -146
  265. package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +55 -33
  266. package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +103 -17
  267. package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +1 -1
  268. package/src/renderers/webgpu/utils/WebGPUCapabilities.js +48 -0
  269. package/src/renderers/webgpu/utils/WebGPUConstants.js +8 -0
  270. package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +91 -17
  271. package/src/renderers/webgpu/utils/WebGPUUtils.js +18 -2
  272. package/src/renderers/webxr/WebXRController.js +12 -0
  273. package/src/textures/HTMLTexture.js +74 -0
  274. package/src/textures/Source.js +1 -1
  275. package/src/textures/Texture.js +13 -2
  276. package/src/utils.js +23 -1
  277. 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 )
@@ -211,4 +211,6 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi
211
211
  }
212
212
 
213
213
  #endif
214
+
215
+ #include <lightprobes_pars_fragment>
214
216
  `;
@@ -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
- float v = 0.5 / ( gv + gl );
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 );
@@ -1,7 +1,6 @@
1
1
  export default /* glsl */`
2
2
  #ifdef PREMULTIPLIED_ALPHA
3
3
 
4
- // Get normal blending with premultipled, use with CustomBlending, OneFactor, OneMinusSrcAlphaFactor, AddEquation.
5
4
  gl_FragColor.rgb *= gl_FragColor.a;
6
5
 
7
6
  #endif
@@ -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
- // Offsetting the position used for querying occlusion along the world normal can be used to reduce shadow acne.
6
- vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
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 * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
42
+ vec4 texColor = textureCube( envMap, backgroundRotation * vWorldDirection );
44
43
 
45
44
  #elif defined( ENVMAP_TYPE_CUBE_UV )
46
45
 
@@ -232,7 +232,6 @@ const ShaderLib = {
232
232
 
233
233
  uniforms: {
234
234
  envMap: { value: null },
235
- flipEnvMap: { value: - 1 },
236
235
  backgroundBlurriness: { value: 0 },
237
236
  backgroundIntensity: { value: 1 },
238
237
  backgroundRotation: { value: /*@__PURE__*/ new Matrix3() }
@@ -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 && ( property.isColor ||
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
- dst[ u ][ p ] = property.slice();
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 { Euler } from '../../math/Euler.js';
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
- // accommodate left-handed frame
136
- _e1.x *= - 1; _e1.y *= - 1; _e1.z *= - 1;
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
- // environment maps which are not cube render targets or PMREMs follow a different convention
141
- _e1.y *= - 1;
142
- _e1.z *= - 1;
146
+ boxMesh.material.uniforms.backgroundRotation.value.premultiply( _m );
143
147
 
144
148
  }
145
149
 
146
- boxMesh.material.uniforms.envMap.value = background;
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 { Euler } from '../../math/Euler.js';
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.isMeshBasicMaterial ) {
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
- _e1.copy( envMapRotation );
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
- // environment maps which are not cube render targets or PMREMs follow a different convention
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, LinearSRGBColorSpace, SRGBTransfer, UVMapping } from '../../constants.js';
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;
@@ -204,7 +210,7 @@ function WebGLPrograms( renderer, environments, extensions, capabilities, bindin
204
210
  instancingColor: IS_INSTANCEDMESH && object.instanceColor !== null,
205
211
  instancingMorph: IS_INSTANCEDMESH && object.morphTexture !== null,
206
212
 
207
- outputColorSpace: ( currentRenderTarget === null ) ? renderer.outputColorSpace : ( currentRenderTarget.isXRRenderTarget === true ? currentRenderTarget.texture.colorSpace : LinearSRGBColorSpace ),
213
+ outputColorSpace: ( currentRenderTarget === null ) ? renderer.outputColorSpace : ( currentRenderTarget.isXRRenderTarget === true ? currentRenderTarget.texture.colorSpace : ColorManagement.workingColorSpace ),
208
214
  alphaToCoverage: !! material.alphaToCoverage,
209
215
 
210
216
  map: HAS_MAP,
@@ -221,6 +227,7 @@ function WebGLPrograms( renderer, environments, extensions, capabilities, bindin
221
227
 
222
228
  normalMapObjectSpace: HAS_NORMALMAP && material.normalMapType === ObjectSpaceNormalMap,
223
229
  normalMapTangentSpace: HAS_NORMALMAP && material.normalMapType === TangentSpaceNormalMap,
230
+ packedNormalMap: HAS_NORMALMAP && material.normalMapType === TangentSpaceNormalMap && isPackedRGFormat( material.normalMap.format ),
224
231
 
225
232
  metalnessMap: HAS_METALNESSMAP,
226
233
  roughnessMap: HAS_ROUGHNESSMAP,
@@ -305,6 +312,7 @@ function WebGLPrograms( renderer, environments, extensions, capabilities, bindin
305
312
  //
306
313
 
307
314
  vertexTangents: !! geometry.attributes.tangent && ( HAS_NORMALMAP || HAS_ANISOTROPY ),
315
+ vertexNormals: !! geometry.attributes.normal,
308
316
  vertexColors: material.vertexColors,
309
317
  vertexAlphas: material.vertexColors === true && !! geometry.attributes.color && geometry.attributes.color.itemSize === 4,
310
318
 
@@ -347,6 +355,8 @@ function WebGLPrograms( renderer, environments, extensions, capabilities, bindin
347
355
 
348
356
  numLightProbes: lights.numLightProbes,
349
357
 
358
+ numLightProbeGrids: lightProbeGrids.length,
359
+
350
360
  numClippingPlanes: clipping.numPlanes,
351
361
  numClipIntersection: clipping.numIntersection,
352
362
 
@@ -543,6 +553,10 @@ function WebGLPrograms( renderer, environments, extensions, capabilities, bindin
543
553
  _programLayers.enable( 22 );
544
554
  if ( parameters.normalOctahedral )
545
555
  _programLayers.enable( 23 );
556
+ if ( parameters.packedNormalMap )
557
+ _programLayers.enable( 24 );
558
+ if ( parameters.vertexNormals )
559
+ _programLayers.enable( 25 );
546
560
 
547
561
  array.push( _programLayers.mask );
548
562
  _programLayers.disableAll();
@@ -591,6 +605,8 @@ function WebGLPrograms( renderer, environments, extensions, capabilities, bindin
591
605
  _programLayers.enable( 20 );
592
606
  if ( parameters.alphaToCoverage )
593
607
  _programLayers.enable( 21 );
608
+ if ( parameters.numLightProbeGrids > 0 )
609
+ _programLayers.enable( 22 );
594
610
 
595
611
  array.push( _programLayers.mask );
596
612