super-three 0.156.0 → 0.157.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.
Files changed (223) hide show
  1. package/build/three.cjs +753 -277
  2. package/build/three.js +753 -277
  3. package/build/three.min.js +2 -2
  4. package/build/three.module.js +750 -276
  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/csm/CSMShader.js +25 -21
  9. package/examples/jsm/exporters/EXRExporter.js +102 -24
  10. package/examples/jsm/exporters/GLTFExporter.js +1 -1
  11. package/examples/jsm/libs/rhino3dm/rhino3dm.js +8726 -4
  12. package/examples/jsm/libs/rhino3dm/rhino3dm.module.js +8737 -4
  13. package/examples/jsm/libs/rhino3dm/rhino3dm.wasm +0 -0
  14. package/examples/jsm/lights/LightProbeGenerator.js +37 -3
  15. package/examples/jsm/lines/LineMaterial.js +90 -156
  16. package/examples/jsm/loaders/3DMLoader.js +378 -104
  17. package/examples/jsm/loaders/GLTFLoader.js +1 -1
  18. package/examples/jsm/loaders/LDrawLoader.js +22 -16
  19. package/examples/jsm/loaders/RGBELoader.js +1 -1
  20. package/examples/jsm/loaders/USDZLoader.js +215 -12
  21. package/examples/jsm/materials/MeshGouraudMaterial.js +22 -18
  22. package/examples/jsm/nodes/Nodes.js +5 -1
  23. package/examples/jsm/nodes/accessors/BitangentNode.js +1 -1
  24. package/examples/jsm/nodes/accessors/BufferAttributeNode.js +2 -2
  25. package/examples/jsm/nodes/accessors/BufferNode.js +1 -1
  26. package/examples/jsm/nodes/accessors/CameraNode.js +1 -1
  27. package/examples/jsm/nodes/accessors/CubeTextureNode.js +2 -2
  28. package/examples/jsm/nodes/accessors/ExtendedMaterialNode.js +6 -5
  29. package/examples/jsm/nodes/accessors/InstanceNode.js +2 -2
  30. package/examples/jsm/nodes/accessors/LineMaterialNode.js +7 -9
  31. package/examples/jsm/nodes/accessors/MaterialNode.js +34 -46
  32. package/examples/jsm/nodes/accessors/MaterialReferenceNode.js +9 -9
  33. package/examples/jsm/nodes/accessors/ModelNode.js +1 -1
  34. package/examples/jsm/nodes/accessors/ModelViewProjectionNode.js +5 -4
  35. package/examples/jsm/nodes/accessors/MorphNode.js +4 -4
  36. package/examples/jsm/nodes/accessors/NormalNode.js +1 -1
  37. package/examples/jsm/nodes/accessors/Object3DNode.js +1 -1
  38. package/examples/jsm/nodes/accessors/PointUVNode.js +1 -1
  39. package/examples/jsm/nodes/accessors/PositionNode.js +1 -1
  40. package/examples/jsm/nodes/accessors/ReferenceNode.js +13 -7
  41. package/examples/jsm/nodes/accessors/ReflectVectorNode.js +2 -2
  42. package/examples/jsm/nodes/accessors/SceneNode.js +2 -2
  43. package/examples/jsm/nodes/accessors/SkinningNode.js +2 -2
  44. package/examples/jsm/nodes/accessors/StorageBufferNode.js +1 -1
  45. package/examples/jsm/nodes/accessors/TangentNode.js +1 -1
  46. package/examples/jsm/nodes/accessors/TextureBicubicNode.js +2 -2
  47. package/examples/jsm/nodes/accessors/TextureNode.js +12 -6
  48. package/examples/jsm/nodes/accessors/TextureSizeNode.js +2 -2
  49. package/examples/jsm/nodes/accessors/TextureStoreNode.js +1 -1
  50. package/examples/jsm/nodes/accessors/UVNode.js +1 -1
  51. package/examples/jsm/nodes/accessors/UserDataNode.js +2 -2
  52. package/examples/jsm/nodes/code/CodeNode.js +1 -1
  53. package/examples/jsm/nodes/code/ExpressionNode.js +1 -1
  54. package/examples/jsm/nodes/code/FunctionCallNode.js +1 -1
  55. package/examples/jsm/nodes/code/FunctionNode.js +18 -7
  56. package/examples/jsm/nodes/code/ScriptableNode.js +2 -2
  57. package/examples/jsm/nodes/code/ScriptableValueNode.js +2 -2
  58. package/examples/jsm/nodes/core/ArrayUniformNode.js +1 -1
  59. package/examples/jsm/nodes/core/AttributeNode.js +1 -1
  60. package/examples/jsm/nodes/core/BypassNode.js +1 -1
  61. package/examples/jsm/nodes/core/CacheNode.js +1 -1
  62. package/examples/jsm/nodes/core/ConstNode.js +1 -1
  63. package/examples/jsm/nodes/core/ContextNode.js +2 -2
  64. package/examples/jsm/nodes/core/IndexNode.js +1 -1
  65. package/examples/jsm/nodes/core/InputNode.js +1 -1
  66. package/examples/jsm/nodes/core/Node.js +28 -13
  67. package/examples/jsm/nodes/core/NodeBuilder.js +3 -17
  68. package/examples/jsm/nodes/core/NodeFrame.js +37 -14
  69. package/examples/jsm/nodes/core/OutputStructNode.js +8 -4
  70. package/examples/jsm/nodes/core/PropertyNode.js +3 -3
  71. package/examples/jsm/nodes/core/StackNode.js +1 -1
  72. package/examples/jsm/nodes/core/StructTypeNode.js +1 -1
  73. package/examples/jsm/nodes/core/TempNode.js +1 -1
  74. package/examples/jsm/nodes/core/UniformNode.js +3 -1
  75. package/examples/jsm/nodes/core/VarNode.js +1 -1
  76. package/examples/jsm/nodes/core/VaryingNode.js +1 -1
  77. package/examples/jsm/nodes/core/constants.js +1 -1
  78. package/examples/jsm/nodes/display/BlendModeNode.js +2 -2
  79. package/examples/jsm/nodes/display/BumpMapNode.js +2 -2
  80. package/examples/jsm/nodes/display/ColorAdjustmentNode.js +2 -2
  81. package/examples/jsm/nodes/display/ColorSpaceNode.js +2 -2
  82. package/examples/jsm/nodes/display/FrontFacingNode.js +1 -1
  83. package/examples/jsm/nodes/display/NormalMapNode.js +2 -2
  84. package/examples/jsm/nodes/display/PosterizeNode.js +2 -2
  85. package/examples/jsm/nodes/display/ToneMappingNode.js +2 -2
  86. package/examples/jsm/nodes/display/ViewportDepthNode.js +2 -2
  87. package/examples/jsm/nodes/display/ViewportDepthTextureNode.js +1 -1
  88. package/examples/jsm/nodes/display/ViewportNode.js +2 -2
  89. package/examples/jsm/nodes/display/ViewportSharedTextureNode.js +1 -1
  90. package/examples/jsm/nodes/display/ViewportTextureNode.js +1 -1
  91. package/examples/jsm/nodes/fog/FogExp2Node.js +2 -2
  92. package/examples/jsm/nodes/fog/FogNode.js +2 -2
  93. package/examples/jsm/nodes/fog/FogRangeNode.js +2 -2
  94. package/examples/jsm/nodes/geometry/RangeNode.js +2 -2
  95. package/examples/jsm/nodes/gpgpu/ComputeNode.js +1 -1
  96. package/examples/jsm/nodes/lighting/AONode.js +2 -2
  97. package/examples/jsm/nodes/lighting/AmbientLightNode.js +3 -3
  98. package/examples/jsm/nodes/lighting/AnalyticLightNode.js +4 -4
  99. package/examples/jsm/nodes/lighting/DirectionalLightNode.js +4 -4
  100. package/examples/jsm/nodes/lighting/EnvironmentNode.js +2 -2
  101. package/examples/jsm/nodes/lighting/HemisphereLightNode.js +3 -3
  102. package/examples/jsm/nodes/lighting/IESSpotLightNode.js +2 -2
  103. package/examples/jsm/nodes/lighting/LightNode.js +2 -2
  104. package/examples/jsm/nodes/lighting/LightingContextNode.js +3 -3
  105. package/examples/jsm/nodes/lighting/LightingNode.js +1 -1
  106. package/examples/jsm/nodes/lighting/LightsNode.js +4 -4
  107. package/examples/jsm/nodes/lighting/PointLightNode.js +3 -3
  108. package/examples/jsm/nodes/lighting/SpotLightNode.js +4 -4
  109. package/examples/jsm/nodes/materials/Line2NodeMaterial.js +449 -0
  110. package/examples/jsm/nodes/materials/LineBasicNodeMaterial.js +1 -1
  111. package/examples/jsm/nodes/materials/LineDashedNodeMaterial.js +2 -2
  112. package/examples/jsm/nodes/materials/Materials.js +1 -0
  113. package/examples/jsm/nodes/materials/MeshBasicNodeMaterial.js +1 -1
  114. package/examples/jsm/nodes/materials/MeshLambertNodeMaterial.js +2 -2
  115. package/examples/jsm/nodes/materials/MeshNormalNodeMaterial.js +2 -2
  116. package/examples/jsm/nodes/materials/MeshPhongNodeMaterial.js +3 -3
  117. package/examples/jsm/nodes/materials/MeshPhysicalNodeMaterial.js +6 -6
  118. package/examples/jsm/nodes/materials/MeshStandardNodeMaterial.js +3 -3
  119. package/examples/jsm/nodes/materials/NodeMaterial.js +27 -26
  120. package/examples/jsm/nodes/materials/PointsNodeMaterial.js +1 -1
  121. package/examples/jsm/nodes/materials/SpriteNodeMaterial.js +2 -2
  122. package/examples/jsm/nodes/math/CondNode.js +1 -1
  123. package/examples/jsm/nodes/math/HashNode.js +8 -9
  124. package/examples/jsm/nodes/math/MathNode.js +2 -2
  125. package/examples/jsm/nodes/math/OperatorNode.js +1 -1
  126. package/examples/jsm/nodes/procedural/CheckerNode.js +3 -3
  127. package/examples/jsm/nodes/shadernode/ShaderNode.js +81 -28
  128. package/examples/jsm/nodes/utils/ArrayElementNode.js +1 -1
  129. package/examples/jsm/nodes/utils/ConvertNode.js +1 -1
  130. package/examples/jsm/nodes/utils/DiscardNode.js +1 -1
  131. package/examples/jsm/nodes/utils/EquirectUVNode.js +2 -2
  132. package/examples/jsm/nodes/utils/JoinNode.js +1 -1
  133. package/examples/jsm/nodes/utils/LoopNode.js +11 -11
  134. package/examples/jsm/nodes/utils/MatcapUVNode.js +2 -2
  135. package/examples/jsm/nodes/utils/MaxMipLevelNode.js +1 -1
  136. package/examples/jsm/nodes/utils/OscNode.js +2 -2
  137. package/examples/jsm/nodes/utils/PackingNode.js +2 -2
  138. package/examples/jsm/nodes/utils/RemapNode.js +2 -2
  139. package/examples/jsm/nodes/utils/RotateUVNode.js +2 -2
  140. package/examples/jsm/nodes/utils/SetNode.js +62 -0
  141. package/examples/jsm/nodes/utils/SpecularMIPLevelNode.js +2 -2
  142. package/examples/jsm/nodes/utils/SplitNode.js +1 -1
  143. package/examples/jsm/nodes/utils/SpriteSheetUVNode.js +2 -2
  144. package/examples/jsm/nodes/utils/TimerNode.js +2 -2
  145. package/examples/jsm/nodes/utils/TriplanarTexturesNode.js +2 -2
  146. package/examples/jsm/objects/Sky.js +1 -3
  147. package/examples/jsm/postprocessing/OutputPass.js +3 -2
  148. package/examples/jsm/renderers/common/Background.js +2 -2
  149. package/examples/jsm/renderers/common/Bindings.js +3 -5
  150. package/examples/jsm/renderers/common/Pipelines.js +7 -7
  151. package/examples/jsm/renderers/common/RenderContext.js +3 -0
  152. package/examples/jsm/renderers/common/RenderObject.js +40 -16
  153. package/examples/jsm/renderers/common/RenderObjects.js +8 -14
  154. package/examples/jsm/renderers/common/Renderer.js +40 -13
  155. package/examples/jsm/renderers/common/SampledTexture.js +4 -2
  156. package/examples/jsm/renderers/common/StorageTexture.js +19 -0
  157. package/examples/jsm/renderers/common/Textures.js +14 -9
  158. package/examples/jsm/renderers/common/nodes/NodeBuilderState.js +35 -0
  159. package/examples/jsm/renderers/common/nodes/NodeSampledTexture.js +20 -10
  160. package/examples/jsm/renderers/common/nodes/NodeSampler.js +0 -6
  161. package/examples/jsm/renderers/common/nodes/Nodes.js +51 -24
  162. package/examples/jsm/renderers/webgl/WebGLBackend.js +100 -5
  163. package/examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js +92 -6
  164. package/examples/jsm/renderers/webgl/utils/WebGLTextureUtils.js +13 -0
  165. package/examples/jsm/renderers/webgl-legacy/nodes/WebGLNodeBuilder.js +3 -3
  166. package/examples/jsm/renderers/webgl-legacy/nodes/WebGLNodes.js +14 -2
  167. package/examples/jsm/renderers/webgpu/WebGPUBackend.js +5 -5
  168. package/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js +6 -3
  169. package/examples/jsm/renderers/webgpu/utils/WebGPUPipelineUtils.js +5 -5
  170. package/examples/jsm/renderers/webgpu/utils/WebGPUTexturePassUtils.js +285 -0
  171. package/examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js +197 -167
  172. package/examples/jsm/shaders/GammaCorrectionShader.js +1 -1
  173. package/examples/jsm/shaders/MMDToonShader.js +4 -4
  174. package/examples/jsm/shaders/OutputShader.js +2 -2
  175. package/examples/jsm/shaders/SubsurfaceScatteringShader.js +6 -6
  176. package/examples/jsm/utils/BufferGeometryUtils.js +6 -4
  177. package/package.json +1 -1
  178. package/src/Three.js +0 -2
  179. package/src/animation/AnimationUtils.js +3 -20
  180. package/src/animation/KeyframeTrack.js +8 -8
  181. package/src/cameras/Camera.js +1 -5
  182. package/src/cameras/CubeCamera.js +14 -8
  183. package/src/constants.js +7 -1
  184. package/src/core/RenderTarget.js +16 -7
  185. package/src/extras/core/CurvePath.js +4 -1
  186. package/src/loaders/MaterialLoader.js +1 -1
  187. package/src/loaders/ObjectLoader.js +6 -0
  188. package/src/materials/Material.js +8 -8
  189. package/src/math/Color.js +1 -5
  190. package/src/math/ColorManagement.js +82 -60
  191. package/src/objects/Sprite.js +2 -2
  192. package/src/renderers/WebGLMultiviewRenderTarget.js +35 -0
  193. package/src/renderers/WebGLRenderer.js +78 -22
  194. package/src/renderers/shaders/ShaderChunk/aomap_fragment.glsl.js +1 -1
  195. package/src/renderers/shaders/ShaderChunk/clearcoat_normal_fragment_begin.glsl.js +1 -1
  196. package/src/renderers/shaders/ShaderChunk/colorspace_pars_fragment.glsl.js +35 -2
  197. package/src/renderers/shaders/ShaderChunk/common.glsl.js +0 -9
  198. package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +19 -15
  199. package/src/renderers/shaders/ShaderChunk/lights_fragment_end.glsl.js +2 -2
  200. package/src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js +4 -4
  201. package/src/renderers/shaders/ShaderChunk/lights_lambert_pars_fragment.glsl.js +3 -3
  202. package/src/renderers/shaders/ShaderChunk/lights_pars_begin.glsl.js +11 -6
  203. package/src/renderers/shaders/ShaderChunk/lights_phong_pars_fragment.glsl.js +4 -4
  204. package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +1 -1
  205. package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +16 -16
  206. package/src/renderers/shaders/ShaderChunk/lights_toon_pars_fragment.glsl.js +3 -3
  207. package/src/renderers/shaders/ShaderChunk/normal_fragment_begin.glsl.js +1 -1
  208. package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +1 -1
  209. package/src/renderers/shaders/UniformsUtils.js +2 -2
  210. package/src/renderers/webgl/WebGLBackground.js +5 -4
  211. package/src/renderers/webgl/WebGLLights.js +14 -3
  212. package/src/renderers/webgl/WebGLMultiview.js +100 -0
  213. package/src/renderers/webgl/WebGLProgram.js +84 -5
  214. package/src/renderers/webgl/WebGLPrograms.js +11 -2
  215. package/src/renderers/webgl/WebGLTextures.js +214 -26
  216. package/src/renderers/webgl/WebGLUtils.js +21 -23
  217. package/src/renderers/webxr/WebXRManager.js +36 -12
  218. package/src/scenes/Fog.js +1 -0
  219. package/src/scenes/FogExp2.js +1 -0
  220. package/src/textures/Source.js +2 -2
  221. package/examples/jsm/renderers/webgpu/utils/WebGPUTextureMipmapUtils.js +0 -163
  222. package/src/lights/AmbientLightProbe.js +0 -21
  223. package/src/lights/HemisphereLightProbe.js +0 -30
