super-three 0.155.0 → 0.157.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 (268) hide show
  1. package/build/three.cjs +361 -324
  2. package/build/three.js +361 -324
  3. package/build/three.min.js +2 -2
  4. package/build/three.module.js +354 -323
  5. package/build/three.module.min.js +1 -1
  6. package/examples/jsm/capabilities/WebGL.js +17 -0
  7. package/examples/jsm/controls/DragControls.js +3 -2
  8. package/examples/jsm/controls/OrbitControls.js +13 -5
  9. package/examples/jsm/csm/CSMShader.js +59 -21
  10. package/examples/jsm/exporters/EXRExporter.js +102 -24
  11. package/examples/jsm/exporters/GLTFExporter.js +1 -1
  12. package/examples/jsm/libs/rhino3dm/rhino3dm.js +8726 -4
  13. package/examples/jsm/libs/rhino3dm/rhino3dm.module.js +8737 -4
  14. package/examples/jsm/libs/rhino3dm/rhino3dm.wasm +0 -0
  15. package/examples/jsm/libs/tween.module.js +790 -735
  16. package/examples/jsm/libs/utif.module.js +1644 -1558
  17. package/examples/jsm/lights/LightProbeGenerator.js +37 -3
  18. package/examples/jsm/lines/LineMaterial.js +90 -156
  19. package/examples/jsm/loaders/3DMLoader.js +378 -104
  20. package/examples/jsm/loaders/DDSLoader.js +46 -3
  21. package/examples/jsm/loaders/EXRLoader.js +4 -4
  22. package/examples/jsm/loaders/FBXLoader.js +2 -0
  23. package/examples/jsm/loaders/GLTFLoader.js +18 -8
  24. package/examples/jsm/loaders/KTX2Loader.js +126 -77
  25. package/examples/jsm/loaders/LDrawLoader.js +22 -16
  26. package/examples/jsm/loaders/LogLuvLoader.js +2 -2
  27. package/examples/jsm/loaders/MMDLoader.js +10 -7
  28. package/examples/jsm/loaders/RGBELoader.js +48 -66
  29. package/examples/jsm/loaders/STLLoader.js +7 -0
  30. package/examples/jsm/loaders/USDZLoader.js +215 -12
  31. package/examples/jsm/materials/MeshGouraudMaterial.js +22 -18
  32. package/examples/jsm/nodes/Nodes.js +8 -1
  33. package/examples/jsm/nodes/accessors/BitangentNode.js +1 -1
  34. package/examples/jsm/nodes/accessors/BufferAttributeNode.js +30 -4
  35. package/examples/jsm/nodes/accessors/BufferNode.js +1 -1
  36. package/examples/jsm/nodes/accessors/CameraNode.js +1 -1
  37. package/examples/jsm/nodes/accessors/CubeTextureNode.js +19 -4
  38. package/examples/jsm/nodes/accessors/ExtendedMaterialNode.js +4 -5
  39. package/examples/jsm/nodes/accessors/InstanceNode.js +2 -2
  40. package/examples/jsm/nodes/accessors/LineMaterialNode.js +29 -0
  41. package/examples/jsm/nodes/accessors/MaterialNode.js +23 -13
  42. package/examples/jsm/nodes/accessors/MaterialReferenceNode.js +12 -9
  43. package/examples/jsm/nodes/accessors/ModelNode.js +1 -1
  44. package/examples/jsm/nodes/accessors/ModelViewProjectionNode.js +5 -4
  45. package/examples/jsm/nodes/accessors/MorphNode.js +4 -4
  46. package/examples/jsm/nodes/accessors/NormalNode.js +1 -1
  47. package/examples/jsm/nodes/accessors/Object3DNode.js +3 -3
  48. package/examples/jsm/nodes/accessors/PointUVNode.js +1 -1
  49. package/examples/jsm/nodes/accessors/PositionNode.js +1 -1
  50. package/examples/jsm/nodes/accessors/ReferenceNode.js +13 -7
  51. package/examples/jsm/nodes/accessors/ReflectVectorNode.js +2 -2
  52. package/examples/jsm/nodes/accessors/SceneNode.js +2 -2
  53. package/examples/jsm/nodes/accessors/SkinningNode.js +2 -2
  54. package/examples/jsm/nodes/accessors/StorageBufferNode.js +1 -1
  55. package/examples/jsm/nodes/accessors/TangentNode.js +1 -1
  56. package/examples/jsm/nodes/accessors/TextureBicubicNode.js +2 -2
  57. package/examples/jsm/nodes/accessors/TextureNode.js +18 -8
  58. package/examples/jsm/nodes/accessors/TextureSizeNode.js +2 -2
  59. package/examples/jsm/nodes/accessors/TextureStoreNode.js +29 -0
  60. package/examples/jsm/nodes/accessors/UVNode.js +1 -1
  61. package/examples/jsm/nodes/accessors/UserDataNode.js +2 -2
  62. package/examples/jsm/nodes/code/CodeNode.js +1 -1
  63. package/examples/jsm/nodes/code/ExpressionNode.js +1 -1
  64. package/examples/jsm/nodes/code/FunctionCallNode.js +1 -1
  65. package/examples/jsm/nodes/code/FunctionNode.js +18 -7
  66. package/examples/jsm/nodes/code/ScriptableNode.js +2 -2
  67. package/examples/jsm/nodes/code/ScriptableValueNode.js +2 -2
  68. package/examples/jsm/nodes/core/ArrayUniformNode.js +1 -1
  69. package/examples/jsm/nodes/core/AttributeNode.js +3 -3
  70. package/examples/jsm/nodes/core/BypassNode.js +1 -1
  71. package/examples/jsm/nodes/core/CacheNode.js +1 -1
  72. package/examples/jsm/nodes/core/ConstNode.js +1 -1
  73. package/examples/jsm/nodes/core/ContextNode.js +2 -2
  74. package/examples/jsm/nodes/core/IndexNode.js +1 -1
  75. package/examples/jsm/nodes/core/InputNode.js +1 -1
  76. package/examples/jsm/nodes/core/Node.js +45 -14
  77. package/examples/jsm/nodes/core/NodeBuilder.js +83 -15
  78. package/examples/jsm/nodes/core/NodeFrame.js +37 -14
  79. package/examples/jsm/nodes/core/NodeUniform.js +1 -1
  80. package/examples/jsm/nodes/core/OutputStructNode.js +62 -0
  81. package/examples/jsm/nodes/core/PropertyNode.js +3 -1
  82. package/examples/jsm/nodes/core/StackNode.js +5 -5
  83. package/examples/jsm/nodes/core/StructTypeNode.js +24 -0
  84. package/examples/jsm/nodes/core/TempNode.js +1 -1
  85. package/examples/jsm/nodes/core/UniformNode.js +3 -1
  86. package/examples/jsm/nodes/core/VarNode.js +1 -1
  87. package/examples/jsm/nodes/core/VaryingNode.js +1 -1
  88. package/examples/jsm/nodes/core/constants.js +1 -1
  89. package/examples/jsm/nodes/display/BlendModeNode.js +2 -2
  90. package/examples/jsm/nodes/display/BumpMapNode.js +2 -2
  91. package/examples/jsm/nodes/display/ColorAdjustmentNode.js +2 -2
  92. package/examples/jsm/nodes/display/ColorSpaceNode.js +2 -2
  93. package/examples/jsm/nodes/display/FrontFacingNode.js +1 -1
  94. package/examples/jsm/nodes/display/NormalMapNode.js +2 -2
  95. package/examples/jsm/nodes/display/PosterizeNode.js +2 -2
  96. package/examples/jsm/nodes/display/ToneMappingNode.js +2 -2
  97. package/examples/jsm/nodes/display/ViewportDepthNode.js +2 -2
  98. package/examples/jsm/nodes/display/ViewportDepthTextureNode.js +1 -1
  99. package/examples/jsm/nodes/display/ViewportNode.js +21 -7
  100. package/examples/jsm/nodes/display/ViewportSharedTextureNode.js +1 -1
  101. package/examples/jsm/nodes/display/ViewportTextureNode.js +1 -1
  102. package/examples/jsm/nodes/fog/FogExp2Node.js +2 -2
  103. package/examples/jsm/nodes/fog/FogNode.js +2 -2
  104. package/examples/jsm/nodes/fog/FogRangeNode.js +2 -2
  105. package/examples/jsm/nodes/geometry/RangeNode.js +2 -2
  106. package/examples/jsm/nodes/gpgpu/ComputeNode.js +1 -1
  107. package/examples/jsm/nodes/lighting/AONode.js +2 -2
  108. package/examples/jsm/nodes/lighting/AmbientLightNode.js +3 -3
  109. package/examples/jsm/nodes/lighting/AnalyticLightNode.js +4 -4
  110. package/examples/jsm/nodes/lighting/DirectionalLightNode.js +4 -4
  111. package/examples/jsm/nodes/lighting/EnvironmentNode.js +2 -2
  112. package/examples/jsm/nodes/lighting/HemisphereLightNode.js +3 -3
  113. package/examples/jsm/nodes/lighting/IESSpotLightNode.js +2 -2
  114. package/examples/jsm/nodes/lighting/LightNode.js +2 -2
  115. package/examples/jsm/nodes/lighting/LightingContextNode.js +3 -3
  116. package/examples/jsm/nodes/lighting/LightingNode.js +1 -1
  117. package/examples/jsm/nodes/lighting/LightsNode.js +4 -4
  118. package/examples/jsm/nodes/lighting/PointLightNode.js +3 -3
  119. package/examples/jsm/nodes/lighting/SpotLightNode.js +4 -4
  120. package/examples/jsm/nodes/materials/Line2NodeMaterial.js +449 -0
  121. package/examples/jsm/nodes/materials/LineBasicNodeMaterial.js +1 -1
  122. package/examples/jsm/nodes/materials/LineDashedNodeMaterial.js +54 -0
  123. package/examples/jsm/nodes/materials/Materials.js +2 -0
  124. package/examples/jsm/nodes/materials/MeshBasicNodeMaterial.js +1 -1
  125. package/examples/jsm/nodes/materials/MeshLambertNodeMaterial.js +2 -2
  126. package/examples/jsm/nodes/materials/MeshNormalNodeMaterial.js +2 -2
  127. package/examples/jsm/nodes/materials/MeshPhongNodeMaterial.js +3 -3
  128. package/examples/jsm/nodes/materials/MeshPhysicalNodeMaterial.js +6 -6
  129. package/examples/jsm/nodes/materials/MeshStandardNodeMaterial.js +3 -3
  130. package/examples/jsm/nodes/materials/NodeMaterial.js +39 -29
  131. package/examples/jsm/nodes/materials/PointsNodeMaterial.js +1 -1
  132. package/examples/jsm/nodes/materials/SpriteNodeMaterial.js +2 -2
  133. package/examples/jsm/nodes/math/CondNode.js +1 -1
  134. package/examples/jsm/nodes/math/HashNode.js +34 -0
  135. package/examples/jsm/nodes/math/MathNode.js +2 -2
  136. package/examples/jsm/nodes/math/OperatorNode.js +1 -1
  137. package/examples/jsm/nodes/procedural/CheckerNode.js +3 -3
  138. package/examples/jsm/nodes/shadernode/ShaderNode.js +85 -28
  139. package/examples/jsm/nodes/utils/ArrayElementNode.js +1 -1
  140. package/examples/jsm/nodes/utils/ConvertNode.js +1 -1
  141. package/examples/jsm/nodes/utils/DiscardNode.js +1 -1
  142. package/examples/jsm/nodes/utils/EquirectUVNode.js +2 -2
  143. package/examples/jsm/nodes/utils/JoinNode.js +1 -1
  144. package/examples/jsm/nodes/utils/LoopNode.js +11 -11
  145. package/examples/jsm/nodes/utils/MatcapUVNode.js +2 -2
  146. package/examples/jsm/nodes/utils/MaxMipLevelNode.js +1 -1
  147. package/examples/jsm/nodes/utils/OscNode.js +2 -2
  148. package/examples/jsm/nodes/utils/PackingNode.js +2 -2
  149. package/examples/jsm/nodes/utils/RemapNode.js +2 -2
  150. package/examples/jsm/nodes/utils/RotateUVNode.js +2 -2
  151. package/examples/jsm/nodes/utils/SetNode.js +62 -0
  152. package/examples/jsm/nodes/utils/SpecularMIPLevelNode.js +2 -2
  153. package/examples/jsm/nodes/utils/SplitNode.js +2 -2
  154. package/examples/jsm/nodes/utils/SpriteSheetUVNode.js +2 -2
  155. package/examples/jsm/nodes/utils/TimerNode.js +2 -2
  156. package/examples/jsm/nodes/utils/TriplanarTexturesNode.js +2 -2
  157. package/examples/jsm/objects/Sky.js +1 -3
  158. package/examples/jsm/postprocessing/FilmPass.js +3 -5
  159. package/examples/jsm/postprocessing/OutputPass.js +3 -2
  160. package/examples/jsm/postprocessing/RenderPass.js +30 -12
  161. package/examples/jsm/postprocessing/SAOPass.js +23 -98
  162. package/examples/jsm/postprocessing/SSAOPass.js +10 -30
  163. package/examples/jsm/renderers/common/Backend.js +11 -8
  164. package/examples/jsm/renderers/common/Background.js +2 -2
  165. package/examples/jsm/renderers/common/Binding.js +6 -0
  166. package/examples/jsm/renderers/common/Bindings.js +4 -5
  167. package/examples/jsm/renderers/common/Pipelines.js +9 -9
  168. package/examples/jsm/renderers/common/RenderContext.js +3 -0
  169. package/examples/jsm/renderers/common/RenderContexts.js +26 -1
  170. package/examples/jsm/renderers/common/RenderList.js +12 -4
  171. package/examples/jsm/renderers/common/RenderObject.js +43 -15
  172. package/examples/jsm/renderers/common/RenderObjects.js +8 -14
  173. package/examples/jsm/renderers/common/Renderer.js +52 -16
  174. package/examples/jsm/renderers/common/SampledTexture.js +6 -3
  175. package/examples/jsm/renderers/common/Sampler.js +1 -1
  176. package/examples/jsm/renderers/common/StorageBuffer.js +1 -1
  177. package/examples/jsm/renderers/common/StorageTexture.js +19 -0
  178. package/examples/jsm/renderers/common/Textures.js +166 -21
  179. package/examples/jsm/renderers/common/nodes/NodeBuilderState.js +35 -0
  180. package/examples/jsm/renderers/common/nodes/NodeSampledTexture.js +21 -11
  181. package/examples/jsm/renderers/common/nodes/NodeSampler.js +1 -7
  182. package/examples/jsm/renderers/common/nodes/Nodes.js +79 -18
  183. package/examples/jsm/renderers/webgl/WebGLBackend.js +702 -0
  184. package/examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js +207 -20
  185. package/examples/jsm/renderers/webgl/utils/WebGLAttributeUtils.js +84 -0
  186. package/examples/jsm/renderers/webgl/utils/WebGLExtensions.js +26 -0
  187. package/examples/jsm/renderers/webgl/utils/WebGLState.js +529 -0
  188. package/examples/jsm/renderers/webgl/utils/WebGLTextureUtils.js +212 -0
  189. package/examples/jsm/renderers/webgl/utils/WebGLUtils.js +242 -0
  190. package/examples/jsm/renderers/webgl-legacy/nodes/GLSL1NodeBuilder.js +340 -0
  191. package/examples/jsm/renderers/{webgl → webgl-legacy}/nodes/WebGLNodeBuilder.js +4 -4
  192. package/examples/jsm/renderers/{webgl → webgl-legacy}/nodes/WebGLNodes.js +14 -2
  193. package/examples/jsm/renderers/webgpu/WebGPUBackend.js +282 -43
  194. package/examples/jsm/renderers/webgpu/WebGPURenderer.js +18 -2
  195. package/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js +93 -60
  196. package/examples/jsm/renderers/webgpu/nodes/WGSLNodeFunction.js +2 -2
  197. package/examples/jsm/renderers/webgpu/utils/WebGPUBindingUtils.js +15 -2
  198. package/examples/jsm/renderers/webgpu/utils/WebGPUPipelineUtils.js +39 -14
  199. package/examples/jsm/renderers/webgpu/utils/WebGPUTexturePassUtils.js +285 -0
  200. package/examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js +205 -284
  201. package/examples/jsm/renderers/webgpu/utils/WebGPUUtils.js +6 -5
  202. package/examples/jsm/shaders/FilmShader.js +11 -54
  203. package/examples/jsm/shaders/GammaCorrectionShader.js +1 -1
  204. package/examples/jsm/shaders/MMDToonShader.js +4 -4
  205. package/examples/jsm/shaders/OutputShader.js +2 -2
  206. package/examples/jsm/shaders/SAOShader.js +0 -13
  207. package/examples/jsm/shaders/SSAOShader.js +33 -26
  208. package/examples/jsm/shaders/SubsurfaceScatteringShader.js +6 -6
  209. package/examples/jsm/utils/BufferGeometryUtils.js +6 -4
  210. package/package.json +1 -1
  211. package/src/Three.js +1 -2
  212. package/src/animation/AnimationUtils.js +3 -20
  213. package/src/animation/KeyframeTrack.js +8 -8
  214. package/src/audio/Audio.js +6 -0
  215. package/src/cameras/Camera.js +1 -5
  216. package/src/cameras/CubeCamera.js +14 -8
  217. package/src/constants.js +10 -1
  218. package/src/core/Object3D.js +1 -14
  219. package/src/core/RenderTarget.js +16 -7
  220. package/src/core/UniformsGroup.js +2 -2
  221. package/src/extras/core/CurvePath.js +4 -1
  222. package/src/loaders/DataTextureLoader.js +0 -2
  223. package/src/loaders/MaterialLoader.js +1 -1
  224. package/src/loaders/ObjectLoader.js +6 -0
  225. package/src/materials/Material.js +10 -10
  226. package/src/math/Color.js +1 -5
  227. package/src/math/ColorManagement.js +82 -60
  228. package/src/math/Vector2.js +2 -2
  229. package/src/math/Vector3.js +3 -3
  230. package/src/math/Vector4.js +4 -4
  231. package/src/objects/Line.js +1 -1
  232. package/src/objects/Mesh.js +1 -1
  233. package/src/objects/Points.js +1 -1
  234. package/src/objects/Sprite.js +2 -2
  235. package/src/renderers/WebGLRenderer.js +42 -51
  236. package/src/renderers/shaders/ShaderChunk/aomap_fragment.glsl.js +1 -1
  237. package/src/renderers/shaders/ShaderChunk/clearcoat_normal_fragment_begin.glsl.js +1 -1
  238. package/src/renderers/shaders/ShaderChunk/colorspace_pars_fragment.glsl.js +35 -2
  239. package/src/renderers/shaders/ShaderChunk/common.glsl.js +0 -9
  240. package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +19 -15
  241. package/src/renderers/shaders/ShaderChunk/lights_fragment_end.glsl.js +2 -2
  242. package/src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js +4 -4
  243. package/src/renderers/shaders/ShaderChunk/lights_lambert_pars_fragment.glsl.js +3 -3
  244. package/src/renderers/shaders/ShaderChunk/lights_pars_begin.glsl.js +11 -6
  245. package/src/renderers/shaders/ShaderChunk/lights_phong_pars_fragment.glsl.js +4 -4
  246. package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +1 -1
  247. package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +16 -16
  248. package/src/renderers/shaders/ShaderChunk/lights_toon_pars_fragment.glsl.js +3 -3
  249. package/src/renderers/shaders/ShaderChunk/map_fragment.glsl.js +11 -1
  250. package/src/renderers/shaders/ShaderChunk/normal_fragment_begin.glsl.js +1 -1
  251. package/src/renderers/shaders/ShaderLib/background.glsl.js +8 -0
  252. package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +1 -1
  253. package/src/renderers/shaders/UniformsUtils.js +2 -2
  254. package/src/renderers/webgl/WebGLBackground.js +9 -17
  255. package/src/renderers/webgl/WebGLLights.js +14 -3
  256. package/src/renderers/webgl/WebGLProgram.js +36 -5
  257. package/src/renderers/webgl/WebGLPrograms.js +9 -1
  258. package/src/renderers/webgl/WebGLTextures.js +19 -8
  259. package/src/renderers/webgl/WebGLUtils.js +25 -20
  260. package/src/scenes/Fog.js +1 -0
  261. package/src/scenes/FogExp2.js +1 -0
  262. package/src/textures/Source.js +2 -2
  263. package/src/textures/Texture.js +2 -2
  264. package/src/utils.js +9 -1
  265. package/examples/jsm/renderers/webgpu/utils/WebGPUTextureMipmapUtils.js +0 -163
  266. package/src/lights/AmbientLightProbe.js +0 -21
  267. package/src/lights/HemisphereLightProbe.js +0 -30
  268. /package/examples/jsm/renderers/{webgl → webgl-legacy}/nodes/SlotNode.js +0 -0
