super-three 0.136.0 → 0.136.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 (125) hide show
  1. package/LICENSE +1 -1
  2. package/build/three.js +1634 -1608
  3. package/build/three.min.js +1 -1
  4. package/build/three.module.js +4630 -4534
  5. package/examples/js/animation/MMDPhysics.js +1 -1
  6. package/examples/js/cameras/CinematicCamera.js +2 -7
  7. package/examples/js/exporters/MMDExporter.js +1 -1
  8. package/examples/js/geometries/ConvexGeometry.js +1 -1
  9. package/examples/js/loaders/BasisTextureLoader.js +1 -0
  10. package/examples/js/loaders/EXRLoader.js +25 -19
  11. package/examples/js/loaders/GLTFLoader.js +2 -2
  12. package/examples/js/loaders/HDRCubeTextureLoader.js +0 -2
  13. package/examples/js/loaders/LDrawLoader.js +1131 -859
  14. package/examples/js/loaders/LUT3dlLoader.js +17 -10
  15. package/examples/js/loaders/LUTCubeLoader.js +3 -4
  16. package/examples/js/loaders/RGBELoader.js +6 -6
  17. package/examples/js/loaders/RGBMLoader.js +1 -1
  18. package/examples/js/loaders/SVGLoader.js +3 -1
  19. package/examples/js/loaders/VRMLLoader.js +9 -21
  20. package/examples/js/math/ConvexHull.js +7 -13
  21. package/examples/js/misc/Volume.js +2 -2
  22. package/examples/js/modifiers/CurveModifier.js +8 -7
  23. package/examples/js/modifiers/EdgeSplitModifier.js +1 -1
  24. package/examples/js/modifiers/SimplifyModifier.js +1 -1
  25. package/examples/js/objects/Reflector.js +1 -13
  26. package/examples/js/objects/ReflectorForSSRPass.js +0 -10
  27. package/examples/js/objects/Refractor.js +1 -13
  28. package/examples/js/objects/Water.js +1 -13
  29. package/examples/js/postprocessing/GlitchPass.js +4 -5
  30. package/examples/js/postprocessing/SMAAPass.js +2 -9
  31. package/examples/js/postprocessing/SSAOPass.js +9 -21
  32. package/examples/js/postprocessing/SavePass.js +1 -5
  33. package/examples/js/shaders/DigitalGlitch.js +3 -3
  34. package/examples/js/shaders/MMDToonShader.js +0 -1
  35. package/examples/js/shaders/SSAOShader.js +1 -1
  36. package/examples/jsm/animation/MMDPhysics.js +1 -1
  37. package/examples/jsm/cameras/CinematicCamera.js +2 -5
  38. package/examples/jsm/{WebGL.js → capabilities/WebGL.js} +2 -2
  39. package/examples/jsm/{renderers/webgpu → capabilities}/WebGPU.js +1 -1
  40. package/examples/jsm/exporters/GLTFExporter.js +8 -24
  41. package/examples/jsm/exporters/MMDExporter.js +1 -1
  42. package/examples/jsm/geometries/ConvexGeometry.js +1 -1
  43. package/examples/jsm/libs/lil-gui.module.min.js +2 -2
  44. package/examples/jsm/loaders/BasisTextureLoader.js +7 -0
  45. package/examples/jsm/loaders/EXRLoader.js +22 -19
  46. package/examples/jsm/loaders/GLTFLoader.js +1 -3
  47. package/examples/jsm/loaders/HDRCubeTextureLoader.js +1 -4
  48. package/examples/jsm/loaders/LDrawLoader.js +1147 -885
  49. package/examples/jsm/loaders/LUT3dlLoader.js +17 -12
  50. package/examples/jsm/loaders/LUTCubeLoader.js +3 -5
  51. package/examples/jsm/loaders/RGBELoader.js +7 -8
  52. package/examples/jsm/loaders/RGBMLoader.js +1 -1
  53. package/examples/jsm/loaders/SVGLoader.js +6 -1
  54. package/examples/jsm/loaders/VRMLLoader.js +9 -22
  55. package/examples/jsm/math/ConvexHull.js +7 -13
  56. package/examples/jsm/misc/Volume.js +2 -2
  57. package/examples/jsm/modifiers/CurveModifier.js +9 -8
  58. package/examples/jsm/modifiers/EdgeSplitModifier.js +1 -1
  59. package/examples/jsm/modifiers/SimplifyModifier.js +1 -1
  60. package/examples/jsm/node-editor/NodeEditor.js +21 -22
  61. package/examples/jsm/nodes/utils/ColorSpaceNode.js +4 -13
  62. package/examples/jsm/objects/Lensflare.js +4 -4
  63. package/examples/jsm/objects/Reflector.js +1 -16
  64. package/examples/jsm/objects/ReflectorForSSRPass.js +0 -12
  65. package/examples/jsm/objects/Refractor.js +1 -16
  66. package/examples/jsm/objects/Water.js +1 -16
  67. package/examples/jsm/postprocessing/GlitchPass.js +7 -6
  68. package/examples/jsm/postprocessing/SMAAPass.js +2 -11
  69. package/examples/jsm/postprocessing/SSAOPass.js +13 -25
  70. package/examples/jsm/postprocessing/SavePass.js +1 -3
  71. package/examples/jsm/renderers/nodes/Nodes.js +2 -0
  72. package/examples/jsm/renderers/nodes/ShaderNode.js +58 -31
  73. package/examples/jsm/renderers/nodes/display/ColorSpaceNode.js +9 -46
  74. package/examples/jsm/renderers/nodes/inputs/TextureNode.js +5 -10
  75. package/examples/jsm/renderers/nodes/math/MathNode.js +2 -1
  76. package/examples/jsm/renderers/webgpu/WebGPUObjects.js +1 -1
  77. package/examples/jsm/renderers/webgpu/WebGPURenderer.js +3 -5
  78. package/examples/jsm/renderers/webgpu/WebGPUTextures.js +1 -2
  79. package/examples/jsm/renderers/webgpu/nodes/WebGPUNodeBuilder.js +10 -4
  80. package/examples/jsm/shaders/DigitalGlitch.js +3 -3
  81. package/examples/jsm/shaders/MMDToonShader.js +0 -1
  82. package/examples/jsm/shaders/SSAOShader.js +1 -1
  83. package/examples/jsm/utils/LDrawUtils.js +195 -0
  84. package/examples/jsm/webxr/VRButton.js +24 -0
  85. package/examples/jsm/webxr/XREstimatedLight.js +2 -0
  86. package/package.json +4 -1
  87. package/src/animation/AnimationMixer.js +1 -0
  88. package/src/cameras/CubeCamera.js +2 -0
  89. package/src/constants.js +3 -16
  90. package/src/extras/ImageUtils.js +63 -0
  91. package/src/extras/PMREMGenerator.js +32 -82
  92. package/src/loaders/MaterialLoader.js +1 -1
  93. package/src/materials/Material.js +4 -4
  94. package/src/math/Color.js +1 -1
  95. package/src/math/Quaternion.js +1 -1
  96. package/src/renderers/WebGLCubeRenderTarget.js +0 -2
  97. package/src/renderers/WebGLRenderer.js +1 -67
  98. package/src/renderers/shaders/ShaderChunk/emissivemap_fragment.glsl.js +0 -2
  99. package/src/renderers/shaders/ShaderChunk/encodings_pars_fragment.glsl.js +0 -4
  100. package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +0 -2
  101. package/src/renderers/shaders/ShaderChunk/lightmap_fragment.glsl.js +1 -1
  102. package/src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js +1 -1
  103. package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +2 -2
  104. package/src/renderers/shaders/ShaderChunk/map_fragment.glsl.js +10 -3
  105. package/src/renderers/shaders/ShaderChunk/map_particle_fragment.glsl.js +1 -2
  106. package/src/renderers/shaders/ShaderChunk/transmission_pars_fragment.glsl.js +8 -7
  107. package/src/renderers/shaders/ShaderLib/background.glsl.js +1 -3
  108. package/src/renderers/shaders/ShaderLib/equirect.glsl.js +1 -3
  109. package/src/renderers/shaders/ShaderLib/meshbasic.glsl.js +1 -1
  110. package/src/renderers/shaders/ShaderLib/meshmatcap.glsl.js +1 -2
  111. package/src/renderers/shaders/ShaderLib.js +2 -2
  112. package/src/renderers/webgl/WebGLCubeMaps.js +0 -4
  113. package/src/renderers/webgl/WebGLCubeUVMaps.js +29 -16
  114. package/src/renderers/webgl/WebGLMorphtargets.js +12 -0
  115. package/src/renderers/webgl/WebGLProgram.js +4 -16
  116. package/src/renderers/webgl/WebGLPrograms.js +8 -47
  117. package/src/renderers/webgl/WebGLState.js +81 -0
  118. package/src/renderers/webgl/WebGLTextures.js +75 -22
  119. package/src/renderers/webgl/WebGLUtils.js +86 -28
  120. package/src/renderers/webxr/WebXRManager.js +3 -3
  121. package/src/textures/Texture.js +2 -1
  122. package/src/textures/VideoTexture.js +1 -3
  123. package/examples/js/WebGL.js +0 -90
  124. package/examples/js/utils/RoughnessMipmapper.js +0 -268
  125. package/examples/jsm/utils/RoughnessMipmapper.js +0 -288