@@ -21,7 +21,9 @@ import {
21
21
  UnsignedInt248Type,
22
22
  UnsignedShort4444Type,
23
23
  UnsignedShort5551Type,
24
- WebGLCoordinateSystem
24
+ WebGLCoordinateSystem,
25
+ DisplayP3ColorSpace,
26
+ LinearDisplayP3ColorSpace
25
27
  } from '../constants.js';
26
28
  import { Color } from '../math/Color.js';
27
29
  import { Frustum } from '../math/Frustum.js';
@@ -44,6 +46,7 @@ import { WebGLGeometries } from './webgl/WebGLGeometries.js';
44
46
  import { WebGLIndexedBufferRenderer } from './webgl/WebGLIndexedBufferRenderer.js';
45
47
  import { WebGLInfo } from './webgl/WebGLInfo.js';
46
48
  import { WebGLMorphtargets } from './webgl/WebGLMorphtargets.js';
49
+ import { WebGLMultiview } from './webgl/WebGLMultiview.js';
47
50
  import { WebGLObjects } from './webgl/WebGLObjects.js';
48
51
  import { WebGLPrograms } from './webgl/WebGLPrograms.js';
49
52
  import { WebGLProperties } from './webgl/WebGLProperties.js';
@@ -60,6 +63,7 @@ import { WebXRManager } from './webxr/WebXRManager.js';
60
63
  import { WebGLMaterials } from './webgl/WebGLMaterials.js';
