|
@@ -9731,9 +9731,9 @@ var encodings_fragment = "gl_FragColor = linearToOutputTexel( gl_FragColor );";
|
|
|
|
|
|
var encodings_pars_fragment = "vec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn 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 );\n}";
|
|
|
|
|
|
-var envmap_fragment = "#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 envColor = textureCubeUV( envMap, reflectVec, 0.0 );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif";
|
|
|
+var envmap_fragment = "#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 envColor = textureCubeUV( envMap, reflectVec, backgroundBlurriness );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif";
|
|
|
|
|
|
-var envmap_common_pars_fragment = "#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif";
|
|
|
+var envmap_common_pars_fragment = "#ifdef USE_ENVMAP\n\tuniform float backgroundBlurriness;\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif";
|
|
|
|
|
|
var envmap_pars_fragment = "#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif";
|
|
|
|
|
@@ -10126,7 +10126,11 @@ const UniformsLib = {
|
|
|
// physical
|
|
|
refractionRatio: {
|
|
|
value: 0.98
|
|
|
- } // basic, lambert, phong
|
|
|
+ },
|
|
|
+ // basic, lambert, phong
|
|
|
+ backgroundBlurriness: {
|
|
|
+ value: 0
|
|
|
+ } // background
|
|
|
|
|
|
},
|
|
|
aomap: {
|
|
@@ -10628,7 +10632,7 @@ ShaderLib.physical = {
|
|
|
fragmentShader: ShaderChunk.meshphysical_frag
|
|
|
};
|
|
|
|
|
|
-function WebGLBackground(renderer, cubemaps, state, objects, alpha, premultipliedAlpha) {
|
|
|
+function WebGLBackground(renderer, cubemaps, cubeuvmaps, state, objects, alpha, premultipliedAlpha) {
|
|
|
const clearColor = new Color(0x000000);
|
|
|
let clearAlpha = alpha === true ? 0 : 1;
|
|
|
let planeMesh;
|
|
@@ -10642,7 +10646,9 @@ function WebGLBackground(renderer, cubemaps, state, objects, alpha, premultiplie
|
|
|
let background = scene.isScene === true ? scene.background : null;
|
|
|
|
|
|
if (background && background.isTexture) {
|
|
|
- background = cubemaps.get(background);
|
|
|
+ const usePMREM = scene.backgroundBlurriness > 0; // use PMREM if the user wants to blur the background
|
|
|
+
|
|
|
+ background = (usePMREM ? cubeuvmaps : cubemaps).get(background);
|
|
|
} // Ignore background in AR
|
|
|
// TODO: Reconsider this.
|
|
|
|
|
@@ -10695,6 +10701,7 @@ function WebGLBackground(renderer, cubemaps, state, objects, alpha, premultiplie
|
|
|
|
|
|
boxMesh.material.uniforms.envMap.value = background;
|
|
|
boxMesh.material.uniforms.flipEnvMap.value = background.isCubeTexture && background.isRenderTargetTexture === false ? -1 : 1;
|
|
|
+ boxMesh.material.uniforms.backgroundBlurriness.value = scene.backgroundBlurriness;
|
|
|
|
|
|
if (currentBackground !== background || currentBackgroundVersion !== background.version || currentTonemapping !== renderer.toneMapping) {
|
|
|
boxMesh.material.needsUpdate = true;
|
|
@@ -19674,7 +19681,7 @@ function WebGLRenderer(parameters = {}) {
|
|
|
materials = new WebGLMaterials(_this, properties);
|
|
|
renderLists = new WebGLRenderLists();
|
|
|
renderStates = new WebGLRenderStates(extensions, capabilities);
|
|
|
- background = new WebGLBackground(_this, cubemaps, state, objects, _alpha, _premultipliedAlpha);
|
|
|
+ background = new WebGLBackground(_this, cubemaps, cubeuvmaps, state, objects, _alpha, _premultipliedAlpha);
|
|
|
shadowMap = new WebGLShadowMap(_this, objects, capabilities);
|
|
|
uniformsGroups = new WebGLUniformsGroups(_gl, info, capabilities, state);
|
|
|
bufferRenderer = new WebGLBufferRenderer(_gl, extensions, info, capabilities);
|
|
@@ -21051,6 +21058,7 @@ class Scene extends Object3D {
|
|
|
this.background = null;
|
|
|
this.environment = null;
|
|
|
this.fog = null;
|
|
|
+ this.backgroundBlurriness = 0;
|
|
|
this.overrideMaterial = null;
|
|
|
|
|
|
if (typeof __THREE_DEVTOOLS__ !== 'undefined') {
|
|
@@ -21065,6 +21073,7 @@ class Scene extends Object3D {
|
|
|
if (source.background !== null) this.background = source.background.clone();
|
|
|
if (source.environment !== null) this.environment = source.environment.clone();
|
|
|
if (source.fog !== null) this.fog = source.fog.clone();
|
|
|
+ this.backgroundBlurriness = source.backgroundBlurriness;
|
|
|
if (source.overrideMaterial !== null) this.overrideMaterial = source.overrideMaterial.clone();
|
|
|
this.matrixAutoUpdate = source.matrixAutoUpdate;
|
|
|
return this;
|
|
@@ -21073,6 +21082,7 @@ class Scene extends Object3D {
|
|
|
toJSON(meta) {
|
|
|
const data = super.toJSON(meta);
|
|
|
if (this.fog !== null) data.object.fog = this.fog.toJSON();
|
|
|
+ if (this.backgroundBlurriness > 0) data.backgroundBlurriness = this.backgroundBlurriness;
|
|
|
return data;
|
|
|
} // @deprecated
|
|
|
|
|
@@ -30635,6 +30645,7 @@ class ObjectLoader extends Loader {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ if (data.backgroundBlurriness !== undefined) object.backgroundBlurriness = data.backgroundBlurriness;
|
|
|
break;
|
|
|
|
|
|
case 'PerspectiveCamera':
|