@@ -1,11 +1,44 @@
1
1
  export default /* glsl */`
2
2
 
3
- vec4 LinearToLinear( in vec4 value ) {
3
+ // http://www.russellcottrell.com/photo/matrixCalculator.htm
4
+
5
+ // Linear sRGB => XYZ => Linear Display P3
6
+ const mat3 LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 = mat3(
7
+ vec3( 0.8224621, 0.177538, 0.0 ),
8
+ vec3( 0.0331941, 0.9668058, 0.0 ),
9
+ vec3( 0.0170827, 0.0723974, 0.9105199 )
10
+ );
11
+
12
+ // Linear Display P3 => XYZ => Linear sRGB
13
+ const mat3 LINEAR_DISPLAY_P3_TO_LINEAR_SRGB = mat3(
14
+ vec3( 1.2249401, - 0.2249404, 0.0 ),
15
+ vec3( - 0.0420569, 1.0420571, 0.0 ),
16
+ vec3( - 0.0196376, - 0.0786361, 1.0982735 )
17
+ );
18
+
19
+ vec4 LinearSRGBToLinearDisplayP3( in vec4 value ) {
20
+ return vec4( value.rgb * LINEAR_SRGB_TO_LINEAR_DISPLAY_P3, value.a );
21
+ }
22
+
23
+ vec4 LinearDisplayP3ToLinearSRGB( in vec4 value ) {
24
+ return vec4( value.rgb * LINEAR_DISPLAY_P3_TO_LINEAR_SRGB, value.a );
25
+ }
26
+
27
+ vec4 LinearTransferOETF( in vec4 value ) {
4
28
  return value;
5
29
  }
6
30
 
7
- vec4 LinearTosRGB( in vec4 value ) {
31
+ vec4 sRGBTransferOETF( in vec4 value ) {
8
32
  return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );
9
33
  }
10
34
 
35
+ // @deprecated, r156
36
+ vec4 LinearToLinear( in vec4 value ) {
37
+ return value;
38
+ }
39
+
40
+ // @deprecated, r156
41
+ vec4 LinearTosRGB( in vec4 value ) {
42
+ return sRGBTransferOETF( value );
43
+ }
11
44
  `;