@@ -7,8 +7,6 @@ import {
7
7
  NoToneMapping,
8
8
  NoBlending,
9
9
  RGBAFormat,
10
- UnsignedByteType,
11
- sRGBEncoding,
12
10
  HalfFloatType
13
11
  } from '../constants.js';
14
12
 
@@ -42,11 +40,6 @@ const TOTAL_LODS = LOD_MAX - LOD_MIN + 1 + EXTRA_LOD_SIGMA.length;
42
40
  // samples and exit early, but not recompile the shader.
43
41
  const MAX_SAMPLES = 20;
44
42
 
45
- const ENCODINGS = {
46
- [ LinearEncoding ]: 0,
47
- [ sRGBEncoding ]: 1
48
- };
49
-
50
43
  const _flatCamera = /*@__PURE__*/ new OrthographicCamera();
51
44
  const { _lodPlanes, _sizeLods, _sigmas } = /*@__PURE__*/ _createPlanes();
52
45
  const _clearColor = /*@__PURE__*/ new Color();
@@ -131,9 +124,9 @@ class PMREMGenerator {
131
124
  * or HDR. The ideal input image size is 1k (1024 x 512),
132
125
  * as this matches best with the 256 x 256 cubemap output.
133
126
  */
134
- fromEquirectangular( equirectangular ) {
127
+ fromEquirectangular( equirectangular, renderTarget = null ) {
135
128
 
136
- return this._fromTexture( equirectangular );
129
+ return this._fromTexture( equirectangular, renderTarget );
137
130
 
138
131
  }
139
132
 
@@ -142,9 +135,9 @@ class PMREMGenerator {
142
135
  * or HDR. The ideal input cube size is 256 x 256,
143
136
  * as this matches best with the 256 x 256 cubemap output.
144
137
  */
145
- fromCubemap( cubemap ) {
138
+ fromCubemap( cubemap, renderTarget = null ) {
146
139
 
147
- return this._fromTexture( cubemap );
140
+ return this._fromTexture( cubemap, renderTarget );
148
141
 
149
142
  }
150
143
 
@@ -187,6 +180,8 @@ class PMREMGenerator {
187
180
 
188
181
  this._blurMaterial.dispose();
189
182
 
183
+ if ( this._pingPongRenderTarget !== null ) this._pingPongRenderTarget.dispose();
184
+
190
185
  if ( this._cubemapShader !== null ) this._cubemapShader.dispose();
191
186
  if ( this._equirectShader !== null ) this._equirectShader.dispose();
192
187
 
@@ -202,17 +197,16 @@ class PMREMGenerator {
202
197
 
203
198
  _cleanup( outputTarget ) {
204
199
 
205
- this._pingPongRenderTarget.dispose();
206
200
  this._renderer.setRenderTarget( _oldTarget );
207
201
  outputTarget.scissorTest = false;
208
202
  _setViewport( outputTarget, 0, 0, outputTarget.width, outputTarget.height );
209
203
 
210
204
  }
211
205
 
212
- _fromTexture( texture ) {
206
+ _fromTexture( texture, renderTarget ) {
213
207
 
214
208
  _oldTarget = this._renderer.getRenderTarget();
215
- const cubeUVRenderTarget = this._allocateTargets( texture );
209
+ const cubeUVRenderTarget = renderTarget || this._allocateTargets( texture );
216
210
  this._textureToCubeUV( texture, cubeUVRenderTarget );
217
211
  this._applyPMREM( cubeUVRenderTarget );
218
212
  this._cleanup( cubeUVRenderTarget );
@@ -235,7 +229,13 @@ class PMREMGenerator {
235
229
 
236
230
  const cubeUVRenderTarget = _createRenderTarget( params );
237
231
  cubeUVRenderTarget.depthBuffer = texture ? false : true;
238
- this._pingPongRenderTarget = _createRenderTarget( params );
232
+
233
+ if ( this._pingPongRenderTarget === null ) {
234
+
235
+ this._pingPongRenderTarget = _createRenderTarget( params );
236
+
237
+ }
238
+
239
239
  return cubeUVRenderTarget;
240
240
 
241
241
  }
@@ -295,12 +295,12 @@ class PMREMGenerator {
295
295
  for ( let i = 0; i < 6; i ++ ) {
296
296
 
297
297
  const col = i % 3;
298
- if ( col == 0 ) {
298
+ if ( col === 0 ) {
299
299
 
300
300
  cubeCamera.up.set( 0, upSign[ i ], 0 );
301
301
  cubeCamera.lookAt( forwardSign[ i ], 0, 0 );
302
302
 
303
- } else if ( col == 1 ) {
303
+ } else if ( col === 1 ) {
304
304
 
305
305
  cubeCamera.up.set( 0, 0, upSign[ i ] );
306
306
  cubeCamera.lookAt( 0, forwardSign[ i ], 0 );
@@ -335,20 +335,6 @@ class PMREMGenerator {
335
335
 
336
336
  }
337
337
 
338
- _setEncoding( uniform, texture ) {
339
-
340
- if ( this._renderer.capabilities.isWebGL2 === true && texture.format === RGBAFormat && texture.type === UnsignedByteType && texture.encoding === sRGBEncoding ) {
341
-
342
- uniform.value = ENCODINGS[ LinearEncoding ];
343
-
344
- } else {
345
-
346
- uniform.value = ENCODINGS[ texture.encoding ];
347
-
348
- }
349
-
350
- }
351
-
352
338
  _textureToCubeUV( texture, cubeUVRenderTarget ) {
353
339
 
354
340
  const renderer = this._renderer;
@@ -357,15 +343,17 @@ class PMREMGenerator {
357
343
 
358
344
  if ( isCubeTexture ) {
359
345
 
360
- if ( this._cubemapShader == null ) {
346
+ if ( this._cubemapShader === null ) {
361
347
 
362
348
  this._cubemapShader = _getCubemapShader();
363
349
 
364
350
  }
365
351
 
352
+ this._cubemapShader.uniforms.flipEnvMap.value = ( texture.isRenderTargetTexture === false ) ? - 1 : 1;
353
+
366
354
  } else {
367
355
 
368
- if ( this._equirectShader == null ) {
356
+ if ( this._equirectShader === null ) {
369
357
 
370
358
  this._equirectShader = _getEquirectShader();
371
359
 
@@ -386,8 +374,6 @@ class PMREMGenerator {
386
374
 
387
375
  }
388
376
 
389
- this._setEncoding( uniforms[ 'inputEncoding' ], texture );
390
-
391
377
  _setViewport( cubeUVRenderTarget, 0, 0, 3 * SIZE_MAX, 2 * SIZE_MAX );
392
378
 
393
379
  renderer.setRenderTarget( cubeUVRenderTarget );
@@ -486,7 +472,7 @@ class PMREMGenerator {
486
472
  const weight = Math.exp( - x * x / 2 );
487
473
  weights.push( weight );
488
474
 
489
- if ( i == 0 ) {
475
+ if ( i === 0 ) {
490
476
 
491
477
  sum += weight;
492
478
 
@@ -548,7 +534,7 @@ function _createPlanes() {
548
534
 
549
535
  sigma = EXTRA_LOD_SIGMA[ i - LOD_MAX + LOD_MIN - 1 ];
550
536
 
551
- } else if ( i == 0 ) {
537
+ } else if ( i === 0 ) {
552
538
 
553
539
  sigma = 0;
554
540
 
@@ -662,8 +648,6 @@ function _getBlurShader( maxSamples ) {
662
648
  uniform float mipInt;
663
649
  uniform vec3 poleAxis;
664
650
 
665
- ${ _getEncodings() }
666
-
667
651
  #define ENVMAP_TYPE_CUBE_UV
668
652
  #include <cube_uv_reflection_fragment>
669
653
 
@@ -730,8 +714,7 @@ function _getEquirectShader() {
730
714
 
731
715
  uniforms: {
732
716
  'envMap': { value: null },
733
- 'texelSize': { value: texelSize },
734
- 'inputEncoding': { value: ENCODINGS[ LinearEncoding ] }
717
+ 'texelSize': { value: texelSize }
735
718
  },
736
719
 
737
720
  vertexShader: _getCommonVertexShader(),
@@ -746,8 +729,6 @@ function _getEquirectShader() {
746
729
  uniform sampler2D envMap;
747
730
  uniform vec2 texelSize;
748
731
 
749
- ${ _getEncodings() }
750
-
751
732
  #include <common>
752
733
 
753
734
  void main() {
@@ -759,13 +740,13 @@ function _getEquirectShader() {
759
740
 
760
741
  vec2 f = fract( uv / texelSize - 0.5 );
761
742
  uv -= f * texelSize;
762
- vec3 tl = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb;
743
+ vec3 tl = texture2D ( envMap, uv ).rgb;
763
744
  uv.x += texelSize.x;
764
- vec3 tr = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb;
745
+ vec3 tr = texture2D ( envMap, uv ).rgb;
765
746
  uv.y += texelSize.y;
766
- vec3 br = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb;
747
+ vec3 br = texture2D ( envMap, uv ).rgb;
767
748
  uv.x -= texelSize.x;
768
- vec3 bl = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb;
749
+ vec3 bl = texture2D ( envMap, uv ).rgb;
769
750
 
770
751
  vec3 tm = mix( tl, tr, f.x );
771
752
  vec3 bm = mix( bl, br, f.x );
@@ -792,7 +773,7 @@ function _getCubemapShader() {
792
773
 
793
774
  uniforms: {
794
775
  'envMap': { value: null },
795
- 'inputEncoding': { value: ENCODINGS[ LinearEncoding ] }
776
+ 'flipEnvMap': { value: - 1 }
796
777
  },
797
778
 
798
779
  vertexShader: _getCommonVertexShader(),
@@ -802,15 +783,15 @@ function _getCubemapShader() {
802
783
  precision mediump float;
803
784
  precision mediump int;
804
785
 
786
+ uniform float flipEnvMap;
787
+
805
788
  varying vec3 vOutputDirection;
806
789
 
807
790
  uniform samplerCube envMap;
808
791
 
809
- ${ _getEncodings() }
810
-
811
792
  void main() {
812
793
 
813
- gl_FragColor = envMapTexelToLinear( textureCube( envMap, vec3( - vOutputDirection.x, vOutputDirection.yz ) ) );
794
+ gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
814
795
 
815
796
  }
816
797
  `,
@@ -888,35 +869,4 @@ function _getCommonVertexShader() {
888
869
 
889
870
  }
890
871
 
891
- function _getEncodings() {
892
-
893
- return /* glsl */`
894
-
895
- uniform int inputEncoding;
896
-
897
- #include <encodings_pars_fragment>
898
-
899
- vec4 inputTexelToLinear( vec4 value ) {
900
-
901
- if ( inputEncoding == 0 ) {
902
-
903
- return value;
904
-
905
- } else {
906
-
907
- return sRGBToLinear( value );
908
-
909
- }
910
-
911
- }
912
-
913
- vec4 envMapTexelToLinear( vec4 color ) {
914
-
915
- return inputTexelToLinear( color );
916
-
917
- }
918
- `;
919
-
920
- }
921
-
922
872
  export { PMREMGenerator };
@@ -95,12 +95,12 @@ class MaterialLoader extends Loader {
95
95
  if ( json.side !== undefined ) material.side = json.side;
96
96
  if ( json.shadowSide !== undefined ) material.shadowSide = json.shadowSide;
97
97
  if ( json.opacity !== undefined ) material.opacity = json.opacity;
98
- if ( json.format !== undefined ) material.format = json.format;
99
98
  if ( json.transparent !== undefined ) material.transparent = json.transparent;
100
99
  if ( json.alphaTest !== undefined ) material.alphaTest = json.alphaTest;
101
100
  if ( json.depthTest !== undefined ) material.depthTest = json.depthTest;
102
101
  if ( json.depthWrite !== undefined ) material.depthWrite = json.depthWrite;
103
102
  if ( json.colorWrite !== undefined ) material.colorWrite = json.colorWrite;
103
+ if ( json.alphaWrite !== undefined ) material.alphaWrite = json.alphaWrite;
104
104
 
105
105
  if ( json.stencilWrite !== undefined ) material.stencilWrite = json.stencilWrite;
106
106
  if ( json.stencilWriteMask !== undefined ) material.stencilWriteMask = json.stencilWriteMask;
@@ -1,5 +1,5 @@
1
1
  import { EventDispatcher } from '../core/EventDispatcher.js';
2
- import { FrontSide, FlatShading, NormalBlending, LessEqualDepth, AddEquation, OneMinusSrcAlphaFactor, SrcAlphaFactor, AlwaysStencilFunc, KeepStencilOp, RGBAFormat } from '../constants.js';
2
+ import { FrontSide, FlatShading, NormalBlending, LessEqualDepth, AddEquation, OneMinusSrcAlphaFactor, SrcAlphaFactor, AlwaysStencilFunc, KeepStencilOp } from '../constants.js';
3
3
  import * as MathUtils from '../math/MathUtils.js';
4
4
 
5
5
  let materialId = 0;
@@ -24,7 +24,6 @@ class Material extends EventDispatcher {
24
24
  this.vertexColors = false;
25
25
 
26
26
  this.opacity = 1;
27
- this.format = RGBAFormat;
28
27
  this.transparent = false;
29
28
 
30
29
  this.blendSrc = SrcAlphaFactor;
@@ -54,6 +53,7 @@ class Material extends EventDispatcher {
54
53
  this.shadowSide = null;
55
54
 
56
55
  this.colorWrite = true;
56
+ this.alphaWrite = true;
57
57
 
58
58
  this.precision = null; // override the renderer's default precision for this material
59
59
 
@@ -306,13 +306,13 @@ class Material extends EventDispatcher {
306
306
  if ( this.vertexColors ) data.vertexColors = true;
307
307
 
308
308
  if ( this.opacity < 1 ) data.opacity = this.opacity;
309
- if ( this.format !== RGBAFormat ) data.format = this.format;
310
309
  if ( this.transparent === true ) data.transparent = this.transparent;
311
310
 
312
311
  data.depthFunc = this.depthFunc;
313
312
  data.depthTest = this.depthTest;
314
313
  data.depthWrite = this.depthWrite;
315
314
  data.colorWrite = this.colorWrite;
315
+ data.alphaWrite = this.alphaWrite;
316
316
 
317
317
  data.stencilWrite = this.stencilWrite;
318
318
  data.stencilWriteMask = this.stencilWriteMask;
@@ -403,7 +403,6 @@ class Material extends EventDispatcher {
403
403
  this.vertexColors = source.vertexColors;
404
404
 
405
405
  this.opacity = source.opacity;
406
- this.format = source.format;
407
406
  this.transparent = source.transparent;
408
407
 
409
408
  this.blendSrc = source.blendSrc;
@@ -449,6 +448,7 @@ class Material extends EventDispatcher {
449
448
  this.shadowSide = source.shadowSide;
450
449
 
451
450
  this.colorWrite = source.colorWrite;
451
+ this.alphaWrite = source.alphaWrite;
452
452
 
453
453
  this.precision = source.precision;
454
454
 
package/src/math/Color.js CHANGED
@@ -563,4 +563,4 @@ Color.prototype.r = 1;
563
563
  Color.prototype.g = 1;
564
564
  Color.prototype.b = 1;
565
565
 
566
- export { Color };
566
+ export { Color, SRGBToLinear };
@@ -604,7 +604,7 @@ class Quaternion {
604
604
 
605
605
  slerpQuaternions( qa, qb, t ) {
606
606
 
607
- this.copy( qa ).slerp( qb, t );
607
+ return this.copy( qa ).slerp( qb, t );
608
608
 
609
609
  }
610
610
 
@@ -37,8 +37,6 @@ class WebGLCubeRenderTarget extends WebGLRenderTarget {
37
37
  this.texture.generateMipmaps = options.generateMipmaps !== undefined ? options.generateMipmaps : false;
38
38
  this.texture.minFilter = options.minFilter !== undefined ? options.minFilter : LinearFilter;
39
39
 
40
- this.texture._needsFlipEnvMap = false;
41
-
42
40
  }
43
41
 
44
42
  fromEquirectangularTexture( renderer, texture ) {
@@ -154,10 +154,6 @@ function WebGLRenderer( parameters = {} ) {
154
154
  const _scissor = new Vector4( 0, 0, _width, _height );
155
155
  let _scissorTest = false;
156
156
 
157
- //
158
-
159
- const _currentDrawBuffers = [];
160
-
161
157
  // frustum
162
158
 
163
159
  const _frustum = new Frustum();
@@ -290,8 +286,6 @@ function WebGLRenderer( parameters = {} ) {
290
286
 
291
287
  state = new WebGLState( _gl, extensions, capabilities );
292
288
 
293
- _currentDrawBuffers[ 0 ] = _gl.BACK;
294
-
295
289
  info = new WebGLInfo( _gl );
296
290
  properties = new WebGLProperties();
297
291
  textures = new WebGLTextures( _gl, extensions, state, properties, capabilities, utils, info );
@@ -1920,67 +1914,7 @@ function WebGLRenderer( parameters = {} ) {
1920
1914
 
1921
1915
  if ( framebufferBound && capabilities.drawBuffers && useDefaultFramebuffer ) {
1922
1916
 
1923
- let needsUpdate = false;
1924
-
1925
- if ( renderTarget ) {
1926
-
1927
- if ( renderTarget.isWebGLMultipleRenderTargets ) {
1928
-
1929
- const textures = renderTarget.texture;
1930
-
1931
- if ( _currentDrawBuffers.length !== textures.length || _currentDrawBuffers[ 0 ] !== _gl.COLOR_ATTACHMENT0 ) {
1932
-
1933
- for ( let i = 0, il = textures.length; i < il; i ++ ) {
1934
-
1935
- _currentDrawBuffers[ i ] = _gl.COLOR_ATTACHMENT0 + i;
1936
-
1937
- }
1938
-
1939
- _currentDrawBuffers.length = textures.length;
1940
-
1941
- needsUpdate = true;
1942
-
1943
- }
1944
-
1945
- } else {
1946
-
1947
- if ( _currentDrawBuffers.length !== 1 || _currentDrawBuffers[ 0 ] !== _gl.COLOR_ATTACHMENT0 ) {
1948
-
1949
- _currentDrawBuffers[ 0 ] = _gl.COLOR_ATTACHMENT0;
1950
- _currentDrawBuffers.length = 1;
1951
-
1952
- needsUpdate = true;
1953
-
1954
- }
1955
-
1956
- }
1957
-
1958
- } else {
1959
-
1960
- if ( _currentDrawBuffers.length !== 1 || _currentDrawBuffers[ 0 ] !== _gl.BACK ) {
1961
-
1962
- _currentDrawBuffers[ 0 ] = _gl.BACK;
1963
- _currentDrawBuffers.length = 1;
1964
-
1965
- needsUpdate = true;
1966
-
1967
- }
1968
-
1969
- }
1970
-
1971
- if ( needsUpdate ) {
1972
-
1973
- if ( capabilities.isWebGL2 ) {
1974
-
1975
- _gl.drawBuffers( _currentDrawBuffers );
1976
-
1977
- } else {
1978
-
1979
- extensions.get( 'WEBGL_draw_buffers' ).drawBuffersWEBGL( _currentDrawBuffers );
1980
-
1981
- }
1982
-
1983
- }
1917
+ state.drawBuffers( renderTarget, framebuffer );
1984
1918
 
1985
1919
  }
1986
1920
 
@@ -3,8 +3,6 @@ export default /* glsl */`
3
3
 
4
4
  vec4 emissiveColor = texture2D( emissiveMap, vUv );
5
5
 
6
- emissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;
7
-
8
6
  totalEmissiveRadiance *= emissiveColor.rgb;
9
7
 
10
8
  #endif
@@ -4,10 +4,6 @@ vec4 LinearToLinear( in vec4 value ) {
4
4
  return value;
5
5
  }
6
6
 
7
- vec4 sRGBToLinear( in vec4 value ) {
8
- return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );
9
- }
10
-
11
7
  vec4 LinearTosRGB( in vec4 value ) {
12
8
  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 );
13
9
  }
@@ -38,8 +38,6 @@ export default /* glsl */`
38
38
 
39
39
  vec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
40
40
 
41
- envColor = envMapTexelToLinear( envColor );
42
-
43
41
  #elif defined( ENVMAP_TYPE_CUBE_UV )
44
42
 
45
43
  vec4 envColor = textureCubeUV( envMap, reflectVec, 0.0 );
@@ -2,7 +2,7 @@ export default /* glsl */`
2
2
  #ifdef USE_LIGHTMAP
3
3
 
4
4
  vec4 lightMapTexel = texture2D( lightMap, vUv2 );
5
- vec3 lightMapIrradiance = lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;
5
+ vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
6
6
 
7
7
  #ifndef PHYSICALLY_CORRECT_LIGHTS
8
8
 
@@ -4,7 +4,7 @@ export default /* glsl */`
4
4
  #ifdef USE_LIGHTMAP
5
5
 
6
6
  vec4 lightMapTexel = texture2D( lightMap, vUv2 );
7
- vec3 lightMapIrradiance = lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;
7
+ vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
8
8
 
9
9
  #ifndef PHYSICALLY_CORRECT_LIGHTS
10
10
 
@@ -24,7 +24,7 @@ material.roughness = min( material.roughness, 1.0 );
24
24
 
25
25
  #ifdef USE_SPECULARCOLORMAP
26
26
 
27
- specularColorFactor *= specularColorMapTexelToLinear( texture2D( specularColorMap, vUv ) ).rgb;
27
+ specularColorFactor *= texture2D( specularColorMap, vUv ).rgb;
28
28
 
29
29
  #endif
30
30
 
@@ -79,7 +79,7 @@ material.roughness = min( material.roughness, 1.0 );
79
79
 
80
80
  #ifdef USE_SHEENCOLORMAP
81
81
 
82
- material.sheenColor *= sheenColorMapTexelToLinear( texture2D( sheenColorMap, vUv ) ).rgb;
82
+ material.sheenColor *= texture2D( sheenColorMap, vUv ).rgb;
83
83
 
84
84
  #endif
85
85
 
@@ -1,10 +1,17 @@
1
1
  export default /* glsl */`
2
2
  #ifdef USE_MAP
3
3
 
4
- vec4 texelColor = texture2D( map, vUv );
4
+ vec4 sampledDiffuseColor = texture2D( map, vUv );
5
5
 
6
- texelColor = mapTexelToLinear( texelColor );
7
- diffuseColor *= texelColor;
6
+ #ifdef DECODE_VIDEO_TEXTURE
7
+
8
+ // inline sRGB decode (TODO: Remove this code when https://crbug.com/1256340 is solved)
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;
8
15
 
9
16
  #endif
10
17
  `;
@@ -7,8 +7,7 @@ export default /* glsl */`
7
7
 
8
8
  #ifdef USE_MAP
9
9
 
10
- vec4 mapTexel = texture2D( map, uv );
11
- diffuseColor *= mapTexelToLinear( mapTexel );
10
+ diffuseColor *= texture2D( map, uv );
12
11
 
13
12
  #endif
14
13
 
@@ -29,7 +29,7 @@ export default /* glsl */`
29
29
 
30
30
  varying vec3 vWorldPosition;
31
31
 
32
- vec3 getVolumeTransmissionRay( vec3 n, vec3 v, float thickness, float ior, mat4 modelMatrix ) {
32
+ vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
33
33
 
34
34
  // Direction of refracted light.
35
35
  vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
@@ -45,7 +45,7 @@ export default /* glsl */`
45
45
 
46
46
  }
47
47
 
48
- float applyIorToRoughness( float roughness, float ior ) {
48
+ float applyIorToRoughness( const in float roughness, const in float ior ) {
49
49
 
50
50
  // Scale roughness with IOR so that an IOR of 1.0 results in no microfacet refraction and
51
51
  // an IOR of 1.5 results in the default amount of microfacet refraction.
@@ -53,7 +53,7 @@ export default /* glsl */`
53
53
 
54
54
  }
55
55
 
56
- vec4 getTransmissionSample( vec2 fragCoord, float roughness, float ior ) {
56
+ vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
57
57
 
58
58
  float framebufferLod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
59
59
 
@@ -69,7 +69,7 @@ export default /* glsl */`
69
69
 
70
70
  }
71
71
 
72
- vec3 applyVolumeAttenuation( vec3 radiance, float transmissionDistance, vec3 attenuationColor, float attenuationDistance ) {
72
+ vec3 applyVolumeAttenuation( const in vec3 radiance, const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
73
73
 
74
74
  if ( attenuationDistance == 0.0 ) {
75
75
 
@@ -87,9 +87,10 @@ export default /* glsl */`
87
87
 
88
88
  }
89
89
 
90
- vec4 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 diffuseColor, vec3 specularColor, float specularF90,
91
- vec3 position, mat4 modelMatrix, mat4 viewMatrix, mat4 projMatrix, float ior, float thickness,
92
- vec3 attenuationColor, float attenuationDistance ) {
90
+ vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
91
+ const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
92
+ const in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness,
93
+ const in vec3 attenuationColor, const in float attenuationDistance ) {
93
94
 
94
95
  vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
95
96
  vec3 refractedRayExit = position + transmissionRay;
@@ -18,9 +18,7 @@ varying vec2 vUv;
18
18
 
19
19
  void main() {
20
20
 
21
- vec4 texColor = texture2D( t2D, vUv );
22
-
23
- gl_FragColor = mapTexelToLinear( texColor );
21
+ gl_FragColor = texture2D( t2D, vUv );
24
22
 
25
23
  #include <tonemapping_fragment>
26
24
  #include <encodings_fragment>
@@ -26,9 +26,7 @@ void main() {
26
26
 
27
27
  vec2 sampleUV = equirectUv( direction );
28
28
 
29
- vec4 texColor = texture2D( tEquirect, sampleUV );
30
-
31
- gl_FragColor = mapTexelToLinear( texColor );
29
+ gl_FragColor = texture2D( tEquirect, sampleUV );
32
30
 
33
31
  #include <tonemapping_fragment>
34
32
  #include <encodings_fragment>
@@ -87,7 +87,7 @@ void main() {
87
87
  #ifdef USE_LIGHTMAP
88
88
 
89
89
  vec4 lightMapTexel= texture2D( lightMap, vUv2 );
90
- reflectedLight.indirectDiffuse += lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;
90
+ reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity;
91
91
 
92
92
  #else
93
93
 
@@ -86,11 +86,10 @@ void main() {
86
86
  #ifdef USE_MATCAP
87
87
 
88
88
  vec4 matcapColor = texture2D( matcap, uv );
89
- matcapColor = matcapTexelToLinear( matcapColor );
90
89
 
91
90
  #else
92
91
 
93
- vec4 matcapColor = vec4( 1.0 );
92
+ vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 ); // default if matcap is missing
94
93
 
95
94
  #endif
96
95
 
@@ -299,7 +299,7 @@ ShaderLib.physical = {
299
299
  sheen: { value: 0 },
300
300
  sheenColor: { value: new Color( 0x000000 ) },
301
301
  sheenColorMap: { value: null },
302
- sheenRoughness: { value: 0 },
302
+ sheenRoughness: { value: 1 },
303
303
  sheenRoughnessMap: { value: null },
304
304
  transmission: { value: 0 },
305
305
  transmissionMap: { value: null },
@@ -309,7 +309,7 @@ ShaderLib.physical = {
309
309
  thicknessMap: { value: null },
310
310
  attenuationDistance: { value: 0 },
311
311
  attenuationColor: { value: new Color( 0x000000 ) },
312
- specularIntensity: { value: 0 },
312
+ specularIntensity: { value: 1 },
313
313
  specularIntensityMap: { value: null },
314
314
  specularColor: { value: new Color( 1, 1, 1 ) },
315
315
  specularColorMap: { value: null },