three-stdlib 2.6.2 → 2.6.3

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.
@@ -1,9 +1,7 @@
1
- import { GammaEncoding, RGBDEncoding, RGBM16Encoding, RGBM7Encoding, RGBEEncoding, sRGBEncoding, LinearEncoding } from 'three';
1
+ import { sRGBEncoding, LinearEncoding } from 'three';
2
2
  import { TempNode } from '../core/TempNode.js';
3
3
  import { ConstNode } from '../core/ConstNode.js';
4
- import { FloatNode } from '../inputs/FloatNode.js';
5
4
  import { FunctionNode } from '../core/FunctionNode.js';
6
- import { ExpressionNode } from '../core/ExpressionNode.js';
7
5
 
8
6
  function ColorSpaceNode(input, method) {
9
7
  TempNode.call(this, 'v4');
@@ -12,21 +10,9 @@ function ColorSpaceNode(input, method) {
12
10
  }
13
11
 
14
12
  ColorSpaceNode.Nodes = function () {
15
- // For a discussion of what this is, please read this: http://lousodrome.net/blog/light/2013/05/26/gamma-correct-and-hdr-rendering-in-a-32-bits-buffer/
16
13
  var LinearToLinear = new FunctionNode(['vec4 LinearToLinear( in vec4 value ) {', ' return value;', '}'].join('\n'));
17
- var GammaToLinear = new FunctionNode(['vec4 GammaToLinear( in vec4 value, in float gammaFactor ) {', ' return vec4( pow( value.xyz, vec3( gammaFactor ) ), value.w );', '}'].join('\n'));
18
- var LinearToGamma = new FunctionNode(['vec4 LinearToGamma( in vec4 value, in float gammaFactor ) {', ' return vec4( pow( value.xyz, vec3( 1.0 / gammaFactor ) ), value.w );', '}'].join('\n'));
19
14
  var sRGBToLinear = new FunctionNode(['vec4 sRGBToLinear( in vec4 value ) {', ' 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.w );', '}'].join('\n'));
20
- var LinearTosRGB = new FunctionNode(['vec4 LinearTosRGB( in vec4 value ) {', ' 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.w );', '}'].join('\n'));
21
- var RGBEToLinear = new FunctionNode(['vec4 RGBEToLinear( in vec4 value ) {', ' return vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );', '}'].join('\n'));
22
- var LinearToRGBE = new FunctionNode(['vec4 LinearToRGBE( in vec4 value ) {', ' float maxComponent = max( max( value.r, value.g ), value.b );', ' float fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );', ' return vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );', // return vec4( value.brg, ( 3.0 + 128.0 ) / 256.0 );
23
- '}'].join('\n')); // reference: http://iwasbeingirony.blogspot.ca/2010/06/difference-between-rgbm-and-rgbd.html
24
-
25
- var RGBMToLinear = new FunctionNode(['vec3 RGBMToLinear( in vec4 value, in float maxRange ) {', ' return vec4( value.xyz * value.w * maxRange, 1.0 );', '}'].join('\n'));
26
- var LinearToRGBM = new FunctionNode(['vec3 LinearToRGBM( in vec4 value, in float maxRange ) {', ' float maxRGB = max( value.x, max( value.g, value.b ) );', ' float M = clamp( maxRGB / maxRange, 0.0, 1.0 );', ' M = ceil( M * 255.0 ) / 255.0;', ' return vec4( value.rgb / ( M * maxRange ), M );', '}'].join('\n')); // reference: http://iwasbeingirony.blogspot.ca/2010/06/difference-between-rgbm-and-rgbd.html
27
-
28
- var RGBDToLinear = new FunctionNode(['vec3 RGBDToLinear( in vec4 value, in float maxRange ) {', ' return vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );', '}'].join('\n'));
29
- var LinearToRGBD = new FunctionNode(['vec3 LinearToRGBD( in vec4 value, in float maxRange ) {', ' float maxRGB = max( value.x, max( value.g, value.b ) );', ' float D = max( maxRange / maxRGB, 1.0 );', ' D = clamp( floor( D ) / 255.0, 0.0, 1.0 );', ' return vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );', '}'].join('\n')); // LogLuv reference: http://graphicrants.blogspot.ca/2009/04/rgbm-color-encoding.html
15
+ var LinearTosRGB = new FunctionNode(['vec4 LinearTosRGB( in vec4 value ) {', ' 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.w );', '}'].join('\n')); // LogLuv reference: http://graphicrants.blogspot.ca/2009/04/rgbm-color-encoding.html
30
16
  // M matrix, for encoding
31
17
 
32
18
  var cLogLuvM = new ConstNode('const mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );');
@@ -36,16 +22,8 @@ ColorSpaceNode.Nodes = function () {
36
22
  var LogLuvToLinear = new FunctionNode(['vec4 LogLuvToLinear( in vec4 value ) {', ' float Le = value.z * 255.0 + value.w;', ' vec3 Xp_Y_XYZp;', ' Xp_Y_XYZp.y = exp2((Le - 127.0) / 2.0);', ' Xp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;', ' Xp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;', ' vec3 vRGB = cLogLuvInverseM * Xp_Y_XYZp.rgb;', ' return vec4( max(vRGB, 0.0), 1.0 );', '}'].join('\n'), [cLogLuvInverseM]);
37
23
  return {
38
24
  LinearToLinear: LinearToLinear,
39
- GammaToLinear: GammaToLinear,
40
- LinearToGamma: LinearToGamma,
41
25
  sRGBToLinear: sRGBToLinear,
42
26
  LinearTosRGB: LinearTosRGB,
43
- RGBEToLinear: RGBEToLinear,
44
- LinearToRGBE: LinearToRGBE,
45
- RGBMToLinear: RGBMToLinear,
46
- LinearToRGBM: LinearToRGBM,
47
- RGBDToLinear: RGBDToLinear,
48
- LinearToRGBD: LinearToRGBD,
49
27
  cLogLuvM: cLogLuvM,
50
28
  LinearToLogLuv: LinearToLogLuv,
51
29
  cLogLuvInverseM: cLogLuvInverseM,
@@ -54,16 +32,10 @@ ColorSpaceNode.Nodes = function () {
54
32
  }();
55
33
 
56
34
  ColorSpaceNode.LINEAR_TO_LINEAR = 'LinearToLinear';
57
- ColorSpaceNode.GAMMA_TO_LINEAR = 'GammaToLinear';
58
- ColorSpaceNode.LINEAR_TO_GAMMA = 'LinearToGamma';
59
35
  ColorSpaceNode.SRGB_TO_LINEAR = 'sRGBToLinear';
60
36
  ColorSpaceNode.LINEAR_TO_SRGB = 'LinearTosRGB';
61
37
  ColorSpaceNode.RGBE_TO_LINEAR = 'RGBEToLinear';
62
38
  ColorSpaceNode.LINEAR_TO_RGBE = 'LinearToRGBE';
63
- ColorSpaceNode.RGBM_TO_LINEAR = 'RGBMToLinear';
64
- ColorSpaceNode.LINEAR_TO_RGBM = 'LinearToRGBM';
65
- ColorSpaceNode.RGBD_TO_LINEAR = 'RGBDToLinear';
66
- ColorSpaceNode.LINEAR_TO_RGBD = 'LinearToRGBD';
67
39
  ColorSpaceNode.LINEAR_TO_LOG_LUV = 'LinearToLogLuv';
68
40
  ColorSpaceNode.LOG_LUV_TO_LINEAR = 'LogLuvToLinear';
69
41
 
@@ -74,21 +46,6 @@ ColorSpaceNode.getEncodingComponents = function (encoding) {
74
46
 
75
47
  case sRGBEncoding:
76
48
  return ['sRGB'];
77
-
78
- case RGBEEncoding:
79
- return ['RGBE'];
80
-
81
- case RGBM7Encoding:
82
- return ['RGBM', new FloatNode(7.0).setReadonly(true)];
83
-
84
- case RGBM16Encoding:
85
- return ['RGBM', new FloatNode(16.0).setReadonly(true)];
86
-
87
- case RGBDEncoding:
88
- return ['RGBD', new FloatNode(256.0).setReadonly(true)];
89
-
90
- case GammaEncoding:
91
- return ['Gamma', new ExpressionNode('float( GAMMA_FACTOR )', 'f')];
92
49
  }
93
50
  };
94
51
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "three-stdlib",
3
- "version": "2.6.2",
3
+ "version": "2.6.3",
4
4
  "private": false,
5
5
  "description": "stand-alone library of threejs examples",
6
6
  "main": "index.cjs.js",
@@ -9,8 +9,7 @@ const GammaCorrectionShader = {
9
9
  }
10
10
  },
11
11
  vertexShader: ['varying vec2 vUv;', 'void main() {', ' vUv = uv;', ' gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );', '}'].join('\n'),
12
- fragmentShader: ['uniform sampler2D tDiffuse;', 'varying vec2 vUv;', 'void main() {', ' vec4 tex = texture2D( tDiffuse, vUv );', ' gl_FragColor = LinearTosRGB( tex );', // optional: LinearToGamma( tex, float( GAMMA_FACTOR ) );
13
- '}'].join('\n')
12
+ fragmentShader: ['uniform sampler2D tDiffuse;', 'varying vec2 vUv;', 'void main() {', ' vec4 tex = texture2D( tDiffuse, vUv );', ' gl_FragColor = LinearTosRGB( tex );', '}'].join('\n')
14
13
  };
15
14
 
16
15
  export { GammaCorrectionShader };