提交 779f1e43 编写于 作者: M Mr.doob

Implemented envMapBlurriness

上级 7cd67a8e
......@@ -70,6 +70,8 @@
var envMap = pmremGenerator.fromEquirectangular( texture ).texture;
pmremGenerator.dispose();
envMap.blurriness = 0.15;
scene.background = envMap;
scene.environment = envMap;
......
......@@ -145,6 +145,8 @@
//
hdrCubeRenderTarget.texture.blurriness = 0.2;
scene.background = hdrCubeRenderTarget.texture;
scene.environment = hdrCubeRenderTarget.texture;
......
......@@ -2089,6 +2089,7 @@ function WebGLRenderer( parameters ) {
if ( envMap ) {
uniforms.envMap.value = envMap;
uniforms.envMapBlurriness.value = envMap.blurriness;
// don't flip CubeTexture envMaps, flip everything else:
// WebGLRenderTargetCube will be flipped for backwards compatibility
......
export default /* glsl */`
#ifdef USE_ENVMAP
uniform float envMapBlurriness;
uniform float envMapIntensity;
uniform float flipEnvMap;
uniform int maxMipLevel;
......@@ -10,6 +11,6 @@ export default /* glsl */`
#else
uniform sampler2D envMap;
#endif
#endif
`;
......@@ -4,7 +4,7 @@ export default /* glsl */`
#ifdef ENV_WORLDPOS
vec3 cameraToFrag;
if ( isOrthographic ) {
cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
......@@ -40,7 +40,7 @@ export default /* glsl */`
#elif defined( ENVMAP_TYPE_CUBE_UV )
vec4 envColor = textureCubeUV( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ), 0.0 );
vec4 envColor = textureCubeUV( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ), envMapBlurriness );
#elif defined( ENVMAP_TYPE_EQUIREC )
......
......@@ -30,6 +30,7 @@ var UniformsLib = {
envmap: {
envMap: { value: null },
envMapBlurriness: { value: 0 },
flipEnvMap: { value: - 1 },
reflectivity: { value: 1.0 },
refractionRatio: { value: 0.98 },
......
......@@ -105,6 +105,7 @@ function WebGLBackground( renderer, state, objects, premultipliedAlpha ) {
var texture = background.isWebGLRenderTargetCube ? background.texture : background;
boxMesh.material.uniforms.envMap.value = texture;
boxMesh.material.uniforms.envMapBlurriness.value = texture.blurriness;
boxMesh.material.uniforms.flipEnvMap.value = texture.isCubeTexture ? - 1 : 1;
if ( currentBackground !== background ||
......
......@@ -61,6 +61,8 @@ function Texture( image, mapping, wrapS, wrapT, magFilter, minFilter, format, ty
this.flipY = true;
this.unpackAlignment = 4; // valid values: 1, 2, 4, 8 (see http://www.khronos.org/opengles/sdk/docs/man/xhtml/glPixelStorei.xml)
this.blurriness = 0;
// Values of encoding !== THREE.LinearEncoding only supported on map, envMap and emissiveMap.
//
// Also changing the encoding after already used by a Material will not automatically make the Material
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册