|
@@ -199,7 +199,7 @@ function WebGLLights( extensions, capabilities ) {
|
|
|
const matrix4 = new Matrix4();
|
|
|
const matrix42 = new Matrix4();
|
|
|
|
|
|
- function setup( lights ) {
|
|
|
+ function setup( lights, physicallyCorrectLights ) {
|
|
|
|
|
|
let r = 0, g = 0, b = 0;
|
|
|
|
|
@@ -217,6 +217,9 @@ function WebGLLights( extensions, capabilities ) {
|
|
|
|
|
|
lights.sort( shadowCastingLightsFirst );
|
|
|
|
|
|
+ // artist-friendly light intensity scaling factor
|
|
|
+ const scaleFactor = ( physicallyCorrectLights !== true ) ? Math.PI : 1;
|
|
|
+
|
|
|
for ( let i = 0, l = lights.length; i < l; i ++ ) {
|
|
|
|
|
|
const light = lights[ i ];
|
|
@@ -229,9 +232,9 @@ function WebGLLights( extensions, capabilities ) {
|
|
|
|
|
|
if ( light.isAmbientLight ) {
|
|
|
|
|
|
- r += color.r * intensity;
|
|
|
- g += color.g * intensity;
|
|
|
- b += color.b * intensity;
|
|
|
+ r += color.r * intensity * scaleFactor;
|
|
|
+ g += color.g * intensity * scaleFactor;
|
|
|
+ b += color.b * intensity * scaleFactor;
|
|
|
|
|
|
} else if ( light.isLightProbe ) {
|
|
|
|
|
@@ -245,7 +248,7 @@ function WebGLLights( extensions, capabilities ) {
|
|
|
|
|
|
const uniforms = cache.get( light );
|
|
|
|
|
|
- uniforms.color.copy( light.color ).multiplyScalar( light.intensity );
|
|
|
+ uniforms.color.copy( light.color ).multiplyScalar( light.intensity * scaleFactor );
|
|
|
|
|
|
if ( light.castShadow ) {
|
|
|
|
|
@@ -276,7 +279,7 @@ function WebGLLights( extensions, capabilities ) {
|
|
|
|
|
|
uniforms.position.setFromMatrixPosition( light.matrixWorld );
|
|
|
|
|
|
- uniforms.color.copy( color ).multiplyScalar( intensity );
|
|
|
+ uniforms.color.copy( color ).multiplyScalar( intensity * scaleFactor );
|
|
|
uniforms.distance = distance;
|
|
|
|
|
|
uniforms.coneCos = Math.cos( light.angle );
|
|
@@ -327,7 +330,7 @@ function WebGLLights( extensions, capabilities ) {
|
|
|
|
|
|
const uniforms = cache.get( light );
|
|
|
|
|
|
- uniforms.color.copy( light.color ).multiplyScalar( light.intensity );
|
|
|
+ uniforms.color.copy( light.color ).multiplyScalar( light.intensity * scaleFactor );
|
|
|
uniforms.distance = light.distance;
|
|
|
uniforms.decay = light.decay;
|
|
|
|
|
@@ -360,8 +363,8 @@ function WebGLLights( extensions, capabilities ) {
|
|
|
|
|
|
const uniforms = cache.get( light );
|
|
|
|
|
|
- uniforms.skyColor.copy( light.color ).multiplyScalar( intensity );
|
|
|
- uniforms.groundColor.copy( light.groundColor ).multiplyScalar( intensity );
|
|
|
+ uniforms.skyColor.copy( light.color ).multiplyScalar( intensity * scaleFactor );
|
|
|
+ uniforms.groundColor.copy( light.groundColor ).multiplyScalar( intensity * scaleFactor );
|
|
|
|
|
|
state.hemi[ hemiLength ] = uniforms;
|
|
|
|