@@ -52,15 +52,6 @@ struct ReflectedLight {
52
52
  vec3 indirectSpecular;
53
53
  };
54
54
 
55
- struct GeometricContext {
56
- vec3 position;
57
- vec3 normal;
58
- vec3 viewDir;
59
- #ifdef USE_CLEARCOAT
60
- vec3 clearcoatNormal;
61
- #endif
62
- };
63
-
64
55
  #ifdef USE_ALPHAHASH
65
56
 
66
57
  varying vec3 vPosition;
@@ -13,21 +13,21 @@ export default /* glsl */`
13
13
  * - Add diffuse light probe (irradiance cubemap) support.
14
14
  */
15
15
 
16
- GeometricContext geometry;
16
+ vec3 geometryPosition = - vViewPosition;
17
+ vec3 geometryNormal = normal;
18
+ vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
17
19
 
18
- geometry.position = - vViewPosition;
19
- geometry.normal = normal;
20
- geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
20
+ vec3 geometryClearcoatNormal;
21
21
 
22
22
  #ifdef USE_CLEARCOAT
23
23
 
24
- geometry.clearcoatNormal = clearcoatNormal;
24
+ geometryClearcoatNormal = clearcoatNormal;
25
25
 
26
26
  #endif
27
27
 
28
28
  #ifdef USE_IRIDESCENCE
29
29
 
30
- float dotNVi = saturate( dot( normal, geometry.viewDir ) );
30
+ float dotNVi = saturate( dot( normal, geometryViewDir ) );
31
31
 
32
32
  if ( material.iridescenceThickness == 0.0 ) {
33
33
 
@@ -64,14 +64,14 @@ IncidentLight directLight;
64
64
 
65
65
  pointLight = pointLights[ i ];
66
66
 
67
- getPointLightInfo( pointLight, geometry, directLight );
67
+ getPointLightInfo( pointLight, geometryPosition, directLight );
68
68
 
69
69
  #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
70
70
  pointLightShadow = pointLightShadows[ i ];
71
71
  directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
72
72
  #endif
73
73
 
74
- RE_Direct( directLight, geometry, material, reflectedLight );
74
+ RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
75
75
 
76
76
  }
77
77
  #pragma unroll_loop_end
@@ -94,7 +94,7 @@ IncidentLight directLight;
94
94
 
95
95
  spotLight = spotLights[ i ];
96
96
 
97
- getSpotLightInfo( spotLight, geometry, directLight );
97
+ getSpotLightInfo( spotLight, geometryPosition, directLight );
98
98
 
99
99
  // spot lights are ordered [shadows with maps, shadows without maps, maps without shadows, none]
100
100
  #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
@@ -119,7 +119,7 @@ IncidentLight directLight;
119
119
  directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
120
120
  #endif
121
121
 
122
- RE_Direct( directLight, geometry, material, reflectedLight );
122
+ RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
123
123
 
124
124
  }
125
125
  #pragma unroll_loop_end
@@ -138,14 +138,14 @@ IncidentLight directLight;
138
138
 
139
139
  directionalLight = directionalLights[ i ];
140
140
 
141
- getDirectionalLightInfo( directionalLight, geometry, directLight );
141
+ getDirectionalLightInfo( directionalLight, directLight );
142
142
 
143
143
  #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
144
144
  directionalLightShadow = directionalLightShadows[ i ];
145
145
  directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
146
146
  #endif
147
147
 
148
- RE_Direct( directLight, geometry, material, reflectedLight );
148
+ RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
149
149
 
150
150
  }
151
151
  #pragma unroll_loop_end
@@ -160,7 +160,7 @@ IncidentLight directLight;
160
160
  for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
161
161
 
162
162
  rectAreaLight = rectAreaLights[ i ];
163
- RE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );
163
+ RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
164
164
 
165
165
  }
166
166
  #pragma unroll_loop_end
@@ -173,14 +173,18 @@ IncidentLight directLight;
173
173
 
174
174
  vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
175
175
 
176
- irradiance += getLightProbeIrradiance( lightProbe, geometry.normal );
176
+ #if defined( USE_LIGHT_PROBES )
177
+
178
+ irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
179
+
180
+ #endif
177
181
 
178
182
  #if ( NUM_HEMI_LIGHTS > 0 )
179
183
 
180
184
  #pragma unroll_loop_start
181
185
  for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
182
186
 
183
- irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal );
187
+ irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
184
188
 
185
189
  }
186
190
  #pragma unroll_loop_end
@@ -1,13 +1,13 @@
1
1
  export default /* glsl */`
