Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/materials/MeshToonMaterial.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class MeshToonMaterial extends Material {

/**
* Gradient map for toon shading. It's required to set
* {@link Texture#minFilter} and {@link Texture#magFilter} to {@linkNearestFilter}
* {@link Texture#minFilter} and {@link Texture#magFilter} to {@link NearestFilter}
* when using this type of texture.
*
* @type {?Texture}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ export default /* glsl */`
#ifdef USE_ENVMAP

uniform float envMapIntensity;
uniform float flipEnvMap;
uniform mat3 envMapRotation;

#ifdef ENVMAP_TYPE_CUBE
Expand Down
2 changes: 1 addition & 1 deletion src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default /* glsl */`

#ifdef ENVMAP_TYPE_CUBE

vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
vec4 envColor = textureCube( envMap, envMapRotation * reflectVec );

#ifdef ENVMAP_BLENDING_MULTIPLY

Expand Down
1 change: 0 additions & 1 deletion src/renderers/shaders/ShaderLib.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,6 @@ const ShaderLib = {

uniforms: {
envMap: { value: null },
flipEnvMap: { value: - 1 },
backgroundBlurriness: { value: 0 },
backgroundIntensity: { value: 1 },
backgroundRotation: { value: /*@__PURE__*/ new Matrix3() }
Expand Down
3 changes: 1 addition & 2 deletions src/renderers/shaders/ShaderLib/backgroundCube.glsl.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ export const fragment = /* glsl */`

#endif

uniform float flipEnvMap;
uniform float backgroundBlurriness;
uniform float backgroundIntensity;
uniform mat3 backgroundRotation;
Expand All @@ -40,7 +39,7 @@ void main() {

#ifdef ENVMAP_TYPE_CUBE

vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
vec4 texColor = textureCube( envMap, backgroundRotation * vWorldDirection );

#elif defined( ENVMAP_TYPE_CUBE_UV )

Expand Down
1 change: 0 additions & 1 deletion src/renderers/shaders/UniformsLib.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ const UniformsLib = {

envMap: { value: null },
envMapRotation: { value: /*@__PURE__*/ new Matrix3() },
flipEnvMap: { value: - 1 },
reflectivity: { value: 1.0 }, // basic, lambert, phong
ior: { value: 1.5 }, // physical
refractionRatio: { value: 0.98 }, // basic, lambert, phong
Expand Down
26 changes: 13 additions & 13 deletions src/renderers/webgl/WebGLBackground.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@ import { PlaneGeometry } from '../../geometries/PlaneGeometry.js';
import { ShaderMaterial } from '../../materials/ShaderMaterial.js';
import { Color } from '../../math/Color.js';
import { ColorManagement } from '../../math/ColorManagement.js';
import { Euler } from '../../math/Euler.js';
import { Matrix3 } from '../../math/Matrix3.js';
import { Matrix4 } from '../../math/Matrix4.js';
import { Mesh } from '../../objects/Mesh.js';
import { ShaderLib } from '../shaders/ShaderLib.js';
import { cloneUniforms, getUnlitUniformColorSpace } from '../shaders/UniformsUtils.js';

const _rgb = { r: 0, b: 0, g: 0 };
const _e1 = /*@__PURE__*/ new Euler();
const _m1 = /*@__PURE__*/ new Matrix4();
const _m = /*@__PURE__*/ new Matrix3();

_m.set( - 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0 );

function WebGLBackground( renderer, environments, state, objects, alpha, premultipliedAlpha ) {

Expand Down Expand Up @@ -130,24 +132,22 @@ function WebGLBackground( renderer, environments, state, objects, alpha, premult

}

_e1.copy( scene.backgroundRotation );

// accommodate left-handed frame
_e1.x *= - 1; _e1.y *= - 1; _e1.z *= - 1;
boxMesh.material.uniforms.envMap.value = background;
boxMesh.material.uniforms.backgroundBlurriness.value = scene.backgroundBlurriness;
boxMesh.material.uniforms.backgroundIntensity.value = scene.backgroundIntensity;


// note: since the matrix is orthonormal, we can use the more-efficient transpose() in lieu of invert()
boxMesh.material.uniforms.backgroundRotation.value.setFromMatrix4( _m1.makeRotationFromEuler( scene.backgroundRotation ) ).transpose();

if ( background.isCubeTexture && background.isRenderTargetTexture === false ) {

// environment maps which are not cube render targets or PMREMs follow a different convention
_e1.y *= - 1;
_e1.z *= - 1;
boxMesh.material.uniforms.backgroundRotation.value.premultiply( _m );

}

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;
boxMesh.material.uniforms.backgroundIntensity.value = scene.backgroundIntensity;
boxMesh.material.uniforms.backgroundRotation.value.setFromMatrix4( _m1.makeRotationFromEuler( _e1 ) );

boxMesh.material.toneMapped = ColorManagement.getTransfer( background.colorSpace ) !== SRGBTransfer;

if ( currentBackground !== background ||
Expand Down
19 changes: 7 additions & 12 deletions src/renderers/webgl/WebGLMaterials.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { BackSide } from '../../constants.js';
import { getUnlitUniformColorSpace } from '../shaders/UniformsUtils.js';
import { Euler } from '../../math/Euler.js';
import { Matrix3 } from '../../math/Matrix3.js';
import { Matrix4 } from '../../math/Matrix4.js';

const _e1 = /*@__PURE__*/ new Euler();
const _m1 = /*@__PURE__*/ new Matrix4();
const _m = /*@__PURE__*/ new Matrix3();

_m.set( - 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0 );

function WebGLMaterials( renderer, properties ) {

Expand Down Expand Up @@ -235,23 +237,16 @@ function WebGLMaterials( renderer, properties ) {

uniforms.envMap.value = envMap;

_e1.copy( envMapRotation );
// note: since the matrix is orthonormal, we can use the more-efficient transpose() in lieu of invert()
uniforms.envMapRotation.value.setFromMatrix4( _m1.makeRotationFromEuler( envMapRotation ) ).transpose();

// accommodate left-handed frame
_e1.x *= - 1; _e1.y *= - 1; _e1.z *= - 1;

if ( envMap.isCubeTexture && envMap.isRenderTargetTexture === false ) {

// environment maps which are not cube render targets or PMREMs follow a different convention
_e1.y *= - 1;
_e1.z *= - 1;
uniforms.envMapRotation.value.premultiply( _m );

}

uniforms.envMapRotation.value.setFromMatrix4( _m1.makeRotationFromEuler( _e1 ) );

uniforms.flipEnvMap.value = ( envMap.isCubeTexture && envMap.isRenderTargetTexture === false ) ? - 1 : 1;

uniforms.reflectivity.value = material.reflectivity;
uniforms.ior.value = material.ior;
uniforms.refractionRatio.value = material.refractionRatio;
Expand Down