|
@@ -91,7 +91,7 @@ if ( Object.assign === undefined ) {
|
|
|
|
|
|
}
|
|
|
|
|
|
-const REVISION = '118';
|
|
|
+const REVISION = '119dev';
|
|
|
const MOUSE = { LEFT: 0, MIDDLE: 1, RIGHT: 2, ROTATE: 0, DOLLY: 1, PAN: 2 };
|
|
|
const TOUCH = { ROTATE: 0, PAN: 1, DOLLY_PAN: 2, DOLLY_ROTATE: 3 };
|
|
|
const CullFaceNone = 0;
|
|
@@ -14051,46 +14051,44 @@ WebGLCubeRenderTarget.prototype.fromEquirectangularTexture = function ( renderer
|
|
|
tEquirect: { value: null },
|
|
|
},
|
|
|
|
|
|
- vertexShader: [
|
|
|
+ vertexShader: /* glsl */`
|
|
|
|
|
|
- "varying vec3 vWorldDirection;",
|
|
|
+ varying vec3 vWorldDirection;
|
|
|
|
|
|
- "vec3 transformDirection( in vec3 dir, in mat4 matrix ) {",
|
|
|
+ vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
|
|
|
|
|
|
- " return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );",
|
|
|
+ return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
|
|
|
|
|
|
- "}",
|
|
|
-
|
|
|
- "void main() {",
|
|
|
-
|
|
|
- " vWorldDirection = transformDirection( position, modelMatrix );",
|
|
|
+ }
|
|
|
|
|
|
- " #include <begin_vertex>",
|
|
|
- " #include <project_vertex>",
|
|
|
+ void main() {
|
|
|
|
|
|
- "}"
|
|
|
+ vWorldDirection = transformDirection( position, modelMatrix );
|
|
|
|
|
|
- ].join( '\n' ),
|
|
|
+ #include <begin_vertex>
|
|
|
+ #include <project_vertex>
|
|
|
|
|
|
- fragmentShader: [
|
|
|
+ }
|
|
|
+ `,
|
|
|
|
|
|
- "uniform sampler2D tEquirect;",
|
|
|
+ fragmentShader: /* glsl */`
|
|
|
|
|
|
- "varying vec3 vWorldDirection;",
|
|
|
+ uniform sampler2D tEquirect;
|
|
|
|
|
|
- "#include <common>",
|
|
|
+ varying vec3 vWorldDirection;
|
|
|
|
|
|
- "void main() {",
|
|
|
+ #include <common>
|
|
|
|
|
|
- " vec3 direction = normalize( vWorldDirection );",
|
|
|
+ void main() {
|
|
|
|
|
|
- " vec2 sampleUV = equirectUv( direction );",
|
|
|
+ vec3 direction = normalize( vWorldDirection );
|
|
|
|
|
|
- " gl_FragColor = texture2D( tEquirect, sampleUV );",
|
|
|
+ vec2 sampleUV = equirectUv( direction );
|
|
|
|
|
|
- "}"
|
|
|
+ gl_FragColor = texture2D( tEquirect, sampleUV );
|
|
|
|
|
|
- ].join( '\n' ),
|
|
|
+ }
|
|
|
+ `
|
|
|
};
|
|
|
|
|
|
const material = new ShaderMaterial( {
|
|
@@ -16671,7 +16669,7 @@ function WebGLExtensions( gl ) {
|
|
|
|
|
|
return {
|
|
|
|
|
|
- get: function ( name ) {
|
|
|
+ has: function ( name ) {
|
|
|
|
|
|
if ( extensions[ name ] !== undefined ) {
|
|
|
|
|
@@ -16704,15 +16702,21 @@ function WebGLExtensions( gl ) {
|
|
|
|
|
|
}
|
|
|
|
|
|
- if ( extension === null ) {
|
|
|
+ extensions[ name ] = extension;
|
|
|
+
|
|
|
+ return !! extension;
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ get: function ( name ) {
|
|
|
+
|
|
|
+ if ( ! this.has( name ) ) {
|
|
|
|
|
|
console.warn( 'THREE.WebGLRenderer: ' + name + ' extension not supported.' );
|
|
|
|
|
|
}
|
|
|
|
|
|
- extensions[ name ] = extension;
|
|
|
-
|
|
|
- return extension;
|
|
|
+ return extensions[ name ];
|
|
|
|
|
|
}
|
|
|
|
|
@@ -49160,48 +49164,70 @@ function _getBlurShader( maxSamples ) {
|
|
|
|
|
|
vertexShader: _getCommonVertexShader(),
|
|
|
|
|
|
- fragmentShader: `
|
|
|
-precision mediump float;
|
|
|
-precision mediump int;
|
|
|
-varying vec3 vOutputDirection;
|
|
|
-uniform sampler2D envMap;
|
|
|
-uniform int samples;
|
|
|
-uniform float weights[n];
|
|
|
-uniform bool latitudinal;
|
|
|
-uniform float dTheta;
|
|
|
-uniform float mipInt;
|
|
|
-uniform vec3 poleAxis;
|
|
|
-
|
|
|
-${_getEncodings()}
|
|
|
-
|
|
|
-#define ENVMAP_TYPE_CUBE_UV
|
|
|
-#include <cube_uv_reflection_fragment>
|
|
|
-
|
|
|
-vec3 getSample(float theta, vec3 axis) {
|
|
|
- float cosTheta = cos(theta);
|
|
|
- // Rodrigues' axis-angle rotation
|
|
|
- vec3 sampleDirection = vOutputDirection * cosTheta
|
|
|
- + cross(axis, vOutputDirection) * sin(theta)
|
|
|
- + axis * dot(axis, vOutputDirection) * (1.0 - cosTheta);
|
|
|
- return bilinearCubeUV(envMap, sampleDirection, mipInt);
|
|
|
-}
|
|
|
-
|
|
|
-void main() {
|
|
|
- vec3 axis = latitudinal ? poleAxis : cross(poleAxis, vOutputDirection);
|
|
|
- if (all(equal(axis, vec3(0.0))))
|
|
|
- axis = vec3(vOutputDirection.z, 0.0, - vOutputDirection.x);
|
|
|
- axis = normalize(axis);
|
|
|
- gl_FragColor = vec4(0.0);
|
|
|
- gl_FragColor.rgb += weights[0] * getSample(0.0, axis);
|
|
|
- for (int i = 1; i < n; i++) {
|
|
|
- if (i >= samples)
|
|
|
- break;
|
|
|
- float theta = dTheta * float(i);
|
|
|
- gl_FragColor.rgb += weights[i] * getSample(-1.0 * theta, axis);
|
|
|
- gl_FragColor.rgb += weights[i] * getSample(theta, axis);
|
|
|
- }
|
|
|
- gl_FragColor = linearToOutputTexel(gl_FragColor);
|
|
|
-}
|
|
|
+ fragmentShader: /* glsl */`
|
|
|
+
|
|
|
+ precision mediump float;
|
|
|
+ precision mediump int;
|
|
|
+
|
|
|
+ varying vec3 vOutputDirection;
|
|
|
+
|
|
|
+ uniform sampler2D envMap;
|
|
|
+ uniform int samples;
|
|
|
+ uniform float weights[ n ];
|
|
|
+ uniform bool latitudinal;
|
|
|
+ uniform float dTheta;
|
|
|
+ uniform float mipInt;
|
|
|
+ uniform vec3 poleAxis;
|
|
|
+
|
|
|
+ ${_getEncodings()}
|
|
|
+
|
|
|
+ #define ENVMAP_TYPE_CUBE_UV
|
|
|
+ #include <cube_uv_reflection_fragment>
|
|
|
+
|
|
|
+ vec3 getSample( float theta, vec3 axis ) {
|
|
|
+
|
|
|
+ float cosTheta = cos( theta );
|
|
|
+ // Rodrigues' axis-angle rotation
|
|
|
+ vec3 sampleDirection = vOutputDirection * cosTheta
|
|
|
+ + cross( axis, vOutputDirection ) * sin( theta )
|
|
|
+ + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
|
|
|
+
|
|
|
+ return bilinearCubeUV( envMap, sampleDirection, mipInt );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ void main() {
|
|
|
+
|
|
|
+ vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
|
|
|
+
|
|
|
+ if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
|
|
|
+
|
|
|
+ axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ axis = normalize( axis );
|
|
|
+
|
|
|
+ gl_FragColor = vec4( 0.0 );
|
|
|
+ gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
|
|
|
+
|
|
|
+ for ( int i = 1; i < n; i++ ) {
|
|
|
+
|
|
|
+ if ( i >= samples ) {
|
|
|
+
|
|
|
+ break;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ float theta = dTheta * float( i );
|
|
|
+ gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
|
|
|
+ gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ gl_FragColor = linearToOutputTexel( gl_FragColor );
|
|
|
+
|
|
|
+ }
|
|
|
`,
|
|
|
|
|
|
blending: NoBlending,
|
|
@@ -49230,35 +49256,44 @@ function _getEquirectShader() {
|
|
|
|
|
|
vertexShader: _getCommonVertexShader(),
|
|
|
|
|
|
- fragmentShader: `
|
|
|
-precision mediump float;
|
|
|
-precision mediump int;
|
|
|
-varying vec3 vOutputDirection;
|
|
|
-uniform sampler2D envMap;
|
|
|
-uniform vec2 texelSize;
|
|
|
-
|
|
|
-${_getEncodings()}
|
|
|
-
|
|
|
-#include <common>
|
|
|
-
|
|
|
-void main() {
|
|
|
- gl_FragColor = vec4(0.0);
|
|
|
- vec3 outputDirection = normalize(vOutputDirection);
|
|
|
- vec2 uv = equirectUv( outputDirection );
|
|
|
- vec2 f = fract(uv / texelSize - 0.5);
|
|
|
- uv -= f * texelSize;
|
|
|
- vec3 tl = envMapTexelToLinear(texture2D(envMap, uv)).rgb;
|
|
|
- uv.x += texelSize.x;
|
|
|
- vec3 tr = envMapTexelToLinear(texture2D(envMap, uv)).rgb;
|
|
|
- uv.y += texelSize.y;
|
|
|
- vec3 br = envMapTexelToLinear(texture2D(envMap, uv)).rgb;
|
|
|
- uv.x -= texelSize.x;
|
|
|
- vec3 bl = envMapTexelToLinear(texture2D(envMap, uv)).rgb;
|
|
|
- vec3 tm = mix(tl, tr, f.x);
|
|
|
- vec3 bm = mix(bl, br, f.x);
|
|
|
- gl_FragColor.rgb = mix(tm, bm, f.y);
|
|
|
- gl_FragColor = linearToOutputTexel(gl_FragColor);
|
|
|
-}
|
|
|
+ fragmentShader: /* glsl */`
|
|
|
+
|
|
|
+ precision mediump float;
|
|
|
+ precision mediump int;
|
|
|
+
|
|
|
+ varying vec3 vOutputDirection;
|
|
|
+
|
|
|
+ uniform sampler2D envMap;
|
|
|
+ uniform vec2 texelSize;
|
|
|
+
|
|
|
+ ${_getEncodings()}
|
|
|
+
|
|
|
+ #include <common>
|
|
|
+
|
|
|
+ void main() {
|
|
|
+
|
|
|
+ gl_FragColor = vec4( 0.0 );
|
|
|
+
|
|
|
+ vec3 outputDirection = normalize( vOutputDirection );
|
|
|
+ vec2 uv = equirectUv( outputDirection );
|
|
|
+
|
|
|
+ vec2 f = fract( uv / texelSize - 0.5 );
|
|
|
+ uv -= f * texelSize;
|
|
|
+ vec3 tl = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb;
|
|
|
+ uv.x += texelSize.x;
|
|
|
+ vec3 tr = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb;
|
|
|
+ uv.y += texelSize.y;
|
|
|
+ vec3 br = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb;
|
|
|
+ uv.x -= texelSize.x;
|
|
|
+ vec3 bl = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb;
|
|
|
+
|
|
|
+ vec3 tm = mix( tl, tr, f.x );
|
|
|
+ vec3 bm = mix( bl, br, f.x );
|
|
|
+ gl_FragColor.rgb = mix( tm, bm, f.y );
|
|
|
+
|
|
|
+ gl_FragColor = linearToOutputTexel( gl_FragColor );
|
|
|
+
|
|
|
+ }
|
|
|
`,
|
|
|
|
|
|
blending: NoBlending,
|
|
@@ -49285,19 +49320,24 @@ function _getCubemapShader() {
|
|
|
|
|
|
vertexShader: _getCommonVertexShader(),
|
|
|
|
|
|
- fragmentShader: `
|
|
|
-precision mediump float;
|
|
|
-precision mediump int;
|
|
|
-varying vec3 vOutputDirection;
|
|
|
-uniform samplerCube envMap;
|
|
|
+ fragmentShader: /* glsl */`
|
|
|
|
|
|
-${_getEncodings()}
|
|
|
+ precision mediump float;
|
|
|
+ precision mediump int;
|
|
|
|
|
|
-void main() {
|
|
|
- gl_FragColor = vec4(0.0);
|
|
|
- gl_FragColor.rgb = envMapTexelToLinear(textureCube(envMap, vec3( - vOutputDirection.x, vOutputDirection.yz ))).rgb;
|
|
|
- gl_FragColor = linearToOutputTexel(gl_FragColor);
|
|
|
-}
|
|
|
+ varying vec3 vOutputDirection;
|
|
|
+
|
|
|
+ uniform samplerCube envMap;
|
|
|
+
|
|
|
+ ${_getEncodings()}
|
|
|
+
|
|
|
+ void main() {
|
|
|
+
|
|
|
+ gl_FragColor = vec4( 0.0 );
|
|
|
+ gl_FragColor.rgb = envMapTexelToLinear( textureCube( envMap, vec3( - vOutputDirection.x, vOutputDirection.yz ) ) ).rgb;
|
|
|
+ gl_FragColor = linearToOutputTexel( gl_FragColor );
|
|
|
+
|
|
|
+ }
|
|
|
`,
|
|
|
|
|
|
blending: NoBlending,
|
|
@@ -49312,92 +49352,149 @@ void main() {
|
|
|
|
|
|
function _getCommonVertexShader() {
|
|
|
|
|
|
- return `
|
|
|
-precision mediump float;
|
|
|
-precision mediump int;
|
|
|
-attribute vec3 position;
|
|
|
-attribute vec2 uv;
|
|
|
-attribute float faceIndex;
|
|
|
-varying vec3 vOutputDirection;
|
|
|
-
|
|
|
-// RH coordinate system; PMREM face-indexing convention
|
|
|
-vec3 getDirection(vec2 uv, float face) {
|
|
|
- uv = 2.0 * uv - 1.0;
|
|
|
- vec3 direction = vec3(uv, 1.0);
|
|
|
- if (face == 0.0) {
|
|
|
- direction = direction.zyx; // ( 1, v, u ) pos x
|
|
|
- } else if (face == 1.0) {
|
|
|
- direction = direction.xzy;
|
|
|
- direction.xz *= -1.0; // ( -u, 1, -v ) pos y
|
|
|
- } else if (face == 2.0) {
|
|
|
- direction.x *= -1.0; // ( -u, v, 1 ) pos z
|
|
|
- } else if (face == 3.0) {
|
|
|
- direction = direction.zyx;
|
|
|
- direction.xz *= -1.0; // ( -1, v, -u ) neg x
|
|
|
- } else if (face == 4.0) {
|
|
|
- direction = direction.xzy;
|
|
|
- direction.xy *= -1.0; // ( -u, -1, v ) neg y
|
|
|
- } else if (face == 5.0) {
|
|
|
- direction.z *= -1.0; // ( u, v, -1 ) neg z
|
|
|
- }
|
|
|
- return direction;
|
|
|
-}
|
|
|
-
|
|
|
-void main() {
|
|
|
- vOutputDirection = getDirection(uv, faceIndex);
|
|
|
- gl_Position = vec4( position, 1.0 );
|
|
|
-}
|
|
|
+ return /* glsl */`
|
|
|
+
|
|
|
+ precision mediump float;
|
|
|
+ precision mediump int;
|
|
|
+
|
|
|
+ attribute vec3 position;
|
|
|
+ attribute vec2 uv;
|
|
|
+ attribute float faceIndex;
|
|
|
+
|
|
|
+ varying vec3 vOutputDirection;
|
|
|
+
|
|
|
+ // RH coordinate system; PMREM face-indexing convention
|
|
|
+ vec3 getDirection( vec2 uv, float face ) {
|
|
|
+
|
|
|
+ uv = 2.0 * uv - 1.0;
|
|
|
+
|
|
|
+ vec3 direction = vec3( uv, 1.0 );
|
|
|
+
|
|
|
+ if ( face == 0.0 ) {
|
|
|
+
|
|
|
+ direction = direction.zyx; // ( 1, v, u ) pos x
|
|
|
+
|
|
|
+ } else if ( face == 1.0 ) {
|
|
|
+
|
|
|
+ direction = direction.xzy;
|
|
|
+ direction.xz *= -1.0; // ( -u, 1, -v ) pos y
|
|
|
+
|
|
|
+ } else if ( face == 2.0 ) {
|
|
|
+
|
|
|
+ direction.x *= -1.0; // ( -u, v, 1 ) pos z
|
|
|
+
|
|
|
+ } else if ( face == 3.0 ) {
|
|
|
+
|
|
|
+ direction = direction.zyx;
|
|
|
+ direction.xz *= -1.0; // ( -1, v, -u ) neg x
|
|
|
+
|
|
|
+ } else if ( face == 4.0 ) {
|
|
|
+
|
|
|
+ direction = direction.xzy;
|
|
|
+ direction.xy *= -1.0; // ( -u, -1, v ) neg y
|
|
|
+
|
|
|
+ } else if ( face == 5.0 ) {
|
|
|
+
|
|
|
+ direction.z *= -1.0; // ( u, v, -1 ) neg z
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return direction;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ void main() {
|
|
|
+
|
|
|
+ vOutputDirection = getDirection( uv, faceIndex );
|
|
|
+ gl_Position = vec4( position, 1.0 );
|
|
|
+
|
|
|
+ }
|
|
|
`;
|
|
|
|
|
|
}
|
|
|
|
|
|
function _getEncodings() {
|
|
|
|
|
|
- return `
|
|
|
-uniform int inputEncoding;
|
|
|
-uniform int outputEncoding;
|
|
|
-
|
|
|
-#include <encodings_pars_fragment>
|
|
|
-
|
|
|
-vec4 inputTexelToLinear(vec4 value){
|
|
|
- if(inputEncoding == 0){
|
|
|
- return value;
|
|
|
- }else if(inputEncoding == 1){
|
|
|
- return sRGBToLinear(value);
|
|
|
- }else if(inputEncoding == 2){
|
|
|
- return RGBEToLinear(value);
|
|
|
- }else if(inputEncoding == 3){
|
|
|
- return RGBMToLinear(value, 7.0);
|
|
|
- }else if(inputEncoding == 4){
|
|
|
- return RGBMToLinear(value, 16.0);
|
|
|
- }else if(inputEncoding == 5){
|
|
|
- return RGBDToLinear(value, 256.0);
|
|
|
- }else{
|
|
|
- return GammaToLinear(value, 2.2);
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-vec4 linearToOutputTexel(vec4 value){
|
|
|
- if(outputEncoding == 0){
|
|
|
- return value;
|
|
|
- }else if(outputEncoding == 1){
|
|
|
- return LinearTosRGB(value);
|
|
|
- }else if(outputEncoding == 2){
|
|
|
- return LinearToRGBE(value);
|
|
|
- }else if(outputEncoding == 3){
|
|
|
- return LinearToRGBM(value, 7.0);
|
|
|
- }else if(outputEncoding == 4){
|
|
|
- return LinearToRGBM(value, 16.0);
|
|
|
- }else if(outputEncoding == 5){
|
|
|
- return LinearToRGBD(value, 256.0);
|
|
|
- }else{
|
|
|
- return LinearToGamma(value, 2.2);
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-vec4 envMapTexelToLinear(vec4 color) {
|
|
|
- return inputTexelToLinear(color);
|
|
|
-}
|
|
|
+ return /* glsl */`
|
|
|
+
|
|
|
+ uniform int inputEncoding;
|
|
|
+ uniform int outputEncoding;
|
|
|
+
|
|
|
+ #include <encodings_pars_fragment>
|
|
|
+
|
|
|
+ vec4 inputTexelToLinear( vec4 value ) {
|
|
|
+
|
|
|
+ if( inputEncoding == 0 ) {
|
|
|
+
|
|
|
+ return value;
|
|
|
+
|
|
|
+ } else if ( inputEncoding == 1 ) {
|
|
|
+
|
|
|
+ return sRGBToLinear( value );
|
|
|
+
|
|
|
+ } else if ( inputEncoding == 2 ) {
|
|
|
+
|
|
|
+ return RGBEToLinear( value );
|
|
|
+
|
|
|
+ } else if ( inputEncoding == 3 ) {
|
|
|
+
|
|
|
+ return RGBMToLinear( value, 7.0 );
|
|
|
+
|
|
|
+ } else if ( inputEncoding == 4 ) {
|
|
|
+
|
|
|
+ return RGBMToLinear( value, 16.0 );
|
|
|
+
|
|
|
+ } else if ( inputEncoding == 5 ) {
|
|
|
+
|
|
|
+ return RGBDToLinear( value, 256.0 );
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ return GammaToLinear( value, 2.2 );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ vec4 linearToOutputTexel( vec4 value ){
|
|
|
+
|
|
|
+ if( outputEncoding == 0 ) {
|
|
|
+
|
|
|
+ return value;
|
|
|
+
|
|
|
+ } else if ( outputEncoding == 1 ) {
|
|
|
+
|
|
|
+ return LinearTosRGB( value );
|
|
|
+
|
|
|
+ } else if ( outputEncoding == 2 ) {
|
|
|
+
|
|
|
+ return LinearToRGBE( value );
|
|
|
+
|
|
|
+ } else if ( outputEncoding == 3 ) {
|
|
|
+
|
|
|
+ return LinearToRGBM( value, 7.0 );
|
|
|
+
|
|
|
+ } else if ( outputEncoding == 4 ) {
|
|
|
+
|
|
|
+ return LinearToRGBM( value, 16.0 );
|
|
|
+
|
|
|
+ } else if ( outputEncoding == 5 ) {
|
|
|
+
|
|
|
+ return LinearToRGBD( value, 256.0 );
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ return LinearToGamma( value, 2.2 );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ vec4 envMapTexelToLinear( vec4 color ) {
|
|
|
+
|
|
|
+ return inputTexelToLinear( color );
|
|
|
+
|
|
|
+ }
|
|
|
`;
|
|
|
|
|
|
}
|