2
2
  #if defined( RE_IndirectDiffuse )
3
3
 
4
- RE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );
4
+ RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
5
5
 
6
6
  #endif
7
7
 
8
8
  #if defined( RE_IndirectSpecular )
9
9
 
10
- RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );
10
+ RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
11
11
 
12
12
  #endif
13
13
  `;
@@ -12,7 +12,7 @@ export default /* glsl */`
12
12
 
13
13
  #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
14
14
 
15
- iblIrradiance += getIBLIrradiance( geometry.normal );
15
+ iblIrradiance += getIBLIrradiance( geometryNormal );
16
16
 
17
17
  #endif
18
18
 
@@ -22,17 +22,17 @@ export default /* glsl */`
22
22
 
23
23
  #ifdef USE_ANISOTROPY
24
24
 
25
- radiance += getIBLAnisotropyRadiance( geometry.viewDir, geometry.normal, material.roughness, material.anisotropyB, material.anisotropy );
25
+ radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
26
26
 
27
27
  #else
28
28
 
29
- radiance += getIBLRadiance( geometry.viewDir, geometry.normal, material.roughness );
29
+ radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
30
30
 
31
31
  #endif
32
32
 
33
33
  #ifdef USE_CLEARCOAT
34
34
 
35
- clearcoatRadiance += getIBLRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness );
35
+ clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
36
36
 
37
37
  #endif
38
38
 
@@ -8,16 +8,16 @@ struct LambertMaterial {
8
8
 
9
9
  };
10
10
 
11
- void RE_Direct_Lambert( const in IncidentLight directLight, const in GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
11
+ void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
12
12
 
13
- float dotNL = saturate( dot( geometry.normal, directLight.direction ) );
13
+ float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
14
14
  vec3 irradiance = dotNL * directLight.color;
15
15
 
16
16
  reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
17
17
 
18
18
  }
19
19
 
20
- void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
20
+ void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
21
21
 
22
22
  reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
23
23
 
@@ -1,7 +1,12 @@
1
1
  export default /* glsl */`
