|
@@ -58,6 +58,7 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
|
|
|
|
// physically based shading
|
|
|
|
|
|
+ this.gammaFactor = 2.0; // for backwards compatibility
|
|
|
this.gammaInput = false;
|
|
|
this.gammaOutput = false;
|
|
|
|
|
@@ -4524,7 +4525,7 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
|
|
|
|
if ( _this.gammaInput ) {
|
|
|
|
|
|
- uniforms.diffuse.value.copyGammaToLinear( material.color );
|
|
|
+ uniforms.diffuse.value.copyGammaToLinear( material.color, this.gammaFactor );
|
|
|
|
|
|
} else {
|
|
|
|
|
@@ -4658,9 +4659,9 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
|
|
|
|
if ( _this.gammaInput ) {
|
|
|
|
|
|
- uniforms.ambient.value.copyGammaToLinear( material.ambient );
|
|
|
- uniforms.emissive.value.copyGammaToLinear( material.emissive );
|
|
|
- uniforms.specular.value.copyGammaToLinear( material.specular );
|
|
|
+ uniforms.ambient.value.copyGammaToLinear( material.ambient, this.gammaFactor );
|
|
|
+ uniforms.emissive.value.copyGammaToLinear( material.emissive, this.gammaFactor );
|
|
|
+ uniforms.specular.value.copyGammaToLinear( material.specular, this.gammaFactor );
|
|
|
|
|
|
} else {
|
|
|
|
|
@@ -4682,8 +4683,8 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
|
|
|
|
if ( _this.gammaInput ) {
|
|
|
|
|
|
- uniforms.ambient.value.copyGammaToLinear( material.ambient );
|
|
|
- uniforms.emissive.value.copyGammaToLinear( material.emissive );
|
|
|
+ uniforms.ambient.value.copyGammaToLinear( material.ambient, this.gammaFactor );
|
|
|
+ uniforms.emissive.value.copyGammaToLinear( material.emissive, this.gammaFactor );
|
|
|
|
|
|
} else {
|
|
|
|
|
@@ -5157,11 +5158,11 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
|
|
|
|
//
|
|
|
|
|
|
- function setColorGamma( array, offset, color, intensitySq ) {
|
|
|
+ function setColorGamma( array, offset, color, intensity ) {
|
|
|
|
|
|
- array[ offset ] = color.r * color.r * intensitySq;
|
|
|
- array[ offset + 1 ] = color.g * color.g * intensitySq;
|
|
|
- array[ offset + 2 ] = color.b * color.b * intensitySq;
|
|
|
+ array[ offset ] = Math.pow( color.r * intensity, this.gammaFactor );
|
|
|
+ array[ offset + 1 ] = Math.pow( color.g * intensity, this.gammaFactor );
|
|
|
+ array[ offset + 2 ] = Math.pow( color.b * intensity, this.gammaFactor );
|
|
|
|
|
|
}
|
|
|
|
|
@@ -5233,9 +5234,9 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
|
|
|
|
if ( _this.gammaInput ) {
|
|
|
|
|
|
- r += color.r * color.r;
|
|
|
- g += color.g * color.g;
|
|
|
- b += color.b * color.b;
|
|
|
+ r += Math.pow( color.r, this.gammaFactor );
|
|
|
+ g += Math.pow( color.g, this.gammaFactor );
|
|
|
+ b += Math.pow( color.b, this.gammaFactor );
|
|
|
|
|
|
} else {
|
|
|
|
|
@@ -5264,7 +5265,7 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
|
|
|
|
if ( _this.gammaInput ) {
|
|
|
|
|
|
- setColorGamma( dirColors, dirOffset, color, intensity * intensity );
|
|
|
+ setColorGamma( dirColors, dirOffset, color, intensity );
|
|
|
|
|
|
} else {
|
|
|
|
|
@@ -5284,7 +5285,7 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
|
|
|
|
if ( _this.gammaInput ) {
|
|
|
|
|
|
- setColorGamma( pointColors, pointOffset, color, intensity * intensity );
|
|
|
+ setColorGamma( pointColors, pointOffset, color, intensity );
|
|
|
|
|
|
} else {
|
|
|
|
|
@@ -5312,7 +5313,7 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
|
|
|
|
if ( _this.gammaInput ) {
|
|
|
|
|
|
- setColorGamma( spotColors, spotOffset, color, intensity * intensity );
|
|
|
+ setColorGamma( spotColors, spotOffset, color, intensity );
|
|
|
|
|
|
} else {
|
|
|
|
|
@@ -5361,10 +5362,8 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
|
|
|
|
if ( _this.gammaInput ) {
|
|
|
|
|
|
- intensitySq = intensity * intensity;
|
|
|
-
|
|
|
- setColorGamma( hemiSkyColors, hemiOffset, skyColor, intensitySq );
|
|
|
- setColorGamma( hemiGroundColors, hemiOffset, groundColor, intensitySq );
|
|
|
+ setColorGamma( hemiSkyColors, hemiOffset, skyColor, intensity );
|
|
|
+ setColorGamma( hemiGroundColors, hemiOffset, groundColor, intensity );
|
|
|
|
|
|
} else {
|
|
|
|