61
64
  import { WebGLUniformsGroups } from './webgl/WebGLUniformsGroups.js';
62
65
  import { createCanvasElement } from '../utils.js';
66
+ import { ColorManagement } from '../math/ColorManagement.js';
63
67
 
64
68
  class WebGLRenderer {
65
69
 
@@ -76,6 +80,7 @@ class WebGLRenderer {
76
80
  preserveDrawingBuffer = false,
77
81
  powerPreference = 'default',
78
82
  failIfMajorPerformanceCaveat = false,
83
+ multiviewStereo = false,
79
84
  } = parameters;
80
85
 
81
86
  this.isWebGLRenderer = true;
@@ -141,7 +146,7 @@ class WebGLRenderer {
141
146
 
142
147
  // physically based shading
143
148
 
144
- this.outputColorSpace = SRGBColorSpace;
149
+ this._outputColorSpace = SRGBColorSpace;
145
150
 
146
151
  // physical lights
147
152
 
@@ -310,6 +315,7 @@ class WebGLRenderer {
310
315
  let extensions, capabilities, state, info;
311
316
  let properties, textures, cubemaps, cubeuvmaps, attributes, geometries, objects;
312
317
  let programCache, materials, renderLists, renderStates, clipping, shadowMap;
318
+ let multiview;
313
319
 
314
320
  let background, morphtargets, bufferRenderer, indexedBufferRenderer;
315
321
 
@@ -343,6 +349,7 @@ class WebGLRenderer {
343
349
  renderLists = new WebGLRenderLists();
344
350
  renderStates = new WebGLRenderStates( extensions, capabilities );
345
351
  background = new WebGLBackground( _this, cubemaps, cubeuvmaps, state, objects, _alpha, premultipliedAlpha );
352
+ multiview = new WebGLMultiview( _this, extensions, _gl );
346
353
  shadowMap = new WebGLShadowMap( _this, objects, capabilities );
347
354
  uniformsGroups = new WebGLUniformsGroups( _gl, info, capabilities, state );
348
355
 
@@ -365,7 +372,7 @@ class WebGLRenderer {
365
372
 
366
373
  // xr
367
374
 
368
- const xr = ( typeof navigator !== 'undefined' && 'xr' in navigator ) ? new WebXRManager( _this, _gl ) : new WebVRManager( _this );
375
+ const xr = ( typeof navigator !== 'undefined' && 'xr' in navigator ) ? new WebXRManager( _this, _gl, extensions, multiviewStereo ) : new WebVRManager( _this );
369
376
 
370
377
  this.xr = xr;
371
378
 
@@ -1112,13 +1119,23 @@ class WebGLRenderer {
1112
1119
 
1113
1120
  if ( camera.isArrayCamera ) {
1114
1121
 
1115
- const cameras = camera.cameras;
1122
+ if ( xr.enabled && xr.isMultiview ) {
1116
1123
 
1117
- for ( let i = 0, l = cameras.length; i < l; i ++ ) {
1124
+ textures.setDeferTextureUploads( true );
1118
1125
 
1119
- const camera2 = cameras[ i ];
1126
+ renderScene( currentRenderList, scene, camera, camera.cameras[ 0 ].viewport );
1120
1127
 
1121
- renderScene( currentRenderList, scene, camera2, camera2.viewport );
1128
+ } else {
1129
+
1130
+ const cameras = camera.cameras;
1131
+
1132
+ for ( let i = 0, l = cameras.length; i < l; i ++ ) {
1133
+
1134
+ const camera2 = cameras[ i ];
1135
+
1136
+ renderScene( currentRenderList, scene, camera2, camera2.viewport );
1137
+
1138
+ }
1122
1139
 
1123
1140
  }
1124
1141
 
@@ -1146,6 +1163,8 @@ class WebGLRenderer {
1146
1163
 
1147
1164
  if ( scene.isScene === true ) scene.onAfterRender( _this, scene, camera );
1148
1165
 
1166
+ textures.runDeferredUploads();
1167
+
1149
1168
  if ( xr.enabled && xr.submitFrame ) {
1150
1169
 
1151
1170
  xr.submitFrame();
@@ -1613,6 +1632,7 @@ class WebGLRenderer {
1613
1632
  materialProperties.vertexAlphas = parameters.vertexAlphas;
1614
1633
  materialProperties.vertexTangents = parameters.vertexTangents;
1615
1634
  materialProperties.toneMapping = parameters.toneMapping;
1635
+ materialProperties.numMultiviewViews = parameters.numMultiviewViews;
1616
1636
 
1617
1637
  }
1618
1638
 
@@ -1644,6 +1664,8 @@ class WebGLRenderer {
1644
1664
 
1645
1665
  }
1646
1666
 
1667
+ const numMultiviewViews = _currentRenderTarget && _currentRenderTarget.isWebGLMultiviewRenderTarget ? _currentRenderTarget.numViews : 0;
1668
+
1647
1669
  const morphAttribute = geometry.morphAttributes.position || geometry.morphAttributes.normal || geometry.morphAttributes.color;
1648
1670
  const morphTargetsCount = ( morphAttribute !== undefined ) ? morphAttribute.length : 0;
1649
1671
 
@@ -1747,6 +1769,10 @@ class WebGLRenderer {
1747
1769
 
1748
1770
  needsProgramChange = true;
1749
1771
 
1772
+ } else if ( materialProperties.numMultiviewViews !== numMultiviewViews ) {
1773
+
1774
+ needsProgramChange = true;
1775
+
1750
1776
  }
1751
1777
 
1752
1778
  } else {
@@ -1793,8 +1819,17 @@ class WebGLRenderer {
1793
1819
 
1794
1820
  // common camera uniforms
1795
1821
 
1796
- p_uniforms.setValue( _gl, 'projectionMatrix', camera.projectionMatrix );
1797
- p_uniforms.setValue( _gl, 'viewMatrix', camera.matrixWorldInverse );
1822
+ if ( program.numMultiviewViews > 0 ) {
1823
+
1824
+ multiview.updateCameraProjectionMatricesUniform( camera, p_uniforms );
1825
+ multiview.updateCameraViewMatricesUniform( camera, p_uniforms );
1826
+
1827
+ } else {
1828
+
1829
+ p_uniforms.setValue( _gl, 'projectionMatrix', camera.projectionMatrix );
1830
+ p_uniforms.setValue( _gl, 'viewMatrix', camera.matrixWorldInverse );
1831
+
1832
+ }
1798
1833
 
1799
1834
  const uCamPos = p_uniforms.map.cameraPosition;
1800
1835
 
@@ -1942,8 +1977,17 @@ class WebGLRenderer {
1942
1977
 
1943
1978
  // common matrices
1944
1979
 
1945
- p_uniforms.setValue( _gl, 'modelViewMatrix', object.modelViewMatrix );
1946
- p_uniforms.setValue( _gl, 'normalMatrix', object.normalMatrix );
1980
+ if ( program.numMultiviewViews > 0 ) {
1981
+
1982
+ multiview.updateObjectMatricesUniforms( object, camera, p_uniforms );
1983
+
1984
+ } else {
1985
+
1986
+ p_uniforms.setValue( _gl, 'modelViewMatrix', object.modelViewMatrix );
1987
+ p_uniforms.setValue( _gl, 'normalMatrix', object.normalMatrix );
1988
+
1989
+ }
1990
+
1947
1991
  p_uniforms.setValue( _gl, 'modelMatrix', object.matrixWorld );
1948
1992
 
1949
1993
  // UBOs
@@ -2053,20 +2097,16 @@ class WebGLRenderer {
2053
2097
  const renderTargetProperties = properties.get( renderTarget );
2054
2098
  renderTargetProperties.__hasExternalTextures = true;
2055
2099
 
2056
- if ( renderTargetProperties.__hasExternalTextures ) {
2057
-
2058
- renderTargetProperties.__autoAllocateDepthBuffer = depthTexture === undefined;
2100
+ renderTargetProperties.__autoAllocateDepthBuffer = depthTexture === undefined;
2059
2101
 
2060
- if ( ! renderTargetProperties.__autoAllocateDepthBuffer ) {
2102
+ if ( ! renderTargetProperties.__autoAllocateDepthBuffer && ! _currentRenderTarget.isWebGLMultiviewRenderTarget ) {
2061
2103
 
2062
- // The multisample_render_to_texture extension doesn't work properly if there
2063
- // are midframe flushes and an external depth buffer. Disable use of the extension.
2064
- if ( extensions.has( 'WEBGL_multisampled_render_to_texture' ) === true ) {
2104
+ // The multisample_render_to_texture extension doesn't work properly if there
2105
+ // are midframe flushes and an external depth buffer. Disable use of the extension.
2106
+ if ( extensions.has( 'WEBGL_multisampled_render_to_texture' ) === true ) {
2065
2107
 
2066
- console.warn( 'THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided' );
2067
- renderTargetProperties.__useRenderToTexture = false;
2068
-
2069
- }
2108
+ console.warn( 'THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided' );
2109
+ renderTargetProperties.__useRenderToTexture = false;
2070
2110
 
2071
2111
  }
2072
2112
 
@@ -2449,6 +2489,22 @@ class WebGLRenderer {
2449
2489
 
2450
2490
  }
2451
2491
 
2492
+ get outputColorSpace() {
2493
+
2494
+ return this._outputColorSpace;
2495
+
2496
+ }
2497
+
2498
+ set outputColorSpace( colorSpace ) {
2499
+
2500
+ this._outputColorSpace = colorSpace;
2501
+
2502
+ const gl = this.getContext();
2503
+ gl.drawingBufferColorSpace = colorSpace === DisplayP3ColorSpace ? 'display-p3' : 'srgb';
2504
+ gl.unpackColorSpace = ColorManagement.workingColorSpace === LinearDisplayP3ColorSpace ? 'display-p3' : 'srgb';
2505
+
2506
+ }
2507
+
2452
2508
  get physicallyCorrectLights() { // @deprecated, r150
2453
2509
 
2454
2510
  console.warn( 'THREE.WebGLRenderer: The property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead.' );
@@ -8,7 +8,7 @@ export default /* glsl */`
8
8
 
9
9
  #if defined( USE_ENVMAP ) && defined( STANDARD )
10
10
 
11
- float dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );
11
+ float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
12
12
 
13
13
  reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
14
14
 
@@ -1,7 +1,7 @@
1
1
  export default /* glsl */`
2
2
  #ifdef USE_CLEARCOAT
3
3
 
4
- vec3 clearcoatNormal = geometryNormal;
4
+ vec3 clearcoatNormal = nonPerturbedNormal;
5
5
 
6
6
  #endif
7
7
  `;
@@ -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