2
2
  uniform bool receiveShadow;
3
3
  uniform vec3 ambientLightColor;
4
- uniform vec3 lightProbe[ 9 ];
4
+
5
+ #if defined( USE_LIGHT_PROBES )
6
+
7
+ uniform vec3 lightProbe[ 9 ];
8
+
9
+ #endif
5
10
 
6
11
  // get the irradiance (radiance convolved with cosine lobe) at the point 'normal' on the unit sphere
7
12
  // source: https://graphics.stanford.edu/papers/envmap/envmap.pdf
@@ -94,7 +99,7 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi
94
99
 
95
100
  uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
96
101
 
97
- void getDirectionalLightInfo( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight light ) {
102
+ void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
98
103
 
99
104
  light.color = directionalLight.color;
100
105
  light.direction = directionalLight.direction;
@@ -117,9 +122,9 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi
117
122
  uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
118
123
 
119
124
  // light is an out parameter as having it as a return value caused compiler errors on some devices
120
- void getPointLightInfo( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight light ) {
125
+ void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
121
126
 
122
- vec3 lVector = pointLight.position - geometry.position;
127
+ vec3 lVector = pointLight.position - geometryPosition;
123
128
 
124
129
  light.direction = normalize( lVector );
125
130
 
@@ -149,9 +154,9 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi
149
154
  uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
150
155
 
151
156
  // light is an out parameter as having it as a return value caused compiler errors on some devices
152
- void getSpotLightInfo( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight light ) {
157
+ void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
153
158
 
154
- vec3 lVector = spotLight.position - geometry.position;
159
+ vec3 lVector = spotLight.position - geometryPosition;
155
160
 
156
161
  light.direction = normalize( lVector );
157
162
 
@@ -10,18 +10,18 @@ struct BlinnPhongMaterial {
10
10
 
11
11
  };
12
12
 
13
- void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
13
+ void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
14
14
 
15
- float dotNL = saturate( dot( geometry.normal, directLight.direction ) );
15
+ float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
16
16
  vec3 irradiance = dotNL * directLight.color;
17
17
 
18
18
  reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
19
19
 
20
- reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularShininess ) * material.specularStrength;
20
+ reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
21
21
 
22
22
  }
23
23
 
24
- void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
24
+ void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
25
25
 
26
26
  reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
27
27
 
@@ -2,7 +2,7 @@ export default /* glsl */`
2
2
  PhysicalMaterial material;
3
3
  material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
4
4
 
5
- vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );
5
+ vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
6
6
  float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
7
7
 
8
8
  material.roughness = max( roughnessFactor, 0.0525 );// 0.0525 corresponds to the base mip of a 256 cubemap.
@@ -433,11 +433,11 @@ void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const
433
433
 
434
434
  #if NUM_RECT_AREA_LIGHTS > 0
435
435
 
436
- void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
436
+ void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
437
437
 
438
- vec3 normal = geometry.normal;
439
- vec3 viewDir = geometry.viewDir;
440
- vec3 position = geometry.position;
438
+ vec3 normal = geometryNormal;
439
+ vec3 viewDir = geometryViewDir;
440
+ vec3 position = geometryPosition;
441
441
  vec3 lightPos = rectAreaLight.position;
442
442
  vec3 halfWidth = rectAreaLight.halfWidth;
443
443
  vec3 halfHeight = rectAreaLight.halfHeight;
@@ -473,50 +473,50 @@ void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const
473
473
 
474
474
  #endif
475
475
 
476
- void RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
476
+ void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
477
477
 
478
- float dotNL = saturate( dot( geometry.normal, directLight.direction ) );
478
+ float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
479
479
 
480
480
  vec3 irradiance = dotNL * directLight.color;
481
481
 
482
482
  #ifdef USE_CLEARCOAT
483
483
 
484
- float dotNLcc = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );
484
+ float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
485
485
 
486
486
  vec3 ccIrradiance = dotNLcc * directLight.color;
487
487
 
488
- clearcoatSpecular += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometry.viewDir, geometry.clearcoatNormal, material );
488
+ clearcoatSpecular += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
489
489
 
490
490
  #endif
491
491
 
492
492
  #ifdef USE_SHEEN
493
493
 
494
- sheenSpecular += irradiance * BRDF_Sheen( directLight.direction, geometry.viewDir, geometry.normal, material.sheenColor, material.sheenRoughness );
494
+ sheenSpecular += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
495
495
 
496
496
  #endif
497
497
 
498
- reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.normal, material );
498
+ reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );
499
499
 
500
500
  reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
501
501
  }
502
502
 
503
- void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
503
+ void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
504
504
 
505
505
  reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
506
506
 
507
507
  }
508
508
 
509
- void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {
509
+ void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {
510
510
 
511
511
  #ifdef USE_CLEARCOAT
512
512
 
513
- clearcoatSpecular += clearcoatRadiance * EnvironmentBRDF( geometry.clearcoatNormal, geometry.viewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
513
+ clearcoatSpecular += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
514
514
 
515
515
  #endif
516
516
 
517
517
  #ifdef USE_SHEEN
518
518
 
519
- sheenSpecular += irradiance * material.sheenColor * IBLSheenBRDF( geometry.normal, geometry.viewDir, material.sheenRoughness );
519
+ sheenSpecular += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
520
520
 
521
521
  #endif
522
522
 
@@ -528,11 +528,11 @@ void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradia
528
528
 
529
529
  #ifdef USE_IRIDESCENCE
530
530
 
531
- computeMultiscatteringIridescence( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
531
+ computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
532
532
 
533
533
  #else
534
534
 
535
- computeMultiscattering( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
535
+ computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
536
536
 
537
537
  #endif
538
538
 
@@ -7,15 +7,15 @@ struct ToonMaterial {
7
7
 
8
8
  };
9
9
 
10
- void RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
10
+ void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
11
11
 
12
- vec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;
12
+ vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
13
13
 
14
14
  reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
15
15
 
16
16
  }
17
17
 
18
- void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
18
+ void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
19
19
 
20
20
  reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
21
21
 
@@ -1,7 +1,17 @@
1
1
  export default /* glsl */`
2
2
  #ifdef USE_MAP
3
3
 
4
- diffuseColor *= texture2D( map, vMapUv );
4
+ vec4 sampledDiffuseColor = texture2D( map, vMapUv );
5
+
6
+ #ifdef DECODE_VIDEO_TEXTURE
7
+
8
+ // use inline sRGB decode until browsers properly support SRGB8_APLHA8 with video textures
9
+
10
+ sampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w );
11
+
12
+ #endif
13
+
14
+ diffuseColor *= sampledDiffuseColor;
5
15
 
6
16
  #endif
7
17
  `;
@@ -71,6 +71,6 @@ float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
71
71
 
72
72
  // non perturbed normal for clearcoat among others
73
73
 
74
- vec3 geometryNormal = normal;
74
+ vec3 nonPerturbedNormal = normal;
75
75
 
76
76
  `;
@@ -21,6 +21,14 @@ void main() {
21
21
 
22
22
  vec4 texColor = texture2D( t2D, vUv );
23
23
 
24
+ #ifdef DECODE_VIDEO_TEXTURE
25
+
26
+ // use inline sRGB decode until browsers properly support SRGB8_APLHA8 with video textures
27
+
28
+ texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );
29
+
30
+ #endif
31
+
24
32
  texColor.rgb *= backgroundIntensity;
25
33
 
26
34
  gl_FragColor = texColor;
@@ -203,7 +203,7 @@ void main() {
203
203
 
204
204
  #ifdef USE_CLEARCOAT
205
205
 
206
- float dotNVcc = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );
206
+ float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
207
207
 
208
208
  vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
209
209
 
@@ -1,4 +1,4 @@
1
- import { LinearSRGBColorSpace } from '../../constants.js';
1
+ import { ColorManagement } from '../../math/ColorManagement.js';
2
2
 
3
3
  /**
4
4
  * Uniform Utilities
@@ -93,7 +93,7 @@ export function getUnlitUniformColorSpace( renderer ) {
93
93
 
94
94
  }
95
95
 
96
- return LinearSRGBColorSpace;
96
+ return ColorManagement.workingColorSpace;
97
97
 
98
98
  }
99
99
 
@@ -1,8 +1,9 @@
1
- import { BackSide, FrontSide, CubeUVReflectionMapping, SRGBColorSpace } from '../../constants.js';
1
+ import { BackSide, FrontSide, CubeUVReflectionMapping, SRGBTransfer } from '../../constants.js';
2
2
  import { BoxGeometry } from '../../geometries/BoxGeometry.js';
3
3
  import { PlaneGeometry } from '../../geometries/PlaneGeometry.js';
4
4
  import { ShaderMaterial } from '../../materials/ShaderMaterial.js';
5
5
  import { Color } from '../../math/Color.js';
6
+ import { ColorManagement } from '../../math/ColorManagement.js';
6
7
  import { Mesh } from '../../objects/Mesh.js';
7
8
  import { ShaderLib } from '../shaders/ShaderLib.js';
8
9
  import { cloneUniforms, getUnlitUniformColorSpace } from '../shaders/UniformsUtils.js';
@@ -44,24 +45,15 @@ function WebGLBackground( renderer, cubemaps, cubeuvmaps, state, objects, alpha,
44
45
 
45
46
  }
46
47
 
47
- const xr = renderer.xr;
48
- const environmentBlendMode = xr.getEnvironmentBlendMode();
48
+ const environmentBlendMode = renderer.xr.getEnvironmentBlendMode();
49
49
 
50
- switch ( environmentBlendMode ) {
50
+ if ( environmentBlendMode === 'additive' ) {
51
51
 
52
- case 'opaque':
53
- forceClear = true;
54
- break;
52
+ state.buffers.color.setClear( 0, 0, 0, 1, premultipliedAlpha );
55
53
 
56
- case 'additive':
57
- state.buffers.color.setClear( 0, 0, 0, 1, premultipliedAlpha );
58
- forceClear = true;
59
- break;
54
+ } else if ( environmentBlendMode === 'alpha-blend' ) {
60
55
 
61
- case 'alpha-blend':
62
- state.buffers.color.setClear( 0, 0, 0, 0, premultipliedAlpha );
63
- forceClear = true;
64
- break;
56
+ state.buffers.color.setClear( 0, 0, 0, 0, premultipliedAlpha );
65
57
 
66
58
  }
67
59
 
@@ -117,7 +109,7 @@ function WebGLBackground( renderer, cubemaps, cubeuvmaps, state, objects, alpha,
117
109
  boxMesh.material.uniforms.flipEnvMap.value = ( background.isCubeTexture && background.isRenderTargetTexture === false ) ? - 1 : 1;
118
110
  boxMesh.material.uniforms.backgroundBlurriness.value = scene.backgroundBlurriness;
119
111
  boxMesh.material.uniforms.backgroundIntensity.value = scene.backgroundIntensity;
120
- boxMesh.material.toneMapped = ( background.colorSpace === SRGBColorSpace ) ? false : true;
112
+ boxMesh.material.toneMapped = ColorManagement.getTransfer( background.colorSpace ) !== SRGBTransfer;
121
113
 
122
114
  if ( currentBackground !== background ||
123
115
  currentBackgroundVersion !== background.version ||
@@ -173,7 +165,7 @@ function WebGLBackground( renderer, cubemaps, cubeuvmaps, state, objects, alpha,
173
165
 
174
166
  planeMesh.material.uniforms.t2D.value = background;
175
167
  planeMesh.material.uniforms.backgroundIntensity.value = scene.backgroundIntensity;
176
- planeMesh.material.toneMapped = ( background.colorSpace === SRGBColorSpace ) ? false : true;
168
+ planeMesh.material.toneMapped = ColorManagement.getTransfer( background.colorSpace ) !== SRGBTransfer;
177
169
 
178
170
  if ( background.matrixAutoUpdate === true ) {
179
171
 
@@ -170,7 +170,9 @@ function WebGLLights( extensions, capabilities ) {
170
170
  numDirectionalShadows: - 1,
171
171
  numPointShadows: - 1,
172
172
  numSpotShadows: - 1,
173
- numSpotMaps: - 1
173
+ numSpotMaps: - 1,
174
+
175
+ numLightProbes: - 1
174
176
  },
175
177
 
176
178
  ambient: [ 0, 0, 0 ],
@@ -192,7 +194,8 @@ function WebGLLights( extensions, capabilities ) {
192
194
  pointShadowMap: [],
193
195
  pointShadowMatrix: [],
194
196
  hemi: [],
195
- numSpotLightShadowsWithMaps: 0
197
+ numSpotLightShadowsWithMaps: 0,
198
+ numLightProbes: 0
196
199
 
197
200
  };
198
201
 
@@ -220,6 +223,8 @@ function WebGLLights( extensions, capabilities ) {
220
223
  let numSpotMaps = 0;
221
224
  let numSpotShadowsWithMaps = 0;
222
225
 
226
+ let numLightProbes = 0;
227
+
223
228
  // ordering : [shadow casting + map texturing, map texturing, shadow casting, none ]
224
229
  lights.sort( shadowCastingAndTexturingLightsFirst );
225
230
 
@@ -250,6 +255,8 @@ function WebGLLights( extensions, capabilities ) {
250
255
 
251
256
  }
252
257
 
258
+ numLightProbes ++;
259
+
253
260
  } else if ( light.isDirectionalLight ) {
254
261
 
255
262
  const uniforms = cache.get( light );
@@ -437,7 +444,8 @@ function WebGLLights( extensions, capabilities ) {
437
444
  hash.numDirectionalShadows !== numDirectionalShadows ||
438
445
  hash.numPointShadows !== numPointShadows ||
439
446
  hash.numSpotShadows !== numSpotShadows ||
440
- hash.numSpotMaps !== numSpotMaps ) {
447
+ hash.numSpotMaps !== numSpotMaps ||
448
+ hash.numLightProbes !== numLightProbes ) {
441
449
 
442
450
  state.directional.length = directionalLength;
443
451
  state.spot.length = spotLength;
@@ -456,6 +464,7 @@ function WebGLLights( extensions, capabilities ) {
456
464
  state.spotLightMatrix.length = numSpotShadows + numSpotMaps - numSpotShadowsWithMaps;
457
465
  state.spotLightMap.length = numSpotMaps;
458
466
  state.numSpotLightShadowsWithMaps = numSpotShadowsWithMaps;
467
+ state.numLightProbes = numLightProbes;
459
468
 
460
469
  hash.directionalLength = directionalLength;
461
470
  hash.pointLength = pointLength;
@@ -468,6 +477,8 @@ function WebGLLights( extensions, capabilities ) {
468
477
  hash.numSpotShadows = numSpotShadows;
469
478
  hash.numSpotMaps = numSpotMaps;
470
479
 
480
+ hash.numLightProbes = numLightProbes;
481
+
471
482
  state.version = nextVersion ++;
472
483
 
473
484
  }